NAME
uvm_km_alloc
,
uvm_km_zalloc
,
uvm_km_alloc1
,
uvm_km_kmemalloc
,
uvm_km_valloc
,
uvm_km_valloc_wait
,
uvm_km_suballoc
,
uvm_km_free
,
uvm_km_free_wakeup
—
raw kernel memory or address space
allocator
SYNOPSIS
#include
<sys/param.h>
#include <uvm/uvm.h>
vaddr_t
uvm_km_alloc
(vm_map_t
map, vsize_t
size);
vaddr_t
uvm_km_zalloc
(vm_map_t
map, vsize_t
size);
vaddr_t
uvm_km_alloc1
(vm_map_t
map, vsize_t size,
vsize_t align,
boolean_t zeroit);
vaddr_t
uvm_km_kmemalloc
(vm_map_t
map, struct uvm_object
*obj, vsize_t size,
int flags);
vaddr_t
uvm_km_valloc
(vm_map_t
map, vsize_t
size);
vaddr_t
uvm_km_valloc_wait
(vm_map_t
map, vsize_t
size);
struct vm_map *
uvm_km_suballoc
(vm_map_t
map, vaddr_t *min,
vaddr_t *max ,
vsize_t size,
int flags,
boolean_t fixed,
vm_map_t submap);
void
uvm_km_free
(vm_map_t
map, vaddr_t addr,
vsize_t size);
void
uvm_km_free_wakeup
(vm_map_t
map, vaddr_t addr,
vsize_t size);
DESCRIPTION
The
uvm_km_alloc
()
and
uvm_km_zalloc
()
functions allocate size bytes of wired kernel memory
in map map. In addition to allocation,
uvm_km_zalloc
() zeros the memory. Both of these
functions are defined as macros in terms of
uvm_km_alloc1
(), and should almost always be used in
preference to uvm_km_alloc1
().
The
uvm_km_alloc1
()
function allocates and returns size bytes of wired
memory in the kernel map aligned to the align
boundary, zeroing the memory if the zeroit argument is
non-zero.
The
uvm_km_kmemalloc
()
function allocates and returns size bytes of wired
kernel memory into obj. The flags can be any of:
#define UVM_KMF_NOWAIT 0x1 /* matches M_NOWAIT */ #define UVM_KMF_VALLOC 0x2 /* allocate VA only */ #define UVM_KMF_TRYLOCK UVM_FLAG_TRYLOCK /* try locking only */
The UVM_KMF_NOWAIT
flag causes
uvm_km_kmemalloc
()
to return immediately if no memory is available.
UVM_KMF_VALLOC
causes no pages to be allocated, only
a virtual address. UVM_KMF_TRYLOCK
causes
uvm_km_kmemalloc
() to only try and not sleep when
locking maps.
The
uvm_km_valloc
()
and
uvm_km_valloc_wait
()
functions return a newly allocated zero-filled address in the kernel map of
size size.
uvm_km_valloc_wait
() will also wait for kernel
memory to become available, if there is a memory shortage.
The
uvm_km_suballoc
()
function allocates submap (with the specified flags,
as described above) from map, creating a new map if
submap is NULL
. The addresses
of the submap can be specified exactly by setting the
fixed argument to non-zero, which causes the
min argument to specify the beginning of the address
in the submap. If fixed is zero, any address of size
size will be allocated from map
and the start and end addresses returned in min and
max.
The
uvm_km_free
()
and
uvm_km_free_wakeup
()
functions free size bytes of memory in the kernel map,
starting at address addr.
uvm_km_free_wakeup
() calls
wakeup
()
on the map before unlocking the map.