aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/boot/boot.zig (renamed from src/bootstrap/boot.zig)0
-rw-r--r--src/boot/boot32.s (renamed from src/bootstrap/boot32.s)66
-rw-r--r--src/boot/boot64.s (renamed from src/bootstrap/boot64.s)7
-rw-r--r--src/main.zig2
4 files changed, 34 insertions, 41 deletions
diff --git a/src/bootstrap/boot.zig b/src/boot/boot.zig
index 998e1e5..998e1e5 100644
--- a/src/bootstrap/boot.zig
+++ b/src/boot/boot.zig
diff --git a/src/bootstrap/boot32.s b/src/boot/boot32.s
index dc02102..5650422 100644
--- a/src/bootstrap/boot32.s
+++ b/src/boot/boot32.s
@@ -7,32 +7,27 @@
/* Entry point. It puts the machine into a consistent state and starts long mode. */
_start:
mov $0x80000, %esp // Setup the stack.
- push %ebx // Pass multiboot info structure.
- push %eax // Pass multiboot magic code.
-
- call check_multiboot
- call check_cpuid
- call check_long_mode
-
- call setup_page_tables
- call enable_paging
+
+ call boot_check_multiboot
+ call boot_check_cpuid
+ call boot_check_long_mode
- lgdt (gdtdesc)
- jmpl $0x8, $long_mode_start
+ call boot_setup_page_tables
+ call boot_enable_paging
- call halt
-halt:
+ lgdt (boot_gdtdesc)
+ jmpl $0x8, $boot_long_mode_start
hlt
-check_multiboot:
+boot_check_multiboot:
cmp $0x36d76289, %eax
- jne .no_multiboot
+ jne .boot_no_multiboot
ret
-.no_multiboot:
+.boot_no_multiboot:
mov $'M', %al
- jmp error
+ jmp boot_error
-check_cpuid:
+boot_check_cpuid:
pushfd
pop %eax
mov %eax, %ecx
@@ -44,29 +39,29 @@ check_cpuid:
push %ecx
popfd
cmp %eax, %ecx
- je .no_cpuid
+ je .boot_no_cpuid
ret
-.no_cpuid:
+.boot_no_cpuid:
mov $'C', %al
- jmp error
+ jmp boot_error
-check_long_mode:
+boot_check_long_mode:
mov $0x80000000, %eax
cpuid
cmp $0x80000001, %eax
- jb .no_long_mode
+ jb .boot_no_long_mode
mov $0x80000001, %eax
cpuid
test $(1 << 29), %edx
- jz .no_long_mode
+ jz .boot_no_long_mode
ret
-.no_long_mode:
+.boot_no_long_mode:
mov $'L', %al
- jmp error
+ jmp boot_error
-setup_page_tables:
+boot_setup_page_tables:
mov $page_table_l3, %eax
or $0b11 , %eax /* present, writable */
mov %eax, (page_table_l4)
@@ -76,7 +71,7 @@ setup_page_tables:
mov %eax, (page_table_l3)
mov $0, %ecx /* counter */
-.loop:
+.boot_pages_loop:
mov $0x200000, %eax /* 2MiB */
mul %ecx
@@ -85,11 +80,11 @@ setup_page_tables:
inc %ecx /* increment counter */
cmp $512, %ecx /* checks if the whole table is mapped */
- jne .loop /* if not, continue */
+ jne .boot_pages_loop /* if not, continue */
ret
-enable_paging:
+boot_enable_paging:
/* pass page table location to cpu */
mov $page_table_l4, %eax
mov %eax, %cr3
@@ -112,7 +107,7 @@ enable_paging:
ret
-error:
+boot_error:
/* print in VGA "ERR: X" where X is the error code */
movl $0x4f524f45, 0xb8000
movl $0x4f3a4f52, 0xb8004
@@ -134,10 +129,9 @@ stack_top:
.section .rodata
.p2align 2 /* force 4 byte alignment */
-gdt64:
+boot_gdt64:
.quad 0 /* zero entry */
-.code_segment:
.quad (1 << 43) | (1 << 44) | (1 << 47) | (1 << 53) /* code segment */
-gdtdesc:
- .word (gdtdesc - gdt64 - 1) /* sizeof(gdt) - 1 */
- .long gdt64 /* address gdt */ \ No newline at end of file
+boot_gdtdesc:
+ .word (boot_gdtdesc - boot_gdt64 - 1) /* sizeof(gdt) - 1 */
+ .long boot_gdt64 /* address gdt */ \ No newline at end of file
diff --git a/src/bootstrap/boot64.s b/src/boot/boot64.s
index 493912b..e851388 100644
--- a/src/bootstrap/boot64.s
+++ b/src/boot/boot64.s
@@ -1,9 +1,9 @@
-.global long_mode_start
+.global boot_long_mode_start
.extern kmain
.section .text
.code64
-long_mode_start:
+boot_long_mode_start:
// load null into all data segment registers
mov $0, %ax
mov %ax, %ss
@@ -12,5 +12,4 @@ long_mode_start:
mov %ax, %fs
mov %ax, %gs
- call kmain
- hlt \ No newline at end of file
+ jmp kmain \ No newline at end of file
diff --git a/src/main.zig b/src/main.zig
index 36dcd5e..e647a81 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,5 +1,5 @@
comptime {
- _ = @import("bootstrap/boot.zig");
+ _ = @import("boot/boot.zig");
}
const debug = @import("debugcon.zig");