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 LIST_ENTRY mMappingDataBase
= INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase
);
31 BOOLEAN mEnvironmentVariableRead
= FALSE
;
32 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
87 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
88 IN EFI_HANDLE ControllerHandle
,
89 IN OUT EFI_HANDLE
* DriverImageHandle
94 // Check that ControllerHandle is a valid handle
96 if (ControllerHandle
== NULL
) {
97 return EFI_INVALID_PARAMETER
;
101 // Read the environment variable(s) that contain the override mappings from Controller Device Path to
102 // a set of Driver Device Paths, and initialize in memory database of the overrides that map Controller
103 // Device Paths to an ordered set of Driver Device Paths and Driver Handles. This action is only performed
104 // once and finished in first call.
106 if (!mEnvironmentVariableRead
) {
107 mEnvironmentVariableRead
= TRUE
;
109 Status
= InitOverridesMapping (&mMappingDataBase
);
110 if (Status
== EFI_NOT_FOUND
) {
111 InitializeListHead (&mMappingDataBase
);
112 return EFI_NOT_FOUND
;
113 } else if (Status
== EFI_VOLUME_CORRUPTED
){
114 DEBUG ((DEBUG_ERROR
, "Platform Driver Override Variable is corrupt\n"));
116 // The environment variable(s) that contain the override mappings from Controller Device Path to
117 // a set of Driver Device Paths is corrupted, platform code can use LibDeleteOverridesVariables to
118 // delete all orverride variables as a policy. Here can be IBV/OEM customized.
121 //LibDeleteOverridesVariables();
122 InitializeListHead (&mMappingDataBase
);
123 return EFI_NOT_FOUND
;
124 } else if (EFI_ERROR (Status
)){
125 InitializeListHead (&mMappingDataBase
);
126 return EFI_NOT_FOUND
;
130 // if the environment variable does not exist or the variable appears to be corrupt, just return not found
132 if (IsListEmpty (&mMappingDataBase
)) {
133 return EFI_NOT_FOUND
;
136 return GetDriverFromMapping (
148 For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs
149 makes those APIs very difficult to use, so not support.
157 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
158 IN EFI_HANDLE ControllerHandle
,
159 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DriverImagePath
162 return EFI_UNSUPPORTED
;
167 For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs
168 makes those APIs very difficult to use, so not support.
176 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
177 IN EFI_HANDLE ControllerHandle
,
178 IN EFI_DEVICE_PATH_PROTOCOL
* DriverImagePath
,
179 IN EFI_HANDLE DriverImageHandle
182 return EFI_UNSUPPORTED
;