Next | Prev | Up | Top | Contents | Index

Using the mmap Operating System Function

A user-level driver may access a generic EISA device by opening the appropriate /dev/eisa special file, followed by an mmap() call to map in the device. For example:

int fd, len, off;
char *addr;
fd=open("/dev/eisa/eisa0io", O_RDWR);
len=4096;
off=0x1000;
addr=mmap(0, len, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, off);
 .
 .
 .
/* addr can be used to access any card register by adding the 
 * appropriate offset and then dereferencing the pointer
 */
 .
 .
 .
Note that in the example above, the offset starts at 0X1000, which is the base address of the first EISA slot. On Indigo2 systems, the slots are numbered in ascending order from top to bottom (that is, slot one is the top and slot four is on the bottom.). See the mmap(D2) man page for a complete description of this system call.

The mmap() routine maps len bytes starting at EISA address off to the user virtual address addr. Any loads or stores to the address range addr to addr+len will result in read or writes to the EISA I/O space.

Note: You are responsible for identifying the offset to reference each device on a slot-specific basis. The offset must be incremented by 4096 to reference the next EISA card's I/O space; the offset to an ISA card is its ISA address.


Next | Prev | Up | Top | Contents | Index