キーボードコントローラーによりA20以上のアドレスバスを有効にする
code:enable_a20_by_kbd.asm
kbd_io_data equ 60h
kbd_io_cmd equ 64h
kbd_io_status equ 64h
kbd_cmd_disable_kbd equ 0adh
kbd_cmd_enable_kbd equ 0aeh
kbd_cmd_read_port2 equ 0d0h
kbd_cmd_write_port2 equ 0d1h
kbd_status_in_ready_mask equ 01h
kbd_status_out_not_ready_mask equ 02h
kbd_port2_gatea20_mask equ 02h
enable_a20_by_kbd:
cli
call wait_kbd_for_out
mov al, kbd_cmd_disable_kbd
out kbd_io_cmd, al
call wait_kbd_for_out
mov al, kbd_cmd_read_port2
out kbd_io_cmd, al
call wait_kbd_for_in
in al, kbd_io_data
push ax
call wait_kbd_for_out
mov al, kbd_cmd_write_port2
out kbd_io_cmd, al
call wait_kbd_for_out
pop ax
or al, kbd_port2_gatea20_mask
out kbd_io_data, al
call wait_kbd_for_out
mov al, kbd_cmd_enable_kbd
out kbd_io_cmd, al
call wait_kbd_for_out
sti
ret
wait_kbd_for_out:
in al, kbd_io_status
test al, kbd_status_out_not_ready_mask
jnz wait_kbd_for_out
ret
wait_kbd_for_in:
in al, kbd_io_status
test al, kbd_status_in_ready_mask
jz wait_kbd_for_in
ret
参考