From b290614d493ff72fc2a4410d169314e501b7e79e Mon Sep 17 00:00:00 2001 From: vanjeff Date: Wed, 16 Jan 2008 09:04:43 +0000 Subject: Port PlatformDriOverrideDxe into R9. 1. Add one OverrideVariableGuid in MdeModulePkg 2. Add one library PlatDriOverLib used by PlatformDriOverrideDxe. 3. Add PlatformDriOverrideDxe in MdeModulePkg git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4557 6f19259b-4bc3-4df7-8a09-765794883524 --- .../PlatformDriOverrideDxe/PlatformDriOverride.c | 186 +++++++++++++++++++++ .../PlatformDriOverrideDxe/PlatformDriOverride.h | 58 +++++++ .../PlatformDriOverrideDxe.inf | 48 ++++++ .../PlatformDriOverrideDxe.msa | 50 ++++++ 4 files changed, 342 insertions(+) create mode 100644 MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c create mode 100644 MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.h create mode 100644 MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf create mode 100644 MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.msa (limited to 'MdeModulePkg/Universal/PlatformDriOverrideDxe') diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c new file mode 100644 index 0000000000..2a189138ed --- /dev/null +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.c @@ -0,0 +1,186 @@ +/** @file + +Copyright (c) 2007, 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. + +Module Name: + + PlatformDriOverride.c + +Abstract: + + +**/ + + +#include "PlatformDriOverride.h" + +EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL gPlatformDriverOverride = { + GetDriver, + GetDriverPath, + DriverLoaded +}; + +STATIC LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase); +STATIC BOOLEAN mEnvironmentVariableRead = FALSE; +STATIC EFI_HANDLE mCallerImageHandle; + + +EFI_STATUS +EFIAPI +PlatformDriverOverrideEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + Platform Driver Override driver entry point, install the Platform Driver Override Protocol + +Arguments: + (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) + +Returns: + EFI_STATUS + +--*/ +{ + mEnvironmentVariableRead = FALSE; + mCallerImageHandle = ImageHandle; + InitializeListHead (&mMappingDataBase); + return InstallPlatformDriverOverrideProtocol (&gPlatformDriverOverride); +} + + +/** + 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(). + +**/ +STATIC +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 (Status == EFI_NOT_FOUND) { + InitializeListHead (&mMappingDataBase); + return EFI_NOT_FOUND; + } else if (Status == EFI_VOLUME_CORRUPTED){ + DEBUG ((DEBUG_ERROR, "Platform Driver Override Variable is corrupt\n")); + // + // The environment variable(s) that contain the override mappings from Controller Device Path to + // a set of Driver Device Paths is corrupted, platform code can use LibDeleteOverridesVariables to + // delete all orverride variables as a policy. Here can be IBV/OEM customized. + // + + //LibDeleteOverridesVariables(); + InitializeListHead (&mMappingDataBase); + return EFI_NOT_FOUND; + } else if (EFI_ERROR (Status)){ + InitializeListHead (&mMappingDataBase); + return EFI_NOT_FOUND; + } + } + // + // if the environment variable does not exist or the variable appears to be corrupt, just return not found + // + if (IsListEmpty (&mMappingDataBase)) { + return EFI_NOT_FOUND; + } + + return GetDriverFromMapping ( + This, + ControllerHandle, + DriverImageHandle, + &mMappingDataBase, + mCallerImageHandle + ); + +} + + +/** + For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs + makes those APIs very difficult to use, so not support. + + + +**/ +STATIC +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; +} + + +/** + For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs + makes those APIs very difficult to use, so not support. + + + +**/ +STATIC +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; +} diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.h b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.h new file mode 100644 index 0000000000..5a5b276451 --- /dev/null +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverride.h @@ -0,0 +1,58 @@ +/** @file + +Copyright (c) 2007, 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. + +Module Name: + + PlatformDriOverride.h + +Abstract: + + +**/ + +#ifndef PLATFORM_DRI_OVERRIDE_H_ +#define PLATFORM_DRI_OVERRIDE_H_ + +#include + +#include +#include +#include +#include + +STATIC +EFI_STATUS +EFIAPI +GetDriver ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN OUT EFI_HANDLE * DriverImageHandle + ); + +STATIC +EFI_STATUS +EFIAPI +GetDriverPath ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath + ); + +STATIC +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 + ); +#endif diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf new file mode 100644 index 0000000000..dbc9f0ecb7 --- /dev/null +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf @@ -0,0 +1,48 @@ +#/** @file +# Component name for module PlatformDriOverride +# +# FIX ME! +# Copyright (c) 2007, 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 = DXE_DRIVER + VERSION_STRING = 1.0 + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + 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 + PlatformDriOverride.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + UefiDriverEntryPoint + DebugLib + PlatDriOverLib + diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.msa b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.msa new file mode 100644 index 0000000000..6e1645af35 --- /dev/null +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.msa @@ -0,0 +1,50 @@ + + + PlatformDriOverrideDxe + DXE_DRIVER + 35034CE2-A6E5-4fb4-BABE-A0156E9B2549 + 1.0 + Component name for module PlatformDriOverride + FIX ME! + Copyright (c) 2007, 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. + FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 + + + IA32 X64 IPF EBC + false + PlatformDriOverrideDxe + + + + DebugLib + + + UefiDriverEntryPoint + + + BaseLib + + + + PlatformDriOverride.h + PlatformDriOverride.c + + + + + + + EFI_SPECIFICATION_VERSION 0x00020000 + EDK_RELEASE_VERSION 0x00020000 + + PlatformDriverOverrideEntry + + + \ No newline at end of file -- cgit v1.2.3