3 Copyright (c) 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include "PlatformDriOverride.h"
24 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL gPlatformDriverOverride
= {
30 STATIC LIST_ENTRY mMappingDataBase
= INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase
);
31 STATIC BOOLEAN mEnvironmentVariableRead
= FALSE
;
32 STATIC EFI_HANDLE mCallerImageHandle
;
37 PlatformDriverOverrideEntry (
38 IN EFI_HANDLE ImageHandle
,
39 IN EFI_SYSTEM_TABLE
*SystemTable
44 Platform Driver Override driver entry point, install the Platform Driver Override Protocol
47 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
54 mEnvironmentVariableRead
= FALSE
;
55 mCallerImageHandle
= ImageHandle
;
56 InitializeListHead (&mMappingDataBase
);
57 return InstallPlatformDriverOverrideProtocol (&gPlatformDriverOverride
);
62 Retrieves the image handle of the platform override driver for a controller in the system.
64 @param This A pointer to the
65 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.
66 @param ControllerHandle The device handle of the controller to check if a
67 driver override exists.
68 @param DriverImageHandle On input, a pointer to the previous driver image
69 handle returned by GetDriver(). On output, a
70 pointer to the next driver image handle. Passing
71 in a NULL, will return the first driver image
72 handle for ControllerHandle.
74 @retval EFI_SUCCESS The driver override for ControllerHandle was
75 returned in DriverImageHandle.
76 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not
78 @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not a
79 valid handle. DriverImageHandle is not a handle
80 that was returned on a previous call to
88 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
89 IN EFI_HANDLE ControllerHandle
,
90 IN OUT EFI_HANDLE
* DriverImageHandle
95 // Check that ControllerHandle is a valid handle
97 if (ControllerHandle
== NULL
) {
98 return EFI_INVALID_PARAMETER
;
102 // Read the environment variable(s) that contain the override mappings from Controller Device Path to
103 // a set of Driver Device Paths, and initialize in memory database of the overrides that map Controller
104 // Device Paths to an ordered set of Driver Device Paths and Driver Handles. This action is only performed
105 // once and finished in first call.
107 if (!mEnvironmentVariableRead
) {
108 mEnvironmentVariableRead
= TRUE
;
110 Status
= InitOverridesMapping (&mMappingDataBase
);
111 if (Status
== EFI_NOT_FOUND
) {
112 InitializeListHead (&mMappingDataBase
);
113 return EFI_NOT_FOUND
;
114 } else if (Status
== EFI_VOLUME_CORRUPTED
){
115 DEBUG ((DEBUG_ERROR
, "Platform Driver Override Variable is corrupt\n"));
117 // The environment variable(s) that contain the override mappings from Controller Device Path to
118 // a set of Driver Device Paths is corrupted, platform code can use LibDeleteOverridesVariables to
119 // delete all orverride variables as a policy. Here can be IBV/OEM customized.
122 //LibDeleteOverridesVariables();
123 InitializeListHead (&mMappingDataBase
);
124 return EFI_NOT_FOUND
;
125 } else if (EFI_ERROR (Status
)){
126 InitializeListHead (&mMappingDataBase
);
127 return EFI_NOT_FOUND
;
131 // if the environment variable does not exist or the variable appears to be corrupt, just return not found
133 if (IsListEmpty (&mMappingDataBase
)) {
134 return EFI_NOT_FOUND
;
137 return GetDriverFromMapping (
149 For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs
150 makes those APIs very difficult to use, so not support.
159 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
160 IN EFI_HANDLE ControllerHandle
,
161 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DriverImagePath
164 return EFI_UNSUPPORTED
;
169 For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs
170 makes those APIs very difficult to use, so not support.
179 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
180 IN EFI_HANDLE ControllerHandle
,
181 IN EFI_DEVICE_PATH_PROTOCOL
* DriverImagePath
,
182 IN EFI_HANDLE DriverImageHandle
185 return EFI_UNSUPPORTED
;