3 Copyright (c) 2004, 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.
18 Serial IO protocol as defined in the EFI 1.0 specification.
20 Abstraction of a basic serial device. Targeted at 16550 UART, but
21 could be much more generic.
28 #define EFI_SERIAL_IO_PROTOCOL_GUID \
30 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} \
33 EFI_FORWARD_DECLARATION (EFI_SERIAL_IO_PROTOCOL
);
36 // Serial IO Data structures
55 // define for Control bits, grouped by read only, write only, and read write
60 #define EFI_SERIAL_CLEAR_TO_SEND 0x00000010
61 #define EFI_SERIAL_DATA_SET_READY 0x00000020
62 #define EFI_SERIAL_RING_INDICATE 0x00000040
63 #define EFI_SERIAL_CARRIER_DETECT 0x00000080
64 #define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100
65 #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200
70 #define EFI_SERIAL_REQUEST_TO_SEND 0x00000002
71 #define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001
76 #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000
77 #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000
78 #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000
81 // Serial IO Member Functions
85 (EFIAPI
*EFI_SERIAL_RESET
) (
86 IN EFI_SERIAL_IO_PROTOCOL
* This
91 Reset the serial device.
94 This - Protocol instance pointer.
97 EFI_SUCCESS - The device was reset.
98 EFI_DEVICE_ERROR - The serial device could not be reset.
105 (EFIAPI
*EFI_SERIAL_SET_ATTRIBUTES
) (
106 IN EFI_SERIAL_IO_PROTOCOL
* This
,
108 IN UINT32 ReceiveFifoDepth
,
110 IN EFI_PARITY_TYPE Parity
,
112 IN EFI_STOP_BITS_TYPE StopBits
117 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
118 data buts, and stop bits on a serial device.
121 This - Protocol instance pointer.
122 BaudRate - The requested baud rate. A BaudRate value of 0 will use the the
123 device's default interface speed.
124 ReveiveFifoDepth - The requested depth of the FIFO on the receive side of the
125 serial interface. A ReceiveFifoDepth value of 0 will use
126 the device's dfault FIFO depth.
127 Timeout - The requested time out for a single character in microseconds.
128 This timeout applies to both the transmit and receive side of the
129 interface. A Timeout value of 0 will use the device's default time
131 Parity - The type of parity to use on this serial device. A Parity value of
132 DefaultParity will use the device's default parity value.
133 DataBits - The number of data bits to use on the serial device. A DataBits
134 vaule of 0 will use the device's default data bit setting.
135 StopBits - The number of stop bits to use on this serial device. A StopBits
136 value of DefaultStopBits will use the device's default number of
140 EFI_SUCCESS - The device was reset.
141 EFI_DEVICE_ERROR - The serial device could not be reset.
148 (EFIAPI
*EFI_SERIAL_SET_CONTROL_BITS
) (
149 IN EFI_SERIAL_IO_PROTOCOL
* This
,
155 Set the control bits on a serial device
158 This - Protocol instance pointer.
159 Control - Set the bits of Control that are settable.
162 EFI_SUCCESS - The new control bits were set on the serial device.
163 EFI_UNSUPPORTED - The serial device does not support this operation.
164 EFI_DEVICE_ERROR - The serial device is not functioning correctly.
171 (EFIAPI
*EFI_SERIAL_GET_CONTROL_BITS
) (
172 IN EFI_SERIAL_IO_PROTOCOL
* This
,
178 Retrieves the status of thecontrol bits on a serial device
181 This - Protocol instance pointer.
182 Control - A pointer to return the current Control signals from the serial
186 EFI_SUCCESS - The control bits were read from the serial device.
187 EFI_DEVICE_ERROR - The serial device is not functioning correctly.
194 (EFIAPI
*EFI_SERIAL_WRITE
) (
195 IN EFI_SERIAL_IO_PROTOCOL
* This
,
196 IN OUT UINTN
*BufferSize
,
202 Writes data to a serial device.
205 This - Protocol instance pointer.
206 BufferSize - On input, the size of the Buffer. On output, the amount of
207 data actually written.
208 Buffer - The buffer of data to write
211 EFI_SUCCESS - The data was written.
212 EFI_DEVICE_ERROR - The device reported an error.
213 EFI_TIMEOUT - The data write was stopped due to a timeout.
220 (EFIAPI
*EFI_SERIAL_READ
) (
221 IN EFI_SERIAL_IO_PROTOCOL
* This
,
222 IN OUT UINTN
*BufferSize
,
228 Writes data to a serial device.
231 This - Protocol instance pointer.
232 BufferSize - On input, the size of the Buffer. On output, the amount of
233 data returned in Buffer.
234 Buffer - The buffer to return the data into.
237 EFI_SUCCESS - The data was read.
238 EFI_DEVICE_ERROR - The device reported an error.
239 EFI_TIMEOUT - The data write was stopped due to a timeout.
246 The data values in SERIAL_IO_MODE are read-only and are updated by the code
247 that produces the SERIAL_IO_PROTOCOL member functions.
249 ControlMask - A mask fo the Control bits that the device supports. The device
250 must always support the Input Buffer Empty control bit.
251 TimeOut - If applicable, the number of microseconds to wait before timing out
252 a Read or Write operation.
253 BaudRate - If applicable, the current baud rate setting of the device; otherwise,
254 baud rate has the value of zero to indicate that device runs at the
255 device's designed speed.
256 ReceiveFifoDepth - The number of characters the device will buffer on input
257 DataBits - The number of characters the device will buffer on input
258 Parity - If applicable, this is the EFI_PARITY_TYPE that is computed or
259 checked as each character is transmitted or reveived. If the device
260 does not support parity the value is the default parity value.
261 StopBits - If applicable, the EFI_STOP_BITS_TYPE number of stop bits per
262 character. If the device does not support stop bits the value is
263 the default stop bit values.
270 // current Attributes
274 UINT32 ReceiveFifoDepth
;
278 } EFI_SERIAL_IO_MODE
;
280 #define SERIAL_IO_INTERFACE_REVISION 0x00010000
282 struct _EFI_SERIAL_IO_PROTOCOL
{
284 EFI_SERIAL_RESET Reset
;
285 EFI_SERIAL_SET_ATTRIBUTES SetAttributes
;
286 EFI_SERIAL_SET_CONTROL_BITS SetControl
;
287 EFI_SERIAL_GET_CONTROL_BITS GetControl
;
288 EFI_SERIAL_WRITE Write
;
289 EFI_SERIAL_READ Read
;
291 EFI_SERIAL_IO_MODE
*Mode
;
294 extern EFI_GUID gEfiSerialIoProtocolGuid
;