mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 01:52:08 +03:00
[memmap] Allow explicit colour selection for memory map debug messages
Provide DBGC_MEMMAP() as a replacement for memmap_dump(), allowing the colour used to match other messages within the same message group. Retain a dedicated colour for output from memmap_dump_all(), on the basis that it is generally most useful to visually compare full memory dumps against previous full memory dumps. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -80,7 +80,7 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
|||||||
* away with using just 32-bit arithmetic after this
|
* away with using just 32-bit arithmetic after this
|
||||||
* stage.
|
* stage.
|
||||||
*/
|
*/
|
||||||
memmap_dump ( ®ion );
|
DBGC_MEMMAP ( ®ion, ®ion );
|
||||||
if ( region.min > max ) {
|
if ( region.min > max ) {
|
||||||
DBGC ( ®ion, "...starts after max=%#08lx\n", max );
|
DBGC ( ®ion, "...starts after max=%#08lx\n", max );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ static void multiboot_build_memmap ( struct image *image,
|
|||||||
/* Ignore any non-memory regions */
|
/* Ignore any non-memory regions */
|
||||||
if ( ! ( region.flags & MEMMAP_FL_MEMORY ) )
|
if ( ! ( region.flags & MEMMAP_FL_MEMORY ) )
|
||||||
continue;
|
continue;
|
||||||
memmap_dump ( ®ion );
|
DBGC_MEMMAP ( image, ®ion );
|
||||||
|
|
||||||
/* Check Multiboot memory map limit */
|
/* Check Multiboot memory map limit */
|
||||||
if ( ! remaining ) {
|
if ( ! remaining ) {
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ physaddr_t fdtmem_relocate ( struct fdt_header *hdr, physaddr_t max ) {
|
|||||||
|
|
||||||
/* Parse FDT */
|
/* Parse FDT */
|
||||||
if ( ( rc = fdt_parse ( &fdt, hdr, -1UL ) ) != 0 ) {
|
if ( ( rc = fdt_parse ( &fdt, hdr, -1UL ) ) != 0 ) {
|
||||||
DBGC ( ®ion, "FDTMEM could not parse FDT: %s\n",
|
DBGC ( hdr, "FDTMEM could not parse FDT: %s\n",
|
||||||
strerror ( rc ) );
|
strerror ( rc ) );
|
||||||
/* Refuse relocation if we have no FDT */
|
/* Refuse relocation if we have no FDT */
|
||||||
return old;
|
return old;
|
||||||
@@ -282,7 +282,7 @@ physaddr_t fdtmem_relocate ( struct fdt_header *hdr, physaddr_t max ) {
|
|||||||
/* Determine required length */
|
/* Determine required length */
|
||||||
len = fdtmem_len ( &fdt );
|
len = fdtmem_len ( &fdt );
|
||||||
assert ( len > 0 );
|
assert ( len > 0 );
|
||||||
DBGC ( ®ion, "FDTMEM requires %#zx + %#zx => %#zx bytes for "
|
DBGC ( hdr, "FDTMEM requires %#zx + %#zx => %#zx bytes for "
|
||||||
"relocation\n", memsz, fdt.len, len );
|
"relocation\n", memsz, fdt.len, len );
|
||||||
|
|
||||||
/* Construct memory map and choose a relocation address */
|
/* Construct memory map and choose a relocation address */
|
||||||
@@ -297,7 +297,7 @@ physaddr_t fdtmem_relocate ( struct fdt_header *hdr, physaddr_t max ) {
|
|||||||
next = ( region.max + 1 );
|
next = ( region.max + 1 );
|
||||||
|
|
||||||
/* Dump region descriptor (for debugging) */
|
/* Dump region descriptor (for debugging) */
|
||||||
memmap_dump ( ®ion );
|
DBGC_MEMMAP ( hdr, ®ion );
|
||||||
assert ( region.max >= region.min );
|
assert ( region.max >= region.min );
|
||||||
|
|
||||||
/* Use highest possible region */
|
/* Use highest possible region */
|
||||||
@@ -313,7 +313,7 @@ physaddr_t fdtmem_relocate ( struct fdt_header *hdr, physaddr_t max ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGC ( ®ion, "FDTMEM relocating %#08lx => [%#08lx,%#08lx]\n",
|
DBGC ( hdr, "FDTMEM relocating %#08lx => [%#08lx,%#08lx]\n",
|
||||||
old, new, ( ( physaddr_t ) ( new + len - 1 ) ) );
|
old, new, ( ( physaddr_t ) ( new + len - 1 ) ) );
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ size_t memmap_largest ( physaddr_t *start ) {
|
|||||||
*start = 0;
|
*start = 0;
|
||||||
largest = 0;
|
largest = 0;
|
||||||
for_each_memmap ( ®ion, 1 ) {
|
for_each_memmap ( ®ion, 1 ) {
|
||||||
memmap_dump ( ®ion );
|
DBGC_MEMMAP ( ®ion, ®ion );
|
||||||
if ( ! memmap_is_usable ( ®ion ) )
|
if ( ! memmap_is_usable ( ®ion ) )
|
||||||
continue;
|
continue;
|
||||||
size = memmap_size ( ®ion );
|
size = memmap_size ( ®ion );
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ static int lkrn_ram ( struct image *image, struct lkrn_context *ctx ) {
|
|||||||
|
|
||||||
/* Locate start of RAM */
|
/* Locate start of RAM */
|
||||||
for_each_memmap ( ®ion, 0 ) {
|
for_each_memmap ( ®ion, 0 ) {
|
||||||
memmap_dump ( ®ion );
|
DBGC_MEMMAP ( image, ®ion );
|
||||||
if ( ! ( region.flags & MEMMAP_FL_MEMORY ) )
|
if ( ! ( region.flags & MEMMAP_FL_MEMORY ) )
|
||||||
continue;
|
continue;
|
||||||
ctx->ram = region.min;
|
ctx->ram = region.min;
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ int prep_segment ( void *segment, size_t filesz, size_t memsz ) {
|
|||||||
physaddr_t end = ( start + memsz );
|
physaddr_t end = ( start + memsz );
|
||||||
physaddr_t max;
|
physaddr_t max;
|
||||||
|
|
||||||
DBGC ( ®ion, "SEGMENT [%#08lx,%#08lx,%#08lx)\n", start, mid, end );
|
DBGC ( segment, "SEGMENT [%#08lx,%#08lx,%#08lx)\n", start, mid, end );
|
||||||
|
|
||||||
/* Check for malformed lengths */
|
/* Check for malformed lengths */
|
||||||
if ( filesz > memsz ) {
|
if ( filesz > memsz ) {
|
||||||
DBGC ( ®ion, "SEGMENT [%#08lx,%#08lx,%#08lx) is "
|
DBGC ( segment, "SEGMENT [%#08lx,%#08lx,%#08lx) is "
|
||||||
"malformed\n", start, mid, end );
|
"malformed\n", start, mid, end );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@@ -81,18 +81,18 @@ int prep_segment ( void *segment, size_t filesz, size_t memsz ) {
|
|||||||
|
|
||||||
/* Check for address space overflow */
|
/* Check for address space overflow */
|
||||||
if ( max < start ) {
|
if ( max < start ) {
|
||||||
DBGC ( ®ion, "SEGMENT [%#08lx,%#08lx,%#08lx) wraps "
|
DBGC ( segment, "SEGMENT [%#08lx,%#08lx,%#08lx) wraps "
|
||||||
"around\n", start, mid, end );
|
"around\n", start, mid, end );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Describe region containing this segment */
|
/* Describe region containing this segment */
|
||||||
memmap_describe ( start, 1, ®ion );
|
memmap_describe ( start, 1, ®ion );
|
||||||
memmap_dump ( ®ion );
|
DBGC_MEMMAP ( segment, ®ion );
|
||||||
|
|
||||||
/* Fail unless region is usable and sufficiently large */
|
/* Fail unless region is usable and sufficiently large */
|
||||||
if ( ( ! memmap_is_usable ( ®ion ) ) || ( region.max < max ) ) {
|
if ( ( ! memmap_is_usable ( ®ion ) ) || ( region.max < max ) ) {
|
||||||
DBGC ( ®ion, "SEGMENT [%#08lx,%#08lx,%#08lx) does not fit "
|
DBGC ( segment, "SEGMENT [%#08lx,%#08lx,%#08lx) does not fit "
|
||||||
"into available memory\n", start, mid, end );
|
"into available memory\n", start, mid, end );
|
||||||
return -ERANGE_SEGMENT;
|
return -ERANGE_SEGMENT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,26 +183,29 @@ memmap_use ( struct used_region *used, physaddr_t start, size_t size ) {
|
|||||||
#define for_each_memmap( region, hide ) \
|
#define for_each_memmap( region, hide ) \
|
||||||
for_each_memmap_from ( (region), 0, (hide) )
|
for_each_memmap_from ( (region), 0, (hide) )
|
||||||
|
|
||||||
|
#define DBG_MEMMAP_IF( level, region ) do { \
|
||||||
|
const char *name = (region)->name; \
|
||||||
|
unsigned int flags = (region)->flags; \
|
||||||
|
\
|
||||||
|
DBG_IF ( level, "MEMMAP (%s%s%s%s) [%#08llx,%#08llx]%s%s\n", \
|
||||||
|
( ( flags & MEMMAP_FL_MEMORY ) ? "M" : "-" ), \
|
||||||
|
( ( flags & MEMMAP_FL_RESERVED ) ? "R" : "-" ), \
|
||||||
|
( ( flags & MEMMAP_FL_USED ) ? "U" : "-" ), \
|
||||||
|
( ( flags & MEMMAP_FL_INACCESSIBLE ) ? "X" : "-" ), \
|
||||||
|
( ( unsigned long long ) (region)->min ), \
|
||||||
|
( ( unsigned long long ) (region)->max ), \
|
||||||
|
( name ? " " : "" ), ( name ? name : "" ) ); \
|
||||||
|
} while ( 0 )
|
||||||
|
|
||||||
/**
|
#define DBGC_MEMMAP_IF( level, id, ... ) do { \
|
||||||
* Dump memory region descriptor (for debugging)
|
DBG_AC_IF ( level, id ); \
|
||||||
*
|
DBG_MEMMAP_IF ( level, __VA_ARGS__ ); \
|
||||||
* @v region Region descriptor
|
DBG_DC_IF ( level ); \
|
||||||
*/
|
} while ( 0 )
|
||||||
static inline void memmap_dump ( const struct memmap_region *region ) {
|
|
||||||
const char *name = region->name;
|
|
||||||
unsigned int flags = region->flags;
|
|
||||||
|
|
||||||
/* Dump region information */
|
#define DBGC_MEMMAP( ... ) DBGC_MEMMAP_IF ( LOG, ##__VA_ARGS__ )
|
||||||
DBGC ( region, "MEMMAP (%s%s%s%s) [%#08llx,%#08llx]%s%s\n",
|
#define DBGC2_MEMMAP( ... ) DBGC_MEMMAP_IF ( EXTRA, ##__VA_ARGS__ )
|
||||||
( ( flags & MEMMAP_FL_MEMORY ) ? "M" : "-" ),
|
#define DBGCP_MEMMAP( ... ) DBGC_MEMMAP_IF ( PROFILE, ##__VA_ARGS__ )
|
||||||
( ( flags & MEMMAP_FL_RESERVED ) ? "R" : "-" ),
|
|
||||||
( ( flags & MEMMAP_FL_USED ) ? "U" : "-" ),
|
|
||||||
( ( flags & MEMMAP_FL_INACCESSIBLE ) ? "X" : "-" ),
|
|
||||||
( ( unsigned long long ) region->min ),
|
|
||||||
( ( unsigned long long ) region->max ),
|
|
||||||
( name ? " " : "" ), ( name ? name : "" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump system memory map (for debugging)
|
* Dump system memory map (for debugging)
|
||||||
@@ -217,10 +220,10 @@ static inline void memmap_dump_all ( int hide ) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Describe all memory regions */
|
/* Describe all memory regions */
|
||||||
DBGC ( ®ion, "MEMMAP with in-use regions %s:\n",
|
DBGC ( &memmap_describe, "MEMMAP with in-use regions %s:\n",
|
||||||
( hide ? "hidden" : "ignored" ) );
|
( hide ? "hidden" : "ignored" ) );
|
||||||
for_each_memmap ( ®ion, hide )
|
for_each_memmap ( ®ion, hide )
|
||||||
memmap_dump ( ®ion );
|
DBGC_MEMMAP ( &memmap_describe, ®ion );
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void memmap_update ( struct memmap_region *region, uint64_t start,
|
extern void memmap_update ( struct memmap_region *region, uint64_t start,
|
||||||
|
|||||||
Reference in New Issue
Block a user