Logical memory blocks
-
LMB_NONE
LMB_NONE ()
no special request
Parameters
Description
LMB Memory region attribute flag to indicate that there are no special requests for this region. Normally used as a placeholder value.
-
LMB_NOMAP
LMB_NOMAP ()
do not add to MMU configuration
Parameters
Description
LMB Memory region attribute flag to indicate that the region will not be mapped by LMB. Normally used for reserved regions.
-
LMB_NOOVERWRITE
LMB_NOOVERWRITE ()
do not overwrite/re-reserve
Parameters
Description
LMB Memory region attribute flag to indicate that the region will not be overwritten or re-reserved. Normally used for reserved regions.
-
LMB_NONOTIFY
LMB_NONOTIFY ()
do not notify other modules of changes
Parameters
Description
LMB Memory region attribute flag to indicate that the region will not notify downstream allocators (currently just the EFI allocator) of changes to this region through lmb_map_update_notify().
-
enum lmb_map_op
memory map operation
Constants
LMB_MAP_OP_RESERVEreserve memory
LMB_MAP_OP_FREEfree memory
LMB_MAP_OP_ADDadd memory
-
struct lmb_region
Description of one region
Definition
struct lmb_region {
phys_addr_t base;
phys_size_t size;
u32 flags;
};
Members
baseBase address of the region
sizeSize of the region
flagsMemory region attributes
-
struct lmb
The LMB structure
Definition
struct lmb {
struct alist available_mem;
struct alist used_mem;
bool test;
};
Members
available_memList of memory available to LMB
used_memList of used/reserved memory regions
testIs structure being used for LMB tests
-
int lmb_init(void)
Initialise the LMB module.
Parameters
voidno arguments
Return
0 on success, negative error code on failure.
Description
Initialise the LMB lists needed for keeping the memory map. There are two lists, in form of allocated list data structure. One for the available memory, and one for the used memory. Initialise the two lists as part of board init. Add memory to the available memory list and reserve common areas by adding them to the used memory list.
-
void lmb_add_memory(void)
Add memory range for LMB allocations.
Parameters
voidno arguments
Description
Add the entire available memory range to the pool of memory that can be used by the LMB module for allocations.
-
long lmb_reserve(phys_addr_t base, phys_size_t size, u32 flags)
Reserve one region with a specific flags bitfield
Parameters
phys_addr_t baseBase address of the memory region
phys_size_t sizeSize of the memory region
u32 flagsFlags for the memory region
Return
0- Added successfully, or it’s already added (only if LMB_NONE)-EEXIST- The region is already added, and flags != LMB_NONE-1- Failure
-
phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, uint flags)
Allocate specified memory region with specified attributes
Parameters
phys_size_t sizeSize of the region requested
ulong alignAlignment of the memory region requested
phys_addr_t max_addrMaximum address of the requested region
uint flagsMemory region attributes to be set
Description
Allocate a region of memory with the attributes specified through the parameter. The max_addr parameter is used to specify the maximum address below which the requested region should be allocated.
Return
Base address on success, 0 on error.
-
int lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags)
Allocate specified memory address with specified attributes
Parameters
phys_addr_t baseBase Address requested
phys_size_t sizeSize of the region requested
u32 flagsMemory region attributes to be set
Description
Allocate a region of memory with the attributes specified through the parameter. The base parameter is used to specify the base address of the requested region.
Return
0 on success -1 on error
-
int lmb_is_reserved_flags(phys_addr_t addr, int flags)
Test if address is in reserved region with flag bits set
Parameters
phys_addr_t addrAddress to be tested
int flagsBitmap with bits to be tested
Description
The function checks if a reserved region comprising addr exists which has all flag bits set which are set in flags.
Return
1 if matching reservation exists, 0 otherwise.
-
long lmb_free_flags(phys_addr_t base, phys_size_t size, uint flags)
Free up a region of memory
Parameters
phys_addr_t baseBase Address of region to be freed
phys_size_t sizeSize of the region to be freed
uint flagsMemory region attributes
Return
0 on success, negative error code on failure.
Parameters
struct lmb *io_lmbIO LMB to initialize
Return
0 on success, negative error code on failure.
Parameters
struct lmb *io_lmbIO LMB to teardown
-
long io_lmb_add(struct lmb *io_lmb, phys_addr_t base, phys_size_t size)
Add an IOVA range for allocations
Parameters
struct lmb *io_lmbLMB to add the space to
phys_addr_t baseBase Address of region to add
phys_size_t sizeSize of the region to add
Description
Add the IOVA space [base, base + size] to be managed by io_lmb.
Return
0 on success, negative error code on failure.
-
phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align)
Allocate specified IO memory address with specified alignment
Parameters
struct lmb *io_lmbLMB to alloc from
phys_size_t sizeSize of the region requested
ulong alignRequired address and size alignment
Description
Allocate a region of IO memory. The base parameter is used to specify the base address of the requested region.
Return
Base IO address on success, 0 on error.
-
long io_lmb_free(struct lmb *io_lmb, phys_addr_t base, phys_size_t size)
Free up a region of IOVA space
Parameters
struct lmb *io_lmbLMB to return the IO address space to
phys_addr_t baseBase Address of region to be freed
phys_size_t sizeSize of the region to be freed
Return
0 on success, negative error code on failure.