[memmap] Rename addr/last fields to min/max for clarity

Use the terminology "min" and "max" for addresses covered by a memory
region descriptor, since this is sufficiently intuitive to generally
not require further explanation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-05-23 16:55:42 +01:00
parent cd38ed4fab
commit 036e43334a
12 changed files with 69 additions and 73 deletions
+12 -11
View File
@@ -196,22 +196,23 @@ static int fdtmem_update_tree ( struct memmap_region *region,
/**
* Describe memory region
*
* @v addr Address within region
* @v fdt Device tree
* @v min Minimum address
* @v max Maximum accessible physical address
* @v fdt Device tree
* @v region Region descriptor to fill in
*/
static void fdtmem_describe ( uint64_t addr, struct fdt *fdt, physaddr_t max,
static void fdtmem_describe ( uint64_t min, uint64_t max, struct fdt *fdt,
struct memmap_region *region ) {
uint64_t inaccessible = ( ( ( uint64_t ) max ) + 1 );
uint64_t inaccessible;
/* Initialise region */
memmap_init ( addr, region );
memmap_init ( min, region );
/* Update region based on device tree */
fdtmem_update_tree ( region, fdt );
/* Treat inaccessible physical memory as such */
inaccessible = ( max + 1 );
memmap_update ( region, inaccessible, -inaccessible,
MEMMAP_FL_INACCESSIBLE, NULL );
}
@@ -289,15 +290,15 @@ physaddr_t fdtmem_relocate ( struct fdt_header *hdr, physaddr_t max ) {
for ( addr = 0, next = 1 ; next ; addr = next ) {
/* Describe region and in-use memory */
fdtmem_describe ( addr, &fdt, max, &region );
fdtmem_describe ( addr, max, &fdt, &region );
memmap_update ( &region, old, memsz, MEMMAP_FL_USED, "iPXE" );
memmap_update ( &region, virt_to_phys ( hdr ), fdt.len,
MEMMAP_FL_RESERVED, "FDT" );
next = ( region.last + 1 );
next = ( region.max + 1 );
/* Dump region descriptor (for debugging) */
memmap_dump ( &region );
assert ( region.last >= region.addr );
assert ( region.max >= region.min );
/* Use highest possible region */
if ( memmap_is_usable ( &region ) &&
@@ -364,15 +365,15 @@ int fdtmem_register ( struct fdt_header *hdr, physaddr_t max ) {
/**
* Describe memory region from system memory map
*
* @v addr Address within region
* @v min Minimum address
* @v hide Hide in-use regions from the memory map
* @v region Region descriptor to fill in
*/
static void fdtmem_describe_region ( uint64_t addr, int hide,
static void fdtmem_describe_region ( uint64_t min, int hide,
struct memmap_region *region ) {
/* Describe memory region based on device tree */
fdtmem_describe ( addr, &sysfdt, fdtmem_max, region );
fdtmem_describe ( min, fdtmem_max, &sysfdt, region );
/* Update memory region based on in-use regions, if applicable */
if ( hide )
+18 -18
View File
@@ -46,54 +46,54 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
void memmap_update ( struct memmap_region *region, uint64_t start,
uint64_t size, unsigned int flags, const char *name ) {
uint64_t last;
uint64_t max;
/* Sanity check */
assert ( region->last >= region->addr );
assert ( region->max >= region->min );
/* Ignore empty regions */
if ( ! size )
return;
/* Calculate last addresses (and truncate if necessary) */
last = ( start + size - 1 );
if ( last < start ) {
last = ~( ( uint64_t ) 0 );
/* Calculate max addresses (and truncate if necessary) */
max = ( start + size - 1 );
if ( max < start ) {
max = ~( ( uint64_t ) 0 );
DBGC ( region, "MEMMAP [%#08llx,%#08llx] %s truncated "
"(invalid size %#08llx)\n",
( ( unsigned long long ) start ),
( ( unsigned long long ) last ), name,
( ( unsigned long long ) max ), name,
( ( unsigned long long ) size ) );
}
/* Ignore regions entirely below the region of interest */
if ( last < region->addr )
if ( max < region->min )
return;
/* Ignore regions entirely above the region of interest */
if ( start > region->last )
if ( start > region->max )
return;
/* Update region of interest as applicable */
if ( start <= region->addr ) {
if ( start <= region->min ) {
/* Record this region as covering the region of interest */
region->flags |= flags;
if ( name )
region->name = name;
/* Update last address if no closer boundary exists */
if ( last < region->last )
region->last = last;
/* Update max address if no closer boundary exists */
if ( max < region->max )
region->max = max;
} else if ( start < region->last ) {
} else if ( start < region->max ) {
/* Update last address if no closer boundary exists */
region->last = ( start - 1 );
/* Update max address if no closer boundary exists */
region->max = ( start - 1 );
}
/* Sanity check */
assert ( region->last >= region->addr );
assert ( region->max >= region->min );
}
/**
@@ -134,7 +134,7 @@ size_t memmap_largest ( physaddr_t *start ) {
if ( size > largest ) {
DBGC ( &region, "...new largest region found\n" );
largest = size;
*start = region.addr;
*start = region.min;
}
}
return largest;
+2 -2
View File
@@ -175,9 +175,9 @@ static int memmap_settings_fetch ( struct settings *settings,
/* Extract results from this region */
if ( include_start ) {
result += region.addr;
result += region.min;
DBGC ( settings, "MEMMAP %d start %#08llx\n", index,
( ( unsigned long long ) region.addr ) );
( ( unsigned long long ) region.min ) );
}
if ( include_length ) {
result += memmap_size ( &region );