Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/pc/kbd.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname pc/kbd.c 1991/0702
## diff -e /dev/null /n/bootesdump/1991/0702/sys/src/9/safari/kbd.c
0a
#include	"u.h"
#include	"lib.h"
#include	"dat.h"
#include	"fns.h"

enum {
	Data=		0x60,	/* data port */

	Status=		0x64,	/* status port */
	 Inready=	0x01,	/*  input character ready */
	 Outbusy=	0x02,	/*  output busy */
	 Sysflag=	0x04,	/*  ??? */
	 Cmddata=	0x08,	/*  cmd==0, data==1 */
	 kbdinh=	0x10,	/*  keyboard inhibited */
	 Xtimeout=	0x20,	/*  transmit timeout */
	 Rtimeout=	0x40,	/*  receive timeout */
	 Parity=	0x80,	/*  0==odd, 1==even */

	
};

char noshift[256] = 
{
[0x00]	Nokey,	0x1b,	'1',	'2',	'3',	'4',	'5',	'6',
[0x08]	'7',	'8',	'9',	'0',	'-',	'=',	'\b',	'\t',
[0x10]
[0x28]
[0x30]
};

/*
 *  get a byte from the keyboard
 */
int
kbdc(void)
{
	while((inb(Status)&Inready)==0)
		;
	return inb(Data);
}

1	0x1b,
3b	F1,
3c	F2,
3d	F3,
3e	F4,
3f	F5,
40	f6,
41	F7,
42	F8,
43	F9,
44	F10,
57	F11,
58	F12,
e0 52	INS,
e0 53	DEL,
2	'1',
3	'2',
4	'3',
5	'4',
6	'5',
7	'6',
8	'7',
9	'8',
A	'9',
B	'0',
C	'-',
D	'=',
E	'\b',
E0 47	Home,
F	'\t',
10	'q',
11	'w',
12	'e',
13	'r',
14	't',
15	'y',
16	'u',
17	'i',
18	'o',
19	'p',
1a	'[',
1b	']',
2b	'\\',
e0 49	Pageup,
3a	Capslock,
1e	'a'
1f	's' 
20	'd'
21	'f'
22	'g'
23	'h'
24	'j'
25	'k'
26	'l'
27	';'
28	'\''
1c	'\r'
2a	Lshift,
2c	'z'
2d	'x'
2e	'c'
2f	'v'
30	'b'
31	'n'
32	'm'
33	','
34	'.'
35	'/'
36	Rshift,
e0 51	Pagedown,
e0 4f	End,
e0 48	Uparrow,
e0 50	Downarrow,
e0 4b	Leftarrow,
e0 4d   Rightarrow,
e0 1d	Rctl,
e0 38	Ralt,
39	Space,
38	Lalt,
1d	Lctl,
29	'`',
1d 38 1 81 b8 9d	F1
1d 38 21 a1 b8 9d	F2
	2e ae		F3
	19 99		F4
	26		F5
	2F		F6

e1 1d 45 e1 9d cf	F7
e0 46 e0 c6		f8
e0 2a e0 37 e0 b7 e0 aa	f9
54			f10
45			f11
46			f12
.
## diffname pc/kbd.c 1991/0703
## diff -e /n/bootesdump/1991/0702/sys/src/9/safari/kbd.c /n/bootesdump/1991/0703/sys/src/9/safari/kbd.c
130,135c
	/*
	 *  get a character to be there
	 */
	c = inb(Data);

	keyup = c&0x80;
	c &= 0x7f;
	if(c > sizeof kbtab){
		print("unknown key %ux\n", c|keyup);
		kbdputc(&kbdq, k1);
		goto out;
	}

	/*
	 *  e0's is the first of a 2 character sequence
	 */
	if(c == 0xe0){
		esc1 = 1;
		goto out;
	} else if(c == 0xe1){
		esc2 = 2;
		goto out;
	}

	if(esc1){
		c = kbtabesc1[c];
		esc1 = 0;
	} else if(esc2){
		esc2--;
		goto out;
	} else if(shift)
		c = kbtabshift[c];
	else
		c = kbtab[c];

	if(caps && c<='z' && c>='a')
		c += 'A' - 'a';

	/*
	 *  keyup only important for shifts
	 */
	if(keyup){
		switch(c){
		case Shift:
			shift = 0;
			break;
		case Ctrl:
			ctl = 0;
			break;
		}
		goto out;
	}

	/*
 	 *  normal character
	 */
	if(!(c & Spec)){
		if(ctl)
			c &= 0x1f;
		switch(lstate){
		case 1:
			k1 = c;
			lstate = 2;
			return;
		case 2:
			k2 = c;
			lstate = 0;
			c = latin1(k1, k2);
			if(c == 0){
				kbdputc(&kbdq, k1);
				c = k2;
			}
			/* fall through */
		default:
			break;
		}
	} else {
		switch(c){
		case Caps:
			caps ^= 1;
			goto out;
		case Num:
			num ^= 1;
			goto out;
		case Shift:
			shift = 1;
			goto out;
		case Latin:
			lstate = 1;
			goto out;
		case Ctrl:
			ctl = 1;
			goto out;
		}
	}
	kbdputc(&kbdq, c);
out:
	INTENABLE;			/* reenable interrupt */
	return;
}
.
42,128c
int
kbdputc(IOQ* q, int c)
{
	screenputc(c);
	putc(q, c);
}

/*
 *  keyboard interrupt
 */
