support virtual mapping for memory-mapped device
ppid_t prefixmmap(void *idata, channel_t channel,
size_t offset, int prot);
entry point is called to provide
direct user access to memory for memory-mapped devices.
A memory-mapped device has memory that can be mapped
into a process's address space.
system call, when applied to
a device special file, allows this device memory to be mapped
into user space for direct access by the user application.
This avoids overhead from kernel buffering and system calls.
This entry point maps one page,
at the specified relative logical offset
within the device's memory.
This offset space may be different
from offsets used for normal I/O;
therefore, it is the driver's responsibility
to validate offsets.
For hardware drivers,
a pointer to the device-specific instance
as returned by the CFG_ADD subfunction of the
entry point routine.
For software-only drivers,
idata is unused and undefined.
``Device instance'' in HDK Technical Reference.
Channel number used to select subcomponents
and/or operating modes of this device instance.
``Channel number'' in HDK Technical Reference.
Byte offset within the driver's mappable memory
for this device instance.
This value must be a multiple of ptob(1)
function passed the value of 1,
which returns the size of a page, in bytes).
If the protection and offset are valid for the device, the
driver should return the physical page ID
as returned by
Otherwise, NOPAGE should be returned.
This entry point is optional.
If it is not provided,
attempts fail with the ENODEV error number.
This entry point is called only when the device is open.
Valid values for prot are:
Page can be read.
Page can be written.
Page can be executed.
Page is accessible from user-level.
All of the above.
A physical page ID is a machine-specific token
that uniquely identifies a page of physical memory
in the system (either kernel memory or device memory).
To get the physical page ID for a given virtual address,
To get the physical page ID for a given physical address,
No assumptions should be made about
the format of a physical page ID.
the mapping remains in use until
the device instance is closed,
which is the next last close for this device instance.
Any memory so mapped must not be freed
until after the device instance is closed.
Context and synchronization
The driver can block and can do operations such as
that require access to
the requesting process's user-level address space.
1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp, 8, 8mp
Differences between versions
The syntax for
in DDI versions prior to version 8 is:
int prefixmmap(dev_t dev, off_t offset, int prot);
the device number for the device to be mapped.
In DDI versions prior to version 8,
is only available to character device drivers
and is a named entry point,
so must be defined as a global symbol.
For DDI 8 and later versions,
drivers must declare this entry point routine
d_mmap member of their
Named entry point routines must be declared
in the driver's
The declaration for this entry point is
This applies only to non-STREAMS drivers
that use DDI versions prior to version 8.
``Memory-mapped I/O'' in HDK Technical Reference
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005