25 #define MEMMAP_INLINE( _subsys, _api_func ) \ 26 SINGLE_API_INLINE ( MEMMAP_PREFIX_ ## _subsys, _api_func ) 35 #define PROVIDE_MEMMAP( _subsys, _api_func, _func ) \ 36 PROVIDE_SINGLE_API ( MEMMAP_PREFIX_ ## _subsys, _api_func, _func ) 44 #define PROVIDE_MEMMAP_INLINE( _subsys, _api_func ) \ 45 PROVIDE_SINGLE_API_INLINE ( MEMMAP_PREFIX_ ## _subsys, _api_func ) 59 #define MEMMAP_FL_MEMORY 0x0001 60 #define MEMMAP_FL_RESERVED 0x0002 61 #define MEMMAP_FL_USED 0x0004 62 #define MEMMAP_FL_INACCESSIBLE 0x0008 101 return ( region->
max - region->
min + 1 );
115 #define USED_REGIONS __table ( struct used_region, "used_regions" ) 118 #define __used_region __table_entry ( USED_REGIONS, 01 ) 125 #include <bits/memmap.h> 170 #define for_each_memmap_from( region, start, hide ) \ 171 for ( (region)->min = (start), (region)->max = 0 ; \ 172 ( ( ( (region)->max + 1 ) != 0 ) && \ 173 ( memmap_describe ( (region)->min, (hide), \ 174 (region) ), 1 ) ) ; \ 175 (region)->min = ( (region)->max + 1 ) ) 183 #define for_each_memmap( region, hide ) \ 184 for_each_memmap_from ( (region), 0, (hide) ) 186 #define DBG_MEMMAP_IF( level, region ) do { \ 187 const char *name = (region)->name; \ 188 unsigned int flags = (region)->flags; \ 190 DBG_IF ( level, "MEMMAP (%s%s%s%s) [%#08llx,%#08llx]%s%s\n", \ 191 ( ( flags & MEMMAP_FL_MEMORY ) ? "M" : "-" ), \ 192 ( ( flags & MEMMAP_FL_RESERVED ) ? "R" : "-" ), \ 193 ( ( flags & MEMMAP_FL_USED ) ? "U" : "-" ), \ 194 ( ( flags & MEMMAP_FL_INACCESSIBLE ) ? "X" : "-" ), \ 195 ( ( unsigned long long ) (region)->min ), \ 196 ( ( unsigned long long ) (region)->max ), \ 197 ( name ? " " : "" ), ( name ? name : "" ) ); \ 200 #define DBGC_MEMMAP_IF( level, id, ... ) do { \ 201 DBG_AC_IF ( level, id ); \ 202 DBG_MEMMAP_IF ( level, __VA_ARGS__ ); \ 203 DBG_DC_IF ( level ); \ 206 #define DBGC_MEMMAP( ... ) DBGC_MEMMAP_IF ( LOG, ##__VA_ARGS__ ) 207 #define DBGC2_MEMMAP( ... ) DBGC_MEMMAP_IF ( EXTRA, ##__VA_ARGS__ ) 208 #define DBGCP_MEMMAP( ... ) DBGC_MEMMAP_IF ( PROFILE, ##__VA_ARGS__ ) 224 ( 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.