The seccond address is 0x7b, not 0x81. Reference: /n/sources/patch/applied/kbd.c-comment-hexmath Date: Sun Apr 12 05:13:44 CES 2009 Signed-off-by: a@9srv.net --- /sys/src/9/pc/kbd.c Sun Apr 12 05:12:44 2009 +++ /sys/src/9/pc/kbd.c Sun Apr 12 05:12:42 2009 @@ -56,7 +56,7 @@ }; /* - * The codes at 0x79 and 0x81 are produed by the PFU Happy Hacking keyboard. + * The codes at 0x79 and 0x7b are produed by the PFU Happy Hacking keyboard. * A 'standard' keyboard doesn't produce anything above 0x58. */ Rune kbtab[Nscan] = @@ -176,7 +176,6 @@ static Lock i8042lock; static uchar ccc; static void (*auxputc)(int, int); -static int nokbd = 1; /* * wait for output no longer busy @@ -216,12 +215,10 @@ void i8042reset(void) { + ushort *s = KADDR(0x472); int i, x; - if(nokbd) - return; - - *((ushort*)KADDR(0x472)) = 0x1234; /* BIOS warm-boot flag */ + *s = 0x1234; /* BIOS warm-boot flag */ /* * newer reset the machine command @@ -546,57 +543,35 @@ iunlock(&i8042lock); } -static char *initfailed = "i8042: kbdinit failed\n"; - -static int -outbyte(int port, int c) -{ - outb(port, c); - if(outready() < 0) { - print(initfailed); - return -1; - } - return 0; -} - void kbdinit(void) { - int c, try; + int c; /* wait for a quiescent controller */ - try = 1000; - while(try-- > 0 && (c = inb(Status)) & (Outbusy | Inready)) { + while((c = inb(Status)) & (Outbusy | Inready)) if(c & Inready) inb(Data); - delay(1); - } - if (try <= 0) { - print(initfailed); - return; - } /* get current controller command byte */ outb(Cmd, 0x20); if(inready() < 0){ - print("i8042: kbdinit can't read ccc\n"); + print("kbdinit: can't read ccc\n"); ccc = 0; } else ccc = inb(Data); /* enable kbd xfers and interrupts */ + /* disable mouse */ ccc &= ~Ckbddis; ccc |= Csf | Ckbdint | Cscs1; - if(outready() < 0) { - print(initfailed); - return; - } - - nokbd = 0; - - /* disable mouse */ - if (outbyte(Cmd, 0x60) < 0 || outbyte(Data, ccc) < 0) - print("i8042: kbdinit mouse disable failed\n"); + if(outready() < 0) + print("kbd init failed\n"); + outb(Cmd, 0x60); + if(outready() < 0) + print("kbd init failed\n"); + outb(Data, ccc); + outready(); } void