Coarse grained memory allocation, in C.
Coarse grained memory allocation, in C.
#include <stdio.h>
static int allocate_mem(unsigned long size_in_bytes, unsigned long flags,
void **virt_addr)
{
int r;
return r;
*virt_addr = 0;
flags & L4RE_MA_SUPER_PAGES
{
return r;
}
return 0;
}
static int free_mem(void *virt_addr)
{
int r;
return r;
return 0;
}
int main(void)
{
void *virt;
return 1;
printf("Allocated memory.\n");
printf("Touched memory.\n");
if (free_mem(virt))
return 2;
printf("Freed and done. Bye.\n");
return 0;
}
Capability allocator C interface.
l4_cap_idx_t l4re_ds_t
Dataspace type.
long l4re_ma_alloc(long size, l4re_ds_t const mem, unsigned long flags) L4_NOTHROW
Allocate memory.
int l4re_rm_attach(void **start, unsigned long size, l4re_rm_flags_t flags, l4re_ds_t mem, l4re_rm_offset_t offs, unsigned char align) L4_NOTHROW
Attach a data space to a region.
int l4re_rm_detach_ds(void *addr, l4re_ds_t *ds) L4_NOTHROW
Detach and unmap a region and return affected dataspace in the current task.
@ L4RE_RM_F_SEARCH_ADDR
Search for a suitable address range.
void l4re_util_cap_free_um(l4_cap_idx_t cap) L4_NOTHROW
Return capability index to capability allocator, and unmaps the object.
l4_cap_idx_t l4re_util_cap_alloc(void) L4_NOTHROW
Get free capability index at capability allocator.
unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is the invalid capability.
#define L4_SUPERPAGESHIFT
Size of a large page, log2-based.
l4_addr_t l4_trunc_page(l4_addr_t address) L4_NOTHROW
Round an address down to the next lower page boundary.
#define L4_PAGESIZE
Minimal page size (in bytes).
#define L4_PAGESHIFT
Size of a page, log2-based.
Memory allocator C interface.
Region map interface, C interface.