diff options
Diffstat (limited to 'kernel/main.dats')
-rw-r--r-- | kernel/main.dats | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/kernel/main.dats b/kernel/main.dats index 65cb8df..f18c2e1 100644 --- a/kernel/main.dats +++ b/kernel/main.dats @@ -3,6 +3,12 @@ staload "kernel/interrupts/idt.sats" staload BOOT = "kernel/bootinfo/multiboot.sats" staload FRAME = "kernel/memory/frame.sats" +staload ENTRY = "kernel/memory/paging/entry.sats" +staload PAGE = "kernel/memory/paging/page.sats" + +staload "lib/SATS/valid.sats" +staload "lib/DATS/valid.dats" + staload "lib/SATS/writer.sats" #define ATS_DYNLOADFLAG 0 @@ -28,9 +34,27 @@ in end fn test() : void = let - fun loop(i : int) : void = if (i < 160) then( let val _ = $FRAME.allocate_frame() in end; loop(succ(i))) + val a = sz_to_Ptr0(i2sz(42 * 512 * 512 * 4096)); // 42th P3 entry + val page = $PAGE.containing_address(a) + val () = println!("page num: ", page.num) + val frame = $FRAME.allocate_frame() + var flags = @[$ENTRY.entry_flag]($ENTRY.WRITABLE) + val () = $PAGE.map_to(page,frame,flags,i2sz(1)) + val aframe = $PAGE.translate(a) + val frame2 = $FRAME.allocate_frame() + (* val () = println!("Map to ", frame.num) *) in - loop(0) + if (is_valid(aframe)) then + let + val vframe = unwrap_valid(aframe) + in + println!("Got ",vframe) + end + else ( + destroy_unvalid(aframe); + println!("Unvalid aframe") + ); + println!("frame2: ", frame2.num) end @@ -45,16 +69,11 @@ implement main(p) = let val () = $FRAME.init(kernel_start,kernel_end,multiboot_start,multiboot_end); in - $BOOT.print_memory_mappings(); - $BOOT.print_elf_headers(); + (* $BOOT.print_memory_mappings(); *) + (* $BOOT.print_elf_headers(); *) println!("Kernel Size: ", kernel_size(kernel_start,kernel_end)); test(); - let - val frame = $FRAME.allocate_frame() - in - println!(frame.num) - end; // Initialize interrupt table idt_init(); |