DDI_UMEM_LOCK(9F) | Kernel Functions for Drivers | DDI_UMEM_LOCK(9F) |
ddi_umem_lock, ddi_umem_unlock - lock and unlock memory pages
#include <sys/ddi.h> #include <sys/sunddi.h> int ddi_umem_lock(caddr_t addr, size_t len, int flags,
ddi_umem_cookie_t *cookiep);
void ddi_umem_unlock(ddi_umem_cookie_t cookie);
illumos DDI specific (illumos DDI)
addr
len
flags
DDI_UMEMLOCK_READ
DDI_UMEMLOCK_WRITE
cookiep
cookie
The ddi_umem_lock() function locks down the physical pages (including I/O pages) that correspond to the current process' virtual address range [addr, addr + size) and fills in a cookie representing the locked pages. This cookie can be used to create a buf(9S) structure that can be used to perform I/O (see ddi_umem_iosetup(9F) and ddi_dma_buf_bind_handle(9F), or it can be used with devmap_umem_setup(9F) to export the memory to an application.
The virtual address and length specified must be at a page boundary and the mapping performed in terms of the system page size. See pagesize(1).
The flags argument indicates the intended use of the locked memory. Set flags to DDI_UMEMLOCK_READ if the memory pages will be read (for example, in a disk write or a network send.) Set flags to DDI_UMEMLOCK_WRITE if the memory pages will be written (for example, in a disk read or a network receive). You must choose one (and only one) of these values.
To unlock the locked pages, the drivers call ddi_umem_unlock(9F) with the cookie obtained from ddi_umem_lock().
The process is not allowed to exec(2) or fork(2) while its physical pages are locked down by the device driver.
The device driver must ensure that the physical pages have been unlocked after the application has called close(2).
On success, a 0 is returned. Otherwise, one of the following errno values is returned.
EFAULT
EACCES
ENOMEM
EAGAIN
EINVAL
The ddi_umem_lock() function can only be called from user context; ddi_umem_unlock() from user, kernel, and interrupt contexts.
ddi_dma_buf_bind_handle(9F), ddi_umem_alloc(9F), ddi_umem_iosetup(9F), devmap_umem_setup(9F)
The ddi_umem_unlock() function consumes physical memory. The driver is responsible for a speedy unlock to free up the resources.
The ddi_umem_unlock() function can defer unlocking of the pages to a later time depending on the implementation.
April 10, 2007 | OmniOS |