#include <oskit/lmm.h>void lmm_add_region(lmm_t *lmm, lmm_region_t *region, void *addr, oskit_size_t size, lmm_flags_t flags, lmm_pri_t pri);
This function attaches a new memory region to an LMM pool. The region describes a contiguous range of addresses with specific attributes, in which free memory management may need to be done.The caller must supply a structure of type lmm_region_t in which the LMM can store critical state for the region. This structure must remain available for the exclusive use of the LMM for the entire remaining lifetime of the LMM pool to which it is attached. However, the contents of the structure is opaque; client code should not examine or modify its contents directly.
The caller must only ensure that if multiple regions are attached to a single LMM pool, they refer to disjoint address ranges.
Note that this routine does not actually make any free memory available; it merely registers a range of addresses in which free memory might be made available later. Typically this call is followed by one or more calls to lmm_add_free, which actually adds memory blocks to the pool's free memory list.
The act of registering a new region does not cause any of the memory described by that region to be accessed or modified in any way by the LMM; only the lmm_region_t structure itself is modified at this point. The LMM will only access and modify memory that is explicitly added to the free list using lmm_add_free. This means, for example, that it is safe to create a single region with a base of 0 and a size of (oskit_size_t)-1, regardless of what parts of that address range actually contain valid memory.
See Section 15.2 for general information on memory regions.
- lmm
- The LMM pool to which the region should be added.
- region
- A pointer to a structure in which the LMM maintains the critical state representing the region. The initial contents of the structure don't matter; however, the structure must remain available and untouched for the remaining lifetime of the LMM pool to which it is attached.
- addr
- The start address of the region to add. Different regions attached to a single LMM pool must cover disjoint areas of memory.
- size
- The size of the region to add. Must be greater than zero, but no more than (oskit_addr_t)-1 - addr; in other words, the region must not wrap around past the end of the address space.
- flags
- The attribute flags to be associated with the region. Allocation requests will be satisfied from this region only if all of the flags specified in the allocation request are also present in the region's flags word.
- pri
- The allocation priority for the region, as a signed integer. Higher priority regions will be preferred over lower priority regions for satisfying allocations.