? o Index: pckbdreg.h =================================================================== RCS file: /cvsroot/src/sys/dev/pckbport/pckbdreg.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -r1.2 -r1.3 --- pckbdreg.h 11 Dec 2005 12:23:22 -0000 1.2 +++ pckbdreg.h 6 Mar 2013 03:26:17 -0000 1.3 @@ -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 */ Index: pckbport.c =================================================================== RCS file: /cvsroot/src/sys/dev/pckbport/pckbport.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -p -r1.14 -r1.15 --- pckbport.c 9 Sep 2011 14:00:01 -0000 1.14 +++ pckbport.c 6 Mar 2013 03:26:17 -0000 1.15 @@ -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 -__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 #include @@ -93,11 +93,14 @@ static const char * const pckbport_slot_ 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 * 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 * 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 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_ 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