]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/SerialIo.h
Formalize comments for Protocols and PPIs.
[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
4ca9b6c4 7 Copyright (c) 2006 - 2008, Intel Corporation \r
d1f95000 8 All rights reserved. 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
12\r
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
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
28/// \r
a6508c05 29#define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID\r
30\r
d1f95000 31typedef 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
36/// \r
a6508c05 37typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE;\r
38\r
99e8ed21 39///\r
40/// Serial IO Data structures\r
41///\r
d1f95000 42typedef enum {\r
43 DefaultParity,\r
44 NoParity,\r
45 EvenParity,\r
46 OddParity,\r
47 MarkParity,\r
48 SpaceParity\r
49} EFI_PARITY_TYPE;\r
50\r
51typedef enum {\r
52 DefaultStopBits,\r
53 OneStopBit,\r
54 OneFiveStopBits,\r
55 TwoStopBits\r
56} EFI_STOP_BITS_TYPE;\r
57\r
58//\r
59// define for Control bits, grouped by read only, write only, and read write\r
60//\r
61//\r
62// Read Only\r
63//\r
64#define EFI_SERIAL_CLEAR_TO_SEND 0x00000010\r
65#define EFI_SERIAL_DATA_SET_READY 0x00000020\r
66#define EFI_SERIAL_RING_INDICATE 0x00000040\r
67#define EFI_SERIAL_CARRIER_DETECT 0x00000080\r
68#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100\r
69#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200\r
70\r
71//\r
72// Write Only\r
73//\r
74#define EFI_SERIAL_REQUEST_TO_SEND 0x00000002\r
75#define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001\r
76\r
77//\r
78// Read Write\r
79//\r
80#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000\r
81#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000\r
82#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000\r
83\r
84//\r
85// Serial IO Member Functions\r
86//\r
87/**\r
88 Reset the serial device.\r
89\r
90 @param This Protocol instance pointer.\r
91 \r
92 @retval EFI_SUCCESS The device was reset.\r
93 @retval EFI_DEVICE_ERROR The serial device could not be reset.\r
94\r
95**/\r
96typedef\r
97EFI_STATUS\r
8b13229b 98(EFIAPI *EFI_SERIAL_RESET)(\r
d1f95000 99 IN EFI_SERIAL_IO_PROTOCOL *This\r
ed66e1bc 100 );\r
d1f95000 101\r
102/**\r
103 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity, \r
104 data buts, and stop bits on a serial device.\r
105\r
106 @param This Protocol instance pointer.\r
107 @param BaudRate The requested baud rate. A BaudRate value of 0 will use the the\r
108 device's default interface speed.\r
109 @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the\r
110 serial interface. A ReceiveFifoDepth value of 0 will use\r
111 the device's dfault FIFO depth.\r
112 @param Timeout The requested time out for a single character in microseconds.\r
113 This timeout applies to both the transmit and receive side of the\r
114 interface. A Timeout value of 0 will use the device's default time\r
115 out value.\r
116 @param Parity The type of parity to use on this serial device. A Parity value of\r
117 DefaultParity will use the device's default parity value.\r
118 @param DataBits The number of data bits to use on the serial device. A DataBits\r
119 vaule of 0 will use the device's default data bit setting.\r
120 @param StopBits The number of stop bits to use on this serial device. A StopBits\r
121 value of DefaultStopBits will use the device's default number of\r
122 stop bits.\r
123\r
124 @retval EFI_SUCCESS The device was reset.\r
125 @retval EFI_DEVICE_ERROR The serial device could not be reset.\r
126\r
127**/\r
128typedef\r
129EFI_STATUS\r
8b13229b 130(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES)(\r
d1f95000 131 IN EFI_SERIAL_IO_PROTOCOL *This,\r
132 IN UINT64 BaudRate,\r
133 IN UINT32 ReceiveFifoDepth,\r
134 IN UINT32 Timeout,\r
135 IN EFI_PARITY_TYPE Parity,\r
136 IN UINT8 DataBits,\r
137 IN EFI_STOP_BITS_TYPE StopBits\r
ed66e1bc 138 );\r
d1f95000 139\r
140/**\r
141 Set the control bits on a serial device\r
142\r
143 @param This Protocol instance pointer.\r
144 @param Control Set the bits of Control that are settable.\r
145\r
146 @retval EFI_SUCCESS The new control bits were set on the serial device.\r
147 @retval EFI_UNSUPPORTED The serial device does not support this operation.\r
148 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
149\r
150**/\r
151typedef\r
152EFI_STATUS\r
8b13229b 153(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS)(\r
d1f95000 154 IN EFI_SERIAL_IO_PROTOCOL *This,\r
155 IN UINT32 Control\r
ed66e1bc 156 );\r
d1f95000 157\r
158/**\r
159 Retrieves the status of thecontrol bits on a serial device\r
160\r
161 @param This Protocol instance pointer.\r
162 @param Control A pointer to return the current Control signals from the serial device.\r
163 \r
164 @retval EFI_SUCCESS The control bits were read from the serial device.\r
165 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
166\r
167**/\r
168typedef\r
169EFI_STATUS\r
8b13229b 170(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS)(\r
d1f95000 171 IN EFI_SERIAL_IO_PROTOCOL *This,\r
172 OUT UINT32 *Control\r
ed66e1bc 173 );\r
d1f95000 174\r
175/**\r
176 Writes data to a serial device.\r
177\r
178 @param This Protocol instance pointer.\r
179 @param BufferSize On input, the size of the Buffer. On output, the amount of\r
180 data actually written.\r
181 @param Buffer The buffer of data to write\r
182\r
183 @retval EFI_SUCCESS The data was written.\r
184 @retval EFI_DEVICE_ERROR The device reported an error.\r
185 @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
186\r
187**/\r
188typedef\r
189EFI_STATUS\r
8b13229b 190(EFIAPI *EFI_SERIAL_WRITE)(\r
d1f95000 191 IN EFI_SERIAL_IO_PROTOCOL *This,\r
192 IN OUT UINTN *BufferSize,\r
193 IN VOID *Buffer\r
ed66e1bc 194 );\r
d1f95000 195\r
196/**\r
197 Writes data to a serial device.\r
198\r
199 @param This Protocol instance pointer.\r
200 @param BufferSize On input, the size of the Buffer. On output, the amount of\r
201 data returned in Buffer.\r
202 @param Buffer The buffer to return the data into.\r
203\r
204 @retval EFI_SUCCESS The data was read.\r
205 @retval EFI_DEVICE_ERROR The device reported an error.\r
206 @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
207\r
208**/\r
209typedef\r
210EFI_STATUS\r
8b13229b 211(EFIAPI *EFI_SERIAL_READ)(\r
d1f95000 212 IN EFI_SERIAL_IO_PROTOCOL *This,\r
213 IN OUT UINTN *BufferSize,\r
214 OUT VOID *Buffer\r
ed66e1bc 215 );\r
d1f95000 216\r
217/**\r
4ca9b6c4 218 @par Data Structure Description:\r
d1f95000 219 The data values in SERIAL_IO_MODE are read-only and are updated by the code \r
220 that produces the SERIAL_IO_PROTOCOL member functions.\r
221\r
4ca9b6c4
LG
222 @param ControlMask\r
223 A mask fo the Control bits that the device supports. The device\r
d1f95000 224 must always support the Input Buffer Empty control bit.\r
4ca9b6c4
LG
225 \r
226 @param TimeOut\r
227 If applicable, the number of microseconds to wait before timing out\r
d1f95000 228 a Read or Write operation.\r
4ca9b6c4
LG
229 \r
230 @param BaudRate\r
231 If applicable, the current baud rate setting of the device; otherwise,\r
d1f95000 232 baud rate has the value of zero to indicate that device runs at the\r
233 device's designed speed.\r
4ca9b6c4
LG
234 \r
235 @param ReceiveFifoDepth\r
236 The number of characters the device will buffer on input\r
237 \r
238 @param DataBits\r
239 The number of characters the device will buffer on input\r
240 \r
241 @param Parity\r
242 If applicable, this is the EFI_PARITY_TYPE that is computed or \r
d1f95000 243 checked as each character is transmitted or reveived. If the device\r
244 does not support parity the value is the default parity value.\r
4ca9b6c4
LG
245 \r
246 @param StopBits\r
247 If applicable, the EFI_STOP_BITS_TYPE number of stop bits per\r
d1f95000 248 character. If the device does not support stop bits the value is\r
249 the default stop bit values.\r
250\r
251**/\r
252typedef struct {\r
253 UINT32 ControlMask;\r
254\r
255 //\r
256 // current Attributes\r
257 //\r
258 UINT32 Timeout;\r
259 UINT64 BaudRate;\r
260 UINT32 ReceiveFifoDepth;\r
261 UINT32 DataBits;\r
262 UINT32 Parity;\r
263 UINT32 StopBits;\r
264} EFI_SERIAL_IO_MODE;\r
265\r
a6508c05 266#define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000\r
267#define SERIAL_IO_INTERFACE_REVISION EFI_SERIAL_IO_PROTOCOL_REVISION\r
d1f95000 268\r
44717a39 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
d1f95000 274struct _EFI_SERIAL_IO_PROTOCOL {\r
1f08a159 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 back wards compatible, \r
278 /// it is not the same GUID.\r
279 ///\r
d1f95000 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
44717a39 287 ///\r
288 /// Pointer to SERIAL_IO_MODE data.\r
289 ///\r
d1f95000 290 EFI_SERIAL_IO_MODE *Mode;\r
291};\r
292\r
293extern EFI_GUID gEfiSerialIoProtocolGuid;\r
294\r
295#endif\r