1 /* $NetBSD: gatea20.c,v 1.12 2009/08/23 12:31:05 jmcneill Exp $ */
3 /* extracted from freebsd:sys/i386/boot/biosboot/io.c */
7 #include <lib/libsa/stand.h>
13 #define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
14 #define K_STATUS 0x64 /* keyboard status */
15 #define K_CMD 0x64 /* keybd ctlr command (write-only) */
17 #define K_OBUF_FUL 0x01 /* output buffer full */
18 #define K_IBUF_FUL 0x02 /* input buffer full */
20 #define KC_CMD_WIN 0xd0 /* read output port */
21 #define KC_CMD_WOUT 0xd1 /* write output port */
22 #define KB_A20 0x9f /* enable A20,
24 enable output buffer full interrupt
29 * Gate A20 for high memory
31 static unsigned char x_20
= KB_A20
;
40 * First, try asking the BIOS to enable A20.
42 * If that fails, try system configuration port 0x92 but only
43 * if known to be necessary. Not all systems enable A20 via the
44 * keyboard controller, some don't have keyboard controllers,
45 * and playing with port 0x92 may cause some systems to break.
47 * Otherwise, use the traditional method (keyboard controller).
55 biosmca_ps2model
== 0xf82 ||
57 (inb(K_STATUS
) == 0xff && inb(K_RDWR
) == 0xff)) {
61 outb(0x92, data
| 0x2);
63 while (inb(K_STATUS
) & K_IBUF_FUL
);
65 while (inb(K_STATUS
) & K_OBUF_FUL
)
68 outb(K_CMD
, KC_CMD_WOUT
);
70 while (inb(K_STATUS
) & K_IBUF_FUL
);
74 while (inb(K_STATUS
) & K_IBUF_FUL
);
76 while (inb(K_STATUS
) & K_OBUF_FUL
)