L4Re Operating System Framework
Interface and Usage Documentation
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:

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.
 
- 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< Thread > const &thread_cap, l4_umword_t label, l4_utcb_t *utcb=l4_utcb()) noexcept
 Create a new IPC gate.
 
- 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, L4::PROTO_EMPTY >
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 Base::__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 Base::__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, L4::PROTO_EMPTY >
L4::Cap< Classc () const noexcept
 Get the capability to ourselves.
 
- Protected Member Functions inherited from L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY >
L4::Cap< Classc () 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, L4::PROTO_EMPTY >
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 61 of file mem_alloc.

Member Enumeration Documentation

◆ 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 71 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
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.
[out]memCapability slot where the capability to the dataspace is received.
flagsSpecial dataspace properties, see Mem_alloc_flags
alignLog2 alignment of dataspace if supported by allocator, will be at least L4_PAGESHIFT, with Super_pages flag set at least L4_SUPERPAGESHIFT
paddrThe physical address where the dataspace should be allocated if Mem_alloc_flags::Fixed flag is set.
Return values
0Success
-L4_ERANGEGiven size not supported.
-L4_ENOMEMNot enough memory available.
<0IPC error

Definition at line 35 of file mem_alloc_impl.h.

References l4_error().

+ Here is the call graph for this function:

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