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