void
kbdintr(void *a)
{
	int c, nc;
	static int esc1, esc2;
	static int shift;
	static int caps;
	static int ctl;
	static int num;
	static int lstate, k1, k2;
	int keyup;
.
37,39c
	int c;

	for(;;){
		while((inb(Status)&Inready)==0)
			;
		kbdintr(&c);
		c = getc(&kbdq);
		if(c != -1)
			return c;
	}
.
30a
uchar kbtabshift[] =
{
[0x00]	No,	0x1b,	'!',	'@',	'#',	'$',	'%',	'^',
[0x08]	'&',	'*',	'(',	')',	'_',	'+',	'\b',	'\t',
[0x10]	'Q',	'W',	'E',	'R',	'T',	'Y',	'U',	'I',
[0x18]	'O',	'P',	'{',	'}',	'\n',	Ctrl,	'A',	'S',
[0x20]	'D',	'F',	'G',	'H',	'J',	'K',	'L',	':',
[0x28]	'"',	'~',	Shift,	'|',	'Z',	'X',	'C',	'V',
[0x30]	'B',	'N',	'M',	'<',	'>',	'?',	Shift,	No,
[0x38]	Latin,	' ',	Caps,	F|1,	F|2,	F|3,	F|4,	F|5,
[0x40]	F|6,	F|7,	F|8,	F|9,	F|10,	Num,	F|12,	Home,
[0x48]	No,	No,	No,	No,	No,	No,	No,	No,
[0x50]	No,	No,	No,	No,	No,	No,	No,	F|11,
[0x58]	F|12,	No,	No,	No,	No,	No,	No,	No,
};

uchar kbtabesc1[] =
{
[0x00]	No,	No,	No,	No,	No,	No,	No,	No,
[0x08]	No,	No,	No,	No,	No,	No,	No,	No,
[0x10]	No,	No,	No,	No,	No,	No,	No,	No,
[0x18]	No,	No,	No,	No,	No,	Ctrl,	No,	No,
[0x20]	No,	No,	No,	No,	No,	No,	No,	No,
[0x28]	No,	No,	No,	No,	No,	No,	No,	No,
[0x30]	No,	No,	No,	No,	No,	No,	No,	Print,
[0x38]	Latin,	No,	No,	No,	No,	No,	No,	No,
[0x40]	No,	No,	No,	No,	No,	No,	Break,	Home,
[0x48]	Up,	Pgup,	No,	Down,	No,	Right,	No,	End,
[0x50]	Left,	Pgdown,	Ins,	Del,	No,	No,	No,	No,
[0x58]	No,	No,	No,	No,	No,	No,	No,	No,
};

struct latin
{
	uchar	l;
	char	c[2];
}latintab[] = {
	'€',	"!!",	/* spanish initial ! */
	'€',	"c|",	/* cent */
	'€',	"c$",	/* cent */
	'€',	"l$",	/* pound sterling */
	'€',	"g$",	/* general currency */
	'€',	"y$",	/* yen */
	'€',	"j$",	/* yen */
	'€',	"||",	/* broken vertical bar */
	'€',	"SS",	/* section symbol */
	'€',	"\"\"",	/* dieresis */
	'€',	"cr",	/* copyright */
	'€',	"cO",	/* copyright */
	'€',	"sa",	/* super a, feminine ordinal */
	'€',	"<<",	/* left angle quotation */
	'€',	"no",	/* not sign, hooked overbar */
	'€',	"--",	/* soft hyphen */
	'€',	"rg",	/* registered trademark */
	'€',	"__",	/* macron */
	'€',	"s0",	/* degree (sup o) */
	'€',	"+-",	/* plus-minus */
	'€',	"s2",	/* sup 2 */
	'€',	"s3",	/* sup 3 */
	'€',	"''",	/* grave accent */
	'€',	"mu",	/* mu */
	'€',	"pg",	/* paragraph (pilcrow) */
	'€',	"..",	/* centered . */
	'€',	",,",	/* cedilla */
	'€',	"s1",	/* sup 1 */
	'€',	"so",	/* sup o */
	'€',	">>",	/* right angle quotation */
	'€',	"14",	/* 1/4 */
	'€',	"12",	/* 1/2 */
	'€',	"34",	/* 3/4 */
	'€',	"??",	/* spanish initial ? */
	'€',	"A`",	/* A grave */
	'€',	"A'",	/* A acute */
	'€',	"A^",	/* A circumflex */
	'€',	"A~",	/* A tilde */
	'€',	"A\"",	/* A dieresis */
	'€',	"A:",	/* A dieresis */
	'€',	"Ao",	/* A circle */
	'€',	"AO",	/* A circle */
	'€',	"Ae",	/* AE ligature */
	'€',	"AE",	/* AE ligature */
	'€',	"C,",	/* C cedilla */
	'€',	"E`",	/* E grave */
	'€',	"E'",	/* E acute */
	'€',	"E^",	/* E circumflex */
	'€',	"E\"",	/* E dieresis */
	'€',	"E:",	/* E dieresis */
	'€',	"I`",	/* I grave */
	'€',	"I'",	/* I acute */
	'€',	"I^",	/* I circumflex */
	'€',	"I\"",	/* I dieresis */
	'€',	"I:",	/* I dieresis */
	'€',	"D-",	/* Eth */
	'€',	"N~",	/* N tilde */
	'€',	"O`",	/* O grave */
	'€',	"O'",	/* O acute */
	'€',	"O^",	/* O circumflex */
	'€',	"O~",	/* O tilde */
	'€',	"O\"",	/* O dieresis */
	'€',	"O:",	/* O dieresis */
	'€',	"OE",	/* O dieresis */
	'€',	"Oe",	/* O dieresis */
	'€',	"xx",	/* times sign */
	'€',	"O/",	/* O slash */
	'€',	"U`",	/* U grave */
	'€',	"U'",	/* U acute */
	'€',	"U^",	/* U circumflex */
	'€',	"U\"",	/* U dieresis */
	'€',	"U:",	/* U dieresis */
	'€',	"UE",	/* U dieresis */
	'€',	"Ue",	/* U dieresis */
	'€',	"Y'",	/* Y acute */
	'€',	"P|",	/* Thorn */
	'€',	"Th",	/* Thorn */
	'€',	"TH",	/* Thorn */
	'€',	"ss",	/* sharp s */
	'€',	"a`",	/* a grave */
	'€',	"a'",	/* a acute */
	'€',	"a^",	/* a circumflex */
	'€',	"a~",	/* a tilde */
	'€',	"a\"",	/* a dieresis */
	'€',	"a:",	/* a dieresis */
	'€',	"ao",	/* a circle */
	'€',	"ae",	/* ae ligature */
	'€',	"c,",	/* c cedilla */
	'€',	"e`",	/* e grave */
	'€',	"e'",	/* e acute */
	'€',	"e^",	/* e circumflex */
	'€',	"e\"",	/* e dieresis */
	'€',	"e:",	/* e dieresis */
	'€',	"i`",	/* i grave */
	'€',	"i'",	/* i acute */
	'€',	"i^",	/* i circumflex */
	'€',	"i\"",	/* i dieresis */
	'€',	"i:",	/* i dieresis */
	'€',	"d-",	/* eth */
	'€',	"n~",	/* n tilde */
	'€',	"o`",	/* o grave */
	'€',	"o'",	/* o acute */
	'€',	"o^",	/* o circumflex */
	'€',	"o~",	/* o tilde */
	'€',	"o\"",	/* o dieresis */
	'€',	"o:",	/* o dieresis */
	'€',	"oe",	/* o dieresis */
	'€',	"-:",	/* divide sign */
	'€',	"o/",	/* o slash */
	'€',	"u`",	/* u grave */
	'€',	"u'",	/* u acute */
	'€',	"u^",	/* u circumflex */
	'€',	"u\"",	/* u dieresis */
	'€',	"u:",	/* u dieresis */
	'€',	"ue",	/* u dieresis */
	'€',	"y'",	/* y acute */
	'€',	"th",	/* thorn */
	'€',	"p|",	/* thorn */
	'€',	"y\"",	/* y dieresis */
	'€',	"y:",	/* y dieresis */
	0,	0,
};

KIOQ	kbdq;

int
latin1(int k1, int k2)
{
	int i;
	struct latin *l;

	for(l=latintab; l->l; l++)
		if(k1==l->c[0] && k2==l->c[1])
			return l->l;
	return 0;
}

void
kbdinit(void)
{
	initq(&kbdq);
	setvec(Kbdvec, kbdintr, SEGIG);
}

.
26,28c
[0x10]	'q',	'w',	'e',	'r',	't',	'y',	'u',	'i',
[0x18]	'o',	'p',	'[',	']',	'\n',	Ctrl,	'a',	's',
[0x20]	'd',	'f',	'g',	'h',	'j',	'k',	'l',	';',
[0x28]	'\'',	'`',	Shift,	'\\',	'z',	'x',	'c',	'v',
[0x30]	'b',	'n',	'm',	',',	'.',	'/',	Shift,	No,
[0x38]	Latin,	' ',	Caps,	F|1,	F|2,	F|3,	F|4,	F|5,
[0x40]	F|6,	F|7,	F|8,	F|9,	F|10,	Num,	F|12,	Home,
[0x48]	No,	No,	No,	No,	No,	No,	No,	No,
[0x50]	No,	No,	No,	No,	No,	No,	No,	F|11,
[0x58]	F|12,	No,	No,	No,	No,	No,	No,	No,
.
24c
[0x00]	No,	0x1b,	'1',	'2',	'3',	'4',	'5',	'6',
.
22c
uchar kbtab[] = 
.
19c
	Spec=	0x80,

	PF=	Spec|0x20,	/* num pad function key */
	View=	Spec|0x00,	/* view (shift window up) */
	F=	Spec|0x40,	/* function key */
	Shift=	Spec|0x60,
	Break=	Spec|0x61,
	Ctrl=	Spec|0x62,
	Latin=	Spec|0x63,
	Caps=	Spec|0x64,
	Num=	Spec|0x65,
	No=	Spec|0x7F,	/* no mapping */

	Home=	F|13,
	Up=	F|14,
	Pgup=	F|15,
	Print=	F|16,
	Left=	View,
	Right=	View,
	End=	'\r',
	Down=	View,
	Pgdown=	View,
	Ins=	F|20,
	Del=	0x7F,
.
4a
#include	"io.h"
#include	"mem.h"
.
## diffname pc/kbd.c 1991/0705
## diff -e /n/bootesdump/1991/0703/sys/src/9/safari/kbd.c /n/bootesdump/1991/0705/sys/src/9/safari/kbd.c
381c
	INT0ENABLE;			/* reenable interrupt */
.
## diffname pc/kbd.c 1991/0706
## diff -e /n/bootesdump/1991/0705/sys/src/9/safari/kbd.c /n/bootesdump/1991/0706/sys/src/9/safari/kbd.c
380,381d
376c
			return;
.
373c
			return;
.
370c
			return;
.
367c
			return;
.
364c
			return;
.
334c
		return;
.
313c
		return;
.
305c
		return;
.
302c
		return;
.
294c
		return;
.
273c
kbdintr(Ureg *ur)
.
265c
	if(c==0x10)
		panic("^p");
.
248,262d
244,246d
6d
2a
#include	"mem.h"
.
## diffname pc/kbd.c 1991/0711
## diff -e /n/bootesdump/1991/0706/sys/src/9/safari/kbd.c /n/bootesdump/1991/0711/sys/src/9/safari/kbd.c
244,251d
## diffname pc/kbd.c 1991/0716
## diff -e /n/bootesdump/1991/0711/sys/src/9/safari/kbd.c /n/bootesdump/1991/0716/sys/src/9/safari/kbd.c
241c
	setvec(Kbdvec, kbdintr);
.
## diffname pc/kbd.c 1991/0719
## diff -e /n/bootesdump/1991/0716/sys/src/9/safari/kbd.c /n/bootesdump/1991/0719/sys/src/9/safari/kbd.c
260c
	 *  get a character
.
## diffname pc/kbd.c 1991/0730
## diff -e /n/bootesdump/1991/0719/sys/src/9/safari/kbd.c /n/bootesdump/1991/0730/sys/src/9/safari/kbd.c
262a

	/*
	 *  if it's the mouse...
	 */
	if(s & Minready){
print("mousechar\n");
		mouseputc(&mouseq, c);
		return;
	}
.
261a
	s = inb(Status);
.
260c
	 *  get status and character
.
250c
	int s, c, nc;
.
241a

	/* 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);
.
239a
	uchar c;

.
20a
	Cmd=		0x64,	/* command port (write only) */

.
16,19c
	 Inhibit=	0x10,	/*  keyboard/mouse inhibited */
	 Minready=	0x20,	/*  mouse character ready */
	 Rtimeout=	0x40,	/*  general timeout */
	 Parity=	0x80,	/*  1 == error */
.
14c
	 Sysflag=	0x04,	/*  system flag */
.
## diffname pc/kbd.c 1991/0731
## diff -e /n/bootesdump/1991/0730/sys/src/9/safari/kbd.c /n/bootesdump/1991/0731/sys/src/9/safari/kbd.c
394c
	return 0;
}

