aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/boot32.s59
1 files changed, 19 insertions, 40 deletions
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