* away with using just 32-bit arithmetic after this
* stage.
*/
- memmap_dump ( ®ion );
+ DBGC_MEMMAP ( ®ion, ®ion );
if ( region.min > max ) {
DBGC ( ®ion, "...starts after max=%#08lx\n", max );
break;
/* Ignore any non-memory regions */
if ( ! ( region.flags & MEMMAP_FL_MEMORY ) )
continue;
- memmap_dump ( ®ion );
+ DBGC_MEMMAP ( image, ®ion );
/* Check Multiboot memory map limit */
if ( ! remaining ) {
/* Parse FDT */
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 ) );
/* Refuse relocation if we have no FDT */
return old;
/* Determine required length */
len = fdtmem_len ( &fdt );
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 );
/* Construct memory map and choose a relocation address */
next = ( region.max + 1 );
/* Dump region descriptor (for debugging) */
- memmap_dump ( ®ion );
+ DBGC_MEMMAP ( hdr, ®ion );
assert ( region.max >= region.min );
/* Use highest possible region */
}
}
- DBGC ( ®ion, "FDTMEM relocating %#08lx => [%#08lx,%#08lx]\n",
+ DBGC ( hdr, "FDTMEM relocating %#08lx => [%#08lx,%#08lx]\n",
old, new, ( ( physaddr_t ) ( new + len - 1 ) ) );
return new;
}
*start = 0;
largest = 0;
for_each_memmap ( ®ion, 1 ) {
- memmap_dump ( ®ion );
+ DBGC_MEMMAP ( ®ion, ®ion );
if ( ! memmap_is_usable ( ®ion ) )
continue;
size = memmap_size ( ®ion );
/* Locate start of RAM */
for_each_memmap ( ®ion, 0 ) {
- memmap_dump ( ®ion );
+ DBGC_MEMMAP ( image, ®ion );
if ( ! ( region.flags & MEMMAP_FL_MEMORY ) )
continue;
ctx->ram = region.min;
physaddr_t end = ( start + memsz );
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 */
if ( filesz > memsz ) {
- DBGC ( ®ion, "SEGMENT [%#08lx,%#08lx,%#08lx) is "
+ DBGC ( segment, "SEGMENT [%#08lx,%#08lx,%#08lx) is "
"malformed\n", start, mid, end );
return -EINVAL;
}
/* Check for address space overflow */
if ( max < start ) {
- DBGC ( ®ion, "SEGMENT [%#08lx,%#08lx,%#08lx) wraps "
+ DBGC ( segment, "SEGMENT [%#08lx,%#08lx,%#08lx) wraps "
"around\n", start, mid, end );
return -EINVAL;
}
/* Describe region containing this segment */
memmap_describe ( start, 1, ®ion );
- memmap_dump ( ®ion );
+ DBGC_MEMMAP ( segment, ®ion );
/* Fail unless region is usable and sufficiently large */
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 );
return -ERANGE_SEGMENT;
}
#define for_each_memmap( region, hide ) \
for_each_memmap_from ( (region), 0, (hide) )
-
-/**
- * Dump memory region descriptor (for debugging)
- *
- * @v region Region descriptor
- */
-static inline void memmap_dump ( const struct memmap_region *region ) {
- const char *name = region->name;
- unsigned int flags = region->flags;
-
- /* Dump region information */
- DBGC ( region, "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 : "" ) );
-}
+#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 { \
+ DBG_AC_IF ( level, id ); \
+ DBG_MEMMAP_IF ( level, __VA_ARGS__ ); \
+ DBG_DC_IF ( level ); \
+ } while ( 0 )
+
+#define DBGC_MEMMAP( ... ) DBGC_MEMMAP_IF ( LOG, ##__VA_ARGS__ )
+#define DBGC2_MEMMAP( ... ) DBGC_MEMMAP_IF ( EXTRA, ##__VA_ARGS__ )
+#define DBGCP_MEMMAP( ... ) DBGC_MEMMAP_IF ( PROFILE, ##__VA_ARGS__ )
/**
* Dump system memory map (for debugging)
return;
/* 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" ) );
for_each_memmap ( ®ion, hide )
- memmap_dump ( ®ion );
+ DBGC_MEMMAP ( &memmap_describe, ®ion );
}
extern void memmap_update ( struct memmap_region *region, uint64_t start,