ReactOS  0.4.13-dev-464-g6b95727
inbvport.c File Reference
#include <ntoskrnl.h>
#include <debug.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 56 of file inbvport.c.

58 {
59  /* Set FIFO as requested */
60  CpEnableFifo(Port[PortId].Address, Enable);
61 }
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
static WCHAR Address[46]
Definition: ping.c:68
VOID NTAPI CpEnableFifo(IN PUCHAR Address, IN BOOLEAN Enable)
Definition: cport.c:54
CPPORT Port[4]
Definition: inbvport.c:16

Referenced by HdlspEnableTerminal().

◆ InbvPortGetByte()

BOOLEAN NTAPI InbvPortGetByte ( IN ULONG  PortId,
OUT PUCHAR  Byte 
)

Definition at line 38 of file inbvport.c.

40 {
41  /* Read a byte from the port */
42  return CpGetByte(&Port[PortId], Byte, TRUE, FALSE) == CP_GET_SUCCESS;
43 }
#define TRUE
Definition: types.h:120
unsigned char Byte
Definition: zconf.h:391
USHORT NTAPI CpGetByte(IN PCPPORT Port, OUT PUCHAR Byte, IN BOOLEAN Wait, IN BOOLEAN Poll)
Definition: cport.c:256
CPPORT Port[4]
Definition: inbvport.c:16
#define CP_GET_SUCCESS
Definition: cportlib.h:18

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 73 of file inbvport.c.

78 {
79  /* Not yet supported */
80  ASSERT(IsMMIODevice == FALSE);
81 
82  /* Set default baud rate */
83  if (BaudRate == 0) BaudRate = 19200;
84 
85  /* Check if port or address given */
86  if (PortNumber)
87  {
88  /* Pick correct address for port */
89  if (!PortAddress)
90  {
91  switch (PortNumber)
92  {
93  case 1:
94  PortAddress = (PUCHAR)0x3F8;
95  break;
96 
97  case 2:
98  PortAddress = (PUCHAR)0x2F8;
99  break;
100 
101  case 3:
102  PortAddress = (PUCHAR)0x3E8;
103  break;
104 
105  default:
106  PortNumber = 4;
107  PortAddress = (PUCHAR)0x2E8;
108  }
109  }
110  }
111  else
112  {
113  /* Pick correct port for address */
114  PortAddress = (PUCHAR)0x2F8;
115  if (CpDoesPortExist(PortAddress))
116  {
117  PortNumber = 2;
118  }
119  else
120  {
121  PortAddress = (PUCHAR)0x3F8;
122  if (!CpDoesPortExist(PortAddress)) return FALSE;
123  PortNumber = 1;
124  }
125  }
126 
127  /* Initialize the port unless it's already up, and then return it */
128  if (Port[PortNumber - 1].Address) return FALSE;
129 
130  CpInitialize(&Port[PortNumber - 1], PortAddress, BaudRate);
131  *PortId = PortNumber - 1;
132 
133  return TRUE;
134 }
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN NTAPI CpDoesPortExist(IN PUCHAR Address)
Definition: cport.c:227
ULONG PortNumber
Definition: storport.c:18
static WCHAR Address[46]
Definition: ping.c:68
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CPPORT Port[4]
Definition: inbvport.c:16
NTSTATUS NTAPI CpInitialize(IN PCPPORT Port, IN PUCHAR Address, IN ULONG BaudRate)
Definition: cport.c:88

Referenced by HdlspEnableTerminal().

◆ InbvPortPollOnly()

BOOLEAN NTAPI InbvPortPollOnly ( IN ULONG  PortId)

Definition at line 28 of file inbvport.c.

29 {
30  UCHAR Dummy;
31 
32  /* Poll a byte from the port */
33  return CpGetByte(&Port[PortId], &Dummy, FALSE, TRUE) == CP_GET_SUCCESS;
34 }
#define TRUE
Definition: types.h:120
USHORT NTAPI CpGetByte(IN PCPPORT Port, OUT PUCHAR Byte, IN BOOLEAN Wait, IN BOOLEAN Poll)
Definition: cport.c:256
unsigned char UCHAR
Definition: xmlstorage.h:181
CPPORT Port[4]
Definition: inbvport.c:16
#define CP_GET_SUCCESS
Definition: cportlib.h:18

Referenced by HdlspDispatch().

◆ InbvPortPutByte()

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

Definition at line 47 of file inbvport.c.

49 {
50  /* Send the byte */
51  CpPutByte(&Port[PortId], Byte);
52 }
unsigned char Byte
Definition: zconf.h:391
VOID NTAPI CpPutByte(IN PCPPORT Port, IN UCHAR Byte)
Definition: cport.c:306
CPPORT Port[4]
Definition: inbvport.c:16

Referenced by HdlspPutData(), and HdlspSendStringAtBaud().

◆ InbvPortTerminate()

VOID NTAPI InbvPortTerminate ( IN ULONG  PortId)

Definition at line 65 of file inbvport.c.

66 {
67  /* The port is now available */
68  Port[PortId].Address = NULL;
69 }
smooth NULL
Definition: ftsmooth.c:416
CPPORT Port[4]
Definition: inbvport.c:16
PUCHAR Address
Definition: cportlib.h:29

Referenced by HdlspEnableTerminal().

Variable Documentation

◆ Port

CPPORT Port[4]
Initial value:
=
{
{NULL, 0, TRUE},
{NULL, 0, TRUE},
{NULL, 0, TRUE},
{NULL, 0, TRUE}
}
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416

Definition at line 16 of file inbvport.c.

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