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
;
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
194 WinNtSerialIoDriverBindingSupported (
195 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
196 IN EFI_HANDLE Handle
,
197 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
203 TODO: Add function description
207 This - TODO: add argument description
208 Handle - TODO: add argument description
209 RemainingDevicePath - TODO: add argument description
213 TODO: add return values
221 WinNtSerialIoDriverBindingStart (
222 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
223 IN EFI_HANDLE Handle
,
224 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
230 TODO: Add function description
234 This - TODO: add argument description
235 Handle - TODO: add argument description
236 RemainingDevicePath - TODO: add argument description
240 TODO: add return values
248 WinNtSerialIoDriverBindingStop (
249 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
250 IN EFI_HANDLE Handle
,
251 IN UINTN NumberOfChildren
,
252 IN EFI_HANDLE
*ChildHandleBuffer
258 TODO: Add function description
262 This - TODO: add argument description
263 Handle - TODO: add argument description
264 NumberOfChildren - TODO: add argument description
265 ChildHandleBuffer - TODO: add argument description
269 TODO: add return values
278 IN EFI_SERIAL_IO_PROTOCOL
*This
284 TODO: Add function description
288 This - TODO: add argument description
292 TODO: add return values
300 WinNtSerialIoSetAttributes (
301 IN EFI_SERIAL_IO_PROTOCOL
*This
,
303 IN UINT32 ReceiveFifoDepth
,
305 IN EFI_PARITY_TYPE Parity
,
307 IN EFI_STOP_BITS_TYPE StopBits
313 TODO: Add function description
317 This - TODO: add argument description
318 BaudRate - TODO: add argument description
319 ReceiveFifoDepth - TODO: add argument description
320 Timeout - TODO: add argument description
321 Parity - TODO: add argument description
322 DataBits - TODO: add argument description
323 StopBits - TODO: add argument description
327 TODO: add return values
335 WinNtSerialIoSetControl (
336 IN EFI_SERIAL_IO_PROTOCOL
*This
,
343 TODO: Add function description
347 This - TODO: add argument description
348 Control - TODO: add argument description
352 TODO: add return values
360 WinNtSerialIoGetControl (
361 IN EFI_SERIAL_IO_PROTOCOL
*This
,
368 TODO: Add function description
372 This - TODO: add argument description
373 Control - TODO: add argument description
377 TODO: add return values
386 IN EFI_SERIAL_IO_PROTOCOL
*This
,
387 IN OUT UINTN
*BufferSize
,
394 TODO: Add function description
398 This - TODO: add argument description
399 BufferSize - TODO: add argument description
400 Buffer - TODO: add argument description
404 TODO: add return values
413 IN EFI_SERIAL_IO_PROTOCOL
*This
,
414 IN OUT UINTN
*BufferSize
,
421 TODO: Add function description
425 This - TODO: add argument description
426 BufferSize - TODO: add argument description
427 Buffer - TODO: add argument description
431 TODO: add return values
438 IN SERIAL_DEV_FIFO
*Fifo
444 TODO: Add function description
448 Fifo - TODO: add argument description
452 TODO: add return values
459 IN SERIAL_DEV_FIFO
*Fifo
465 TODO: Add function description
469 Fifo - TODO: add argument description
473 TODO: add return values
480 IN SERIAL_DEV_FIFO
*Fifo
,
487 TODO: Add function description
491 Fifo - TODO: add argument description
492 Data - TODO: add argument description
496 TODO: add return values
502 IsaSerialFifoRemove (
503 IN SERIAL_DEV_FIFO
*Fifo
,
510 TODO: Add function description
514 Fifo - TODO: add argument description
515 Data - TODO: add argument description
519 TODO: add return values
525 IsaSerialReceiveTransmit (
526 WIN_NT_SERIAL_IO_PRIVATE_DATA
*Private
532 TODO: Add function description
536 Private - TODO: add argument description
540 TODO: add return values