void
kbdintr(Ureg *ur)
{
	while(kbdintr0() == 0)
		;
.
390c
			return 0;
.
387c
			return 0;
.
384c
			return 0;
.
381c
			return 0;
.
378c
			return 0;
.
361c
			return 0;
.
348c
		return 0;
.
327c
		return 0;
.
319c
		return 0;
.
316c
		return 0;
.
308c
		return 0;
.
298,300c
		mymouseputc(c);
		return 0;
.
291a
	if(!(s&Inready))
		return -1;

	/*
	 *  get the character
	 */
.
289c
	 *  get status
.
276,277c
int
kbdintr0(void)
.
269,270c
/*
 *  mouse message is three bytes
 *
 *	byte 0 -	0 0 SDY SDX 1 M R L
 *	byte 1 -	DX
 *	byte 2 -	DY
 */
static void
mymouseputc(int c)
{
	static short msg[3];
	static int nb;
	static uchar b[] = {0, 4, 1, 5, 2, 6, 3, 7};
	static lastdx, lastdy;
	int diff;
	extern Mouseinfo mouse;

	/* 
	 *  check byte 0 for consistency
	 */
	if(nb==0 && (c&0xc8)!=0x08)
		return;

	msg[nb] = c;
	if(++nb == 3){
		nb = 0;
		if(msg[0] & 0x10)
			msg[1] |= 0xFF00;
		if(msg[0] & 0x20)
			msg[2] |= 0xFF00;

		mouse.newbuttons = b[msg[0]&7];
		mouse.dx = msg[1];
		mouse.dy = -msg[2];
print("%d %d\n", mouse.dx, mouse.dy);
		mouse.track = 1;
		mouseclock();
	}
.
267a
}
.
265,266c
	outb(Data, 0x47);
	while(inb(Status) & Outbusy)
		;
	outb(Cmd, 0xA8);

	/* make mouse streaming (and enabled) */
	mousecmd(0xEA, -1);
	mousecmd(0xF4, -1);

	/* resolution */
	mousecmd(0xE8, 0x03);
print("res set\n");
.
252,261c
	/* enable kbd/mouse xfers and interrupts */
.
245a
	initq(&mouseq);
	setvec(Mousevec, kbdintr);
.
242c
	int c, s;
.
238a
static void
mousecmd(int cmd, int arg)
{
	unsigned int c;

	do {
		while(inb(Status) & Outbusy)
			;
		outb(Cmd, 0xD4);
		while(inb(Status) & Outbusy)
			;
		outb(Data, cmd);
		if(arg >= 0){
			while(inb(Status) & Outbusy)
				;
			outb(Data, arg);
		}
		while(!(inb(Status) & Inready))
			;
		c = inb(Data);
	} while(c == 0xFE);
	if(c != 0xFA)
		print("mouse command returns bad status %lux", c);
}

.
77,78c
[0x50]	No,	No,	No,	No,	No,	No,	No,	KF|11,
[0x58]	KF|12,	No,	No,	No,	No,	No,	No,	No,
.
74,75c
[0x38]	Latin,	' ',	Caps,	KF|1,	KF|2,	KF|3,	KF|4,	KF|5,
[0x40]	KF|6,	KF|7,	KF|8,	KF|9,	KF|10,	Num,	KF|12,	Home,
.
61,62c
[0x50]	No,	No,	No,	No,	No,	No,	No,	KF|11,
[0x58]	KF|12,	No,	No,	No,	No,	No,	No,	No,
.
58,59c
[0x38]	Latin,	' ',	Caps,	KF|1,	KF|2,	KF|3,	KF|4,	KF|5,
[0x40]	KF|6,	KF|7,	KF|8,	KF|9,	KF|10,	Num,	KF|12,	Home,
.
45c
	Ins=	KF|20,
.
36,39c
	Home=	KF|13,
	Up=	KF|14,
	Pgup=	KF|15,
	Print=	KF|16,
.
27c
	KF=	Spec|0x40,	/* function key */
.
19c
	 Parity=	0x80,
.
7a
#include	<libg.h>
#include	<gnot.h>
#include	"screen.h"

.
## diffname pc/kbd.c 1991/0801
## diff -e /n/bootesdump/1991/0731/sys/src/9/safari/kbd.c /n/bootesdump/1991/0801/sys/src/9/safari/kbd.c
336d
297,299c
/*	mousecmd(0xE8, 0x03); /**/
.
## diffname pc/kbd.c 1991/0803
## diff -e /n/bootesdump/1991/0801/sys/src/9/safari/kbd.c /n/bootesdump/1991/0803/sys/src/9/safari/kbd.c
292,297c
	/* make mouse streaming, enabled */
	if(mousecmd(0xEA) < 0
	|| mousecmd(0xF4) < 0)
		print("can't initialize mouse\n");
.
288,289c
	if(outready() < 0)
		print("kbd init failed\n");
.
285,286c
	if(outready() < 0)
		print("kbd init failed\n");
.
271a
	int tries;
.
265c
		return -1;
	return 0;
.
255,261c
		if(inready() < 0)
			return -1;
.
252,253c
		if(outready() < 0)
			return -1;
.
248,250c
	for(tries=0; tries < 10; tries++){
		if(outready() < 0)
			return -1;
.
246a
	int tries;
.
245a
	int tries;

	for(tries = 0; (inb(Status) & Outbusy); tries++)
		if(tries > 1000)
			return -1;
	return 0;
}

/*
 *  wait for input
 */
static int
inready(void)
{
	int tries;

	for(tries = 0; !(inb(Status) & Inready); tries++)
		if(tries > 1000)
			return -1;
	return 0;
}

/*
 *  send a command to the mouse
 */
static int
mousecmd(int cmd)
{
.
243,244c
/*
 *  wait for output no longer busy
 */
static int
outready(void)
.
## diffname pc/kbd.c 1991/0809
## diff -e /n/bootesdump/1991/0803/sys/src/9/safari/kbd.c /n/bootesdump/1991/0809/sys/src/9/safari/kbd.c
339c
	static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7};
.
## diffname pc/kbd.c 1991/0821
## diff -e /n/bootesdump/1991/0809/sys/src/9/safari/kbd.c /n/bootesdump/1991/0821/sys/src/9/safari/kbd.c
420a
print("\nescape1 %lux\n", c);
.
## diffname pc/kbd.c 1991/0822
## diff -e /n/bootesdump/1991/0821/sys/src/9/safari/kbd.c /n/bootesdump/1991/0822/sys/src/9/safari/kbd.c
423a
		kbdputc(&kbdq, c);
		return 0;
.
421d
419a
	keyup = c&0x80;
	c &= 0x7f;
	if(c > sizeof kbtab){
		print("unknown key %ux\n", c|keyup);
		kbdputc(&kbdq, k1);
		return 0;
	}

.
401,408d
## diffname pc/kbd.c 1991/0823
## diff -e /n/bootesdump/1991/0822/sys/src/9/safari/kbd.c /n/bootesdump/1991/0823/sys/src/9/safari/kbd.c
361a
		spllo();		/* mouse tracking kills uart0 */
.
## diffname pc/kbd.c 1991/0904
## diff -e /n/bootesdump/1991/0823/sys/src/9/safari/kbd.c /n/bootesdump/1991/0904/sys/src/9/safari/kbd.c
280,289c
	c = 0;
	do{
		for(tries=0; tries < 10; tries++){
			if(outready() < 0)
				return -1;
			outb(Cmd, 0xD4);
			if(outready() < 0)
				return -1;
			outb(Data, cmd);
			if(inready() < 0)
				return -1;
			c = inb(Data);
		}
.
## diffname pc/kbd.c 1991/0905
## diff -e /n/bootesdump/1991/0904/sys/src/9/safari/kbd.c /n/bootesdump/1991/0905/sys/src/9/safari/kbd.c
229a

/*
 *  predeclared
 */
static void	kbdintr(Ureg*);

.
228a
/*
 *  keyboard input q
 */
.
## diffname pc/kbd.c 1991/0906
## diff -e /n/bootesdump/1991/0905/sys/src/9/safari/kbd.c /n/bootesdump/1991/0906/sys/src/9/safari/kbd.c
436c
		if(!keyup)
			kbdputc(&kbdq, c);
.
## diffname pc/kbd.c 1991/0911
## diff -e /n/bootesdump/1991/0906/sys/src/9/safari/kbd.c /n/bootesdump/1991/0911/sys/src/9/safari/kbd.c
503a
			return 0;
		case Middle:
			middle(2);
.
460a
		case Middle:
			middle(0);
			break;
.
379a
 *  Ctrl key used as middle button pressed
 */
static void
middle(int newval)
{
	middlebutton = newval;
	mouse.newbuttons = mousebuttons | middlebutton;
	mouse.dx = 0;
	mouse.dy = 0;
	mouse.track = 1;
	spllo();		/* mouse tracking kills uart0 */
	mouseclock();
}

/*
.
370c
		mousebuttons = b[msg[0]&7];
		mouse.newbuttons = mousebuttons | middlebutton;
.
233a
static int mousebuttons;
static int middlebutton;

.
78c
[0x38]	Latin,	' ',	Ctrl,	KF|1,	KF|2,	KF|3,	KF|4,	KF|5,
.
62c
[0x38]	Latin,	' ',	Ctrl,	KF|1,	KF|2,	KF|3,	KF|4,	KF|5,
.
37a
	Middle=	Spec|0x66,
.
## diffname pc/kbd.c 1991/1108
## diff -e /n/bootesdump/1991/0911/sys/src/9/safari/kbd.c /n/bootesdump/1991/1108/sys/src/9/safari/kbd.c
243,254d
102,229d
## diffname pc/kbd.c 1991/1207
## diff -e /n/bootesdump/1991/1108/sys/src/9/safari/kbd.c /n/bootesdump/1991/1207/sys/src/9/safari/kbd.c
195c
	outb(Cmd, 0xA8);	/* BUG -- should this be AE? */
.
192c
	outb(Data, 0x47);	/* BUG -- on 6300 0x65 */
.
## diffname pc/kbd.c 1991/1210
## diff -e /n/bootesdump/1991/1207/sys/src/9/safari/kbd.c /n/bootesdump/1991/1210/sys/src/9/safari/kbd.c
188,200c
	switch(machtype){
	case Attnsx:
		/* enable kbd/mouse xfers and interrupts */
		outb(Cmd, 0x60);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Data, 0x47);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Cmd, 0xA8);
	
		/* make mouse streaming, enabled */
		if(mousecmd(0xEA) < 0
		|| mousecmd(0xF4) < 0)
			print("can't initialize mouse\n");
		break;
	case At:
		/* enable kbd xfers and interrupts */
		outb(Cmd, 0x60);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Data, 0x65);
		break;
	}
