diff options
author | Xander <xander@biltopia.org> | 2023-08-20 22:57:07 +0200 |
---|---|---|
committer | Xander <xander@biltopia.org> | 2023-08-20 23:03:17 +0200 |
commit | 70cca66089896730797a71ba545c7f4e87b12975 (patch) | |
tree | 167a22d505b32bf80bd8b432833e12a74a98941b /kernel/main.dats | |
parent | 7fce269442cb37810a14d088ea4a61d040ec3066 (diff) | |
download | ats-os-master.tar.xz ats-os-master.zip |
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(); |