From 636e49fd2b8a3b897657412dc2493c978d15173f Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Fri, 17 Aug 2018 23:15:08 +0300 Subject: [PATCH] Now A20 line works --- Boot486/boot0.S | 161 +++++---------------------------------- Boot486/run.sh | 2 +- System/Mod486/Kernel.odc | Bin 84020 -> 85026 bytes 3 files changed, 21 insertions(+), 142 deletions(-) diff --git a/Boot486/boot0.S b/Boot486/boot0.S index 21608cb..9ff81fa 100644 --- a/Boot486/boot0.S +++ b/Boot486/boot0.S @@ -25,8 +25,9 @@ # Stage 1 # =========================================================================== # -.code16 _start: + +.code16 stage1: # 1. Setup canonical %cs:%eip, segment registers %ds, %es, %fs, %gs, %ss and stack %sp cli @@ -41,10 +42,10 @@ stage1: mov %dx, BootDiskAdr call mapmem + sti # 2. Enable A20 gate - call enable_A20 - sti + call enableA20 # 3. Reset disk controller (%dl and %dh initialized by bios) and read Kernel into buffer movl $(kernel_code_end - kernel_code_start), KernelSizeAdr @@ -263,161 +264,39 @@ readsectors__success: ret # =========================================================================== # -# Check that A20 Gate is enabled -# output: set zero flag if disabled -# restore: %ds %es +# Enable A20 Line # =========================================================================== # .code16 -check_A20: - push %ds - push %es -# push %ax -# push %di -# push %si - - xor %ax, %ax - mov %ax, %es - - not %ax - mov %ax, %ds - - mov $0x0500, %di - mov $0x0510, %si - - mov %es:0(%di), %al - push %ax - - mov %ds:0(%si), %al - push %ax - - movb $0x00, %es:0(%di) - movb $0xff, %ds:0(%si) - - cmpb $0xff, %es:0(%di) - - pop %ax - mov %es:0(%di), %al - - pop %ax - mov %es:0(%di), %al - - mov $0, %ax - - je check_A20__exit - - mov $1, %ax - -check_A20__exit: -# pop %si -# pop %di -# pop %ax - pop %es - pop %ds - or %al, %al - ret - -# =========================================================================== # -# Enable A20 Gate -# =========================================================================== # - -enable_A20: - /* First check */ - call check_A20 - jnz enable_A20__success - /* BIOS method */ - mov $0x2401, %ax - int $0x15 - - call check_A20 - jnz enable_A20__success - - /* Keyboard method 1 */ - mov $0xd0, %al - out %al, $0x64 - - call check_A20 - jnz enable_A20__success - - /* Keyboard method 2 */ -/* -# cli - - call enable_A20__wait1 - mov $0xad, %al - out %al, $0x64 - - call enable_A20__wait1 - mov $0xd0, %al - out %al, $0x64 - - enable_A20__wait2: +enableA20: + cli + xor %cx, %cx +enableA20_1: + inc %cx + jz enableA20_3 in $0x64, %al - test $1, %al - jz enable_A20__wait2 - - in $0x60, %al - push %eax - - call enable_A20__wait1 + test $0x2, %al + jnz enableA20_1 mov $0xd1, %al out %al, $0x64 - - call enable_A20__wait1 - pop %eax - or $2, %al - out %al, $0x64 - - call enable_A20__wait1 - mov $0xae, %al - out %al, $0x64 - - call enable_A20__wait1 -# sti - -# call check_A20 -# jnz enable_A20__success -*/ - - /* Control port A method */ - mov $1, %al - out %al, $0x92 - - call check_A20 - jnz enable_A20__success - - /* Fast method */ - in $0xee, %al - - call check_A20 - jnz enable_A20__success - - mov $msg_a20_failed, %si - call print -# cli -# hlt - -enable_A20__success: - ret - -/* -enable_A20__wait1: +enableA20_2: in $0x64, %al - test $2, %al - jnz enable_A20__wait1 + test $0x2, %al + jnz enableA20_2 + mov $0xdf, %al + out %al, $0x60 +enableA20_3: + sti ret -*/ # =========================================================================== # # =========================================================================== # # =========================================================================== # msg_mapmem_failed: .asciz "1" -msg_a20_failed: .asciz "2" msg_chs_error: .asciz "3" msg_kernel_read_failed: .asciz "4" - msg_protected_mode: .asciz ">5" current_sector: diff --git a/Boot486/run.sh b/Boot486/run.sh index a9c515f..4fc543e 100755 --- a/Boot486/run.sh +++ b/Boot486/run.sh @@ -1,4 +1,4 @@ #!/bin/sh set -e -qemu-system-i386 -s -m 1G -hda ../BlackBox.img +qemu-system-i386 -s -m 26M -hda ../BlackBox.img diff --git a/System/Mod486/Kernel.odc b/System/Mod486/Kernel.odc index 0930a934abbc3460d332291c68553683af90ba9a..02f3ca45d366e1c26443e26e33ad4b59faf2385f 100644 GIT binary patch delta 1311 zcmZ`%-)kII6rO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