plan 9 kernel history: overview | file list | diff list

1991/0730/pc/kbd.c (diff list | history)

1991/0719/sys/src/9/pc/kbd.c:11,231991/0730/sys/src/9/pc/kbd.c:11,25 (short | long | prev | next)
1991/0702    
	Status=		0x64,	/* status port */ 
	 Inready=	0x01,	/*  input character ready */ 
	 Outbusy=	0x02,	/*  output busy */ 
	 Sysflag=	0x04,	/*  ??? */ 
1991/0730    
	 Sysflag=	0x04,	/*  system flag */ 
1991/0702    
	 Cmddata=	0x08,	/*  cmd==0, data==1 */ 
	 kbdinh=	0x10,	/*  keyboard inhibited */ 
	 Xtimeout=	0x20,	/*  transmit timeout */ 
	 Rtimeout=	0x40,	/*  receive timeout */ 
	 Parity=	0x80,	/*  0==odd, 1==even */ 
1991/0730    
	 Inhibit=	0x10,	/*  keyboard/mouse inhibited */ 
	 Minready=	0x20,	/*  mouse character ready */ 
	 Rtimeout=	0x40,	/*  general timeout */ 
	 Parity=	0x80,	/*  1 == error */ 
1991/0702    
 
1991/0730    
	Cmd=		0x64,	/* command port (write only) */ 
 
1991/0703    
	Spec=	0x80, 
 
	PF=	Spec|0x20,	/* num pad function key */ 
1991/0719/sys/src/9/pc/kbd.c:237,2441991/0730/sys/src/9/pc/kbd.c:239,273
1991/0703    
void 
kbdinit(void) 
{ 
1991/0730    
	uchar c; 
 
1991/0703    
	initq(&kbdq); 
1991/0716    
	setvec(Kbdvec, kbdintr); 
1991/0730    
 
	/* wait for a quiescent controller */ 
	while((c = inb(Status)) & (Outbusy | Inready)) 
		if(c & Inready) 
			inb(Data); 
 
	/* read controller command byte */ 
	outb(Cmd, 0x20); 
	while(!(inb(Status) & Inready)) 
		; 
	c = inb(Data); 
print("input completed\n"); 
delay(5000); 
 
	/* enable mouse and mouse interupts */ 
	c = (c&~0x20) | 0x02; 
	outb(Cmd, 0x60); 
	while(inb(Status) & Outbusy) 
		; 
	outb(Data, c); 
print("mouse enabled\n"); 
delay(5000); 
 
	initq(&mouseq); 
	setvec(Mousevec, kbdintr); 
1991/0703    
} 
 
/* 
1991/0719/sys/src/9/pc/kbd.c:247,2531991/0730/sys/src/9/pc/kbd.c:276,282
1991/0703    
void 
1991/0706    
kbdintr(Ureg *ur) 
1991/0703    
{ 
	int c, nc; 
1991/0730    
	int s, c, nc; 
1991/0703    
	static int esc1, esc2; 
	static int shift; 
	static int caps; 
1991/0719/sys/src/9/pc/kbd.c:257,2651991/0730/sys/src/9/pc/kbd.c:286,304
1991/0703    
	int keyup; 
1991/0702    
 
1991/0703    
	/* 
1991/0719    
	 *  get a character 
1991/0730    
	 *  get status and character 
1991/0703    
	 */ 
1991/0730    
	s = inb(Status); 
1991/0703    
	c = inb(Data); 
1991/0730    
 
	/* 
	 *  if it's the mouse... 
	 */ 
	if(s & Minready){ 
print("mousechar\n"); 
		mouseputc(&mouseq, c); 
		return; 
	} 
1991/0703    
 
	keyup = c&0x80; 
	c &= 0x7f; 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)