iPXE
SerialIo.h
Go to the documentation of this file.
1 /** @file
2  Serial IO protocol as defined in the UEFI 2.0 specification.
3 
4  Abstraction of a basic serial device. Targeted at 16550 UART, but
5  could be much more generic.
6 
7  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
8  SPDX-License-Identifier: BSD-2-Clause-Patent
9 
10 **/
11 
12 #ifndef __SERIAL_IO_PROTOCOL_H__
13 #define __SERIAL_IO_PROTOCOL_H__
14 
15 FILE_LICENCE ( BSD2_PATENT );
16 
17 #define EFI_SERIAL_IO_PROTOCOL_GUID \
18  { \
19  0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD } \
20  }
21 
22 #define EFI_SERIAL_TERMINAL_DEVICE_TYPE_GUID \
23  { \
24  0X6AD9A60F, 0X5815, 0X4C7C, { 0X8A, 0X10, 0X50, 0X53, 0XD2, 0XBF, 0X7A, 0X1B } \
25  }
26 
27 ///
28 /// Protocol GUID defined in EFI1.1.
29 ///
30 #define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID
31 
33 
34 ///
35 /// Backward-compatible with EFI1.1.
36 ///
38 
39 ///
40 /// Parity type that is computed or checked as each character is transmitted or received. If the
41 /// device does not support parity, the value is the default parity value.
42 ///
43 typedef enum {
51 
52 ///
53 /// Stop bits type
54 ///
55 typedef enum {
61 
62 //
63 // define for Control bits, grouped by read only, write only, and read write
64 //
65 //
66 // Read Only
67 //
68 #define EFI_SERIAL_CLEAR_TO_SEND 0x00000010
69 #define EFI_SERIAL_DATA_SET_READY 0x00000020
70 #define EFI_SERIAL_RING_INDICATE 0x00000040
71 #define EFI_SERIAL_CARRIER_DETECT 0x00000080
72 #define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100
73 #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200
74 
75 //
76 // Write Only
77 //
78 #define EFI_SERIAL_REQUEST_TO_SEND 0x00000002
79 #define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001
80 
81 //
82 // Read Write
83 //
84 #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000
85 #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000
86 #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000
87 
88 //
89 // Serial IO Member Functions
90 //
91 
92 /**
93  Reset the serial device.
94 
95  @param This Protocol instance pointer.
96 
97  @retval EFI_SUCCESS The device was reset.
98  @retval EFI_DEVICE_ERROR The serial device could not be reset.
99 
100 **/
101 typedef
105  );
106 
107 /**
108  Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
109  data bits, and stop bits on a serial device.
110 
111  @param This Protocol instance pointer.
112  @param BaudRate The requested baud rate. A BaudRate value of 0 will use the
113  device's default interface speed.
114  @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
115  serial interface. A ReceiveFifoDepth value of 0 will use
116  the device's default FIFO depth.
117  @param Timeout The requested time out for a single character in microseconds.
118  This timeout applies to both the transmit and receive side of the
119  interface. A Timeout value of 0 will use the device's default time
120  out value.
121  @param Parity The type of parity to use on this serial device. A Parity value of
122  DefaultParity will use the device's default parity value.
123  @param DataBits The number of data bits to use on the serial device. A DataBits
124  vaule of 0 will use the device's default data bit setting.
125  @param StopBits The number of stop bits to use on this serial device. A StopBits
126  value of DefaultStopBits will use the device's default number of
127  stop bits.
128 
129  @retval EFI_SUCCESS The device was reset.
130  @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported value.
131  @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
132 
133 **/
134 typedef
138  IN UINT64 BaudRate,
139  IN UINT32 ReceiveFifoDepth,
140  IN UINT32 Timeout,
142  IN UINT8 DataBits,
143  IN EFI_STOP_BITS_TYPE StopBits
144  );
145 
146 /**
147  Set the control bits on a serial device
148 
149  @param This Protocol instance pointer.
150  @param Control Set the bits of Control that are settable.
151 
152  @retval EFI_SUCCESS The new control bits were set on the serial device.
153  @retval EFI_UNSUPPORTED The serial device does not support this operation.
154  @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
155 
156 **/
157 typedef
161  IN UINT32 Control
162  );
163 
164 /**
165  Retrieves the status of thecontrol bits on a serial device
166 
167  @param This Protocol instance pointer.
168  @param Control A pointer to return the current Control signals from the serial device.
169 
170  @retval EFI_SUCCESS The control bits were read from the serial device.
171  @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
172 
173 **/
174 typedef
178  OUT UINT32 *Control
179  );
180 
181 /**
182  Writes data to a serial device.
183 
184  @param This Protocol instance pointer.
185  @param BufferSize On input, the size of the Buffer. On output, the amount of
186  data actually written.
187  @param Buffer The buffer of data to write
188 
189  @retval EFI_SUCCESS The data was written.
190  @retval EFI_DEVICE_ERROR The device reported an error.
191  @retval EFI_TIMEOUT The data write was stopped due to a timeout.
192 
193 **/
194 typedef
199  IN VOID *Buffer
200  );
201 
202 /**
203  Writes data to a serial device.
204 
205  @param This Protocol instance pointer.
206  @param BufferSize On input, the size of the Buffer. On output, the amount of
207  data returned in Buffer.
208  @param Buffer The buffer to return the data into.
209 
210  @retval EFI_SUCCESS The data was read.
211  @retval EFI_DEVICE_ERROR The device reported an error.
212  @retval EFI_TIMEOUT The data write was stopped due to a timeout.
213 
214 **/
215 typedef
220  OUT VOID *Buffer
221  );
222 
223 /**
224  @par Data Structure Description:
225  The data values in SERIAL_IO_MODE are read-only and are updated by the code
226  that produces the SERIAL_IO_PROTOCOL member functions.
227 
228  @param ControlMask
229  A mask for the Control bits that the device supports. The device
230  must always support the Input Buffer Empty control bit.
231 
232  @param TimeOut
233  If applicable, the number of microseconds to wait before timing out
234  a Read or Write operation.
235 
236  @param BaudRate
237  If applicable, the current baud rate setting of the device; otherwise,
238  baud rate has the value of zero to indicate that device runs at the
239  device's designed speed.
240 
241  @param ReceiveFifoDepth
242  The number of characters the device will buffer on input
243 
244  @param DataBits
245  The number of characters the device will buffer on input
246 
247  @param Parity
248  If applicable, this is the EFI_PARITY_TYPE that is computed or
249  checked as each character is transmitted or reveived. If the device
250  does not support parity the value is the default parity value.
251 
252  @param StopBits
253  If applicable, the EFI_STOP_BITS_TYPE number of stop bits per
254  character. If the device does not support stop bits the value is
255  the default stop bit values.
256 
257 **/
258 typedef struct {
260 
261  //
262  // current Attributes
263  //
271 
272 #define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000
273 #define EFI_SERIAL_IO_PROTOCOL_REVISION1p1 0x00010001
274 #define SERIAL_IO_INTERFACE_REVISION EFI_SERIAL_IO_PROTOCOL_REVISION
275 
276 ///
277 /// The Serial I/O protocol is used to communicate with UART-style serial devices.
278 /// These can be standard UART serial ports in PC-AT systems, serial ports attached
279 /// to a USB interface, or potentially any character-based I/O device.
280 ///
282  ///
283  /// The revision to which the EFI_SERIAL_IO_PROTOCOL adheres. All future revisions
284  /// must be backwards compatible. If a future version is not backwards compatible,
285  /// it is not the same GUID.
286  ///
294  ///
295  /// Pointer to SERIAL_IO_MODE data.
296  ///
298  ///
299  /// Pointer to a GUID identifying the device connected to the serial port.
300  /// This field is NULL when the protocol is installed by the serial port
301  /// driver and may be populated by a platform driver for a serial port
302  /// with a known device attached. The field will remain NULL if there is
303  /// no platform serial device identification information available.
304  ///
305  CONST EFI_GUID *DeviceTypeGuid; // Revision 1.1
306 };
307 
310 
311 #endif
UINT32 Revision
The revision to which the EFI_SERIAL_IO_PROTOCOL adheres.
Definition: SerialIo.h:287
EFI_SERIAL_GET_CONTROL_BITS GetControl
Definition: SerialIo.h:291
FILE_LICENCE(BSD2_PATENT)
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
EFI_SERIAL_SET_CONTROL_BITS SetControl
Definition: SerialIo.h:290
EFI_SERIAL_SET_ATTRIBUTES SetAttributes
Definition: SerialIo.h:289
EFI_PARITY_TYPE
Parity type that is computed or checked as each character is transmitted or received.
Definition: SerialIo.h:43
unsigned int UINT32
Definition: ProcessorBind.h:98
EFI_GUID gEfiSerialTerminalDeviceTypeGuid
EFI_STATUS(EFIAPI * EFI_SERIAL_SET_ATTRIBUTES)(IN EFI_SERIAL_IO_PROTOCOL *This, IN UINT64 BaudRate, IN UINT32 ReceiveFifoDepth, IN UINT32 Timeout, IN EFI_PARITY_TYPE Parity, IN UINT8 DataBits, IN EFI_STOP_BITS_TYPE StopBits)
Sets the baud rate, receive FIFO depth, transmit/receice time out, parity, data bits,...
Definition: SerialIo.h:136
UINT16_t BufferSize
Buffer size.
Definition: pxe_api.h:64
EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE
Backward-compatible with EFI1.1.
Definition: SerialIo.h:37
unsigned char UINT8
EFI_STATUS(EFIAPI * EFI_SERIAL_WRITE)(IN EFI_SERIAL_IO_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
Writes data to a serial device.
Definition: SerialIo.h:196
#define OUT
Definition: mlx_utils.h:29
EFI_STOP_BITS_TYPE
Stop bits type.
Definition: SerialIo.h:55
The Serial I/O protocol is used to communicate with UART-style serial devices.
Definition: SerialIo.h:281
CONST EFI_GUID * DeviceTypeGuid
Pointer to a GUID identifying the device connected to the serial port.
Definition: SerialIo.h:305
EFI_STATUS(EFIAPI * EFI_SERIAL_RESET)(IN EFI_SERIAL_IO_PROTOCOL *This)
Reset the serial device.
Definition: SerialIo.h:103
#define EFIAPI
SEGOFF16_t Buffer
Buffer address.
Definition: pxe_api.h:65
EFI_STATUS(EFIAPI * EFI_SERIAL_SET_CONTROL_BITS)(IN EFI_SERIAL_IO_PROTOCOL *This, IN UINT32 Control)
Set the control bits on a serial device.
Definition: SerialIo.h:159
UINT64 UINTN
Unsigned value of native width.
#define VOID
Undeclared type.
Definition: Base.h:271
unsigned long long UINT64
Definition: ProcessorBind.h:96
#define IN
Definition: mlx_utils.h:28
EFI_SERIAL_READ Read
Definition: SerialIo.h:293
UINT32 ControlMask
Definition: SerialIo.h:259
#define CONST
Datum is read-only.
Definition: Base.h:261
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_SERIAL_IO_MODE * Mode
Pointer to SERIAL_IO_MODE data.
Definition: SerialIo.h:297
EFI_GUID gEfiSerialIoProtocolGuid
EFI_STATUS(EFIAPI * EFI_SERIAL_GET_CONTROL_BITS)(IN EFI_SERIAL_IO_PROTOCOL *This, OUT UINT32 *Control)
Retrieves the status of thecontrol bits on a serial device.
Definition: SerialIo.h:176
UINT8 Parity
Definition: Acpi50.h:141
EFI_SERIAL_RESET Reset
Definition: SerialIo.h:288
UINT32 ReceiveFifoDepth
Definition: SerialIo.h:266
EFI_SERIAL_WRITE Write
Definition: SerialIo.h:292
EFI_STATUS(EFIAPI * EFI_SERIAL_READ)(IN EFI_SERIAL_IO_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
Writes data to a serial device.
Definition: SerialIo.h:217