CeDOS - Commit 4d1bca99

Added A20 check Booting aborts if A20 is disabled
Celina Sophie Kalus
Mon, 25 Dec 2017 18:40:52 +0100
2 files changed, 61 insertions(+), 3 deletions(-)
M boot/boot.sboot/boot.s

@@ -24,8 +24,22 @@ movb $0, %al

movb $0x05, %ah int $0x10 + # check if A20 gate is enabled + mov $a20_msg, %si + call print + call checkA20 + je disabled +enabled: + call print_done + jmp resume +disabled: + call print_fail + jmp disabled +resume: + + # TODO: - # - activate A20 gate + # - activate A20 gate # reset bootdrive reset:

@@ -119,6 +133,48 @@ int $0x10

jmp print_loop print_end: ret + +print_done: + mov $done_msg, %si + jmp print + +print_fail: + mov $fail_msg, %si + jmp print + + # ############################################ + # checkA20 + # checks if A20 line is enabled + # equal flag: * clear, if A20 is enabled + # * set, if A20 is disabled + # ############################################ +checkA20: + push %ds + push %es + push %si + push %di + + mov $0x0000, %ax + mov %ax, %ds + mov $0xFFFF, %ax + mov %ax, %es + + mov $0x7DFE, %si + mov $0x7E0E, %di + + movw %ds:(%si), %cx + movw %es:(%di), %dx + cmp %cx, %dx + + pop %di + pop %si + pop %es + pop %ds + ret + +a20_msg: + .ascii "Enabling A20..." + .byte 0 reset_msg: .ascii "Resett"
M makefilemakefile

@@ -8,10 +8,12 @@

export GCC_PREFIX = $(HOME)/opt/cross/i686-elf-/bin/i686-elf- ifdef DEBUG -export GCC_OPTIONS = -O1 -Wno-write-strings -Qn -Wall -Wextra -fno-exceptions -nostdlib -nostartfiles -ffreestanding +GCC_OPTIONS = -D DEBUG -O0 -Wno-write-strings -Qn -Wall -Wextra -fno-exceptions -nostdlib -nostartfiles -ffreestanding else -export GCC_OPTIONS = -D DEBUG -O0 -Wno-write-strings -Qn -Wall -Wextra -fno-exceptions -nostdlib -nostartfiles -ffreestanding +GCC_OPTIONS = -O1 -Wno-write-strings -Qn -Wall -Wextra -fno-exceptions -nostdlib -nostartfiles -ffreestanding endif + +export GCC_OPTIONS # OBJ_FILES = $(wildcard obj/asm/*.o) $(wildcard obj/cpp/*.o)