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