Re: How to access physical ISA-memory from kernel space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



+BigNose wrote:

I installed a ISA memory card which has 8K memory at the address E0000.
(embedded system)
But how can I access it?

I read in a book that it should work like that:

#define FRAM_ADDRESS 0xE0000

[ ... ]

fram= (t_FRAM *) FRAM_ADDRESS;

No, this does not work. The kernel speaks virtual addresses, not physical. Given that ISA memory is always mapped on x86, you could in fact access it directly if only using the virtual address (and there are old functions such as isa_readb() which do this) but you should access ISA memory same as all other I/O memory, through io{read,write}{8,16,32) after an ioremap().

Ie, do something like:

  #include <asm/io.h>

  #define PHYSADDR 0xe0000
  #define PHYSSIZE (8 * 1024)

  void *mem = ioremap(PHYSADDR, PHYSSIZE);
  if (!mem) {
	  printk(KERN_ERR "something unthinkable happened\n");
	  return -EINVAL;
  }

  u16 tmp = ioread16(mem);

  iounmap(mem);

Note that while you'll get away with using the value ioremap() returns as a direct pointer on x86, this also not adviced since not necesarily portable -- using ioread/iowrite is adviced.

Rene.






--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux