/** @file\r
Head file for BDS Architectural Protocol implementation\r
\r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
#include <Guid/ConnectConInEvent.h>\r
#include <Guid/Performance.h>\r
#include <Guid/StatusCodeDataTypeVariable.h>\r
+#include <Guid/EventGroup.h>\r
\r
#include <Protocol/Bds.h>\r
#include <Protocol/LoadedImage.h>\r
#include <Protocol/VariableLock.h>\r
+#include <Protocol/DeferredImageLoad.h>\r
\r
#include <Library/UefiDriverEntryPoint.h>\r
#include <Library/DebugLib.h>\r
gConnectConInEventGuid ## SOMETIMES_CONSUMES ## Event\r
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID\r
gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data)\r
+ gEfiEventReadyToBootGuid ## CONSUMES ## Event\r
\r
[Protocols]\r
gEfiBdsArchProtocolGuid ## PRODUCES\r
gEfiSimpleTextInputExProtocolGuid ## CONSUMES\r
gEdkiiVariableLockProtocolGuid ## CONSUMES\r
+ gEfiDeferredImageLoadProtocolGuid ## CONSUMES\r
\r
[FeaturePcd]\r
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES\r
DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status));\r
}\r
}\r
+/**\r
+ Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to\r
+ check whether there is remaining deferred load images.\r
+\r
+ @param[in] Event The Event that is being processed.\r
+ @param[in] Context The Event Context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CheckDeferredLoadImageOnReadyToBoot (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE *Handles;\r
+ UINTN Index;\r
+ UINTN ImageIndex;\r
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;\r
+ VOID *Image;\r
+ UINTN ImageSize;\r
+ BOOLEAN BootOption;\r
+ CHAR16 *DevicePathStr;\r
+\r
+ //\r
+ // Find all the deferred image load protocols.\r
+ //\r
+ HandleCount = 0;\r
+ Handles = NULL;\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ &gEfiDeferredImageLoadProtocolGuid,\r
+ NULL,\r
+ &HandleCount,\r
+ &Handles\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return;\r
+ }\r
+\r
+ for (Index = 0; Index < HandleCount; Index++) {\r
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+\r
+ for (ImageIndex = 0; ; ImageIndex++) {\r
+ //\r
+ // Load all the deferred images in this protocol instance.\r
+ //\r
+ Status = DeferredImage->GetImageInfo (\r
+ DeferredImage,\r
+ ImageIndex,\r
+ &ImageDevicePath,\r
+ (VOID **) &Image,\r
+ &ImageSize,\r
+ &BootOption\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
+ }\r
+ DevicePathStr = ConvertDevicePathToText (ImageDevicePath, FALSE, FALSE);\r
+ DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not loaded: %s.\n", DevicePathStr));\r
+ if (DevicePathStr != NULL) {\r
+ FreePool (DevicePathStr);\r
+ }\r
+ }\r
+ }\r
+ if (Handles != NULL) {\r
+ FreePool (Handles);\r
+ }\r
+}\r
\r
/**\r
\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ DEBUG_CODE (\r
+ EFI_EVENT Event;\r
+ //\r
+ // Register notify function to check deferred images on ReadyToBoot Event.\r
+ //\r
+ Status = gBS->CreateEventEx (\r
+ EVT_NOTIFY_SIGNAL,\r
+ TPL_CALLBACK,\r
+ CheckDeferredLoadImageOnReadyToBoot,\r
+ NULL,\r
+ &gEfiEventReadyToBootGuid,\r
+ &Event\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ );\r
return Status;\r
}\r
\r