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