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