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