1 /* $NetBSD: gatea20.c,v 1.2 1997/10/29 00:32:49 fvdl Exp $ */ 2 3 /* extracted from freebsd:sys/i386/boot/biosboot/io.c */ 4 5 #include <sys/types.h> 6 #include <machine/pio.h> 7 8 #include <lib/libsa/stand.h> 9 10 #include "libi386.h" 11 12 #define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ 13 #define K_STATUS 0x64 /* keyboard status */ 14 #define K_CMD 0x64 /* keybd ctlr command (write-only) */ 15 16 #define K_OBUF_FUL 0x01 /* output buffer full */ 17 #define K_IBUF_FUL 0x02 /* input buffer full */ 18 19 #define KC_CMD_WIN 0xd0 /* read output port */ 20 #define KC_CMD_WOUT 0xd1 /* write output port */ 21 #define KB_A20 0x9f /* enable A20, 22 reset (!), 23 enable output buffer full interrupt 24 enable data line 25 disable clock line */ 26 27 /* 28 * Gate A20 for high memory 29 */ 30 static unsigned char x_20 = KB_A20; 31 void gateA20() 32 { 33 __asm("pushfl ; cli"); 34 #ifdef IBM_L40 35 outb(0x92, 0x2); 36 #else IBM_L40 37 while (inb(K_STATUS) & K_IBUF_FUL); 38 while (inb(K_STATUS) & K_OBUF_FUL) 39 (void)inb(K_RDWR); 40 41 outb(K_CMD, KC_CMD_WOUT); 42 delay(100); 43 while (inb(K_STATUS) & K_IBUF_FUL); 44 outb(K_RDWR, x_20); 45 delay(100); 46 while (inb(K_STATUS) & K_IBUF_FUL); 47 #endif IBM_L40 48 __asm("popfl"); 49 } 50