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