]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Logo/Logo.c
MdeModulePkg/CapsuleRuntimeDxe: Add RISCV64 architecture
[mirror_edk2.git] / MdeModulePkg / Logo / Logo.c
CommitLineData
af468025
RN
1/** @file\r
2 Logo DXE Driver, install Edkii Platform Logo protocol.\r
3\r
1c020add 4Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
af468025
RN
6\r
7**/\r
8#include <Uefi.h>\r
9#include <Protocol/HiiDatabase.h>\r
10#include <Protocol/GraphicsOutput.h>\r
11#include <Protocol/HiiImageEx.h>\r
12#include <Protocol/PlatformLogo.h>\r
13#include <Protocol/HiiPackageList.h>\r
14#include <Library/UefiBootServicesTableLib.h>\r
15#include <Library/DebugLib.h>\r
16\r
17typedef struct {\r
18 EFI_IMAGE_ID ImageId;\r
19 EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;\r
20 INTN OffsetX;\r
21 INTN OffsetY;\r
22} LOGO_ENTRY;\r
23\r
24EFI_HII_IMAGE_EX_PROTOCOL *mHiiImageEx;\r
25EFI_HII_HANDLE mHiiHandle;\r
26LOGO_ENTRY mLogos[] = {\r
27 {\r
28 IMAGE_TOKEN (IMG_LOGO),\r
29 EdkiiPlatformLogoDisplayAttributeCenter,\r
30 0,\r
31 0\r
32 }\r
33};\r
34\r
35/**\r
36 Load a platform logo image and return its data and attributes.\r
37\r
38 @param This The pointer to this protocol instance.\r
39 @param Instance The visible image instance is found.\r
40 @param Image Points to the image.\r
41 @param Attribute The display attributes of the image returned.\r
42 @param OffsetX The X offset of the image regarding the Attribute.\r
43 @param OffsetY The Y offset of the image regarding the Attribute.\r
44\r
45 @retval EFI_SUCCESS The image was fetched successfully.\r
46 @retval EFI_NOT_FOUND The specified image could not be found.\r
47**/\r
48EFI_STATUS\r
49EFIAPI\r
50GetImage (\r
51 IN EDKII_PLATFORM_LOGO_PROTOCOL *This,\r
52 IN OUT UINT32 *Instance,\r
53 OUT EFI_IMAGE_INPUT *Image,\r
54 OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,\r
55 OUT INTN *OffsetX,\r
56 OUT INTN *OffsetY\r
57 )\r
58{\r
59 UINT32 Current;\r
60 if (Instance == NULL || Image == NULL ||\r
61 Attribute == NULL || OffsetX == NULL || OffsetY == NULL) {\r
62 return EFI_INVALID_PARAMETER;\r
63 }\r
64\r
65 Current = *Instance;\r
ac127309 66 if (Current >= ARRAY_SIZE (mLogos)) {\r
af468025
RN
67 return EFI_NOT_FOUND;\r
68 }\r
69\r
70 (*Instance)++;\r
71 *Attribute = mLogos[Current].Attribute;\r
72 *OffsetX = mLogos[Current].OffsetX;\r
73 *OffsetY = mLogos[Current].OffsetY;\r
74 return mHiiImageEx->GetImageEx (mHiiImageEx, mHiiHandle, mLogos[Current].ImageId, Image);\r
75}\r
76\r
77EDKII_PLATFORM_LOGO_PROTOCOL mPlatformLogo = {\r
78 GetImage\r
79};\r
80\r
81/**\r
82 Entrypoint of this module.\r
83\r
84 This function is the entrypoint of this module. It installs the Edkii\r
85 Platform Logo protocol.\r
86\r
87 @param ImageHandle The firmware allocated handle for the EFI image.\r
88 @param SystemTable A pointer to the EFI System Table.\r
89\r
90 @retval EFI_SUCCESS The entry point is executed successfully.\r
91\r
92**/\r
93EFI_STATUS\r
94EFIAPI\r
95InitializeLogo (\r
96 IN EFI_HANDLE ImageHandle,\r
97 IN EFI_SYSTEM_TABLE *SystemTable\r
98 )\r
99{\r
100 EFI_STATUS Status;\r
101 EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
102 EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
103 EFI_HANDLE Handle;\r
104\r
105 Status = gBS->LocateProtocol (\r
106 &gEfiHiiDatabaseProtocolGuid,\r
107 NULL,\r
108 (VOID **) &HiiDatabase\r
109 );\r
110 ASSERT_EFI_ERROR (Status);\r
111\r
112 Status = gBS->LocateProtocol (\r
113 &gEfiHiiImageExProtocolGuid,\r
114 NULL,\r
115 (VOID **) &mHiiImageEx\r
116 );\r
117 ASSERT_EFI_ERROR (Status);\r
118\r
119 //\r
120 // Retrieve HII package list from ImageHandle\r
121 //\r
122 Status = gBS->OpenProtocol (\r
123 ImageHandle,\r
124 &gEfiHiiPackageListProtocolGuid,\r
125 (VOID **) &PackageList,\r
126 ImageHandle,\r
127 NULL,\r
128 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
129 );\r
1c020add
MK
130 if (EFI_ERROR (Status)) {\r
131 DEBUG ((DEBUG_ERROR, "HII Image Package with logo not found in PE/COFF resource section\n"));\r
132 return Status;\r
133 }\r
af468025
RN
134\r
135 //\r
136 // Publish HII package list to HII Database.\r
137 //\r
138 Status = HiiDatabase->NewPackageList (\r
139 HiiDatabase,\r
140 PackageList,\r
141 NULL,\r
142 &mHiiHandle\r
143 );\r
144 if (!EFI_ERROR (Status)) {\r
145 Handle = NULL;\r
146 Status = gBS->InstallMultipleProtocolInterfaces (\r
147 &Handle,\r
148 &gEdkiiPlatformLogoProtocolGuid, &mPlatformLogo,\r
149 NULL\r
150 );\r
151 }\r
152 return Status;\r
153}\r