From b6349c053751cfbcd026110db5864a3ce789bd65 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 24 Feb 2009 08:33:03 +0000 Subject: Change directory name PlatformDriOverride to PlatformDriOverrideDxe. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7643 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/MdeModulePkg.dsc | 2 +- .../PlatformDriOverrideDxe/PlatformDriOverride.c | 212 +++++++++++++++++++++ .../PlatformDriOverrideDxe.inf | 49 +++++ .../PlatformDriverOverride/PlatformDriOverride.c | 212 --------------------- .../PlatformDriOverrideDxe.inf | 49 ----- 5 files changed, 262 insertions(+), 262 deletions(-) create mode 100644 MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c create mode 100644 MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf delete mode 100644 MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverride.c delete mode 100644 MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe.inf (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 7c69fa25e4..f04da20264 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -338,7 +338,7 @@ MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PcatSingleSegmentPciCfg2Pei.inf MdeModulePkg/Universal/PCD/Dxe/Pcd.inf MdeModulePkg/Universal/PCD/Pei/Pcd.inf - MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf + MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf MdeModulePkg/Application/PlatOverMngr/PlatOverMngr.inf MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c new file mode 100644 index 0000000000..64e9a4d64d --- /dev/null +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c @@ -0,0 +1,212 @@ +/** @file + +Copyright (c) 2007 - 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include + +LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase); +BOOLEAN mEnvironmentVariableRead = FALSE; +EFI_HANDLE mCallerImageHandle = NULL; + +/** + Retrieves the image handle of the platform override driver for a controller in the system. + + @param This A pointer to the + EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance. + @param ControllerHandle The device handle of the controller to check if a + driver override exists. + @param DriverImageHandle On input, a pointer to the previous driver image + handle returned by GetDriver(). On output, a + pointer to the next driver image handle. Passing + in a NULL, will return the first driver image + handle for ControllerHandle. + + @retval EFI_SUCCESS The driver override for ControllerHandle was + returned in DriverImageHandle. + @retval EFI_NOT_FOUND A driver override for ControllerHandle was not + found. + @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not a + valid handle. DriverImageHandle is not a handle + that was returned on a previous call to + GetDriver(). + +**/ +EFI_STATUS +EFIAPI +GetDriver ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT EFI_HANDLE *DriverImageHandle + ) +{ + EFI_STATUS Status; + + // + // Check that ControllerHandle is a valid handle + // + if (ControllerHandle == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Read the environment variable(s) that contain the override mappings from Controller Device Path to + // a set of Driver Device Paths, and initialize in memory database of the overrides that map Controller + // Device Paths to an ordered set of Driver Device Paths and Driver Handles. This action is only performed + // once and finished in first call. + // + if (!mEnvironmentVariableRead) { + mEnvironmentVariableRead = TRUE; + + Status = InitOverridesMapping (&mMappingDataBase); + if (EFI_ERROR (Status)){ + DEBUG ((DEBUG_ERROR, "The status to Get Platform Driver Override Variable is %r\n", Status)); + InitializeListHead (&mMappingDataBase); + return EFI_NOT_FOUND; + } + } + + // + // if the environment variable does not exist, just return not found + // + if (IsListEmpty (&mMappingDataBase)) { + return EFI_NOT_FOUND; + } + + return GetDriverFromMapping ( + ControllerHandle, + DriverImageHandle, + &mMappingDataBase, + mCallerImageHandle + ); +} + +/** + Retrieves the device path of the platform override driver for a controller in the system. + This driver doesn't support this API. + + @param This A pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_ + PROTOCOL instance. + @param ControllerHandle The device handle of the controller to check if a driver override + exists. + @param DriverImagePath On input, a pointer to the previous driver device path returned by + GetDriverPath(). On output, a pointer to the next driver + device path. Passing in a pointer to NULL, will return the first + driver device path for ControllerHandle. + + @retval EFI_UNSUPPORTED +**/ +EFI_STATUS +EFIAPI +GetDriverPath ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath + ) +{ + return EFI_UNSUPPORTED; +} + + +/** + Used to associate a driver image handle with a device path that was returned on a prior call to the + GetDriverPath() service. This driver image handle will then be available through the + GetDriver() service. This driver doesn't support this API. + + @param This A pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_ + PROTOCOL instance. + @param ControllerHandle The device handle of the controller. + @param DriverImagePath A pointer to the driver device path that was returned in a prior + call to GetDriverPath(). + @param DriverImageHandle The driver image handle that was returned by LoadImage() + when the driver specified by DriverImagePath was loaded + into memory. + + @retval EFI_UNSUPPORTED +**/ +EFI_STATUS +EFIAPI +DriverLoaded ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *DriverImagePath, + IN EFI_HANDLE DriverImageHandle + ) +{ + return EFI_UNSUPPORTED; +} + +EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL mPlatformDriverOverride = { + GetDriver, + GetDriverPath, + DriverLoaded +}; + +/** + Platform Driver Override driver entry point, install the Platform Driver Override Protocol + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS The DXE Driver, DXE Runtime Driver, DXE SMM Driver, + or UEFI Driver exited normally. + @retval EFI_ALREADY_STARTED A protocol instance has been installed. Not need install again. +**/ +EFI_STATUS +EFIAPI +PlatformDriverOverrideEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_HANDLE Handle; + EFI_STATUS Status; + VOID *Instance; + + mCallerImageHandle = ImageHandle; + + // + // According to UEFI spec, there can be at most a single instance + // in the system of the EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL. + // So here we check the existence. + // + Status = gBS->LocateProtocol ( + &gEfiPlatformDriverOverrideProtocolGuid, + NULL, + &Instance + ); + // + // If there was no error, assume there is an installation and return error + // + if (!EFI_ERROR (Status)) { + return EFI_ALREADY_STARTED; + } + + // + // Install platform driver override protocol + // + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + &gEfiPlatformDriverOverrideProtocolGuid, + EFI_NATIVE_INTERFACE, + &mPlatformDriverOverride + ); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf new file mode 100644 index 0000000000..855fb82a59 --- /dev/null +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf @@ -0,0 +1,49 @@ +#/** @file +# This driver produces UEFI PLATFORM_DRIVER_OVERRIDE_PROTOCOL if this protocol doesn't exist. +# It doesn't install again if this protocol exists. +# It only implements one interface GetDriver of PLATFORM_DRIVER_OVERRIDE_PROTOCOL protocol +# and doesn't support other two interfaces GetDriverPath, DriverLoaded. +# +# Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved. +# +# 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 +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PlatformDriOverrideDxe + FILE_GUID = 35034CE2-A6E5-4fb4-BABE-A0156E9B2549 + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = PlatformDriverOverrideEntry + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources.common] + PlatformDriOverride.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + UefiDriverEntryPoint + DebugLib + PlatformDriverOverrideLib + UefiBootServicesTableLib + +[Protocols] + gEfiPlatformDriverOverrideProtocolGuid ## PRODUCED + \ No newline at end of file diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverride.c b/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverride.c deleted file mode 100644 index 64e9a4d64d..0000000000 --- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverride.c +++ /dev/null @@ -1,212 +0,0 @@ -/** @file - -Copyright (c) 2007 - 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include -#include - -LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase); -BOOLEAN mEnvironmentVariableRead = FALSE; -EFI_HANDLE mCallerImageHandle = NULL; - -/** - Retrieves the image handle of the platform override driver for a controller in the system. - - @param This A pointer to the - EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance. - @param ControllerHandle The device handle of the controller to check if a - driver override exists. - @param DriverImageHandle On input, a pointer to the previous driver image - handle returned by GetDriver(). On output, a - pointer to the next driver image handle. Passing - in a NULL, will return the first driver image - handle for ControllerHandle. - - @retval EFI_SUCCESS The driver override for ControllerHandle was - returned in DriverImageHandle. - @retval EFI_NOT_FOUND A driver override for ControllerHandle was not - found. - @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not a - valid handle. DriverImageHandle is not a handle - that was returned on a previous call to - GetDriver(). - -**/ -EFI_STATUS -EFIAPI -GetDriver ( - IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN OUT EFI_HANDLE *DriverImageHandle - ) -{ - EFI_STATUS Status; - - // - // Check that ControllerHandle is a valid handle - // - if (ControllerHandle == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Read the environment variable(s) that contain the override mappings from Controller Device Path to - // a set of Driver Device Paths, and initialize in memory database of the overrides that map Controller - // Device Paths to an ordered set of Driver Device Paths and Driver Handles. This action is only performed - // once and finished in first call. - // - if (!mEnvironmentVariableRead) { - mEnvironmentVariableRead = TRUE; - - Status = InitOverridesMapping (&mMappingDataBase); - if (EFI_ERROR (Status)){ - DEBUG ((DEBUG_ERROR, "The status to Get Platform Driver Override Variable is %r\n", Status)); - InitializeListHead (&mMappingDataBase); - return EFI_NOT_FOUND; - } - } - - // - // if the environment variable does not exist, just return not found - // - if (IsListEmpty (&mMappingDataBase)) { - return EFI_NOT_FOUND; - } - - return GetDriverFromMapping ( - ControllerHandle, - DriverImageHandle, - &mMappingDataBase, - mCallerImageHandle - ); -} - -/** - Retrieves the device path of the platform override driver for a controller in the system. - This driver doesn't support this API. - - @param This A pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_ - PROTOCOL instance. - @param ControllerHandle The device handle of the controller to check if a driver override - exists. - @param DriverImagePath On input, a pointer to the previous driver device path returned by - GetDriverPath(). On output, a pointer to the next driver - device path. Passing in a pointer to NULL, will return the first - driver device path for ControllerHandle. - - @retval EFI_UNSUPPORTED -**/ -EFI_STATUS -EFIAPI -GetDriverPath ( - IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath - ) -{ - return EFI_UNSUPPORTED; -} - - -/** - Used to associate a driver image handle with a device path that was returned on a prior call to the - GetDriverPath() service. This driver image handle will then be available through the - GetDriver() service. This driver doesn't support this API. - - @param This A pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_ - PROTOCOL instance. - @param ControllerHandle The device handle of the controller. - @param DriverImagePath A pointer to the driver device path that was returned in a prior - call to GetDriverPath(). - @param DriverImageHandle The driver image handle that was returned by LoadImage() - when the driver specified by DriverImagePath was loaded - into memory. - - @retval EFI_UNSUPPORTED -**/ -EFI_STATUS -EFIAPI -DriverLoaded ( - IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *DriverImagePath, - IN EFI_HANDLE DriverImageHandle - ) -{ - return EFI_UNSUPPORTED; -} - -EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL mPlatformDriverOverride = { - GetDriver, - GetDriverPath, - DriverLoaded -}; - -/** - Platform Driver Override driver entry point, install the Platform Driver Override Protocol - - @param ImageHandle ImageHandle of the loaded driver. - @param SystemTable Pointer to the EFI System Table. - - @retval EFI_SUCCESS The DXE Driver, DXE Runtime Driver, DXE SMM Driver, - or UEFI Driver exited normally. - @retval EFI_ALREADY_STARTED A protocol instance has been installed. Not need install again. -**/ -EFI_STATUS -EFIAPI -PlatformDriverOverrideEntry ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_HANDLE Handle; - EFI_STATUS Status; - VOID *Instance; - - mCallerImageHandle = ImageHandle; - - // - // According to UEFI spec, there can be at most a single instance - // in the system of the EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL. - // So here we check the existence. - // - Status = gBS->LocateProtocol ( - &gEfiPlatformDriverOverrideProtocolGuid, - NULL, - &Instance - ); - // - // If there was no error, assume there is an installation and return error - // - if (!EFI_ERROR (Status)) { - return EFI_ALREADY_STARTED; - } - - // - // Install platform driver override protocol - // - Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Handle, - &gEfiPlatformDriverOverrideProtocolGuid, - EFI_NATIVE_INTERFACE, - &mPlatformDriverOverride - ); - ASSERT_EFI_ERROR (Status); - return EFI_SUCCESS; -} diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe.inf b/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe.inf deleted file mode 100644 index 855fb82a59..0000000000 --- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe.inf +++ /dev/null @@ -1,49 +0,0 @@ -#/** @file -# This driver produces UEFI PLATFORM_DRIVER_OVERRIDE_PROTOCOL if this protocol doesn't exist. -# It doesn't install again if this protocol exists. -# It only implements one interface GetDriver of PLATFORM_DRIVER_OVERRIDE_PROTOCOL protocol -# and doesn't support other two interfaces GetDriverPath, DriverLoaded. -# -# Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved. -# -# 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 -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformDriOverrideDxe - FILE_GUID = 35034CE2-A6E5-4fb4-BABE-A0156E9B2549 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = PlatformDriverOverrideEntry - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources.common] - PlatformDriOverride.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - BaseLib - UefiDriverEntryPoint - DebugLib - PlatformDriverOverrideLib - UefiBootServicesTableLib - -[Protocols] - gEfiPlatformDriverOverrideProtocolGuid ## PRODUCED - \ No newline at end of file -- cgit v1.2.3