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