Loading...
Searching...
No Matches
Memory allocator
L4Re C Interface

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

enum l4re_ma_flags

Flags for requesting memory at the memory allocator.

See also
  L4Re::Mem_alloc::Mem_alloc_flags

Definition at line 32 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

  size

  Size 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.

  mem | Capability slot where the capability to the dataspace is received.
  flags | Special dataspace properties, see l4re_ma_flags

Return values

  0 | Success
  -L4_ERANGE | Given size not supported.
  -L4_ENOMEM | Not enough memory available.
  <0 | IPC 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 136 of file mem_alloc.h.

References L4_NOTHROW, l4re_ds_t, and l4re_ma_alloc_align_srv().

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

  size

  Size 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.

  mem | Capability slot where the capability to the dataspace is received.
  flags | Special dataspace properties, see l4re_ma_flags
  align | Log2 alignment of dataspace if supported by allocator, will be at least L4_PAGESHIFT, with Super_pages flag set at least L4_SUPERPAGESHIFT

Return values

  0 | Success
  -L4_ERANGE | Given size not supported.
  -L4_ENOMEM | Not enough memory available.
  <0 | IPC 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 144 of file mem_alloc.h.

References L4_NOTHROW, l4re_ds_t, and l4re_ma_alloc_align_srv().

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

  srv | Memory allocator service.
  size | Size to be requested.
  mem | Capability slot to put the requested dataspace in
  flags | Flags, see l4re_ma_flags
  align | Log2 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.

References L4_CV, L4_INLINE, L4_NOTHROW, and l4re_ds_t.

Referenced by l4re_ma_alloc(), and l4re_ma_alloc_align().

Here is the caller graph for this function: