|
L4Re - L4 Runtime Environment
|
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< Class > | c () const |
| Get the capability to ourselves. | |
Protected Member Functions inherited from L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY > | |
| L4::Cap< Class > | c () 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. | |
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.
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. |
| long L4Re::Mem_alloc::alloc | ( | long | size, |
| L4::Cap< Dataspace > | mem, | ||
| unsigned long | flags = 0, |
||
| unsigned long | align = 0 |
||
| ) | const | ||
| throw | ( | ||
| ) | |||
Allocate anonymous memory.
| size | Size 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] | 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 |
| 0 | Success |
| -L4_ERANGE | Given size not supported. |
| -L4_ENOMEM | Not enough memory available. |
| <0 | IPC 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 dataspace.
| mem | Dataspace to be released. |
| 0 |
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.