6 #define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
7 #define K_STATUS 0x64 /* keyboard status */
8 #define K_CMD 0x64 /* keybd ctlr command (write-only) */
10 #define K_OBUF_FUL 0x01 /* output buffer full */
11 #define K_IBUF_FUL 0x02 /* input buffer full */
13 #define KC_CMD_WIN 0xd0 /* read output port */
14 #define KC_CMD_WOUT 0xd1 /* write output port */
15 #define KB_SET_A20 0xdf /* enable A20,
16 enable output buffer full interrupt
19 #define KB_UNSET_A20 0xdd /* enable A20,
20 enable output buffer full interrupt
24 enum { Disable_A20 = 0x2400, Enable_A20 = 0x2401, Query_A20_Status = 0x2402,
25 Query_A20_Support = 0x2403 };
30 static void empty_8042 ( void ) {
33 time = currticks() + TICKS_PER_SEC; /* max wait of 1 second */
34 while ( ( inb ( K_CMD ) & K_IBUF_FUL ) &&
35 currticks() < time ) {
36 /* Do nothing. In particular, do *not* read from
37 * K_RDWR, because that will drain the keyboard buffer
38 * and lose keypresses.
45 * Gate A20 for high memory
47 * Note that this function gets called as part of the return path from
48 * librm's real_call, which is used to make the int15 call if librm is
49 * being used. To avoid an infinite recursion, we make gateA20_set
50 * return immediately if it is already part of the call stack.
52 void gateA20_set ( void ) {
53 static char reentry_guard = 0;
54 unsigned int discard_a;
61 __asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
67 : "=r" ( flags ), "=a" ( discard_a )
68 : "a" ( Enable_A20 ) );
72 /* INT 15 method failed, try alternatives */
77 outb(KC_CMD_WOUT, K_CMD);
79 outb(KB_SET_A20, K_RDWR);
87 void gateA20_unset ( void ) {
88 /* Not currently implemented */