From 1d25d9783127c181f79732eb5c20c680444af414 Mon Sep 17 00:00:00 2001 From: Xander Date: Fri, 21 Jul 2023 21:36:54 +0200 Subject: Mainly refactoring --- kernel/main.dats | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'kernel/main.dats') diff --git a/kernel/main.dats b/kernel/main.dats index 94955ee..c57f53d 100644 --- a/kernel/main.dats +++ b/kernel/main.dats @@ -14,8 +14,19 @@ staload UN = "prelude/SATS/unsafe.sats" } %} +//NOTE: how to make sure ats checks 2 contstraints in one if statement? +fn kernel_size(kernel_start : Ptr, kernel_end : Ptr) : size_t = let + extern castfn Ptr12size (a : Ptr1): size_t +in + if (kernel_end > the_null_ptr) then + if (kernel_start > the_null_ptr) then + Ptr12size(kernel_end) - Ptr12size(kernel_start) + else + i2sz(0) + else + i2sz(0) +end -extern castfn char_arr2string {n:nat} (arr : &(@[char][n])) : string n extern fun breakpoint() :void = "mac#" @@ -25,10 +36,13 @@ implement main(p) = let // Initialize boot info struct val bootptr = boot_info_init(p) + val (kernel_start,kernel_end) = get_kernel_ranges(bootptr) in print_memory_mappings(bootptr); + print_elf_headers(bootptr); + println!("Kernel Size: ", kernel_size(kernel_start,kernel_end)); // Initialize interrupt table idt_init(); -- cgit v1.2.3