aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2024-05-02 01:51:50 +0300
committerMarin Ivanov <[email protected]>2024-05-02 01:51:50 +0300
commita34fd654a2b44a7febe68f4a36e7f23457a20064 (patch)
tree4686caa38baa54515a49dcb7a9deed256a19c494
parent476d95c3d01d085013d2986997d0232c3a97d27b (diff)
cleanup: remove unused code and fix asm comments
-rw-r--r--build.zig2
-rw-r--r--src/boot32.s59
2 files changed, 19 insertions, 42 deletions
diff --git a/build.zig b/build.zig
index be894d5..a7a9ee2 100644
--- a/build.zig
+++ b/build.zig
@@ -46,8 +46,6 @@ pub fn build(b: *Build) !void {
kernel_step.dependOn(&kernel.step);
const iso_dir = b.fmt("{?s}/iso_root", .{b.cache_root.path});
- // const kernel_path = b.install_path ++ "/" ++ kernel.out_filename;
- // const kernel_path = b.getInstallPath(kernel.install_step.?.dest_dir, kernel.out_filename);
const kernel_path = try fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "bin", kernel.out_filename });
const iso_path = b.fmt("{s}/disk.iso", .{b.exe_dir});
diff --git a/src/boot32.s b/src/boot32.s
index e71d047..dc02102 100644
--- a/src/boot32.s
+++ b/src/boot32.s
@@ -4,7 +4,7 @@
.section .text
.code32
-// Entry point. It puts the machine into a consistent state and starts long mode.
+/* 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.
@@ -19,7 +19,6 @@ _start:
lgdt (gdtdesc)
jmpl $0x8, $long_mode_start
- //jmp gdt64.code_segment:long_mode_start
call halt
halt:
@@ -69,44 +68,44 @@ check_long_mode:
setup_page_tables:
mov $page_table_l3, %eax
- or $0b11 , %eax // present, writable
+ or $0b11 , %eax /* present, writable */
mov %eax, (page_table_l4)
mov $page_table_l2, %eax
- or $0b11, %eax // present, writable
+ or $0b11, %eax /* present, writable */
mov %eax, (page_table_l3)
- mov $0, %ecx // counter
+ mov $0, %ecx /* counter */
.loop:
- mov $0x200000, %eax // 2MiB
+ mov $0x200000, %eax /* 2MiB */
mul %ecx
- or $0b10000011, %eax // present, writable, huge page
+ or $0b10000011, %eax /* present, writable, huge page */
mov %eax, +page_table_l2(,%ecx,8)
- inc %ecx // increment counter
- cmp $512, %ecx // checks if the whole table is mapped
- jne .loop // if not, continue
+ inc %ecx /* increment counter */
+ cmp $512, %ecx /* checks if the whole table is mapped */
+ jne .loop /* if not, continue */
ret
enable_paging:
- // pass page table location to cpu
+ /* pass page table location to cpu */
mov $page_table_l4, %eax
mov %eax, %cr3
- // enable PAE
+ /* enable PAE */
mov %cr4, %eax
or $(1 << 5), %eax
mov %eax, %cr4
- // enable long mode
+ /* enable long mode */
mov $0xC0000080, %ecx
rdmsr
or $(1 << 8), %eax
wrmsr
- // enable paging
+ /* enable paging */
mov %cr0, %eax
or $(1 << 31), %eax
mov %eax, %cr0
@@ -114,7 +113,7 @@ enable_paging:
ret
error:
- // // print "ERR: X" where X is the error code
+ /* print in VGA "ERR: X" where X is the error code */
movl $0x4f524f45, 0xb8000
movl $0x4f3a4f52, 0xb8004
movl $0x4f204f20, 0xb8008
@@ -134,31 +133,11 @@ stack_bottom:
stack_top:
.section .rodata
-.p2align 2 # force 4 byte alignment
+.p2align 2 /* force 4 byte alignment */
gdt64:
- .quad 0 // zero entry
+ .quad 0 /* zero entry */
.code_segment:
- .quad (1 << 43) | (1 << 44) | (1 << 47) | (1 << 53) # 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
-
-//# Bootstrap GDT
-//gdt:
-// SEG_NULLASM # null seg
-// SEG_ASM(STA_X|STA_R, 0x0, 0xffffffff) # code seg
-// SEG_ASM(STA_W, 0x0, 0xffffffff) # data seg
-//
-//gdtdesc:
-// .word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
-// .long gdt # address gdt
-//
-//section .rodata
-//gdt64:
-// dq 0 ; zero entry
-//.code_segment: equ $ - gdt64
-// dq (1 << 43) | (1 << 44) | (1 << 47) | (1 << 53) ; code segment
-//.pointer:
-// dw $ - gdt64 - 1 ; length
-// dq gdt64 ; address
-// \ No newline at end of file
+ .word (gdtdesc - gdt64 - 1) /* sizeof(gdt) - 1 */
+ .long gdt64 /* address gdt */ \ No newline at end of file