L4Re - L4 Runtime Environment
L4Re::Mem_alloc Class Reference

Memory allocation interface. More...

+ 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 }
 Flags for the allocator. More...
 

Public Member Functions

long alloc (long size, L4::Cap< Dataspace > mem, unsigned long flags=0, unsigned long align=0) const throw ()
 Allocate anonymous memory. More...
 
long free (L4::Cap< Dataspace > mem) const throw ()
 Free dataspace. More...
 
- Public Member Functions inherited from L4::Factory
S create (Cap< void > target, long obj, l4_utcb_t *utcb=l4_utcb()) throw ()
 Generic create call to the factory. More...
 
template<typename OBJ >
S create (Cap< OBJ > target, l4_utcb_t *utcb=l4_utcb()) throw ()
 Create call for typed capabilities. More...
 
l4_msgtag_t create_task (Cap< Task > const &target_cap, l4_fpage_t const &utcb_area, l4_utcb_t *utcb=l4_utcb()) throw ()
 Create a new task. More...
 
l4_msgtag_t create_thread (Cap< Thread > const &target_cap, l4_utcb_t *utcb=l4_utcb()) throw ()
 Create a new thread. More...
 
l4_msgtag_t create_factory (Cap< Factory > const &target_cap, unsigned long limit, l4_utcb_t *utcb=l4_utcb()) throw ()
 Create a new factory. More...
 
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()) throw ()
 Create a new IPC gate. More...
 
l4_msgtag_t create_irq (Cap< Irq >const &target_cap, l4_utcb_t *utcb=l4_utcb()) throw ()
 Create a new IRQ. More...
 
l4_msgtag_t create_vm (Cap< Vm >const &target_cap, l4_utcb_t *utcb=l4_utcb()) throw ()
 Create a new virtual machine. More...
 
- 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. More...
 

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 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, L4::PROTO_EMPTY >
L4::Cap< Classc () const
 Get the capability to ourselves.
 
- Protected Member Functions inherited from L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY >
L4::Cap< Classc () const
 Get the capability to ourselves.
 
- Protected Member Functions inherited from L4::Kobject
l4_cap_idx_t cap () const throw ()
 Return capability selector. More...
 
- Static Protected Member Functions inherited from L4::Kobject_t< Mem_alloc, L4::Factory, L4::PROTO_EMPTY >
static void __check_protocols__ ()
 Helper to check for protocol conflicts.
 
- Static Protected Member Functions inherited from L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY >
static void __check_protocols__ ()
 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.

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 
) const
throw (
)

Allocate anonymous memory.

Parameters
sizeSize in bytes to be requested (granularity is (super)pages and the size is rounded up to this granularity). 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
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::Factory::create(), and l4_error().

+ Here is the call graph for this function:

◆ free()

long L4Re::Mem_alloc::free ( L4::Cap< Dataspace mem) const
throw (
)

Free dataspace.

Parameters
memDataspace to be released.
Return values
0
Deprecated:
This function is an empty stub which remains here for backward compatibility only. Use L4::Task::unmap(mem, L4_FP_DELETE_OBJ) or other similar means to remove a dataspace.

Definition at line 47 of file mem_alloc_impl.h.


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