.
172a
i8042a20(void)
{
	outready();
	outb(Cmd, 0xD1);
	outready();
	outb(Data, 0xDF);
	outready();
}

/*
 *  ask 8042 to reset the 386
 */
void
i8042reset(void)
{
	outready();
	outb(Cmd, 0xD1);
	outready();
	outb(Data, 0xDE);
	outready();
}

void
.
171a
/*
 *  ask 8042 to enable the use of address bit 20
 */
.
## diffname pc/kbd.c 1991/1211
## diff -e /n/bootesdump/1991/1210/sys/src/9/safari/kbd.c /n/bootesdump/1991/1211/sys/src/9/safari/kbd.c
407a
		return 0;
.
405a
			kbdputc(&kbdq, c);
.
399,404c
			if(c != -1)
				kbdputc(&kbdq, c);
			else for(i=0; i<nk; i++)
				kbdputc(&kbdq, kc[i]);
			break;
		case 3:
		case 4:
		case 5:
			kc[lstate-2] = c;
			lstate++;
			break;
		case 6:
			kc[4] = c;
			c = unicode(kc);
			nk = 5;
			goto putit;
.
397c
			kc[1] = c;
			c = latin1(kc);
			nk = 2;
		putit:
.
395c
			if(c == 'X')
				lstate = 3;
			break;
.
393c
			kc[0] = c;
.
346d
308c
	static int lstate;
	static uchar kc[5];
.
302c
	int s, c, i, nk, nc;
.
194c
	outb(Data, 0x0);
.
## diffname pc/kbd.c 1992/0211
## diff -e /n/bootesdump/1991/1211/sys/src/9/safari/kbd.c /n/bootesdump/1992/0211/sys/src/9/safari/kbd.c
387a
dochar:
.
354c
			goto dochar;
.
## diffname pc/kbd.c 1992/0221
## diff -e /n/bootesdump/1992/0211/sys/src/9/safari/kbd.c /n/bootesdump/1992/0221/sys/src/9/safari/kbd.c
450,456d
311a
	USED(ur);

.
299,300c
void
kbdintr(Ureg *ur)
.
## diffname pc/kbd.c 1992/0222
## diff -e /n/bootesdump/1992/0221/sys/src/9/safari/kbd.c /n/bootesdump/1992/0222/sys/src/9/safari/kbd.c
451a
}

void
kbdintr(Ureg *ur)
{
	kbdintr0();
.
312,313d
299,300c
int
kbdintr0(void)
.
## diffname pc/kbd.c 1992/0321
## diff -e /n/bootesdump/1992/0222/sys/src/9/safari/kbd.c /n/bootesdump/1992/0321/sys/src/9/safari/kbd.c
2c
#include	"../port/lib.h"
.
## diffname pc/kbd.c 1992/0404
## diff -e /n/bootesdump/1992/0321/sys/src/9/safari/kbd.c /n/bootesdump/1992/0404/sys/src/9/safari/kbd.c
185,197d
## diffname pc/kbd.c 1992/0408
## diff -e /n/bootesdump/1992/0404/sys/src/9/safari/kbd.c /n/bootesdump/1992/0408/sys/src/9/safari/kbd.c
222a

		/* set up /dev/eia0 as the mouse */
		uartspecial(0, 0, &mouseq, 1200);
print("uartspecial done\n");
delay(1000);
.
202a
		bigcursor();
		setvec(Mousevec, kbdintr);

.
193,194d
191d
## diffname pc/kbd.c 1992/0409
## diff -e /n/bootesdump/1992/0408/sys/src/9/safari/kbd.c /n/bootesdump/1992/0409/sys/src/9/safari/kbd.c
226,227d
## diffname pc/kbd.c 1992/0711
## diff -e /n/bootesdump/1992/0409/sys/src/9/safari/kbd.c /n/bootesdump/1992/0711/sys/src/9/safari/kbd.c
444a
	USED(ur);
.
292c
	int s, c, i, nk;
.
244d
188,189c
	int c;
.
## diffname pc/kbd.c 1992/0806
## diff -e /n/bootesdump/1992/0711/sys/src/9/safari/kbd.c /n/bootesdump/1992/0806/sys/src/9/safari/kbd.c
376d
341,343d
97,98c
[0x48]	Up,	Pgup,	No,	Left,	No,	Right,	No,	End,
[0x50]	Down,	Pgdown,	Ins,	Del,	No,	No,	No,	No,
.
93,94c
[0x28]	No,	No,	Shift,	No,	No,	No,	No,	No,
[0x30]	No,	No,	No,	No,	No,	'/',	No,	Print,
.
91c
[0x18]	No,	No,	No,	No,	'\n',	Ctrl,	No,	No,
.
80,82c
[0x40]	KF|6,	KF|7,	KF|8,	KF|9,	KF|10,	Num,	KF|12,	'7',
[0x48]	'8',	'9',	'-',	'4',	'5',	'6',	'+',	'1',
[0x50]	'2',	'3',	'0',	'.',	No,	No,	No,	KF|11,
.
78c
[0x30]	'B',	'N',	'M',	'<',	'>',	'?',	Shift,	'*',
.
64,66c
[0x40]	KF|6,	KF|7,	KF|8,	KF|9,	KF|10,	Num,	KF|12,	'7',
[0x48]	'8',	'9',	'-',	'4',	'5',	'6',	'+',	'1',
[0x50]	'2',	'3',	'0',	'.',	No,	No,	No,	KF|11,
.
62c
[0x30]	'b',	'n',	'm',	',',	'.',	'/',	Shift,	'*',
.
39c
	No=	0x00,		/* peter */
.
## diffname pc/kbd.c 1992/0811
## diff -e /n/bootesdump/1992/0808/sys/src/9/safari/kbd.c /n/bootesdump/1992/0811/sys/src/9/pc/kbd.c
427,428c
		case KF|1:
			mbon(4);
			return 0;
		case KF|2:
			mbon(2);
			return 0;
		case KF|3:
			mbon(1);
.
365a
		case KF|2:
			mboff(2);
			break;
		case KF|3:
			mboff(1);
			break;
.
363,364c
		case KF|1:
			mboff(4);
.
282a
static void
mboff(int val)
{
	keybuttons &= ~val;
	mouse.newbuttons = mousebuttons | keybuttons;
	mouse.dx = 0;
	mouse.dy = 0;
	mouse.track = 1;
	spllo();		/* mouse tracking kills uart0 */
	mouseclock();
}
.
275,276c
	keybuttons |= val;
	mouse.newbuttons = mousebuttons | keybuttons;
.
273c
mbon(int val)
.
260c
		mouse.newbuttons = mousebuttons | keybuttons;
.
214a

		/* turn on mouse acceleration */
		mousecmd(0xE7);
.
108c
static int keybuttons;
.
## diffname pc/kbd.c 1992/0825
## diff -e /n/bootesdump/1992/0811/sys/src/9/pc/kbd.c /n/bootesdump/1992/0825/sys/src/9/pc/kbd.c
227a
		break;
	}
}

/*
 *  turn mouse acceleration on/off
 */
void
mouseaccelerate(int on)
{

	switch(machtype){
	case Attnsx:
		if(on)
			mousecmd(0xE7);
		else
			mousecmd(0xE6);
.
217c
		mouseaccelerate(0);
.
## diffname pc/kbd.c 1992/0902
## diff -e /n/bootesdump/1992/0825/sys/src/9/pc/kbd.c /n/bootesdump/1992/0902/sys/src/9/pc/kbd.c
239,240c
	switch(mousetype){
	case MousePS2:
.
228a
	case Mouseother:
		/* enable kbd xfers and interrupts */
		outb(Cmd, 0x60);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Data, 0x65);
		break;
.
219c
	case Mouseserial:
.
197,198c
	switch(mousetype){
	case MousePS2:
.
185a
i8042reset(void)
{
	outready();
	outb(Cmd, 0xD1);
	outready();
	outb(Data, 0xDE);
	outready();
}

void
.
184a
/*
 *  ask 8042 to reset the machine
 */
.
## diffname pc/kbd.c 1992/0904
## diff -e /n/bootesdump/1992/0902/sys/src/9/pc/kbd.c /n/bootesdump/1992/0904/sys/src/9/pc/kbd.c
264a
		break;
	}
}

/*
 *  set mouse resolution
 */
void
mouseres(int res)
{

	switch(mousetype){
	case MousePS2:
		mousecmd(0xE8);
		mousecmd(res);
.
239,249c
/*
 *  set up a ps2 mouse
 */
void
mouseps2(void)
{
	if(mousetype)
		return;

	bigcursor();
	setvec(Mousevec, kbdintr);

	/* enable kbd/mouse xfers and interrupts */
	outb(Cmd, 0x60);
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Data, 0x47);
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Cmd, 0xA8);

	/* make mouse streaming, enabled */
	mousecmd(0xEA);
	mousecmd(0xF4);
	mousetype = MousePS2;
.
229,237c
	/* set up /dev/eia0 as the mouse */
	uartspecial(port, 0, &mouseq, 1200);
	mousetype = Mouseserial;
}
.
215,227c
/*
 *  setup a serial mouse
 */
void
mouseserial(int port)
{
	if(mousetype)
		return;
.
210,213c
	/* enable kbd xfers and interrupts */
	outb(Cmd, 0x60);
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Data, 0x65);
}
.
114a
enum
{
	/* what kind of mouse */
	Mouseother=	0,
	Mouseserial=	1,
	MousePS2=	2,
};
static int mousetype;
.
## diffname pc/kbd.c 1992/0918
## diff -e /n/bootesdump/1992/0904/sys/src/9/pc/kbd.c /n/bootesdump/1992/0918/sys/src/9/pc/kbd.c
372d
328c
		mousebuttons = b[(msg[0]&7) | (shift ? 8 : 0)];
