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