/** @file\r
Serial driver for PCI or SIO UARTS.\r
\r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
Check the device path node whether it's the Flow Control node or not.\r
\r
@param[in] FlowControl The device path node to be checked.\r
- \r
+\r
@retval TRUE It's the Flow Control node.\r
@retval FALSE It's not.\r
\r
/**\r
The user Entry Point for module PciSioSerial. The user code starts with this function.\r
\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
@param[in] SystemTable A pointer to the EFI System Table.\r
- \r
+\r
@retval EFI_SUCCESS The entry point is executed successfully.\r
@retval other Some error occurs when executing this entry point.\r
\r
if (EFI_ERROR (Status)) {\r
Status = IsPciSerialController (Controller);\r
}\r
- return Status; \r
+ return Status;\r
}\r
\r
/**\r
// For PCI serial device, use the information from PCD\r
//\r
if (PciSerialParameter != NULL) {\r
- BarIndex = (PciSerialParameter->BarIndex == PCI_BAR_ALL) ? 0 : PciSerialParameter->BarIndex;\r
+ BarIndex = (PciSerialParameter->BarIndex == MAX_UINT8) ? 0 : PciSerialParameter->BarIndex;\r
Offset = PciSerialParameter->Offset;\r
if (PciSerialParameter->RegisterStride != 0) {\r
SerialDevice->RegisterStride = PciSerialParameter->RegisterStride;\r
ControllerNumber = 0;\r
ContainsControllerNode = FALSE;\r
SerialDevices = GetChildSerialDevices (Controller, IoProtocolGuid, &SerialDeviceCount);\r
- //\r
- // If the SerialIo instance specified by RemainingDevicePath is already created,\r
- // update the attributes/control.\r
- //\r
- if ((SerialDeviceCount != 0) && (RemainingDevicePath != NULL)) {\r
- Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode (RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);\r
- for (Index = 0; Index < SerialDeviceCount; Index++) {\r
- ASSERT ((SerialDevices != NULL) && (SerialDevices[Index] != NULL));\r
- if ((!SerialDevices[Index]->ContainsControllerNode && !ContainsControllerNode) ||\r
- (SerialDevices[Index]->ContainsControllerNode && ContainsControllerNode && SerialDevices[Index]->Instance == ControllerNumber)\r
- ) {\r
- SerialIo = &SerialDevices[Index]->SerialIo;\r
- Status = EFI_INVALID_PARAMETER;\r
- //\r
- // Pass NULL ActualBaudRate to VerifyUartParameters to disallow baudrate degrade.\r
- // DriverBindingStart() shouldn't create a handle with different UART device path.\r
- //\r
- if (VerifyUartParameters (SerialDevices[Index]->ClockRate, Uart->BaudRate, Uart->DataBits,\r
- (EFI_PARITY_TYPE) Uart->Parity, (EFI_STOP_BITS_TYPE) Uart->StopBits, NULL, NULL)) {\r
- Status = SerialIo->SetAttributes (\r
- SerialIo,\r
- Uart->BaudRate,\r
- SerialIo->Mode->ReceiveFifoDepth,\r
- SerialIo->Mode->Timeout,\r
- (EFI_PARITY_TYPE) Uart->Parity,\r
- Uart->DataBits,\r
- (EFI_STOP_BITS_TYPE) Uart->StopBits\r
- );\r
- }\r
- FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Uart);\r
- if (!EFI_ERROR (Status) && IsUartFlowControlDevicePathNode (FlowControl)) {\r
- Status = SerialIo->GetControl (SerialIo, &Control);\r
- if (!EFI_ERROR (Status)) {\r
- if (ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) {\r
- Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
- } else {\r
- Control &= ~EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
+\r
+ if (SerialDeviceCount != 0) {\r
+ if (RemainingDevicePath == NULL) {\r
+ //\r
+ // If the SerialIo instance is already created, NULL as RemainingDevicePath is treated\r
+ // as to create the same SerialIo instance.\r
+ //\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ //\r
+ // Update the attributes/control of the SerialIo instance specified by RemainingDevicePath.\r
+ //\r
+ Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode (RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);\r
+ for (Index = 0; Index < SerialDeviceCount; Index++) {\r
+ ASSERT ((SerialDevices != NULL) && (SerialDevices[Index] != NULL));\r
+ if ((!SerialDevices[Index]->ContainsControllerNode && !ContainsControllerNode) ||\r
+ (SerialDevices[Index]->ContainsControllerNode && ContainsControllerNode && SerialDevices[Index]->Instance == ControllerNumber)\r
+ ) {\r
+ SerialIo = &SerialDevices[Index]->SerialIo;\r
+ Status = EFI_INVALID_PARAMETER;\r
+ //\r
+ // Pass NULL ActualBaudRate to VerifyUartParameters to disallow baudrate degrade.\r
+ // DriverBindingStart() shouldn't create a handle with different UART device path.\r
+ //\r
+ if (VerifyUartParameters (SerialDevices[Index]->ClockRate, Uart->BaudRate, Uart->DataBits,\r
+ (EFI_PARITY_TYPE) Uart->Parity, (EFI_STOP_BITS_TYPE) Uart->StopBits, NULL, NULL)) {\r
+ Status = SerialIo->SetAttributes (\r
+ SerialIo,\r
+ Uart->BaudRate,\r
+ SerialIo->Mode->ReceiveFifoDepth,\r
+ SerialIo->Mode->Timeout,\r
+ (EFI_PARITY_TYPE) Uart->Parity,\r
+ Uart->DataBits,\r
+ (EFI_STOP_BITS_TYPE) Uart->StopBits\r
+ );\r
+ }\r
+ FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Uart);\r
+ if (!EFI_ERROR (Status) && IsUartFlowControlDevicePathNode (FlowControl)) {\r
+ Status = SerialIo->GetControl (SerialIo, &Control);\r
+ if (!EFI_ERROR (Status)) {\r
+ if (ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) {\r
+ Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
+ } else {\r
+ Control &= ~EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;\r
+ }\r
+ //\r
+ // Clear the bits that are not allowed to pass to SetControl\r
+ //\r
+ Control &= (EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |\r
+ EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |\r
+ EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE);\r
+ Status = SerialIo->SetControl (SerialIo, Control);\r
}\r
- //\r
- // Clear the bits that are not allowed to pass to SetControl\r
- //\r
- Control &= (EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |\r
- EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |\r
- EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE);\r
- Status = SerialIo->SetControl (SerialIo, Control);\r
}\r
+ break;\r
}\r
- break;\r
}\r
- }\r
- if (Index != SerialDeviceCount) {\r
- //\r
- // Directly return if the SerialIo instance specified by RemainingDevicePath is found and updated.\r
- // Otherwise continue to create the instance specified by RemainingDevicePath.\r
- //\r
- if (SerialDevices != NULL) {\r
- FreePool (SerialDevices);\r
+ if (Index != SerialDeviceCount) {\r
+ //\r
+ // Directly return if the SerialIo instance specified by RemainingDevicePath is found and updated.\r
+ // Otherwise continue to create the instance specified by RemainingDevicePath.\r
+ //\r
+ if (SerialDevices != NULL) {\r
+ FreePool (SerialDevices);\r
+ }\r
+ return Status;\r
}\r
- return Status;\r
}\r
}\r
\r
&Supports\r
);\r
if (!EFI_ERROR (Status)) {\r
- Supports &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY;\r
+ Supports &= (UINT64)(EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY);\r
Status = ParentIo.PciIo->Attributes (\r
ParentIo.PciIo,\r
EfiPciIoAttributeOperationEnable,\r