From e99aa5a2113a275c2e16cf049ce8e66642e6c64c Mon Sep 17 00:00:00 2001 From: mdkinney Date: Tue, 19 Sep 2006 19:14:02 +0000 Subject: [PATCH] Update Device Path Module to use PCD Feature Flags to determine of the Device Path To Text and Text To Device Path Protocols are produced or not. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1572 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/DevicePath/Dxe/DevicePath.c | 95 ++++++++++++------- .../Universal/DevicePath/Dxe/DevicePath.h | 19 +--- .../Universal/DevicePath/Dxe/DevicePath.msa | 33 ++++--- .../DevicePath/Dxe/DevicePathFromText.c | 2 +- .../DevicePath/Dxe/DevicePathToText.c | 2 +- 5 files changed, 84 insertions(+), 67 deletions(-) diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c index 78c5defe3a..6117a3245e 100644 --- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c +++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.c @@ -22,10 +22,31 @@ Abstract: #include "DevicePath.h" -DEVICE_PATH_DRIVER_PRIVATE_DATA mPrivateData; - -EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL; -EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS; +EFI_HANDLE mDevicePathHandle = NULL; + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = { + GetDevicePathSizeProtocolInterface, + DuplicateDevicePathProtocolInterface, + AppendDevicePathProtocolInterface, + AppendDeviceNodeProtocolInterface, + AppendDevicePathInstanceProtocolInterface, + GetNextDevicePathInstanceProtocolInterface, + IsDevicePathMultiInstanceProtocolInterface, + CreateDeviceNodeProtocolInterface +}; + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_TO_TEXT_PROTOCOL mDevicePathToText = { + ConvertDeviceNodeToText, + ConvertDevicePathToText +}; + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePathFromText = { + ConvertTextToDeviceNode, + ConvertTextToDevicePath +}; + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL; +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS; EFI_STATUS EFIAPI @@ -49,36 +70,40 @@ DevicePathEntryPoint ( --*/ { EFI_STATUS Status; - - mPrivateData.Signature = DEVICE_PATH_DRIVER_SIGNATURE; - - mPrivateData.DevicePathUtilities.GetDevicePathSize = GetDevicePathSizeProtocolInterface; - mPrivateData.DevicePathUtilities.DuplicateDevicePath = DuplicateDevicePathProtocolInterface; - mPrivateData.DevicePathUtilities.AppendDevicePath = AppendDevicePathProtocolInterface; - mPrivateData.DevicePathUtilities.AppendDeviceNode = AppendDeviceNodeProtocolInterface; - mPrivateData.DevicePathUtilities.AppendDevicePathInstance = AppendDevicePathInstanceProtocolInterface; - mPrivateData.DevicePathUtilities.GetNextDevicePathInstance = GetNextDevicePathInstanceProtocolInterface; - mPrivateData.DevicePathUtilities.IsDevicePathMultiInstance = IsDevicePathMultiInstanceProtocolInterface; - mPrivateData.DevicePathUtilities.CreateDeviceNode = CreateDeviceNodeProtocolInterface; - - mPrivateData.DevicePathToText.ConvertDeviceNodeToText = ConvertDeviceNodeToText; - mPrivateData.DevicePathToText.ConvertDevicePathToText = ConvertDevicePathToText; - - mPrivateData.DevicePathFromText.ConvertTextToDeviceNode = ConvertTextToDeviceNode; - mPrivateData.DevicePathFromText.ConvertTextToDevicePath = ConvertTextToDevicePath; - - mPrivateData.Handle = NULL; - - Status = gBS->InstallMultipleProtocolInterfaces ( - &mPrivateData.Handle, - &gEfiDevicePathUtilitiesProtocolGuid, - &mPrivateData.DevicePathUtilities, - &gEfiDevicePathToTextProtocolGuid, - &mPrivateData.DevicePathToText, - &gEfiDevicePathFromTextProtocolGuid, - &mPrivateData.DevicePathFromText, - NULL - ); - + + Status = EFI_UNSUPPORTED; + if (FeaturePcdGet (PcdDevicePathSupportDevicePathToText)) { + if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mDevicePathHandle, + &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities, + &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText, + &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mDevicePathHandle, + &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities, + &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText, + NULL + ); + } + } else { + if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mDevicePathHandle, + &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities, + &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &mDevicePathHandle, + &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities, + NULL + ); + } + } return Status; } diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.h b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.h index 8e9072417e..f74a65c48b 100644 --- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.h +++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.h @@ -21,23 +21,8 @@ Abstract: #ifndef _DEVICE_PATH_DRIVER_H #define _DEVICE_PATH_DRIVER_H -extern EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid; -extern EFI_GUID mEfiDevicePathMessagingSASGuid; - -#define DEVICE_PATH_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('D', 'P', 'D', 'V') - -typedef struct { - - UINT32 Signature; - EFI_HANDLE Handle; - // - // Produced protocols - // - EFI_DEVICE_PATH_UTILITIES_PROTOCOL DevicePathUtilities; - EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL DevicePathFromText; - EFI_DEVICE_PATH_TO_TEXT_PROTOCOL DevicePathToText; - -} DEVICE_PATH_DRIVER_PRIVATE_DATA; +extern const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid; +extern const EFI_GUID mEfiDevicePathMessagingSASGuid; #define MAX_CHAR 480 diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.msa b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.msa index b96ca9e4ba..541c01482d 100644 --- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.msa +++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePath.msa @@ -1,15 +1,5 @@ - - - - + DevicePath DXE_DRIVER @@ -59,6 +49,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.--> DevicePathLib + + PcdLib + DevicePath.c @@ -71,7 +64,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.--> - + gEfiDebugPortProtocolGuid @@ -109,4 +102,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.--> DevicePathEntryPoint - + + + PcdDevicePathSupportDevicePathToText + gEfiEdkModulePkgTokenSpaceGuid + FALSE + If TRUE, then the Device Path To Text Protocol should be produced by the platform + + + PcdDevicePathSupportDevicePathFromText + gEfiEdkModulePkgTokenSpaceGuid + FALSE + If TRUE, then the Device Path From Text Protocol should be produced by the platform + + + \ No newline at end of file diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c index d611b39f61..cd49359c76 100644 --- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c +++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathFromText.c @@ -2174,7 +2174,7 @@ DevPathFromTextBBS ( return (EFI_DEVICE_PATH_PROTOCOL *) Bbs; } -DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = { +GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = { {L"Pci", DevPathFromTextPci}, {L"PcCard", DevPathFromTextPcCard}, {L"MemoryMapped", DevPathFromTextMemoryMapped}, diff --git a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathToText.c b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathToText.c index f38f2ea110..25c88e07d6 100644 --- a/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathToText.c +++ b/EdkModulePkg/Universal/DevicePath/Dxe/DevicePathToText.c @@ -1255,7 +1255,7 @@ DevPathToTextNodeUnknown ( CatPrint (Str, L"?"); } -DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = { +GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = { {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci}, {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard}, {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap}, -- 2.39.2