mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
77aa51cd89
commit
b290614d49
|
@ -0,0 +1,34 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2008, 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:
|
||||
|
||||
OverrideVariable.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Platform Override Variable Guid definitions
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef __EFI_OVERRIDE_VARIABLE_GUID_H__
|
||||
#define __EFI_OVERRIDE_VARIABLE_GUID_H__
|
||||
|
||||
//
|
||||
// This guid is used for a platform driver override variable
|
||||
//
|
||||
#define EFI_OVERRIDE_VARIABLE_GUID \
|
||||
{ 0x8e3d4ad5, 0xf762, 0x438a, { 0xa1, 0xc1, 0x5b, 0x9f, 0xe6, 0x8c, 0x6b, 0x15 }}
|
||||
|
||||
extern EFI_GUID gEfiOverrideVariableGuid;
|
||||
|
||||
|
||||
#endif // #ifndef __EFI_OVERRIDE_VARIABLE_GUID_H__
|
|
@ -0,0 +1,255 @@
|
|||
/** @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:
|
||||
|
||||
PlatDriOverLib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PLAT_DRI_OVER_LIB_H_
|
||||
#define _PLAT_DRI_OVER_LIB_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/PlatformDriverOverride.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Library/BaseLib.h>
|
||||
|
||||
#include <VariableFormat.h>
|
||||
|
||||
/**
|
||||
Install the Platform Driver Override Protocol, and ensure there is only one Platform Driver Override Protocol
|
||||
in the system.
|
||||
|
||||
@param gPlatformDriverOverride PlatformDriverOverride protocol interface which
|
||||
needs to be installed
|
||||
|
||||
@retval EFI_ALREADY_STARTED There has been a Platform Driver Override
|
||||
Protocol in the system, cannot install it again.
|
||||
@retval Other Returned by InstallProtocolInterface
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InstallPlatformDriverOverrideProtocol (
|
||||
EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *gPlatformDriverOverride
|
||||
);
|
||||
|
||||
/**
|
||||
Free all the mapping database memory resource and initialize the mapping list entry
|
||||
|
||||
@param MappingDataBase Mapping database list entry pointer
|
||||
|
||||
@retval EFI_INVALID_PARAMETER mapping database list entry is NULL
|
||||
@retval EFI_SUCCESS Free success
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FreeMappingDatabase (
|
||||
IN OUT LIST_ENTRY *MappingDataBase
|
||||
);
|
||||
|
||||
/**
|
||||
Read the environment variable(s) that contain the override mappings from Controller Device Path to
|
||||
a set of Driver Device Paths, and create the mapping database in memory with those variable info.
|
||||
VariableLayout{
|
||||
//
|
||||
// NotEnd indicate whether the variable is the last one, and has no subsequent variable need to load.
|
||||
// Each variable has MaximumVariableSize limitation, so we maybe need multi variables to store
|
||||
// large mapping infos.
|
||||
// The variable(s) name rule is PlatDriOver, PlatDriOver1, PlatDriOver2, ....
|
||||
//
|
||||
UINT32 NotEnd;
|
||||
//
|
||||
// The entry which contains the mapping that Controller Device Path to a set of Driver Device Paths
|
||||
// There are often multi mapping entries in a variable.
|
||||
//
|
||||
UINT32 SIGNATURE; //EFI_SIGNATURE_32('p','d','o','i')
|
||||
UINT32 DriverNum;
|
||||
EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];
|
||||
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
|
||||
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
|
||||
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
|
||||
......
|
||||
UINT32 SIGNATURE;
|
||||
UINT32 DriverNum;
|
||||
EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];
|
||||
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
|
||||
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
|
||||
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
|
||||
......
|
||||
}
|
||||
typedef struct _PLATFORM_OVERRIDE_ITEM{
|
||||
UINTN Signature; //EFI_SIGNATURE_32('p','d','o','i')
|
||||
LIST_ENTRY Link;
|
||||
UINT32 DriverInfoNum;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;
|
||||
LIST_ENTRY DriverInfoList; //DRIVER_IMAGE_INFO List
|
||||
} PLATFORM_OVERRIDE_ITEM;
|
||||
typedef struct _DRIVER_IMAGE_INFO{
|
||||
UINTN Signature; //EFI_SIGNATURE_32('p','d','i','i')
|
||||
LIST_ENTRY Link;
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DriverImagePath;
|
||||
BOOLEAN UnLoadable;
|
||||
BOOLEAN UnStartable;
|
||||
} DRIVER_IMAGE_INFO;
|
||||
|
||||
@param MappingDataBase Mapping database list entry pointer
|
||||
|
||||
@retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
|
||||
@retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable
|
||||
@retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted
|
||||
@retval EFI_SUCCESS Create the mapping database in memory
|
||||
successfully
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitOverridesMapping (
|
||||
OUT LIST_ENTRY *MappingDataBase
|
||||
);
|
||||
|
||||
/**
|
||||
Save the memory mapping database into NV environment variable(s)
|
||||
|
||||
@param MappingDataBase Mapping database list entry pointer
|
||||
|
||||
@retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
|
||||
@retval EFI_SUCCESS Save memory mapping database successfully
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SaveOverridesMapping (
|
||||
IN LIST_ENTRY *MappingDataBase
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.
|
||||
|
||||
@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 output, a pointer to the next driver handle.
|
||||
Passing in a pointer to NULL, will return the
|
||||
first driver handle for ControllerHandle.
|
||||
@param MappingDataBase MappingDataBase - Mapping database list entry
|
||||
pointer
|
||||
@param CallerImageHandle The caller driver's image handle, for
|
||||
UpdateFvFileDevicePath use.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not
|
||||
a valid handle. Or DriverImagePath is not a
|
||||
device path that was returned on a previous call
|
||||
to GetDriverPath().
|
||||
@retval EFI_NOT_FOUND A driver override for ControllerHandle was not
|
||||
found.
|
||||
@retval EFI_UNSUPPORTED The operation is not supported.
|
||||
@retval EFI_SUCCESS The driver override for ControllerHandle was
|
||||
returned in DriverImagePath.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetDriverFromMapping (
|
||||
IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN OUT EFI_HANDLE * DriverImageHandle,
|
||||
IN LIST_ENTRY * MappingDataBase,
|
||||
IN EFI_HANDLE CallerImageHandle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DeleteOverridesVariables (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Check mapping database whether already has the mapping info which
|
||||
records the input Controller to input DriverImage.
|
||||
If has, the controller's total override driver number and input DriverImage's order number is return.
|
||||
|
||||
@param ControllerDevicePath The controller device path need to add a
|
||||
override driver image item
|
||||
@param DriverImageDevicePath The driver image device path need to be insert
|
||||
@param MappingDataBase Mapping database list entry pointer
|
||||
@param DriverInfoNum the controller's total override driver number
|
||||
@param DriverImageNO The inserted order number
|
||||
|
||||
@return EFI_INVALID_PARAMETER
|
||||
@return EFI_NOT_FOUND
|
||||
@return EFI_SUCCESS
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CheckMapping (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
|
||||
IN LIST_ENTRY * MappingDataBase,
|
||||
OUT UINT32 *DriverInfoNum,
|
||||
OUT UINT32 *DriverImageNO
|
||||
);
|
||||
|
||||
/**
|
||||
Insert a driver image as a controller's override driver into the mapping database.
|
||||
The driver image's order number is indicated by DriverImageNO.
|
||||
|
||||
@param ControllerDevicePath The controller device path need to add a
|
||||
override driver image item
|
||||
@param DriverImageDevicePath The driver image device path need to be insert
|
||||
@param MappingDataBase Mapping database list entry pointer
|
||||
@param DriverImageNO The inserted order number
|
||||
|
||||
@return EFI_INVALID_PARAMETER
|
||||
@return EFI_ALREADY_STARTED
|
||||
@return EFI_SUCCESS
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InsertDriverImage (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
|
||||
IN LIST_ENTRY *MappingDataBase,
|
||||
IN UINT32 DriverImageNO
|
||||
);
|
||||
|
||||
/**
|
||||
Delete a controller's override driver from the mapping database.
|
||||
|
||||
@param ControllerDevicePath The controller device path need to add a
|
||||
override driver image item
|
||||
@param DriverImageDevicePath The driver image device path need to be insert
|
||||
@param MappingDataBase Mapping database list entry pointer
|
||||
@param DriverImageNO The inserted order number
|
||||
|
||||
@return EFI_INVALID_PARAMETER
|
||||
@return EFI_NOT_FOUND
|
||||
@return EFI_SUCCESS
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DeleteDriverImage (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
|
||||
IN LIST_ENTRY *MappingDataBase
|
||||
);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,65 @@
|
|||
#/** @file
|
||||
# Component name for module PlatDriOverLib
|
||||
#
|
||||
# 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 = PlatDriOverLib
|
||||
FILE_GUID = 8bd8d711-2736-46d7-8c81-5de68e0a9e88
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PlatDriOverLib
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
PlatDriOver.h
|
||||
PlatDriOverLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DxeServicesTableLib
|
||||
MemoryAllocationLib
|
||||
DevicePathLib
|
||||
BaseLib
|
||||
UefiLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
PrintLib
|
||||
|
||||
[Guids]
|
||||
gEfiOverrideVariableGuid # ALWAYS_CONSUMED
|
||||
|
||||
[Protocols]
|
||||
gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiPlatformDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiDriverBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>PlatDriOverLib</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>8bd8d711-2736-46d7-8c81-5de68e0a9e88</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component name for module PlatDriOverLib</Abstract>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2007, Intel Corporation. All rights reserved.</Copyright>
|
||||
<License>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.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>PlatDriOverLib</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_PRODUCED">
|
||||
<Keyword>PlatDriOverLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>PrintLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiRuntimeServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DevicePathLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DxeServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>PlatDriOverLib.c</Filename>
|
||||
<Filename>PlatDriOver.h</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiDriverBindingProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiBusSpecificDriverOverrideProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiPlatformDriverOverrideProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiLoadedImageProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiFirmwareVolumeProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiFirmwareVolume2ProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
|
@ -0,0 +1,121 @@
|
|||
/** @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:
|
||||
|
||||
PlatDriOver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PLAT_DRI_OVER_H_
|
||||
#define _PLAT_DRI_OVER_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/PlatformDriverOverride.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Protocol/BusSpecificDriverOverride.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/PlatDriOverLib.h>
|
||||
|
||||
#include <Guid/OverrideVariable.h>
|
||||
|
||||
|
||||
#define PLATFORM_OVERRIDE_ITEM_SIGNATURE EFI_SIGNATURE_32('p','d','o','i')
|
||||
typedef struct _PLATFORM_OVERRIDE_ITEM{
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
UINT32 DriverInfoNum;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;
|
||||
LIST_ENTRY DriverInfoList; //DRIVER_IMAGE_INFO List
|
||||
EFI_HANDLE LastReturnedImageHandle;
|
||||
} PLATFORM_OVERRIDE_ITEM;
|
||||
|
||||
#define DRIVER_IMAGE_INFO_SIGNATURE EFI_SIGNATURE_32('p','d','i','i')
|
||||
typedef struct _DRIVER_IMAGE_INFO{
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DriverImagePath;
|
||||
BOOLEAN UnLoadable;
|
||||
BOOLEAN UnStartable;
|
||||
} DRIVER_IMAGE_INFO;
|
||||
|
||||
#define DEVICE_PATH_STACK_ITEM_SIGNATURE EFI_SIGNATURE_32('d','p','s','i')
|
||||
typedef struct _DEVICE_PATH_STACK_ITEM{
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
} DEVICE_PATH_STACK_ITEM;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PushDevPathStack (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PopDevPathStack (
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
CheckExistInStack (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UpdateFvFileDevicePath (
|
||||
IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,
|
||||
IN EFI_GUID *FileGuid,
|
||||
IN EFI_HANDLE CallerImageHandle
|
||||
);
|
||||
|
||||
VOID *
|
||||
GetVariableAndSize (
|
||||
IN CHAR16 *Name,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
OUT UINTN *VariableSize
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
ConnectDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
BdsConnectDeviceByPciClassType (
|
||||
UINT8 ClassType,
|
||||
UINT8 SubClassCode,
|
||||
UINT8 PI,
|
||||
BOOLEAN Recursive
|
||||
);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
|||
# Mde Module Package Reference Implementations
|
||||
#
|
||||
# This module provides headers and libraries that conform to EFI/PI Industry standards.
|
||||
# Copyright (c) 2007, Intel Corporation.
|
||||
# Copyright (c) 2007 - 2008, Intel Corporation.
|
||||
#
|
||||
# All rights reserved.
|
||||
# This program and the accompanying materials are licensed and made available under
|
||||
|
@ -33,6 +33,7 @@
|
|||
UdpIoLib|Include/Library/UdpIoLib.h
|
||||
S3Lib|Include/Library/S3Lib.h
|
||||
RecoveryLib|Include/Library/RecoveryLib.h
|
||||
PlatDriOverLib|Include/Library/PlatDriOverLib.h
|
||||
|
||||
[Guids.common]
|
||||
|
||||
|
@ -64,6 +65,7 @@
|
|||
gEfiPeiPeCoffLoaderGuid = { 0xD8117CFF, 0x94A6, 0x11D4, { 0x9A, 0x3A, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}
|
||||
gEfiVariableInfoGuid = { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }}
|
||||
gSimpleTextInExNotifyGuid = { 0x856f2def, 0x4e93, 0x4d6b, { 0x94, 0xce, 0x1c, 0xfe, 0x47, 0x01, 0x3e, 0xa5 }}
|
||||
gEfiOverrideVariableGuid = { 0x8e3d4ad5, 0xf762, 0x438a, { 0xa1, 0xc1, 0x5b, 0x9f, 0xe6, 0x8c, 0x6b, 0x15 }}
|
||||
|
||||
[Protocols.common]
|
||||
|
||||
|
@ -97,7 +99,7 @@
|
|||
|
||||
##gPeiFlashMapPpiGuid will be removed in future
|
||||
gPeiFlashMapPpiGuid = { 0xf34c2fa0, 0xde88, 0x4270, {0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c } }
|
||||
|
||||
|
||||
gPeiOperatorPresencePpiGuid = { 0x20a7378c, 0xaa83, 0x4ce1, {0x82, 0x1f, 0x47, 0x40, 0xee, 0x1b, 0x3f, 0x9f } }
|
||||
|
||||
[PcdsFeatureFlag.common]
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
|
||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
|
||||
PlatDriOverLib|MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf
|
||||
|
||||
[LibraryClasses.IA32]
|
||||
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||
|
@ -255,6 +256,8 @@
|
|||
MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
|
||||
MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
|
||||
|
||||
MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf
|
||||
|
||||
MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
|
||||
MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
|
||||
|
||||
|
@ -274,6 +277,8 @@
|
|||
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
|
||||
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
|
||||
|
||||
MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf
|
||||
|
||||
MdeModulePkg/Application/HelloWorld/HelloWorld.inf
|
||||
|
||||
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 <PiDxe.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PlatDriOverLib.h>
|
||||
|
||||
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
|
|
@ -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
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>PlatformDriOverrideDxe</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>35034CE2-A6E5-4fb4-BABE-A0156E9B2549</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component name for module PlatformDriOverride</Abstract>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2007, Intel Corporation. All rights reserved.</Copyright>
|
||||
<License>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.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>PlatformDriOverrideDxe</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>PlatformDriOverride.h</Filename>
|
||||
<Filename>PlatformDriOverride.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
<ModuleEntryPoint>PlatformDriverOverrideEntry</ModuleEntryPoint>
|
||||
</Extern>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
Loading…
Reference in New Issue