| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pms.c,v 1.40 2022/10/28 23:40:37 riastradh Exp $ */ | | 1 | /* $NetBSD: pms.c,v 1.41 2023/09/05 05:55:12 mrg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2004 Kentaro Kurahone. | | 4 | * Copyright (c) 2004 Kentaro Kurahone. |
5 | * Copyright (c) 2004 Ales Krenek. | | 5 | * Copyright (c) 2004 Ales Krenek. |
6 | * Copyright (c) 1994 Charles M. Hannum. | | 6 | * Copyright (c) 1994 Charles M. Hannum. |
7 | * Copyright (c) 1992, 1993 Erik Forsberg. | | 7 | * Copyright (c) 1992, 1993 Erik Forsberg. |
8 | * All rights reserved. | | 8 | * All rights reserved. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -16,27 +16,27 @@ | | | @@ -16,27 +16,27 @@ |
16 | * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED | | 16 | * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
19 | * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | | 19 | * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | #include <sys/cdefs.h> | | 28 | #include <sys/cdefs.h> |
29 | __KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.40 2022/10/28 23:40:37 riastradh Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.41 2023/09/05 05:55:12 mrg Exp $"); |
30 | | | 30 | |
31 | #include "opt_pms.h" | | 31 | #include "opt_pms.h" |
32 | | | 32 | |
33 | #include <sys/param.h> | | 33 | #include <sys/param.h> |
34 | #include <sys/systm.h> | | 34 | #include <sys/systm.h> |
35 | #include <sys/device.h> | | 35 | #include <sys/device.h> |
36 | #include <sys/ioctl.h> | | 36 | #include <sys/ioctl.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
38 | #include <sys/kthread.h> | | 38 | #include <sys/kthread.h> |
39 | | | 39 | |
40 | #include <sys/bus.h> | | 40 | #include <sys/bus.h> |
41 | | | 41 | |
42 | #include <dev/pckbport/pckbportvar.h> | | 42 | #include <dev/pckbport/pckbportvar.h> |
| @@ -551,26 +551,28 @@ pmsinput(void *vsc, int data) | | | @@ -551,26 +551,28 @@ pmsinput(void *vsc, int data) |
551 | } | | 551 | } |
552 | } | | 552 | } |
553 | sc->last = sc->current; | | 553 | sc->last = sc->current; |
554 | | | 554 | |
555 | if (sc->inputstate == 0) { | | 555 | if (sc->inputstate == 0) { |
556 | /* | | 556 | /* |
557 | * Some devices (seen on trackballs anytime, and on | | 557 | * Some devices (seen on trackballs anytime, and on |
558 | * some mice shortly after reset) output garbage bytes | | 558 | * some mice shortly after reset) output garbage bytes |
559 | * between packets. Just ignore them. | | 559 | * between packets. Just ignore them. |
560 | */ | | 560 | */ |
561 | if ((data & 0xc0) != 0) | | 561 | if ((data & 0xc0) != 0) |
562 | return; /* not in sync yet, discard input */ | | 562 | return; /* not in sync yet, discard input */ |
563 | } | | 563 | } |
| | | 564 | if (sc->inputstate >= sizeof(sc->packet)) |
| | | 565 | panic("inputstate should never be %d", sc->inputstate); |
564 | | | 566 | |
565 | sc->packet[sc->inputstate++] = data & 0xff; | | 567 | sc->packet[sc->inputstate++] = data & 0xff; |
566 | switch (sc->inputstate) { | | 568 | switch (sc->inputstate) { |
567 | case 0: | | 569 | case 0: |
568 | /* no useful processing can be done yet */ | | 570 | /* no useful processing can be done yet */ |
569 | break; | | 571 | break; |
570 | | | 572 | |
571 | case 1: | | 573 | case 1: |
572 | /* | | 574 | /* |
573 | * Why should we test for bit 0x8 and insist on it here? | | 575 | * Why should we test for bit 0x8 and insist on it here? |
574 | * The old (psm.c and psm_intelli.c) drivers didn't do | | 576 | * The old (psm.c and psm_intelli.c) drivers didn't do |
575 | * it, and there are devices where it does harm (that's | | 577 | * it, and there are devices where it does harm (that's |
576 | * why it is not used if using PMS_STANDARD protocol). | | 578 | * why it is not used if using PMS_STANDARD protocol). |