/** Shadow PeiCore module from flash to installed memory. @param PrivateData PeiCore's private data structure @return PeiCore function address after shadowing. **/ PEICORE_FUNCTION_POINTER ShadowPeiCore ( IN PEI_CORE_INSTANCE *PrivateData ) { EFI_PEI_FILE_HANDLE PeiCoreFileHandle; EFI_PHYSICAL_ADDRESS EntryPoint; EFI_STATUS Status; UINT32 AuthenticationState; PeiCoreFileHandle = NULL; // // Find the PEI Core in the BFV // Status = PrivateData->Fv[0].FvPpi->FindFileByType ( PrivateData->Fv[0].FvPpi, EFI_FV_FILETYPE_PEI_CORE, PrivateData->Fv[0].FvHandle, &PeiCoreFileHandle ); ASSERT_EFI_ERROR (Status); // // Shadow PEI Core into memory so it will run faster // Status = PeiLoadImage ( GetPeiServicesTablePointer (), *((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle), PEIM_STATE_REGISITER_FOR_SHADOW, &EntryPoint, &AuthenticationState ); ASSERT_EFI_ERROR (Status); // // Compute the PeiCore's function address after shaowed PeiCore. // _ModuleEntryPoint is PeiCore main function entry // return (PEICORE_FUNCTION_POINTER)((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint); }
/** Shadow PeiCore module from flash to installed memory. @param PrivateData PeiCore's private data structure @return PeiCore function address after shadowing. **/ PEICORE_FUNCTION_POINTER ShadowPeiCore ( IN PEI_CORE_INSTANCE *PrivateData ) { EFI_PEI_FILE_HANDLE PeiCoreFileHandle; EFI_PHYSICAL_ADDRESS EntryPoint; EFI_STATUS Status; UINT32 AuthenticationState; UINTN Index; EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi; UINTN PeiCoreFvIndex; PeiCoreFileHandle = NULL; // // Default PeiCore is in BFV // PeiCoreFvIndex = 0; // // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI indicated FV or BFV // Status = PeiServicesLocatePpi ( &gEfiPeiCoreFvLocationPpiGuid, 0, NULL, (VOID **) &PeiCoreFvLocationPpi ); if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation != NULL)) { // // If PeiCoreFvLocation present, the PEI Core should be found from indicated FV // for (Index = 0; Index < PrivateData->FvCount; Index ++) { if (PrivateData->Fv[Index].FvHandle == PeiCoreFvLocationPpi->PeiCoreFvLocation) { PeiCoreFvIndex = Index; break; } } ASSERT (Index < PrivateData->FvCount); } // // Find PEI Core from the given FV index // Status = PrivateData->Fv[PeiCoreFvIndex].FvPpi->FindFileByType ( PrivateData->Fv[PeiCoreFvIndex].FvPpi, EFI_FV_FILETYPE_PEI_CORE, PrivateData->Fv[PeiCoreFvIndex].FvHandle, &PeiCoreFileHandle ); ASSERT_EFI_ERROR (Status); // // Shadow PEI Core into memory so it will run faster // Status = PeiLoadImage ( GetPeiServicesTablePointer (), *((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle), PEIM_STATE_REGISTER_FOR_SHADOW, &EntryPoint, &AuthenticationState ); ASSERT_EFI_ERROR (Status); // // Compute the PeiCore's function address after shaowed PeiCore. // _ModuleEntryPoint is PeiCore main function entry // return (PEICORE_FUNCTION_POINTER)((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint); }