27BOOLEAN mImageLoadedAfterEndOfDxe =
FALSE;
61 Status =
gBS->LocateDevicePath (
62 &gEfiFirmwareVolume2ProtocolGuid,
66 if (!EFI_ERROR (Status)) {
67 Status =
gBS->OpenProtocol (
69 &gEfiFirmwareVolume2ProtocolGuid,
73 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
75 if (!EFI_ERROR (Status)) {
102 for (Index = 0; Index < mDeferred3rdPartyImage.
Count; Index++) {
103 if (
CompareMem (ImageDevicePath, mDeferred3rdPartyImage.
ImageInfo[Index].ImageDevicePath, DevicePathSize) == 0) {
104 ASSERT (mDeferred3rdPartyImage.
ImageInfo[Index].BootOption == BootOption);
105 return &mDeferred3rdPartyImage.
ImageInfo[Index];
122 IN BOOLEAN BootOption
135 if (ImageInfo ==
NULL) {
139 mDeferred3rdPartyImage.
ImageInfo = ImageInfo;
144 ImageInfo = &mDeferred3rdPartyImage.
ImageInfo[mDeferred3rdPartyImage.
Count];
146 if (ImageInfo->ImageDevicePath ==
NULL) {
150 ImageInfo->BootOption = BootOption;
151 ImageInfo->Loaded =
FALSE;
152 mDeferred3rdPartyImage.
Count++;
190 OUT BOOLEAN *BootOption
196 if ((This ==
NULL) || (ImageSize ==
NULL) || (Image ==
NULL)) {
197 return EFI_INVALID_PARAMETER;
200 if ((ImageDevicePath ==
NULL) || (BootOption ==
NULL)) {
201 return EFI_INVALID_PARAMETER;
207 if (ImageIndex == 0) {
209 for (Index = 0; Index < mDeferred3rdPartyImage.
Count; Index++) {
210 if (!mDeferred3rdPartyImage.
ImageInfo[Index].Loaded) {
212 &mDeferred3rdPartyImage.
ImageInfo[NewCount],
213 &mDeferred3rdPartyImage.
ImageInfo[Index],
220 mDeferred3rdPartyImage.
Count = NewCount;
223 if (ImageIndex >= mDeferred3rdPartyImage.
Count) {
224 return EFI_NOT_FOUND;
230 *ImageDevicePath = mDeferred3rdPartyImage.
ImageInfo[ImageIndex].ImageDevicePath;
231 *BootOption = mDeferred3rdPartyImage.
ImageInfo[ImageIndex].BootOption;
277 Status =
gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid,
NULL, &Interface);
278 if (EFI_ERROR (Status)) {
282 gBS->CloseEvent (Event);
284 if (mImageLoadedAfterEndOfDxe) {
291 "[Security] 3rd party images must be dispatched after DxeSmmReadyToLock Protocol installation!\n"
294 EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED,
295 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)
316 IN BOOLEAN BootPolicy
335 CHAR16 *DevicePathStr;
340 "[Security] 3rd party image[%p] %s EndOfDxe: %s.\n",
342 mEndOfDxe ? L
"can be loaded after" : L
"is deferred to load before",
345 if (DevicePathStr !=
NULL) {
352 mImageLoadedAfterEndOfDxe =
TRUE;
357 if (ImageInfo !=
NULL) {
358 ImageInfo->Loaded =
TRUE;
367 if (ImageInfo ==
NULL) {
371 return EFI_ACCESS_DENIED;
389 Status =
gBS->InstallMultipleProtocolInterfaces (
391 &gEfiDeferredImageLoadProtocolGuid,
397 Status =
gBS->CreateEventEx (
402 &gEfiEndOfDxeEventGroupGuid,
408 &gEfiDxeSmmReadyToLockProtocolGuid,
VOID EFIAPI CpuDeadLoop(VOID)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS Defer3rdPartyImageLoad(IN CONST EFI_DEVICE_PATH_PROTOCOL *File, IN BOOLEAN BootPolicy)
VOID Defer3rdPartyImageLoadInitialize(VOID)
EFI_STATUS EFIAPI GetDefferedImageInfo(IN EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *This, IN UINTN ImageIndex, OUT EFI_DEVICE_PATH_PROTOCOL **ImageDevicePath, OUT VOID **Image, OUT UINTN *ImageSize, OUT BOOLEAN *BootOption)
VOID QueueImage(IN CONST EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath, IN BOOLEAN BootOption)
VOID EFIAPI EndOfDxe(IN EFI_EVENT Event, IN VOID *Context)
DEFERRED_3RD_PARTY_IMAGE_INFO * LookupImage(IN CONST EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath, IN BOOLEAN BootOption)
BOOLEAN FileFromFv(IN CONST EFI_DEVICE_PATH_PROTOCOL *File)
VOID EFIAPI DxeSmmReadyToLock(IN EFI_EVENT Event, IN VOID *Context)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DuplicateDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define REPORT_STATUS_CODE(Type, Value)
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
DEFERRED_3RD_PARTY_IMAGE_INFO * ImageInfo
deferred 3rd party image item
UINTN Count
deferred 3rd party image count