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"
13 #include "kernel_console.h"
16 #include "globalconfig.h"
18 #include "kmem_alloc.h"
19 #include "mem_layout.h"
20 #include "mem_region.h"
22 #include "processor.h"
29 Unsigned32 checksum_ro;
30 Unsigned32 checksum_rw;
31 } check_sum = {"FIASCOCHECKSUM=", 0, 0};
33 extern "C" char _start[];
34 extern "C" char _end[];
36 extern "C" void exit(int rc) __attribute__((noreturn));
45 // test if [start1..end1-1] overlaps [start2..end2-1]
48 check_overlap (const char *str,
49 Address start1, Address end1, Address start2, Address end2)
51 if ((start1 >= start2 && start1 < end2) || (end1 > start2 && end1 <= end2))
52 panic("Kernel [0x%014lx,0x%014lx) overlaps %s [0x%014lx,0x%014lx).",
53 start1, end1, str, start2, end2);
56 typedef void (*Start)(unsigned) FIASCO_FASTCALL;
58 extern "C" FIASCO_FASTCALL
62 extern Kip my_kernel_info_page;
65 // setup stuff for base_paging_init()
67 // now do base_paging_init(): sets up paging with one-to-one mapping
70 asm volatile ("" ::: "memory");
72 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 Mem_unit::tlb_flush();
97 start = (Start)_start;
99 Address phys_start = (Address)_start - Mem_layout::Kernel_image + Mem_layout::Kernel_image_phys;
100 Address phys_end = (Address)_end - Mem_layout::Kernel_image + Mem_layout::Kernel_image_phys;
101 check_overlap ("VGA/IO", phys_start, phys_end, 0xa0000, 0x100000);
103 if (Checksum::get_checksum_ro() != check_sum.checksum_ro)
104 panic("Read-only (text) checksum does not match.");
106 if (Checksum::get_checksum_rw() != check_sum.checksum_rw)
107 panic("Read-write (data) checksum does not match.");
109 start(check_sum.checksum_ro);