2 Serial IO protocol as defined in the UEFI 2.0 specification.
4 Abstraction of a basic serial device. Targeted at 16550 UART, but
5 could be much more generic.
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #ifndef __SERIAL_IO_PROTOCOL_H__
19 #define __SERIAL_IO_PROTOCOL_H__
21 #define EFI_SERIAL_IO_PROTOCOL_GUID \
23 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD } \
27 // Protocol GUID defined in EFI1.1.
29 #define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID
31 typedef struct _EFI_SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL
;
35 // Backward-compatible with EFI1.1.
37 typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE
;
40 // Serial IO Data structures
59 // define for Control bits, grouped by read only, write only, and read write
64 #define EFI_SERIAL_CLEAR_TO_SEND 0x00000010
65 #define EFI_SERIAL_DATA_SET_READY 0x00000020
66 #define EFI_SERIAL_RING_INDICATE 0x00000040
67 #define EFI_SERIAL_CARRIER_DETECT 0x00000080
68 #define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100
69 #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200
74 #define EFI_SERIAL_REQUEST_TO_SEND 0x00000002
75 #define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001
80 #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000
81 #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000
82 #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000
85 // Serial IO Member Functions
88 Reset the serial device.
90 @param This Protocol instance pointer.
92 @retval EFI_SUCCESS The device was reset.
93 @retval EFI_DEVICE_ERROR The serial device could not be reset.
98 (EFIAPI
*EFI_SERIAL_RESET
) (
99 IN EFI_SERIAL_IO_PROTOCOL
*This
104 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
105 data buts, and stop bits on a serial device.
107 @param This Protocol instance pointer.
108 @param BaudRate The requested baud rate. A BaudRate value of 0 will use the the
109 device's default interface speed.
110 @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
111 serial interface. A ReceiveFifoDepth value of 0 will use
112 the device's dfault FIFO depth.
113 @param Timeout The requested time out for a single character in microseconds.
114 This timeout applies to both the transmit and receive side of the
115 interface. A Timeout value of 0 will use the device's default time
117 @param Parity The type of parity to use on this serial device. A Parity value of
118 DefaultParity will use the device's default parity value.
119 @param DataBits The number of data bits to use on the serial device. A DataBits
120 vaule of 0 will use the device's default data bit setting.
121 @param StopBits The number of stop bits to use on this serial device. A StopBits
122 value of DefaultStopBits will use the device's default number of
125 @retval EFI_SUCCESS The device was reset.
126 @retval EFI_DEVICE_ERROR The serial device could not be reset.
131 (EFIAPI
*EFI_SERIAL_SET_ATTRIBUTES
) (
132 IN EFI_SERIAL_IO_PROTOCOL
*This
,
134 IN UINT32 ReceiveFifoDepth
,
136 IN EFI_PARITY_TYPE Parity
,
138 IN EFI_STOP_BITS_TYPE StopBits
143 Set the control bits on a serial device
145 @param This Protocol instance pointer.
146 @param Control Set the bits of Control that are settable.
148 @retval EFI_SUCCESS The new control bits were set on the serial device.
149 @retval EFI_UNSUPPORTED The serial device does not support this operation.
150 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
155 (EFIAPI
*EFI_SERIAL_SET_CONTROL_BITS
) (
156 IN EFI_SERIAL_IO_PROTOCOL
*This
,
162 Retrieves the status of thecontrol bits on a serial device
164 @param This Protocol instance pointer.
165 @param Control A pointer to return the current Control signals from the serial device.
167 @retval EFI_SUCCESS The control bits were read from the serial device.
168 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
173 (EFIAPI
*EFI_SERIAL_GET_CONTROL_BITS
) (
174 IN EFI_SERIAL_IO_PROTOCOL
*This
,
180 Writes data to a serial device.
182 @param This Protocol instance pointer.
183 @param BufferSize On input, the size of the Buffer. On output, the amount of
184 data actually written.
185 @param Buffer The buffer of data to write
187 @retval EFI_SUCCESS The data was written.
188 @retval EFI_DEVICE_ERROR The device reported an error.
189 @retval EFI_TIMEOUT The data write was stopped due to a timeout.
194 (EFIAPI
*EFI_SERIAL_WRITE
) (
195 IN EFI_SERIAL_IO_PROTOCOL
*This
,
196 IN OUT UINTN
*BufferSize
,
202 Writes data to a serial device.
204 @param This Protocol instance pointer.
205 @param BufferSize On input, the size of the Buffer. On output, the amount of
206 data returned in Buffer.
207 @param Buffer The buffer to return the data into.
209 @retval EFI_SUCCESS The data was read.
210 @retval EFI_DEVICE_ERROR The device reported an error.
211 @retval EFI_TIMEOUT The data write was stopped due to a timeout.
216 (EFIAPI
*EFI_SERIAL_READ
) (
217 IN EFI_SERIAL_IO_PROTOCOL
*This
,
218 IN OUT UINTN
*BufferSize
,
224 The data values in SERIAL_IO_MODE are read-only and are updated by the code
225 that produces the SERIAL_IO_PROTOCOL member functions.
227 ControlMask - A mask fo the Control bits that the device supports. The device
228 must always support the Input Buffer Empty control bit.
229 TimeOut - If applicable, the number of microseconds to wait before timing out
230 a Read or Write operation.
231 BaudRate - If applicable, the current baud rate setting of the device; otherwise,
232 baud rate has the value of zero to indicate that device runs at the
233 device's designed speed.
234 ReceiveFifoDepth - The number of characters the device will buffer on input
235 DataBits - The number of characters the device will buffer on input
236 Parity - If applicable, this is the EFI_PARITY_TYPE that is computed or
237 checked as each character is transmitted or reveived. If the device
238 does not support parity the value is the default parity value.
239 StopBits - If applicable, the EFI_STOP_BITS_TYPE number of stop bits per
240 character. If the device does not support stop bits the value is
241 the default stop bit values.
248 // current Attributes
252 UINT32 ReceiveFifoDepth
;
256 } EFI_SERIAL_IO_MODE
;
258 #define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000
259 #define SERIAL_IO_INTERFACE_REVISION EFI_SERIAL_IO_PROTOCOL_REVISION
261 struct _EFI_SERIAL_IO_PROTOCOL
{
263 EFI_SERIAL_RESET Reset
;
264 EFI_SERIAL_SET_ATTRIBUTES SetAttributes
;
265 EFI_SERIAL_SET_CONTROL_BITS SetControl
;
266 EFI_SERIAL_GET_CONTROL_BITS GetControl
;
267 EFI_SERIAL_WRITE Write
;
268 EFI_SERIAL_READ Read
;
270 EFI_SERIAL_IO_MODE
*Mode
;
273 extern EFI_GUID gEfiSerialIoProtocolGuid
;