From deec9eeabdb560545f94198686b2f93ec6d20839 Mon Sep 17 00:00:00 2001 From: hpa Date: Tue, 30 Aug 2005 00:05:26 +0000 Subject: [PATCH] Correct the enabling of the 16550A FIFO --- com32/libutil/get_key.c | 13 +++++++++---- parseconfig.inc | 12 ++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/com32/libutil/get_key.c b/com32/libutil/get_key.c index 228253e..bd06008 100644 --- a/com32/libutil/get_key.c +++ b/com32/libutil/get_key.c @@ -1,7 +1,7 @@ #ident "$Id$" /* ----------------------------------------------------------------------- * * - * Copyright 2004 H. Peter Anvin - All Rights Reserved + * Copyright 2004-2005 H. Peter Anvin - All Rights Reserved * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -116,6 +116,8 @@ static const struct keycode keycodes[] = { }; #define NCODES ((int)(sizeof keycodes/sizeof(struct keycode))) +#define KEY_TIMEOUT ((CLK_TCK+9)/10) + int get_key(FILE *f, clock_t timeout) { unsigned char buffer[MAXLEN]; @@ -135,9 +137,12 @@ int get_key(FILE *f, clock_t timeout) rv = read(fileno(f), &ch, 1); if ( rv == 0 || (rv == -1 && errno == EAGAIN) ) { clock_t lateness = times(NULL)-start; - if ( nc && lateness > 1+CLK_TCK/20 ) - return buffer[0]; /* timeout in sequence */ - else if ( !nc && timeout && lateness > timeout ) + if ( nc && lateness > 1+KEY_TIMEOUT ) { + if ( nc == 1 ) + return buffer[0]; /* timeout in sequence */ + else if ( timeout && lateness > timeout ) + return KEY_NONE; + } else if ( !nc && timeout && lateness > timeout ) return KEY_NONE; /* timeout before sequence */ do_idle(); diff --git a/parseconfig.inc b/parseconfig.inc index 09712b9..450af29 100644 --- a/parseconfig.inc +++ b/parseconfig.inc @@ -214,29 +214,29 @@ pc_serial: call getint call slow_out mov al,03h ; Disable DLAB - add dx,byte 2 ; DX -> LCR + inc dx ; DX -> LCR + inc dx call slow_out in al,dx ; Read back LCR (detect missing hw) cmp al,03h ; If nothing here we'll read 00 or FF jne .serial_port_bad ; Assume serial port busted - sub dx,byte 2 ; DX -> IER + dec dx + dec dx ; DX -> IER xor al,al ; IRQ disable call slow_out - inc dx - inc dx ; DX -> FCR + inc dx ; DX -> FCR/IIR mov al,01h call slow_out ; Enable FIFOs if present - dec dx ; DX -> IIR in al,dx - inc dx ; DX -> FCR cmp al,0C0h ; FIFOs enabled and usable? jae .fifo_ok xor ax,ax ; Disable FIFO if unusable call slow_out .fifo_ok: + inc dx inc dx ; DX -> MCR in al,dx or al,[FlowOutput] ; Assert bits -- 2.7.4