]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/SerialIo.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
f43a14e3
OY
20#define EFI_SERIAL_TERMINAL_DEVICE_TYPE_GUID \\r
21 { \\r
22 0X6AD9A60F, 0X5815, 0X4C7C, { 0X8A, 0X10, 0X50, 0X53, 0XD2, 0XBF, 0X7A, 0X1B } \\r
23 }\r
24\r
99e8ed21 25///\r
26/// Protocol GUID defined in EFI1.1.\r
9095d37b 27///\r
a6508c05 28#define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID\r
29\r
d1f95000 30typedef struct _EFI_SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL;\r
31\r
99e8ed21 32///\r
33/// Backward-compatible with EFI1.1.\r
9095d37b 34///\r
2f88bd3a 35typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE;\r
a6508c05 36\r
99e8ed21 37///\r
9319d2c2
LG
38/// Parity type that is computed or checked as each character is transmitted or received. If the\r
39/// device does not support parity, the value is the default parity value.\r
99e8ed21 40///\r
d1f95000 41typedef enum {\r
42 DefaultParity,\r
43 NoParity,\r
44 EvenParity,\r
45 OddParity,\r
46 MarkParity,\r
47 SpaceParity\r
48} EFI_PARITY_TYPE;\r
49\r
9319d2c2
LG
50///\r
51/// Stop bits type\r
52///\r
d1f95000 53typedef enum {\r
54 DefaultStopBits,\r
55 OneStopBit,\r
56 OneFiveStopBits,\r
57 TwoStopBits\r
58} EFI_STOP_BITS_TYPE;\r
59\r
60//\r
61// define for Control bits, grouped by read only, write only, and read write\r
62//\r
63//\r
64// Read Only\r
65//\r
66#define EFI_SERIAL_CLEAR_TO_SEND 0x00000010\r
67#define EFI_SERIAL_DATA_SET_READY 0x00000020\r
68#define EFI_SERIAL_RING_INDICATE 0x00000040\r
69#define EFI_SERIAL_CARRIER_DETECT 0x00000080\r
70#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100\r
71#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200\r
72\r
73//\r
74// Write Only\r
75//\r
76#define EFI_SERIAL_REQUEST_TO_SEND 0x00000002\r
77#define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001\r
78\r
79//\r
80// Read Write\r
81//\r
2f88bd3a
MK
82#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000\r
83#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000\r
84#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000\r
d1f95000 85\r
86//\r
87// Serial IO Member Functions\r
88//\r
2f88bd3a 89\r
d1f95000 90/**\r
91 Reset the serial device.\r
92\r
93 @param This Protocol instance pointer.\r
9095d37b 94\r
d1f95000 95 @retval EFI_SUCCESS The device was reset.\r
96 @retval EFI_DEVICE_ERROR The serial device could not be reset.\r
97\r
98**/\r
99typedef\r
100EFI_STATUS\r
8b13229b 101(EFIAPI *EFI_SERIAL_RESET)(\r
d1f95000 102 IN EFI_SERIAL_IO_PROTOCOL *This\r
ed66e1bc 103 );\r
d1f95000 104\r
105/**\r
9095d37b 106 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,\r
41b474b7 107 data bits, and stop bits on a serial device.\r
d1f95000 108\r
109 @param This Protocol instance pointer.\r
630b4187 110 @param BaudRate The requested baud rate. A BaudRate value of 0 will use the\r
d1f95000 111 device's default interface speed.\r
112 @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the\r
113 serial interface. A ReceiveFifoDepth value of 0 will use\r
630b4187 114 the device's default FIFO depth.\r
d1f95000 115 @param Timeout The requested time out for a single character in microseconds.\r
116 This timeout applies to both the transmit and receive side of the\r
117 interface. A Timeout value of 0 will use the device's default time\r
118 out value.\r
119 @param Parity The type of parity to use on this serial device. A Parity value of\r
120 DefaultParity will use the device's default parity value.\r
121 @param DataBits The number of data bits to use on the serial device. A DataBits\r
122 vaule of 0 will use the device's default data bit setting.\r
123 @param StopBits The number of stop bits to use on this serial device. A StopBits\r
124 value of DefaultStopBits will use the device's default number of\r
125 stop bits.\r
126\r
13d378fc
JG
127 @retval EFI_SUCCESS The device was reset.\r
128 @retval EFI_INVALID_PARAMETER One or more attributes has an unsupported value.\r
129 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
d1f95000 130\r
131**/\r
132typedef\r
133EFI_STATUS\r
8b13229b 134(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES)(\r
d1f95000 135 IN EFI_SERIAL_IO_PROTOCOL *This,\r
136 IN UINT64 BaudRate,\r
137 IN UINT32 ReceiveFifoDepth,\r
138 IN UINT32 Timeout,\r
139 IN EFI_PARITY_TYPE Parity,\r
140 IN UINT8 DataBits,\r
141 IN EFI_STOP_BITS_TYPE StopBits\r
ed66e1bc 142 );\r
d1f95000 143\r
144/**\r
145 Set the control bits on a serial device\r
146\r
147 @param This Protocol instance pointer.\r
148 @param Control Set the bits of Control that are settable.\r
149\r
150 @retval EFI_SUCCESS The new control bits were set on the serial device.\r
151 @retval EFI_UNSUPPORTED The serial device does not support this operation.\r
152 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
153\r
154**/\r
155typedef\r
156EFI_STATUS\r
8b13229b 157(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS)(\r
d1f95000 158 IN EFI_SERIAL_IO_PROTOCOL *This,\r
159 IN UINT32 Control\r
ed66e1bc 160 );\r
d1f95000 161\r
162/**\r
163 Retrieves the status of thecontrol bits on a serial device\r
164\r
165 @param This Protocol instance pointer.\r
166 @param Control A pointer to return the current Control signals from the serial device.\r
9095d37b 167\r
d1f95000 168 @retval EFI_SUCCESS The control bits were read from the serial device.\r
169 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
170\r
171**/\r
172typedef\r
173EFI_STATUS\r
8b13229b 174(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS)(\r
d1f95000 175 IN EFI_SERIAL_IO_PROTOCOL *This,\r
176 OUT UINT32 *Control\r
ed66e1bc 177 );\r
d1f95000 178\r
179/**\r
180 Writes data to a serial device.\r
181\r
182 @param This Protocol instance pointer.\r
183 @param BufferSize On input, the size of the Buffer. On output, the amount of\r
184 data actually written.\r
185 @param Buffer The buffer of data to write\r
186\r
187 @retval EFI_SUCCESS The data was written.\r
188 @retval EFI_DEVICE_ERROR The device reported an error.\r
189 @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
190\r
191**/\r
192typedef\r
193EFI_STATUS\r
8b13229b 194(EFIAPI *EFI_SERIAL_WRITE)(\r
d1f95000 195 IN EFI_SERIAL_IO_PROTOCOL *This,\r
196 IN OUT UINTN *BufferSize,\r
197 IN VOID *Buffer\r
ed66e1bc 198 );\r
d1f95000 199\r
200/**\r
201 Writes data to a serial device.\r
202\r
203 @param This Protocol instance pointer.\r
204 @param BufferSize On input, the size of the Buffer. On output, the amount of\r
205 data returned in Buffer.\r
f754f721 206 @param Buffer The buffer to return the data into.\r
d1f95000 207\r
208 @retval EFI_SUCCESS The data was read.\r
209 @retval EFI_DEVICE_ERROR The device reported an error.\r
210 @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
211\r
212**/\r
213typedef\r
214EFI_STATUS\r
8b13229b 215(EFIAPI *EFI_SERIAL_READ)(\r
d1f95000 216 IN EFI_SERIAL_IO_PROTOCOL *This,\r
217 IN OUT UINTN *BufferSize,\r
218 OUT VOID *Buffer\r
ed66e1bc 219 );\r
d1f95000 220\r
221/**\r
4ca9b6c4 222 @par Data Structure Description:\r
9095d37b 223 The data values in SERIAL_IO_MODE are read-only and are updated by the code\r
d1f95000 224 that produces the SERIAL_IO_PROTOCOL member functions.\r
225\r
4ca9b6c4 226 @param ControlMask\r
630b4187 227 A mask for the Control bits that the device supports. The device\r
d1f95000 228 must always support the Input Buffer Empty control bit.\r
9095d37b 229\r
4ca9b6c4
LG
230 @param TimeOut\r
231 If applicable, the number of microseconds to wait before timing out\r
d1f95000 232 a Read or Write operation.\r
9095d37b 233\r
4ca9b6c4
LG
234 @param BaudRate\r
235 If applicable, the current baud rate setting of the device; otherwise,\r
d1f95000 236 baud rate has the value of zero to indicate that device runs at the\r
237 device's designed speed.\r
9095d37b 238\r
4ca9b6c4
LG
239 @param ReceiveFifoDepth\r
240 The number of characters the device will buffer on input\r
9095d37b 241\r
4ca9b6c4
LG
242 @param DataBits\r
243 The number of characters the device will buffer on input\r
9095d37b 244\r
4ca9b6c4 245 @param Parity\r
9095d37b 246 If applicable, this is the EFI_PARITY_TYPE that is computed or\r
d1f95000 247 checked as each character is transmitted or reveived. If the device\r
248 does not support parity the value is the default parity value.\r
9095d37b 249\r
4ca9b6c4
LG
250 @param StopBits\r
251 If applicable, the EFI_STOP_BITS_TYPE number of stop bits per\r
d1f95000 252 character. If the device does not support stop bits the value is\r
253 the default stop bit values.\r
254\r
255**/\r
256typedef struct {\r
2f88bd3a 257 UINT32 ControlMask;\r
d1f95000 258\r
259 //\r
260 // current Attributes\r
261 //\r
2f88bd3a
MK
262 UINT32 Timeout;\r
263 UINT64 BaudRate;\r
264 UINT32 ReceiveFifoDepth;\r
265 UINT32 DataBits;\r
266 UINT32 Parity;\r
267 UINT32 StopBits;\r
d1f95000 268} EFI_SERIAL_IO_MODE;\r
269\r
2f88bd3a
MK
270#define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000\r
271#define EFI_SERIAL_IO_PROTOCOL_REVISION1p1 0x00010001\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 279struct _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
2f88bd3a
MK
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
2f88bd3a 295 EFI_SERIAL_IO_MODE *Mode;\r
7e9cef64
OY
296 ///\r
297 /// Pointer to a GUID identifying the device connected to the serial port.\r
298 /// This field is NULL when the protocol is installed by the serial port\r
299 /// driver and may be populated by a platform driver for a serial port\r
300 /// with a known device attached. The field will remain NULL if there is\r
301 /// no platform serial device identification information available.\r
302 ///\r
2f88bd3a 303 CONST EFI_GUID *DeviceTypeGuid; // Revision 1.1\r
d1f95000 304};\r
305\r
2f88bd3a
MK
306extern EFI_GUID gEfiSerialIoProtocolGuid;\r
307extern EFI_GUID gEfiSerialTerminalDeviceTypeGuid;\r
d1f95000 308\r
309#endif\r