.
310c
	static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 5, 2, 3, 6, 7 };
.
303a
 *
 *  shift & left button is the same as middle button
.
297a
static int shift;

.
## diffname pc/kbd.c 1992/1013
## diff -e /n/bootesdump/1992/0918/sys/src/9/pc/kbd.c /n/bootesdump/1992/1013/sys/src/9/pc/kbd.c
202c
	outb(Data, 0xDE);	/* set reset line high */
.
199a
	outb(Cmd, 0xFE);	/* pulse reset line */
	outready();
	/*
	 *  this is the old IBM way
	 */
	outready();
.
198a
	/*
	 *  this works for dhog
	 */
.
186d
## diffname pc/kbd.c 1992/1014
## diff -e /n/bootesdump/1992/1013/sys/src/9/pc/kbd.c /n/bootesdump/1992/1014/sys/src/9/pc/kbd.c
163c
		for(tries=0; tries < 100; tries++){
.
133c
		if(tries > 10000)
.
## diffname pc/kbd.c 1992/1015
## diff -e /n/bootesdump/1992/1014/sys/src/9/pc/kbd.c /n/bootesdump/1992/1015/sys/src/9/pc/kbd.c
407c
		mymouseputc(&mouseq, c);
.
347a
	return 0;
.
330c
		return 0;
.
325a
	USED(q);		/* not */
.
317,318c
static int
mymouseputc(IOQ *q, int c)
.
270a
	splx(x);

.
266a
	if(outready() < 0)
		print("mouse init failed\n");
.
265c
		print("mouse init failed\n");
.
262,263c
		print("mouse init failed\n");
	outb(Data, ccc);
.
259a
	x = splhi();
	ccc &= ~Cmousedis;
	ccc |= Cmouseint;
	if(outready() < 0)
		print("mouse init failed\n");
.
253,254c
	int x;
.
239c
	if(mousetype == Mouseserial)
.
230c
	outb(Data, ccc);
	outready();
.
226a
	ccc &= ~Ckbddis;
	ccc |= Csf | Ckbdint | Cscs1;
	if(outready() < 0)
		print("kbd init failed\n");
.
225a
	/* get current controller command byte */
	outb(Cmd, 0x20);
	if(inready() < 0){
		print("kbdinit: can't read ccc\n");
		ccc = 0;
	} else
		ccc = inb(Data);

.
185a
	outready();
.
176a
	}
.
175c
	if(c != 0xFA){
		print("mouse returns %2.2ux to the %2.2ux command\n", c, cmd);
.
163,173c
		if(tries++ > 5)
			break;
		if(outready() < 0)
			continue;
		outb(Cmd, 0xD4);
		if(outready() < 0)
			continue;
		outb(Data, cmd);
		if(outready() < 0)
			continue;
		if(inready() < 0)
			continue;
		c = inb(Data);
.
161a
	tries = 0;
.
148a
		delay(2);
	}
.
146,147c
	for(tries = 0; !(inb(Status) & Inready); tries++){
		if(tries > 500)
.
134a
		delay(2);
	}
.
132,133c
	for(tries = 0; (inb(Status) & Outbusy); tries++){
		if(tries > 500)
.
123a
static int	mymouseputc(IOQ*, int);

.
116a
	/* controller command byte */
	Cscs1=		(1<<6),		/* scan code set 1 */
	Cmousedis=	(1<<5),		/* mouse disable */
	Ckbddis=	(1<<4),		/* kbd disable */
	Csf=		(1<<2),		/* system flag */
	Cmouseint=	(1<<1),		/* mouse interrupt enable */
	Ckbdint=	(1<<0),		/* kbd interrupt enable */

.
108a
static uchar ccc;
.
## diffname pc/kbd.c 1992/1016
## diff -e /n/bootesdump/1992/1015/sys/src/9/pc/kbd.c /n/bootesdump/1992/1016/sys/src/9/pc/kbd.c
343a
		splx(x);
.
341a
		x = splhi();
.
338a
	int x;
.
328a
		splx(x);
.
324a
		x = splhi();
.
321a
	int x;
.
309c
	mousecmd(0xF6);
.
273c
	if(mousetype)
.
192c
	} while(c == 0xFE || c == 0);
.
190c
			break;
.
188c
			break;
.
185c
			break;
.
182c
			break;
.
## diffname pc/kbd.c 1992/1017
## diff -e /n/bootesdump/1992/1016/sys/src/9/pc/kbd.c /n/bootesdump/1992/1017/sys/src/9/pc/kbd.c
581c
			mbon(Lbutton);
.
578c
			mbon(Mbutton);
.
575c
			mbon(Rbutton);
.
511c
			mboff(Lbutton);
.
508c
			mboff(Mbutton);
.
505c
			mboff(Rbutton);
.
457c
		ps2mouseputc(&mouseq, c);
.
400a
 *  microsoft 3 button, 7 bit bytes
 *
 *	byte 0 -	1  L  R Y7 Y6 X7 X6
 *	byte 1 -	0 X5 X4 X3 X2 X1 X0
 *	byte 2 -	0 Y5 Y4 Y3 Y2 Y1 Y0
 *	byte 3 -	0  M  x  x  x  x  x	(optional)
 *
 *  shift & left button is the same as middle button (for 2 button mice)
 */
static int
m3mouseputc(IOQ *q, int c)
{
	static uchar msg[3];
	static int nb;
	static uchar b[] = { 0, 4, 1, 5, 0, 4, 3, 7 };
	extern Mouseinfo mouse;

	USED(q);		/* not */

	/* 
	 *  check bit 6 for consistency
	 */
	if(nb==0){
		if((c&0x40) != 0){
			/* must be 4th (M button) byte */
			mousebuttons = (mousebuttons & ~Mbutton) | ((c&0x2)?Mbutton:0);
			mouse.newbuttons = mousebuttons | keybuttons;
			mouse.dx = 0;
			mouse.dy = 0;
			mouse.track = 0;
			mouseclock();
			return 0;
		}
	}
	msg[nb] = c;
	if(++nb == 3){
		nb = 0;
		mousebuttons = b[(msg[0]>>4)&3 | (shift ? 4 : 0)];
		mouse.newbuttons = mousebuttons | keybuttons;
		mouse.dx = (((msg[0]&3)<<7) | msg[1]) - 128;
		mouse.dy = (((msg[0]&0xc)<<5) | msg[2]) - 128;
		mouse.track = 1;
		mouseclock();
	}
	return 0;
}

/*
 *  set/change mouse configuration
 */
void
mousectl(char *arg)
{
	int n, x;
	char *field[3];

	n = getfields(arg, field, 3, ' ');
	if(n < 1)
		return;
	if(strncmp(field[0], "serial", 6) == 0){
		if(n > 1)
			serialmouse(atoi(field[1]), field[2], 0);
		else
			serialmouse(atoi(field[0]+6), 0, 1);
	} else if(strcmp(field[0], "ps2") == 0){
		ps2mouse();
	} else if(strcmp(field[0], "accelerated") == 0){
		switch(mousetype){
		case MousePS2:
			x = splhi();
			mousecmd(0xE7);
			splx(x);
			break;
		}
	} else if(strcmp(field[0], "linear") == 0){
		switch(mousetype){
		case MousePS2:
			x = splhi();
			mousecmd(0xE6);
			splx(x);
			break;
		}
	} else if(strcmp(field[0], "res") == 0){
		if(n < 2)
			n = 1;
		else
			n = atoi(field[1]);
		switch(mousetype){
		case MousePS2:
			x = splhi();
			mousecmd(0xE8);
			mousecmd(n);
			splx(x);
			break;
		}
	}
}

