--- /dev/null
+/** @file\r
+ Logo DXE Driver, install Edkii Platform Logo protocol.\r
+\r
+Copyright (c) 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <Uefi.h>\r
+#include <Protocol/HiiDatabase.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/HiiImageEx.h>\r
+#include <Protocol/PlatformLogo.h>\r
+#include <Protocol/HiiPackageList.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+typedef struct {\r
+ EFI_IMAGE_ID ImageId;\r
+ EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;\r
+ INTN OffsetX;\r
+ INTN OffsetY;\r
+} LOGO_ENTRY;\r
+\r
+EFI_HII_IMAGE_EX_PROTOCOL *mHiiImageEx;\r
+EFI_HII_HANDLE mHiiHandle;\r
+LOGO_ENTRY mLogos[] = {\r
+ {\r
+ IMAGE_TOKEN (IMG_LOGO),\r
+ EdkiiPlatformLogoDisplayAttributeCenter,\r
+ 0,\r
+ 0\r
+ }\r
+};\r
+\r
+/**\r
+ Load a platform logo image and return its data and attributes.\r
+\r
+ @param This The pointer to this protocol instance.\r
+ @param Instance The visible image instance is found.\r
+ @param Image Points to the image.\r
+ @param Attribute The display attributes of the image returned.\r
+ @param OffsetX The X offset of the image regarding the Attribute.\r
+ @param OffsetY The Y offset of the image regarding the Attribute.\r
+\r
+ @retval EFI_SUCCESS The image was fetched successfully.\r
+ @retval EFI_NOT_FOUND The specified image could not be found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetImage (\r
+ IN EDKII_PLATFORM_LOGO_PROTOCOL *This,\r
+ IN OUT UINT32 *Instance,\r
+ OUT EFI_IMAGE_INPUT *Image,\r
+ OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,\r
+ OUT INTN *OffsetX,\r
+ OUT INTN *OffsetY\r
+ )\r
+{\r
+ UINT32 Current;\r
+ if (Instance == NULL || Image == NULL ||\r
+ Attribute == NULL || OffsetX == NULL || OffsetY == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Current = *Instance;\r
+ if (Current >= sizeof (mLogos) / sizeof (mLogos[0])) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ (*Instance)++;\r
+ *Attribute = mLogos[Current].Attribute;\r
+ *OffsetX = mLogos[Current].OffsetX;\r
+ *OffsetY = mLogos[Current].OffsetY;\r
+ return mHiiImageEx->GetImageEx (mHiiImageEx, mHiiHandle, mLogos[Current].ImageId, Image);\r
+}\r
+\r
+EDKII_PLATFORM_LOGO_PROTOCOL mPlatformLogo = {\r
+ GetImage\r
+};\r
+\r
+/**\r
+ Entrypoint of this module.\r
+\r
+ This function is the entrypoint of this module. It installs the Edkii\r
+ Platform Logo protocol.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeLogo (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
+ EFI_HANDLE Handle;\r
+\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiHiiDatabaseProtocolGuid,\r
+ NULL,\r
+ (VOID **) &HiiDatabase\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiHiiImageExProtocolGuid,\r
+ NULL,\r
+ (VOID **) &mHiiImageEx\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Retrieve HII package list from ImageHandle\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ImageHandle,\r
+ &gEfiHiiPackageListProtocolGuid,\r
+ (VOID **) &PackageList,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Publish HII package list to HII Database.\r
+ //\r
+ Status = HiiDatabase->NewPackageList (\r
+ HiiDatabase,\r
+ PackageList,\r
+ NULL,\r
+ &mHiiHandle\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Handle = NULL;\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Handle,\r
+ &gEdkiiPlatformLogoProtocolGuid, &mPlatformLogo,\r
+ NULL\r
+ );\r
+ }\r
+ return Status;\r
+}\r