2 Serial driver for standard UARTS on an ISA bus.
4 Copyright (c) 2006 - 2007, 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
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.
18 // ISA Serial Driver Global Variables
20 EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver
= {
21 SerialControllerDriverSupported
,
22 SerialControllerDriverStart
,
23 SerialControllerDriverStop
,
30 SERIAL_DEV gSerialDevTempate
= {
34 SERIAL_IO_INTERFACE_REVISION
,
36 IsaSerialSetAttributes
,
44 SERIAL_PORT_DEFAULT_CONTROL_MASK
,
45 SERIAL_PORT_DEFAULT_TIMEOUT
,
46 FixedPcdGet64 (PcdUartDefaultBaudRate
), // BaudRate
47 SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH
,
48 FixedPcdGet8 (PcdUartDefaultDataBits
), // DataBits
49 FixedPcdGet8 (PcdUartDefaultParity
), // Parity
50 FixedPcdGet8 (PcdUartDefaultStopBits
) // StopBits
56 MESSAGING_DEVICE_PATH
,
59 (UINT8
) (sizeof (UART_DEVICE_PATH
)),
60 (UINT8
) ((sizeof (UART_DEVICE_PATH
)) >> 8)
64 FixedPcdGet64 (PcdUartDefaultBaudRate
),
65 FixedPcdGet8 (PcdUartDefaultDataBits
),
66 FixedPcdGet8 (PcdUartDefaultParity
),
67 FixedPcdGet8 (PcdUartDefaultStopBits
)
74 SERIAL_MAX_BUFFER_SIZE
,
80 SERIAL_MAX_BUFFER_SIZE
,
90 The user Entry Point for module IsaSerial. The user code starts with this function.
92 @param[in] ImageHandle The firmware allocated handle for the EFI image.
93 @param[in] SystemTable A pointer to the EFI System Table.
95 @retval EFI_SUCCESS The entry point is executed successfully.
96 @retval other Some error occurs when executing this entry point.
101 InitializeIsaSerial (
102 IN EFI_HANDLE ImageHandle
,
103 IN EFI_SYSTEM_TABLE
*SystemTable
109 // Install driver model protocol(s).
111 Status
= EfiLibInstallDriverBindingComponentName2 (
114 &gSerialControllerDriver
,
116 &gIsaSerialComponentName
,
117 &gIsaSerialComponentName2
119 ASSERT_EFI_ERROR (Status
);
126 Check to see if this driver supports the given controller
128 @param This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
129 @param Controller - The handle of the controller to test.
130 @param RemainingDevicePath - A pointer to the remaining portion of a device path.
132 @return EFI_SUCCESS - This driver can support the given controller
137 SerialControllerDriverSupported (
138 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
139 IN EFI_HANDLE Controller
,
140 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
145 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
146 EFI_ISA_IO_PROTOCOL
*IsaIo
;
147 UART_DEVICE_PATH UartNode
;
150 // Ignore the RemainingDevicePath
153 // Open the IO Abstraction(s) needed to perform the supported test
155 Status
= gBS
->OpenProtocol (
157 &gEfiDevicePathProtocolGuid
,
158 (VOID
**) &ParentDevicePath
,
159 This
->DriverBindingHandle
,
161 EFI_OPEN_PROTOCOL_BY_DRIVER
163 if (Status
== EFI_ALREADY_STARTED
) {
167 if (EFI_ERROR (Status
)) {
173 &gEfiDevicePathProtocolGuid
,
174 This
->DriverBindingHandle
,
178 Status
= gBS
->OpenProtocol (
180 &gEfiIsaIoProtocolGuid
,
182 This
->DriverBindingHandle
,
184 EFI_OPEN_PROTOCOL_BY_DRIVER
187 if (Status
== EFI_ALREADY_STARTED
) {
191 if (EFI_ERROR (Status
)) {
195 // Use the ISA I/O Protocol to see if Controller is standard ISA UART that
196 // can be managed by this driver.
198 Status
= EFI_SUCCESS
;
199 if (IsaIo
->ResourceList
->Device
.HID
!= EISA_PNP_ID (0x501)) {
200 Status
= EFI_UNSUPPORTED
;
204 // Make sure RemainingDevicePath is valid
206 if (RemainingDevicePath
!= NULL
) {
207 Status
= EFI_UNSUPPORTED
;
210 (UART_DEVICE_PATH
*) RemainingDevicePath
,
211 sizeof (UART_DEVICE_PATH
)
213 if (UartNode
.Header
.Type
!= MESSAGING_DEVICE_PATH
||
214 UartNode
.Header
.SubType
!= MSG_UART_DP
||
215 sizeof (UART_DEVICE_PATH
) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) &UartNode
)
220 if (UartNode
.BaudRate
> SERIAL_PORT_MAX_BAUD_RATE
) {
224 if (UartNode
.Parity
< NoParity
|| UartNode
.Parity
> SpaceParity
) {
228 if (UartNode
.DataBits
< 5 || UartNode
.DataBits
> 8) {
232 if (UartNode
.StopBits
< OneStopBit
|| UartNode
.StopBits
> TwoStopBits
) {
236 if ((UartNode
.DataBits
== 5) && (UartNode
.StopBits
== TwoStopBits
)) {
240 if ((UartNode
.DataBits
>= 6) && (UartNode
.DataBits
<= 8) && (UartNode
.StopBits
== OneFiveStopBits
)) {
244 Status
= EFI_SUCCESS
;
249 // Close the I/O Abstraction(s) used to perform the supported test
253 &gEfiIsaIoProtocolGuid
,
254 This
->DriverBindingHandle
,
262 Start to management the controller passed in
264 @param This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
265 @param Controller - The handle of the controller to test.
266 @param RemainingDevicePath - A pointer to the remaining portion of a device path.
268 @return EFI_SUCCESS - Driver is started successfully
273 SerialControllerDriverStart (
274 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
275 IN EFI_HANDLE Controller
,
276 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
281 EFI_ISA_IO_PROTOCOL
*IsaIo
;
282 SERIAL_DEV
*SerialDevice
;
284 UART_DEVICE_PATH Node
;
285 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
286 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfoBuffer
;
288 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
292 // Get the Parent Device Path
294 Status
= gBS
->OpenProtocol (
296 &gEfiDevicePathProtocolGuid
,
297 (VOID
**) &ParentDevicePath
,
298 This
->DriverBindingHandle
,
300 EFI_OPEN_PROTOCOL_BY_DRIVER
302 if (EFI_ERROR (Status
) && Status
!= EFI_ALREADY_STARTED
) {
306 // Report status code enable the serial
308 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
310 EFI_P_PC_ENABLE
| EFI_PERIPHERAL_SERIAL_PORT
,
315 // Grab the IO abstraction we need to get any work done
317 Status
= gBS
->OpenProtocol (
319 &gEfiIsaIoProtocolGuid
,
321 This
->DriverBindingHandle
,
323 EFI_OPEN_PROTOCOL_BY_DRIVER
325 if (EFI_ERROR (Status
) && Status
!= EFI_ALREADY_STARTED
) {
329 if (Status
== EFI_ALREADY_STARTED
) {
331 if (RemainingDevicePath
== NULL
) {
335 // Make sure a child handle does not already exist. This driver can only
336 // produce one child per serial port.
338 Status
= gBS
->OpenProtocolInformation (
340 &gEfiIsaIoProtocolGuid
,
344 if (EFI_ERROR (Status
)) {
348 Status
= EFI_ALREADY_STARTED
;
349 for (Index
= 0; Index
< EntryCount
; Index
++) {
350 if (OpenInfoBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) {
351 Status
= gBS
->OpenProtocol (
352 OpenInfoBuffer
[Index
].ControllerHandle
,
353 &gEfiSerialIoProtocolGuid
,
355 This
->DriverBindingHandle
,
357 EFI_OPEN_PROTOCOL_GET_PROTOCOL
359 if (!EFI_ERROR (Status
)) {
360 CopyMem (&Node
, RemainingDevicePath
, sizeof (UART_DEVICE_PATH
));
361 Status
= SerialIo
->SetAttributes (
364 SerialIo
->Mode
->ReceiveFifoDepth
,
365 SerialIo
->Mode
->Timeout
,
366 (EFI_PARITY_TYPE
) Node
.Parity
,
368 (EFI_STOP_BITS_TYPE
) Node
.StopBits
375 gBS
->FreePool (OpenInfoBuffer
);
379 // Initialize the serial device instance
381 SerialDevice
= AllocateCopyPool (sizeof (SERIAL_DEV
), &gSerialDevTempate
);
382 if (SerialDevice
== NULL
) {
383 Status
= EFI_OUT_OF_RESOURCES
;
387 SerialDevice
->SerialIo
.Mode
= &(SerialDevice
->SerialMode
);
388 SerialDevice
->IsaIo
= IsaIo
;
389 SerialDevice
->ParentDevicePath
= ParentDevicePath
;
391 ADD_SERIAL_NAME (SerialDevice
, IsaIo
);
393 for (Index
= 0; SerialDevice
->IsaIo
->ResourceList
->ResourceItem
[Index
].Type
!= EfiIsaAcpiResourceEndOfList
; Index
++) {
394 if (SerialDevice
->IsaIo
->ResourceList
->ResourceItem
[Index
].Type
== EfiIsaAcpiResourceIo
) {
395 SerialDevice
->BaseAddress
= (UINT16
) SerialDevice
->IsaIo
->ResourceList
->ResourceItem
[Index
].StartRange
;
399 // Report status code the serial present
401 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
403 EFI_P_PC_PRESENCE_DETECT
| EFI_PERIPHERAL_SERIAL_PORT
,
407 if (!IsaSerialPortPresent (SerialDevice
)) {
408 Status
= EFI_DEVICE_ERROR
;
409 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
411 EFI_P_EC_NOT_DETECTED
| EFI_PERIPHERAL_SERIAL_PORT
,
417 if (RemainingDevicePath
!= NULL
) {
419 // Match the configuration of the RemainingDevicePath. IsHandleSupported()
420 // already checked to make sure the RemainingDevicePath contains settings
421 // that we can support.
423 CopyMem (&SerialDevice
->UartDevicePath
, RemainingDevicePath
, sizeof (UART_DEVICE_PATH
));
426 // Use the values from the gSerialDevTempate as no remaining device path was
431 // Build the device path by appending the UART node to the ParentDevicePath
432 // from the WinNtIo handle. The Uart setings are zero here, since
433 // SetAttribute() will update them to match the current setings.
435 SerialDevice
->DevicePath
= AppendDevicePathNode (
437 (EFI_DEVICE_PATH_PROTOCOL
*)&SerialDevice
->UartDevicePath
439 if (SerialDevice
->DevicePath
== NULL
) {
440 Status
= EFI_DEVICE_ERROR
;
445 // Fill in Serial I/O Mode structure based on either the RemainingDevicePath or defaults.
447 SerialDevice
->SerialMode
.BaudRate
= SerialDevice
->UartDevicePath
.BaudRate
;
448 SerialDevice
->SerialMode
.DataBits
= SerialDevice
->UartDevicePath
.DataBits
;
449 SerialDevice
->SerialMode
.Parity
= SerialDevice
->UartDevicePath
.Parity
;
450 SerialDevice
->SerialMode
.StopBits
= SerialDevice
->UartDevicePath
.StopBits
;
453 // Issue a reset to initialize the COM port
455 Status
= SerialDevice
->SerialIo
.Reset (&SerialDevice
->SerialIo
);
456 if (EFI_ERROR (Status
)) {
457 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
459 EFI_P_EC_CONTROLLER_ERROR
| EFI_PERIPHERAL_SERIAL_PORT
,
465 // Install protocol interfaces for the serial device.
467 Status
= gBS
->InstallMultipleProtocolInterfaces (
468 &SerialDevice
->Handle
,
469 &gEfiDevicePathProtocolGuid
,
470 SerialDevice
->DevicePath
,
471 &gEfiSerialIoProtocolGuid
,
472 &SerialDevice
->SerialIo
,
475 if (EFI_ERROR (Status
)) {
479 // Open For Child Device
481 Status
= gBS
->OpenProtocol (
483 &gEfiIsaIoProtocolGuid
,
485 This
->DriverBindingHandle
,
486 SerialDevice
->Handle
,
487 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
491 if (EFI_ERROR (Status
)) {
494 &gEfiDevicePathProtocolGuid
,
495 This
->DriverBindingHandle
,
500 &gEfiIsaIoProtocolGuid
,
501 This
->DriverBindingHandle
,
505 if (SerialDevice
->DevicePath
) {
506 gBS
->FreePool (SerialDevice
->DevicePath
);
509 FreeUnicodeStringTable (SerialDevice
->ControllerNameTable
);
510 gBS
->FreePool (SerialDevice
);
518 Disconnect this driver with the controller, uninstall related protocol instance
520 @param This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
521 @param Controller - The handle of the controller to test.
522 @param NumberOfChildren - Number of child device.
523 @param ChildHandleBuffer - A pointer to the remaining portion of a device path.
525 @retval EFI_SUCCESS - Operation successfully
526 @retval EFI_DEVICE_ERROR - Cannot stop the driver successfully
531 SerialControllerDriverStop (
532 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
533 IN EFI_HANDLE Controller
,
534 IN UINTN NumberOfChildren
,
535 IN EFI_HANDLE
*ChildHandleBuffer
541 BOOLEAN AllChildrenStopped
;
542 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
543 SERIAL_DEV
*SerialDevice
;
544 EFI_ISA_IO_PROTOCOL
*IsaIo
;
545 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
547 Status
= gBS
->HandleProtocol (
549 &gEfiDevicePathProtocolGuid
,
550 (VOID
**) &DevicePath
554 // Report the status code disable the serial
556 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
558 EFI_P_PC_DISABLE
| EFI_PERIPHERAL_SERIAL_PORT
,
563 // Complete all outstanding transactions to Controller.
564 // Don't allow any new transaction to Controller to be started.
566 if (NumberOfChildren
== 0) {
568 // Close the bus driver
570 Status
= gBS
->CloseProtocol (
572 &gEfiIsaIoProtocolGuid
,
573 This
->DriverBindingHandle
,
577 Status
= gBS
->CloseProtocol (
579 &gEfiDevicePathProtocolGuid
,
580 This
->DriverBindingHandle
,
586 AllChildrenStopped
= TRUE
;
588 for (Index
= 0; Index
< NumberOfChildren
; Index
++) {
590 Status
= gBS
->OpenProtocol (
591 ChildHandleBuffer
[Index
],
592 &gEfiSerialIoProtocolGuid
,
594 This
->DriverBindingHandle
,
596 EFI_OPEN_PROTOCOL_GET_PROTOCOL
598 if (!EFI_ERROR (Status
)) {
600 SerialDevice
= SERIAL_DEV_FROM_THIS (SerialIo
);
602 Status
= gBS
->CloseProtocol (
604 &gEfiIsaIoProtocolGuid
,
605 This
->DriverBindingHandle
,
606 ChildHandleBuffer
[Index
]
609 Status
= gBS
->UninstallMultipleProtocolInterfaces (
610 ChildHandleBuffer
[Index
],
611 &gEfiDevicePathProtocolGuid
,
612 SerialDevice
->DevicePath
,
613 &gEfiSerialIoProtocolGuid
,
614 &SerialDevice
->SerialIo
,
617 if (EFI_ERROR (Status
)) {
620 &gEfiIsaIoProtocolGuid
,
622 This
->DriverBindingHandle
,
623 ChildHandleBuffer
[Index
],
624 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
627 if (SerialDevice
->DevicePath
) {
628 gBS
->FreePool (SerialDevice
->DevicePath
);
631 FreeUnicodeStringTable (SerialDevice
->ControllerNameTable
);
632 gBS
->FreePool (SerialDevice
);
636 if (EFI_ERROR (Status
)) {
637 AllChildrenStopped
= FALSE
;
641 if (!AllChildrenStopped
) {
642 return EFI_DEVICE_ERROR
;
649 Detect whether specific FIFO is full or not
651 @param Fifo - A pointer to the Data Structure SERIAL_DEV_FIFO
653 @return whether specific FIFO is full or not
658 IN SERIAL_DEV_FIFO
*Fifo
662 if (Fifo
->Surplus
== 0) {
670 Detect whether specific FIFO is empty or not
673 @param Fifo - A pointer to the Data Structure SERIAL_DEV_FIFO
675 @return whether specific FIFO is empty or not
680 IN SERIAL_DEV_FIFO
*Fifo
684 if (Fifo
->Surplus
== SERIAL_MAX_BUFFER_SIZE
) {
692 Add data to specific FIFO
694 @param Fifo - A pointer to the Data Structure SERIAL_DEV_FIFO
695 @param Data - the data added to FIFO
697 @retval EFI_SUCCESS - Add data to specific FIFO successfully
698 @retval EFI_OUT_OF_RESOURCE - Failed to add data because FIFO is already full
703 IN SERIAL_DEV_FIFO
*Fifo
,
709 // if FIFO full can not add data
711 if (IsaSerialFifoFull (Fifo
)) {
712 return EFI_OUT_OF_RESOURCES
;
715 // FIFO is not full can add data
717 Fifo
->Data
[Fifo
->Last
] = Data
;
720 if (Fifo
->Last
== SERIAL_MAX_BUFFER_SIZE
) {
728 Remove data from specific FIFO
730 @param Fifo - A pointer to the Data Structure SERIAL_DEV_FIFO
731 @param Data - the data removed from FIFO
733 @retval EFI_SUCCESS - Remove data from specific FIFO successfully
734 @retval EFI_OUT_OF_RESOURCE - Failed to remove data because FIFO is empty
738 IsaSerialFifoRemove (
739 IN SERIAL_DEV_FIFO
*Fifo
,
745 // if FIFO is empty, no data can remove
747 if (IsaSerialFifoEmpty (Fifo
)) {
748 return EFI_OUT_OF_RESOURCES
;
751 // FIFO is not empty, can remove data
753 *Data
= Fifo
->Data
[Fifo
->First
];
756 if (Fifo
->First
== SERIAL_MAX_BUFFER_SIZE
) {
764 Reads and writes all avaliable data.
766 @param SerialDevice - The device to flush
768 @retval EFI_SUCCESS - Data was read/written successfully.
769 @retval EFI_OUT_OF_RESOURCE - Failed because software receive FIFO is full. Note, when
770 this happens, pending writes are not done.
774 IsaSerialReceiveTransmit (
775 IN SERIAL_DEV
*SerialDevice
781 BOOLEAN ReceiveFifoFull
;
789 // Begin the read or write
791 if (SerialDevice
->SoftwareLoopbackEnable
) {
793 ReceiveFifoFull
= IsaSerialFifoFull (&SerialDevice
->Receive
);
794 if (!IsaSerialFifoEmpty (&SerialDevice
->Transmit
)) {
795 IsaSerialFifoRemove (&SerialDevice
->Transmit
, &Data
);
796 if (ReceiveFifoFull
) {
797 return EFI_OUT_OF_RESOURCES
;
800 IsaSerialFifoAdd (&SerialDevice
->Receive
, Data
);
802 } while (!IsaSerialFifoEmpty (&SerialDevice
->Transmit
));
804 ReceiveFifoFull
= IsaSerialFifoFull (&SerialDevice
->Receive
);
806 Lsr
.Data
= READ_LSR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
808 if (FeaturePcdGet (PcdNtEmulatorEnable
)) {
810 // This is required for NT to avoid a forever-spin...
811 // This would be better if READ_LSR was a polling operation
812 // that would timeout.
817 // Flush incomming data to prevent a an overrun during a long write
819 if (Lsr
.Bits
.DR
&& !ReceiveFifoFull
) {
820 ReceiveFifoFull
= IsaSerialFifoFull (&SerialDevice
->Receive
);
821 if (!ReceiveFifoFull
) {
822 if (Lsr
.Bits
.FIFOE
|| Lsr
.Bits
.OE
|| Lsr
.Bits
.PE
|| Lsr
.Bits
.FE
|| Lsr
.Bits
.BI
) {
823 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
825 EFI_P_EC_INPUT_ERROR
| EFI_PERIPHERAL_SERIAL_PORT
,
826 SerialDevice
->DevicePath
828 if (Lsr
.Bits
.FIFOE
|| Lsr
.Bits
.PE
|| Lsr
.Bits
.FE
|| Lsr
.Bits
.BI
) {
829 Data
= READ_RBR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
834 // Make sure the receive data will not be missed, Assert DTR
836 if (SerialDevice
->HardwareFlowControl
) {
837 Mcr
.Data
= READ_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
839 WRITE_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Mcr
.Data
);
842 Data
= READ_RBR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
847 if (SerialDevice
->HardwareFlowControl
) {
848 Mcr
.Data
= READ_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
850 WRITE_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Mcr
.Data
);
853 IsaSerialFifoAdd (&SerialDevice
->Receive
, Data
);
857 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
859 EFI_P_SERIAL_PORT_PC_CLEAR_BUFFER
| EFI_PERIPHERAL_SERIAL_PORT
,
860 SerialDevice
->DevicePath
867 if (Lsr
.Bits
.THRE
&& !IsaSerialFifoEmpty (&SerialDevice
->Transmit
)) {
869 // Make sure the transmit data will not be missed
871 if (SerialDevice
->HardwareFlowControl
) {
875 Mcr
.Data
= READ_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
877 WRITE_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Mcr
.Data
);
882 Msr
.Data
= READ_MSR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
883 while (!Msr
.Bits
.CTS
) {
884 gBS
->Stall (TIMEOUT_STALL_INTERVAL
);
890 Msr
.Data
= READ_MSR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
894 IsaSerialFifoRemove (&SerialDevice
->Transmit
, &Data
);
895 WRITE_THR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Data
);
899 // write the data out
901 if (!SerialDevice
->HardwareFlowControl
) {
902 IsaSerialFifoRemove (&SerialDevice
->Transmit
, &Data
);
903 WRITE_THR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Data
);
906 // Make sure the transmit data will not be missed
908 if (SerialDevice
->HardwareFlowControl
) {
912 Mcr
.Data
= READ_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
914 WRITE_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Mcr
.Data
);
917 } while (Lsr
.Bits
.THRE
&& !IsaSerialFifoEmpty (&SerialDevice
->Transmit
));
924 // Interface Functions
929 @param This - Pointer to EFI_SERIAL_IO_PROTOCOL
931 @retval EFI_SUCCESS - Reset successfully
932 @retval EFI_DEVICE_ERROR - Failed to reset
938 IN EFI_SERIAL_IO_PROTOCOL
*This
942 SERIAL_DEV
*SerialDevice
;
949 SerialDevice
= SERIAL_DEV_FROM_THIS (This
);
952 // Report the status code reset the serial
954 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
956 EFI_P_PC_RESET
| EFI_PERIPHERAL_SERIAL_PORT
,
957 SerialDevice
->DevicePath
960 Tpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
963 // Make sure DLAB is 0.
965 Lcr
.Data
= READ_LCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
967 WRITE_LCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Lcr
.Data
);
970 // Turn off all interrupts
972 Ier
.Data
= READ_IER (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
977 WRITE_IER (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Ier
.Data
);
982 Fcr
.Bits
.TRFIFOE
= 0;
983 WRITE_FCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Fcr
.Data
);
986 // Turn off loopback and disable device interrupt.
988 Mcr
.Data
= READ_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
992 WRITE_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Mcr
.Data
);
995 // Clear the scratch pad register
997 WRITE_SCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, 0);
1000 // Go set the current attributes
1002 Status
= This
->SetAttributes (
1004 This
->Mode
->BaudRate
,
1005 This
->Mode
->ReceiveFifoDepth
,
1006 This
->Mode
->Timeout
,
1007 (EFI_PARITY_TYPE
) This
->Mode
->Parity
,
1008 (UINT8
) This
->Mode
->DataBits
,
1009 (EFI_STOP_BITS_TYPE
) This
->Mode
->StopBits
1012 if (EFI_ERROR (Status
)) {
1013 gBS
->RestoreTPL (Tpl
);
1014 return EFI_DEVICE_ERROR
;
1017 // Go set the current control bits
1019 Status
= This
->SetControl (
1021 This
->Mode
->ControlMask
1024 if (EFI_ERROR (Status
)) {
1025 gBS
->RestoreTPL (Tpl
);
1026 return EFI_DEVICE_ERROR
;
1029 // for 16550A enable FIFO, 16550 disable FIFO
1031 Fcr
.Bits
.TRFIFOE
= 1;
1032 Fcr
.Bits
.RESETRF
= 1;
1033 Fcr
.Bits
.RESETTF
= 1;
1034 WRITE_FCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Fcr
.Data
);
1037 // Reset the software FIFO
1039 SerialDevice
->Receive
.First
= 0;
1040 SerialDevice
->Receive
.Last
= 0;
1041 SerialDevice
->Receive
.Surplus
= SERIAL_MAX_BUFFER_SIZE
;
1042 SerialDevice
->Transmit
.First
= 0;
1043 SerialDevice
->Transmit
.Last
= 0;
1044 SerialDevice
->Transmit
.Surplus
= SERIAL_MAX_BUFFER_SIZE
;
1046 gBS
->RestoreTPL (Tpl
);
1049 // Device reset is complete
1055 Set new attributes to a serial device
1057 @param This - Pointer to EFI_SERIAL_IO_PROTOCOL
1058 @param BaudRate - The baudrate of the serial device
1059 @param ReceiveFifoDepth - The depth of receive FIFO buffer
1060 @param Timeout - The request timeout for a single char
1061 @param Parity - The type of parity used in serial device
1062 @param DataBits - Number of databits used in serial device
1063 @param StopBits - Number of stopbits used in serial device
1065 @retval EFI_SUCCESS - The new attributes were set
1066 @retval EFI_INVALID_PARAMETERS - One or more attributes have an unsupported value
1067 @retval EFI_UNSUPPORTED - Data Bits can not set to 5 or 6
1068 @retval EFI_DEVICE_ERROR - The serial device is not functioning correctly (no return)
1073 IsaSerialSetAttributes (
1074 IN EFI_SERIAL_IO_PROTOCOL
*This
,
1076 IN UINT32 ReceiveFifoDepth
,
1078 IN EFI_PARITY_TYPE Parity
,
1080 IN EFI_STOP_BITS_TYPE StopBits
1084 SERIAL_DEV
*SerialDevice
;
1087 SERIAL_PORT_LCR Lcr
;
1088 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
1091 SerialDevice
= SERIAL_DEV_FROM_THIS (This
);
1094 // Check for default settings and fill in actual values.
1096 if (BaudRate
== 0) {
1097 BaudRate
= FixedPcdGet64 (PcdUartDefaultBaudRate
);
1100 if (ReceiveFifoDepth
== 0) {
1101 ReceiveFifoDepth
= SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH
;
1105 Timeout
= SERIAL_PORT_DEFAULT_TIMEOUT
;
1108 if (Parity
== DefaultParity
) {
1109 Parity
= (EFI_PARITY_TYPE
)FixedPcdGet8 (PcdUartDefaultParity
);
1112 if (DataBits
== 0) {
1113 DataBits
= FixedPcdGet8 (PcdUartDefaultDataBits
);
1116 if (StopBits
== DefaultStopBits
) {
1117 StopBits
= (EFI_STOP_BITS_TYPE
) FixedPcdGet8 (PcdUartDefaultStopBits
);
1120 // 5 and 6 data bits can not be verified on a 16550A UART
1121 // Return EFI_INVALID_PARAMETER if an attempt is made to use these settings.
1123 if ((DataBits
== 5) || (DataBits
== 6)) {
1124 return EFI_INVALID_PARAMETER
;
1127 // Make sure all parameters are valid
1129 if ((BaudRate
> SERIAL_PORT_MAX_BAUD_RATE
) || (BaudRate
< SERIAL_PORT_MIN_BAUD_RATE
)) {
1130 return EFI_INVALID_PARAMETER
;
1133 // 50,75,110,134,150,300,600,1200,1800,2000,2400,3600,4800,7200,9600,19200,
1134 // 38400,57600,115200
1136 if (BaudRate
< 75) {
1138 } else if (BaudRate
< 110) {
1140 } else if (BaudRate
< 134) {
1142 } else if (BaudRate
< 150) {
1144 } else if (BaudRate
< 300) {
1146 } else if (BaudRate
< 600) {
1148 } else if (BaudRate
< 1200) {
1150 } else if (BaudRate
< 1800) {
1152 } else if (BaudRate
< 2000) {
1154 } else if (BaudRate
< 2400) {
1156 } else if (BaudRate
< 3600) {
1158 } else if (BaudRate
< 4800) {
1160 } else if (BaudRate
< 7200) {
1162 } else if (BaudRate
< 9600) {
1164 } else if (BaudRate
< 19200) {
1166 } else if (BaudRate
< 38400) {
1168 } else if (BaudRate
< 57600) {
1170 } else if (BaudRate
< 115200) {
1172 } else if (BaudRate
<= SERIAL_PORT_MAX_BAUD_RATE
) {
1176 if ((ReceiveFifoDepth
< 1) || (ReceiveFifoDepth
> SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH
)) {
1177 return EFI_INVALID_PARAMETER
;
1180 if ((Timeout
< SERIAL_PORT_MIN_TIMEOUT
) || (Timeout
> SERIAL_PORT_MAX_TIMEOUT
)) {
1181 return EFI_INVALID_PARAMETER
;
1184 if ((Parity
< NoParity
) || (Parity
> SpaceParity
)) {
1185 return EFI_INVALID_PARAMETER
;
1188 if ((DataBits
< 5) || (DataBits
> 8)) {
1189 return EFI_INVALID_PARAMETER
;
1192 if ((StopBits
< OneStopBit
) || (StopBits
> TwoStopBits
)) {
1193 return EFI_INVALID_PARAMETER
;
1196 // for DataBits = 5, StopBits can not set TwoStopBits
1198 // if ((DataBits == 5) && (StopBits == TwoStopBits)) {
1199 // return EFI_INVALID_PARAMETER;
1202 // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits
1204 if ((DataBits
>= 6) && (DataBits
<= 8) && (StopBits
== OneFiveStopBits
)) {
1205 return EFI_INVALID_PARAMETER
;
1209 // Compute divisor use to program the baud rate using a round determination
1211 Divisor
= (UINT32
) DivU64x32Remainder (
1212 SERIAL_PORT_INPUT_CLOCK
,
1213 ((UINT32
) BaudRate
* 16),
1220 if ((Divisor
== 0) || (Divisor
& 0xffff0000)) {
1221 return EFI_INVALID_PARAMETER
;
1224 Tpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1227 // Compute the actual baud rate that the serial port will be programmed for.
1229 BaudRate
= SERIAL_PORT_INPUT_CLOCK
/ Divisor
/ 16;
1232 // Put serial port on Divisor Latch Mode
1234 Lcr
.Data
= READ_LCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
1236 WRITE_LCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Lcr
.Data
);
1239 // Write the divisor to the serial port
1241 WRITE_DLL (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, (UINT8
) (Divisor
& 0xff));
1242 WRITE_DLM (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, (UINT8
) ((Divisor
>> 8) & 0xff));
1245 // Put serial port back in normal mode and set remaining attributes.
1252 Lcr
.Bits
.EVENPAR
= 0;
1253 Lcr
.Bits
.STICPAR
= 0;
1258 Lcr
.Bits
.EVENPAR
= 1;
1259 Lcr
.Bits
.STICPAR
= 0;
1264 Lcr
.Bits
.EVENPAR
= 0;
1265 Lcr
.Bits
.STICPAR
= 0;
1270 Lcr
.Bits
.EVENPAR
= 1;
1271 Lcr
.Bits
.STICPAR
= 1;
1276 Lcr
.Bits
.EVENPAR
= 0;
1277 Lcr
.Bits
.STICPAR
= 1;
1289 case OneFiveStopBits
:
1300 Lcr
.Bits
.SERIALDB
= (UINT8
) ((DataBits
- 5) & 0x03);
1301 WRITE_LCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Lcr
.Data
);
1304 // Set the Serial I/O mode
1306 This
->Mode
->BaudRate
= BaudRate
;
1307 This
->Mode
->ReceiveFifoDepth
= ReceiveFifoDepth
;
1308 This
->Mode
->Timeout
= Timeout
;
1309 This
->Mode
->Parity
= Parity
;
1310 This
->Mode
->DataBits
= DataBits
;
1311 This
->Mode
->StopBits
= StopBits
;
1314 // See if Device Path Node has actually changed
1316 if (SerialDevice
->UartDevicePath
.BaudRate
== BaudRate
&&
1317 SerialDevice
->UartDevicePath
.DataBits
== DataBits
&&
1318 SerialDevice
->UartDevicePath
.Parity
== Parity
&&
1319 SerialDevice
->UartDevicePath
.StopBits
== StopBits
1321 gBS
->RestoreTPL (Tpl
);
1325 // Update the device path
1327 SerialDevice
->UartDevicePath
.BaudRate
= BaudRate
;
1328 SerialDevice
->UartDevicePath
.DataBits
= DataBits
;
1329 SerialDevice
->UartDevicePath
.Parity
= (UINT8
) Parity
;
1330 SerialDevice
->UartDevicePath
.StopBits
= (UINT8
) StopBits
;
1332 NewDevicePath
= AppendDevicePathNode (
1333 SerialDevice
->ParentDevicePath
,
1334 (EFI_DEVICE_PATH_PROTOCOL
*) &SerialDevice
->UartDevicePath
1336 if (NewDevicePath
== NULL
) {
1337 gBS
->RestoreTPL (Tpl
);
1338 return EFI_DEVICE_ERROR
;
1341 if (SerialDevice
->Handle
!= NULL
) {
1342 Status
= gBS
->ReinstallProtocolInterface (
1343 SerialDevice
->Handle
,
1344 &gEfiDevicePathProtocolGuid
,
1345 SerialDevice
->DevicePath
,
1348 if (EFI_ERROR (Status
)) {
1349 gBS
->RestoreTPL (Tpl
);
1354 if (SerialDevice
->DevicePath
) {
1355 gBS
->FreePool (SerialDevice
->DevicePath
);
1358 SerialDevice
->DevicePath
= NewDevicePath
;
1360 gBS
->RestoreTPL (Tpl
);
1368 @param This - Pointer to EFI_SERIAL_IO_PROTOCOL
1369 @param Control - Control bits that can be settable
1371 @retval EFI_SUCCESS - New Control bits were set successfully
1372 @retval EFI_UNSUPPORTED - The Control bits wanted to set are not supported
1377 IsaSerialSetControl (
1378 IN EFI_SERIAL_IO_PROTOCOL
*This
,
1382 SERIAL_DEV
*SerialDevice
;
1383 SERIAL_PORT_MCR Mcr
;
1387 // The control bits that can be set are :
1388 // EFI_SERIAL_DATA_TERMINAL_READY: 0x0001 // WO
1389 // EFI_SERIAL_REQUEST_TO_SEND: 0x0002 // WO
1390 // EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE: 0x1000 // RW
1391 // EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE: 0x2000 // RW
1393 SerialDevice
= SERIAL_DEV_FROM_THIS (This
);
1396 // first determine the parameter is invalid
1398 if (Control
& 0xffff8ffc) {
1399 return EFI_UNSUPPORTED
;
1402 Tpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1404 Mcr
.Data
= READ_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
1408 SerialDevice
->SoftwareLoopbackEnable
= FALSE
;
1409 SerialDevice
->HardwareFlowControl
= FALSE
;
1411 if (Control
& EFI_SERIAL_DATA_TERMINAL_READY
) {
1415 if (Control
& EFI_SERIAL_REQUEST_TO_SEND
) {
1419 if (Control
& EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE
) {
1423 if (Control
& EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE
) {
1424 SerialDevice
->HardwareFlowControl
= TRUE
;
1427 WRITE_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Mcr
.Data
);
1429 if (Control
& EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE
) {
1430 SerialDevice
->SoftwareLoopbackEnable
= TRUE
;
1433 gBS
->RestoreTPL (Tpl
);
1441 @param This - Pointer to EFI_SERIAL_IO_PROTOCOL
1442 @param Control - Control signals of the serial device
1444 @retval EFI_SUCCESS - Get Control signals successfully
1449 IsaSerialGetControl (
1450 IN EFI_SERIAL_IO_PROTOCOL
*This
,
1454 SERIAL_DEV
*SerialDevice
;
1455 SERIAL_PORT_MSR Msr
;
1456 SERIAL_PORT_MCR Mcr
;
1459 Tpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1461 SerialDevice
= SERIAL_DEV_FROM_THIS (This
);
1466 // Read the Modem Status Register
1468 Msr
.Data
= READ_MSR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
1471 *Control
|= EFI_SERIAL_CLEAR_TO_SEND
;
1475 *Control
|= EFI_SERIAL_DATA_SET_READY
;
1479 *Control
|= EFI_SERIAL_RING_INDICATE
;
1483 *Control
|= EFI_SERIAL_CARRIER_DETECT
;
1486 // Read the Modem Control Register
1488 Mcr
.Data
= READ_MCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
1490 if (Mcr
.Bits
.DTRC
) {
1491 *Control
|= EFI_SERIAL_DATA_TERMINAL_READY
;
1495 *Control
|= EFI_SERIAL_REQUEST_TO_SEND
;
1499 *Control
|= EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE
;
1502 if (SerialDevice
->HardwareFlowControl
) {
1503 *Control
|= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE
;
1506 // See if the Transmit FIFO is empty
1508 IsaSerialReceiveTransmit (SerialDevice
);
1510 if (IsaSerialFifoEmpty (&SerialDevice
->Transmit
)) {
1511 *Control
|= EFI_SERIAL_OUTPUT_BUFFER_EMPTY
;
1514 // See if the Receive FIFO is empty.
1516 IsaSerialReceiveTransmit (SerialDevice
);
1518 if (IsaSerialFifoEmpty (&SerialDevice
->Receive
)) {
1519 *Control
|= EFI_SERIAL_INPUT_BUFFER_EMPTY
;
1522 if (SerialDevice
->SoftwareLoopbackEnable
) {
1523 *Control
|= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE
;
1526 gBS
->RestoreTPL (Tpl
);
1532 Write the specified number of bytes to serial device
1534 @param This - Pointer to EFI_SERIAL_IO_PROTOCOL
1535 @param BufferSize - On input the size of Buffer, on output the amount of
1536 data actually written
1537 @param Buffer - The buffer of data to write
1539 @retval EFI_SUCCESS - The data were written successfully
1540 @retval EFI_DEVICE_ERROR - The device reported an error
1541 @retval EFI_TIMEOUT - The write operation was stopped due to timeout
1547 IN EFI_SERIAL_IO_PROTOCOL
*This
,
1548 IN OUT UINTN
*BufferSize
,
1552 SERIAL_DEV
*SerialDevice
;
1559 SerialDevice
= SERIAL_DEV_FROM_THIS (This
);
1563 if (*BufferSize
== 0) {
1568 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
1570 EFI_P_EC_OUTPUT_ERROR
| EFI_PERIPHERAL_SERIAL_PORT
,
1571 SerialDevice
->DevicePath
1574 return EFI_DEVICE_ERROR
;
1577 Tpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1579 CharBuffer
= (UINT8
*) Buffer
;
1581 for (Index
= 0; Index
< *BufferSize
; Index
++) {
1582 IsaSerialFifoAdd (&SerialDevice
->Transmit
, CharBuffer
[Index
]);
1584 while (IsaSerialReceiveTransmit (SerialDevice
) != EFI_SUCCESS
|| !IsaSerialFifoEmpty (&SerialDevice
->Transmit
)) {
1586 // Unsuccessful write so check if timeout has expired, if not,
1587 // stall for a bit, increment time elapsed, and try again
1589 if (Elapsed
>= This
->Mode
->Timeout
) {
1590 *BufferSize
= ActualWrite
;
1591 gBS
->RestoreTPL (Tpl
);
1595 gBS
->Stall (TIMEOUT_STALL_INTERVAL
);
1597 Elapsed
+= TIMEOUT_STALL_INTERVAL
;
1602 // Successful write so reset timeout
1607 gBS
->RestoreTPL (Tpl
);
1613 Read the specified number of bytes from serial device
1615 @param This - Pointer to EFI_SERIAL_IO_PROTOCOL
1616 @param BufferSize - On input the size of Buffer, on output the amount of
1617 data returned in buffer
1618 @param Buffer - The buffer to return the data into
1620 @retval EFI_SUCCESS - The data were read successfully
1621 @retval EFI_DEVICE_ERROR - The device reported an error
1622 @retval EFI_TIMEOUT - The read operation was stopped due to timeout
1628 IN EFI_SERIAL_IO_PROTOCOL
*This
,
1629 IN OUT UINTN
*BufferSize
,
1633 SERIAL_DEV
*SerialDevice
;
1640 SerialDevice
= SERIAL_DEV_FROM_THIS (This
);
1643 if (*BufferSize
== 0) {
1648 return EFI_DEVICE_ERROR
;
1651 Tpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1653 Status
= IsaSerialReceiveTransmit (SerialDevice
);
1655 if (EFI_ERROR (Status
)) {
1658 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
1660 EFI_P_EC_INPUT_ERROR
| EFI_PERIPHERAL_SERIAL_PORT
,
1661 SerialDevice
->DevicePath
1664 gBS
->RestoreTPL (Tpl
);
1666 return EFI_DEVICE_ERROR
;
1669 CharBuffer
= (UINT8
*) Buffer
;
1670 for (Index
= 0; Index
< *BufferSize
; Index
++) {
1671 while (IsaSerialFifoRemove (&SerialDevice
->Receive
, &(CharBuffer
[Index
])) != EFI_SUCCESS
) {
1673 // Unsuccessful read so check if timeout has expired, if not,
1674 // stall for a bit, increment time elapsed, and try again
1675 // Need this time out to get conspliter to work.
1677 if (Elapsed
>= This
->Mode
->Timeout
) {
1678 *BufferSize
= Index
;
1679 gBS
->RestoreTPL (Tpl
);
1683 gBS
->Stall (TIMEOUT_STALL_INTERVAL
);
1684 Elapsed
+= TIMEOUT_STALL_INTERVAL
;
1686 Status
= IsaSerialReceiveTransmit (SerialDevice
);
1687 if (Status
== EFI_DEVICE_ERROR
) {
1688 *BufferSize
= Index
;
1689 gBS
->RestoreTPL (Tpl
);
1690 return EFI_DEVICE_ERROR
;
1694 // Successful read so reset timeout
1699 IsaSerialReceiveTransmit (SerialDevice
);
1701 gBS
->RestoreTPL (Tpl
);
1707 Use scratchpad register to test if this serial port is present
1709 @param SerialDevice - Pointer to serial device structure
1711 @return if this serial port is present
1714 IsaSerialPortPresent (
1715 IN SERIAL_DEV
*SerialDevice
1727 Temp
= READ_SCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
);
1728 WRITE_SCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, 0xAA);
1730 if (READ_SCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
) != 0xAA) {
1731 if (!FeaturePcdGet (PcdNtEmulatorEnable
)) {
1736 WRITE_SCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, 0x55);
1738 if (READ_SCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
) != 0x55) {
1739 if (!FeaturePcdGet (PcdNtEmulatorEnable
)) {
1746 WRITE_SCR (SerialDevice
->IsaIo
, SerialDevice
->BaseAddress
, Temp
);
1751 Use IsaIo protocol to read serial port
1753 @param IsaIo - Pointer to EFI_ISA_IO_PROTOCOL instance
1754 @param BaseAddress - Serial port register group base address
1755 @param Offset - Offset in register group
1757 @return Data read from serial port
1762 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
1763 IN UINT16 BaseAddress
,
1770 // Use IsaIo to access IO
1775 BaseAddress
+ Offset
,
1783 Use IsaIo protocol to write serial port
1785 @param IsaIo - Pointer to EFI_ISA_IO_PROTOCOL instance
1786 @param BaseAddress - Serial port register group base address
1787 @param Offset - Offset in register group
1788 @param Data - data which is to be written to some serial port register
1792 IsaSerialWritePort (
1793 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
1794 IN UINT16 BaseAddress
,
1800 // Use IsaIo to access IO
1805 BaseAddress
+ Offset
,