From cd57963daf600559af8d2d54c414dccc25dc28ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 28 Nov 2012 23:16:01 +0000 Subject: [PATCH] [CPORTLIB/FREELDR] GetByte --> Wait for data (with timeout) and get it if available. PollByte --> Check for data, get it if available, and return immediately. svn path=/trunk/; revision=57780 --- reactos/boot/freeldr/freeldr/comm/rs232.c | 9 ++------- reactos/boot/freeldr/freeldr/windows/headless.c | 4 ++-- reactos/include/reactos/libs/cportlib/cportlib.h | 3 +-- reactos/lib/cportlib/cport.c | 6 +----- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/comm/rs232.c b/reactos/boot/freeldr/freeldr/comm/rs232.c index 6755884a3e5..347ca0986e6 100644 --- a/reactos/boot/freeldr/freeldr/comm/rs232.c +++ b/reactos/boot/freeldr/freeldr/comm/rs232.c @@ -100,7 +100,7 @@ BOOLEAN Rs232PortGetByte(PUCHAR ByteReceived) if (PortInitialized == FALSE) return FALSE; - return (CpGetByte(&Rs232ComPort, ByteReceived, FALSE, FALSE) == CP_GET_SUCCESS); + return (CpGetByte(&Rs232ComPort, ByteReceived, TRUE) == CP_GET_SUCCESS); } /* @@ -109,12 +109,7 @@ BOOLEAN Rs232PortPollByte(PUCHAR ByteReceived) if (PortInitialized == FALSE) return FALSE; - while ((READ_PORT_UCHAR (SER_LSR(Rs232PortBase)) & SR_LSR_DR) == 0) - ; - - *ByteReceived = READ_PORT_UCHAR (SER_RBR(Rs232PortBase)); - - return TRUE; + return (CpGetByte(&Rs232ComPort, ByteReceived, FALSE) == CP_GET_SUCCESS); } */ diff --git a/reactos/boot/freeldr/freeldr/windows/headless.c b/reactos/boot/freeldr/freeldr/windows/headless.c index bcc0f6434b0..aa701ea2ab5 100644 --- a/reactos/boot/freeldr/freeldr/windows/headless.c +++ b/reactos/boot/freeldr/freeldr/windows/headless.c @@ -143,7 +143,7 @@ BOOLEAN WinLdrPortGetByte(IN ULONG PortId, OUT PUCHAR Data) { - return CpGetByte(&Port[PortId], Data, TRUE, FALSE) == CP_GET_SUCCESS; + return CpGetByte(&Port[PortId], Data, TRUE) == CP_GET_SUCCESS; } BOOLEAN @@ -151,7 +151,7 @@ WinLdrPortPollOnly(IN ULONG PortId) { UCHAR Dummy; - return CpGetByte(&Port[PortId], &Dummy, FALSE, TRUE) == CP_GET_SUCCESS; + return CpGetByte(&Port[PortId], &Dummy, FALSE) == CP_GET_SUCCESS; } VOID diff --git a/reactos/include/reactos/libs/cportlib/cportlib.h b/reactos/include/reactos/libs/cportlib/cportlib.h index b7681f7d337..d145f8261f3 100644 --- a/reactos/include/reactos/libs/cportlib/cportlib.h +++ b/reactos/include/reactos/libs/cportlib/cportlib.h @@ -69,8 +69,7 @@ NTAPI CpGetByte( IN PCPPORT Port, OUT PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll + IN BOOLEAN Wait ); VOID diff --git a/reactos/lib/cportlib/cport.c b/reactos/lib/cportlib/cport.c index 7279b69893b..8e493dd268a 100644 --- a/reactos/lib/cportlib/cport.c +++ b/reactos/lib/cportlib/cport.c @@ -255,8 +255,7 @@ USHORT NTAPI CpGetByte(IN PCPPORT Port, OUT PUCHAR Byte, - IN BOOLEAN Wait, - IN BOOLEAN Poll) + IN BOOLEAN Wait) { UCHAR Lsr; ULONG LimitCount = Wait ? TIMEOUT_COUNT : 1; @@ -278,9 +277,6 @@ CpGetByte(IN PCPPORT Port, return CP_GET_ERROR; } - /* If only polling was requested by caller, return now */ - if (Poll) return CP_GET_SUCCESS; - /* Otherwise read the byte and return it */ *Byte = READ_PORT_UCHAR(Port->Address + RECEIVE_BUFFER_REGISTER);