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 _UNIXPKG_SERIAL_IO_
22 #define _UNIXPKG_SERIAL_IO_
23 #include <sys/types.h>
31 #define SERIAL_MAX_BUFFER_SIZE 256
32 #define TIMEOUT_STALL_INTERVAL 10
38 UINT8 Data
[SERIAL_MAX_BUFFER_SIZE
];
41 #define UNIX_SERIAL_IO_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('U', 'N', 's', 'i')
46 // Protocol data for the new handle we are going to add
49 EFI_SERIAL_IO_PROTOCOL SerialIo
;
50 EFI_SERIAL_IO_MODE SerialIoMode
;
51 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
56 EFI_HANDLE ControllerHandle
;
57 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
58 UART_DEVICE_PATH UartDevicePath
;
59 EFI_UNIX_THUNK_PROTOCOL
*UnixThunk
;
61 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
64 // Private NT type Data;
67 struct termios UnixTermios
;
69 BOOLEAN SoftwareLoopbackEnable
;
70 BOOLEAN HardwareFlowControl
;
71 BOOLEAN HardwareLoopbackEnable
;
75 } UNIX_SERIAL_IO_PRIVATE_DATA
;
77 #define UNIX_SERIAL_IO_PRIVATE_DATA_FROM_THIS(a) \
78 CR(a, UNIX_SERIAL_IO_PRIVATE_DATA, SerialIo, UNIX_SERIAL_IO_PRIVATE_DATA_SIGNATURE)
81 // Global Protocol Variables
83 extern EFI_DRIVER_BINDING_PROTOCOL gUnixSerialIoDriverBinding
;
84 extern EFI_COMPONENT_NAME_PROTOCOL gUnixSerialIoComponentName
;
87 // Macros to convert EFI serial types to NT serial types.
93 #define SERIAL_TIMEOUT_DEFAULT (1000 * 1000)
94 #define SERIAL_BAUD_DEFAULT 115200
95 #define SERIAL_FIFO_DEFAULT 14
96 #define SERIAL_DATABITS_DEFAULT 8
97 #define SERIAL_PARITY_DEFAULT DefaultParity
98 #define SERIAL_STOPBITS_DEFAULT DefaultStopBits
100 #define SERIAL_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \
101 EFI_SERIAL_DATA_SET_READY | \
102 EFI_SERIAL_RING_INDICATE | \
103 EFI_SERIAL_CARRIER_DETECT | \
104 EFI_SERIAL_REQUEST_TO_SEND | \
105 EFI_SERIAL_DATA_TERMINAL_READY | \
106 EFI_SERIAL_INPUT_BUFFER_EMPTY)
108 #define ConvertBaud2Nt(x) (DWORD) x
109 #define ConvertData2Nt(x) (BYTE) x
111 #define ConvertParity2Nt(x) \
113 x == DefaultParity ? NOPARITY : \
114 x == NoParity ? NOPARITY : \
115 x == EvenParity ? EVENPARITY : \
116 x == OddParity ? ODDPARITY : \
117 x == MarkParity ? MARKPARITY : \
118 x == SpaceParity ? SPACEPARITY : 0 \
121 #define ConvertStop2Nt(x) \
123 x == DefaultParity ? ONESTOPBIT : \
124 x == OneFiveStopBits ? ONE5STOPBITS : \
125 x == TwoStopBits ? TWOSTOPBITS : 0 \
128 #define ConvertTime2Nt(x) ((x) / 1000)
131 // 115400 baud with rounding errors
133 #define SERIAL_PORT_MAX_BAUD_RATE 115400
136 // Function Prototypes
140 InitializeUnixSerialIo (
141 IN EFI_HANDLE ImageHandle
,
142 IN EFI_SYSTEM_TABLE
*SystemTable
148 TODO: Add function description
152 ImageHandle - TODO: add argument description
153 SystemTable - TODO: add argument description
157 TODO: add return values
164 UnixSerialIoDriverBindingSupported (
165 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
166 IN EFI_HANDLE Handle
,
167 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
173 TODO: Add function description
177 This - TODO: add argument description
178 Handle - TODO: add argument description
179 RemainingDevicePath - TODO: add argument description
183 TODO: add return values
190 UnixSerialIoDriverBindingStart (
191 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
192 IN EFI_HANDLE Handle
,
193 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
199 TODO: Add function description
203 This - TODO: add argument description
204 Handle - TODO: add argument description
205 RemainingDevicePath - TODO: add argument description
209 TODO: add return values
216 UnixSerialIoDriverBindingStop (
217 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
218 IN EFI_HANDLE Handle
,
219 IN UINTN NumberOfChildren
,
220 IN EFI_HANDLE
*ChildHandleBuffer
226 TODO: Add function description
230 This - TODO: add argument description
231 Handle - TODO: add argument description
232 NumberOfChildren - TODO: add argument description
233 ChildHandleBuffer - TODO: add argument description
237 TODO: add return values
245 IN EFI_SERIAL_IO_PROTOCOL
*This
251 TODO: Add function description
255 This - TODO: add argument description
259 TODO: add return values
266 UnixSerialIoSetAttributes (
267 IN EFI_SERIAL_IO_PROTOCOL
*This
,
269 IN UINT32 ReceiveFifoDepth
,
271 IN EFI_PARITY_TYPE Parity
,
273 IN EFI_STOP_BITS_TYPE StopBits
279 TODO: Add function description
283 This - TODO: add argument description
284 BaudRate - TODO: add argument description
285 ReceiveFifoDepth - TODO: add argument description
286 Timeout - TODO: add argument description
287 Parity - TODO: add argument description
288 DataBits - TODO: add argument description
289 StopBits - TODO: add argument description
293 TODO: add return values
300 UnixSerialIoSetControl (
301 IN EFI_SERIAL_IO_PROTOCOL
*This
,
308 TODO: Add function description
312 This - TODO: add argument description
313 Control - TODO: add argument description
317 TODO: add return values
324 UnixSerialIoGetControl (
325 IN EFI_SERIAL_IO_PROTOCOL
*This
,
332 TODO: Add function description
336 This - TODO: add argument description
337 Control - TODO: add argument description
341 TODO: add return values
349 IN EFI_SERIAL_IO_PROTOCOL
*This
,
350 IN OUT UINTN
*BufferSize
,
357 TODO: Add function description
361 This - TODO: add argument description
362 BufferSize - TODO: add argument description
363 Buffer - TODO: add argument description
367 TODO: add return values
375 IN EFI_SERIAL_IO_PROTOCOL
*This
,
376 IN OUT UINTN
*BufferSize
,
383 TODO: Add function description
387 This - TODO: add argument description
388 BufferSize - TODO: add argument description
389 Buffer - TODO: add argument description
393 TODO: add return values
400 IN SERIAL_DEV_FIFO
*Fifo
406 TODO: Add function description
410 Fifo - TODO: add argument description
414 TODO: add return values
421 IN SERIAL_DEV_FIFO
*Fifo
427 TODO: Add function description
431 Fifo - TODO: add argument description
435 TODO: add return values
442 IN SERIAL_DEV_FIFO
*Fifo
,
449 TODO: Add function description
453 Fifo - TODO: add argument description
454 Data - TODO: add argument description
458 TODO: add return values
464 IsaSerialFifoRemove (
465 IN SERIAL_DEV_FIFO
*Fifo
,
472 TODO: Add function description
476 Fifo - TODO: add argument description
477 Data - TODO: add argument description
481 TODO: add return values
487 IsaSerialReceiveTransmit (
488 UNIX_SERIAL_IO_PRIVATE_DATA
*Private
494 TODO: Add function description
498 Private - TODO: add argument description
502 TODO: add return values