26 #define MEMMAP_INLINE( _subsys, _api_func ) \ 27 SINGLE_API_INLINE ( MEMMAP_PREFIX_ ## _subsys, _api_func ) 36 #define PROVIDE_MEMMAP( _subsys, _api_func, _func ) \ 37 PROVIDE_SINGLE_API ( MEMMAP_PREFIX_ ## _subsys, _api_func, _func ) 45 #define PROVIDE_MEMMAP_INLINE( _subsys, _api_func ) \ 46 PROVIDE_SINGLE_API_INLINE ( MEMMAP_PREFIX_ ## _subsys, _api_func ) 60 #define MEMMAP_FL_MEMORY 0x0001 61 #define MEMMAP_FL_RESERVED 0x0002 62 #define MEMMAP_FL_USED 0x0004 63 #define MEMMAP_FL_INACCESSIBLE 0x0008 102 return ( region->
max - region->
min + 1 );
116 #define USED_REGIONS __table ( struct used_region, "used_regions" ) 119 #define __used_region __table_entry ( USED_REGIONS, 01 ) 126 #include <bits/memmap.h> 171 #define for_each_memmap_from( region, start, hide ) \ 172 for ( (region)->min = (start), (region)->max = 0 ; \ 173 ( ( ( (region)->max + 1 ) != 0 ) && \ 174 ( memmap_describe ( (region)->min, (hide), \ 175 (region) ), 1 ) ) ; \ 176 (region)->min = ( (region)->max + 1 ) ) 184 #define for_each_memmap( region, hide ) \ 185 for_each_memmap_from ( (region), 0, (hide) ) 187 #define DBG_MEMMAP_IF( level, region ) do { \ 188 const char *name = (region)->name; \ 189 unsigned int flags = (region)->flags; \ 191 DBG_IF ( level, "MEMMAP (%s%s%s%s) [%#08llx,%#08llx]%s%s\n", \ 192 ( ( flags & MEMMAP_FL_MEMORY ) ? "M" : "-" ), \ 193 ( ( flags & MEMMAP_FL_RESERVED ) ? "R" : "-" ), \ 194 ( ( flags & MEMMAP_FL_USED ) ? "U" : "-" ), \ 195 ( ( flags & MEMMAP_FL_INACCESSIBLE ) ? "X" : "-" ), \ 196 ( ( unsigned long long ) (region)->min ), \ 197 ( ( unsigned long long ) (region)->max ), \ 198 ( name ? " " : "" ), ( name ? name : "" ) ); \ 201 #define DBGC_MEMMAP_IF( level, id, ... ) do { \ 202 DBG_AC_IF ( level, id ); \ 203 DBG_MEMMAP_IF ( level, __VA_ARGS__ ); \ 204 DBG_DC_IF ( level ); \ 207 #define DBGC_MEMMAP( ... ) DBGC_MEMMAP_IF ( LOG, ##__VA_ARGS__ ) 208 #define DBGC2_MEMMAP( ... ) DBGC_MEMMAP_IF ( EXTRA, ##__VA_ARGS__ ) 209 #define DBGCP_MEMMAP( ... ) DBGC_MEMMAP_IF ( PROFILE, ##__VA_ARGS__ ) 225 ( hide ?
"hidden" :
"ignored" ) );
static int memmap_is_usable(const struct memmap_region *region)
Check if memory region is usable.
size_t size
Length of region.
static void memmap_use(struct used_region *used, physaddr_t start, size_t size)
Update an in-use memory region.
uint64_t max
Maximum address in region.
uint16_t size
Buffer size.
Flattened Device Tree memory map.
unsigned long long uint64_t
size_t memmap_largest(physaddr_t *start)
Find largest usable memory region.
void memmap_update_used(struct memmap_region *region)
Update memory region descriptor based on all in-use memory regions.
uint32_t start
Starting offset.
physaddr_t start
Start address.
void memmap_describe(uint64_t min, int hide, struct memmap_region *region)
Describe memory region from system memory map.
#define for_each_memmap(region, hide)
Iterate over memory regions.
unsigned int flags
Region flags.
const char * name
Region name (for debug messages)
static void memmap_dump_all(int hide)
Dump system memory map (for debugging)
static uint64_t memmap_size(const struct memmap_region *region)
Get remaining size of memory region (from the described address upwards)
#define MEMMAP_FL_MEMORY
Contains memory.
void memmap_update(struct memmap_region *region, uint64_t start, uint64_t size, unsigned int flags, const char *name)
Update memory region descriptor.
const char * name
Region name.
uint64_t min
Minimum address in region.
Null system memory map API.
A memory region descriptor.
static void memmap_init(uint64_t min, struct memmap_region *region)
Initialise memory region descriptor.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define NULL
NULL pointer (VOID *)
void memmap_sync(void)
Synchronise in-use regions with the externally visible system memory map.