summaryrefslogtreecommitdiff
path: root/UnixPkg
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-14 08:55:03 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-14 08:55:03 +0000
commitaf4a63857cd189964cc2c6b53b54483efaba78a3 (patch)
tree791e8df39b79520e7e3c7cbb9bb33bc2d0bb89c5 /UnixPkg
parent0cd118f7799602a88a5feb8ff1ef3e011a04b8ad (diff)
downloadedk2-platforms-af4a63857cd189964cc2c6b53b54483efaba78a3.tar.xz
updated the Bus Driver that is able to create all or one of its child handles on each call to Start() not to create new child handle if RemainingDeviepath is the End of Device Path Node, per UEFI 2.3.
The others changes include: 1. Check RemainingDevicePath at beginning of Supported(), make sure it has been verified before Start() is called. 2. Check IO protocol firstly rather than EfiDevicePathProtocolGuid, reduce the times entering into Start() function because EfiDevicePathProtocolGuid existed on most of handle. 3. If no any child device is created on last time, and RemainingDevicePath is valid Uart Devcie path, go on creating child device handle based on this RemainingDevicePath. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9262 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UnixPkg')
-rw-r--r--UnixPkg/UnixBusDriverDxe/UnixBusDriver.c86
-rw-r--r--UnixPkg/UnixSerialIoDxe/UnixSerialIo.c185
2 files changed, 173 insertions, 98 deletions
diff --git a/UnixPkg/UnixBusDriverDxe/UnixBusDriver.c b/UnixPkg/UnixBusDriverDxe/UnixBusDriver.c
index 64f0245fc7..a7be30c385 100644
--- a/UnixPkg/UnixBusDriverDxe/UnixBusDriver.c
+++ b/UnixPkg/UnixBusDriverDxe/UnixBusDriver.c
@@ -1,6 +1,6 @@
/*+++
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2009, Intel Corporation
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
@@ -186,20 +186,30 @@ Returns:
// it is a legal Device Path Node for this bus driver's children.
//
if (RemainingDevicePath != NULL) {
- if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
- RemainingDevicePath->SubType != HW_VENDOR_DP ||
- DevicePathNodeLength(RemainingDevicePath) != sizeof(UNIX_VENDOR_DEVICE_PATH_NODE)) {
- return EFI_UNSUPPORTED;
- }
-
- for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {
- if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {
- break;
+ //
+ // 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
+ //
+ if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||
+ RemainingDevicePath->SubType != HW_VENDOR_DP ||
+ DevicePathNodeLength(RemainingDevicePath) != sizeof(UNIX_VENDOR_DEVICE_PATH_NODE)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {
+ if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {
+ break;
+ }
+ }
+
+ if (Index >= UNIX_PCD_ARRAY_SIZE) {
+ return EFI_UNSUPPORTED;
}
- }
-
- if (Index >= UNIX_PCD_ARRAY_SIZE) {
- return EFI_UNSUPPORTED;
}
}
@@ -208,8 +218,8 @@ Returns:
//
Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **)&ParentDevicePath,
+ &gEfiUnixThunkProtocolGuid,
+ (VOID **)&UnixThunk,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -222,17 +232,23 @@ Returns:
return Status;
}
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
gBS->CloseProtocol (
ControllerHandle,
- &gEfiDevicePathProtocolGuid,
+ &gEfiUnixThunkProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
+ //
+ // Open the EFI Device Path protocol needed to perform the supported test
+ //
Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiUnixThunkProtocolGuid,
- (VOID **)&UnixThunk,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -253,12 +269,12 @@ Returns:
Status = EFI_UNSUPPORTED;
}
- //
- // 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 (
ControllerHandle,
- &gEfiUnixThunkProtocolGuid,
+ &gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
@@ -414,15 +430,25 @@ Returns:
CreateDevice = TRUE;
if (RemainingDevicePath != NULL) {
CreateDevice = FALSE;
- Node = (UNIX_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
- if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
- Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
- DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)
- ) {
- if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&
- Node->Instance == Count
+ //
+ // Check if RemainingDevicePath is the End of Device Path Node,
+ // if yes, don't create any child device
+ //
+ if (!IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // check its validation
+ //
+ Node = (UNIX_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;
+ if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&
+ Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&
+ DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)
) {
- CreateDevice = TRUE;
+ if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&
+ Node->Instance == Count
+ ) {
+ CreateDevice = TRUE;
+ }
}
}
}
diff --git a/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c b/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c
index edbfd0ad13..ff9bced4e9 100644
--- a/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c
+++ b/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c
@@ -223,12 +223,53 @@ Returns:
UART_DEVICE_PATH *UartNode;
//
+ // 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 ||
+ DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {
+ goto Error;
+ }
+ if (UartNode->BaudRate < 0 || 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;
+ }
+ }
+ }
+
+ //
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&ParentDevicePath,
+ &gEfiUnixIoProtocolGuid,
+ (VOID**)&UnixIo,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -241,17 +282,23 @@ Returns:
return Status;
}
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
gBS->CloseProtocol (
Handle,
- &gEfiDevicePathProtocolGuid,
+ &gEfiUnixIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
+ //
+ // Open the EFI Device Path protocol needed to perform the supported test
+ //
Status = gBS->OpenProtocol (
Handle,
- &gEfiUnixIoProtocolGuid,
- (VOID**)&UnixIo,
+ &gEfiDevicePathProtocolGuid,
+ (VOID**)&ParentDevicePath,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -265,6 +312,16 @@ Returns:
}
//
+ // Close protocol, don't use device path protocol in the Support() function
+ //
+ gBS->CloseProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Handle
+ );
+
+ //
// Make sure that the Unix Thunk Protocol is valid
//
if (UnixIo->UnixThunk->Signature != EFI_UNIX_THUNK_PROTOCOL_SIGNATURE) {
@@ -280,46 +337,9 @@ Returns:
goto Error;
}
- if (RemainingDevicePath != NULL) {
- Status = EFI_UNSUPPORTED;
- UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
- if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
- UartNode->Header.SubType != MSG_UART_DP ||
- DevicePathNodeLength((EFI_DEVICE_PATH_PROTOCOL *)UartNode) != sizeof(UART_DEVICE_PATH)) {
- goto Error;
- }
- if (UartNode->BaudRate < 0 || 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;
- }
+ return EFI_SUCCESS;
Error:
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
- gBS->CloseProtocol (
- Handle,
- &gEfiUnixIoProtocolGuid,
- This->DriverBindingHandle,
- Handle
- );
-
return Status;
}
@@ -353,6 +373,7 @@ Returns:
UINTN Index;
EFI_SERIAL_IO_PROTOCOL *SerialIo;
CHAR8 AsciiDevName[1024];
+ UART_DEVICE_PATH *UartNode;
DEBUG ((EFI_D_INFO, "SerialIo drive binding start!\r\n"));
Private = NULL;
@@ -396,7 +417,10 @@ Returns:
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;
}
@@ -426,15 +450,15 @@ Returns:
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
- CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
+ UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
Status = SerialIo->SetAttributes (
SerialIo,
- Node.BaudRate,
+ UartNode->BaudRate,
SerialIo->Mode->ReceiveFifoDepth,
SerialIo->Mode->Timeout,
- Node.Parity,
- Node.DataBits,
- Node.StopBits
+ UartNode->Parity,
+ UartNode->DataBits,
+ UartNode->StopBits
);
}
break;
@@ -442,7 +466,47 @@ Returns:
}
FreePool (OpenInfoBuffer);
- return Status;
+ if (Index < EntryCount) {
+ //
+ // If gEfiUnixIoProtocolGuid is opened by one child device, return
+ //
+ return Status;
+ }
+ //
+ // If gEfiUnixIoProtocolGuid is not opened by any child device,
+ // go further to create child device handle based on RemainingDevicePath
+ //
+ }
+
+ if (RemainingDevicePath == NULL) {
+ //
+ // Build the device path by appending the UART node to the ParentDevicePath
+ // from the UnixIo handle. The Uart setings are zero here, since
+ // SetAttribute() will update them to match the default setings.
+ //
+ ZeroMem (&Node, sizeof (UART_DEVICE_PATH));
+ Node.Header.Type = MESSAGING_DEVICE_PATH;
+ Node.Header.SubType = MSG_UART_DP;
+ SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Node, sizeof (UART_DEVICE_PATH));
+
+ } else if (!IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // only scan the specified device by RemainingDevicePath
+ //
+ //
+ // Match the configuration of the RemainingDevicePath. IsHandleSupported()
+ // already checked to make sure the RemainingDevicePath contains settings
+ // that we can support.
+ //
+ CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
+
+ } else {
+ //
+ // If RemainingDevicePath is the End of Device Path Node,
+ // skip enumerate any device and return EFI_SUCESSS
+ //
+ return EFI_SUCCESS;
}
//
@@ -486,6 +550,8 @@ Returns:
Private->Fifo.Last = 0;
Private->Fifo.Surplus = SERIAL_MAX_BUFFER_SIZE;
+ CopyMem (&Private->UartDevicePath, &Node, sizeof (UART_DEVICE_PATH));
+
AddUnicodeString (
"eng",
gUnixSerialIoComponentName.SupportedLanguages,
@@ -502,24 +568,7 @@ Returns:
Private->SerialIo.Read = UnixSerialIoRead;
Private->SerialIo.Mode = &Private->SerialIoMode;
- if (RemainingDevicePath != NULL) {
- //
- // Match the configuration of the RemainingDevicePath. IsHandleSupported()
- // already checked to make sure the RemainingDevicePath contains settings
- // that we can support.
- //
- CopyMem (&Private->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
- } else {
- //
- // Build the device path by appending the UART node to the ParentDevicePath
- // from the UnixIo handle. The Uart setings are zero here, since
- // SetAttribute() will update them to match the default setings.
- //
- ZeroMem (&Private->UartDevicePath, sizeof (UART_DEVICE_PATH));
- Private->UartDevicePath.Header.Type = MESSAGING_DEVICE_PATH;
- Private->UartDevicePath.Header.SubType = MSG_UART_DP;
- SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &Private->UartDevicePath, sizeof (UART_DEVICE_PATH));
- }
+
//
// Build the device path by appending the UART node to the ParentDevicePath