diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-10 19:39:30 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-10 19:39:30 +0200 |
commit | a302ef42887a1a349d9918d5d1471bbea8f59c2b (patch) | |
tree | ce655d3c31574c6cb77bc437abedf66d32ac9d90 /src/vmm.cc | |
parent | Move elf and iso to builddir (diff) | |
download | kernel.cpp-a302ef42887a1a349d9918d5d1471bbea8f59c2b.tar.xz |
vmm: display segment map info
Diffstat (limited to 'src/vmm.cc')
-rw-r--r-- | src/vmm.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/vmm.cc b/src/vmm.cc new file mode 100644 index 0000000..346e6ab --- /dev/null +++ b/src/vmm.cc @@ -0,0 +1,49 @@ +#include <stdlib.h> + +typedef void (*constructor)(); + +extern "C" { +/* .text */ +uint32_t begin_text; +uint32_t end_text; + +/* .rodata */ +uint32_t begin_rodata; +uint32_t end_rodata; + +/* .data */ +uint32_t begin_constinit; +uint32_t end_constinit; +constructor begin_ctors; +constructor end_ctors; +uint32_t begin_data; +uint32_t end_data; + +/* .bss */ +uint32_t begin_bss; +uint32_t end_bss; + +void kernel_constructors() { + for (constructor* i = &begin_ctors; i != &end_ctors; ++i) (*i)(); +} + +void dump_address() { + printk("text begin: ", uhex{reinterpret_cast<uint32_t>(&begin_text)}, + " end: ", uhex{reinterpret_cast<uint32_t>(&end_text)}, '\n'); + + printk("rodata begin: ", uhex{reinterpret_cast<uint32_t>(&begin_rodata)}, + " end: ", uhex{reinterpret_cast<uint32_t>(&end_rodata)}, '\n'); + + printk("constinit begin: ", uhex{reinterpret_cast<uint32_t>(&begin_constinit)}, + " end: ", uhex{reinterpret_cast<uint32_t>(&end_constinit)}, '\n'); + + printk("ctors begin: ", uhex{reinterpret_cast<uint32_t>(&begin_ctors)}, + " end: ", uhex{reinterpret_cast<uint32_t>(&end_ctors)}, '\n'); + + printk("data begin: ", uhex{reinterpret_cast<uint32_t>(&begin_data)}, + " end: ", uhex{reinterpret_cast<uint32_t>(&end_data)}, '\n'); + + printk("bss begin: ", uhex{reinterpret_cast<uint32_t>(&begin_bss)}, + " end: ", uhex{reinterpret_cast<uint32_t>(&end_bss)}, '\n'); +} +} // extern "C" |