Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

m68k: print memory layout info in boot log

Output a table of the kernel memory regions at boot time.
This is taken directly from the ARM architecture code that does this.
The table looks like this:

Virtual kernel memory layout:
vector : 0x00000000 - 0x00000400 ( 0 KiB)
kmap : 0xd0000000 - 0xe0000000 ( 256 MiB)
vmalloc : 0xc0000000 - 0xcfffffff ( 255 MiB)
lowmem : 0x00000000 - 0x02000000 ( 32 MiB)
.init : 0x00128000 - 0x00134000 ( 48 KiB)
.text : 0x00020000 - 0x00118d54 ( 996 KiB)
.data : 0x00118d60 - 0x00126000 ( 53 KiB)
.bss : 0x00134000 - 0x001413e0 ( 53 KiB)

This has been very useful while debugging the ColdFire virtual memory
support code. But in general I think it is nice to know extacly where
the kernel has layed everything out on boot.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>

+39
+1
arch/m68k/include/asm/traps.h
··· 18 18 19 19 typedef void (*e_vector)(void); 20 20 extern e_vector vectors[]; 21 + extern e_vector *_ramvec; 21 22 22 23 asmlinkage void auto_inthandler(void); 23 24 asmlinkage void user_inthandler(void);
+2
arch/m68k/kernel/vmlinux-std.lds
··· 31 31 32 32 RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE) 33 33 34 + _sbss = .; 34 35 BSS_SECTION(0, 0, 0) 36 + _ebss = .; 35 37 36 38 _edata = .; /* End of data section */ 37 39
+2
arch/m68k/kernel/vmlinux-sun3.lds
··· 44 44 . = ALIGN(PAGE_SIZE); 45 45 __init_end = .; 46 46 47 + _sbss = .; 47 48 BSS_SECTION(0, 0, 0) 49 + _ebss = .; 48 50 49 51 _end = . ; 50 52
+34
arch/m68k/mm/init_mm.c
··· 24 24 #include <asm/page.h> 25 25 #include <asm/pgalloc.h> 26 26 #include <asm/system.h> 27 + #include <asm/traps.h> 27 28 #include <asm/machdep.h> 28 29 #include <asm/io.h> 29 30 #ifdef CONFIG_ATARI ··· 76 75 77 76 extern pmd_t *zero_pgtable; 78 77 78 + #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE) 79 + #define VECTORS &vectors[0] 80 + #else 81 + #define VECTORS _ramvec 82 + #endif 83 + 84 + void __init print_memmap(void) 85 + { 86 + #define UL(x) ((unsigned long) (x)) 87 + #define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10 88 + #define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20 89 + #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024) 90 + 91 + pr_notice("Virtual kernel memory layout:\n" 92 + " vector : 0x%08lx - 0x%08lx (%4ld KiB)\n" 93 + " kmap : 0x%08lx - 0x%08lx (%4ld MiB)\n" 94 + " vmalloc : 0x%08lx - 0x%08lx (%4ld MiB)\n" 95 + " lowmem : 0x%08lx - 0x%08lx (%4ld MiB)\n" 96 + " .init : 0x%p" " - 0x%p" " (%4d KiB)\n" 97 + " .text : 0x%p" " - 0x%p" " (%4d KiB)\n" 98 + " .data : 0x%p" " - 0x%p" " (%4d KiB)\n" 99 + " .bss : 0x%p" " - 0x%p" " (%4d KiB)\n", 100 + MLK(VECTORS, VECTORS + 256), 101 + MLM(KMAP_START, KMAP_END), 102 + MLM(VMALLOC_START, VMALLOC_END), 103 + MLM(PAGE_OFFSET, (unsigned long)high_memory), 104 + MLK_ROUNDUP(__init_begin, __init_end), 105 + MLK_ROUNDUP(_stext, _etext), 106 + MLK_ROUNDUP(_sdata, _edata), 107 + MLK_ROUNDUP(_sbss, _ebss)); 108 + } 109 + 79 110 void __init mem_init(void) 80 111 { 81 112 pg_data_t *pgdat; ··· 158 125 codepages << (PAGE_SHIFT-10), 159 126 datapages << (PAGE_SHIFT-10), 160 127 initpages << (PAGE_SHIFT-10)); 128 + print_memmap(); 161 129 } 162 130 163 131 #ifdef CONFIG_BLK_DEV_INITRD