xref: /netbsd-src/sys/arch/i386/stand/lib/gatea20.c (revision 481fca6e59249d8ffcf24fef7cfbe7b131bfb080)
1 /*	$NetBSD: gatea20.c,v 1.3 2000/05/11 16:11:54 jdolecek 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 #ifndef IBM_L40
31 static unsigned char	x_20 = KB_A20;
32 #endif
33 void gateA20()
34 {
35 	__asm("pushfl ; cli");
36 #ifdef	IBM_L40
37 	outb(0x92, 0x2);
38 #else	/* !IBM_L40 */
39 	while (inb(K_STATUS) & K_IBUF_FUL);
40 	while (inb(K_STATUS) & K_OBUF_FUL)
41 		(void)inb(K_RDWR);
42 
43 	outb(K_CMD, KC_CMD_WOUT);
44 	delay(100);
45 	while (inb(K_STATUS) & K_IBUF_FUL);
46 	outb(K_RDWR, x_20);
47 	delay(100);
48 	while (inb(K_STATUS) & K_IBUF_FUL);
49 #endif	/* IBM_L40 */
50 	__asm("popfl");
51 }
52