summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pckbport/pckbdreg.h4
-rw-r--r--sys/dev/pckbport/pckbport.c71
2 files changed, 33 insertions, 42 deletions
diff --git a/sys/dev/pckbport/pckbdreg.h b/sys/dev/pckbport/pckbdreg.h
index 12e18e6f167..e848ea6599d 100644
--- a/sys/dev/pckbport/pckbdreg.h
+++ b/sys/dev/pckbport/pckbdreg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbdreg.h,v 1.2 2005/12/11 12:23:22 christos Exp $ */
+/* $NetBSD: pckbdreg.h,v 1.3 2013/03/06 03:26:17 christos Exp $ */
/*
* Keyboard definitions
@@ -19,7 +19,9 @@
#define KBR_EXTENDED0 0xE0 /* extended key sequence */
#define KBR_EXTENDED1 0xE1 /* extended key sequence */
#define KBR_RESEND 0xFE /* needs resend of command */
+#define KBR_BAT_DONE 0xAA
#define KBR_ACK 0xFA /* received a valid command */
+#define KBR_BAT_FAIL 0xFC
#define KBR_OVERRUN 0x00 /* flooded */
#define KBR_FAILURE 0xFD /* diagnostic failure */
#define KBR_BREAK 0xF0 /* break code prefix - sent on key release */
diff --git a/sys/dev/pckbport/pckbport.c b/sys/dev/pckbport/pckbport.c
index 340a0d495c0..32618f49b41 100644
--- a/sys/dev/pckbport/pckbport.c
+++ b/sys/dev/pckbport/pckbport.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbport.c,v 1.14 2011/09/09 14:00:01 jakllsch Exp $ */
+/* $NetBSD: pckbport.c,v 1.15 2013/03/06 03:26:17 christos Exp $ */
/*
* Copyright (c) 2004 Ben Harris
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pckbport.c,v 1.14 2011/09/09 14:00:01 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbport.c,v 1.15 2013/03/06 03:26:17 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -93,11 +93,14 @@ static const char * const pckbport_slot_names[] = { "kbd", "aux" };
static struct pckbport_tag pckbport_cntag;
-#define KBC_DEVCMD_ACK 0xfa
-#define KBC_DEVCMD_RESEND 0xfe
-
#define KBD_DELAY DELAY(8)
+#ifdef PCKBPORTDEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
static int
pckbport_poll_data1(pckbport_tag_t t, pckbport_slot_t slot)
{
@@ -261,35 +264,29 @@ pckbport_poll_cmd1(struct pckbport_tag *t, pckbport_slot_t slot,
if (c != -1)
break;
}
-
- if (c == KBC_DEVCMD_ACK) {
+ switch (c) {
+ case KBR_ACK:
cmd->cmdidx++;
continue;
- }
- if (c == KBC_DEVCMD_RESEND) {
-#ifdef PCKBPORTDEBUG
- printf("pckbport_cmd: RESEND\n");
-#endif
+ case KBR_BAT_DONE:
+ case KBR_BAT_FAIL:
+ case KBR_RESEND:
+ DPRINTF(("%s: %s\n", __func__, c == KBR_RESEND ?
+ "RESEND" : (c == KBR_BAT_DONE ? "BAT_DONE" :
+ "BAT_FAIL")));
if (cmd->retries++ < 5)
continue;
else {
-#ifdef PCKBPORTDEBUG
- printf("pckbport: cmd failed\n");
-#endif
+ DPRINTF(("%s: cmd failed\n", __func__));
cmd->status = EIO;
return;
}
- }
- if (c == -1) {
-#ifdef PCKBPORTDEBUG
- printf("pckbport_cmd: timeout\n");
-#endif
+ case -1:
+ DPRINTF(("%s: timeout\n", __func__));
cmd->status = EIO;
return;
}
-#ifdef PCKBPORTDEBUG
- printf("pckbport_cmd: lost 0x%x\n", c);
-#endif
+ DPRINTF(("%s: lost 0x%x\n", __func__, c));
}
while (cmd->responseidx < cmd->responselen) {
@@ -303,9 +300,7 @@ pckbport_poll_cmd1(struct pckbport_tag *t, pckbport_slot_t slot,
break;
}
if (c == -1) {
-#ifdef PCKBPORTDEBUG
- printf("pckbport_cmd: no data\n");
-#endif
+ DPRINTF(("%s: no data\n", __func__));
cmd->status = ETIMEDOUT;
return;
} else
@@ -344,15 +339,12 @@ void
pckbport_cleanqueue(struct pckbport_slotdata *q)
{
struct pckbport_devcmd *cmd;
-#ifdef PCKBPORTDEBUG
- int i;
-#endif
while ((cmd = TAILQ_FIRST(&q->cmdqueue))) {
TAILQ_REMOVE(&q->cmdqueue, cmd, next);
#ifdef PCKBPORTDEBUG
- printf("pckbport_cleanqueue: removing");
- for (i = 0; i < cmd->cmdlen; i++)
+ printf("%s: removing", __func__);
+ for (int i = 0; i < cmd->cmdlen; i++)
printf(" %02x", cmd->cmd[i]);
printf("\n");
#endif
@@ -445,17 +437,15 @@ pckbport_cmdresponse(struct pckbport_tag *t, pckbport_slot_t slot, u_char data)
panic("pckbport_cmdresponse: no active command");
#endif
if (cmd->cmdidx < cmd->cmdlen) {
- if (data != KBC_DEVCMD_ACK && data != KBC_DEVCMD_RESEND)
+ if (data != KBR_ACK && data != KBR_RESEND)
return 0;
- if (data == KBC_DEVCMD_RESEND) {
+ if (data == KBR_RESEND) {
if (cmd->retries++ < 5)
/* try again last command */
goto restart;
else {
-#ifdef PCKBPORTDEBUG
- printf("pckbport: cmd failed\n");
-#endif
+ DPRINTF(("%s: cmd failed\n", __func__));
cmd->status = EIO;
/* dequeue */
}
@@ -584,12 +574,11 @@ pckbportintr(pckbport_tag_t t, pckbport_slot_t slot, int data)
if (CMD_IN_QUEUE(q) && pckbport_cmdresponse(t, slot, data))
return;
- if (t->t_inputhandler[slot])
+ if (t->t_inputhandler[slot]) {
(*t->t_inputhandler[slot])(t->t_inputarg[slot], data);
-#ifdef PCKBPORTDEBUG
- else
- printf("pckbportintr: slot %d lost %d\n", slot, data);
-#endif
+ return;
+ }
+ DPRINTF(("%s: slot %d lost %d\n", slot, data, __func__));
}
int