]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/SerialIo.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / SerialIo.h
CommitLineData
d1f95000 1/** @file\r
8a7d75b0 2 Serial IO protocol as defined in the UEFI 2.0 specification.\r
d1f95000 3\r
4 Abstraction of a basic serial device. Targeted at 16550 UART, but\r
5 could be much more generic.\r
6\r
9095d37b 7 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d1f95000 9\r
d1f95000 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
99e8ed21 20///\r
21/// Protocol GUID defined in EFI1.1.\r
9095d37b 22///\r
a6508c05 23#define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID\r
24\r
d1f95000 25typedef struct _EFI_SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL;\r
26\r
a6508c05 27\r
99e8ed21 28///\r
29/// Backward-compatible with EFI1.1.\r
9095d37b 30///\r
a6508c05 31typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE;\r
32\r
99e8ed21 33///\r
9319d2c2
LG
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
99e8ed21 36///\r
d1f95000 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
9319d2c2
LG
46///\r
47/// Stop bits type\r
48///\r
d1f95000 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
9095d37b 89\r
d1f95000 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
8b13229b 96(EFIAPI *EFI_SERIAL_RESET)(\r
d1f95000 97 IN EFI_SERIAL_IO_PROTOCOL *This\r
ed66e1bc 98 );\r
d1f95000 99\r
100/**\r
9095d37b 101 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,\r
41b474b7 102 data bits, and stop bits on a serial device.\r
d1f95000 103\r
104 @param This Protocol instance pointer.\r
630b4187 105 @param BaudRate The requested baud rate. A BaudRate value of 0 will use the\r
d1f95000 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
630b4187 109 the device's default FIFO depth.\r
d1f95000 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
13d378fc
JG
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
d1f95000 125\r
126**/\r
127typedef\r
128EFI_STATUS\r
8b13229b 129(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES)(\r
d1f95000 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
ed66e1bc 137 );\r
d1f95000 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
8b13229b 152(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS)(\r
d1f95000 153 IN EFI_SERIAL_IO_PROTOCOL *This,\r
154 IN UINT32 Control\r
ed66e1bc 155 );\r
d1f95000 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
9095d37b 162\r
d1f95000 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
8b13229b 169(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS)(\r
d1f95000 170 IN EFI_SERIAL_IO_PROTOCOL *This,\r
171 OUT UINT32 *Control\r
ed66e1bc 172 );\r
d1f95000 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
8b13229b 189(EFIAPI *EFI_SERIAL_WRITE)(\r
d1f95000 190 IN EFI_SERIAL_IO_PROTOCOL *This,\r
191 IN OUT UINTN *BufferSize,\r
192 IN VOID *Buffer\r
ed66e1bc 193 );\r
d1f95000 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
f754f721 201 @param Buffer The buffer to return the data into.\r
d1f95000 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
8b13229b 210(EFIAPI *EFI_SERIAL_READ)(\r
d1f95000 211 IN EFI_SERIAL_IO_PROTOCOL *This,\r
212 IN OUT UINTN *BufferSize,\r
213 OUT VOID *Buffer\r
ed66e1bc 214 );\r
d1f95000 215\r
216/**\r
4ca9b6c4 217 @par Data Structure Description:\r
9095d37b 218 The data values in SERIAL_IO_MODE are read-only and are updated by the code\r
d1f95000 219 that produces the SERIAL_IO_PROTOCOL member functions.\r
220\r
4ca9b6c4 221 @param ControlMask\r
630b4187 222 A mask for the Control bits that the device supports. The device\r
d1f95000 223 must always support the Input Buffer Empty control bit.\r
9095d37b 224\r
4ca9b6c4
LG
225 @param TimeOut\r
226 If applicable, the number of microseconds to wait before timing out\r
d1f95000 227 a Read or Write operation.\r
9095d37b 228\r
4ca9b6c4
LG
229 @param BaudRate\r
230 If applicable, the current baud rate setting of the device; otherwise,\r
d1f95000 231 baud rate has the value of zero to indicate that device runs at the\r
232 device's designed speed.\r
9095d37b 233\r
4ca9b6c4
LG
234 @param ReceiveFifoDepth\r
235 The number of characters the device will buffer on input\r
9095d37b 236\r
4ca9b6c4
LG
237 @param DataBits\r
238 The number of characters the device will buffer on input\r
9095d37b 239\r
4ca9b6c4 240 @param Parity\r
9095d37b 241 If applicable, this is the EFI_PARITY_TYPE that is computed or\r
d1f95000 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
9095d37b 244\r
4ca9b6c4
LG
245 @param StopBits\r
246 If applicable, the EFI_STOP_BITS_TYPE number of stop bits per\r
d1f95000 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
a6508c05 265#define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000\r
266#define SERIAL_IO_INTERFACE_REVISION EFI_SERIAL_IO_PROTOCOL_REVISION\r
d1f95000 267\r
44717a39 268///\r
9095d37b
LG
269/// The Serial I/O protocol is used to communicate with UART-style serial devices.\r
270/// These can be standard UART serial ports in PC-AT systems, serial ports attached\r
f754f721 271/// to a USB interface, or potentially any character-based I/O device.\r
44717a39 272///\r
d1f95000 273struct _EFI_SERIAL_IO_PROTOCOL {\r
1f08a159 274 ///\r
9095d37b
LG
275 /// The revision to which the EFI_SERIAL_IO_PROTOCOL adheres. All future revisions\r
276 /// must be backwards compatible. If a future version is not backwards compatible,\r
1f08a159 277 /// it is not the same GUID.\r
278 ///\r
d1f95000 279 UINT32 Revision;\r
280 EFI_SERIAL_RESET Reset;\r
281 EFI_SERIAL_SET_ATTRIBUTES SetAttributes;\r
282 EFI_SERIAL_SET_CONTROL_BITS SetControl;\r
283 EFI_SERIAL_GET_CONTROL_BITS GetControl;\r
284 EFI_SERIAL_WRITE Write;\r
285 EFI_SERIAL_READ Read;\r
44717a39 286 ///\r
287 /// Pointer to SERIAL_IO_MODE data.\r
288 ///\r
d1f95000 289 EFI_SERIAL_IO_MODE *Mode;\r
290};\r
291\r
292extern EFI_GUID gEfiSerialIoProtocolGuid;\r
293\r
294#endif\r