Barrelfish
|
Memory manager header. More...
Data Structures | |
struct | mmnode |
Node in Memory manager Btree. Private. More... | |
struct | mm |
Memory manager instance data. More... | |
struct | mem_cap |
Structure to record all information about a given memory region. More... | |
Macros | |
#define | MM_NODE_SIZE(maxchildbits) (sizeof(struct mmnode) + sizeof(struct mmnode *) * (1UL << (maxchildbits))) |
Macro to statically determine size of a node, given the maxchildbits. | |
Enumerations |
Functions | |
void | mm_debug_print (struct mmnode *mmnode, int space) |
Debug printout of the status of all nodes. More... | |
errval_t | mm_init (struct mm *mm, enum objtype objtype, genpaddr_t base, uint8_t sizebits, uint8_t maxchildbits, slab_refill_func_t slab_refill_func, slot_alloc_t slot_alloc_func, slot_refill_t slot_refill_func, void *slot_alloc_inst, bool delete_chunked) |
Initialise a memory manager instance. More... | |
void | mm_destroy (struct mm *mm) |
Destroy a memory manager instance. More... | |
errval_t | mm_add (struct mm *mm, struct capref cap, uint8_t sizebits, genpaddr_t base) |
Add a new region to the memory manager. More... | |
errval_t | mm_add_multi (struct mm *mm, struct capref cap, gensize_t size, genpaddr_t base) |
Add a new region to the memory manager. The region does not need to be power-of-two sized or aligned. More... | |
errval_t | mm_alloc (struct mm *mm, uint8_t sizebits, struct capref *retcap, genpaddr_t *retbase) |
Allocate an arbitrary memory region of a given size. More... | |
errval_t | mm_alloc_range (struct mm *mm, uint8_t sizebits, genpaddr_t minbase, genpaddr_t maxlimit, struct capref *retcap, genpaddr_t *retbase) |
Allocate memory region of a given size within a given address range. More... | |
errval_t | mm_realloc_range (struct mm *mm, uint8_t sizebits, genpaddr_t base, struct capref *retcap) |
Return cap to a specific region, that may be partially allocated. More... | |
errval_t | mm_free (struct mm *mm, struct capref cap, genpaddr_t base, uint8_t sizebits) |
Free an allocated region. More... | |
size_t | mm_relinquish_all (struct mm *mm, struct mem_cap *ret, size_t retlen) |
Fills an array with metadata for all free regions. More... | |
size_t | mm_relinquish_range (struct mm *mm, genpaddr_t base, genpaddr_t limit, struct mem_cap *ret, size_t retlen) |
Fills an array with metadata for all free regions within a given range. More... | |
Memory manager header.
enum nodetype |
Add a new region to the memory manager.
It is an error if any part of the region has already been added, or the region doesn't fit within the base and size specified for the allocator.
mm | Memory manager instance |
cap | Capability to newly-added region |
sizebits | Size of region |
base | Physical base address of region |
Add a new region to the memory manager. The region does not need to be power-of-two sized or aligned.
It is an error if any part of the region has already been added, or the region doesn't fit within the base and size specified for the allocator.
mm | Memory manager instance |
cap | Capability to newly-added region |
size | Size of region |
base | Physical base address of region |
errval_t mm_alloc | ( | struct mm * | mm, |
uint8_t | sizebits, | ||
struct capref * | retcap, | ||
genpaddr_t * | retbase | ||
) |
Allocate an arbitrary memory region of a given size.
mm | Memory manager instance |
sizebits | Size of requested region |
retcap | Pointer to capref struct, to be filled-in |
retbase | If non-NULL, the base address of the allocated region is returned here |
errval_t mm_alloc_range | ( | struct mm * | mm, |
uint8_t | sizebits, | ||
genpaddr_t | minbase, | ||
genpaddr_t | maxlimit, | ||
struct capref * | retcap, | ||
genpaddr_t * | retbase | ||
) |
Allocate memory region of a given size within a given address range.
If this call succeeds, it must be the case that: *retbase >= minbase && *retbase + (1UL << sizebits) <= maxlimit
mm | Memory manager instance |
sizebits | Size of requested region |
minbase | Minimum base address of region to allocate |
maxlimit | Maximum limit address of region to allocate |
retcap | Pointer to capref struct, to be filled-in |
retbase | If non-NULL, the base address of the allocated region is returned here |
void mm_debug_print | ( | struct mmnode * | mmnode, |
int | space | ||
) |
Debug printout of the status of all nodes.
mmnode | Struct mmnode to print from |
space | Call with 0, used to track depth for pretty printing |
void mm_destroy | ( | struct mm * | mm | ) |
Destroy a memory manager instance.
mm | Memory manager instance |
Free an allocated region.
Marks the region (which must previously have been allocated) as free.
mm | Memory manager instance |
cap | Cap to re-insert (specify NULL_CAP if delete_chunked == false) |
base | Physical base address of region |
sizebits | Size of region |
errval_t mm_init | ( | struct mm * | mm, |
enum objtype objtype | , | ||
genpaddr_t | base, | ||
uint8_t | sizebits, | ||
uint8_t | maxchildbits, | ||
slab_refill_func_t | slab_refill_func, | ||
slot_alloc_t | slot_alloc_func, | ||
slot_refill_t | slot_refill_func, | ||
void * | slot_alloc_inst, | ||
bool | delete_chunked | ||
) |
Initialise a memory manager instance.
mm | Pointer to memory manager instance, to be filled-in |
objtype | Kernel object type to be managed |
base | Base address of region to be managed |
sizebits | Size (in bits) of region to be managed |
maxchildbits | Maximum number of children (in bits) at each node |
slab_refill_func | Function to be used to refill slab allocator If this is NULL, the caller must provide static storage with slab_grow. |
slot_alloc_func | Slot allocator function |
slot_refill_func | Slot allocator refill function |
slot_alloc_inst | Slot allocator opaque instance pointer |
delete_chunked | Whether to delete chunked caps |
errval_t mm_realloc_range | ( | struct mm * | mm, |
uint8_t | sizebits, | ||
genpaddr_t | base, | ||
struct capref * | retcap | ||
) |
Return cap to a specific region, that may be partially allocated.
The parameters to this function specify a fixed memory region (base and size) that may overlap one or more already-allocated memory regions. It marks the entire region as allocated, returning a cap to it.
mm | Memory manager instance |
sizebits | Size of region |
base | Base address of region |
retcap | Pointer to capref struct, to be filled-in |
Fills an array with metadata for all free regions.
The regions returned are marked as allocated.
mm | Memory manager instance |
ret | Pointer to return array to be filled-in |
retlen | Length of the array, in slots |
size_t mm_relinquish_range | ( | struct mm * | mm, |
genpaddr_t | base, | ||
genpaddr_t | limit, | ||
struct mem_cap * | ret, | ||
size_t | retlen | ||
) |
Fills an array with metadata for all free regions within a given range.
The regions returned are marked as allocated.
It must be the case for every returned cap (i) that: ret[i]->base >= base && ret[i]->base + (1UL << ret[i]->sizebits) <= limit
mm | Memory manager instance |
base | Base address of range from which to relinquish memory |
limit | Limit address of range from which to relinquish memory |
ret | Pointer to return array to be filled-in |
retlen | Length of the array, in slots |