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