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.
21 #ifndef _WIN_NT_SERIAL_IO_
22 #define _WIN_NT_SERIAL_IO_
25 // The package level header files this module uses
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
58 UINT8 Data
[SERIAL_MAX_BUFFER_SIZE
];
61 #define WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 's', 'i')
66 // Protocol data for the new handle we are going to add
69 EFI_SERIAL_IO_PROTOCOL SerialIo
;
70 EFI_SERIAL_IO_MODE SerialIoMode
;
71 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
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;
91 BOOLEAN SoftwareLoopbackEnable
;
92 BOOLEAN HardwareFlowControl
;
93 BOOLEAN HardwareLoopbackEnable
;
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
;
109 // Macros to convert EFI serial types to NT serial types.
115 #define SERIAL_TIMEOUT_DEFAULT (1000 * 1000)
116 #define SERIAL_BAUD_DEFAULT 115200
117 #define SERIAL_FIFO_DEFAULT 14
118 #define SERIAL_DATABITS_DEFAULT 8
119 #define SERIAL_PARITY_DEFAULT DefaultParity
120 #define SERIAL_STOPBITS_DEFAULT DefaultStopBits
122 #define SERIAL_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \
123 EFI_SERIAL_DATA_SET_READY | \
124 EFI_SERIAL_RING_INDICATE | \
125 EFI_SERIAL_CARRIER_DETECT | \
126 EFI_SERIAL_REQUEST_TO_SEND | \
127 EFI_SERIAL_DATA_TERMINAL_READY | \
128 EFI_SERIAL_INPUT_BUFFER_EMPTY)
130 #define ConvertBaud2Nt(x) (DWORD) x
131 #define ConvertData2Nt(x) (BYTE) x
133 #define ConvertParity2Nt(x) \
135 x == DefaultParity ? NOPARITY : \
136 x == NoParity ? NOPARITY : \
137 x == EvenParity ? EVENPARITY : \
138 x == OddParity ? ODDPARITY : \
139 x == MarkParity ? MARKPARITY : \
140 x == SpaceParity ? SPACEPARITY : 0 \
143 #define ConvertStop2Nt(x) \
145 x == DefaultParity ? ONESTOPBIT : \
146 x == OneFiveStopBits ? ONE5STOPBITS : \
147 x == TwoStopBits ? TWOSTOPBITS : 0 \
150 #define ConvertTime2Nt(x) ((x) / 1000)
153 // 115400 baud with rounding errors
155 #define SERIAL_PORT_MAX_BAUD_RATE 115400
158 // Function Prototypes
162 InitializeWinNtSerialIo (
163 IN EFI_HANDLE ImageHandle
,
164 IN EFI_SYSTEM_TABLE
*SystemTable
170 TODO: Add function description
174 ImageHandle - TODO: add argument description
175 SystemTable - TODO: add argument description
179 TODO: add return values
187 WinNtSerialIoDriverBindingSupported (
188 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
189 IN EFI_HANDLE Handle
,
190 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
196 TODO: Add function description
200 This - TODO: add argument description
201 Handle - TODO: add argument description
202 RemainingDevicePath - TODO: add argument description
206 TODO: add return values
214 WinNtSerialIoDriverBindingStart (
215 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
216 IN EFI_HANDLE Handle
,
217 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
223 TODO: Add function description
227 This - TODO: add argument description
228 Handle - TODO: add argument description
229 RemainingDevicePath - TODO: add argument description
233 TODO: add return values
241 WinNtSerialIoDriverBindingStop (
242 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
243 IN EFI_HANDLE Handle
,
244 IN UINTN NumberOfChildren
,
245 IN EFI_HANDLE
*ChildHandleBuffer
251 TODO: Add function description
255 This - TODO: add argument description
256 Handle - TODO: add argument description
257 NumberOfChildren - TODO: add argument description
258 ChildHandleBuffer - TODO: add argument description
262 TODO: add return values
271 IN EFI_SERIAL_IO_PROTOCOL
*This
277 TODO: Add function description
281 This - TODO: add argument description
285 TODO: add return values
293 WinNtSerialIoSetAttributes (
294 IN EFI_SERIAL_IO_PROTOCOL
*This
,
296 IN UINT32 ReceiveFifoDepth
,
298 IN EFI_PARITY_TYPE Parity
,
300 IN EFI_STOP_BITS_TYPE StopBits
306 TODO: Add function description
310 This - TODO: add argument description
311 BaudRate - TODO: add argument description
312 ReceiveFifoDepth - TODO: add argument description
313 Timeout - TODO: add argument description
314 Parity - TODO: add argument description
315 DataBits - TODO: add argument description
316 StopBits - TODO: add argument description
320 TODO: add return values
328 WinNtSerialIoSetControl (
329 IN EFI_SERIAL_IO_PROTOCOL
*This
,
336 TODO: Add function description
340 This - TODO: add argument description
341 Control - TODO: add argument description
345 TODO: add return values
353 WinNtSerialIoGetControl (
354 IN EFI_SERIAL_IO_PROTOCOL
*This
,
361 TODO: Add function description
365 This - TODO: add argument description
366 Control - TODO: add argument description
370 TODO: add return values
379 IN EFI_SERIAL_IO_PROTOCOL
*This
,
380 IN OUT UINTN
*BufferSize
,
387 TODO: Add function description
391 This - TODO: add argument description
392 BufferSize - TODO: add argument description
393 Buffer - TODO: add argument description
397 TODO: add return values
406 IN EFI_SERIAL_IO_PROTOCOL
*This
,
407 IN OUT UINTN
*BufferSize
,
414 TODO: Add function description
418 This - TODO: add argument description
419 BufferSize - TODO: add argument description
420 Buffer - TODO: add argument description
424 TODO: add return values
431 IN SERIAL_DEV_FIFO
*Fifo
437 TODO: Add function description
441 Fifo - TODO: add argument description
445 TODO: add return values
452 IN SERIAL_DEV_FIFO
*Fifo
458 TODO: Add function description
462 Fifo - TODO: add argument description
466 TODO: add return values
473 IN SERIAL_DEV_FIFO
*Fifo
,
480 TODO: Add function description
484 Fifo - TODO: add argument description
485 Data - TODO: add argument description
489 TODO: add return values
495 IsaSerialFifoRemove (
496 IN SERIAL_DEV_FIFO
*Fifo
,
503 TODO: Add function description
507 Fifo - TODO: add argument description
508 Data - TODO: add argument description
512 TODO: add return values
518 IsaSerialReceiveTransmit (
519 WIN_NT_SERIAL_IO_PRIVATE_DATA
*Private
525 TODO: Add function description
529 Private - TODO: add argument description
533 TODO: add return values