Put the delay in a macro, and implement it differently.

This commit is contained in:
mycroft 1994-10-09 09:28:54 +00:00
parent cbe87dbb9c
commit cce04a7aa1

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)pccons.c 5.11 (Berkeley) 5/21/91 * from: @(#)pccons.c 5.11 (Berkeley) 5/21/91
* $Id: pccons.c,v 1.66 1994/08/17 19:14:53 mycroft Exp $ * $Id: pccons.c,v 1.67 1994/10/09 09:28:54 mycroft Exp $
*/ */
/* /*
@ -149,6 +149,12 @@ char partab[];
extern pcopen(dev_t, int, int, struct proc *); extern pcopen(dev_t, int, int, struct proc *);
#define KBD_DELAY \
{ u_char x = inb(0x84); } \
{ u_char x = inb(0x84); } \
{ u_char x = inb(0x84); } \
{ u_char x = inb(0x84); }
static inline int static inline int
kbd_wait() kbd_wait()
{ {
@ -156,7 +162,7 @@ kbd_wait()
for (i = 100000; i; i--) for (i = 100000; i; i--)
if ((inb(KBSTATP) & KBS_IBF) == 0) { if ((inb(KBSTATP) & KBS_IBF) == 0) {
delay(6); KBD_DELAY;
return 1; return 1;
} }
return 0; return 0;
@ -216,7 +222,8 @@ kbd_cmd(val, polling)
for (i = 100000; i; i--) { for (i = 100000; i; i--) {
if (inb(KBSTATP) & KBS_DIB) { if (inb(KBSTATP) & KBS_DIB) {
register u_char c; register u_char c;
delay(6);
KBD_DELAY;
c = inb(KBDATAP); c = inb(KBDATAP);
if (c == KBR_ACK || c == KBR_ECHO) { if (c == KBR_ACK || c == KBR_ECHO) {
ack = 1; ack = 1;
@ -233,6 +240,7 @@ kbd_cmd(val, polling)
} }
else else
for (i = 100000; i; i--) { for (i = 100000; i; i--) {
inb(KBSTATP);
if (ack) if (ack)
return 1; return 1;
if (nak) if (nak)
@ -334,7 +342,7 @@ pcprobe(parent, self, aux)
#if 1 #if 1
/* Flush any garbage. */ /* Flush any garbage. */
while (inb(KBSTATP) & KBS_DIB) { while (inb(KBSTATP) & KBS_DIB) {
delay(6); KBD_DELAY;
(void) inb(KBDATAP); (void) inb(KBDATAP);
} }
/* Reset the keyboard. */ /* Reset the keyboard. */
@ -343,7 +351,7 @@ pcprobe(parent, self, aux)
goto lose; goto lose;
} }
while ((inb(KBSTATP) & KBS_DIB) == 0); while ((inb(KBSTATP) & KBS_DIB) == 0);
delay(6); KBD_DELAY;
if (inb(KBDATAP) != KBR_RSTDONE) { if (inb(KBDATAP) != KBR_RSTDONE) {
printf("pcprobe: reset error %d\n", 2); printf("pcprobe: reset error %d\n", 2);
goto lose; goto lose;
@ -354,7 +362,7 @@ pcprobe(parent, self, aux)
* flushing the buffer. * flushing the buffer.
*/ */
while (inb(KBSTATP) & KBS_DIB) { while (inb(KBSTATP) & KBS_DIB) {
delay(6); KBD_DELAY;
(void) inb(KBDATAP); (void) inb(KBDATAP);
} }
/* Just to be sure. */ /* Just to be sure. */
@ -666,13 +674,13 @@ pccnputc(dev, c)
pccngetc(dev) pccngetc(dev)
dev_t dev; dev_t dev;
{ {
register int s; u_char oldpolling;
register char *cp; register char *cp;
u_char oldpolling = polling;
if (pc_xmode > 0) if (pc_xmode > 0)
return 0; return 0;
oldpolling = polling;
polling = 1; polling = 1;
do { do {
/* wait for byte */ /* wait for byte */
@ -1328,6 +1336,7 @@ sget()
static u_char capchar[2]; static u_char capchar[2];
top: top:
KBD_DELAY;
dt = inb(KBDATAP); dt = inb(KBDATAP);
switch (dt) { switch (dt) {