udbufalloc(3X)
NAME
udbufalloc, udbuffree − allocate a user-level buffer desciptor
SYNOPSIS
udbuf_t ∗udbufalloc (buffer, size, userdma_flags)
char ∗buffer;
int size;
int userdma_flags;
void udbuffree (udbuf)
udbuf_t ∗udbuf;
DESCRIPTION
udbufalloc and udbuffree provide a simple general-purpose buffer descriptor to provide consistent information across user-level device handlers. udbufalloc returns a pointer to a udbuf_t type structure which provides a description of the physical memory fragmentation of a buffer in user space. udbufalloc expects a pointer to a buffer within a user’s program and the buffer’s size to be provided as arguments. The size of the buffer should be provided in terms of bytes. Additionally, udbufalloc expects some userdma(2) flags to be provided as the third argument. These flags determine the appropriate caching properties for the buffer. See userdma(2) for further information on valid flags.
The argument to udbuffree is a pointer to a udbuf_t type previously allocated by udbufalloc; the memory allocated for the udbuf_t structure will be freed and the cache and memory locks on the user buffer will be returned to their state before the call to udbufalloc.
These routines require that the calling process have plock(2) permission. The udbufalloc(3X) routine calls the userdma(2) system service which imposes several requirements and restrictions for the use of this routine. The user should check the userdma(2) man page for further information.
It is very importantant that the argument passed to the udbuffree(3X) routine be a pointer returned from a udbufalloc(3X) routine.
RETURN VALUE
Udbuffalloc returns a null pointer (0) if there is no available memory to allocate for the buffer descriptor or if the attempt to lock down the user buffer fails. Errno is set to indicate the error.
ERRORS
[ENOMEM] There was not enough memory to allocate a buffer descriptor. For more error codes see userdma(2).
SEE ALSO
CX/UX Programmer’s Reference Manual