/** Measure main BIOS. @retval EFI_SUCCESS Operation completed successfully. @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event. @retval EFI_DEVICE_ERROR The command was unsuccessful. **/ EFI_STATUS MeasureMainBios ( VOID ) { EFI_STATUS Status; UINT32 FvInstances; EFI_PEI_FV_HANDLE VolumeHandle; EFI_FV_INFO VolumeInfo; EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi; PERF_START_EX (mFileHandle, "EventRec", "TrEEPei", 0, PERF_ID_TREE_PEI); FvInstances = 0; while (TRUE) { // // Traverse all firmware volume instances of Static Core Root of Trust for Measurement // (S-CRTM), this firmware volume measure policy can be modified/enhanced by special // platform for special CRTM TPM measuring. // Status = PeiServicesFfsFindNextVolume (FvInstances, &VolumeHandle); if (EFI_ERROR (Status)) { break; } // // Measure and record the firmware volume that is dispatched by PeiCore // Status = PeiServicesFfsGetVolumeInfo (VolumeHandle, &VolumeInfo); ASSERT_EFI_ERROR (Status); // // Locate the corresponding FV_PPI according to founded FV's format guid // Status = PeiServicesLocatePpi ( &VolumeInfo.FvFormat, 0, NULL, (VOID**)&FvPpi ); if (!EFI_ERROR (Status)) { MeasureFvImage ((EFI_PHYSICAL_ADDRESS) (UINTN) VolumeInfo.FvStart, VolumeInfo.FvSize); } FvInstances++; } PERF_END_EX (mFileHandle, "EventRec", "TrEEPei", 0, PERF_ID_TREE_PEI + 1); return EFI_SUCCESS; }
/** Searches DxeCore in all firmware Volumes and loads the first instance that contains DxeCore. @return FileHandle of DxeCore to load DxeCore. **/ EFI_PEI_FILE_HANDLE DxeIplFindDxeCore ( VOID ) { EFI_STATUS Status; UINTN Instance; EFI_PEI_FV_HANDLE VolumeHandle; EFI_PEI_FILE_HANDLE FileHandle; Instance = 0; while (TRUE) { // // Traverse all firmware volume instances // Status = PeiServicesFfsFindNextVolume (Instance, &VolumeHandle); // // If some error occurs here, then we cannot find any firmware // volume that may contain DxeCore. // if (EFI_ERROR (Status)) { REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_EC_DXE_CORRUPT)); } ASSERT_EFI_ERROR (Status); // // Find the DxeCore file type from the beginning in this firmware volume. // FileHandle = NULL; Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle); if (!EFI_ERROR (Status)) { // // Find DxeCore FileHandle in this volume, then we skip other firmware volume and // return the FileHandle. // return FileHandle; } // // We cannot find DxeCore in this firmware volume, then search the next volume. // Instance++; } }