]>
Commit | Line | Data |
---|---|---|
a6f164a7 | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | PlatformDriOverride.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | \r | |
19 | **/\r | |
20 | \r | |
21 | \r | |
22 | #include "PlatformDriOverride.h"\r | |
23 | \r | |
24 | EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL gPlatformDriverOverride = {\r | |
25 | GetDriver,\r | |
26 | GetDriverPath,\r | |
27 | DriverLoaded\r | |
28 | };\r | |
29 | \r | |
fe1e36e5 | 30 | LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase);\r |
31 | BOOLEAN mEnvironmentVariableRead = FALSE;\r | |
32 | EFI_HANDLE mCallerImageHandle;\r | |
a6f164a7 | 33 | \r |
34 | \r | |
35 | EFI_STATUS\r | |
36 | EFIAPI\r | |
37 | PlatformDriverOverrideEntry (\r | |
38 | IN EFI_HANDLE ImageHandle,\r | |
39 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
40 | )\r | |
41 | /*++\r | |
42 | \r | |
43 | Routine Description:\r | |
44 | Platform Driver Override driver entry point, install the Platform Driver Override Protocol\r | |
45 | \r | |
46 | Arguments:\r | |
47 | (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r | |
48 | \r | |
49 | Returns:\r | |
50 | EFI_STATUS\r | |
51 | \r | |
52 | --*/\r | |
53 | {\r | |
54 | mEnvironmentVariableRead = FALSE;\r | |
55 | mCallerImageHandle = ImageHandle;\r | |
56 | InitializeListHead (&mMappingDataBase);\r | |
57 | return InstallPlatformDriverOverrideProtocol (&gPlatformDriverOverride);\r | |
58 | }\r | |
59 | \r | |
60 | \r | |
61 | /**\r | |
62 | Retrieves the image handle of the platform override driver for a controller in the system.\r | |
63 | \r | |
64 | @param This A pointer to the\r | |
65 | EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.\r | |
66 | @param ControllerHandle The device handle of the controller to check if a\r | |
67 | driver override exists.\r | |
68 | @param DriverImageHandle On input, a pointer to the previous driver image\r | |
69 | handle returned by GetDriver(). On output, a\r | |
70 | pointer to the next driver image handle. Passing\r | |
71 | in a NULL, will return the first driver image\r | |
72 | handle for ControllerHandle.\r | |
73 | \r | |
74 | @retval EFI_SUCCESS The driver override for ControllerHandle was\r | |
75 | returned in DriverImageHandle.\r | |
76 | @retval EFI_NOT_FOUND A driver override for ControllerHandle was not\r | |
77 | found.\r | |
78 | @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not a\r | |
79 | valid handle. DriverImageHandle is not a handle\r | |
80 | that was returned on a previous call to\r | |
81 | GetDriver().\r | |
82 | \r | |
83 | **/\r | |
a6f164a7 | 84 | EFI_STATUS\r |
85 | EFIAPI\r | |
86 | GetDriver (\r | |
87 | IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,\r | |
88 | IN EFI_HANDLE ControllerHandle,\r | |
89 | IN OUT EFI_HANDLE * DriverImageHandle\r | |
90 | )\r | |
91 | {\r | |
92 | EFI_STATUS Status;\r | |
93 | //\r | |
94 | // Check that ControllerHandle is a valid handle\r | |
95 | //\r | |
96 | if (ControllerHandle == NULL) {\r | |
97 | return EFI_INVALID_PARAMETER;\r | |
98 | }\r | |
99 | \r | |
100 | //\r | |
101 | // Read the environment variable(s) that contain the override mappings from Controller Device Path to\r | |
102 | // a set of Driver Device Paths, and initialize in memory database of the overrides that map Controller\r | |
103 | // Device Paths to an ordered set of Driver Device Paths and Driver Handles. This action is only performed\r | |
104 | // once and finished in first call.\r | |
105 | //\r | |
106 | if (!mEnvironmentVariableRead) {\r | |
107 | mEnvironmentVariableRead = TRUE;\r | |
108 | \r | |
109 | Status = InitOverridesMapping (&mMappingDataBase);\r | |
110 | if (Status == EFI_NOT_FOUND) {\r | |
111 | InitializeListHead (&mMappingDataBase);\r | |
112 | return EFI_NOT_FOUND;\r | |
113 | } else if (Status == EFI_VOLUME_CORRUPTED){\r | |
114 | DEBUG ((DEBUG_ERROR, "Platform Driver Override Variable is corrupt\n"));\r | |
115 | //\r | |
116 | // The environment variable(s) that contain the override mappings from Controller Device Path to\r | |
117 | // a set of Driver Device Paths is corrupted, platform code can use LibDeleteOverridesVariables to\r | |
118 | // delete all orverride variables as a policy. Here can be IBV/OEM customized.\r | |
119 | //\r | |
120 | \r | |
121 | //LibDeleteOverridesVariables();\r | |
122 | InitializeListHead (&mMappingDataBase);\r | |
123 | return EFI_NOT_FOUND;\r | |
124 | } else if (EFI_ERROR (Status)){\r | |
125 | InitializeListHead (&mMappingDataBase);\r | |
126 | return EFI_NOT_FOUND;\r | |
127 | }\r | |
128 | }\r | |
129 | //\r | |
130 | // if the environment variable does not exist or the variable appears to be corrupt, just return not found\r | |
131 | //\r | |
132 | if (IsListEmpty (&mMappingDataBase)) {\r | |
133 | return EFI_NOT_FOUND;\r | |
134 | }\r | |
135 | \r | |
136 | return GetDriverFromMapping (\r | |
137 | This,\r | |
138 | ControllerHandle,\r | |
139 | DriverImageHandle,\r | |
140 | &mMappingDataBase,\r | |
141 | mCallerImageHandle\r | |
142 | );\r | |
143 | \r | |
144 | }\r | |
145 | \r | |
146 | \r | |
147 | /**\r | |
148 | For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs\r | |
149 | makes those APIs very difficult to use, so not support.\r | |
150 | \r | |
151 | \r | |
152 | \r | |
153 | **/\r | |
a6f164a7 | 154 | EFI_STATUS\r |
155 | EFIAPI\r | |
156 | GetDriverPath (\r | |
157 | IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,\r | |
158 | IN EFI_HANDLE ControllerHandle,\r | |
159 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath\r | |
160 | )\r | |
161 | {\r | |
162 | return EFI_UNSUPPORTED;\r | |
163 | }\r | |
164 | \r | |
165 | \r | |
166 | /**\r | |
167 | For the use of the ControllerHandle parameter in the GetDriverPath() and DriverLoaded() APIs\r | |
168 | makes those APIs very difficult to use, so not support.\r | |
169 | \r | |
170 | \r | |
171 | \r | |
172 | **/\r | |
a6f164a7 | 173 | EFI_STATUS\r |
174 | EFIAPI\r | |
175 | DriverLoaded (\r | |
176 | IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,\r | |
177 | IN EFI_HANDLE ControllerHandle,\r | |
178 | IN EFI_DEVICE_PATH_PROTOCOL * DriverImagePath,\r | |
179 | IN EFI_HANDLE DriverImageHandle\r | |
180 | )\r | |
181 | {\r | |
182 | return EFI_UNSUPPORTED;\r | |
183 | }\r |