| VMEM_ALLOC(9F) | Kernel Functions for Drivers | VMEM_ALLOC(9F) | 
vmem_alloc,
    vmem_xalloc, vmem_free,
    vmem_xfree — allocate and
    free segments from a vmem arena
#include
    <sys/vmem.h>
void *
  
  vmem_alloc(vmem_t *vmp,
    size_t size, int vmflag);
void *
  
  vmem_xalloc(vmem_t *vmp,
    size_t size, size_t align_arg,
    size_t phase, size_t nocross,
    void *minaddr, void *maxaddr,
    int vmflag);
void
  
  vmem_free(vmem_t *vmp,
    void *vaddr, size_t size);
void
  
  vmem_xfree(vmem_t *vmp,
    void *vaddr, size_t size);
illumos DDI specific
VM_SLEEP or
      VM_NOSLEEP must be specified, and indicate whether
      the allocation may block. A VM_SLEEP allocation
      can never fail but may block indefinitely.
    The allocation policy may be specified by one of the following flags:
VM_BESTFITVM_FIRSTFITVM_NEXTFITVMC_IDENTIFIER arena.VM_ENDALLOCVM_BESTFIT,
          VM_FIRSTFIT or the default policy to indicate
          that the higher addresses should be preferred.The default (unnamed) allocation policy is “instant
        fit”, an approximation of VM_BESTFIT in
        guaranteed constant time.
vmem_free()
      or
      vmem_xfree()
      should free.The
    vmem_alloc()
    and vmem_xalloc() functions allocate a segment of
    size length from the vmem arena
    vmp.
The vmflag argument controls the behaviour of the allocation, as described in PARAMETERS.
For allocations with complex requirements, such
    as those used for DMA
    vmem_xalloc()
    takes additional arguments allowing those requirements to be expressed.
Segments allocated with
    vmem_xalloc()
    must always be freed with
    vmem_xfree(),
    since these allocations are uncached.
This function can be called from either user or kernel context. If
    the VM_NOSLEEP flag is specified, it may also be
    called from interrupt context.
Upon successful completion the
    vmem_alloc() and
    vmem_xalloc() functions return a pointer to the
    beginning of the allocated segment. In the case of a
    VMC_IDENTIFIER arena, the address of this pointer is
    the meaningful component, not the value to which it points.
On failure, NULL is returned. When the
    VM_SLEEP flag is specified, these functions can
    never fail (but may block forever).
| January 18, 2017 | OmniOS |