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