Sun, 17 Dec 2017 01:32:48 +0100
4 files changed,
42 insertions(+),
23 deletions(-)
M
boot/boot.s
→
boot/boot.s
@@ -55,18 +55,9 @@ # dl (drive) keep as is
int $0x13 jnc load - # prints out string thats loaded into memory at 0x00010000 - # remove this test later - mov $0x1000, %ax - mov %ax, %ds - mov $0, %si - call print - xor %ax, %ax - mov %ax, %ds - mov %ax, %es - # - load global descriptor table and far jump into protected mode lgdt (GDT_DESCRIPTOR) + lidt (IDT_DESCRIPTOR) mov %cr0, %eax or $1, %eax@@ -76,15 +67,15 @@ ljmp $0x8, $protected
.code32 protected: + # setup registers with appropriate GDT values + mov $0x10, %eax + mov %eax, %ds + mov %eax, %es + mov %eax, %fs + mov %eax, %gs - - # TODO: - # - jump to second stage code - - - # loop forever -loop: - jmp loop + # jump to second stage code + ljmp $0x08, $_ss_start .code16@@ -115,8 +106,12 @@ .byte 10
.byte 0 GDT_DESCRIPTOR: + .word 0x23 .int GDT - .word 0x23 + +IDT_DESCRIPTOR: + .word 0 + .int 0 end: .=510
M
second_stage/entry.s
→
second_stage/entry.s
@@ -1,6 +1,30 @@
.section .text -.global _start -_start: +.global _ss_start +_ss_start: + + # this code prints out all ascii characters in reverse order in + # rainbow colors just to test if this point of the code was reached + # (you might call it overkill, i call it fabulous) + mov $255, %ecx + mov $0xB8000, %esi + +test: + movb %cl, (%esi) + inc %esi + movb %cl, (%esi) + inc %esi + loop test + + + # TODO: + # - copy the kernel code to 0x00100000 + # - create a page directory for the kernel that maps it to 0xC0000000 + # and identity maps the first 1M of memory + # - enable paging + # - jump to kernel code + + + # loop until the heat death of the universe loop: jmp loop
M
second_stage/link.txt
→
second_stage/link.txt
@@ -1,7 +1,7 @@
INPUT(build/entry.o build/gdt.o) OUTPUT_FORMAT(elf32-i386) OUTPUT_ARCH(i386) -ENTRY(_start) +ENTRY(_ss_start) SECTIONS {