From a9313682fc4a75cba8e9cceffd500e070418f6db Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sat, 11 May 1996 23:16:23 +0000 Subject: Give up waiting for a successful keyboard reset after some unreasonable time. I've got a PCI mainboard that simply doesn't grok it, so continuing with a warning (and a keyboard that's working nevertheless :) seems to be better than spin-looping forever. --- sys/dev/syscons/syscons.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sys/dev/syscons') diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index d95ec3db41cf..b968da5b099f 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.146 1996/05/01 03:58:21 bde Exp $ + * $Id: syscons.c,v 1.147 1996/05/02 21:47:50 ache Exp $ */ #include "sc.h" @@ -204,7 +204,7 @@ mask2attr(struct term_stat *term) static int scprobe(struct isa_device *dev) { - int i, retries = 5; + int i, j, retries = 5; unsigned char val; /* Enable interrupts and keyboard controller */ @@ -236,15 +236,17 @@ gotres: if (!retries) printf("scprobe: keyboard won't accept RESET command\n"); else { + i = 10; /* At most 10 retries. */ gotack: DELAY(10); - while ((inb(KB_STAT) & KB_BUF_FULL) == 0) DELAY(10); + j = 1000; /* Wait at most 10 ms (supposedly). */ + while ((inb(KB_STAT) & KB_BUF_FULL) == 0 && --j > 0) DELAY(10); DELAY(10); val = inb(KB_DATA); - if (val == KB_ACK) + if (val == KB_ACK && --i > 0) goto gotack; if (val != KB_RESET_DONE) - printf("scprobe: keyboard RESET failed %02x\n", val); + printf("scprobe: keyboard RESET failed (result = 0x%02x)\n", val); } #ifdef XT_KEYBOARD kbd_wait(); -- cgit v1.3