X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=ntoskrnl%2Finbv%2Finbvport.c;h=e95e82567833a1b43ba9ac30bedc4a46f9ac2da3;hp=5f58cff96df187dceee3c2db473ee7f4d92a03bb;hb=HEAD;hpb=f6f204878d5689524a9c9e26e9932328d8e87f73 diff --git a/ntoskrnl/inbv/inbvport.c b/ntoskrnl/inbv/inbvport.c index 5f58cff96df..269c8f962be 100644 --- a/ntoskrnl/inbv/inbvport.c +++ b/ntoskrnl/inbv/inbvport.c @@ -23,22 +23,41 @@ CPPORT Port[4] = /* FUNCTIONS *****************************************************************/ -VOID +BOOLEAN NTAPI -InbvPortEnableFifo(IN ULONG PortId, - IN BOOLEAN Enable) +InbvPortPollOnly(IN ULONG PortId) { - /* Set FIFO as requested */ - CpEnableFifo(Port[PortId].Address, Enable); + UCHAR Dummy; + + /* Poll a byte from the port */ + return CpGetByte(&Port[PortId], &Dummy, FALSE, TRUE) == CP_GET_SUCCESS; +} + +BOOLEAN +NTAPI +InbvPortGetByte(IN ULONG PortId, + OUT PUCHAR Byte) +{ + /* Read a byte from the port */ + return CpGetByte(&Port[PortId], Byte, TRUE, FALSE) == CP_GET_SUCCESS; } VOID NTAPI -InbvPortPutByte(IN ULONG PortId, - IN BOOLEAN Output) +InbvPortPutByte(IN ULONG PortId, + IN UCHAR Byte) { /* Send the byte */ - CpPutByte(&Port[PortId], Output); + CpPutByte(&Port[PortId], Byte); +} + +VOID +NTAPI +InbvPortEnableFifo(IN ULONG PortId, + IN BOOLEAN Enable) +{ + /* Set FIFO as requested */ + CpEnableFifo(Port[PortId].Address, Enable); } VOID @@ -60,6 +79,45 @@ InbvPortInitialize(IN ULONG BaudRate, /* Not yet supported */ ASSERT(IsMMIODevice == FALSE); +#if defined(SARCH_PC98) + /* Set default baud rate */ + if (BaudRate == 0) BaudRate = 9600; + + /* Check if port or address given */ + if (PortNumber) + { + /* Pick correct address for port */ + if (!PortAddress) + { + if (PortNumber == 1) + { + PortAddress = (PUCHAR)0x30; + } + else + { + PortAddress = (PUCHAR)0x238; + PortNumber = 2; + } + } + } + else + { + /* Pick correct port for address */ + PortAddress = (PUCHAR)0x30; + if (CpDoesPortExist(PortAddress)) + { + PortNumber = 1; + } + else + { + PortAddress = (PUCHAR)0x238; + if (!CpDoesPortExist(PortAddress)) + return FALSE; + + PortNumber = 2; + } + } +#else /* Set default baud rate */ if (BaudRate == 0) BaudRate = 19200; @@ -104,6 +162,7 @@ InbvPortInitialize(IN ULONG BaudRate, PortNumber = 1; } } +#endif /* Initialize the port unless it's already up, and then return it */ if (Port[PortNumber - 1].Address) return FALSE;