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