CeDOS - Commit a0f7ba88

Minor changes
Celina Sophie Kalus
Sun, 24 Dec 2017 00:51:21 +0100
3 files changed, 48 insertions(+), 12 deletions(-)
M boot/boot.sboot/boot.s

@@ -24,18 +24,20 @@ movb $0, %al

movb $0x05, %ah int $0x10 - # print hello world - movw $message, %si - call print - # TODO: # - activate A20 gate # reset bootdrive reset: + movw $reset_msg, %si + call print + movb $0x00, %ah int $0x13 - jc reset + jc error + + movw $done_msg, %si + call print # load second stage into memory starting at adress 0x10000 # (NOTE: this code can only be jumped to after loading the global descriptor table

@@ -43,20 +45,33 @@ # because it uses absolute adresses larger than 16 bit)

# (NOTE2: this routine only loads 0x48 sectors of the second stage into memory # and is in general pretty whacky. should be replaced with sth more serious) load: + movw $load_msg, %si + call print + movw $0x0000, %bx # buffer address movw $0x1000, %ax movw %ax, %es # buffer address (segment) movb $0x02, %ah # function 0x02: read a sector - movb $0x48, %al # sectors to read count + movb $0x048, %al # sectors to read count movb $0x00, %ch # cylinder movb $0x02, %cl # sector movb $0x00, %dh # head # dl (drive) keep as is int $0x13 - jnc load + jc error + + movw $done_msg, %si + call print + + movw $gdt_msg, %si + call print # - load global descriptor table and far jump into protected mode lgdt (GDT_DESCRIPTOR) + + movw $done_msg, %si + call print + lidt (IDT_DESCRIPTOR) mov %cr0, %eax

@@ -79,6 +94,11 @@ # jump to second stage code

ljmp $0x08, $_ss_start .code16 +error: + movw $fail_msg, %si + call print +error_loop: + jmp error_loop # ############################################ # print

@@ -98,10 +118,26 @@ jmp print_loop

print_end: ret +reset_msg: + .ascii "Resetting bootdrive..." + .byte 0 - # some data -message: - .ascii "Hello World!" +load_msg: + .ascii "Loading bootdrive..." + .byte 0 + +gdt_msg: + .ascii "Setting GDT..." + .byte 0 + +done_msg: + .ascii "done" + .byte 13 + .byte 10 + .byte 0 + +fail_msg: + .ascii "fail" .byte 13 .byte 10 .byte 0
M makefilemakefile

@@ -6,7 +6,7 @@ export INCLUDE_DIR = $(CURRENT_DIR)/include

export DEBUG_DIR = $(CURRENT_DIR)/debug export GCC_PREFIX = $(HOME)/opt/cross/i686-elf-/bin/i686-elf- -export GCC_OPTIONS = -O0 -Wno-write-strings -Wall -Wextra -fno-exceptions -nostdlib -nostartfiles -ffreestanding +export GCC_OPTIONS = -O0 -Wno-write-strings -Qn -Wall -Wextra -fno-exceptions -nostdlib -nostartfiles -ffreestanding # OBJ_FILES = $(wildcard obj/asm/*.o) $(wildcard obj/cpp/*.o)
M run.shrun.sh

@@ -1,1 +1,1 @@

-qemu -L .\ -fda build/base.img -m 64 -monitor stdio -no-reboot -d int,cpu_reset 2> debug/err.log+qemu -drive index=0,if=floppy,format=raw,file=build/base.img -m 64 -monitor stdio -no-reboot -d int,cpu_reset 2> debug/err.log