+ in $0x92, %al
+ or $2, %al
+ out %al, $0x92
+ ret
+
+ena20_fast_msg: .asciz "Attempting fast A20 enable\n"
+
+
+ # enable A20 line through the keyboard controller
+ .set KBC_DATA_PORT, 0x60
+ .set KBC_CMD_PORT, 0x64
+ .set KBC_STATUS_PORT, 0x64
+ .set KBC_CMD_RD_OUTPORT, 0xd0
+ .set KBC_CMD_WR_OUTPORT, 0xd1
+
+ .set KBC_STAT_OUT_RDY, 0x01
+ .set KBC_STAT_IN_FULL, 0x02
+
+enable_a20_kbd:
+ mov $ena20_kbd_msg, %esi
+ call putstr
+
+ call kbc_wait_write
+ mov $KBC_CMD_WR_OUTPORT, %al
+ out %al, $KBC_CMD_PORT
+ call kbc_wait_write
+ mov $0xdf, %al
+ out %al, $KBC_DATA_PORT
+ ret
+
+ena20_kbd_msg: .asciz "Attempting KBD A20 enable\n"
+
+ # wait until the keyboard controller is ready to accept another byte
+kbc_wait_write:
+ in $KBC_STATUS_PORT, %al
+ and $KBC_STAT_IN_FULL, %al
+ jnz kbc_wait_write
+ ret