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