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
157 #define SERIAL_PORT_MIN_BAUD_RATE 50
158 #define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16
160 #define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS
161 #define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds
164 // Function Prototypes
168 InitializeWinNtSerialIo (
169 IN EFI_HANDLE ImageHandle
,
170 IN EFI_SYSTEM_TABLE
*SystemTable
176 TODO: Add function description
180 ImageHandle - TODO: add argument description
181 SystemTable - TODO: add argument description
185 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
220 WinNtSerialIoDriverBindingStart (
221 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
222 IN EFI_HANDLE Handle
,
223 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
229 TODO: Add function description
233 This - TODO: add argument description
234 Handle - TODO: add argument description
235 RemainingDevicePath - TODO: add argument description
239 TODO: add return values
247 WinNtSerialIoDriverBindingStop (
248 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
249 IN EFI_HANDLE Handle
,
250 IN UINTN NumberOfChildren
,
251 IN EFI_HANDLE
*ChildHandleBuffer
257 TODO: Add function description
261 This - TODO: add argument description
262 Handle - TODO: add argument description
263 NumberOfChildren - TODO: add argument description
264 ChildHandleBuffer - TODO: add argument description
268 TODO: add return values
277 IN EFI_SERIAL_IO_PROTOCOL
*This
283 TODO: Add function description
287 This - TODO: add argument description
291 TODO: add return values
299 WinNtSerialIoSetAttributes (
300 IN EFI_SERIAL_IO_PROTOCOL
*This
,
302 IN UINT32 ReceiveFifoDepth
,
304 IN EFI_PARITY_TYPE Parity
,
306 IN EFI_STOP_BITS_TYPE StopBits
312 TODO: Add function description
316 This - TODO: add argument description
317 BaudRate - TODO: add argument description
318 ReceiveFifoDepth - TODO: add argument description
319 Timeout - TODO: add argument description
320 Parity - TODO: add argument description
321 DataBits - TODO: add argument description
322 StopBits - TODO: add argument description
326 TODO: add return values
334 WinNtSerialIoSetControl (
335 IN EFI_SERIAL_IO_PROTOCOL
*This
,
342 TODO: Add function description
346 This - TODO: add argument description
347 Control - TODO: add argument description
351 TODO: add return values
359 WinNtSerialIoGetControl (
360 IN EFI_SERIAL_IO_PROTOCOL
*This
,
367 TODO: Add function description
371 This - TODO: add argument description
372 Control - TODO: add argument description
376 TODO: add return values
385 IN EFI_SERIAL_IO_PROTOCOL
*This
,
386 IN OUT UINTN
*BufferSize
,
393 TODO: Add function description
397 This - TODO: add argument description
398 BufferSize - TODO: add argument description
399 Buffer - TODO: add argument description
403 TODO: add return values
412 IN EFI_SERIAL_IO_PROTOCOL
*This
,
413 IN OUT UINTN
*BufferSize
,
420 TODO: Add function description
424 This - TODO: add argument description
425 BufferSize - TODO: add argument description
426 Buffer - TODO: add argument description
430 TODO: add return values
437 IN SERIAL_DEV_FIFO
*Fifo
443 TODO: Add function description
447 Fifo - TODO: add argument description
451 TODO: add return values
458 IN SERIAL_DEV_FIFO
*Fifo
464 TODO: Add function description
468 Fifo - TODO: add argument description
472 TODO: add return values
479 IN SERIAL_DEV_FIFO
*Fifo
,
486 TODO: Add function description
490 Fifo - TODO: add argument description
491 Data - TODO: add argument description
495 TODO: add return values
501 IsaSerialFifoRemove (
502 IN SERIAL_DEV_FIFO
*Fifo
,
509 TODO: Add function description
513 Fifo - TODO: add argument description
514 Data - TODO: add argument description
518 TODO: add return values
524 IsaSerialReceiveTransmit (
525 WIN_NT_SERIAL_IO_PRIVATE_DATA
*Private
531 TODO: Add function description
535 Private - TODO: add argument description
539 TODO: add return values