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