1. remove duplicated NetLibDispatchDpc() calling in Pool function.
[edk2.git] / Nt32Pkg / WinNtSerialIoDxe / WinNtSerialIo.h
blob348cca82b459c7467e74e2e0b6eee0ad73fa4dc3
1 /**@file
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 Module Name:
14 WinNtSerialIo.h
16 Abstract:
19 **/
21 #ifndef _WIN_NT_SERIAL_IO_
22 #define _WIN_NT_SERIAL_IO_
25 // The package level header files this module uses
27 #include <Uefi.h>
28 #include <WinNtDxe.h>
30 // The protocols, PPI and GUID defintions for this module
32 #include <Protocol/WinNtIo.h>
33 #include <Protocol/ComponentName.h>
34 #include <Protocol/SerialIo.h>
35 #include <Protocol/DriverBinding.h>
36 #include <Protocol/DevicePath.h>
38 // The Library classes this module consumes
40 #include <Library/DebugLib.h>
41 #include <Library/BaseLib.h>
42 #include <Library/UefiDriverEntryPoint.h>
43 #include <Library/UefiLib.h>
44 #include <Library/BaseMemoryLib.h>
45 #include <Library/UefiBootServicesTableLib.h>
46 #include <Library/DevicePathLib.h>
47 #include <Library/MemoryAllocationLib.h>
48 #include <Library/PcdLib.h>
51 #define SERIAL_MAX_BUFFER_SIZE 256
52 #define TIMEOUT_STALL_INTERVAL 10
54 typedef struct {
55 UINT32 First;
56 UINT32 Last;
57 UINT32 Surplus;
58 UINT8 Data[SERIAL_MAX_BUFFER_SIZE];
59 } SERIAL_DEV_FIFO;
61 #define WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('N', 'T', 's', 'i')
62 typedef struct {
63 UINT64 Signature;
66 // Protocol data for the new handle we are going to add
68 EFI_HANDLE Handle;
69 EFI_SERIAL_IO_PROTOCOL SerialIo;
70 EFI_SERIAL_IO_MODE SerialIoMode;
71 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
74 // Private Data
76 EFI_HANDLE ControllerHandle;
77 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
78 UART_DEVICE_PATH UartDevicePath;
79 EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
81 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
84 // Private NT type Data;
86 HANDLE NtHandle;
87 DCB NtDCB;
88 DWORD NtError;
89 COMSTAT NtComStatus;
91 BOOLEAN SoftwareLoopbackEnable;
92 BOOLEAN HardwareFlowControl;
93 BOOLEAN HardwareLoopbackEnable;
95 SERIAL_DEV_FIFO Fifo;
97 } WIN_NT_SERIAL_IO_PRIVATE_DATA;
99 #define WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS(a) \
100 CR(a, WIN_NT_SERIAL_IO_PRIVATE_DATA, SerialIo, WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE)
103 // Global Protocol Variables
105 extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSerialIoDriverBinding;
106 extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName;
107 extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtSerialIoComponentName2;
110 // Macros to convert EFI serial types to NT serial types.
114 // one second
116 #define SERIAL_TIMEOUT_DEFAULT (1000 * 1000)
117 #define SERIAL_BAUD_DEFAULT 115200
118 #define SERIAL_FIFO_DEFAULT 14
119 #define SERIAL_DATABITS_DEFAULT 8
120 #define SERIAL_PARITY_DEFAULT DefaultParity
121 #define SERIAL_STOPBITS_DEFAULT DefaultStopBits
123 #define SERIAL_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \
124 EFI_SERIAL_DATA_SET_READY | \
125 EFI_SERIAL_RING_INDICATE | \
126 EFI_SERIAL_CARRIER_DETECT | \
127 EFI_SERIAL_REQUEST_TO_SEND | \
128 EFI_SERIAL_DATA_TERMINAL_READY | \
129 EFI_SERIAL_INPUT_BUFFER_EMPTY)
131 #define ConvertBaud2Nt(x) (DWORD) x
132 #define ConvertData2Nt(x) (BYTE) x
134 #define ConvertParity2Nt(x) \
135 (BYTE) ( \
136 x == DefaultParity ? NOPARITY : \
137 x == NoParity ? NOPARITY : \
138 x == EvenParity ? EVENPARITY : \
139 x == OddParity ? ODDPARITY : \
140 x == MarkParity ? MARKPARITY : \
141 x == SpaceParity ? SPACEPARITY : 0 \
144 #define ConvertStop2Nt(x) \
145 (BYTE) ( \
146 x == DefaultParity ? ONESTOPBIT : \
147 x == OneFiveStopBits ? ONE5STOPBITS : \
148 x == TwoStopBits ? TWOSTOPBITS : 0 \
151 #define ConvertTime2Nt(x) ((x) / 1000)
154 // 115400 baud with rounding errors
156 #define SERIAL_PORT_MAX_BAUD_RATE 115400
158 #define SERIAL_PORT_MIN_BAUD_RATE 50
159 #define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16
161 #define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS
162 #define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds
165 // Function Prototypes
167 EFI_STATUS
168 EFIAPI
169 InitializeWinNtSerialIo (
170 IN EFI_HANDLE ImageHandle,
171 IN EFI_SYSTEM_TABLE *SystemTable
173 /*++
175 Routine Description:
177 TODO: Add function description
179 Arguments:
181 ImageHandle - TODO: add argument description
182 SystemTable - TODO: add argument description
184 Returns:
186 TODO: add return values
188 --*/
191 EFI_STATUS
192 EFIAPI
193 WinNtSerialIoDriverBindingSupported (
194 IN EFI_DRIVER_BINDING_PROTOCOL *This,
195 IN EFI_HANDLE Handle,
196 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
198 /*++
200 Routine Description:
202 TODO: Add function description
204 Arguments:
206 This - TODO: add argument description
207 Handle - TODO: add argument description
208 RemainingDevicePath - TODO: add argument description
210 Returns:
212 TODO: add return values
214 --*/
217 EFI_STATUS
218 EFIAPI
219 WinNtSerialIoDriverBindingStart (
220 IN EFI_DRIVER_BINDING_PROTOCOL *This,
221 IN EFI_HANDLE Handle,
222 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
224 /*++
226 Routine Description:
228 TODO: Add function description
230 Arguments:
232 This - TODO: add argument description
233 Handle - TODO: add argument description
234 RemainingDevicePath - TODO: add argument description
236 Returns:
238 TODO: add return values
240 --*/
243 EFI_STATUS
244 EFIAPI
245 WinNtSerialIoDriverBindingStop (
246 IN EFI_DRIVER_BINDING_PROTOCOL *This,
247 IN EFI_HANDLE Handle,
248 IN UINTN NumberOfChildren,
249 IN EFI_HANDLE *ChildHandleBuffer
251 /*++
253 Routine Description:
255 TODO: Add function description
257 Arguments:
259 This - TODO: add argument description
260 Handle - TODO: add argument description
261 NumberOfChildren - TODO: add argument description
262 ChildHandleBuffer - TODO: add argument description
264 Returns:
266 TODO: add return values
268 --*/
271 EFI_STATUS
272 EFIAPI
273 WinNtSerialIoReset (
274 IN EFI_SERIAL_IO_PROTOCOL *This
276 /*++
278 Routine Description:
280 TODO: Add function description
282 Arguments:
284 This - TODO: add argument description
286 Returns:
288 TODO: add return values
290 --*/
293 EFI_STATUS
294 EFIAPI
295 WinNtSerialIoSetAttributes (
296 IN EFI_SERIAL_IO_PROTOCOL *This,
297 IN UINT64 BaudRate,
298 IN UINT32 ReceiveFifoDepth,
299 IN UINT32 Timeout,
300 IN EFI_PARITY_TYPE Parity,
301 IN UINT8 DataBits,
302 IN EFI_STOP_BITS_TYPE StopBits
304 /*++
306 Routine Description:
308 TODO: Add function description
310 Arguments:
312 This - TODO: add argument description
313 BaudRate - TODO: add argument description
314 ReceiveFifoDepth - TODO: add argument description
315 Timeout - TODO: add argument description
316 Parity - TODO: add argument description
317 DataBits - TODO: add argument description
318 StopBits - TODO: add argument description
320 Returns:
322 TODO: add return values
324 --*/
327 EFI_STATUS
328 EFIAPI
329 WinNtSerialIoSetControl (
330 IN EFI_SERIAL_IO_PROTOCOL *This,
331 IN UINT32 Control
333 /*++
335 Routine Description:
337 TODO: Add function description
339 Arguments:
341 This - TODO: add argument description
342 Control - TODO: add argument description
344 Returns:
346 TODO: add return values
348 --*/
351 EFI_STATUS
352 EFIAPI
353 WinNtSerialIoGetControl (
354 IN EFI_SERIAL_IO_PROTOCOL *This,
355 OUT UINT32 *Control
357 /*++
359 Routine Description:
361 TODO: Add function description
363 Arguments:
365 This - TODO: add argument description
366 Control - TODO: add argument description
368 Returns:
370 TODO: add return values
372 --*/
375 EFI_STATUS
376 EFIAPI
377 WinNtSerialIoWrite (
378 IN EFI_SERIAL_IO_PROTOCOL *This,
379 IN OUT UINTN *BufferSize,
380 IN VOID *Buffer
382 /*++
384 Routine Description:
386 TODO: Add function description
388 Arguments:
390 This - TODO: add argument description
391 BufferSize - TODO: add argument description
392 Buffer - TODO: add argument description
394 Returns:
396 TODO: add return values
398 --*/
401 EFI_STATUS
402 EFIAPI
403 WinNtSerialIoRead (
404 IN EFI_SERIAL_IO_PROTOCOL *This,
405 IN OUT UINTN *BufferSize,
406 OUT VOID *Buffer
408 /*++
410 Routine Description:
412 TODO: Add function description
414 Arguments:
416 This - TODO: add argument description
417 BufferSize - TODO: add argument description
418 Buffer - TODO: add argument description
420 Returns:
422 TODO: add return values
424 --*/
427 BOOLEAN
428 IsaSerialFifoFull (
429 IN SERIAL_DEV_FIFO *Fifo
431 /*++
433 Routine Description:
435 TODO: Add function description
437 Arguments:
439 Fifo - TODO: add argument description
441 Returns:
443 TODO: add return values
445 --*/
448 BOOLEAN
449 IsaSerialFifoEmpty (
450 IN SERIAL_DEV_FIFO *Fifo
452 /*++
454 Routine Description:
456 TODO: Add function description
458 Arguments:
460 Fifo - TODO: add argument description
462 Returns:
464 TODO: add return values
466 --*/
469 EFI_STATUS
470 IsaSerialFifoAdd (
471 IN SERIAL_DEV_FIFO *Fifo,
472 IN UINT8 Data
474 /*++
476 Routine Description:
478 TODO: Add function description
480 Arguments:
482 Fifo - TODO: add argument description
483 Data - TODO: add argument description
485 Returns:
487 TODO: add return values
489 --*/
492 EFI_STATUS
493 IsaSerialFifoRemove (
494 IN SERIAL_DEV_FIFO *Fifo,
495 OUT UINT8 *Data
497 /*++
499 Routine Description:
501 TODO: Add function description
503 Arguments:
505 Fifo - TODO: add argument description
506 Data - TODO: add argument description
508 Returns:
510 TODO: add return values
512 --*/
515 EFI_STATUS
516 IsaSerialReceiveTransmit (
517 WIN_NT_SERIAL_IO_PRIVATE_DATA *Private
519 /*++
521 Routine Description:
523 TODO: Add function description
525 Arguments:
527 Private - TODO: add argument description
529 Returns:
531 TODO: add return values
533 --*/
536 #endif