Fix for ADB hang while probing, based on information from Colin Wood:

Rather than waiting indefinitely for a mouse or extended keyboard to
respond -- which may not even exist -- time out after 2 seconds and
continue.  This corrects a very common problem with the MRG-based ADB
driver that has bitten many people running 1.3.
This commit is contained in:
scottr 1998-02-20 18:14:10 +00:00
parent 0e4a7ffbe0
commit 0ca6188f89

View File

@ -1,4 +1,4 @@
/* $NetBSD: adbsys.c,v 1.34 1997/11/26 06:28:51 scottr Exp $ */
/* $NetBSD: adbsys.c,v 1.35 1998/02/20 18:14:10 scottr Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -204,7 +204,7 @@ extdms_init(totaladbs)
int totaladbs;
{
ADBDataBlock adbdata;
int adbindex, adbaddr;
int adbindex, adbaddr, count;
short cmd;
u_char buffer[9];
@ -256,8 +256,18 @@ extdms_init(totaladbs)
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
/* busy wait until done */;
/* Wait until done, but no more than 2 secs */
count = 40000;
while (!extdms_done && count-- > 0)
delay(50);
if (!extdms_done) {
#ifdef MRG_DEBUG
printf("adb: extdms_init timed out\n");
#endif
return;
}
/* Attempt to initialize Extended Mouse Protocol */
buffer[2] = '\004'; /* make handler ID 4 */
@ -328,7 +338,7 @@ adb_init()
ADBSetInfoBlock adbinfo;
int totaladbs;
int adbindex, adbaddr;
int error, cmd, devtype=0;
int error, cmd, count, devtype = 0;
u_char buffer[9];
extern int adb_initted;
@ -399,9 +409,14 @@ adb_init()
cmd=(((adbaddr<<4) &0xf0) | 0x0d ); /* talk R1 */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done);
/* busy wait until done */
if (buffer[1]==0x9a && buffer[2]==0x20 )
/* Wait until done, but no more than 2 secs */
count = 40000;
while (!extdms_done && count-- > 0)
delay(50);
if (extdms_done &&
buffer[1] == 0x9a && buffer[2] == 0x20)
printf("Mouseman (non-EMP) pseudo keyboard");
else
printf("extended keyboard");
@ -456,8 +471,17 @@ adb_init()
/* talk register 3 */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, (adbaddr << 4) | 0xf);
while (!extdms_done)
/* busy-wait until done */;
/* Wait until done, but no more than 2 secs */
count = 40000;
while (!extdms_done && count-- > 0)
delay(50);
if (!extdms_done) {
printf("ghost mouse?");
break;
}
devtype=buffer[2];
switch (devtype) {
case ADBMS_100DPI: