The ddi_umem_lock(9F) 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 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).
To unlock the locked pages, the drivers call ddi_umem_unlock(9F) with the cookie obtained from ddi_umem_lock(9F).
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).
|