KMEM(9) 386BSD Kernel Programmer's Manual KMEM(9)
NAME
kmem - primary kernel memory / address space management functions
SYNOPSIS
#include "vm.h"
#include "kmem.h"
#include "malloc.h"
vm_offset_t
kmemalloc(vm_map_t map, vm_size_t size, int flags)
void
kmemfree(vm_map_t map, vm_offset_t addr),vm_size_t size
vm_map_t
kmemsuballoc(vm_size_t size, boolean_t pageable)
vm_offset_t
kmemmmap(vm_map_t map, vm_offset_t addr, vm_size_t size)
vm_offset_t
kmemphys(vm_offset_t kva)
DESCRIPTION
Kernel program memory in the 386BSD kernel is managed by the "kmem"
facility, which allows for shared used by kernel threads of portions of
kernel memory (or address space). It is an interface to the virtual
memory system as a way to allocate its resources for application in the
kernel.
The kmemalloc() function allocates page-granularity uninitialized space
for an object whose size is specified by size from the address space or
subspace specified by map. Either memory or just address space
reservation can be allocated. If no resource is available, kmemalloc()
can optionally wait indefinitely for the resource to become available
with the M_WAITOK option passed via the flags (note that this allocator
can be also used from interrupt level without the blocking flag). Since
this function is used by the kernel malloc(9) allocator, both share the
same option flags.
kmemfree() is called to return the resource to the free pool. Since
static array elements are consumed with certain maps (kmem_map),
indefinite allocation is not always possible.
The kmemsuballoc() function is used to create a subspace map within the
kernel for independant management. It reserves a portion of the kernel
address space for sole use by requestors using the allocated subspace map
as an argument.
The kmemmmap() function is used to remap a region of the current process
into the kernel memory (not unlike the mmap(2) system call), allowing
access to the processes memory region globally. The user address space
mapped at addr and for length size is mapped into the kernel within the
address space (or subspace) map.
The kmemphys() function returns the physical address associated with the
kva address in the kernel.
RETURN VALUES
The kmemmalloc() function returns a address of the allocated resource if
successful; otherwise a null address is returned. The kmemsuballoc()
function returns a new map instance as a handle to be used in memory
allocation from that subspace, otherwise it returns a null value. The
kmemmmap() function returns an address of where the requested contents
of a process may be located in the kernel program's address space. The
kmemphys() function returns the physical address or the null address if
ther is no page.
SEE ALSO
malloc(9), free(9), mmap(2), pageout(9)
386BSD Release 1.0 August 29, 1994 2