summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2010-04-09 08:35:44 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2010-04-09 08:35:44 +0000
commit6b008b74fbc9fdef1359c3807fc5d043f34a2046 (patch)
tree138005d4d02ccb2a3135c52af9b47c9358a6e12d
parent76649bf4d80e1d2ed062846c2960292fb63de08d (diff)
downloadedk2-platforms-6b008b74fbc9fdef1359c3807fc5d043f34a2046.tar.xz
1. IsaSerialIo driver was changed to produce the flow control device path node when the remaining device path contains such node. And it will return unsupported when receiving a remaining device path only contains UART node and it’s already produced the flow control node.
2. BMM driver was enhanced to take care of the optional flow control node. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10351 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf3
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c250
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h12
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c170
4 files changed, 321 insertions, 114 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
index 1c8e762923..b47023d149 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf
@@ -52,6 +52,9 @@
UefiDriverEntryPoint
DebugLib
+[Guids]
+ gEfiUartDevicePathGuid
+
[Protocols]
gEfiIsaIoProtocolGuid ## TO_START
gEfiDevicePathProtocolGuid ## TO_START
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
index 04d6373592..b842112230 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
@@ -41,7 +41,7 @@ SERIAL_DEV gSerialDevTempate = {
NULL
},
{ // SerialMode
- SERIAL_PORT_DEFAULT_CONTROL_MASK,
+ SERIAL_PORT_SUPPORT_CONTROL_MASK,
SERIAL_PORT_DEFAULT_TIMEOUT,
FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH,
@@ -87,6 +87,51 @@ SERIAL_DEV gSerialDevTempate = {
};
/**
+ Check the device path node whether it's the Flow Control node or not.
+
+ @param[in] FlowControl The device path node to be checked.
+
+ @retval TRUE It's the Flow Control node.
+ @retval FALSE It's not.
+
+**/
+BOOLEAN
+IsUartFlowControlNode (
+ IN UART_FLOW_CONTROL_DEVICE_PATH *FlowControl
+ )
+{
+ return (BOOLEAN) (
+ (DevicePathType (FlowControl) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (FlowControl) == MSG_VENDOR_DP) &&
+ (CompareGuid (&FlowControl->Guid, &gEfiUartDevicePathGuid))
+ );
+}
+
+/**
+ Check the device path node whether it contains Flow Control node or not.
+
+ @param[in] DevicePath The device path to be checked.
+
+ @retval TRUE It contains the Flow Control node.
+ @retval FALSE It doesn't.
+
+**/
+BOOLEAN
+ContainsFlowControl (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ while (!IsDevicePathEnd (DevicePath)) {
+ if (IsUartFlowControlNode ((UART_FLOW_CONTROL_DEVICE_PATH *) DevicePath)) {
+ return TRUE;
+ }
+ DevicePath = NextDevicePathNode (DevicePath);
+ }
+
+ return FALSE;
+}
+
+/**
The user Entry Point for module IsaSerial. The user code starts with this function.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@@ -145,6 +190,11 @@ SerialControllerDriverSupported (
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_ISA_IO_PROTOCOL *IsaIo;
UART_DEVICE_PATH *UartNode;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UART_FLOW_CONTROL_DEVICE_PATH *FlowControlNode;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ UINTN EntryCount;
+ UINTN Index;
//
// Check RemainingDevicePath validation
@@ -192,8 +242,17 @@ SerialControllerDriverSupported (
if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
goto Error;
}
-
- Status = EFI_SUCCESS;
+
+ FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (UartNode);
+ if (IsUartFlowControlNode (FlowControlNode)) {
+ //
+ // If the second node is Flow Control Node,
+ // return error when it request other than hardware flow control.
+ //
+ if ((ReadUnaligned32 (&FlowControlNode->FlowControlMap) & ~UART_FLOW_CONTROL_HARDWARE) != 0) {
+ goto Error;
+ }
+ }
}
}
@@ -209,7 +268,45 @@ SerialControllerDriverSupported (
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
+ if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath is NULL or is the End of Device Path Node
+ //
+ return EFI_SUCCESS;
+ }
+ //
+ // When the driver has produced device path with flow control node but RemainingDevicePath only contains UART node,
+ // return unsupported, and vice versa.
+ //
+ Status = gBS->OpenProtocolInformation (
+ Controller,
+ &gEfiIsaIoProtocolGuid,
+ &OpenInfoBuffer,
+ &EntryCount
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < EntryCount; Index++) {
+ if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ Status = gBS->OpenProtocol (
+ OpenInfoBuffer[Index].ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &DevicePath,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (!EFI_ERROR (Status) &&
+ (ContainsFlowControl (RemainingDevicePath) ^ ContainsFlowControl (DevicePath))) {
+ Status = EFI_UNSUPPORTED;
+ }
+ break;
+ }
+ }
+ FreePool (OpenInfoBuffer);
+ return Status;
}
if (EFI_ERROR (Status)) {
@@ -295,7 +392,11 @@ SerialControllerDriverStart (
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
UINTN EntryCount;
EFI_SERIAL_IO_PROTOCOL *SerialIo;
- UART_DEVICE_PATH *UartNode;
+ UART_DEVICE_PATH *Uart;
+ UINT32 FlowControlMap;
+ UART_FLOW_CONTROL_DEVICE_PATH *FlowControl;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ UINT32 Control;
SerialDevice = NULL;
//
@@ -371,16 +472,35 @@ SerialControllerDriverStart (
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
- UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
+ Uart = (UART_DEVICE_PATH *) RemainingDevicePath;
Status = SerialIo->SetAttributes (
SerialIo,
- UartNode->BaudRate,
+ Uart->BaudRate,
SerialIo->Mode->ReceiveFifoDepth,
SerialIo->Mode->Timeout,
- (EFI_PARITY_TYPE) UartNode->Parity,
- UartNode->DataBits,
- (EFI_STOP_BITS_TYPE) UartNode->StopBits
+ (EFI_PARITY_TYPE) Uart->Parity,
+ Uart->DataBits,
+ (EFI_STOP_BITS_TYPE) Uart->StopBits
);
+
+ FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Uart);
+ if (!EFI_ERROR (Status) && IsUartFlowControlNode (FlowControl)) {
+ Status = SerialIo->GetControl (SerialIo, &Control);
+ if (!EFI_ERROR (Status)) {
+ if (ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) {
+ Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
+ } else {
+ Control &= ~EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
+ }
+ //
+ // Clear the bits that are not allowed to pass to SetControl
+ //
+ Control &= (EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
+ EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
+ EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE);
+ Status = SerialIo->SetControl (SerialIo, Control);
+ }
+ }
}
break;
}
@@ -412,6 +532,8 @@ SerialControllerDriverStart (
SerialDevice->SerialIo.Mode = &(SerialDevice->SerialMode);
SerialDevice->IsaIo = IsaIo;
SerialDevice->ParentDevicePath = ParentDevicePath;
+ FlowControl = NULL;
+ FlowControlMap = 0;
//
// Check if RemainingDevicePath is NULL,
@@ -426,6 +548,12 @@ SerialControllerDriverStart (
// that we can support.
//
CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
+ FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (RemainingDevicePath);
+ if (IsUartFlowControlNode (FlowControl)) {
+ FlowControlMap = ReadUnaligned32 (&FlowControl->FlowControlMap);
+ } else {
+ FlowControl = NULL;
+ }
}
AddName (SerialDevice, IsaIo);
@@ -435,6 +563,9 @@ SerialControllerDriverStart (
SerialDevice->BaseAddress = (UINT16) SerialDevice->IsaIo->ResourceList->ResourceItem[Index].StartRange;
}
}
+
+ SerialDevice->HardwareFlowControl = (BOOLEAN) (FlowControlMap == UART_FLOW_CONTROL_HARDWARE);
+
//
// Report status code the serial present
//
@@ -456,15 +587,28 @@ SerialControllerDriverStart (
//
// Build the device path by appending the UART node to the ParentDevicePath.
- //The Uart setings are zero here, since SetAttribute() will update them to match
+ // The Uart setings are zero here, since SetAttribute() will update them to match
// the default setings.
//
SerialDevice->DevicePath = AppendDevicePathNode (
ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&SerialDevice->UartDevicePath
+ (EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath
);
+ //
+ // Only produce the Flow Control node when remaining device path has it
+ //
+ if (FlowControl != NULL) {
+ TempDevicePath = SerialDevice->DevicePath;
+ if (TempDevicePath != NULL) {
+ SerialDevice->DevicePath = AppendDevicePathNode (
+ TempDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *) FlowControl
+ );
+ FreePool (TempDevicePath);
+ }
+ }
if (SerialDevice->DevicePath == NULL) {
- Status = EFI_DEVICE_ERROR;
+ Status = EFI_OUT_OF_RESOURCES;
goto Error;
}
@@ -968,6 +1112,7 @@ IsaSerialReset (
SERIAL_PORT_MCR Mcr;
SERIAL_PORT_FCR Fcr;
EFI_TPL Tpl;
+ UINT32 Control;
SerialDevice = SERIAL_DEV_FROM_THIS (This);
@@ -1039,9 +1184,16 @@ IsaSerialReset (
//
// Go set the current control bits
//
+ Control = 0;
+ if (SerialDevice->HardwareFlowControl) {
+ Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
+ }
+ if (SerialDevice->SoftwareLoopbackEnable) {
+ Control |= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE;
+ }
Status = This->SetControl (
This,
- This->Mode->ControlMask
+ Control
);
if (EFI_ERROR (Status)) {
@@ -1108,7 +1260,7 @@ IsaSerialSetAttributes (
UINT32 Divisor;
UINT32 Remained;
SERIAL_PORT_LCR Lcr;
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UART_DEVICE_PATH *Uart;
EFI_TPL Tpl;
SerialDevice = SERIAL_DEV_FROM_THIS (This);
@@ -1347,37 +1499,25 @@ IsaSerialSetAttributes (
SerialDevice->UartDevicePath.Parity = (UINT8) Parity;
SerialDevice->UartDevicePath.StopBits = (UINT8) StopBits;
- NewDevicePath = AppendDevicePathNode (
- SerialDevice->ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath
- );
- if (NewDevicePath == NULL) {
- gBS->RestoreTPL (Tpl);
- return EFI_DEVICE_ERROR;
- }
-
+ Status = EFI_SUCCESS;
if (SerialDevice->Handle != NULL) {
+ Uart = (UART_DEVICE_PATH *) (
+ (UINTN) SerialDevice->DevicePath
+ + GetDevicePathSize (SerialDevice->ParentDevicePath)
+ - END_DEVICE_PATH_LENGTH
+ );
+ CopyMem (Uart, &SerialDevice->UartDevicePath, sizeof (UART_DEVICE_PATH));
Status = gBS->ReinstallProtocolInterface (
SerialDevice->Handle,
&gEfiDevicePathProtocolGuid,
SerialDevice->DevicePath,
- NewDevicePath
+ SerialDevice->DevicePath
);
- if (EFI_ERROR (Status)) {
- gBS->RestoreTPL (Tpl);
- return Status;
- }
- }
-
- if (SerialDevice->DevicePath != NULL) {
- gBS->FreePool (SerialDevice->DevicePath);
}
- SerialDevice->DevicePath = NewDevicePath;
-
gBS->RestoreTPL (Tpl);
- return EFI_SUCCESS;
+ return Status;
}
/**
@@ -1397,9 +1537,11 @@ IsaSerialSetControl (
IN UINT32 Control
)
{
- SERIAL_DEV *SerialDevice;
- SERIAL_PORT_MCR Mcr;
- EFI_TPL Tpl;
+ SERIAL_DEV *SerialDevice;
+ SERIAL_PORT_MCR Mcr;
+ EFI_TPL Tpl;
+ UART_FLOW_CONTROL_DEVICE_PATH *FlowControl;
+ EFI_STATUS Status;
//
// The control bits that can be set are :
@@ -1407,13 +1549,16 @@ IsaSerialSetControl (
// EFI_SERIAL_REQUEST_TO_SEND: 0x0002 // WO
// EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE: 0x1000 // RW
// EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE: 0x2000 // RW
+ // EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE: 0x4000 // RW
//
SerialDevice = SERIAL_DEV_FROM_THIS (This);
//
// first determine the parameter is invalid
//
- if ((Control & 0xffff8ffc) != 0) {
+ if (Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
+ EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
+ EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) {
return EFI_UNSUPPORTED;
}
@@ -1448,9 +1593,32 @@ IsaSerialSetControl (
SerialDevice->SoftwareLoopbackEnable = TRUE;
}
+ Status = EFI_SUCCESS;
+ if (SerialDevice->Handle != NULL) {
+ FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) (
+ (UINTN) SerialDevice->DevicePath
+ + GetDevicePathSize (SerialDevice->ParentDevicePath)
+ - END_DEVICE_PATH_LENGTH
+ + sizeof (UART_DEVICE_PATH)
+ );
+ if (IsUartFlowControlNode (FlowControl) &&
+ ((ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) ^ SerialDevice->HardwareFlowControl)) {
+ //
+ // Flow Control setting is changed, need to reinstall device path protocol
+ //
+ WriteUnaligned32 (&FlowControl->FlowControlMap, SerialDevice->HardwareFlowControl ? UART_FLOW_CONTROL_HARDWARE : 0);
+ Status = gBS->ReinstallProtocolInterface (
+ SerialDevice->Handle,
+ &gEfiDevicePathProtocolGuid,
+ SerialDevice->DevicePath,
+ SerialDevice->DevicePath
+ );
+ }
+ }
+
gBS->RestoreTPL (Tpl);
- return EFI_SUCCESS;
+ return Status;
}
/**
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
index deb7926526..db5bd21b92 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
@@ -116,7 +116,17 @@ typedef struct {
//
#define SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH 1
#define SERIAL_PORT_DEFAULT_TIMEOUT 1000000
-#define SERIAL_PORT_DEFAULT_CONTROL_MASK 0
+#define SERIAL_PORT_SUPPORT_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \
+ EFI_SERIAL_DATA_SET_READY | \
+ EFI_SERIAL_RING_INDICATE | \
+ EFI_SERIAL_CARRIER_DETECT | \
+ EFI_SERIAL_REQUEST_TO_SEND | \
+ EFI_SERIAL_DATA_TERMINAL_READY | \
+ EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | \
+ EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE | \
+ EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE | \
+ EFI_SERIAL_OUTPUT_BUFFER_EMPTY | \
+ EFI_SERIAL_INPUT_BUFFER_EMPTY)
//
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
index c6c9915f55..e79b3f6a30 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
@@ -1,7 +1,7 @@
/** @file
handles console redirection from boot manager
-Copyright (c) 2004 - 2009, Intel Corporation. <BR>
+Copyright (c) 2004 - 2010, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -15,6 +15,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "BootMaint.h"
/**
+ Check whether the device path node is ISA Serial Node.
+
+ @param Acpi Device path node to be checked
+
+ @retval TRUE It's ISA Serial Node.
+ @retval FALSE It's NOT ISA Serial Node.
+
+**/
+BOOLEAN
+IsIsaSerialNode (
+ IN ACPI_HID_DEVICE_PATH *Acpi
+ )
+{
+ return (BOOLEAN) (
+ (DevicePathType (Acpi) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (Acpi) == ACPI_DP) &&
+ (ReadUnaligned32 (&Acpi->HID) == EISA_PNP_ID (0x0501))
+ );
+}
+
+/**
Update Com Ports attributes from DevicePath
@param DevicePath DevicePath that contains Com ports
@@ -51,20 +72,16 @@ ChangeTerminalDevicePath (
UART_DEVICE_PATH *Uart;
UART_DEVICE_PATH *Uart1;
UINTN Com;
- UINT32 Match;
BM_TERMINAL_CONTEXT *NewTerminalContext;
BM_MENU_ENTRY *NewMenuEntry;
- Match = EISA_PNP_ID (0x0501);
Node = DevicePath;
Node = NextDevicePathNode (Node);
Com = 0;
while (!IsDevicePathEnd (Node)) {
- if ((DevicePathType (Node) == ACPI_DEVICE_PATH) && (DevicePathSubType (Node) == ACPI_DP)) {
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
- if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
- CopyMem (&Com, &Acpi->UID, sizeof (UINT32));
- }
+ Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ if (IsIsaSerialNode (Acpi)) {
+ CopyMem (&Com, &Acpi->UID, sizeof (UINT32));
}
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Com);
@@ -165,20 +182,16 @@ ChangeVariableDevicePath (
ACPI_HID_DEVICE_PATH *Acpi;
UART_DEVICE_PATH *Uart;
UINTN Com;
- UINT32 Match;
BM_TERMINAL_CONTEXT *NewTerminalContext;
BM_MENU_ENTRY *NewMenuEntry;
- Match = EISA_PNP_ID (0x0501);
Node = DevicePath;
Node = NextDevicePathNode (Node);
Com = 0;
while (!IsDevicePathEnd (Node)) {
- if ((DevicePathType (Node) == ACPI_DEVICE_PATH) && (DevicePathSubType (Node) == ACPI_DP)) {
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
- if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
- CopyMem (&Com, &Acpi->UID, sizeof (UINT32));
- }
+ Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ if (IsIsaSerialNode (Acpi)) {
+ CopyMem (&Com, &Acpi->UID, sizeof (UINT32));
}
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
@@ -234,29 +247,33 @@ RetrieveUartUid (
IN OUT UINT32 *AcpiUid
)
{
- UINT32 Match;
- UINT8 *Ptr;
+ EFI_STATUS Status;
ACPI_HID_DEVICE_PATH *Acpi;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- gBS->HandleProtocol (
- Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
- );
- Ptr = (UINT8 *) DevicePath;
-
- while (*Ptr != END_DEVICE_PATH_TYPE) {
- Ptr++;
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return FALSE;
}
- Ptr = Ptr - sizeof (UART_DEVICE_PATH) - sizeof (ACPI_HID_DEVICE_PATH);
- Acpi = (ACPI_HID_DEVICE_PATH *) Ptr;
- Match = EISA_PNP_ID (0x0501);
+ Acpi = NULL;
+ for (; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
+ if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (DevicePath) == MSG_UART_DP)) {
+ break;
+ }
+ //
+ // Acpi points to the node before the Uart node
+ //
+ Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
+ }
- if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
+ if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {
if (AcpiUid != NULL) {
- *AcpiUid = Acpi->UID;
+ CopyMem (AcpiUid, &Acpi->UID, sizeof (UINT32));
}
return TRUE;
} else {
@@ -339,7 +356,6 @@ LocateSerialIo (
VOID
)
{
- UINT8 *Ptr;
UINTN Index;
UINTN Index2;
UINTN NoHandles;
@@ -347,8 +363,8 @@ LocateSerialIo (
EFI_STATUS Status;
ACPI_HID_DEVICE_PATH *Acpi;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINT32 Match;
EFI_SERIAL_IO_PROTOCOL *SerialIo;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
EFI_DEVICE_PATH_PROTOCOL *OutDevicePath;
EFI_DEVICE_PATH_PROTOCOL *InpDevicePath;
EFI_DEVICE_PATH_PROTOCOL *ErrDevicePath;
@@ -390,16 +406,19 @@ LocateSerialIo (
&gEfiDevicePathProtocolGuid,
(VOID **) &DevicePath
);
- Ptr = (UINT8 *) DevicePath;
- while (*Ptr != END_DEVICE_PATH_TYPE) {
- Ptr++;
- }
- Ptr = Ptr - sizeof (UART_DEVICE_PATH) - sizeof (ACPI_HID_DEVICE_PATH);
- Acpi = (ACPI_HID_DEVICE_PATH *) Ptr;
- Match = EISA_PNP_ID (0x0501);
+ Acpi = NULL;
+ for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
+ if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
+ break;
+ }
+ //
+ // Acpi points to the node before Uart node
+ //
+ Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ }
- if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
+ if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {
NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);
if (NewMenuEntry == NULL) {
FreePool (Handles);
@@ -547,23 +566,19 @@ UpdateComAttributeFromVariable (
ACPI_HID_DEVICE_PATH *Acpi;
UART_DEVICE_PATH *Uart;
UART_DEVICE_PATH *Uart1;
- UINT32 Match;
UINTN TerminalNumber;
BM_MENU_ENTRY *NewMenuEntry;
BM_TERMINAL_CONTEXT *NewTerminalContext;
UINTN Index;
- Match = EISA_PNP_ID (0x0501);
Node = DevicePath;
Node = NextDevicePathNode (Node);
TerminalNumber = 0;
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
while (!IsDevicePathEnd (Node)) {
- if ((DevicePathType (Node) == ACPI_DEVICE_PATH) && (DevicePathSubType (Node) == ACPI_DP)) {
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
- if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
- CopyMem (&TerminalNumber, &Acpi->UID, sizeof (UINT32));
- }
+ Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ if (IsIsaSerialNode (Acpi)) {
+ CopyMem (&TerminalNumber, &Acpi->UID, sizeof (UINT32));
}
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
@@ -837,46 +852,60 @@ IsTerminalDevicePath (
OUT UINTN *Com
)
{
- UINT8 *Ptr;
- BOOLEAN IsTerminal;
- VENDOR_DEVICE_PATH *Vendor;
- ACPI_HID_DEVICE_PATH *Acpi;
- UINT32 Match;
- EFI_GUID TempGuid;
+ BOOLEAN IsTerminal;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ VENDOR_DEVICE_PATH *Vendor;
+ UART_DEVICE_PATH *Uart;
+ ACPI_HID_DEVICE_PATH *Acpi;
IsTerminal = FALSE;
- //
- // Parse the Device Path, should be change later!!!
- //
- Ptr = (UINT8 *) DevicePath;
- while (*Ptr != END_DEVICE_PATH_TYPE) {
- Ptr++;
+ Uart = NULL;
+ Vendor = NULL;
+ Acpi = NULL;
+ for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
+ //
+ // Vendor points to the node before the End node
+ //
+ Vendor = (VENDOR_DEVICE_PATH *) Node;
+
+ if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
+ Uart = (UART_DEVICE_PATH *) Node;
+ }
+
+ if (Uart == NULL) {
+ //
+ // Acpi points to the node before the UART node
+ //
+ Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ }
}
- Ptr = Ptr - sizeof (VENDOR_DEVICE_PATH);
- Vendor = (VENDOR_DEVICE_PATH *) Ptr;
+ if (Vendor == NULL ||
+ DevicePathType (Vendor) != MESSAGING_DEVICE_PATH ||
+ DevicePathSubType (Vendor) != MSG_VENDOR_DP ||
+ Uart == NULL) {
+ return FALSE;
+ }
//
// There are four kinds of Terminal types
// check to see whether this devicepath
// is one of that type
//
- CopyMem (&TempGuid, &Vendor->Guid, sizeof (EFI_GUID));
-
- if (CompareGuid (&TempGuid, &TerminalTypeGuid[0])) {
+ if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[0])) {
*Termi = TerminalTypePcAnsi;
IsTerminal = TRUE;
} else {
- if (CompareGuid (&TempGuid, &TerminalTypeGuid[1])) {
+ if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[1])) {
*Termi = TerminalTypeVt100;
IsTerminal = TRUE;
} else {
- if (CompareGuid (&TempGuid, &TerminalTypeGuid[2])) {
+ if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[2])) {
*Termi = TerminalTypeVt100Plus;
IsTerminal = TRUE;
} else {
- if (CompareGuid (&TempGuid, &TerminalTypeGuid[3])) {
+ if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[3])) {
*Termi = TerminalTypeVtUtf8;
IsTerminal = TRUE;
} else {
@@ -890,10 +919,7 @@ IsTerminalDevicePath (
return FALSE;
}
- Ptr = Ptr - sizeof (UART_DEVICE_PATH) - sizeof (ACPI_HID_DEVICE_PATH);
- Acpi = (ACPI_HID_DEVICE_PATH *) Ptr;
- Match = EISA_PNP_ID (0x0501);
- if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
+ if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {
CopyMem (Com, &Acpi->UID, sizeof (UINT32));
} else {
return FALSE;