aboutsummaryrefslogtreecommitdiff
path: root/kernel/main.dats
diff options
context:
space:
mode:
authorXander <xander@biltopia.org>2023-08-08 22:17:40 +0200
committerXander <xander@biltopia.org>2023-08-08 22:17:40 +0200
commit245f24890cd78304cf0fd397dda8e72b0a7fbe6b (patch)
tree7210e4d4489b7281fb9213745b4776846402103b /kernel/main.dats
parentcef3f6bdddfe768e7a1a84edcec76c11c1634941 (diff)
downloadats-os-245f24890cd78304cf0fd397dda8e72b0a7fbe6b.tar.xz
ats-os-245f24890cd78304cf0fd397dda8e72b0a7fbe6b.zip
more refactoring and implemented exec_init
Diffstat (limited to 'kernel/main.dats')
-rw-r--r--kernel/main.dats33
1 files changed, 15 insertions, 18 deletions
diff --git a/kernel/main.dats b/kernel/main.dats
index 7b7c162..96cfdda 100644
--- a/kernel/main.dats
+++ b/kernel/main.dats
@@ -13,17 +13,17 @@ staload "lib/SATS/writer.sats"
//NOTE: how to make sure ats checks 2 contstraints in one if statement?
//TODO: put in seperate utils module (just generic size function)
-(* 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 *)
+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
(* fn test(allocptr : !allocptr, bootptr : !bootptr) : void = let *)
(* fun loop(i : int) : void = if (i < 160) then( let val _ = allocate_frame(allocptr.0, bootptr.0 | allocptr.2, bootptr.2) in end; loop(succ(i))) *)
@@ -37,20 +37,17 @@ extern fun breakpoint() :void = "mac#"
extern fun entry(p : Ptr1) : void = "ext#"
implement entry(p) = let
-
-
- (* val (kernel_start,kernel_end) = get_kernel_ranges(bootptr) *)
+ val () = $BOOT.init(p);
+ val (kernel_start,kernel_end) = $BOOT.get_kernel_ranges()
(* val (multiboot_start,multiboot_end) = get_multiboot_ranges(bootptr) *)
(* val allocptr = frame_allocator_init(kernel_start,kernel_end,multiboot_start,multiboot_end,bootptr) *)
in
// Initialize boot info struct
- $BOOT.init(p);
- clear_screen();
$BOOT.print_memory_mappings();
+ $BOOT.print_elf_headers();
- (* print_elf_headers(bootptr); *)
- (* println!("Kernel Size: ", kernel_size(kernel_start,kernel_end)); *)
+ println!("Kernel Size: ", kernel_size(kernel_start,kernel_end));
(* test(allocptr,bootptr); *)
(* let *)
(* val frame = allocate_frame(allocptr.0, bootptr.0 | allocptr.2, bootptr.2) *)