diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-16 08:28:52 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-16 08:28:52 +0000 |
commit | fb19cc2c71ba2db2106419222934fc699318e4ae (patch) | |
tree | 2cf44d997015a930e2d7da0f7af297b43195a6bf | |
parent | a6bbb98ece8b2f945cf4a9db589059bdbcdf8ab3 (diff) | |
download | edk2-fb19cc2c71ba2db2106419222934fc699318e4ae.tar.gz |
sync patch r10351, r10352, r10353, r10354, r10360 from main trunk.
1. IsaSerialIo, WinNtSerialIo, UnixSerialIo drivers were 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.
3. Update DevicePath.h to add the UART_FLOW_CONTROL_HARDWARE and UART_FLOW_CONTROL_XON_XOFF.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2008@11061 6f19259b-4bc3-4df7-8a09-765794883524
5 files changed, 422 insertions, 182 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf index 81f02ecd10..accc483ad5 100644 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf +++ b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf @@ -53,6 +53,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 cf895c8802..007b5f70c9 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.
@@ -144,46 +189,154 @@ SerialControllerDriverSupported ( EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_ISA_IO_PROTOCOL *IsaIo;
- UART_DEVICE_PATH UartNode;
+ 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;
+ BOOLEAN HasFlowControl;
//
- // Ignore the RemainingDevicePath
+ // Check RemainingDevicePath validation
//
+ if (RemainingDevicePath != NULL) {
+ //
+ // Check if RemainingDevicePath is the End of Device Path Node,
+ // if yes, go on checking other conditions
+ //
+ if (!IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // check its validation
+ //
+ Status = EFI_UNSUPPORTED;
+
+ UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
+ if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
+ UartNode->Header.SubType != MSG_UART_DP ||
+ sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UartNode)
+ ) {
+ goto Error;
+ }
+
+ if (UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {
+ goto Error;
+ }
+
+ if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {
+ goto Error;
+ }
+
+ if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {
+ goto Error;
+ }
+
+ if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {
+ goto Error;
+ }
+
+ if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {
+ goto Error;
+ }
+
+ if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
+ goto Error;
+ }
+
+ 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;
+ }
+ }
+ }
+ }
+
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ &gEfiIsaIoProtocolGuid,
+ (VOID **) &IsaIo,
This->DriverBindingHandle,
Controller,
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)) {
+ HasFlowControl = ContainsFlowControl (RemainingDevicePath);
+ if (HasFlowControl ^ ContainsFlowControl (DevicePath)) {
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+ break;
+ }
+ }
+ FreePool (OpenInfoBuffer);
+ return Status;
}
if (EFI_ERROR (Status)) {
return Status;
}
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
gBS->CloseProtocol (
Controller,
- &gEfiDevicePathProtocolGuid,
+ &gEfiIsaIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
+ //
+ // Open the EFI Device Path protocol needed to perform the supported test
+ //
Status = gBS->OpenProtocol (
Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
-
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
@@ -200,57 +353,14 @@ SerialControllerDriverSupported ( Status = EFI_UNSUPPORTED;
goto Error;
}
- //
- // Make sure RemainingDevicePath is valid
- //
- if (RemainingDevicePath != NULL) {
- Status = EFI_UNSUPPORTED;
- CopyMem (
- &UartNode,
- (UART_DEVICE_PATH *) RemainingDevicePath,
- sizeof (UART_DEVICE_PATH)
- );
- if (UartNode.Header.Type != MESSAGING_DEVICE_PATH ||
- UartNode.Header.SubType != MSG_UART_DP ||
- sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &UartNode)
- ) {
- goto Error;
- }
-
- if (UartNode.BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {
- goto Error;
- }
-
- if (UartNode.Parity < NoParity || UartNode.Parity > SpaceParity) {
- goto Error;
- }
-
- if (UartNode.DataBits < 5 || UartNode.DataBits > 8) {
- goto Error;
- }
-
- if (UartNode.StopBits < OneStopBit || UartNode.StopBits > TwoStopBits) {
- goto Error;
- }
-
- if ((UartNode.DataBits == 5) && (UartNode.StopBits == TwoStopBits)) {
- goto Error;
- }
-
- if ((UartNode.DataBits >= 6) && (UartNode.DataBits <= 8) && (UartNode.StopBits == OneFiveStopBits)) {
- goto Error;
- }
-
- Status = EFI_SUCCESS;
- }
Error:
//
- // Close the I/O Abstraction(s) used to perform the supported test
+ // Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
Controller,
- &gEfiIsaIoProtocolGuid,
+ &gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
Controller
);
@@ -281,11 +391,15 @@ SerialControllerDriverStart ( EFI_ISA_IO_PROTOCOL *IsaIo;
SERIAL_DEV *SerialDevice;
UINTN Index;
- UART_DEVICE_PATH Node;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
UINTN EntryCount;
EFI_SERIAL_IO_PROTOCOL *SerialIo;
+ UART_DEVICE_PATH *Uart;
+ UINT32 FlowControlMap;
+ UART_FLOW_CONTROL_DEVICE_PATH *FlowControl;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ UINT32 Control;
SerialDevice = NULL;
//
@@ -328,9 +442,13 @@ SerialControllerDriverStart ( if (Status == EFI_ALREADY_STARTED) {
- if (RemainingDevicePath == NULL) {
+ if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath is NULL or is the End of Device Path Node
+ //
return EFI_SUCCESS;
}
+
//
// Make sure a child handle does not already exist. This driver can only
// produce one child per serial port.
@@ -357,24 +475,54 @@ SerialControllerDriverStart ( EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
- CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
+ Uart = (UART_DEVICE_PATH *) RemainingDevicePath;
Status = SerialIo->SetAttributes (
SerialIo,
- Node.BaudRate,
+ Uart->BaudRate,
SerialIo->Mode->ReceiveFifoDepth,
SerialIo->Mode->Timeout,
- (EFI_PARITY_TYPE) Node.Parity,
- Node.DataBits,
- (EFI_STOP_BITS_TYPE) Node.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;
}
}
- gBS->FreePool (OpenInfoBuffer);
+ FreePool (OpenInfoBuffer);
return Status;
}
+
+ if (RemainingDevicePath != NULL) {
+ if (IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath is the End of Device Path Node,
+ // skip enumerate any device and return EFI_SUCESSS
+ //
+ return EFI_SUCCESS;
+ }
+ }
+
//
// Initialize the serial device instance
//
@@ -387,6 +535,29 @@ SerialControllerDriverStart ( SerialDevice->SerialIo.Mode = &(SerialDevice->SerialMode);
SerialDevice->IsaIo = IsaIo;
SerialDevice->ParentDevicePath = ParentDevicePath;
+ FlowControl = NULL;
+ FlowControlMap = 0;
+
+ //
+ // Check if RemainingDevicePath is NULL,
+ // if yes, use the values from the gSerialDevTempate as no remaining device path was
+ // passed in.
+ //
+ if (RemainingDevicePath != NULL) {
+ //
+ // If RemainingDevicePath isn't NULL,
+ // match the configuration of the RemainingDevicePath. IsHandleSupported()
+ // already checked to make sure the RemainingDevicePath contains settings
+ // 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);
@@ -395,6 +566,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
//
@@ -414,30 +588,30 @@ SerialControllerDriverStart ( goto Error;
}
- if (RemainingDevicePath != NULL) {
- //
- // Match the configuration of the RemainingDevicePath. IsHandleSupported()
- // already checked to make sure the RemainingDevicePath contains settings
- // that we can support.
- //
- CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
- } else {
- //
- // Use the values from the gSerialDevTempate as no remaining device path was
- // passed in.
- //
- }
//
- // Build the device path by appending the UART node to the ParentDevicePath
- // from the WinNtIo handle. The Uart setings are zero here, since
- // SetAttribute() will update them to match the current setings.
+ // 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 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;
}
@@ -941,6 +1115,7 @@ IsaSerialReset ( SERIAL_PORT_MCR Mcr;
SERIAL_PORT_FCR Fcr;
EFI_TPL Tpl;
+ UINT32 Control;
SerialDevice = SERIAL_DEV_FROM_THIS (This);
@@ -1012,9 +1187,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)) {
@@ -1081,7 +1263,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);
@@ -1320,37 +1502,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;
}
/**
@@ -1370,9 +1540,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 :
@@ -1380,13 +1552,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;
}
@@ -1421,9 +1596,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;
diff --git a/MdePkg/Include/Protocol/DevicePath.h b/MdePkg/Include/Protocol/DevicePath.h index 8a6f339c16..470cc24949 100644 --- a/MdePkg/Include/Protocol/DevicePath.h +++ b/MdePkg/Include/Protocol/DevicePath.h @@ -687,6 +687,9 @@ typedef struct { UINT32 FlowControlMap;
} UART_FLOW_CONTROL_DEVICE_PATH;
+#define UART_FLOW_CONTROL_HARDWARE 0x00000001
+#define UART_FLOW_CONTROL_XON_XOFF 0x00000010
+
#define DEVICE_PATH_MESSAGING_SAS EFI_SAS_DEVICE_PATH_GUID
///
/// Serial Attached SCSI (SAS) devices.
|