]> git.lizzy.rs Git - nyax.git/commitdiff
Redesign kernel/stack/pagetable layout
authorElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 22 Aug 2022 19:46:27 +0000 (21:46 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 22 Aug 2022 19:46:51 +0000 (21:46 +0200)
Makefile
boot.asm

index af1e7af41db27708961bf874b9f5f375a3a1eca7..193a19b187b547d189a1f06a351289d11072d8f3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,3 +15,7 @@ main.out: $(OBJS)
 .PHONY: run
 run: nyax.img
        bochs -q
+
+.PHONY: clean
+clean:
+       rm -rf *.o *.out *.img
index bb147bbd8e2f0dd1765c6948f75aeccef3fdae84..415449eb161e129f973664aaa03a831e4f92926f 100644 (file)
--- a/boot.asm
+++ b/boot.asm
@@ -1,5 +1,9 @@
 [org 0x7C00]
 
+%define PAGETABLE 0x1000
+%define KERNEL 0xD000
+%define STACK 0x7E00
+
 boot:
        xor ax, ax
        mov ds, ax
@@ -8,34 +12,30 @@ boot:
        mov gs, ax
        mov ss, ax
 
-       mov bp, 0x9000
+       mov bp, STACK
        mov sp, bp
 
        mov ax, booting_msg
        call print_str
 
-       mov bx, 0xD000
+       mov bx, KERNEL
        mov cl, 2
        mov al, (MAIN_SIZE + 511) / 512
        call load_disk
 
-       ;mov cl, 3
-       ;mov al, [es:bx]
-       ;call load_disk
-
-       mov di, 0x9000
+       mov di, PAGETABLE+0x0000
 .clr_buf:
        mov byte[di], 0
        inc di
-       cmp di, 0xD000
+       cmp di, PAGETABLE+0x4000
        jne .clr_buf
 
-       mov dword[0x9000], 0xA003
-       mov dword[0xA000], 0xB003
-       mov dword[0xB000], 0xC003
+       mov dword[PAGETABLE+0x0000], PAGETABLE+0x1003
+       mov dword[PAGETABLE+0x1000], PAGETABLE+0x2003
+       mov dword[PAGETABLE+0x2000], PAGETABLE+0x3003
 
        mov eax, 3
-       mov di, 0xC000
+       mov di, PAGETABLE+0x3000
 .build_pt:
        mov [di], eax
        add eax, 0x1000
@@ -43,7 +43,7 @@ boot:
        cmp eax, 0x100000
        jb .build_pt
 
-       mov di, 0x9000
+       mov di, PAGETABLE
 
        mov al, 0xFF
        out 0xA1, al
@@ -108,7 +108,7 @@ print_str:
        pop ax
        ret
 
-booting_msg: db 10, 13, "Booting NyaX...", 10, 10, 13, 0
+booting_msg: db 10, 13, "Loading NyaX...", 10, 10, 13, 0
 disk_error_msg: db "Disk is bwoken, cant boot ;-;", 10, 13, 0
 
 GDT:
@@ -134,7 +134,7 @@ long_mode:
        mov gs, ax
        mov ss, ax
 
-       jmp 0xD000
+       jmp KERNEL
 
 times 510-($-$$) db 0
 dw 0xAA55