ReactOS 0.4.15-dev-5664-g3bf4ef6
serial.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Serial driver
4 * FILE: drivers/dd/serial/serial.h
5 * PURPOSE: Serial driver header
6 *
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8 */
9
10#ifndef _SERIAL_PCH_
11#define _SERIAL_PCH_
12
13#include <ntddk.h>
14#include <ntddser.h>
15
16/* See winbase.h */
17#define PST_RS232 1
18#define COMMPROP_INITIALIZED 0xE73CF52E
19
20typedef enum
21{
28
29typedef enum
30{
32 Uart8250, /* initial version */
33 Uart16450, /* + 38.4 Kbps */
34 Uart16550, /* + 115 Kbps */
35 Uart16550A,/* + FIFO 16 bytes */
36 Uart16650, /* + FIFO 32 bytes, 230 Kbps, power management, auto-flow */
37 Uart16750 /* + FIFO 64 bytes, 460 Kbps */
39
40typedef struct _CIRCULAR_BUFFER
41{
47
49{
54
56
64
69
79
81
82 /* Current values */
83 UCHAR MCR; /* Base+4, Modem Control Register */
84 UCHAR MSR; /* Base+6, Modem Status Register */
86
87typedef struct _WORKITEM_DATA
88{
91
99
100#define SERIAL_TAG 'lreS'
101
102#define INFINITE MAXULONG
103
104/* Baud master clock */
105#define BAUD_CLOCK 1843200
106#define CLOCKS_PER_BIT 16
107
108/* UART registers and bits */
109#define SER_RBR(x) ((PUCHAR)(x)+0) /* Receive Register */
110#define SER_THR(x) ((PUCHAR)(x)+0) /* Transmit Register */
111#define SER_DLL(x) ((PUCHAR)(x)+0) /* Baud Rate Divisor LSB */
112#define SER_IER(x) ((PUCHAR)(x)+1) /* Interrupt Enable Register */
113#define SR_IER_DATA_RECEIVED 0x01
114#define SR_IER_THR_EMPTY 0x02
115#define SR_IER_LSR_CHANGE 0x04
116#define SR_IER_MSR_CHANGE 0x08
117#define SR_IER_SLEEP_MODE 0x10 /* Uart >= 16750 */
118#define SR_IER_LOW_POWER 0x20 /* Uart >= 16750 */
119#define SER_DLM(x) ((PUCHAR)(x)+1) /* Baud Rate Divisor MSB */
120#define SER_IIR(x) ((PUCHAR)(x)+2) /* Interrupt Identification Register */
121#define SR_IIR_SELF 0x00
122#define SR_IIR_ID_MASK 0x07
123#define SR_IIR_MSR_CHANGE SR_IIR_SELF
124#define SR_IIR_THR_EMPTY (SR_IIR_SELF | 2)
125#define SR_IIR_DATA_RECEIVED (SR_IIR_SELF | 4)
126#define SR_IIR_ERROR (SR_IIR_SELF | 6)
127#define SER_FCR(x) ((PUCHAR)(x)+2) /* FIFO Control Register (Uart >= 16550A) */
128#define SR_FCR_ENABLE_FIFO 0x01
129#define SR_FCR_CLEAR_RCVR (0x02 | SR_FCR_ENABLE_FIFO)
130#define SR_FCR_CLEAR_XMIT (0x04 | SR_FCR_ENABLE_FIFO)
131#define SR_FCR_1_BYTE (0x00 | SR_FCR_ENABLE_FIFO)
132#define SR_FCR_4_BYTES (0x40 | SR_FCR_ENABLE_FIFO)
133#define SR_FCR_8_BYTES (0x80 | SR_FCR_ENABLE_FIFO)
134#define SR_FCR_14_BYTES (0xC0 | SR_FCR_ENABLE_FIFO)
135#define SER_LCR(x) ((PUCHAR)(x)+3) /* Line Control Register */
136#define SR_LCR_CS5 0x00
137#define SR_LCR_CS6 0x01
138#define SR_LCR_CS7 0x02
139#define SR_LCR_CS8 0x03
140#define SR_LCR_ST1 0x00
141#define SR_LCR_ST2 0x04
142#define SR_LCR_PNO 0x00
143#define SR_LCR_POD 0x08
144#define SR_LCR_PEV 0x18
145#define SR_LCR_PMK 0x28
146#define SR_LCR_PSP 0x38
147#define SR_LCR_BRK 0x40
148#define SR_LCR_DLAB 0x80
149#define SER_MCR(x) ((PUCHAR)(x)+4) /* Modem Control Register */
150#define SR_MCR_DTR SERIAL_DTR_STATE
151#define SR_MCR_RTS SERIAL_RTS_STATE
152#define SER_LSR(x) ((PUCHAR)(x)+5) /* Line Status Register */
153#define SR_LSR_DATA_RECEIVED 0x01
154#define SR_LSR_OVERRUN_ERROR 0x02
155#define SR_LSR_PARITY_ERROR 0x04
156#define SR_LSR_FRAMING_ERROR 0x08
157#define SR_LSR_BREAK_INT 0x10
158#define SR_LSR_THR_EMPTY 0x20
159#define SR_LSR_TSR_EMPTY 0x40
160#define SR_LSR_ERROR_IN_FIFO 0x80 /* Uart >= 16550A */
161#define SER_MSR(x) ((PUCHAR)(x)+6) /* Modem Status Register */
162#define SR_MSR_CTS_CHANGED 0x01
163#define SR_MSR_DSR_CHANGED 0x02
164#define SR_MSR_RI_CHANGED 0x04
165#define SR_MSR_DCD_CHANGED 0x08
166#define SR_MSR_CTS SERIAL_CTS_STATE /* Clear To Send */
167#define SR_MSR_DSR SERIAL_DSR_STATE /* Data Set Ready */
168#define SI_MSR_RI SERIAL_RI_STATE /* Ring Indicator */
169#define SR_MSR_DCD SERIAL_DCD_STATE /* Data Carrier Detect */
170#define SER_SCR(x) ((PUCHAR)(x)+7) /* Scratch Pad Register, Uart >= Uart16450 */
171
172/************************************ circularbuffer.c */
173
174/* FIXME: transform these functions into #define? */
179
183
187
188ULONG
191
195 IN UCHAR Entry);
196
201
205 IN ULONG NewBufferSize);
206
207/************************************ cleanup.c */
208
210
211/************************************ close.c */
212
214
215/************************************ create.c */
216
218
219/************************************ devctrl.c */
220
222
225 IN PSERIAL_DEVICE_EXTENSION DeviceExtension,
226 IN ULONG NewBaudRate);
227
230 IN PSERIAL_DEVICE_EXTENSION DeviceExtension,
231 IN PSERIAL_LINE_CONTROL NewSettings);
232
233/************************************ info.c */
234
236
237/************************************ legacy.c */
238
241 IN PUCHAR ComPortBase);
242
243/************************************ misc.c */
244
246
249 IN PKDPC Dpc,
250 IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION
251 IN PVOID Unused1,
252 IN PVOID Unused2);
253
256 IN PKDPC Dpc,
257 IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION
258 IN PVOID Unused1,
259 IN PVOID Unused2);
260
263 IN PKDPC Dpc,
264 IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION
265 IN PVOID pIrp, // real type PIRP
266 IN PVOID Unused);
267
268KSERVICE_ROUTINE SerialInterruptService;
269
270/************************************ pnp.c */
271
276 IN UART_TYPE UartType,
277 IN PULONG pComPortNumber OPTIONAL,
279
280DRIVER_ADD_DEVICE SerialAddDevice;
281
286 IN PCM_RESOURCE_LIST ResourceListTranslated);
287
289
290/************************************ power.c */
291
293
294/************************************ rw.c */
295
298
299#endif /* _SERIAL_PCH_ */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
DRIVER_DISPATCH SerialDeviceControl
Definition: serial.h:221
NTSTATUS NTAPI SerialPnpStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST ResourceList, IN PCM_RESOURCE_LIST ResourceListTranslated)
Definition: pnp.c:136
VOID NTAPI SerialReceiveByte(IN PKDPC Dpc, IN PVOID pDeviceExtension, IN PVOID Unused1, IN PVOID Unused2)
Definition: misc.c:30
NTSTATUS PushCircularBufferEntry(IN PCIRCULAR_BUFFER pBuffer, IN UCHAR Entry)
UART_TYPE
Definition: serial.h:30
@ Uart16550
Definition: serial.h:34
@ Uart16550A
Definition: serial.h:35
@ UartUnknown
Definition: serial.h:31
@ Uart16450
Definition: serial.h:33
@ Uart16650
Definition: serial.h:36
@ Uart8250
Definition: serial.h:32
@ Uart16750
Definition: serial.h:37
struct _SERIAL_DEVICE_EXTENSION SERIAL_DEVICE_EXTENSION
VOID NTAPI SerialSendByte(IN PKDPC Dpc, IN PVOID pDeviceExtension, IN PVOID Unused1, IN PVOID Unused2)
Definition: misc.c:67
DRIVER_DISPATCH SerialCleanup
Definition: serial.h:209
BOOLEAN IsCircularBufferEmpty(IN PCIRCULAR_BUFFER pBuffer)
NTSTATUS NTAPI SerialAddDeviceInternal(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo, IN UART_TYPE UartType, IN PULONG pComPortNumber OPTIONAL, OUT PDEVICE_OBJECT *pFdo OPTIONAL)
Definition: pnp.c:18
DRIVER_DISPATCH SerialClose
Definition: serial.h:213
DRIVER_DISPATCH SerialPnp
Definition: serial.h:288
NTSTATUS InitializeCircularBuffer(IN PCIRCULAR_BUFFER pBuffer, IN ULONG BufferSize)
struct _SERIAL_DEVICE_EXTENSION * PSERIAL_DEVICE_EXTENSION
DRIVER_DISPATCH SerialCreate
Definition: serial.h:217
VOID NTAPI SerialCompleteIrp(IN PKDPC Dpc, IN PVOID pDeviceExtension, IN PVOID pIrp, IN PVOID Unused)
Definition: misc.c:105
DRIVER_ADD_DEVICE SerialAddDevice
Definition: serial.h:280
DRIVER_DISPATCH SerialPower
Definition: serial.h:292
struct _WORKITEM_DATA * PWORKITEM_DATA
SERIAL_DEVICE_STATE
Definition: serial.h:21
@ dsSurpriseRemoved
Definition: serial.h:26
@ dsStopped
Definition: serial.h:22
@ dsPaused
Definition: serial.h:24
@ dsStarted
Definition: serial.h:23
@ dsRemoved
Definition: serial.h:25
UART_TYPE SerialDetectUartType(IN PUCHAR ComPortBase)
Definition: legacy.c:16
NTSTATUS PopCircularBufferEntry(IN PCIRCULAR_BUFFER pBuffer, OUT PUCHAR Entry)
DRIVER_DISPATCH ForwardIrpAndForget
Definition: serial.h:245
DRIVER_DISPATCH SerialRead
Definition: serial.h:296
NTSTATUS NTAPI SerialSetBaudRate(IN PSERIAL_DEVICE_EXTENSION DeviceExtension, IN ULONG NewBaudRate)
Definition: devctrl.c:50
struct _CIRCULAR_BUFFER * PCIRCULAR_BUFFER
NTSTATUS FreeCircularBuffer(IN PCIRCULAR_BUFFER pBuffer)
NTSTATUS IncreaseCircularBufferSize(IN PCIRCULAR_BUFFER pBuffer, IN ULONG NewBufferSize)
struct _WORKITEM_DATA WORKITEM_DATA
DRIVER_DISPATCH SerialWrite
Definition: serial.h:297
NTSTATUS NTAPI SerialSetLineControl(IN PSERIAL_DEVICE_EXTENSION DeviceExtension, IN PSERIAL_LINE_CONTROL NewSettings)
Definition: devctrl.c:88
ULONG GetNumberOfElementsInCircularBuffer(IN PCIRCULAR_BUFFER pBuffer)
struct _CIRCULAR_BUFFER CIRCULAR_BUFFER
DRIVER_DISPATCH SerialQueryInformation
Definition: serial.h:235
KSERVICE_ROUTINE SerialInterruptService
Definition: serial.h:268
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
FxDevice * pFdo
FxIrp * pIrp
#define Unused(x)
Definition: atlwin.h:28
unsigned int * PULONG
Definition: retypes.h:1
unsigned char * PUCHAR
Definition: retypes.h:3
unsigned int ULONG
Definition: retypes.h:1
DRIVER_DISPATCH(nfs41_FsdDispatch)
PVOID pBuffer
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
base of all file and directory entries
Definition: entries.h:83
ULONG Length
Definition: serial.h:43
PUCHAR Buffer
Definition: serial.h:42
ULONG WritePosition
Definition: serial.h:45
ULONG ReadPosition
Definition: serial.h:44
Definition: ketypes.h:687
SERIAL_LINE_CONTROL SerialLineControl
Definition: serial.h:65
PKINTERRUPT Interrupt
Definition: serial.h:60
PDEVICE_OBJECT LowerDevice
Definition: serial.h:51
KSPIN_LOCK OutputBufferLock
Definition: serial.h:78
UART_TYPE UartType
Definition: serial.h:66
KSPIN_LOCK InputBufferLock
Definition: serial.h:76
IO_REMOVE_LOCK RemoveLock
Definition: serial.h:53
KEVENT InputBufferNotEmpty
Definition: serial.h:74
ULONG BreakInterruptErrorCount
Definition: serial.h:70
UNICODE_STRING SerialInterfaceName
Definition: serial.h:80
CIRCULAR_BUFFER InputBuffer
Definition: serial.h:75
SERIAL_DEVICE_STATE PnpState
Definition: serial.h:52
CIRCULAR_BUFFER OutputBuffer
Definition: serial.h:77
SERIALPERF_STATS SerialPerfStats
Definition: serial.h:71
SERIAL_TIMEOUTS SerialTimeOuts
Definition: serial.h:72
PDEVICE_OBJECT Pdo
Definition: serial.h:50
LARGE_INTEGER TotalTimeoutTime
Definition: serial.h:95
LARGE_INTEGER IntervalTimeout
Definition: serial.h:94
BOOLEAN ReadAtLeastOneByte
Definition: serial.h:97
BOOLEAN UseTotalTimeout
Definition: serial.h:93
PIRP Irp
Definition: serial.h:89
BOOLEAN UseIntervalTimeout
Definition: serial.h:92
PIO_WORKITEM IoWorkItem
Definition: serial.h:90
BOOLEAN DontWait
Definition: serial.h:96
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:112
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
unsigned char UCHAR
Definition: xmlstorage.h:181