|HP-UX Reference > I
HP-UX 11i Version 3: February 2007
iomap — physical I/O address mapping
The iomap mechanism allows the mapping (thus direct access) of physical I/O addresses into the user process address space. For PA-RISC machines, the physical I/O address space begins at 0xf0000000 and extends to 0xffffffff.
The special (device) files for iomap devices are character special files using the dynamic major number allocation scheme.
The minor number for iomap devices is of the form:
The physical I/O address is formed by prefixing 0xAAAA with 0xF, and by appending 0x000 (this forces the I/O address to be page-aligned). The size of the region to be mapped is given by the expression M*(2^S) 4K pages. For example, the minor number for a device starting at 0xf4000000 that occupies 64MB is 0x4000e1.
The iomap driver must be explicitly added to the /stand/system file, the kernel rebuilt, and the system subsequently rebooted prior to first using iomap.
I/O space is always mapped with both read and write access rights, regardless of the actual permissions on the device special file.
Multiple processes can have concurrently a single iomap device opened and mapped. It is the responsibility of the processes to synchronize their access.
Successive calls to iomap to map the same I/O space must be identical to the first mapping. Identical mappings have the same address and size.
Note that a process can additionally share I/O space (mapped by iomap) with a kernel driver. However, this is only possible if the driver maps in the I/O space with user read/write access rights using the appropriate driver I/O mapping services. Any I/O space mapped by drivers with kernel read/write access rights cannot be concurrently mapped by processes using iomap.
No read() or write() system calls are supported by the iomap driver.
The ioctl() function is used to control the iomap device. The following ioctl() requests are defined in <iomap.h>:
close() shuts down the file descriptor associated with the iomap device. If the close is for the last system wide open on the device, the iomap device is also unmapped from the user address space; otherwise it is left mapped into the user address space (see IOMAPUNMAP above).
Be extremely careful when creating and using iomap devices. Inappropriate accesses to I/O devices or RAM can result in a system crash.
Consider the following code fragment:
#include <sys/iomap.h> ... int fildes; void *addr; ... addr = REQUESTED_ADDRESS; (void) ioctl(fildes, IOMAPMAP, &addr); (void) printf("actual address = 0x%x\n", addr);
where fildes is an open file descriptor for the device special file and REQUESTED_ADDRESS is the address originally requested by the program.
If addr is a null pointer, the system selects a suitable address then returns the selected address in addr.
If the value in addr is not a null pointer, it is used as a specified address for allocating memory. If the specified address cannot be used, an error is returned (see ERRORS).