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

1993/0915/pc/kbd.c (diff list | history)

1993/0226/sys/src/9/pc/kbd.c:25,301993/0915/sys/src/9/pc/kbd.c:25,41 (short | long | prev | next)
1991/0702    
 
1991/0730    
	Cmd=		0x64,	/* command port (write only) */ 
 
1993/0915    
	CTdata=		0x0,	/* chips & Technologies ps2 data port */ 
	CTstatus=	0x1,	/* chips & Technologies ps2 status port */ 
	 Enable=	1<<7, 
	 Clear=		1<<6, 
	 Error=		1<<5, 
	 Intenable=	1<<4, 
	 Reset=		1<<3, 
	 Tready=	1<<2, 
	 Rready=	1<<1, 
	 Idle=		1<<0, 
 
1991/0703    
	Spec=	0x80, 
 
	PF=	Spec|0x20,	/* num pad function key */ 
1993/0226/sys/src/9/pc/kbd.c:112,1171993/0915/sys/src/9/pc/kbd.c:123,129
1992/0811    
static int keybuttons; 
1992/1015    
static uchar ccc; 
1992/1017    
static int shift; 
1993/0915    
ulong ctport; 
1991/0911    
 
1992/0904    
enum 
{ 
1993/0226/sys/src/9/pc/kbd.c:125,1301993/0915/sys/src/9/pc/kbd.c:137,143
1992/0904    
}; 
1991/0703    
 
1992/1017    
static void	kbdintr(Ureg*); 
1993/0915    
static void	ctps2intr(Ureg*); 
1992/1017    
static int	ps2mouseputc(IOQ*, int); 
1992/1015    
 
1991/0803    
/* 
1993/0226/sys/src/9/pc/kbd.c:171,1771993/0915/sys/src/9/pc/kbd.c:184,190
1991/0904    
	c = 0; 
1992/1015    
	tries = 0; 
1991/0904    
	do{ 
1992/1015    
		if(tries++ > 5) 
1993/0915    
		if(tries++ > 2) 
1992/1015    
			break; 
		if(outready() < 0) 
1992/1016    
			break; 
1993/0226/sys/src/9/pc/kbd.c:227,2321993/0915/sys/src/9/pc/kbd.c:240,246
1992/0902    
	outready(); 
} 
 
1993/0915    
 
1992/0902    
void 
1991/0703    
kbdinit(void) 
{ 
1993/0226/sys/src/9/pc/kbd.c:279,2851993/0915/sys/src/9/pc/kbd.c:293,347
1992/0904    
	mousetype = Mouseserial; 
} 
1992/0408    
 
1993/0915    
static void nop(void){}; 
 
1992/0904    
/* 
1993/0915    
 *  look for a chips & technologies 82c710 ps2 mouse on a TI travelmate 
 */ 
static int 
ct82c710(void) 
{ 
	int c; 
 
	/* on non-C&T 2fa and 3fa are input only ports */ 
	/* get chips attention */ 
	outb(0x2fa, 0x55); nop(); nop(); 
	outb(0x3fa, ~0x55); nop(); nop(); 
	outb(0x3fa, 0x36); nop(); nop(); 
 
	/* tell it where its config register should be */ 
	outb(0x3fa, 0x390>>2); nop(); nop(); 
	outb(0x2fa, ~(0x390>>2)); nop(); nop(); 
 
	/* see if this is really a 710 */ 
	outb(0x390, 0xf); nop(); nop(); 
	if(inb(0x391) != (0x390>>2)) 
		return -1; 
 
	/* get data port address */ 
	outb(0x390, 0xd); nop(); nop(); 
	c = inb(0x391); 
	if(c == 0 || c == 0xff) 
		return -1; 
	ctport = c<<2; 
 
	/* turn off config mode */ 
	outb(0x390, 0xf); nop(); nop(); 
	outb(0x391, 0xf); 
 
	setvec(Mousevec, ctps2intr); 
 
	/* enable for interrupts */ 
	c = inb(ctport + CTstatus); 
	c &= ~(Clear|Reset); 
	c |= Enable|Intenable; 
	outb(ctport + CTstatus, c); 
 
	mousetype = MousePS2; 
	return 0; 
} 
 
/* 
1992/0904    
 *  set up a ps2 mouse 
 */ 
1992/1017    
static void 
1993/0226/sys/src/9/pc/kbd.c:290,2951993/0915/sys/src/9/pc/kbd.c:352,360
1992/1017    
	if(mousetype) 
		error(Emouseset); 
1992/0904    
 
1993/0915    
	if(ct82c710() == 0) 
		return; 
 
1992/0904    
	/* enable kbd/mouse xfers and interrupts */ 
1992/1017    
	setvec(Mousevec, kbdintr); 
1992/1015    
	x = splhi(); 
1993/0226/sys/src/9/pc/kbd.c:562,5651993/0915/sys/src/9/pc/kbd.c:627,645
1992/0222    
{ 
1992/0711    
	USED(ur); 
1992/0222    
	kbdintr0(); 
1993/0915    
} 
 
void 
ctps2intr(Ureg *ur) 
{ 
	uchar c; 
 
	USED(ur); 
	c = inb(ctport + CTstatus); 
	if(c & Error) 
		return; 
	if((c & Rready) == 0) 
		return; 
	c = inb(ctport + CTdata); 
	ps2mouseputc(&mouseq, c); 
1991/0703    
} 


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