]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / HiiDatabaseEntry.c
1 /** @file
2 This file contains the entry code to the HII database, which is defined by
3 UEFI 2.1 specification.
4
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "HiiDatabase.h"
11
12 //
13 // Global variables
14 //
15 EFI_EVENT gHiiKeyboardLayoutChanged;
16 BOOLEAN gExportAfterReadyToBoot = FALSE;
17
18 HII_DATABASE_PRIVATE_DATA mPrivate = {
19 HII_DATABASE_PRIVATE_DATA_SIGNATURE,
20 {
21 (LIST_ENTRY *)NULL,
22 (LIST_ENTRY *)NULL
23 },
24 {
25 (LIST_ENTRY *)NULL,
26 (LIST_ENTRY *)NULL
27 },
28 {
29 HiiStringToImage,
30 HiiStringIdToImage,
31 HiiGetGlyph,
32 HiiGetFontInfo
33 },
34 {
35 HiiNewImage,
36 HiiGetImage,
37 HiiSetImage,
38 HiiDrawImage,
39 HiiDrawImageId
40 },
41 {
42 HiiNewImageEx,
43 HiiGetImageEx,
44 HiiSetImageEx,
45 HiiDrawImageEx,
46 HiiDrawImageIdEx,
47 HiiGetImageInfo
48 },
49 {
50 HiiNewString,
51 HiiGetString,
52 HiiSetString,
53 HiiGetLanguages,
54 HiiGetSecondaryLanguages
55 },
56 {
57 HiiNewPackageList,
58 HiiRemovePackageList,
59 HiiUpdatePackageList,
60 HiiListPackageLists,
61 HiiExportPackageLists,
62 HiiRegisterPackageNotify,
63 HiiUnregisterPackageNotify,
64 HiiFindKeyboardLayouts,
65 HiiGetKeyboardLayout,
66 HiiSetKeyboardLayout,
67 HiiGetPackageListHandle
68 },
69 {
70 HiiConfigRoutingExtractConfig,
71 HiiConfigRoutingExportConfig,
72 HiiConfigRoutingRouteConfig,
73 HiiBlockToConfig,
74 HiiConfigToBlock,
75 HiiGetAltCfg
76 },
77 {
78 EfiConfigKeywordHandlerSetData,
79 EfiConfigKeywordHandlerGetData
80 },
81 {
82 (LIST_ENTRY *)NULL,
83 (LIST_ENTRY *)NULL
84 },
85 0,
86 {
87 (LIST_ENTRY *)NULL,
88 (LIST_ENTRY *)NULL
89 },
90 EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK),
91 {
92 0x00000000,
93 0x0000,
94 0x0000,
95 { 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00 }
96 },
97 NULL
98 };
99
100 /**
101 The default event handler for gHiiKeyboardLayoutChanged
102 event group.
103
104 This is internal function.
105
106 @param Event The event that triggered this notification function.
107 @param Context Pointer to the notification functions context.
108
109 **/
110 VOID
111 EFIAPI
112 KeyboardLayoutChangeNullEvent (
113 IN EFI_EVENT Event,
114 IN VOID *Context
115 )
116 {
117 return;
118 }
119
120 /**
121 On Ready To Boot Services Event notification handler.
122
123 To trigger the function that to export the Hii Configuration setting.
124
125 @param[in] Event Event whose notification function is being invoked
126 @param[in] Context Pointer to the notification function's context
127
128 **/
129 VOID
130 EFIAPI
131 OnReadyToBoot (
132 IN EFI_EVENT Event,
133 IN VOID *Context
134 )
135 {
136 //
137 // When ready to boot, we begin to export the HiiDatabase date.
138 // And hook all the possible HiiDatabase change actions to export data.
139 //
140 HiiGetDatabaseInfo (&mPrivate.HiiDatabase);
141 HiiGetConfigRespInfo (&mPrivate.HiiDatabase);
142 gExportAfterReadyToBoot = TRUE;
143
144 gBS->CloseEvent (Event);
145 }
146
147 /**
148 Initialize HII Database.
149
150
151 @param ImageHandle The image handle.
152 @param SystemTable The system table.
153
154 @retval EFI_SUCCESS The Hii database is setup correctly.
155 @return Other value if failed to create the default event for
156 gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for
157 details. Or failed to install the protocols.
158 Check gBS->InstallMultipleProtocolInterfaces for details.
159 Or failed to create Ready To Boot Event.
160 Check EfiCreateEventReadyToBootEx for details.
161
162 **/
163 EFI_STATUS
164 EFIAPI
165 InitializeHiiDatabase (
166 IN EFI_HANDLE ImageHandle,
167 IN EFI_SYSTEM_TABLE *SystemTable
168 )
169 {
170 EFI_STATUS Status;
171 EFI_HANDLE Handle;
172 EFI_EVENT ReadyToBootEvent;
173
174 //
175 // There will be only one HII Database in the system
176 // If there is another out there, someone is trying to install us
177 // again. Fail that scenario.
178 //
179 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiDatabaseProtocolGuid);
180 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiFontProtocolGuid);
181 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiImageProtocolGuid);
182 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiStringProtocolGuid);
183 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiConfigRoutingProtocolGuid);
184 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiConfigKeywordHandlerProtocolGuid);
185
186 InitializeListHead (&mPrivate.DatabaseList);
187 InitializeListHead (&mPrivate.DatabaseNotifyList);
188 InitializeListHead (&mPrivate.HiiHandleList);
189 InitializeListHead (&mPrivate.FontInfoList);
190
191 //
192 // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.
193 //
194 Status = gBS->CreateEventEx (
195 EVT_NOTIFY_SIGNAL,
196 TPL_NOTIFY,
197 KeyboardLayoutChangeNullEvent,
198 NULL,
199 &gEfiHiiKeyBoardLayoutGuid,
200 &gHiiKeyboardLayoutChanged
201 );
202 if (EFI_ERROR (Status)) {
203 return Status;
204 }
205
206 Handle = NULL;
207 Status = gBS->InstallMultipleProtocolInterfaces (
208 &Handle,
209 &gEfiHiiFontProtocolGuid,
210 &mPrivate.HiiFont,
211 &gEfiHiiStringProtocolGuid,
212 &mPrivate.HiiString,
213 &gEfiHiiDatabaseProtocolGuid,
214 &mPrivate.HiiDatabase,
215 &gEfiHiiConfigRoutingProtocolGuid,
216 &mPrivate.ConfigRouting,
217 &gEfiConfigKeywordHandlerProtocolGuid,
218 &mPrivate.ConfigKeywordHandler,
219 NULL
220 );
221
222 if (EFI_ERROR (Status)) {
223 return Status;
224 }
225
226 if (FeaturePcdGet (PcdSupportHiiImageProtocol)) {
227 Status = gBS->InstallMultipleProtocolInterfaces (
228 &Handle,
229 &gEfiHiiImageProtocolGuid,
230 &mPrivate.HiiImage,
231 &gEfiHiiImageExProtocolGuid,
232 &mPrivate.HiiImageEx,
233 NULL
234 );
235 }
236
237 if (FeaturePcdGet (PcdHiiOsRuntimeSupport)) {
238 Status = EfiCreateEventReadyToBootEx (
239 TPL_CALLBACK,
240 OnReadyToBoot,
241 NULL,
242 &ReadyToBootEvent
243 );
244 if (EFI_ERROR (Status)) {
245 return Status;
246 }
247 }
248
249 return Status;
250 }