next up previous contents index
Next: 17.2.3 svm_dealloc: deallocate a Up: 17.2 API reference Previous: 17.2.1 svm_init: initialize SVM

17.2.2 svm_alloc: allocate a region of virtual memory

 

SYNOPSIS

#include <oskit/svm/svm.h>

int svm_alloc(oskit_addr_t *addr, oskit_size_t length, int prot, int flags);

DESCRIPTION

Allocate a region of virtual memory, returning the base address of the new region in addr. The region is length bytes in size, and is initialized to the page level protection specified by prot. The size of the allocation must be an integral number of pages. The caller can optionally specify the (page aligned) base address at which to place the region by providing a non-zero value in addr. The actual base address might differ if the system cannot place the region at that address. Alternatively, if the flags value contains SVM_ALLOC_FIXED, and the region cannot be placed at the requested address, the allocation will fail and return an error code.

PARAMETERS

addr
The location in which to store the base address of the new region. Also used to provide an optional address.
length
The size of the new region in bytes. Must be an integral number of pages.
prot
Page level protection of the new region, composed of SVM_PROT_READ and SVM_PROT_WRITE.
flags
Optional flags.

RETURNS

Returns zero on success. Returns OSKIT_E_INVALIDARG if either the base address or the size of the allocation is not page aligned. Returns OSKIT_E_OUTOFMEMORY if the region cannpt be assigned to the fixed location requested by the caller.

RELATED INFORMATION

svm_dealloc, svm_protect



University of Utah Flux Research Group