From 22e5f89bb1a88e22d86347f5ac32d6336169ca55 Mon Sep 17 00:00:00 2001 From: Nocturn9x Date: Fri, 18 Nov 2022 01:39:08 +0100 Subject: [PATCH] Added experimental code to enable A20 line --- src/boot/switch32.s | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/boot/switch32.s b/src/boot/switch32.s index 7fa64ce..b4338ab 100644 --- a/src/boot/switch32.s +++ b/src/boot/switch32.s @@ -16,12 +16,20 @@ [bits 16] switch_to_protected_mode: - cli ; We disable interrupts... - lgdt [gdt_descriptor] ; ... load the GDT descriptor... + ; We enable the A20 line using + ; the ol' but (mostly) reliable + ; keyboard controller method + mov al, 0xd1 + out 0x64, al + mov al, 0xdf + out 0x60, al + cli ; Now we disable interrupts + lgdt [gdt_descriptor] ; Time to load the GDT descriptor + ; We set 32-bit mode in CR0. Almost done! mov eax, cr0 - or eax, 0x1 ; ... set 32-bit mode in CR0 + or eax, 0x1 mov cr0, eax - jmp CODE_SEG:switch32 ; ... and perform a far jump using a different segment + jmp CODE_SEG:switch32 ; At last, we perform a far jump into a different segment [bits 32]