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 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
;
107 extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtSerialIoComponentName2
;
110 // Macros to convert EFI serial types to NT serial types.
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) \
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) \
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
169 InitializeWinNtSerialIo (
170 IN EFI_HANDLE ImageHandle
,
171 IN EFI_SYSTEM_TABLE
*SystemTable
177 TODO: Add function description
181 ImageHandle - TODO: add argument description
182 SystemTable - TODO: add argument description
186 TODO: add return values
193 WinNtSerialIoDriverBindingSupported (
194 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
195 IN EFI_HANDLE Handle
,
196 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
202 TODO: Add function description
206 This - TODO: add argument description
207 Handle - TODO: add argument description
208 RemainingDevicePath - TODO: add argument description
212 TODO: add return values
219 WinNtSerialIoDriverBindingStart (
220 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
221 IN EFI_HANDLE Handle
,
222 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
228 TODO: Add function description
232 This - TODO: add argument description
233 Handle - TODO: add argument description
234 RemainingDevicePath - TODO: add argument description
238 TODO: add return values
245 WinNtSerialIoDriverBindingStop (
246 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
247 IN EFI_HANDLE Handle
,
248 IN UINTN NumberOfChildren
,
249 IN EFI_HANDLE
*ChildHandleBuffer
255 TODO: Add function description
259 This - TODO: add argument description
260 Handle - TODO: add argument description
261 NumberOfChildren - TODO: add argument description
262 ChildHandleBuffer - TODO: add argument description
266 TODO: add return values
274 IN EFI_SERIAL_IO_PROTOCOL
*This
280 TODO: Add function description
284 This - TODO: add argument description
288 TODO: add return values
295 WinNtSerialIoSetAttributes (
296 IN EFI_SERIAL_IO_PROTOCOL
*This
,
298 IN UINT32 ReceiveFifoDepth
,
300 IN EFI_PARITY_TYPE Parity
,
302 IN EFI_STOP_BITS_TYPE StopBits
308 TODO: Add function description
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
322 TODO: add return values
329 WinNtSerialIoSetControl (
330 IN EFI_SERIAL_IO_PROTOCOL
*This
,
337 TODO: Add function description
341 This - TODO: add argument description
342 Control - TODO: add argument description
346 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
378 IN EFI_SERIAL_IO_PROTOCOL
*This
,
379 IN OUT UINTN
*BufferSize
,
386 TODO: Add function description
390 This - TODO: add argument description
391 BufferSize - TODO: add argument description
392 Buffer - TODO: add argument description
396 TODO: add return values
404 IN EFI_SERIAL_IO_PROTOCOL
*This
,
405 IN OUT UINTN
*BufferSize
,
412 TODO: Add function description
416 This - TODO: add argument description
417 BufferSize - TODO: add argument description
418 Buffer - TODO: add argument description
422 TODO: add return values
429 IN SERIAL_DEV_FIFO
*Fifo
435 TODO: Add function description
439 Fifo - TODO: add argument description
443 TODO: add return values
450 IN SERIAL_DEV_FIFO
*Fifo
456 TODO: Add function description
460 Fifo - TODO: add argument description
464 TODO: add return values
471 IN SERIAL_DEV_FIFO
*Fifo
,
478 TODO: Add function description
482 Fifo - TODO: add argument description
483 Data - TODO: add argument description
487 TODO: add return values
493 IsaSerialFifoRemove (
494 IN SERIAL_DEV_FIFO
*Fifo
,
501 TODO: Add function description
505 Fifo - TODO: add argument description
506 Data - TODO: add argument description
510 TODO: add return values
516 IsaSerialReceiveTransmit (
517 WIN_NT_SERIAL_IO_PRIVATE_DATA
*Private
523 TODO: Add function description
527 Private - TODO: add argument description
531 TODO: add return values