]>
Commit | Line | Data |
---|---|---|
615c6dd0 | 1 | /** @file\r |
b1f6a7c6 | 2 | EFI PEI Core PPI services\r |
3 | \r | |
58dcdada | 4 | Copyright (c) 2006, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
192f6d4c | 12 | \r |
b1f6a7c6 | 13 | **/\r |
192f6d4c | 14 | \r |
b1f6a7c6 | 15 | #include <PeiMain.h>\r |
192f6d4c | 16 | \r |
b1f6a7c6 | 17 | /**\r |
192f6d4c | 18 | \r |
b1f6a7c6 | 19 | Initialize PPI services.\r |
192f6d4c | 20 | \r |
192f6d4c | 21 | \r |
b1f6a7c6 | 22 | @param PrivateData Pointer to the PEI Core data.\r |
23 | @param OldCoreData Pointer to old PEI Core data. \r | |
24 | NULL if being run in non-permament memory mode.\r | |
192f6d4c | 25 | \r |
b1f6a7c6 | 26 | **/\r |
192f6d4c | 27 | VOID\r |
28 | InitializePpiServices (\r | |
b0d803fe | 29 | IN PEI_CORE_INSTANCE *PrivateData,\r |
192f6d4c | 30 | IN PEI_CORE_INSTANCE *OldCoreData\r |
31 | )\r | |
192f6d4c | 32 | {\r |
192f6d4c | 33 | if (OldCoreData == NULL) {\r |
eaf539d0 LG |
34 | PrivateData->PpiData.NotifyListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r |
35 | PrivateData->PpiData.DispatchListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r | |
36 | PrivateData->PpiData.LastDispatchedNotify = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r | |
192f6d4c | 37 | }\r |
192f6d4c | 38 | }\r |
39 | \r | |
b1f6a7c6 | 40 | /**\r |
41 | \r | |
42 | Migrate the Hob list from the CAR stack to PEI installed memory.\r | |
43 | \r | |
44 | @param PeiServices The PEI core services table.\r | |
45 | @param OldCheckingBottom The old checking bottom.\r | |
46 | @param OldCheckingTop The old checking top.\r | |
5c5a0601 | 47 | @param Fixup The address difference between\r |
48 | the new Hob list and old Hob list.\r | |
b1f6a7c6 | 49 | \r |
50 | **/\r | |
192f6d4c | 51 | VOID\r |
52 | ConvertPpiPointers (\r | |
5c5a0601 | 53 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
58dcdada | 54 | IN UINTN OldCheckingBottom,\r |
55 | IN UINTN OldCheckingTop,\r | |
5c5a0601 | 56 | IN UINTN Fixup\r |
192f6d4c | 57 | )\r |
192f6d4c | 58 | {\r |
59 | PEI_CORE_INSTANCE *PrivateData;\r | |
60 | UINT8 Index;\r | |
61 | PEI_PPI_LIST_POINTERS *PpiPointer;\r | |
192f6d4c | 62 | \r |
63 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r | |
64 | \r | |
eaf539d0 | 65 | for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {\r |
192f6d4c | 66 | if (Index < PrivateData->PpiData.PpiListEnd ||\r |
67 | Index > PrivateData->PpiData.NotifyListEnd) {\r | |
68 | PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index];\r | |
58dcdada | 69 | \r |
70 | if (((UINTN)PpiPointer->Raw < OldCheckingTop) &&\r | |
71 | ((UINTN)PpiPointer->Raw >= OldCheckingBottom)) {\r | |
192f6d4c | 72 | //\r |
73 | // Convert the pointer to the PEIM descriptor from the old HOB heap\r | |
74 | // to the relocated HOB heap.\r | |
75 | //\r | |
76 | PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Fixup);\r | |
77 | \r | |
78 | //\r | |
79 | // Only when the PEIM descriptor is in the old HOB should it be necessary\r | |
80 | // to try to convert the pointers in the PEIM descriptor\r | |
81 | //\r | |
58dcdada | 82 | \r |
83 | if (((UINTN)PpiPointer->Ppi->Guid < OldCheckingTop) &&\r | |
84 | ((UINTN)PpiPointer->Ppi->Guid >= OldCheckingBottom)) {\r | |
192f6d4c | 85 | //\r |
86 | // Convert the pointer to the GUID in the PPI or NOTIFY descriptor\r | |
87 | // from the old HOB heap to the relocated HOB heap.\r | |
88 | //\r | |
89 | PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Fixup);\r | |
90 | }\r | |
91 | \r | |
92 | //\r | |
93 | // Assume that no code is located in the temporary memory, so the pointer to\r | |
94 | // the notification function in the NOTIFY descriptor needs not be converted.\r | |
95 | //\r | |
96 | if (Index < PrivateData->PpiData.PpiListEnd &&\r | |
58dcdada | 97 | (UINTN)PpiPointer->Ppi->Ppi < OldCheckingTop &&\r |
98 | (UINTN)PpiPointer->Ppi->Ppi >= OldCheckingBottom) {\r | |
192f6d4c | 99 | //\r |
100 | // Convert the pointer to the PPI interface structure in the PPI descriptor\r | |
101 | // from the old HOB heap to the relocated HOB heap.\r | |
102 | //\r | |
58dcdada | 103 | PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi+ Fixup);\r |
192f6d4c | 104 | }\r |
105 | }\r | |
106 | }\r | |
107 | }\r | |
108 | }\r | |
109 | \r | |
b1f6a7c6 | 110 | /**\r |
192f6d4c | 111 | \r |
b1f6a7c6 | 112 | Install PPI services.\r |
192f6d4c | 113 | \r |
b1f6a7c6 | 114 | @param PeiServices - Pointer to the PEI Service Table\r |
115 | @param PpiList - Pointer to a list of PEI PPI Descriptors.\r | |
116 | \r | |
117 | @retval EFI_SUCCESS - if all PPIs in PpiList are successfully installed.\r | |
118 | @retval EFI_INVALID_PARAMETER - if PpiList is NULL pointer\r | |
119 | @retval EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid\r | |
120 | @retval EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI\r | |
121 | \r | |
122 | **/\r | |
192f6d4c | 123 | EFI_STATUS\r |
124 | EFIAPI\r | |
125 | PeiInstallPpi (\r | |
0c2b5da8 | 126 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
127 | IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r | |
192f6d4c | 128 | )\r |
192f6d4c | 129 | {\r |
130 | PEI_CORE_INSTANCE *PrivateData;\r | |
131 | INTN Index;\r | |
132 | INTN LastCallbackInstall;\r | |
133 | \r | |
134 | \r | |
135 | if (PpiList == NULL) {\r | |
136 | return EFI_INVALID_PARAMETER;\r | |
137 | }\r | |
138 | \r | |
139 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r | |
140 | \r | |
141 | Index = PrivateData->PpiData.PpiListEnd;\r | |
142 | LastCallbackInstall = Index;\r | |
143 | \r | |
144 | //\r | |
145 | // This is loop installs all PPI descriptors in the PpiList. It is terminated\r | |
146 | // by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last\r | |
147 | // EFI_PEI_PPI_DESCRIPTOR in the list.\r | |
148 | //\r | |
58dcdada | 149 | \r |
192f6d4c | 150 | for (;;) {\r |
151 | //\r | |
152 | // Since PpiData is used for NotifyList and InstallList, max resource\r | |
153 | // is reached if the Install reaches the NotifyList\r | |
154 | //\r | |
155 | if (Index == PrivateData->PpiData.NotifyListEnd + 1) {\r | |
156 | return EFI_OUT_OF_RESOURCES;\r | |
157 | }\r | |
158 | //\r | |
58dcdada | 159 | // Check if it is a valid PPI.\r |
192f6d4c | 160 | // If not, rollback list to exclude all in this list.\r |
161 | // Try to indicate which item failed.\r | |
162 | //\r | |
163 | if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {\r | |
164 | PrivateData->PpiData.PpiListEnd = LastCallbackInstall;\r | |
165 | DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %x\n", PpiList->Guid, PpiList->Ppi));\r | |
166 | return EFI_INVALID_PARAMETER;\r | |
167 | }\r | |
168 | \r | |
58dcdada | 169 | DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));\r |
170 | PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;\r | |
192f6d4c | 171 | PrivateData->PpiData.PpiListEnd++;\r |
58dcdada | 172 | \r |
192f6d4c | 173 | //\r |
174 | // Continue until the end of the PPI List.\r | |
175 | //\r | |
58dcdada | 176 | if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r |
192f6d4c | 177 | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r |
178 | break;\r | |
179 | }\r | |
180 | PpiList++;\r | |
181 | Index++;\r | |
182 | }\r | |
183 | \r | |
184 | //\r | |
185 | // Dispatch any callback level notifies for newly installed PPIs.\r | |
186 | //\r | |
187 | DispatchNotify (\r | |
b0d803fe | 188 | PrivateData,\r |
192f6d4c | 189 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r |
190 | LastCallbackInstall,\r | |
191 | PrivateData->PpiData.PpiListEnd,\r | |
58dcdada | 192 | PrivateData->PpiData.DispatchListEnd,\r |
192f6d4c | 193 | PrivateData->PpiData.NotifyListEnd\r |
194 | );\r | |
195 | \r | |
196 | \r | |
197 | return EFI_SUCCESS;\r | |
198 | }\r | |
199 | \r | |
b1f6a7c6 | 200 | /**\r |
201 | \r | |
202 | Re-Install PPI services.\r | |
203 | \r | |
204 | @param PeiServices - Pointer to the PEI Service Table\r | |
205 | @param OldPpi - Pointer to the old PEI PPI Descriptors.\r | |
206 | @param NewPpi - Pointer to the new PEI PPI Descriptors.\r | |
192f6d4c | 207 | \r |
b1f6a7c6 | 208 | @retval EFI_SUCCESS - if the operation was successful\r |
209 | @retval EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL\r | |
210 | @retval EFI_INVALID_PARAMETER - if NewPpi is not valid\r | |
211 | @retval EFI_NOT_FOUND - if the PPI was not in the database\r | |
212 | \r | |
213 | **/\r | |
192f6d4c | 214 | EFI_STATUS\r |
215 | EFIAPI\r | |
216 | PeiReInstallPpi (\r | |
0c2b5da8 | 217 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
218 | IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r | |
219 | IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r | |
192f6d4c | 220 | )\r |
192f6d4c | 221 | {\r |
222 | PEI_CORE_INSTANCE *PrivateData;\r | |
223 | INTN Index;\r | |
224 | \r | |
225 | \r | |
226 | if ((OldPpi == NULL) || (NewPpi == NULL)) {\r | |
227 | return EFI_INVALID_PARAMETER;\r | |
228 | }\r | |
229 | \r | |
230 | if ((NewPpi->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {\r | |
231 | return EFI_INVALID_PARAMETER;\r | |
232 | }\r | |
233 | \r | |
234 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r | |
235 | \r | |
236 | //\r | |
237 | // Find the old PPI instance in the database. If we can not find it,\r | |
238 | // return the EFI_NOT_FOUND error.\r | |
239 | //\r | |
240 | for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {\r | |
241 | if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {\r | |
242 | break;\r | |
243 | }\r | |
244 | }\r | |
245 | if (Index == PrivateData->PpiData.PpiListEnd) {\r | |
246 | return EFI_NOT_FOUND;\r | |
247 | }\r | |
248 | \r | |
249 | //\r | |
250 | // Remove the old PPI from the database, add the new one.\r | |
58dcdada | 251 | //\r |
192f6d4c | 252 | DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));\r |
0c2b5da8 | 253 | PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;\r |
192f6d4c | 254 | \r |
255 | //\r | |
256 | // Dispatch any callback level notifies for the newly installed PPI.\r | |
257 | //\r | |
258 | DispatchNotify (\r | |
b0d803fe | 259 | PrivateData,\r |
192f6d4c | 260 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r |
261 | Index,\r | |
262 | Index+1,\r | |
58dcdada | 263 | PrivateData->PpiData.DispatchListEnd,\r |
192f6d4c | 264 | PrivateData->PpiData.NotifyListEnd\r |
265 | );\r | |
266 | \r | |
267 | \r | |
268 | return EFI_SUCCESS;\r | |
269 | }\r | |
270 | \r | |
b1f6a7c6 | 271 | /**\r |
272 | \r | |
273 | Locate a given named PPI.\r | |
274 | \r | |
192f6d4c | 275 | \r |
b1f6a7c6 | 276 | @param PeiServices - Pointer to the PEI Service Table\r |
277 | @param Guid - Pointer to GUID of the PPI.\r | |
278 | @param Instance - Instance Number to discover.\r | |
279 | @param PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r | |
280 | returns a pointer to the descriptor (includes flags, etc)\r | |
281 | @param Ppi - Pointer to reference the found PPI\r | |
282 | \r | |
283 | @retval EFI_SUCCESS if the PPI is in the database\r | |
284 | @retval EFI_NOT_FOUND if the PPI is not in the database\r | |
285 | \r | |
286 | **/\r | |
192f6d4c | 287 | EFI_STATUS\r |
288 | EFIAPI\r | |
289 | PeiLocatePpi (\r | |
0c2b5da8 | 290 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
291 | IN CONST EFI_GUID *Guid,\r | |
192f6d4c | 292 | IN UINTN Instance,\r |
293 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r | |
294 | IN OUT VOID **Ppi\r | |
295 | )\r | |
192f6d4c | 296 | {\r |
297 | PEI_CORE_INSTANCE *PrivateData;\r | |
298 | INTN Index;\r | |
299 | EFI_GUID *CheckGuid;\r | |
300 | EFI_PEI_PPI_DESCRIPTOR *TempPtr;\r | |
301 | \r | |
58dcdada | 302 | \r |
192f6d4c | 303 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r |
304 | \r | |
305 | //\r | |
306 | // Search the data base for the matching instance of the GUIDed PPI.\r | |
307 | //\r | |
308 | for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {\r | |
309 | TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;\r | |
310 | CheckGuid = TempPtr->Guid;\r | |
311 | \r | |
312 | //\r | |
313 | // Don't use CompareGuid function here for performance reasons.\r | |
314 | // Instead we compare the GUID as INT32 at a time and branch\r | |
315 | // on the first failed comparison.\r | |
316 | //\r | |
317 | if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) &&\r | |
318 | (((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) &&\r | |
319 | (((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) &&\r | |
320 | (((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3])) {\r | |
321 | if (Instance == 0) {\r | |
322 | \r | |
323 | if (PpiDescriptor != NULL) {\r | |
324 | *PpiDescriptor = TempPtr;\r | |
325 | }\r | |
326 | \r | |
327 | if (Ppi != NULL) {\r | |
328 | *Ppi = TempPtr->Ppi;\r | |
329 | }\r | |
330 | \r | |
331 | \r | |
332 | return EFI_SUCCESS;\r | |
333 | }\r | |
334 | Instance--;\r | |
335 | }\r | |
336 | }\r | |
337 | \r | |
338 | return EFI_NOT_FOUND;\r | |
339 | }\r | |
340 | \r | |
b1f6a7c6 | 341 | /**\r |
192f6d4c | 342 | \r |
b1f6a7c6 | 343 | Install a notification for a given PPI.\r |
344 | \r | |
345 | \r | |
346 | @param PeiServices - Pointer to the PEI Service Table\r | |
347 | @param NotifyList - Pointer to list of Descriptors to notify upon.\r | |
348 | \r | |
349 | @retval EFI_SUCCESS if successful\r | |
350 | @retval EFI_OUT_OF_RESOURCES if no space in the database\r | |
351 | @retval EFI_INVALID_PARAMETER if not a good decriptor\r | |
352 | \r | |
353 | **/\r | |
192f6d4c | 354 | EFI_STATUS\r |
355 | EFIAPI\r | |
356 | PeiNotifyPpi (\r | |
0c2b5da8 | 357 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
358 | IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r | |
192f6d4c | 359 | )\r |
192f6d4c | 360 | {\r |
361 | PEI_CORE_INSTANCE *PrivateData;\r | |
362 | INTN Index;\r | |
363 | INTN NotifyIndex;\r | |
364 | INTN LastCallbackNotify;\r | |
365 | EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;\r | |
366 | UINTN NotifyDispatchCount;\r | |
367 | \r | |
368 | \r | |
369 | NotifyDispatchCount = 0;\r | |
370 | \r | |
371 | if (NotifyList == NULL) {\r | |
372 | return EFI_INVALID_PARAMETER;\r | |
373 | }\r | |
374 | \r | |
375 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r | |
376 | \r | |
377 | Index = PrivateData->PpiData.NotifyListEnd;\r | |
378 | LastCallbackNotify = Index;\r | |
379 | \r | |
380 | //\r | |
381 | // This is loop installs all Notify descriptors in the NotifyList. It is\r | |
382 | // terminated by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last\r | |
383 | // EFI_PEI_NOTIFY_DESCRIPTOR in the list.\r | |
384 | //\r | |
385 | \r | |
386 | for (;;) {\r | |
387 | //\r | |
388 | // Since PpiData is used for NotifyList and InstallList, max resource\r | |
389 | // is reached if the Install reaches the PpiList\r | |
390 | //\r | |
391 | if (Index == PrivateData->PpiData.PpiListEnd - 1) {\r | |
392 | return EFI_OUT_OF_RESOURCES;\r | |
393 | }\r | |
58dcdada | 394 | \r |
192f6d4c | 395 | //\r |
396 | // If some of the PPI data is invalid restore original Notify PPI database value\r | |
397 | //\r | |
398 | if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {\r | |
399 | PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;\r | |
400 | DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %x\n", NotifyList->Guid, NotifyList->Notify));\r | |
401 | return EFI_INVALID_PARAMETER;\r | |
402 | }\r | |
58dcdada | 403 | \r |
192f6d4c | 404 | if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {\r |
58dcdada | 405 | NotifyDispatchCount ++;\r |
406 | }\r | |
407 | \r | |
408 | PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;\r | |
409 | \r | |
192f6d4c | 410 | PrivateData->PpiData.NotifyListEnd--;\r |
411 | DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));\r | |
412 | if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r | |
413 | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r | |
414 | break;\r | |
415 | }\r | |
416 | //\r | |
417 | // Go the next descriptor. Remember the NotifyList moves down.\r | |
418 | //\r | |
419 | NotifyList++;\r | |
420 | Index--;\r | |
421 | }\r | |
58dcdada | 422 | \r |
192f6d4c | 423 | //\r |
58dcdada | 424 | // If there is Dispatch Notify PPI installed put them on the bottom\r |
192f6d4c | 425 | //\r |
426 | if (NotifyDispatchCount > 0) {\r | |
58dcdada | 427 | for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) {\r |
192f6d4c | 428 | if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {\r |
429 | NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;\r | |
58dcdada | 430 | \r |
192f6d4c | 431 | for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){\r |
432 | PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify;\r | |
433 | }\r | |
434 | PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;\r | |
58dcdada | 435 | PrivateData->PpiData.DispatchListEnd--;\r |
192f6d4c | 436 | }\r |
437 | }\r | |
58dcdada | 438 | \r |
439 | LastCallbackNotify -= NotifyDispatchCount;\r | |
192f6d4c | 440 | }\r |
58dcdada | 441 | \r |
192f6d4c | 442 | //\r |
443 | // Dispatch any callback level notifies for all previously installed PPIs.\r | |
444 | //\r | |
445 | DispatchNotify (\r | |
b0d803fe | 446 | PrivateData,\r |
192f6d4c | 447 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r |
448 | 0,\r | |
449 | PrivateData->PpiData.PpiListEnd,\r | |
450 | LastCallbackNotify,\r | |
451 | PrivateData->PpiData.NotifyListEnd\r | |
452 | );\r | |
58dcdada | 453 | \r |
454 | \r | |
192f6d4c | 455 | return EFI_SUCCESS;\r |
456 | }\r | |
457 | \r | |
458 | \r | |
b1f6a7c6 | 459 | /**\r |
192f6d4c | 460 | \r |
461 | Process the Notify List at dispatch level.\r | |
462 | \r | |
b1f6a7c6 | 463 | @param PrivateData PeiCore's private data structure.\r |
192f6d4c | 464 | \r |
b1f6a7c6 | 465 | **/\r |
466 | VOID\r | |
467 | ProcessNotifyList (\r | |
468 | IN PEI_CORE_INSTANCE *PrivateData\r | |
469 | )\r | |
192f6d4c | 470 | {\r |
192f6d4c | 471 | INTN TempValue;\r |
58dcdada | 472 | \r |
192f6d4c | 473 | while (TRUE) {\r |
474 | //\r | |
475 | // Check if the PEIM that was just dispatched resulted in any\r | |
476 | // Notifies getting installed. If so, go process any dispatch\r | |
477 | // level Notifies that match the previouly installed PPIs.\r | |
58dcdada | 478 | // Use "while" instead of "if" since DispatchNotify can modify\r |
192f6d4c | 479 | // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.\r |
480 | //\r | |
481 | while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) {\r | |
482 | TempValue = PrivateData->PpiData.DispatchListEnd;\r | |
483 | DispatchNotify (\r | |
b0d803fe | 484 | PrivateData,\r |
192f6d4c | 485 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,\r |
486 | 0,\r | |
487 | PrivateData->PpiData.LastDispatchedInstall,\r | |
488 | PrivateData->PpiData.LastDispatchedNotify,\r | |
489 | PrivateData->PpiData.DispatchListEnd\r | |
490 | );\r | |
491 | PrivateData->PpiData.LastDispatchedNotify = TempValue;\r | |
492 | }\r | |
58dcdada | 493 | \r |
494 | \r | |
192f6d4c | 495 | //\r |
496 | // Check if the PEIM that was just dispatched resulted in any\r | |
497 | // PPIs getting installed. If so, go process any dispatch\r | |
498 | // level Notifies that match the installed PPIs.\r | |
58dcdada | 499 | // Use "while" instead of "if" since DispatchNotify can modify\r |
192f6d4c | 500 | // PpiListEnd (with InstallPpi) so we have to iterate until the same.\r |
501 | //\r | |
502 | while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) {\r | |
503 | TempValue = PrivateData->PpiData.PpiListEnd;\r | |
504 | DispatchNotify (\r | |
b0d803fe | 505 | PrivateData,\r |
192f6d4c | 506 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,\r |
507 | PrivateData->PpiData.LastDispatchedInstall,\r | |
508 | PrivateData->PpiData.PpiListEnd,\r | |
eaf539d0 | 509 | FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1,\r |
192f6d4c | 510 | PrivateData->PpiData.DispatchListEnd\r |
511 | );\r | |
512 | PrivateData->PpiData.LastDispatchedInstall = TempValue;\r | |
513 | }\r | |
58dcdada | 514 | \r |
192f6d4c | 515 | if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) {\r |
516 | break;\r | |
517 | }\r | |
58dcdada | 518 | }\r |
192f6d4c | 519 | return;\r |
520 | }\r | |
521 | \r | |
b1f6a7c6 | 522 | /**\r |
523 | \r | |
524 | Dispatch notifications.\r | |
525 | \r | |
526 | @param PrivateData PeiCore's private data structure\r | |
527 | @param NotifyType Type of notify to fire.\r | |
528 | @param InstallStartIndex Install Beginning index.\r | |
529 | @param InstallStopIndex Install Ending index.\r | |
530 | @param NotifyStartIndex Notify Beginning index.\r | |
531 | @param NotifyStopIndex Notify Ending index.\r | |
532 | \r | |
533 | **/\r | |
192f6d4c | 534 | VOID\r |
535 | DispatchNotify (\r | |
b0d803fe | 536 | IN PEI_CORE_INSTANCE *PrivateData,\r |
192f6d4c | 537 | IN UINTN NotifyType,\r |
538 | IN INTN InstallStartIndex,\r | |
539 | IN INTN InstallStopIndex,\r | |
540 | IN INTN NotifyStartIndex,\r | |
541 | IN INTN NotifyStopIndex\r | |
542 | )\r | |
192f6d4c | 543 | {\r |
192f6d4c | 544 | INTN Index1;\r |
545 | INTN Index2;\r | |
546 | EFI_GUID *SearchGuid;\r | |
547 | EFI_GUID *CheckGuid;\r | |
548 | EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r | |
549 | \r | |
192f6d4c | 550 | //\r |
551 | // Remember that Installs moves up and Notifies moves down.\r | |
552 | //\r | |
553 | for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {\r | |
554 | NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;\r | |
555 | \r | |
556 | CheckGuid = NotifyDescriptor->Guid;\r | |
557 | \r | |
558 | for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {\r | |
559 | SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;\r | |
560 | //\r | |
561 | // Don't use CompareGuid function here for performance reasons.\r | |
562 | // Instead we compare the GUID as INT32 at a time and branch\r | |
563 | // on the first failed comparison.\r | |
564 | //\r | |
565 | if ((((INT32 *)SearchGuid)[0] == ((INT32 *)CheckGuid)[0]) &&\r | |
566 | (((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) &&\r | |
567 | (((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) &&\r | |
568 | (((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) {\r | |
58dcdada | 569 | DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %x\n",\r |
570 | SearchGuid,\r | |
192f6d4c | 571 | NotifyDescriptor->Notify\r |
572 | ));\r | |
573 | NotifyDescriptor->Notify (\r | |
b0d803fe | 574 | GetPeiServicesTablePointer (),\r |
192f6d4c | 575 | NotifyDescriptor,\r |
576 | (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi\r | |
577 | );\r | |
578 | }\r | |
579 | }\r | |
580 | }\r | |
581 | \r | |
582 | return;\r | |
583 | }\r | |
584 | \r |