/*
.
371d
366c
ps2mouseputc(IOQ *q, int c)
.
317,357c
 *  ps/2 mouse message is three bytes
.
309c
	mousecmd(0xEA);
.
292a
	setvec(Mousevec, kbdintr);
.
289,290c
	if(mousetype)
		error(Emouseset);
.
284,285c
static void
ps2mouse(void)
.
277c
	uartspecial(port, 0, &mouseq, setspeed ? 1200 : 0);
	if(type && *type == 'M')
		mouseq.putc = m3mouseputc;
	mouseport = port;
.
274c
		error(Emouseset);
.
270,271c
static void
serialmouse(int port, char *type, int setspeed)
.
240a
	bigcursor();
.
133c
static void	kbdintr(Ureg*);
static int	ps2mouseputc(IOQ*, int);
static int	m3mouseputc(IOQ*, int);
.
131d
111,114d
109a
static int mousetype;
static int mouseport;
static int shift;
.
51a

	Rbutton=4,
	Mbutton=2,
	Lbutton=1,
.
6a
#include	"../port/error.h"
.
## diffname pc/kbd.c 1992/1020
## diff -e /n/bootesdump/1992/1017/sys/src/9/pc/kbd.c /n/bootesdump/1992/1020/sys/src/9/pc/kbd.c
634c
			mouseshifted = shift = 1;
.
567c
			mouseshifted = shift = 0;
.
486,491c
	mousebuttons(keybuttons);
.
475,480c
	mousebuttons(keybuttons);
.
433a
			break;
		case 2:
			serialmouse(atoi(field[1]), 0, 0);
			break;
		case 3:
		default:
			serialmouse(atoi(field[1]), field[2], 0);
			break;
		}
.
430,432c
		switch(n){
		case 1:
.
427,428d
370,417d
358,359c
		mouse.newbuttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons;
.
341d
281a
	if(port >= 2 || port < 0)
		error(Ebadarg);

.
138d
119d
117a
extern int mouseshifted;
.
112d
12a
extern Mouseinfo mouse;

.
## diffname pc/kbd.c 1992/1021
## diff -e /n/bootesdump/1992/1020/sys/src/9/pc/kbd.c /n/bootesdump/1992/1021/sys/src/9/pc/kbd.c
289d
130,134d
119d
116,117d
## diffname pc/kbd.c 1992/1113
## diff -e /n/bootesdump/1992/1021/sys/src/9/pc/kbd.c /n/bootesdump/1992/1113/sys/src/9/pc/kbd.c
355d
## diffname pc/kbd.c 1992/1217
## diff -e /n/bootesdump/1992/1113/sys/src/9/pc/kbd.c /n/bootesdump/1992/1217/sys/src/9/pc/kbd.c
191c
		kprint("mouse returns %2.2ux to the %2.2ux command\n", c, cmd);
.
## diffname pc/kbd.c 1993/0226
## diff -e /n/bootesdump/1992/1217/sys/src/9/pc/kbd.c /n/bootesdump/1993/0226/sys/src/9/pc/kbd.c
580,588d
511,519d
418,433d
351,355c
		buttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons;
		dx = msg[1];
		dy = -msg[2];
		mousetrack(buttons, dx, dy);
.
334a
	int buttons, dx, dy;
.
13,14d
## diffname pc/kbd.c 1993/0915
## diff -e /n/bootesdump/1993/0226/sys/src/9/pc/kbd.c /n/fornaxdump/1993/0915/sys/src/brazil/pc/kbd.c
564a
}

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);
.
292a
	if(ct82c710() == 0)
		return;

.
282a
 *  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;
}

/*
.
281a
static void nop(void){};

.
229a

.
174c
		if(tries++ > 2)
.
127a
static void	ctps2intr(Ureg*);
.
114a
ulong ctport;
.
27a
	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,

.
## diffname pc/kbd.c 1993/1113
## diff -e /n/fornaxdump/1993/0915/sys/src/brazil/pc/kbd.c /n/fornaxdump/1993/1113/sys/src/brazil/pc/kbd.c
644c
	ps2mouseputc(c);
.
621c
	kbdputc(kbdq, c);
.
598c
			kbdputc(kbdq, c);
.
584c
				kbdputc(kbdq, kc[i]);
.
582c
				kbdputc(kbdq, c);
.
511c
		ps2mouseputc(c);
.
400d
393c
ps2mouseputc(int c)
.
292c
		NS16552special(port, setspeed, 0, 0, m3mouseputc);
	else
		NS16552special(port, setspeed, 0, 0, 0);
.
290c
	if(setspeed)
		setspeed = 1200;
.
248a
	kbdq = qopen(4*1024, 0, 0, 0);

.
142a
extern int m3mouseputc(IOQ*, int);

.
141d
118,122d
## diffname pc/kbd.c 1993/1116
## diff -e /n/fornaxdump/1993/1113/sys/src/brazil/pc/kbd.c /n/fornaxdump/1993/1116/sys/src/brazil/pc/kbd.c
248d
11d
## diffname pc/kbd.c 1993/1117
## diff -e /n/fornaxdump/1993/1116/sys/src/brazil/pc/kbd.c /n/fornaxdump/1993/1117/sys/src/brazil/pc/kbd.c
291c
		NS16552special(port, setspeed, &mouseq, 0, mouseputc);
.
289c
		NS16552special(port, setspeed, &mouseq, 0, m3mouseputc);
.
136c
extern int m3mouseputc(IOQ*, int), mouseputc(IOQ*, int);
.
## diffname pc/kbd.c 1993/1124
## diff -e /n/fornaxdump/1993/1117/sys/src/brazil/pc/kbd.c /n/fornaxdump/1993/1124/sys/src/brazil/pc/kbd.c
635,642c
	kbdq = qopen(4*1024, 0, 0, 0);

	setvec(Kbdvec, kbdintr, 0);

	/* wait for a quiescent controller */
	while((c = inb(Status)) & (Outbusy | Inready))
		if(c & Inready)
			inb(Data);

	/* get current controller command byte */
	outb(Cmd, 0x20);
	if(inready() < 0){
		print("kbdinit: can't read ccc\n");
		ccc = 0;
	} else
		ccc = inb(Data);

	/* enable kbd xfers and interrupts */
	ccc &= ~Ckbddis;
	ccc |= Csf | Ckbdint | Cscs1;
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Cmd, 0x60);
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Data, ccc);
	outready();
.
633c
	int c;
.
631c
kbdinit(void)
.
626,627c
	int n, x;
	char *field[3];

	n = getfields(arg, field, 3, ' ');
	if(strncmp(field[0], "serial", 6) == 0){
		switch(n){
		case 1:
			serialmouse(atoi(field[0]+6), 0, 1);
			break;
		case 2:
			serialmouse(atoi(field[1]), 0, 0);
			break;
		case 3:
		default:
			serialmouse(atoi(field[1]), field[2], 0);
			break;
		}
	} else if(strcmp(field[0], "ps2") == 0){
		ps2mouse();
	} else if(strcmp(field[0], "accelerated") == 0){
		switch(mousetype){
		case MousePS2:
			x = splhi();
			mousecmd(0xE7);
			splx(x);
			break;
		}
	} else if(strcmp(field[0], "linear") == 0){
		switch(mousetype){
		case MousePS2:
			x = splhi();
			mousecmd(0xE6);
			splx(x);
			break;
		}
	} else if(strcmp(field[0], "res") == 0){
		if(n < 2)
			n = 1;
		else
			n = atoi(field[1]);
		switch(mousetype){
		case MousePS2:
			x = splhi();
			mousecmd(0xE8);
			mousecmd(n);
			splx(x);
			break;
		}
	}
.
624c
mousectl(char *arg)
.
622a
/*
 *  set up a ps2 mouse
 */
static void
ps2mouse(void)
{
	int x;

	if(mousetype)
		error(Emouseset);

	if(ct82c710() == 0)
		return;

	/* enable kbd/mouse xfers and interrupts */
	setvec(Mousevec, kbdintr, 0);
	x = splhi();
	ccc &= ~Cmousedis;
	ccc |= Cmouseint;
	if(outready() < 0)
		print("mouse init failed\n");
	outb(Cmd, 0x60);
	if(outready() < 0)
		print("mouse init failed\n");
	outb(Data, ccc);
	if(outready() < 0)
		print("mouse init failed\n");
	outb(Cmd, 0xA8);
	if(outready() < 0)
		print("mouse init failed\n");

	/* make mouse streaming, enabled */
	mousecmd(0xEA);
	mousecmd(0xF4);
	splx(x);

	mousetype = MousePS2;
}

/*
 *  set/change mouse configuration
 */
.
620d
616c
			return;
.
613c
			return;
.
610c
			return;
.
607c
			return;
.
604c
			return;
.
599c
		return;
.
557c
		return;
.
536c
		return;
.
528c
		return;
.
521c
		return;
.
518c
		return;
.
510c
		return;
.
498c
		return;
.
492a
	USED(ur, arg);

.
349,483d
347c
kbdintr(Ureg *ur, void *arg)
.
344c
 *  keyboard interrupt
.
331c
	setvec(Mousevec, ctps2intr, 0);
.
294a
/*
 *  ps/2 mouse message is three bytes
 *
 *	byte 0 -	0 0 SDY SDX 1 M R L
 *	byte 1 -	DX
 *	byte 2 -	DY
 *
 *  shift & left button is the same as middle button
 */
static int
ps2mouseputc(int c)
{
	static short msg[3];
	static int nb;
	static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 5, 2, 3, 6, 7 };
	int buttons, dx, dy;

	/* 
	 *  check byte 0 for consistency
	 */
	if(nb==0 && (c&0xc8)!=0x08)
		return 0;

	msg[nb] = c;
	if(++nb == 3){
		nb = 0;
		if(msg[0] & 0x10)
			msg[1] |= 0xFF00;
		if(msg[0] & 0x20)
			msg[2] |= 0xFF00;

		buttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons;
		dx = msg[1];
		dy = -msg[2];
		mousetrack(buttons, dx, dy);
	}
	return 0;
}

static void
ctps2intr(Ureg *ur, void *arg)
{
	uchar c;

	USED(ur, arg);
	c = inb(ctport + CTstatus);
	if(c & Error)
		return;
	if((c & Rready) == 0)
		return;
	c = inb(ctport + CTdata);
	ps2mouseputc(c);
}

.
238,272d
133,135d
## diffname pc/kbd.c 1993/1221
## diff -e /n/fornaxdump/1993/1124/sys/src/brazil/pc/kbd.c /n/fornaxdump/1993/1221/sys/src/brazil/pc/kbd.c
253c
		NS16552special(port, setspeed, &mouseq, 0, NS16552mouse);
.
251c
		NS16552special(port, setspeed, &mouseq, 0, NS16552m3mouse);
.
133,134d
## diffname pc/kbd.c 1994/0205
## diff -e /n/fornaxdump/1993/1221/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0205/sys/src/brazil/pc/kbd.c
390c
		if(mousetype == MousePS2)
			ps2mouseputc(c);
