Loading...
Searching...
No Matches
L4Re::Mem_alloc Class Reference

Memory allocation interface. More...

`#include <mem_alloc>`

Inheritance diagram for L4Re::Mem_alloc:
Collaboration diagram for L4Re::Mem_alloc:

## Data Structures

struct | Stats
| Statistics about memory-allocator. More...

## Public Types

enum | Mem_alloc_flags { Continuous = 0x01 , Pinned = 0x02 , Super_pages = 0x04 , Fixed_paddr = 0x08 }
| Flags for the allocator. More...

## Public Member Functions

long | alloc (long size, L4::Cap< Dataspace > mem, unsigned long flags=0, unsigned long align=0, l4_addr_t paddr=0) const noexcept
| Allocate anonymous memory.
long | info (Stats &stats)
| Get allocator information.
Public Member Functions inherited from L4::Factory
S | create (Cap< void > target, long obj, l4_utcb_t *utcb=l4_utcb()) noexcept
| Generic create call to the factory.
template<typename OBJ>
S | create (Cap< OBJ > target, l4_utcb_t *utcb=l4_utcb()) noexcept
| Create call for typed capabilities.
l4_msgtag_t | create_task (Cap< Task > const &target_cap, l4_fpage_t *utcb_area, l4_utcb_t *utcb=l4_utcb()) noexcept
| Create a new task.
l4_msgtag_t | create_factory (Cap< Factory > const &target_cap, unsigned long limit, l4_utcb_t *utcb=l4_utcb()) noexcept
| Create a new factory.
l4_msgtag_t | create_gate (Cap< void > const &target_cap, Cap< Snd_destination > const &snd_dst_cap, l4_umword_t label, l4_utcb_t *utcb=l4_utcb()) noexcept
| Create a new IPC gate, optionally bound to a send destination (a thread or thread group).
l4_msgtag_t | create_thread_group (Cap< Thread_group > const &target_cap, unsigned policy, l4_utcb_t *utcb=l4_utcb()) noexcept
| Create a new thread group.
Public Member Functions inherited from L4::Kobject
l4_msgtag_t | dec_refcnt (l4_mword_t diff, l4_utcb_t *utcb=l4_utcb())
| Decrement the in kernel reference counter for the object.

## Additional Inherited Members

Protected Types inherited from L4::Kobject_t< Mem_alloc, L4::Factory, L4RE_PROTO_MEM_ALLOC >
typedef Mem_alloc | Class
| The target interface type (inheriting from Kobject_t).
typedef Typeid::Iface< PROTO, Mem_alloc > | __Iface
| The interface description for the derived class.
typedef Typeid::Merge_list< Typeid::Iface_list< __Iface >, typename L4::Factory::__Iface_list > | __Iface_list
| The list of all RPC interfaces provided directly or through inheritance.
Protected Types inherited from L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY >
typedef Factory | Class
| The target interface type (inheriting from Kobject_t).
typedef Typeid::Iface< PROTO, Factory > | __Iface
| The interface description for the derived class.
typedef Typeid::Merge_list< Typeid::Iface_list< __Iface >, typename Kobject::__Iface_list > | __Iface_list
| The list of all RPC interfaces provided directly or through inheritance.
Protected Member Functions inherited from L4::Kobject_t< Mem_alloc, L4::Factory, L4RE_PROTO_MEM_ALLOC >
L4::Cap< Class > | c () const noexcept
| Get the capability to ourselves.
Protected Member Functions inherited from L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY >
L4::Cap< Class > | c () const noexcept
| Get the capability to ourselves.
Protected Member Functions inherited from L4::Kobject
l4_cap_idx_t | cap () const noexcept
| Return capability selector.
Static Protected Member Functions inherited from L4::Kobject_t< Mem_alloc, L4::Factory, L4RE_PROTO_MEM_ALLOC >
static void | __check_protocols__ () noexcept
| Helper to check for protocol conflicts.
Static Protected Member Functions inherited from L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY >
static void | __check_protocols__ () noexcept
| Helper to check for protocol conflicts.

## Detailed Description

Memory allocation interface.

The memory-allocator API is the basic API to allocate memory from the L4Re subsystem. The memory is allocated in terms of dataspaces (see L4Re::Dataspace). The provided dataspaces have at least the property that data written to such a dataspace is available as long as the dataspace is not freed or the data is not overwritten. In particular, the memory backing a dataspace from an allocator need not be allocated instantly, but may be allocated lazily on demand.

A memory allocator can provide dataspaces with additional properties, such as physically contiguous memory, pre-allocated memory, or pinned memory. To request memory with an additional property the L4Re::Mem_alloc::alloc() method provides a flags parameter. If the concrete implementation of a memory allocator does not support or allow allocation of memory with a certain property, the allocation may be refused.

Definition at line 52 of file mem_alloc.

## Member Enumeration Documentation

## Mem_alloc_flags

enum L4Re::Mem_alloc::Mem_alloc_flags

Flags for the allocator.

They describe requested properties of the allocated memory. Support of these properties by the dataspace provider is optional.

Enumerator
Continuous | Allocate physically contiguous memory.
Pinned | Deprecated, use L4Re::Dma_space instead.
Super_pages | Allocate super pages.
Fixed_paddr | Allocate at fixed physical address. Only honored on no-MMU systems. Will fail on MMU systems.

Definition at line 62 of file mem_alloc.

## Member Function Documentation

## alloc()

long L4Re::Mem_alloc::alloc | ( | long | size,
|  | L4::Cap< Dataspace > | mem,
|  | unsigned long | flags = 0,
|  | unsigned long | align = 0,
|  | l4_addr_t | paddr = 0 ) const

noexcept

Allocate anonymous 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.

  [out] | mem | Capability slot where the capability to the dataspace is received.
  | flags | Special dataspace properties, see Mem_alloc_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
  | paddr | The physical address where the dataspace should be allocated if Mem_alloc_flags::Fixed flag is set.

Return values

  0 | Success
  -L4_ERANGE | Given size not supported.
  -L4_ENOMEM | Not enough memory available.
  <0 | IPC error

Definition at line 24 of file mem_alloc_impl.h.

References L4::Kobject::cap(), Fixed_paddr, and l4_error().

Here is the call graph for this function:

## info()

long L4Re::Mem_alloc::info | ( | Stats & | stats | ) |

Get allocator information.

Parameters

  [out] | stats | Allocator information

Return values

  0 | Success
  <0 | IPC error

References info(), and L4_INLINE_RPC.

Referenced by info().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- l4/re/mem_alloc
- l4/re/impl/mem_alloc_impl.h