3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 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_HARDWARE_LOOPBACK_ENABLE | \
130 EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE | \
131 EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE | \
132 EFI_SERIAL_INPUT_BUFFER_EMPTY)
134 #define ConvertBaud2Nt(x) (DWORD) x
135 #define ConvertData2Nt(x) (BYTE) x
137 #define ConvertParity2Nt(x) \
139 x == DefaultParity ? NOPARITY : \
140 x == NoParity ? NOPARITY : \
141 x == EvenParity ? EVENPARITY : \
142 x == OddParity ? ODDPARITY : \
143 x == MarkParity ? MARKPARITY : \
144 x == SpaceParity ? SPACEPARITY : 0 \
147 #define ConvertStop2Nt(x) \
149 x == DefaultParity ? ONESTOPBIT : \
150 x == OneFiveStopBits ? ONE5STOPBITS : \
151 x == TwoStopBits ? TWOSTOPBITS : 0 \
154 #define ConvertTime2Nt(x) ((x) / 1000)
157 // 115400 baud with rounding errors
159 #define SERIAL_PORT_MAX_BAUD_RATE 115400
161 #define SERIAL_PORT_MIN_BAUD_RATE 50
162 #define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16
164 #define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS
165 #define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds
168 // Function Prototypes
172 InitializeWinNtSerialIo (
173 IN EFI_HANDLE ImageHandle
,
174 IN EFI_SYSTEM_TABLE
*SystemTable
180 TODO: Add function description
184 ImageHandle - TODO: add argument description
185 SystemTable - TODO: add argument description
189 TODO: add return values
196 WinNtSerialIoDriverBindingSupported (
197 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
198 IN EFI_HANDLE Handle
,
199 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
205 TODO: Add function description
209 This - TODO: add argument description
210 Handle - TODO: add argument description
211 RemainingDevicePath - TODO: add argument description
215 TODO: add return values
222 WinNtSerialIoDriverBindingStart (
223 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
224 IN EFI_HANDLE Handle
,
225 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
231 TODO: Add function description
235 This - TODO: add argument description
236 Handle - TODO: add argument description
237 RemainingDevicePath - TODO: add argument description
241 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
277 IN EFI_SERIAL_IO_PROTOCOL
*This
283 TODO: Add function description
287 This - TODO: add argument description
291 TODO: add return values
298 WinNtSerialIoSetAttributes (
299 IN EFI_SERIAL_IO_PROTOCOL
*This
,
301 IN UINT32 ReceiveFifoDepth
,
303 IN EFI_PARITY_TYPE Parity
,
305 IN EFI_STOP_BITS_TYPE StopBits
311 TODO: Add function description
315 This - TODO: add argument description
316 BaudRate - TODO: add argument description
317 ReceiveFifoDepth - TODO: add argument description
318 Timeout - TODO: add argument description
319 Parity - TODO: add argument description
320 DataBits - TODO: add argument description
321 StopBits - TODO: add argument description
325 TODO: add return values
332 WinNtSerialIoSetControl (
333 IN EFI_SERIAL_IO_PROTOCOL
*This
,
340 TODO: Add function description
344 This - TODO: add argument description
345 Control - TODO: add argument description
349 TODO: add return values
356 WinNtSerialIoGetControl (
357 IN EFI_SERIAL_IO_PROTOCOL
*This
,
364 TODO: Add function description
368 This - TODO: add argument description
369 Control - TODO: add argument description
373 TODO: add return values
381 IN EFI_SERIAL_IO_PROTOCOL
*This
,
382 IN OUT UINTN
*BufferSize
,
389 TODO: Add function description
393 This - TODO: add argument description
394 BufferSize - TODO: add argument description
395 Buffer - TODO: add argument description
399 TODO: add return values
407 IN EFI_SERIAL_IO_PROTOCOL
*This
,
408 IN OUT UINTN
*BufferSize
,
415 TODO: Add function description
419 This - TODO: add argument description
420 BufferSize - TODO: add argument description
421 Buffer - TODO: add argument description
425 TODO: add return values
432 IN SERIAL_DEV_FIFO
*Fifo
438 TODO: Add function description
442 Fifo - TODO: add argument description
446 TODO: add return values
453 IN SERIAL_DEV_FIFO
*Fifo
459 TODO: Add function description
463 Fifo - TODO: add argument description
467 TODO: add return values
474 IN SERIAL_DEV_FIFO
*Fifo
,
481 TODO: Add function description
485 Fifo - TODO: add argument description
486 Data - TODO: add argument description
490 TODO: add return values
496 IsaSerialFifoRemove (
497 IN SERIAL_DEV_FIFO
*Fifo
,
504 TODO: Add function description
508 Fifo - TODO: add argument description
509 Data - TODO: add argument description
513 TODO: add return values
519 IsaSerialReceiveTransmit (
520 WIN_NT_SERIAL_IO_PRIVATE_DATA
*Private
526 TODO: Add function description
530 Private - TODO: add argument description
534 TODO: add return values