Specifications
D
evice Driver Programming
17-16
• The application’s buffer must be locked in physical memory; that is, the
buffer must be resident, and the virtual to physical mappings must not be
allowed to change.
• The application must know the physical location of the buffer.
• CPU access and I/O access to the buffer must be coherent.
• The virtual pages containing the buffer must be marked “used” and for
DMA read operations, “modified.”
The userdma(2) system call enables you to ensure that all of these requirements are
met.
It is important to note that it is not necessary to call userdma(2) directly from an
application program that is using a user-level device driver. Userdma is invoked by the
udbufalloc(3X) routine, which a user process calls to create the udbuf_t structure
that is used by most user-level driver I/O routines (see “The udbufalloc(3X) Library Rou-
tine” on page 17-16 for an explanation of this routine). Because a call to userdma(2)
requires entry into the kernel, you should avoid invoking userdma(2) from a user-level
driver’s time-critical I/O routines.
Procedures for using the userdma(2) system call are fully explained in the PowerUX
Programming Guide. Reference information is provided in the corresponding system
manual page.
The udbufalloc(3X) Library Routine 17
The udbufalloc library routine allows a user process to allocate a udbuf_t structure
and prepare a user I/O buffer for DMA operations. The udbuf_t structure describes the
layout in physical memory of an I/O buffer in the process’s virtual address space. The I/O
routines of user-level device drivers written by Concurrent Computer Corporation
personnel are required to use the udbuf_t structure to pass the address of the buffer
where I/0 is to be performed.
NOTE
The udbufalloc routine invokes the userdma(2) system
call. As a result, to use this routine, the calling process must have
the P_PLOCK privilege. (For information on userdma(2), see
“The userdma(2) System Call” on page 17-15.)
The specifications required for using the udbufalloc routine are as follows:
udbuf_t *udbufalloc(buffer
,
size
,
userdma_flags)
char
*
buffer
;
int size
;
int userdma_flags
;
Arguments are defined as follows: