]>
Commit | Line | Data |
---|---|---|
91c68197 | 1 | /** @file\r |
637ff819 | 2 | Include for Serial Driver\r |
f8cd287b | 3 | \r |
684fec3c | 4 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r |
180a5a35 | 5 | This program and the accompanying materials\r |
f8cd287b | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
637ff819 | 9 | \r |
f8cd287b | 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
637ff819 | 12 | \r |
f8cd287b | 13 | **/\r |
637ff819 | 14 | \r |
91c68197 LG |
15 | #ifndef _SERIAL_H_\r |
16 | #define _SERIAL_H_\r | |
637ff819 | 17 | \r |
ed7748fe | 18 | \r |
79bc7a89 | 19 | #include <FrameworkDxe.h>\r |
ed7748fe | 20 | \r |
637ff819 | 21 | #include <Protocol/IsaIo.h>\r |
22 | #include <Protocol/SerialIo.h>\r | |
23 | #include <Protocol/DevicePath.h>\r | |
ed7748fe | 24 | \r |
637ff819 | 25 | #include <Library/DebugLib.h>\r |
26 | #include <Library/UefiDriverEntryPoint.h>\r | |
637ff819 | 27 | #include <Library/UefiLib.h>\r |
28 | #include <Library/DevicePathLib.h>\r | |
29 | #include <Library/BaseMemoryLib.h>\r | |
30 | #include <Library/MemoryAllocationLib.h>\r | |
31 | #include <Library/UefiBootServicesTableLib.h>\r | |
32 | #include <Library/ReportStatusCodeLib.h>\r | |
33 | #include <Library/PcdLib.h>\r | |
91c68197 | 34 | \r |
637ff819 | 35 | //\r |
36 | // Driver Binding Externs\r | |
37 | //\r | |
f3d08ccf | 38 | extern EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver;\r |
39 | extern EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName;\r | |
40 | extern EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2;\r | |
637ff819 | 41 | \r |
42 | //\r | |
43 | // Internal Data Structures\r | |
44 | //\r | |
f02bd376 | 45 | #define SERIAL_DEV_SIGNATURE SIGNATURE_32 ('s', 'e', 'r', 'd')\r |
637ff819 | 46 | #define SERIAL_MAX_BUFFER_SIZE 16\r |
47 | #define TIMEOUT_STALL_INTERVAL 10\r | |
48 | \r | |
49 | //\r | |
50 | // Name: SERIAL_DEV_FIFO\r | |
51 | // Purpose: To define Receive FIFO and Transmit FIFO\r | |
52 | // Context: Used by serial data transmit and receive\r | |
53 | // Fields:\r | |
54 | // First UINT32: The index of the first data in array Data[]\r | |
55 | // Last UINT32: The index, which you can put a new data into array Data[]\r | |
56 | // Surplus UINT32: Identify how many data you can put into array Data[]\r | |
57 | // Data[] UINT8 : An array, which used to store data\r | |
58 | //\r | |
59 | typedef struct {\r | |
60 | UINT32 First;\r | |
61 | UINT32 Last;\r | |
62 | UINT32 Surplus;\r | |
63 | UINT8 Data[SERIAL_MAX_BUFFER_SIZE];\r | |
64 | } SERIAL_DEV_FIFO;\r | |
65 | \r | |
66 | typedef enum {\r | |
91c68197 LG |
67 | Uart8250 = 0,\r |
68 | Uart16450 = 1,\r | |
69 | Uart16550 = 2,\r | |
70 | Uart16550A= 3\r | |
637ff819 | 71 | } EFI_UART_TYPE;\r |
72 | \r | |
73 | //\r | |
74 | // Name: SERIAL_DEV\r | |
75 | // Purpose: To provide device specific information\r | |
76 | // Context:\r | |
77 | // Fields:\r | |
78 | // Signature UINTN: The identity of the serial device\r | |
79 | // SerialIo SERIAL_IO_PROTOCOL: Serial I/O protocol interface\r | |
80 | // SerialMode SERIAL_IO_MODE:\r | |
81 | // DevicePath EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device\r | |
82 | // Handle EFI_HANDLE: The handle instance attached to serial device\r | |
83 | // BaseAddress UINT16: The base address of specific serial device\r | |
84 | // Receive SERIAL_DEV_FIFO: The FIFO used to store data,\r | |
85 | // which is received by UART\r | |
86 | // Transmit SERIAL_DEV_FIFO: The FIFO used to store data,\r | |
87 | // which you want to transmit by UART\r | |
88 | // SoftwareLoopbackEnable BOOLEAN:\r | |
89 | // Type EFI_UART_TYPE: Specify the UART type of certain serial device\r | |
90 | //\r | |
91 | typedef struct {\r | |
92 | UINTN Signature;\r | |
93 | \r | |
94 | EFI_HANDLE Handle;\r | |
95 | EFI_SERIAL_IO_PROTOCOL SerialIo;\r | |
96 | EFI_SERIAL_IO_MODE SerialMode;\r | |
97 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
98 | \r | |
99 | EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r | |
100 | UART_DEVICE_PATH UartDevicePath;\r | |
101 | EFI_ISA_IO_PROTOCOL *IsaIo;\r | |
102 | \r | |
103 | UINT16 BaseAddress;\r | |
104 | SERIAL_DEV_FIFO Receive;\r | |
105 | SERIAL_DEV_FIFO Transmit;\r | |
106 | BOOLEAN SoftwareLoopbackEnable;\r | |
107 | BOOLEAN HardwareFlowControl;\r | |
108 | EFI_UART_TYPE Type;\r | |
109 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r | |
110 | } SERIAL_DEV;\r | |
111 | \r | |
637ff819 | 112 | #define SERIAL_DEV_FROM_THIS(a) CR (a, SERIAL_DEV, SerialIo, SERIAL_DEV_SIGNATURE)\r |
113 | \r | |
637ff819 | 114 | //\r |
115 | // Serial Driver Defaults\r | |
116 | //\r | |
637ff819 | 117 | #define SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH 1\r |
118 | #define SERIAL_PORT_DEFAULT_TIMEOUT 1000000\r | |
6b008b74 RN |
119 | #define SERIAL_PORT_SUPPORT_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \\r |
120 | EFI_SERIAL_DATA_SET_READY | \\r | |
121 | EFI_SERIAL_RING_INDICATE | \\r | |
122 | EFI_SERIAL_CARRIER_DETECT | \\r | |
123 | EFI_SERIAL_REQUEST_TO_SEND | \\r | |
124 | EFI_SERIAL_DATA_TERMINAL_READY | \\r | |
125 | EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | \\r | |
126 | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE | \\r | |
127 | EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE | \\r | |
128 | EFI_SERIAL_OUTPUT_BUFFER_EMPTY | \\r | |
129 | EFI_SERIAL_INPUT_BUFFER_EMPTY)\r | |
637ff819 | 130 | \r |
637ff819 | 131 | //\r |
132 | // 115200 baud with rounding errors\r | |
133 | //\r | |
134 | #define SERIAL_PORT_MAX_BAUD_RATE 115400\r | |
135 | #define SERIAL_PORT_MIN_BAUD_RATE 50\r | |
136 | \r | |
137 | #define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16\r | |
138 | #define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS\r | |
139 | #define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds\r | |
140 | //\r | |
141 | // UART Registers\r | |
142 | //\r | |
143 | #define SERIAL_REGISTER_THR 0 // WO Transmit Holding Register\r | |
144 | #define SERIAL_REGISTER_RBR 0 // RO Receive Buffer Register\r | |
145 | #define SERIAL_REGISTER_DLL 0 // R/W Divisor Latch LSB\r | |
146 | #define SERIAL_REGISTER_DLM 1 // R/W Divisor Latch MSB\r | |
147 | #define SERIAL_REGISTER_IER 1 // R/W Interrupt Enable Register\r | |
148 | #define SERIAL_REGISTER_IIR 2 // RO Interrupt Identification Register\r | |
149 | #define SERIAL_REGISTER_FCR 2 // WO FIFO Cotrol Register\r | |
150 | #define SERIAL_REGISTER_LCR 3 // R/W Line Control Register\r | |
151 | #define SERIAL_REGISTER_MCR 4 // R/W Modem Control Register\r | |
152 | #define SERIAL_REGISTER_LSR 5 // R/W Line Status Register\r | |
153 | #define SERIAL_REGISTER_MSR 6 // R/W Modem Status Register\r | |
154 | #define SERIAL_REGISTER_SCR 7 // R/W Scratch Pad Register\r | |
155 | #pragma pack(1)\r | |
156 | //\r | |
157 | // Name: SERIAL_PORT_IER_BITS\r | |
158 | // Purpose: Define each bit in Interrupt Enable Register\r | |
159 | // Context:\r | |
160 | // Fields:\r | |
91c68197 LG |
161 | // Ravie Bit0: Receiver Data Available Interrupt Enable\r |
162 | // Theie Bit1: Transmistter Holding Register Empty Interrupt Enable\r | |
163 | // Rie Bit2: Receiver Interrupt Enable\r | |
164 | // Mie Bit3: Modem Interrupt Enable\r | |
637ff819 | 165 | // Reserved Bit4-Bit7: Reserved\r |
166 | //\r | |
167 | typedef struct {\r | |
91c68197 LG |
168 | UINT8 Ravie : 1;\r |
169 | UINT8 Theie : 1;\r | |
170 | UINT8 Rie : 1;\r | |
171 | UINT8 Mie : 1;\r | |
637ff819 | 172 | UINT8 Reserved : 4;\r |
173 | } SERIAL_PORT_IER_BITS;\r | |
174 | \r | |
175 | //\r | |
176 | // Name: SERIAL_PORT_IER\r | |
177 | // Purpose:\r | |
178 | // Context:\r | |
179 | // Fields:\r | |
180 | // Bits SERIAL_PORT_IER_BITS: Bits of the IER\r | |
181 | // Data UINT8: the value of the IER\r | |
182 | //\r | |
183 | typedef union {\r | |
184 | SERIAL_PORT_IER_BITS Bits;\r | |
185 | UINT8 Data;\r | |
186 | } SERIAL_PORT_IER;\r | |
187 | \r | |
637ff819 | 188 | //\r |
189 | // Name: SERIAL_PORT_FCR_BITS\r | |
190 | // Purpose: Define each bit in FIFO Control Register\r | |
191 | // Context:\r | |
192 | // Fields:\r | |
91c68197 LG |
193 | // TrFIFOE Bit0: Transmit and Receive FIFO Enable\r |
194 | // ResetRF Bit1: Reset Reciever FIFO\r | |
195 | // ResetTF Bit2: Reset Transmistter FIFO\r | |
196 | // Dms Bit3: DMA Mode Select\r | |
637ff819 | 197 | // Reserved Bit4-Bit5: Reserved\r |
91c68197 | 198 | // Rtb Bit6-Bit7: Receive Trigger Bits\r |
637ff819 | 199 | //\r |
200 | typedef struct {\r | |
91c68197 LG |
201 | UINT8 TrFIFOE : 1;\r |
202 | UINT8 ResetRF : 1;\r | |
203 | UINT8 ResetTF : 1;\r | |
204 | UINT8 Dms : 1;\r | |
637ff819 | 205 | UINT8 Reserved : 2;\r |
91c68197 | 206 | UINT8 Rtb : 2;\r |
637ff819 | 207 | } SERIAL_PORT_FCR_BITS;\r |
208 | \r | |
209 | //\r | |
210 | // Name: SERIAL_PORT_FCR\r | |
211 | // Purpose:\r | |
212 | // Context:\r | |
213 | // Fields:\r | |
214 | // Bits SERIAL_PORT_FCR_BITS: Bits of the FCR\r | |
215 | // Data UINT8: the value of the FCR\r | |
216 | //\r | |
217 | typedef union {\r | |
218 | SERIAL_PORT_FCR_BITS Bits;\r | |
219 | UINT8 Data;\r | |
220 | } SERIAL_PORT_FCR;\r | |
221 | \r | |
222 | //\r | |
223 | // Name: SERIAL_PORT_LCR_BITS\r | |
224 | // Purpose: Define each bit in Line Control Register\r | |
225 | // Context:\r | |
226 | // Fields:\r | |
91c68197 LG |
227 | // SerialDB Bit0-Bit1: Number of Serial Data Bits\r |
228 | // StopB Bit2: Number of Stop Bits\r | |
229 | // ParEn Bit3: Parity Enable\r | |
230 | // EvenPar Bit4: Even Parity Select\r | |
231 | // SticPar Bit5: Sticky Parity\r | |
232 | // BrCon Bit6: Break Control\r | |
233 | // DLab Bit7: Divisor Latch Access Bit\r | |
637ff819 | 234 | //\r |
235 | typedef struct {\r | |
91c68197 LG |
236 | UINT8 SerialDB : 2;\r |
237 | UINT8 StopB : 1;\r | |
238 | UINT8 ParEn : 1;\r | |
239 | UINT8 EvenPar : 1;\r | |
240 | UINT8 SticPar : 1;\r | |
241 | UINT8 BrCon : 1;\r | |
242 | UINT8 DLab : 1;\r | |
637ff819 | 243 | } SERIAL_PORT_LCR_BITS;\r |
244 | \r | |
245 | //\r | |
246 | // Name: SERIAL_PORT_LCR\r | |
247 | // Purpose:\r | |
248 | // Context:\r | |
249 | // Fields:\r | |
250 | // Bits SERIAL_PORT_LCR_BITS: Bits of the LCR\r | |
251 | // Data UINT8: the value of the LCR\r | |
252 | //\r | |
253 | typedef union {\r | |
254 | SERIAL_PORT_LCR_BITS Bits;\r | |
255 | UINT8 Data;\r | |
256 | } SERIAL_PORT_LCR;\r | |
257 | \r | |
258 | //\r | |
259 | // Name: SERIAL_PORT_MCR_BITS\r | |
260 | // Purpose: Define each bit in Modem Control Register\r | |
261 | // Context:\r | |
262 | // Fields:\r | |
91c68197 LG |
263 | // DtrC Bit0: Data Terminal Ready Control\r |
264 | // Rts Bit1: Request To Send Control\r | |
265 | // Out1 Bit2: Output1\r | |
266 | // Out2 Bit3: Output2, used to disable interrupt\r | |
267 | // Lme; Bit4: Loopback Mode Enable\r | |
637ff819 | 268 | // Reserved Bit5-Bit7: Reserved\r |
269 | //\r | |
270 | typedef struct {\r | |
91c68197 LG |
271 | UINT8 DtrC : 1;\r |
272 | UINT8 Rts : 1;\r | |
273 | UINT8 Out1 : 1;\r | |
274 | UINT8 Out2 : 1;\r | |
275 | UINT8 Lme : 1;\r | |
637ff819 | 276 | UINT8 Reserved : 3;\r |
277 | } SERIAL_PORT_MCR_BITS;\r | |
278 | \r | |
279 | //\r | |
280 | // Name: SERIAL_PORT_MCR\r | |
281 | // Purpose:\r | |
282 | // Context:\r | |
283 | // Fields:\r | |
284 | // Bits SERIAL_PORT_MCR_BITS: Bits of the MCR\r | |
285 | // Data UINT8: the value of the MCR\r | |
286 | //\r | |
287 | typedef union {\r | |
288 | SERIAL_PORT_MCR_BITS Bits;\r | |
289 | UINT8 Data;\r | |
290 | } SERIAL_PORT_MCR;\r | |
291 | \r | |
292 | //\r | |
293 | // Name: SERIAL_PORT_LSR_BITS\r | |
294 | // Purpose: Define each bit in Line Status Register\r | |
295 | // Context:\r | |
296 | // Fields:\r | |
91c68197 LG |
297 | // Dr Bit0: Receiver Data Ready Status\r |
298 | // Oe Bit1: Overrun Error Status\r | |
299 | // Pe Bit2: Parity Error Status\r | |
300 | // Fe Bit3: Framing Error Status\r | |
301 | // Bi Bit4: Break Interrupt Status\r | |
302 | // Thre Bit5: Transmistter Holding Register Status\r | |
303 | // Temt Bit6: Transmitter Empty Status\r | |
304 | // FIFOe Bit7: FIFO Error Status\r | |
637ff819 | 305 | //\r |
306 | typedef struct {\r | |
91c68197 LG |
307 | UINT8 Dr : 1;\r |
308 | UINT8 Oe : 1;\r | |
309 | UINT8 Pe : 1;\r | |
310 | UINT8 Fe : 1;\r | |
311 | UINT8 Bi : 1;\r | |
312 | UINT8 Thre : 1;\r | |
313 | UINT8 Temt : 1;\r | |
314 | UINT8 FIFOe : 1;\r | |
637ff819 | 315 | } SERIAL_PORT_LSR_BITS;\r |
316 | \r | |
317 | //\r | |
318 | // Name: SERIAL_PORT_LSR\r | |
319 | // Purpose:\r | |
320 | // Context:\r | |
321 | // Fields:\r | |
322 | // Bits SERIAL_PORT_LSR_BITS: Bits of the LSR\r | |
323 | // Data UINT8: the value of the LSR\r | |
324 | //\r | |
325 | typedef union {\r | |
326 | SERIAL_PORT_LSR_BITS Bits;\r | |
327 | UINT8 Data;\r | |
328 | } SERIAL_PORT_LSR;\r | |
329 | \r | |
330 | //\r | |
331 | // Name: SERIAL_PORT_MSR_BITS\r | |
332 | // Purpose: Define each bit in Modem Status Register\r | |
333 | // Context:\r | |
334 | // Fields:\r | |
335 | // DeltaCTS Bit0: Delta Clear To Send Status\r | |
336 | // DeltaDSR Bit1: Delta Data Set Ready Status\r | |
337 | // TrailingEdgeRI Bit2: Trailing Edge of Ring Indicator Status\r | |
338 | // DeltaDCD Bit3: Delta Data Carrier Detect Status\r | |
91c68197 LG |
339 | // Cts Bit4: Clear To Send Status\r |
340 | // Dsr Bit5: Data Set Ready Status\r | |
341 | // Ri Bit6: Ring Indicator Status\r | |
342 | // Dcd Bit7: Data Carrier Detect Status\r | |
637ff819 | 343 | //\r |
344 | typedef struct {\r | |
345 | UINT8 DeltaCTS : 1;\r | |
346 | UINT8 DeltaDSR : 1;\r | |
347 | UINT8 TrailingEdgeRI : 1;\r | |
348 | UINT8 DeltaDCD : 1;\r | |
91c68197 LG |
349 | UINT8 Cts : 1;\r |
350 | UINT8 Dsr : 1;\r | |
351 | UINT8 Ri : 1;\r | |
352 | UINT8 Dcd : 1;\r | |
637ff819 | 353 | } SERIAL_PORT_MSR_BITS;\r |
354 | \r | |
355 | //\r | |
356 | // Name: SERIAL_PORT_MSR\r | |
357 | // Purpose:\r | |
358 | // Context:\r | |
359 | // Fields:\r | |
360 | // Bits SERIAL_PORT_MSR_BITS: Bits of the MSR\r | |
361 | // Data UINT8: the value of the MSR\r | |
362 | //\r | |
363 | typedef union {\r | |
364 | SERIAL_PORT_MSR_BITS Bits;\r | |
365 | UINT8 Data;\r | |
366 | } SERIAL_PORT_MSR;\r | |
367 | \r | |
368 | #pragma pack()\r | |
369 | //\r | |
370 | // Define serial register I/O macros\r | |
371 | //\r | |
372 | #define READ_RBR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_RBR)\r | |
373 | #define READ_DLL(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLL)\r | |
374 | #define READ_DLM(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLM)\r | |
375 | #define READ_IER(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_IER)\r | |
376 | #define READ_IIR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_IIR)\r | |
377 | #define READ_LCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_LCR)\r | |
378 | #define READ_MCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_MCR)\r | |
379 | #define READ_LSR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_LSR)\r | |
380 | #define READ_MSR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_MSR)\r | |
381 | #define READ_SCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_SCR)\r | |
382 | \r | |
383 | #define WRITE_THR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_THR, D)\r | |
384 | #define WRITE_DLL(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLL, D)\r | |
385 | #define WRITE_DLM(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLM, D)\r | |
386 | #define WRITE_IER(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_IER, D)\r | |
387 | #define WRITE_FCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_FCR, D)\r | |
388 | #define WRITE_LCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LCR, D)\r | |
389 | #define WRITE_MCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MCR, D)\r | |
390 | #define WRITE_LSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LSR, D)\r | |
391 | #define WRITE_MSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MSR, D)\r | |
392 | #define WRITE_SCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_SCR, D)\r | |
393 | \r | |
394 | //\r | |
395 | // Prototypes\r | |
396 | // Driver model protocol interface\r | |
397 | //\r | |
91c68197 LG |
398 | /**\r |
399 | Check to see if this driver supports the given controller\r | |
637ff819 | 400 | \r |
91c68197 LG |
401 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
402 | @param Controller The handle of the controller to test.\r | |
403 | @param RemainingDevicePath A pointer to the remaining portion of a device path.\r | |
404 | \r | |
405 | @return EFI_SUCCESS This driver can support the given controller\r | |
406 | \r | |
407 | **/\r | |
637ff819 | 408 | EFI_STATUS\r |
409 | EFIAPI\r | |
410 | SerialControllerDriverSupported (\r | |
411 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
412 | IN EFI_HANDLE Controller,\r | |
413 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
414 | );\r | |
415 | \r | |
91c68197 LG |
416 | /**\r |
417 | Start to management the controller passed in\r | |
418 | \r | |
419 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
420 | @param Controller The handle of the controller to test.\r | |
421 | @param RemainingDevicePath A pointer to the remaining portion of a device path.\r | |
422 | \r | |
423 | @return EFI_SUCCESS Driver is started successfully\r | |
424 | **/\r | |
637ff819 | 425 | EFI_STATUS\r |
426 | EFIAPI\r | |
427 | SerialControllerDriverStart (\r | |
428 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
429 | IN EFI_HANDLE Controller,\r | |
430 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
431 | );\r | |
432 | \r | |
91c68197 LG |
433 | /**\r |
434 | Disconnect this driver with the controller, uninstall related protocol instance\r | |
435 | \r | |
436 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
437 | @param Controller The handle of the controller to test.\r | |
438 | @param NumberOfChildren Number of child device.\r | |
439 | @param ChildHandleBuffer A pointer to the remaining portion of a device path.\r | |
440 | \r | |
441 | @retval EFI_SUCCESS Operation successfully\r | |
442 | @retval EFI_DEVICE_ERROR Cannot stop the driver successfully\r | |
443 | \r | |
444 | **/\r | |
637ff819 | 445 | EFI_STATUS\r |
446 | EFIAPI\r | |
447 | SerialControllerDriverStop (\r | |
448 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
449 | IN EFI_HANDLE Controller,\r | |
450 | IN UINTN NumberOfChildren,\r | |
451 | IN EFI_HANDLE *ChildHandleBuffer\r | |
452 | );\r | |
453 | \r | |
454 | //\r | |
455 | // Serial I/O Protocol Interface\r | |
456 | //\r | |
91c68197 LG |
457 | /**\r |
458 | Reset serial device.\r | |
459 | \r | |
460 | @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r | |
461 | \r | |
462 | @retval EFI_SUCCESS Reset successfully\r | |
463 | @retval EFI_DEVICE_ERROR Failed to reset\r | |
464 | \r | |
465 | **/\r | |
637ff819 | 466 | EFI_STATUS\r |
467 | EFIAPI\r | |
468 | IsaSerialReset (\r | |
469 | IN EFI_SERIAL_IO_PROTOCOL *This\r | |
470 | );\r | |
471 | \r | |
91c68197 LG |
472 | /**\r |
473 | Set new attributes to a serial device.\r | |
474 | \r | |
475 | @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r | |
476 | @param BaudRate The baudrate of the serial device\r | |
477 | @param ReceiveFifoDepth The depth of receive FIFO buffer\r | |
478 | @param Timeout The request timeout for a single char\r | |
479 | @param Parity The type of parity used in serial device\r | |
480 | @param DataBits Number of databits used in serial device\r | |
481 | @param StopBits Number of stopbits used in serial device\r | |
482 | \r | |
483 | @retval EFI_SUCCESS The new attributes were set\r | |
484 | @retval EFI_INVALID_PARAMETERS One or more attributes have an unsupported value\r | |
485 | @retval EFI_UNSUPPORTED Data Bits can not set to 5 or 6\r | |
486 | @retval EFI_DEVICE_ERROR The serial device is not functioning correctly (no return)\r | |
487 | \r | |
488 | **/\r | |
637ff819 | 489 | EFI_STATUS\r |
490 | EFIAPI\r | |
491 | IsaSerialSetAttributes (\r | |
492 | IN EFI_SERIAL_IO_PROTOCOL *This,\r | |
493 | IN UINT64 BaudRate,\r | |
494 | IN UINT32 ReceiveFifoDepth,\r | |
495 | IN UINT32 Timeout,\r | |
496 | IN EFI_PARITY_TYPE Parity,\r | |
497 | IN UINT8 DataBits,\r | |
498 | IN EFI_STOP_BITS_TYPE StopBits\r | |
499 | );\r | |
500 | \r | |
91c68197 LG |
501 | /**\r |
502 | Set Control Bits.\r | |
503 | \r | |
504 | @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r | |
505 | @param Control Control bits that can be settable\r | |
506 | \r | |
507 | @retval EFI_SUCCESS New Control bits were set successfully\r | |
508 | @retval EFI_UNSUPPORTED The Control bits wanted to set are not supported\r | |
509 | \r | |
510 | **/\r | |
637ff819 | 511 | EFI_STATUS\r |
512 | EFIAPI\r | |
513 | IsaSerialSetControl (\r | |
514 | IN EFI_SERIAL_IO_PROTOCOL *This,\r | |
515 | IN UINT32 Control\r | |
516 | );\r | |
517 | \r | |
91c68197 LG |
518 | /**\r |
519 | Get ControlBits.\r | |
520 | \r | |
521 | @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r | |
522 | @param Control Control signals of the serial device\r | |
523 | \r | |
524 | @retval EFI_SUCCESS Get Control signals successfully\r | |
525 | \r | |
526 | **/\r | |
637ff819 | 527 | EFI_STATUS\r |
528 | EFIAPI\r | |
529 | IsaSerialGetControl (\r | |
530 | IN EFI_SERIAL_IO_PROTOCOL *This,\r | |
531 | OUT UINT32 *Control\r | |
532 | );\r | |
533 | \r | |
91c68197 LG |
534 | /**\r |
535 | Write the specified number of bytes to serial device.\r | |
536 | \r | |
537 | @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r | |
538 | @param BufferSize On input the size of Buffer, on output the amount of\r | |
539 | data actually written\r | |
540 | @param Buffer The buffer of data to write\r | |
541 | \r | |
542 | @retval EFI_SUCCESS The data were written successfully\r | |
543 | @retval EFI_DEVICE_ERROR The device reported an error\r | |
544 | @retval EFI_TIMEOUT The write operation was stopped due to timeout\r | |
545 | \r | |
546 | **/\r | |
637ff819 | 547 | EFI_STATUS\r |
548 | EFIAPI\r | |
549 | IsaSerialWrite (\r | |
550 | IN EFI_SERIAL_IO_PROTOCOL *This,\r | |
551 | IN OUT UINTN *BufferSize,\r | |
552 | IN VOID *Buffer\r | |
553 | );\r | |
554 | \r | |
91c68197 LG |
555 | /**\r |
556 | Read the specified number of bytes from serial device.\r | |
557 | \r | |
558 | @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r | |
559 | @param BufferSize On input the size of Buffer, on output the amount of\r | |
560 | data returned in buffer\r | |
561 | @param Buffer The buffer to return the data into\r | |
562 | \r | |
563 | @retval EFI_SUCCESS The data were read successfully\r | |
564 | @retval EFI_DEVICE_ERROR The device reported an error\r | |
565 | @retval EFI_TIMEOUT The read operation was stopped due to timeout\r | |
566 | \r | |
567 | **/\r | |
637ff819 | 568 | EFI_STATUS\r |
569 | EFIAPI\r | |
570 | IsaSerialRead (\r | |
571 | IN EFI_SERIAL_IO_PROTOCOL *This,\r | |
572 | IN OUT UINTN *BufferSize,\r | |
573 | OUT VOID *Buffer\r | |
574 | );\r | |
575 | \r | |
576 | //\r | |
577 | // Internal Functions\r | |
578 | //\r | |
91c68197 LG |
579 | /**\r |
580 | Use scratchpad register to test if this serial port is present.\r | |
581 | \r | |
582 | @param SerialDevice Pointer to serial device structure\r | |
583 | \r | |
584 | @return if this serial port is present\r | |
585 | **/\r | |
637ff819 | 586 | BOOLEAN\r |
587 | IsaSerialPortPresent (\r | |
588 | IN SERIAL_DEV *SerialDevice\r | |
589 | );\r | |
590 | \r | |
91c68197 LG |
591 | /**\r |
592 | Detect whether specific FIFO is full or not.\r | |
593 | \r | |
594 | @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r | |
595 | \r | |
596 | @return whether specific FIFO is full or not\r | |
597 | \r | |
598 | **/\r | |
637ff819 | 599 | BOOLEAN\r |
600 | IsaSerialFifoFull (\r | |
601 | IN SERIAL_DEV_FIFO *Fifo\r | |
602 | );\r | |
603 | \r | |
91c68197 LG |
604 | /**\r |
605 | Detect whether specific FIFO is empty or not.\r | |
606 | \r | |
607 | @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r | |
608 | \r | |
609 | @return whether specific FIFO is empty or not\r | |
610 | \r | |
611 | **/\r | |
637ff819 | 612 | BOOLEAN\r |
613 | IsaSerialFifoEmpty (\r | |
614 | IN SERIAL_DEV_FIFO *Fifo\r | |
615 | );\r | |
616 | \r | |
91c68197 LG |
617 | /**\r |
618 | Add data to specific FIFO.\r | |
619 | \r | |
620 | @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r | |
621 | @param Data the data added to FIFO\r | |
622 | \r | |
623 | @retval EFI_SUCCESS Add data to specific FIFO successfully\r | |
624 | @retval EFI_OUT_OF_RESOURCE Failed to add data because FIFO is already full\r | |
625 | \r | |
626 | **/\r | |
637ff819 | 627 | EFI_STATUS\r |
628 | IsaSerialFifoAdd (\r | |
629 | IN SERIAL_DEV_FIFO *Fifo,\r | |
630 | IN UINT8 Data\r | |
631 | );\r | |
632 | \r | |
91c68197 LG |
633 | /**\r |
634 | Remove data from specific FIFO.\r | |
635 | \r | |
636 | @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r | |
637 | @param Data the data removed from FIFO\r | |
638 | \r | |
639 | @retval EFI_SUCCESS Remove data from specific FIFO successfully\r | |
640 | @retval EFI_OUT_OF_RESOURCE Failed to remove data because FIFO is empty\r | |
641 | \r | |
642 | **/\r | |
637ff819 | 643 | EFI_STATUS\r |
644 | IsaSerialFifoRemove (\r | |
645 | IN SERIAL_DEV_FIFO *Fifo,\r | |
646 | OUT UINT8 *Data\r | |
647 | );\r | |
648 | \r | |
91c68197 LG |
649 | /**\r |
650 | Reads and writes all avaliable data.\r | |
651 | \r | |
652 | @param SerialDevice The device to flush\r | |
653 | \r | |
654 | @retval EFI_SUCCESS Data was read/written successfully.\r | |
655 | @retval EFI_OUT_OF_RESOURCE Failed because software receive FIFO is full. Note, when\r | |
656 | this happens, pending writes are not done.\r | |
657 | \r | |
658 | **/\r | |
637ff819 | 659 | EFI_STATUS\r |
660 | IsaSerialReceiveTransmit (\r | |
661 | IN SERIAL_DEV *SerialDevice\r | |
662 | );\r | |
663 | \r | |
91c68197 LG |
664 | /**\r |
665 | Use IsaIo protocol to read serial port.\r | |
666 | \r | |
667 | @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance\r | |
668 | @param BaseAddress Serial port register group base address\r | |
669 | @param Offset Offset in register group\r | |
670 | \r | |
671 | @return Data read from serial port\r | |
672 | \r | |
673 | **/\r | |
637ff819 | 674 | UINT8\r |
675 | IsaSerialReadPort (\r | |
676 | IN EFI_ISA_IO_PROTOCOL *IsaIo,\r | |
677 | IN UINT16 BaseAddress,\r | |
678 | IN UINT32 Offset\r | |
679 | );\r | |
680 | \r | |
91c68197 LG |
681 | /**\r |
682 | Use IsaIo protocol to write serial port.\r | |
683 | \r | |
684 | @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance\r | |
685 | @param BaseAddress Serial port register group base address\r | |
686 | @param Offset Offset in register group\r | |
687 | @param Data data which is to be written to some serial port register\r | |
688 | \r | |
689 | **/\r | |
637ff819 | 690 | VOID\r |
691 | IsaSerialWritePort (\r | |
692 | IN EFI_ISA_IO_PROTOCOL *IsaIo,\r | |
693 | IN UINT16 BaseAddress,\r | |
694 | IN UINT32 Offset,\r | |
695 | IN UINT8 Data\r | |
696 | );\r | |
697 | \r | |
91c68197 LG |
698 | \r |
699 | //\r | |
700 | // EFI Component Name Functions\r | |
701 | //\r | |
702 | /**\r | |
703 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
704 | \r | |
705 | This function retrieves the user readable name of a driver in the form of a\r | |
706 | Unicode string. If the driver specified by This has a user readable name in\r | |
707 | the language specified by Language, then a pointer to the driver name is\r | |
708 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
709 | by This does not support the language specified by Language,\r | |
710 | then EFI_UNSUPPORTED is returned.\r | |
711 | \r | |
712 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
713 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
714 | \r | |
715 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
716 | array indicating the language. This is the\r | |
717 | language of the driver name that the caller is\r | |
718 | requesting, and it must match one of the\r | |
719 | languages specified in SupportedLanguages. The\r | |
720 | number of languages supported by a driver is up\r | |
721 | to the driver writer. Language is specified\r | |
722 | in RFC 4646 or ISO 639-2 language code format.\r | |
723 | \r | |
724 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
725 | This Unicode string is the name of the\r | |
726 | driver specified by This in the language\r | |
727 | specified by Language.\r | |
728 | \r | |
729 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
730 | This and the language specified by Language was\r | |
731 | returned in DriverName.\r | |
732 | \r | |
733 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
734 | \r | |
735 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
736 | \r | |
737 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
738 | the language specified by Language.\r | |
739 | \r | |
740 | **/\r | |
741 | EFI_STATUS\r | |
742 | EFIAPI\r | |
743 | IsaSerialComponentNameGetDriverName (\r | |
744 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
745 | IN CHAR8 *Language,\r | |
746 | OUT CHAR16 **DriverName\r | |
747 | );\r | |
748 | \r | |
749 | \r | |
750 | /**\r | |
751 | Retrieves a Unicode string that is the user readable name of the controller\r | |
752 | that is being managed by a driver.\r | |
753 | \r | |
754 | This function retrieves the user readable name of the controller specified by\r | |
755 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
756 | driver specified by This has a user readable name in the language specified by\r | |
757 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
758 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
759 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
760 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
761 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
762 | \r | |
763 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
764 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
765 | \r | |
766 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
767 | specified by This is managing. This handle\r | |
768 | specifies the controller whose name is to be\r | |
769 | returned.\r | |
770 | \r | |
771 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
772 | the name of. This is an optional parameter that\r | |
773 | may be NULL. It will be NULL for device\r | |
774 | drivers. It will also be NULL for a bus drivers\r | |
775 | that wish to retrieve the name of the bus\r | |
776 | controller. It will not be NULL for a bus\r | |
777 | driver that wishes to retrieve the name of a\r | |
778 | child controller.\r | |
779 | \r | |
780 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
781 | array indicating the language. This is the\r | |
782 | language of the driver name that the caller is\r | |
783 | requesting, and it must match one of the\r | |
784 | languages specified in SupportedLanguages. The\r | |
785 | number of languages supported by a driver is up\r | |
786 | to the driver writer. Language is specified in\r | |
787 | RFC 4646 or ISO 639-2 language code format.\r | |
788 | \r | |
789 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
790 | This Unicode string is the name of the\r | |
791 | controller specified by ControllerHandle and\r | |
792 | ChildHandle in the language specified by\r | |
793 | Language from the point of view of the driver\r | |
794 | specified by This.\r | |
795 | \r | |
796 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
797 | the language specified by Language for the\r | |
798 | driver specified by This was returned in\r | |
799 | DriverName.\r | |
800 | \r | |
c2d9a4d2 | 801 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r |
91c68197 LG |
802 | \r |
803 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
804 | EFI_HANDLE.\r | |
805 | \r | |
806 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
807 | \r | |
808 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
809 | \r | |
810 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
811 | managing the controller specified by\r | |
812 | ControllerHandle and ChildHandle.\r | |
813 | \r | |
814 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
815 | the language specified by Language.\r | |
816 | \r | |
817 | **/\r | |
818 | EFI_STATUS\r | |
819 | EFIAPI\r | |
820 | IsaSerialComponentNameGetControllerName (\r | |
821 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
822 | IN EFI_HANDLE ControllerHandle,\r | |
823 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
824 | IN CHAR8 *Language,\r | |
825 | OUT CHAR16 **ControllerName\r | |
826 | );\r | |
827 | \r | |
828 | /**\r | |
829 | Add the component name for the serial io device\r | |
830 | \r | |
831 | @param SerialDevice A pointer to the SERIAL_DEV instance.\r | |
832 | \r | |
833 | @param IsaIo A pointer to the EFI_ISA_IO_PROTOCOL instance.\r | |
834 | \r | |
835 | **/\r | |
836 | VOID\r | |
837 | AddName (\r | |
838 | IN SERIAL_DEV *SerialDevice,\r | |
839 | IN EFI_ISA_IO_PROTOCOL *IsaIo\r | |
840 | );\r | |
841 | \r | |
637ff819 | 842 | #endif\r |