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