.
## diffname pc/kbd.c 1994/0216
## diff -e /n/fornaxdump/1994/0205/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0216/sys/src/brazil/pc/kbd.c
597c
	} else if(strcmp(field[0], "swap") == 0)
		mouseswap ^= 1;
.
## diffname pc/kbd.c 1994/0317
## diff -e /n/fornaxdump/1994/0216/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0317/sys/src/brazil/pc/kbd.c
625c
	ccc |= Csf | Ckbdint | Cscs1 | Cmousedis;
.
567c
		ps2mouse(0);
.
535a
	setvec(Mousevec, kbdintr, 0);
.
532,533c
	if(outready() < 0){
		splx(x);
		return;
	}
.
519d
512,513c
	if(mousetype == MousePS2)
		return;
.
508c
ps2mouse(int frominit)
.
239c
	if(mousetype == Mouseserial)
.
## diffname pc/kbd.c 1994/0322
## diff -e /n/fornaxdump/1994/0317/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0322/sys/src/brazil/pc/kbd.c
625a
	/* disable mouse */
.
569c
		ps2mouse();
.
508c
ps2mouse(void)
.
## diffname pc/kbd.c 1994/0413
## diff -e /n/fornaxdump/1994/0322/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0413/sys/src/brazil/pc/kbd.c
10d
## diffname pc/kbd.c 1994/0503
## diff -e /n/fornaxdump/1994/0413/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0503/sys/src/brazil/pc/kbd.c
493c
			collecting = 1;
			nk = 0;
.
479a
		kc[nk++] = c;
		c = latin1(kc, nk);
		if(c < -1)	/* need more keystrokes */
			return;
		if(c != -1)	/* valid sequence */
			kbdputc(kbdq, c);
		else	/* dump characters */
			for(i=0; i<nk; i++)
				kbdputc(kbdq, kc[i]);
		nk = 0;
		collecting = 0;
.
478c
			return;
.
447,476c
		if(!collecting){
.
367c
	static int collecting, nk;
.
362c
	int s, c, i;
.
## diffname pc/kbd.c 1994/0510
## diff -e /n/fornaxdump/1994/0503/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0510/sys/src/brazil/pc/kbd.c
227a
	delay(100);
.
## diffname pc/kbd.c 1994/0512
## diff -e /n/fornaxdump/1994/0510/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0512/sys/src/brazil/pc/kbd.c
229a
	outready();
	delay(100);
	outb(Cmd, 0xD1);
	outready();
	outb(Data, 0xDF);	/* set reset line low */
.
228d
220c
	outb(Cmd, 0xFE);	/* pulse reset line (means resend on AT&T machines) */
.
## diffname pc/kbd.c 1994/0730
## diff -e /n/fornaxdump/1994/0512/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0730/sys/src/brazil/pc/kbd.c
255c
		NS16552special(port, setspeed, &mouseq, 0, mouseputc);
.
253c
		NS16552special(port, setspeed, &mouseq, 0, m3mouseputc);
.
## diffname pc/kbd.c 1994/0825
## diff -e /n/fornaxdump/1994/0730/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0825/sys/src/brazil/pc/kbd.c
246c
	if(port >= 3 || port < 0)
.
## diffname pc/kbd.c 1994/0826
## diff -e /n/fornaxdump/1994/0825/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0826/sys/src/brazil/pc/kbd.c
215a
	ushort *s = (ushort*)(KZERO|0x472);

	*s = 0x1234;		/* BIOS warm-boot flag */

.
## diffname pc/kbd.c 1994/0902
## diff -e /n/fornaxdump/1994/0826/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0902/sys/src/brazil/pc/kbd.c
599a
	qnoblock(kbdq, 1);
.
259c
		ns16552special(port, setspeed, &mouseq, 0, mouseputc);
.
257c
		ns16552special(port, setspeed, &mouseq, 0, m3mouseputc);
.
## diffname pc/kbd.c 1994/0923
## diff -e /n/fornaxdump/1994/0902/sys/src/brazil/pc/kbd.c /n/fornaxdump/1994/0923/sys/src/brazil/pc/kbd.c
229,238c
	x = 0xDF;
	for(i = 0; i < 5; i++){
		x ^= 1;
		outready();
		outb(Cmd, 0xD1);
		outready();
		outb(Data, x);	/* toggle reset */
		delay(100);
	}
.
227c
	 *  Pulse it by hand (old somewhat reliable)
.
225a

.
216a
	int i, x;
.
## diffname pc/kbd.c 1995/0105
## diff -e /n/fornaxdump/1994/0923/sys/src/brazil/pc/kbd.c /n/fornaxdump/1995/0105/sys/src/brazil/pc/kbd.c
191c
		print("mouse returns %2.2ux to the %2.2ux command\n", c, cmd);
.
## diffname pc/kbd.c 1995/0117
## diff -e /n/fornaxdump/1995/0105/sys/src/brazil/pc/kbd.c /n/fornaxdump/1995/0117/sys/src/brazil/pc/kbd.c
546c
	n = getfields(arg, field, 3, " ");
.
## diffname pc/kbd.c 1995/0207
## diff -e /n/fornaxdump/1995/0117/sys/src/brazil/pc/kbd.c /n/fornaxdump/1995/0207/sys/src/brazil/pc/kbd.c
592a
	else
		error(Ebadctl);
.
## diffname pc/kbd.c 1995/0330
## diff -e /n/fornaxdump/1995/0207/sys/src/brazil/pc/kbd.c /n/fornaxdump/1995/0330/sys/src/brazil/pc/kbd.c
484a
			alt = 1;
.
456a
		}
.
455c
		if(ctl){
			if(alt && c == Del)
				exit(0);
.
440a
		case Latin:
			alt = 0;
			break;
.
377a
	static int alt;
.
## diffname pc/kbd.c 1995/1216
## diff -e /n/fornaxdump/1995/0330/sys/src/brazil/pc/kbd.c /n/fornaxdump/1995/1216/sys/src/brazil/pc/kbd.c
583a
			break;
		default:
			mouseaccelerate("0");
.
576a
		default:
			mouseaccelerate(field[1]);
			break;
.
## diffname pc/kbd.c 1996/0315
## diff -e /n/fornaxdump/1995/1216/sys/src/brazil/pc/kbd.c /n/fornaxdump/1996/0315/sys/src/brazil/pc/kbd.c
554c
	n = parsefields(arg, field, 3, " ");
.
## diffname pc/kbd.c 1997/0327
## diff -e /n/fornaxdump/1996/0315/sys/src/brazil/pc/kbd.c /n/emeliedump/1997/0327/sys/src/brazil/pc/kbd.c
637c
	ccc |= Csf | Ckbdint | Cscs1;
.
619c
	intrenable(VectorKBD, i8042intr, 0, BUSUNKNOWN);
.
549,611d
545,547d
535,542c
	auxputc = putc;
	intrenable(VectorAUX, i8042intr, 0, BUSUNKNOWN);
	iunlock(&i8042lock);
.
532c
		iunlock(&i8042lock);
.
529,530c
		print(err);
	outb(Cmd, 0xA8);			/* auxilliary device enable */
.
526c
		print(err);
.
523,524c
		print(err);
	outb(Cmd, 0x60);			/* write control register */
.
515,521c
	ilock(&i8042lock);
.
512,513c
	/* enable kbd/aux xfers and interrupts */
	ccc &= ~Cauxdis;
	ccc |= Cauxint;
.
510c
	char *err = "i8042: aux init failed\n";
.
504,508c
void
i8042auxenable(void (*putc)(int, int))
.
489c
			shift = 1;
.
446c
			shift = 0;
.
400,401c
		if(auxputc != nil)
			auxputc(c, shift);
.
397c
	 *  if it's the aux port...
.
394a
	unlock(&i8042lock);
.
389a
	}
