aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/boot/boot.asm3
-rw-r--r--arch/x86_64/boot/linker.ld12
-rw-r--r--kernel/main.dats29
-rw-r--r--kernel/prelude/DATS/print.dats26
-rw-r--r--kernel/prelude/kernel_prelude.hats3
5 files changed, 63 insertions, 10 deletions
diff --git a/arch/x86_64/boot/boot.asm b/arch/x86_64/boot/boot.asm
index 1abda41..3f85423 100644
--- a/arch/x86_64/boot/boot.asm
+++ b/arch/x86_64/boot/boot.asm
@@ -5,6 +5,7 @@ section .text
bits 32
start:
mov esp, stack_top
+ mov edi, ebx ;Move Multiboot info pointer to edi
call check_multiboot
call check_cpuid
@@ -150,7 +151,7 @@ p3_table:
p2_table:
resb 4096
stack_bottom:
- resb 4096
+ resb 4096 * 4
stack_top:
section .rodata
diff --git a/arch/x86_64/boot/linker.ld b/arch/x86_64/boot/linker.ld
index 5d788f1..0ad745e 100644
--- a/arch/x86_64/boot/linker.ld
+++ b/arch/x86_64/boot/linker.ld
@@ -6,11 +6,19 @@ SECTIONS {
.boot :
{
/* ensure that the multiboot header is at the beginning */
- *(.multiboot_header)
+ KEEP(*(.multiboot_header))
}
.text :
{
- *(.text)
+ *(.text .text.*)
+ }
+
+ .rodata : {
+ *(.rodata .rodata.*)
+ }
+
+ .data.rel.ro : {
+ *(.data.rel.ro.local*) *(.data.rel.ro .data.rel.ro.*)
}
}
diff --git a/kernel/main.dats b/kernel/main.dats
index d6e29f4..b35387f 100644
--- a/kernel/main.dats
+++ b/kernel/main.dats
@@ -1,6 +1,11 @@
#include "./prelude/kernel_prelude.hats"
+#define ATS_DYNLOADFLAG 0
+
staload "kernel/interrupts/idt.sats"
+staload "lib/SATS/writer.sats"
+
+staload UN = "prelude/SATS/unsafe.sats"
%{^
void breakpoint(){
@@ -8,10 +13,29 @@ staload "kernel/interrupts/idt.sats"
}
%}
+extern castfn char_arr2string {n:nat} (arr : &(@[char][n])) : string n
+
extern fun breakpoint() :void = "mac#"
-implement main0 () = (
+extern fun main(p : ptr) : void = "ext#"
+implement main(p) = let
+ prval size = $UN.ptr0_get<strptr>(ptr_add<uint8>(p,
+ 8 +
+ 16 +
+ 16 +
+ 4 + 4
+ (* 16 + *)
+ (* 8 + *)
+ (* 32 + *)
+ (* 16 + 24 + 24 + 24 + 24 + 24 + 48 + // memory map *)
+ (* 792 + // elf *)
+ (* 4 + 4 + 4 *)
+ ))
+in
+
+ clear_screen();
println!("Start");
+ (* println!(size); *)
// Initialize interrupt table
idt_init();
@@ -20,4 +44,5 @@ implement main0 () = (
breakpoint();
println!("End");
-)
+
+end
diff --git a/kernel/prelude/DATS/print.dats b/kernel/prelude/DATS/print.dats
index 6d378fa..0b5c38a 100644
--- a/kernel/prelude/DATS/print.dats
+++ b/kernel/prelude/DATS/print.dats
@@ -5,16 +5,38 @@
staload "lib/SATS/writer.sats"
staload "lib/DATS/itoa.dats"
+staload UN = "prelude/SATS/unsafe.sats"
+
extern fun print_newline() : void
implement print_newline() = put_string("\n")
extern fun assert_errmsg(b: bool, msg: string) : void
implement assert_errmsg(b,msg) = if (~b) then put_string(msg)
-extern fun print_int (n : int) : void
+extern fun print_int (n : int) : void
implement print_int(n) = put_string(itoa(n,10))
-
+
+extern fun print_uint32 (n : uint32) : void
+implement print_uint32 (n) = put_string(itoa($UN.cast{int}(n),10))
+
+extern fun print_uint16 (n : uint16) : void
+implement print_uint16 (n) = put_string(itoa($UN.cast{int}(n),10))
+
+extern fun print_uint8 (n : uint8) : void
+implement print_uint8 (n) = put_string(itoa($UN.cast{int}(n),10))
+
+extern fun print_uint64 (n : uint64) : void
+implement print_uint64 (n) = put_string(itoa($UN.cast{int}(n),10))
+
overload print with put_string of 1
overload print with print_int of 1
+overload print with print_uint32 of 1
+overload print with print_uint64 of 1
+overload print with print_uint16 of 1
+overload print with print_uint8 of 1
+
+extern fun {a : t@ype} println_base {n:nat | n > 1 && n < 33} (n :a, base : int n) : void
+implement{a} println_base(n,base) = println!(itoa($UN.cast{int}(n), base))
+macdef println_hex(s) = (put_string "0x"; println_base(,(s), 16))
macdef assertloc(tf) = assert_errmsg (,(tf), $mylocation)
diff --git a/kernel/prelude/kernel_prelude.hats b/kernel/prelude/kernel_prelude.hats
index eb1990d..39e7560 100644
--- a/kernel/prelude/kernel_prelude.hats
+++ b/kernel/prelude/kernel_prelude.hats
@@ -3,9 +3,6 @@
#include "share/atspre_staload.hats"
-staload "lib/SATS/writer.sats"
-val () = clear_screen()
-
staload "./DATS/print.dats"
#endif