udbufalloc(3X) udbufalloc(3X)
NAME
udbufalloc, udbuffree - allocate a user-level buffer descip-
tor
SYNOPSIS
udbuft *udbufalloc (buffer, size, userdmaflags)
char *buffer;
int size;
int userdmaflags;
void udbuffree (udbuf)
udbuft *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 udbuft 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 informa-
tion.
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 avail-
able 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
Page 1 CX/UX Programmer's Reference Manual
udbufalloc(3X) udbufalloc(3X)
buffer descriptor.
For more error codes see userdma(2).
SEE ALSO
userdma(2).
Page 2 CX/UX Programmer's Reference Manual