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