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