ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

serial.h
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         Serial driver
00004  * FILE:            drivers/dd/serial/serial.h
00005  * PURPOSE:         Serial driver header
00006  *
00007  * PROGRAMMERS:     Hervé Poussineau (hpoussin@reactos.org)
00008  */
00009 
00010 #include <ntddk.h>
00011 #include <ndk/haltypes.h>
00012 #include <ntddser.h>
00013 #include <stdio.h>
00014 #include <debug.h>
00015 
00016 /* See winbase.h */
00017 #define PST_RS232 1
00018 #define COMMPROP_INITIALIZED 0xE73CF52E
00019 
00020 typedef enum
00021 {
00022   dsStopped,
00023   dsStarted,
00024   dsPaused,
00025   dsRemoved,
00026   dsSurpriseRemoved
00027 } SERIAL_DEVICE_STATE;
00028 
00029 typedef enum
00030 {
00031     UartUnknown,
00032     Uart8250,  /* initial version */
00033     Uart16450, /* + 38.4 Kbps */
00034     Uart16550, /* + 115 Kbps */
00035     Uart16550A,/* + FIFO 16 bytes */
00036     Uart16650, /* + FIFO 32 bytes, 230 Kbps, power management, auto-flow */
00037     Uart16750  /* + FIFO 64 bytes, 460 Kbps */
00038 } UART_TYPE;
00039 
00040 typedef struct _CIRCULAR_BUFFER
00041 {
00042     PUCHAR Buffer;
00043     ULONG Length;
00044     ULONG ReadPosition;
00045     ULONG WritePosition;
00046 } CIRCULAR_BUFFER, *PCIRCULAR_BUFFER;
00047 
00048 typedef struct _SERIAL_DEVICE_EXTENSION
00049 {
00050     PDEVICE_OBJECT Pdo;
00051     PDEVICE_OBJECT LowerDevice;
00052     SERIAL_DEVICE_STATE PnpState;
00053     IO_REMOVE_LOCK RemoveLock;
00054 
00055     ULONG SerialPortNumber;
00056 
00057     ULONG ComPort;
00058     ULONG BaudRate;
00059     ULONG BaseAddress;
00060     PKINTERRUPT Interrupt;
00061     KDPC ReceivedByteDpc;
00062     KDPC SendByteDpc;
00063     KDPC CompleteIrpDpc;
00064 
00065     SERIAL_LINE_CONTROL SerialLineControl;
00066     UART_TYPE UartType;
00067     ULONG WaitMask;
00068     PIRP WaitOnMaskIrp;
00069 
00070     ULONG BreakInterruptErrorCount;
00071     SERIALPERF_STATS SerialPerfStats;
00072     SERIAL_TIMEOUTS SerialTimeOuts;
00073     BOOLEAN IsOpened;
00074     KEVENT InputBufferNotEmpty;
00075     CIRCULAR_BUFFER InputBuffer;
00076     KSPIN_LOCK InputBufferLock;
00077     CIRCULAR_BUFFER OutputBuffer;
00078     KSPIN_LOCK OutputBufferLock;
00079 
00080     UNICODE_STRING SerialInterfaceName;
00081 
00082     /* Current values */
00083     UCHAR MCR; /* Base+4, Modem Control Register */
00084     UCHAR MSR; /* Base+6, Modem Status Register */
00085 } SERIAL_DEVICE_EXTENSION, *PSERIAL_DEVICE_EXTENSION;
00086 
00087 typedef struct _WORKITEM_DATA
00088 {
00089     PIRP Irp;
00090     PIO_WORKITEM IoWorkItem;
00091 
00092     BOOLEAN UseIntervalTimeout;
00093     BOOLEAN UseTotalTimeout;
00094     LARGE_INTEGER IntervalTimeout;
00095     LARGE_INTEGER TotalTimeoutTime;
00096     BOOLEAN DontWait;
00097     BOOLEAN ReadAtLeastOneByte;
00098 } WORKITEM_DATA, *PWORKITEM_DATA;
00099 
00100 #define SERIAL_TAG 'lreS'
00101 
00102 #define INFINITE MAXULONG
00103 
00104 /* Baud master clock */
00105 #define BAUD_CLOCK      1843200
00106 #define CLOCKS_PER_BIT  16
00107 
00108 /* UART registers and bits */
00109 #define   SER_RBR(x)   ((x)+0) /* Receive Register */
00110 #define   SER_THR(x)   ((x)+0) /* Transmit Register */
00111 #define   SER_DLL(x)   ((x)+0) /* Baud Rate Divisor LSB */
00112 #define   SER_IER(x)   ((x)+1) /* Interrupt Enable Register */
00113 #define     SR_IER_DATA_RECEIVED  0x01
00114 #define     SR_IER_THR_EMPTY      0x02
00115 #define     SR_IER_LSR_CHANGE     0x04
00116 #define     SR_IER_MSR_CHANGE     0x08
00117 #define     SR_IER_SLEEP_MODE     0x10 /* Uart >= 16750 */
00118 #define     SR_IER_LOW_POWER      0x20 /* Uart >= 16750 */
00119 #define   SER_DLM(x)   ((x)+1) /* Baud Rate Divisor MSB */
00120 #define   SER_IIR(x)   ((x)+2) /* Interrupt Identification Register */
00121 #define     SR_IIR_SELF           0x00
00122 #define     SR_IIR_ID_MASK        0x07
00123 #define     SR_IIR_MSR_CHANGE     SR_IIR_SELF
00124 #define     SR_IIR_THR_EMPTY     (SR_IIR_SELF | 2)
00125 #define     SR_IIR_DATA_RECEIVED (SR_IIR_SELF | 4)
00126 #define     SR_IIR_ERROR         (SR_IIR_SELF | 6)
00127 #define   SER_FCR(x)   ((x)+2) /* FIFO Control Register (Uart >= 16550A) */
00128 #define     SR_FCR_ENABLE_FIFO    0x01
00129 #define     SR_FCR_CLEAR_RCVR    (0x02 | SR_FCR_ENABLE_FIFO)
00130 #define     SR_FCR_CLEAR_XMIT    (0x04 | SR_FCR_ENABLE_FIFO)
00131 #define     SR_FCR_1_BYTE        (0x00 | SR_FCR_ENABLE_FIFO)
00132 #define     SR_FCR_4_BYTES       (0x40 | SR_FCR_ENABLE_FIFO)
00133 #define     SR_FCR_8_BYTES       (0x80 | SR_FCR_ENABLE_FIFO)
00134 #define     SR_FCR_14_BYTES      (0xC0 | SR_FCR_ENABLE_FIFO)
00135 #define   SER_LCR(x)   ((x)+3) /* Line Control Register */
00136 #define     SR_LCR_CS5            0x00
00137 #define     SR_LCR_CS6            0x01
00138 #define     SR_LCR_CS7            0x02
00139 #define     SR_LCR_CS8            0x03
00140 #define     SR_LCR_ST1            0x00
00141 #define     SR_LCR_ST2            0x04
00142 #define     SR_LCR_PNO            0x00
00143 #define     SR_LCR_POD            0x08
00144 #define     SR_LCR_PEV            0x18
00145 #define     SR_LCR_PMK            0x28
00146 #define     SR_LCR_PSP            0x38
00147 #define     SR_LCR_BRK            0x40
00148 #define     SR_LCR_DLAB           0x80
00149 #define   SER_MCR(x)   ((x)+4) /* Modem Control Register */
00150 #define     SR_MCR_DTR            SERIAL_DTR_STATE
00151 #define     SR_MCR_RTS            SERIAL_RTS_STATE
00152 #define   SER_LSR(x)   ((x)+5) /* Line Status Register */
00153 #define     SR_LSR_DATA_RECEIVED  0x01
00154 #define     SR_LSR_OVERRUN_ERROR  0x02
00155 #define     SR_LSR_PARITY_ERROR   0x04
00156 #define     SR_LSR_FRAMING_ERROR  0x08
00157 #define     SR_LSR_BREAK_INT      0x10
00158 #define     SR_LSR_THR_EMPTY      0x20
00159 #define     SR_LSR_TSR_EMPTY      0x40
00160 #define     SR_LSR_ERROR_IN_FIFO  0x80 /* Uart >= 16550A */
00161 #define   SER_MSR(x)   ((x)+6) /* Modem Status Register */
00162 #define     SR_MSR_CTS_CHANGED    0x01
00163 #define     SR_MSR_DSR_CHANGED    0x02
00164 #define     SR_MSR_RI_CHANGED     0x04
00165 #define     SR_MSR_DCD_CHANGED    0x08
00166 #define     SR_MSR_CTS            SERIAL_CTS_STATE /* Clear To Send */
00167 #define     SR_MSR_DSR            SERIAL_DSR_STATE /* Data Set Ready */
00168 #define     SI_MSR_RI             SERIAL_RI_STATE  /* Ring Indicator */
00169 #define     SR_MSR_DCD            SERIAL_DCD_STATE /* Data Carrier Detect */
00170 #define   SER_SCR(x)   ((x)+7) /* Scratch Pad Register, Uart >= Uart16450 */
00171 
00172 /************************************ circularbuffer.c */
00173 
00174 /* FIXME: transform these functions into #define? */
00175 NTSTATUS
00176 InitializeCircularBuffer(
00177     IN PCIRCULAR_BUFFER pBuffer,
00178     IN ULONG BufferSize);
00179 
00180 NTSTATUS
00181 FreeCircularBuffer(
00182     IN PCIRCULAR_BUFFER pBuffer);
00183 
00184 BOOLEAN
00185 IsCircularBufferEmpty(
00186     IN PCIRCULAR_BUFFER pBuffer);
00187 
00188 ULONG
00189 GetNumberOfElementsInCircularBuffer(
00190     IN PCIRCULAR_BUFFER pBuffer);
00191 
00192 NTSTATUS
00193 PushCircularBufferEntry(
00194     IN PCIRCULAR_BUFFER pBuffer,
00195     IN UCHAR Entry);
00196 
00197 NTSTATUS
00198 PopCircularBufferEntry(
00199     IN PCIRCULAR_BUFFER pBuffer,
00200     OUT PUCHAR Entry);
00201 
00202 NTSTATUS
00203 IncreaseCircularBufferSize(
00204     IN PCIRCULAR_BUFFER pBuffer,
00205     IN ULONG NewBufferSize);
00206 
00207 /************************************ cleanup.c */
00208 
00209 DRIVER_DISPATCH SerialCleanup;
00210 
00211 /************************************ close.c */
00212 
00213 DRIVER_DISPATCH SerialClose;
00214 
00215 /************************************ create.c */
00216 
00217 DRIVER_DISPATCH SerialCreate;
00218 
00219 /************************************ devctrl.c */
00220 
00221 DRIVER_DISPATCH SerialDeviceControl;
00222 
00223 NTSTATUS NTAPI
00224 SerialSetBaudRate(
00225     IN PSERIAL_DEVICE_EXTENSION DeviceExtension,
00226     IN ULONG NewBaudRate);
00227 
00228 NTSTATUS NTAPI
00229 SerialSetLineControl(
00230     IN PSERIAL_DEVICE_EXTENSION DeviceExtension,
00231     IN PSERIAL_LINE_CONTROL NewSettings);
00232 
00233 /************************************ info.c */
00234 
00235 DRIVER_DISPATCH SerialQueryInformation;
00236 
00237 /************************************ legacy.c */
00238 
00239 UART_TYPE
00240 SerialDetectUartType(
00241     IN PUCHAR ComPortBase);
00242 
00243 /************************************ misc.c */
00244 
00245 NTSTATUS
00246 ForwardIrpAndWait(
00247     IN PDEVICE_OBJECT DeviceObject,
00248     IN PIRP Irp);
00249 
00250 DRIVER_DISPATCH ForwardIrpAndForget;
00251 
00252 VOID NTAPI
00253 SerialReceiveByte(
00254     IN PKDPC Dpc,
00255     IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION
00256     IN PVOID Unused1,
00257     IN PVOID Unused2);
00258 
00259 VOID NTAPI
00260 SerialSendByte(
00261     IN PKDPC Dpc,
00262     IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION
00263     IN PVOID Unused1,
00264     IN PVOID Unused2);
00265 
00266 VOID NTAPI
00267 SerialCompleteIrp(
00268     IN PKDPC Dpc,
00269     IN PVOID pDeviceExtension, // real type PSERIAL_DEVICE_EXTENSION
00270     IN PVOID pIrp, // real type PIRP
00271     IN PVOID Unused);
00272 
00273 KSERVICE_ROUTINE SerialInterruptService;
00274 
00275 /************************************ pnp.c */
00276 
00277 NTSTATUS NTAPI
00278 SerialAddDeviceInternal(
00279     IN PDRIVER_OBJECT DriverObject,
00280     IN PDEVICE_OBJECT Pdo,
00281     IN UART_TYPE UartType,
00282     IN PULONG pComPortNumber OPTIONAL,
00283     OUT PDEVICE_OBJECT* pFdo OPTIONAL);
00284 
00285 DRIVER_ADD_DEVICE SerialAddDevice;
00286 
00287 NTSTATUS NTAPI
00288 SerialPnpStartDevice(
00289     IN PDEVICE_OBJECT DeviceObject,
00290     IN PCM_RESOURCE_LIST ResourceList,
00291     IN PCM_RESOURCE_LIST ResourceListTranslated);
00292 
00293 DRIVER_DISPATCH SerialPnp;
00294 
00295 /************************************ power.c */
00296 
00297 DRIVER_DISPATCH SerialPower;
00298 
00299 /************************************ rw.c */
00300 
00301 DRIVER_DISPATCH SerialRead;
00302 DRIVER_DISPATCH SerialWrite;

Generated on Fri May 25 2012 04:17:06 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.