L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
Memory allocator

Memory allocator C interface. More...

+ Collaboration diagram for Memory allocator:

Enumerations

enum  l4re_ma_flags
 Flags for requesting memory at the memory allocator. More...
 

Functions

long l4re_ma_alloc (long size, l4re_ds_t const mem, unsigned long flags) L4_NOTHROW
 Allocate memory.
 
long l4re_ma_alloc_align (long size, l4re_ds_t const mem, unsigned long flags, unsigned long align) L4_NOTHROW
 Allocate memory.
 
long l4re_ma_alloc_align_srv (l4_cap_idx_t srv, long size, l4re_ds_t const mem, unsigned long flags, unsigned long align) L4_NOTHROW
 Allocate memory.
 

Detailed Description

Memory allocator C interface.

Enumeration Type Documentation

◆ l4re_ma_flags

Flags for requesting memory at the memory allocator.

See also
L4Re::Mem_alloc::Mem_alloc_flags

Definition at line 42 of file mem_alloc.h.

Function Documentation

◆ l4re_ma_alloc()

long l4re_ma_alloc ( long  size,
l4re_ds_t const  mem,
unsigned long  flags 
)
inline

Allocate memory.

Parameters
sizeSize in bytes to be requested. Allocation granularity is (super)pages, however, the allocator will store the byte-granular given size as the size of the dataspace and consecutively will use this byte-granular size for servicing the dataspace. Allocators may optionally also implement a maximum allocation strategy: if size is a negative value and flags set the Mem_alloc_flags::Continuous bit, the allocator tries to allocate as much memory as possible leaving an amount of at least -size bytes within the associated quota.
memCapability slot where the capability to the dataspace is received.
flagsSpecial dataspace properties, see l4re_ma_flags
Return values
0Success
-L4_ERANGEGiven size not supported.
-L4_ENOMEMNot enough memory available.
<0IPC error
See also
L4Re::Mem_alloc::alloc

The memory allocator returns a dataspace.

Note
This function is using the L4Re::Env::env()->mem_alloc() service.
Examples
examples/libs/l4re/c/ma+rm.c.

Definition at line 146 of file mem_alloc.h.

References l4re_ma_alloc_align_srv(), and l4re_env_t::mem_alloc.

+ Here is the call graph for this function:

◆ l4re_ma_alloc_align()

long l4re_ma_alloc_align ( long  size,
l4re_ds_t const  mem,
unsigned long  flags,
unsigned long  align 
)
inline

Allocate memory.

Parameters
sizeSize in bytes to be requested. Allocation granularity is (super)pages, however, the allocator will store the byte-granular given size as the size of the dataspace and consecutively will use this byte-granular size for servicing the dataspace. Allocators may optionally also implement a maximum allocation strategy: if size is a negative value and flags set the Mem_alloc_flags::Continuous bit, the allocator tries to allocate as much memory as possible leaving an amount of at least -size bytes within the associated quota.
memCapability slot where the capability to the dataspace is received.
flagsSpecial dataspace properties, see l4re_ma_flags
alignLog2 alignment of dataspace if supported by allocator, will be at least L4_PAGESHIFT, with Super_pages flag set at least L4_SUPERPAGESHIFT
Return values
0Success
-L4_ERANGEGiven size not supported.
-L4_ENOMEMNot enough memory available.
<0IPC error
See also
L4Re::Mem_alloc::alloc and
l4re_ma_alloc

The memory allocator returns a dataspace.

Note
This function is using the L4Re::Env::env()->mem_alloc() service.

Definition at line 154 of file mem_alloc.h.

References l4re_ma_alloc_align_srv(), and l4re_env_t::mem_alloc.

+ Here is the call graph for this function:

◆ l4re_ma_alloc_align_srv()

long l4re_ma_alloc_align_srv ( l4_cap_idx_t  srv,
long  size,
l4re_ds_t const  mem,
unsigned long  flags,
unsigned long  align 
)

Allocate memory.

Parameters
srvMemory allocator service.
sizeSize to be requested.
memCapability slot to put the requested dataspace in
flagsFlags, see l4re_ma_flags
alignLog2 alignment of dataspace if supported by allocator, will be at least L4_PAGESHIFT, with Super_pages flag set at least L4_SUPERPAGESHIFT, default 0
Returns
0 on success, <0 on error
See also
L4Re::Mem_alloc::alloc

The memory allocator returns a dataspace.

Referenced by l4re_ma_alloc(), and l4re_ma_alloc_align().

+ Here is the caller graph for this function: