1 | /* $Id: Logo.c 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Logo DXE Driver, install Edkii Platform Logo protocol.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2019-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | * ---------------------------------------------------------------------------
|
---|
36 | * This code is based on:
|
---|
37 | *
|
---|
38 | * Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
|
---|
39 | * SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
40 | */
|
---|
41 | #include <Uefi.h>
|
---|
42 | #include <Protocol/HiiDatabase.h>
|
---|
43 | #include <Protocol/GraphicsOutput.h>
|
---|
44 | #include <Protocol/HiiImageEx.h>
|
---|
45 | #include <Protocol/PlatformLogo.h>
|
---|
46 | #include <Protocol/HiiPackageList.h>
|
---|
47 | #include <Library/UefiBootServicesTableLib.h>
|
---|
48 | #include <Library/DebugLib.h>
|
---|
49 |
|
---|
50 | typedef struct {
|
---|
51 | EFI_IMAGE_ID ImageId;
|
---|
52 | EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;
|
---|
53 | INTN OffsetX;
|
---|
54 | INTN OffsetY;
|
---|
55 | } LOGO_ENTRY;
|
---|
56 |
|
---|
57 | EFI_HII_IMAGE_EX_PROTOCOL *mHiiImageEx;
|
---|
58 | EFI_HII_HANDLE mHiiHandle;
|
---|
59 | LOGO_ENTRY mLogos[] = {
|
---|
60 | {
|
---|
61 | IMAGE_TOKEN (IMG_LOGO),
|
---|
62 | EdkiiPlatformLogoDisplayAttributeCenter,
|
---|
63 | 0,
|
---|
64 | 0
|
---|
65 | }
|
---|
66 | };
|
---|
67 |
|
---|
68 | /**
|
---|
69 | Load a platform logo image and return its data and attributes.
|
---|
70 |
|
---|
71 | @param This The pointer to this protocol instance.
|
---|
72 | @param Instance The visible image instance is found.
|
---|
73 | @param Image Points to the image.
|
---|
74 | @param Attribute The display attributes of the image returned.
|
---|
75 | @param OffsetX The X offset of the image regarding the Attribute.
|
---|
76 | @param OffsetY The Y offset of the image regarding the Attribute.
|
---|
77 |
|
---|
78 | @retval EFI_SUCCESS The image was fetched successfully.
|
---|
79 | @retval EFI_NOT_FOUND The specified image could not be found.
|
---|
80 | **/
|
---|
81 | EFI_STATUS
|
---|
82 | EFIAPI
|
---|
83 | GetImage (
|
---|
84 | IN EDKII_PLATFORM_LOGO_PROTOCOL *This,
|
---|
85 | IN OUT UINT32 *Instance,
|
---|
86 | OUT EFI_IMAGE_INPUT *Image,
|
---|
87 | OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,
|
---|
88 | OUT INTN *OffsetX,
|
---|
89 | OUT INTN *OffsetY
|
---|
90 | )
|
---|
91 | {
|
---|
92 | UINT32 Current;
|
---|
93 | if (Instance == NULL || Image == NULL ||
|
---|
94 | Attribute == NULL || OffsetX == NULL || OffsetY == NULL) {
|
---|
95 | return EFI_INVALID_PARAMETER;
|
---|
96 | }
|
---|
97 |
|
---|
98 | Current = *Instance;
|
---|
99 | if (Current >= ARRAY_SIZE (mLogos)) {
|
---|
100 | return EFI_NOT_FOUND;
|
---|
101 | }
|
---|
102 |
|
---|
103 | (*Instance)++;
|
---|
104 | *Attribute = mLogos[Current].Attribute;
|
---|
105 | *OffsetX = mLogos[Current].OffsetX;
|
---|
106 | *OffsetY = mLogos[Current].OffsetY;
|
---|
107 | return mHiiImageEx->GetImageEx (mHiiImageEx, mHiiHandle, mLogos[Current].ImageId, Image);
|
---|
108 | }
|
---|
109 |
|
---|
110 | EDKII_PLATFORM_LOGO_PROTOCOL mPlatformLogo = {
|
---|
111 | GetImage
|
---|
112 | };
|
---|
113 |
|
---|
114 | /**
|
---|
115 | Entrypoint of this module.
|
---|
116 |
|
---|
117 | This function is the entrypoint of this module. It installs the Edkii
|
---|
118 | Platform Logo protocol.
|
---|
119 |
|
---|
120 | @param ImageHandle The firmware allocated handle for the EFI image.
|
---|
121 | @param SystemTable A pointer to the EFI System Table.
|
---|
122 |
|
---|
123 | @retval EFI_SUCCESS The entry point is executed successfully.
|
---|
124 |
|
---|
125 | **/
|
---|
126 | EFI_STATUS
|
---|
127 | EFIAPI
|
---|
128 | InitializeLogo (
|
---|
129 | IN EFI_HANDLE ImageHandle,
|
---|
130 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
131 | )
|
---|
132 | {
|
---|
133 | EFI_STATUS Status;
|
---|
134 | EFI_HII_PACKAGE_LIST_HEADER *PackageList;
|
---|
135 | EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
|
---|
136 | EFI_HANDLE Handle;
|
---|
137 |
|
---|
138 | Status = gBS->LocateProtocol (
|
---|
139 | &gEfiHiiDatabaseProtocolGuid,
|
---|
140 | NULL,
|
---|
141 | (VOID **) &HiiDatabase
|
---|
142 | );
|
---|
143 | ASSERT_EFI_ERROR (Status);
|
---|
144 |
|
---|
145 | Status = gBS->LocateProtocol (
|
---|
146 | &gEfiHiiImageExProtocolGuid,
|
---|
147 | NULL,
|
---|
148 | (VOID **) &mHiiImageEx
|
---|
149 | );
|
---|
150 | ASSERT_EFI_ERROR (Status);
|
---|
151 |
|
---|
152 | //
|
---|
153 | // Retrieve HII package list from ImageHandle
|
---|
154 | //
|
---|
155 | Status = gBS->OpenProtocol (
|
---|
156 | ImageHandle,
|
---|
157 | &gEfiHiiPackageListProtocolGuid,
|
---|
158 | (VOID **) &PackageList,
|
---|
159 | ImageHandle,
|
---|
160 | NULL,
|
---|
161 | EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
---|
162 | );
|
---|
163 | if (EFI_ERROR (Status)) {
|
---|
164 | DEBUG ((DEBUG_ERROR, "HII Image Package with logo not found in PE/COFF resource section\n"));
|
---|
165 | return Status;
|
---|
166 | }
|
---|
167 |
|
---|
168 | //
|
---|
169 | // Publish HII package list to HII Database.
|
---|
170 | //
|
---|
171 | Status = HiiDatabase->NewPackageList (
|
---|
172 | HiiDatabase,
|
---|
173 | PackageList,
|
---|
174 | NULL,
|
---|
175 | &mHiiHandle
|
---|
176 | );
|
---|
177 | if (!EFI_ERROR (Status)) {
|
---|
178 | Handle = NULL;
|
---|
179 | Status = gBS->InstallMultipleProtocolInterfaces (
|
---|
180 | &Handle,
|
---|
181 | &gEdkiiPlatformLogoProtocolGuid, &mPlatformLogo,
|
---|
182 | NULL
|
---|
183 | );
|
---|
184 | }
|
---|
185 | return Status;
|
---|
186 | }
|
---|