]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Logo/Logo.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
1436aea4
MK
18 EFI_IMAGE_ID ImageId;\r
19 EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;\r
20 INTN OffsetX;\r
21 INTN OffsetY;\r
af468025
RN
22} LOGO_ENTRY;\r
23\r
1436aea4
MK
24EFI_HII_IMAGE_EX_PROTOCOL *mHiiImageEx;\r
25EFI_HII_HANDLE mHiiHandle;\r
26LOGO_ENTRY mLogos[] = {\r
af468025
RN
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
1436aea4
MK
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
af468025
RN
57 )\r
58{\r
1436aea4
MK
59 UINT32 Current;\r
60\r
61 if ((Instance == NULL) || (Image == NULL) ||\r
62 (Attribute == NULL) || (OffsetX == NULL) || (OffsetY == NULL))\r
63 {\r
af468025
RN
64 return EFI_INVALID_PARAMETER;\r
65 }\r
66\r
67 Current = *Instance;\r
ac127309 68 if (Current >= ARRAY_SIZE (mLogos)) {\r
af468025
RN
69 return EFI_NOT_FOUND;\r
70 }\r
71\r
72 (*Instance)++;\r
73 *Attribute = mLogos[Current].Attribute;\r
74 *OffsetX = mLogos[Current].OffsetX;\r
75 *OffsetY = mLogos[Current].OffsetY;\r
76 return mHiiImageEx->GetImageEx (mHiiImageEx, mHiiHandle, mLogos[Current].ImageId, Image);\r
77}\r
78\r
1436aea4 79EDKII_PLATFORM_LOGO_PROTOCOL mPlatformLogo = {\r
af468025
RN
80 GetImage\r
81};\r
82\r
83/**\r
84 Entrypoint of this module.\r
85\r
86 This function is the entrypoint of this module. It installs the Edkii\r
87 Platform Logo protocol.\r
88\r
89 @param ImageHandle The firmware allocated handle for the EFI image.\r
90 @param SystemTable A pointer to the EFI System Table.\r
91\r
92 @retval EFI_SUCCESS The entry point is executed successfully.\r
93\r
94**/\r
95EFI_STATUS\r
96EFIAPI\r
97InitializeLogo (\r
1436aea4
MK
98 IN EFI_HANDLE ImageHandle,\r
99 IN EFI_SYSTEM_TABLE *SystemTable\r
af468025
RN
100 )\r
101{\r
1436aea4
MK
102 EFI_STATUS Status;\r
103 EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
104 EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
105 EFI_HANDLE Handle;\r
af468025
RN
106\r
107 Status = gBS->LocateProtocol (\r
108 &gEfiHiiDatabaseProtocolGuid,\r
109 NULL,\r
1436aea4 110 (VOID **)&HiiDatabase\r
af468025
RN
111 );\r
112 ASSERT_EFI_ERROR (Status);\r
113\r
114 Status = gBS->LocateProtocol (\r
115 &gEfiHiiImageExProtocolGuid,\r
116 NULL,\r
1436aea4 117 (VOID **)&mHiiImageEx\r
af468025
RN
118 );\r
119 ASSERT_EFI_ERROR (Status);\r
120\r
121 //\r
122 // Retrieve HII package list from ImageHandle\r
123 //\r
124 Status = gBS->OpenProtocol (\r
125 ImageHandle,\r
126 &gEfiHiiPackageListProtocolGuid,\r
1436aea4 127 (VOID **)&PackageList,\r
af468025
RN
128 ImageHandle,\r
129 NULL,\r
130 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
131 );\r
1c020add
MK
132 if (EFI_ERROR (Status)) {\r
133 DEBUG ((DEBUG_ERROR, "HII Image Package with logo not found in PE/COFF resource section\n"));\r
134 return Status;\r
135 }\r
af468025
RN
136\r
137 //\r
138 // Publish HII package list to HII Database.\r
139 //\r
140 Status = HiiDatabase->NewPackageList (\r
141 HiiDatabase,\r
142 PackageList,\r
143 NULL,\r
144 &mHiiHandle\r
145 );\r
146 if (!EFI_ERROR (Status)) {\r
147 Handle = NULL;\r
148 Status = gBS->InstallMultipleProtocolInterfaces (\r
149 &Handle,\r
1436aea4
MK
150 &gEdkiiPlatformLogoProtocolGuid,\r
151 &mPlatformLogo,\r
af468025
RN
152 NULL\r
153 );\r
154 }\r
1436aea4 155\r
af468025
RN
156 return Status;\r
157}\r