1 /* this code is run directly from boot.S. our task is to setup the
2 paging just enough so that L4 can run in its native address space
3 at 0xf0001000, and then start up L4. */
11 #include "boot_paging.h"
12 #include "boot_console.h"
15 #include "globalconfig.h"
17 #include "kmem_alloc.h"
18 #include "mem_layout.h"
19 #include "mem_region.h"
20 #include "multiboot.h"
22 #include "processor.h"
28 Unsigned32 checksum_ro;
29 Unsigned32 checksum_rw;
30 } check_sum = {"FIASCOCHECKSUM=", 0, 0};
32 extern "C" char _start[];
33 extern "C" char _end[];
35 extern "C" void exit(int rc) __attribute__((noreturn));
44 // test if [start1..end1-1] overlaps [start2..end2-1]
47 check_overlap (const char *str,
48 Address start1, Address end1, Address start2, Address end2)
50 if ((start1 >= start2 && start1 < end2) || (end1 > start2 && end1 <= end2))
51 panic("Kernel [0x%014lx,0x%014lx) overlaps %s [0x%014lx,0x%014lx).",
52 start1, end1, str, start2, end2);
55 typedef void (*Start)(Multiboot_info *, unsigned, unsigned) FIASCO_FASTCALL;
57 extern "C" FIASCO_FASTCALL
59 bootstrap (Multiboot_info *mbi, unsigned int flag)
61 extern Kip my_kernel_info_page;
64 assert(flag == Multiboot_header::Valid);
66 // setup stuff for base_paging_init()
68 // now do base_paging_init(): sets up paging with one-to-one mapping
71 asm volatile ("" ::: "memory");
73 Kip::init_global_kip(&my_kernel_info_page);
75 printf("Boot: KIP @ %p\n", Kip::k());
77 printf("Boot: Kmem_alloc::base_init();\n");
78 if (!Kmem_alloc::base_init())
80 panic("FATAL: Could not reserve kernel memory, halted\n");
82 printf("Boot: kernel memory reserved\n");
84 // make sure that we did not forgot to discard an unused header section
85 // (compare "objdump -p fiasco.image")
86 if ((Address)_start < Mem_layout::Kernel_image)
87 panic("Fiasco kernel occupies memory below %014lx",
88 (unsigned long)Mem_layout::Kernel_image);
90 if ((Address)&_end - Mem_layout::Kernel_image > 4<<20)
91 panic("Fiasco boot system occupies more than 4MB");
93 base_map_physical_memory_for_kernel();
95 start = (Start)_start;
97 Address phys_start = (Address)_start - Mem_layout::Kernel_image;
98 Address phys_end = (Address)_end - Mem_layout::Kernel_image;
99 check_overlap ("VGA/IO", phys_start, phys_end, 0xa0000, 0x100000);
101 if (Checksum::get_checksum_ro() != check_sum.checksum_ro)
102 panic("Read-only (text) checksum does not match.");
104 if (Checksum::get_checksum_rw() != check_sum.checksum_rw)
105 panic("Read-write (data) checksum does not match.");
107 start (mbi, flag, check_sum.checksum_ro);