ReactOS 0.4.16-dev-2528-g7139e57
inbvport.c File Reference
#include <ntoskrnl.h>
#include <cportlib/cportlib.h>
#include <cportlib/uartinfo.h>
Include dependency graph for inbvport.c:

Go to the source code of this file.

Functions

BOOLEAN NTAPI InbvPortPollOnly (_In_ ULONG PortId)
 
BOOLEAN NTAPI InbvPortGetByte (_In_ ULONG PortId, _Out_ PUCHAR Byte)
 
VOID NTAPI InbvPortPutByte (_In_ ULONG PortId, _In_ UCHAR Byte)
 
VOID NTAPI InbvPortEnableFifo (_In_ ULONG PortId, _In_ BOOLEAN Enable)
 
VOID NTAPI InbvPortTerminate (_In_ ULONG PortId)
 
BOOLEAN NTAPI InbvPortInitialize (_In_ ULONG BaudRate, _In_ ULONG PortNumber, _In_ PUCHAR PortAddress, _Out_ PULONG PortId, _In_ BOOLEAN IsMMIODevice)
 

Variables

CPPORT Port [4]
 

Function Documentation

◆ InbvPortEnableFifo()

VOID NTAPI InbvPortEnableFifo ( _In_ ULONG  PortId,
_In_ BOOLEAN  Enable 
)

Definition at line 60 of file inbvport.c.

63{
64 /* Set FIFO as requested */
66}
VOID NTAPI CpEnableFifo(_In_ PUCHAR Address, _In_ BOOLEAN Enable)
Definition: cport.c:41
CPPORT Port[4]
Definition: inbvport.c:17
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
static WCHAR Address[46]
Definition: ping.c:68

Referenced by HdlspEnableTerminal().

◆ InbvPortGetByte()

BOOLEAN NTAPI InbvPortGetByte ( _In_ ULONG  PortId,
_Out_ PUCHAR  Byte 
)

Definition at line 40 of file inbvport.c.

43{
44 /* Read a byte from the port */
45 return CpGetByte(&Port[PortId], Byte, TRUE, FALSE) == CP_GET_SUCCESS;
46}
USHORT NTAPI CpGetByte(_Inout_ PCPPORT Port, _Out_ PUCHAR Byte, _In_ BOOLEAN Wait, _In_ BOOLEAN Poll)
Definition: cport.c:82
#define CP_GET_SUCCESS
Definition: cportlib.h:17
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char Byte
Definition: zlib.h:37

Referenced by HdlspDispatch().

◆ InbvPortInitialize()

BOOLEAN NTAPI InbvPortInitialize ( _In_ ULONG  BaudRate,
_In_ ULONG  PortNumber,
_In_ PUCHAR  PortAddress,
_Out_ PULONG  PortId,
_In_ BOOLEAN  IsMMIODevice 
)

Definition at line 79 of file inbvport.c.

85{
86 /* Not yet supported */
87 ASSERT(IsMMIODevice == FALSE);
88
89 /* Set the default baud rate */
90 if (BaudRate == 0)
91 BaudRate = DEFAULT_BAUD_RATE;
92
93 /* Check if the port or address is given */
94 if (PortNumber)
95 {
96 /* Pick correct address for port */
97 if (!PortAddress)
98 {
99 if (PortNumber < 1 || PortNumber > MAX_COM_PORTS)
101 PortAddress = UlongToPtr(BaseArray[PortNumber]);
102 }
103 }
104 else
105 {
106 /* Pick correct port for address */
107#if defined(SARCH_PC98)
108 static const ULONG TestPorts[] = {1, 2};
109#else
110 static const ULONG TestPorts[] = {2, 1};
111#endif
112 PortAddress = UlongToPtr(BaseArray[TestPorts[0]]);
113 if (CpDoesPortExist(PortAddress))
114 {
115 PortNumber = TestPorts[0];
116 }
117 else
118 {
119 PortAddress = UlongToPtr(BaseArray[TestPorts[1]]);
120 if (!CpDoesPortExist(PortAddress))
121 return FALSE;
122 PortNumber = TestPorts[1];
123 }
124 }
125
126 /* Initialize the port unless it's already up and return it */
127 if (Port[PortNumber - 1].Address)
128 return FALSE;
129
130 CpInitialize(&Port[PortNumber - 1], PortAddress, BaudRate);
131 *PortId = PortNumber - 1;
132 return TRUE;
133}
NTSTATUS NTAPI CpInitialize(_Inout_ PCPPORT Port, _In_ PUCHAR Address, _In_ ULONG BaudRate)
Definition: cport.c:59
BOOLEAN NTAPI CpDoesPortExist(_In_ PUCHAR Address)
Definition: cport.c:33
#define UlongToPtr(u)
Definition: config.h:106
#define MAX_COM_PORTS
Definition: machpc.c:29
#define ASSERT(a)
Definition: mode.c:44
ULONG PortNumber
Definition: storport.c:18
uint32_t ULONG
Definition: typedefs.h:59
#define DEFAULT_BAUD_RATE
Definition: uartinfo.h:24

Referenced by HdlspEnableTerminal().

◆ InbvPortPollOnly()

BOOLEAN NTAPI InbvPortPollOnly ( _In_ ULONG  PortId)

Definition at line 29 of file inbvport.c.

31{
32 UCHAR Dummy;
33
34 /* Poll a byte from the port */
35 return CpGetByte(&Port[PortId], &Dummy, FALSE, TRUE) == CP_GET_SUCCESS;
36}
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by HdlspDispatch().

◆ InbvPortPutByte()

VOID NTAPI InbvPortPutByte ( _In_ ULONG  PortId,
_In_ UCHAR  Byte 
)

Definition at line 50 of file inbvport.c.

53{
54 /* Send the byte */
55 CpPutByte(&Port[PortId], Byte);
56}
VOID NTAPI CpPutByte(_Inout_ PCPPORT Port, _In_ UCHAR Byte)
Definition: cport.c:93

Referenced by HdlspPutData(), and HdlspSendStringAtBaud().

◆ InbvPortTerminate()

VOID NTAPI InbvPortTerminate ( _In_ ULONG  PortId)

Definition at line 70 of file inbvport.c.

72{
73 /* The port is now available */
74 Port[PortId].Address = NULL;
75}
#define NULL
Definition: types.h:112
PUCHAR Address
Definition: cportlib.h:28

Referenced by HdlspEnableTerminal().

Variable Documentation

◆ Port

CPPORT Port[4]
Initial value:
=
{
{NULL, 0, TRUE},
{NULL, 0, TRUE},
{NULL, 0, TRUE},
{NULL, 0, TRUE}
}

Definition at line 17 of file inbvport.c.

Referenced by InbvPortEnableFifo(), InbvPortGetByte(), InbvPortInitialize(), InbvPortPollOnly(), InbvPortPutByte(), and InbvPortTerminate().