.
388c
	if(!(s&Inready)){
		unlock(&i8042lock);
.
386a
	lock(&i8042lock);
.
382,383d
378d
374,376c
	static int alt, caps, ctl, num, shift;
.
370c
i8042intr(Ureg*, void*)
.
321,366d
303,319d
264,298c
	if(c != 0xFA){
		print("i8042: %2.2ux returned to the %2.2ux command\n", c, cmd);
		return -1;
.
254,262c
	ilock(&i8042lock);
	do{
		if(tries++ > 2)
			break;
		if(outready() < 0)
			break;
		outb(Cmd, 0xD4);
		if(outready() < 0)
			break;
		outb(Data, cmd);
		if(outready() < 0)
			break;
		if(inready() < 0)
			break;
		c = inb(Data);
	} while(c == 0xFE || c == 0);
	iunlock(&i8042lock);
.
251,252c
	c = 0;
	tries = 0;
.
248,249c
	unsigned int c;
	int tries;
.
242,246c
int
i8042auxcmd(int cmd)
.
225c
	outb(Cmd, 0xFE);
.
222c
	 *  newer reset the machine command
.
165,210d
131a
static Lock i8042lock;
static uchar ccc;
static void (*auxputc)(int, int);

.
128c
	Cauxint=	(1<<1),		/* mouse interrupt enable */
.
125c
	Cauxdis=	(1<<5),		/* mouse disable */
.
116,120d
39,65c
	Home=		KF|13,
	Up=		KF|14,
	Pgup=		KF|15,
	Print=		KF|16,
	Left=		View,
	Right=		View,
	End=		'\r',
	Down=		View,
	Pgdown=		View,
	Ins=		KF|20,
	Del=		0x7F,
.
37c
	PF=		Spec|0x20,	/* num pad function key */
	View=		Spec|0x00,	/* view (shift window up) */
	KF=		Spec|0x40,	/* function key */
	Shift=		Spec|0x60,
	Break=		Spec|0x61,
	Ctrl=		Spec|0x62,
	Latin=		Spec|0x63,
	Caps=		Spec|0x64,
	Num=		Spec|0x65,
	Middle=		Spec|0x66,
	No=		0x00,		/* peter */
.
26,35c
	Spec=		0x80,
.
24c
	Cmd=		0x64,		/* command port (write only) */
.
14,21c
	Status=		0x64,		/* status port */
	 Inready=	0x01,		/*  input character ready */
	 Outbusy=	0x02,		/*  output busy */
	 Sysflag=	0x04,		/*  system flag */
	 Cmddata=	0x08,		/*  cmd==0, data==1 */
	 Inhibit=	0x10,		/*  keyboard/mouse inhibited */
	 Minready=	0x20,		/*  mouse character ready */
	 Rtimeout=	0x40,		/*  general timeout */
.
12c
	Data=		0x60,		/* data port */
.
9,10d
## diffname pc/kbd.c 1997/1101
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/pc/kbd.c /n/emeliedump/1997/1101/sys/src/brazil/pc/kbd.c
152c
	ushort *s = KADDR(0x472);
.
## diffname pc/kbd.c 1997/1105
## diff -e /n/emeliedump/1997/1101/sys/src/brazil/pc/kbd.c /n/emeliedump/1997/1105/sys/src/brazil/pc/kbd.c
382a
	if(kbdq == nil)
		panic("kbdinit");
.
## diffname pc/kbd.c 1998/0207
## diff -e /n/emeliedump/1997/1105/sys/src/brazil/pc/kbd.c /n/emeliedump/1998/0207/sys/src/brazil/pc/kbd.c
264c
		c |= keyup;
		if(c != 0xFF)	/* these come fairly often: CAPSLOCK U Y */
			print("unknown key %ux\n", c);
.
## diffname pc/kbd.c 1998/0910
## diff -e /n/emeliedump/1998/0207/sys/src/brazil/pc/kbd.c /n/emeliedump/1998/0910/sys/src/brazil/pc/kbd.c
389c
	intrenable(IrqKBD, i8042intr, 0, BUSUNKNOWN);
.
375c
	intrenable(IrqAUX, i8042intr, 0, BUSUNKNOWN);
.
## diffname pc/kbd.c 1998/1006
## diff -e /n/emeliedump/1998/0910/sys/src/brazil/pc/kbd.c /n/emeliedump/1998/1006/sys/src/brazil/pc/kbd.c
96a
[0x60]	No,	No,	No,	No,	No,	No,	No,	No,
[0x68]	No,	No,	No,	No,	No,	No,	No,	No,
[0x70]	No,	No,	No,	No,	No,	No,	No,	No,
[0x78]	No,	KF|14,	No,	No,	No,	No,	No,	No,
.
80a
[0x60]	No,	No,	No,	No,	No,	No,	No,	No,
[0x68]	No,	No,	No,	No,	No,	No,	No,	No,
[0x70]	No,	No,	No,	No,	No,	No,	No,	No,
[0x78]	No,	KF|14,	No,	KF|14,	No,	No,	No,	No,
.
64a
[0x60]	No,	No,	No,	No,	No,	No,	No,	No,
[0x68]	No,	No,	No,	No,	No,	No,	No,	No,
[0x70]	No,	No,	No,	No,	No,	No,	No,	No,
[0x78]	No,	View,	No,	KF|14,	No,	No,	No,	No,
.
## diffname pc/kbd.c 1999/0713
## diff -e /n/emeliedump/1998/1006/sys/src/brazil/pc/kbd.c /n/emeliedump/1999/0713/sys/src/brazil/pc/kbd.c
400a
	ioalloc(Data, 1, 0);
	ioalloc(Cmd, 1, 0);

.
## diffname pc/kbd.c 1999/0714
## diff -e /n/emeliedump/1999/0713/sys/src/brazil/pc/kbd.c /n/emeliedump/1999/0714/sys/src/brazil/pc/kbd.c
401,402c
	ioalloc(Data, 1, 0, "kbd");
	ioalloc(Cmd, 1, 0, "kbd");
.
## diffname pc/kbd.c 1999/0819
## diff -e /n/emeliedump/1999/0714/sys/src/brazil/pc/kbd.c /n/emeliedump/1999/0819/sys/src/brazil/pc/kbd.c
404c
	intrenable(IrqKBD, i8042intr, 0, BUSUNKNOWN, "kbd");
.
387c
	intrenable(IrqAUX, i8042intr, 0, BUSUNKNOWN, "kbdaux");
.
## diffname pc/kbd.c 1999/1005
## diff -e /n/emeliedump/1999/0819/sys/src/brazil/pc/kbd.c /n/emeliedump/1999/1005/sys/src/brazil/pc/kbd.c
317c
	if(!(c & (Spec|KF))){
.
234c
	static Rune kc[5];
.
91c
Rune kbtabesc1[] =
.
71c
Rune kbtabshift[] =
.
51c
Rune kbtab[] = 
.
46c
	Pgdown=		KF|19,
.
42,43c
	Left=		KF|17,
	Right=		KF|18,
.
28c
	KF=		0xF000,	/* function key (begin Unicode private space) */
.
## diffname pc/kbd.c 1999/1207
## diff -e /n/emeliedump/1999/1005/sys/src/brazil/pc/kbd.c /n/emeliedump/1999/1207/sys/src/9/pc/kbd.c
108c
[0x78]	No,	No,	No,	No,	No,	No,	No,	No,
.
88c
[0x78]	No,	No,	No,	No,	No,	No,	No,	No,
.
81c
[0x40]	KF|6,	KF|7,	KF|8,	KF|9,	KF|10,	Num,	Scroll,	'7',
.
68c
[0x78]	No,	No,	No,	No,	No,	No,	No,	No,
.
61c
[0x40]	KF|6,	KF|7,	KF|8,	KF|9,	KF|10,	Num,	Scroll,	'7',
.
48a
	Scroll=		KF|21,
.
## diffname pc/kbd.c 2000/0107
## diff -e /n/emeliedump/1999/1207/sys/src/9/pc/kbd.c /n/emeliedump/2000/0107/sys/src/9/pc/kbd.c
109c
[0x78]	No,	Up,	No,	No,	No,	No,	No,	No,
.
89c
[0x78]	No,	Up,	No,	Up,	No,	No,	No,	No,
.
69c
[0x78]	No,	View,	No,	Up,	No,	No,	No,	No,
.
51a
/*
 * The codes at 0x79 and 0x81 are produed by the PFU Happy Hacking keyboard.
 * A 'standard' keyboard doesn't produce anything above 0x58.
 */
.
## diffname pc/kbd.c 2002/0411
## diff -e /n/emeliedump/2000/0107/sys/src/9/pc/kbd.c /n/emeliedump/2002/0411/sys/src/9/pc/kbd.c
434a
}

void
kbdenable(void)
{
	kbdq = qopen(4*1024, 0, 0, 0);
	if(kbdq == nil)
		panic("kbdinit");
	qnoblock(kbdq, 1);

	ioalloc(Data, 1, 0, "kbd");
	ioalloc(Cmd, 1, 0, "kbd");

	intrenable(IrqKBD, i8042intr, 0, BUSUNKNOWN, "kbd");
.
401,410d
## diffname pc/kbd.c 2002/0417
## diff -e /n/emeliedump/2002/0411/sys/src/9/pc/kbd.c /n/emeliedump/2002/0417/sys/src/9/pc/kbd.c
360a
			collecting = 0;
			nk = 0;
.
357,358c
			/*
			 * VMware uses Ctl-Alt as the key combination
			 * to make the VM give up keyboard and mouse focus.
			 * This has the unfortunate side effect that when you
			 * come back into focus, Plan 9 thinks you want to type
			 * a compose sequence (you just typed alt). 
			 *
			 * As a clusmy hack around this, we look for ctl-alt
			 * and don't treat it as the start of a compose sequence.
			 */
			if(!ctl){
				collecting = 1;
				nk = 0;
			}
.
## diffname pc/kbd.c 2002/0506
## diff -e /n/emeliedump/2002/0417/sys/src/9/pc/kbd.c /n/emeliedump/2002/0506/sys/src/9/pc/kbd.c
453a

.
228a
int
i8042auxcmds(uchar *cmd, int ncmd)
{
	int i;

	ilock(&i8042lock);
	for(i=0; i<ncmd; i++){
		if(outready() < 0)
			break;
		outb(Cmd, 0xD4);
		if(outready() < 0)
			break;
		outb(Data, cmd[i]);
	}
	iunlock(&i8042lock);
	return i;
}

.
## diffname pc/kbd.c 2002/0703
## diff -e /n/emeliedump/2002/0506/sys/src/9/pc/kbd.c /n/emeliedump/2002/0703/sys/src/9/pc/kbd.c
472d
## diffname pc/kbd.c 2002/0718
## diff -e /n/emeliedump/2002/0703/sys/src/9/pc/kbd.c /n/emeliedump/2002/0718/sys/src/9/pc/kbd.c
371a
			mouseshifted = 1;
.
328a
			mouseshifted = 0;
.
126a
int mouseshifted;

.
## diffname pc/kbd.c 2002/1213
## diff -e /n/emeliedump/2002/0718/sys/src/9/pc/kbd.c /n/emeliedump/2002/1213/sys/src/9/pc/kbd.c
386c
			 * As a clumsy hack around this, we look for ctl-alt
.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.