]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
MdeModulePkg: Clean up source files
[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
147 HiiGetConfigurationSetting(&mPrivate.HiiDatabase);\r
148 gExportAfterReadyToBoot = TRUE;\r
c87b13cd
DB
149\r
150 gBS->CloseEvent (Event);\r
8a45f80e
DB
151}\r
152\r
e90b081a 153/**\r
154 Initialize HII Database.\r
155\r
156\r
157 @param ImageHandle The image handle.\r
158 @param SystemTable The system table.\r
159\r
160 @retval EFI_SUCCESS The Hii database is setup correctly.\r
161 @return Other value if failed to create the default event for\r
162 gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for\r
4a429716 163 details. Or failed to install the protocols.\r
e90b081a 164 Check gBS->InstallMultipleProtocolInterfaces for details.\r
8a45f80e
DB
165 Or failed to create Ready To Boot Event.\r
166 Check EfiCreateEventReadyToBootEx for details.\r
e90b081a 167\r
168**/\r
93e3992d 169EFI_STATUS\r
170EFIAPI\r
171InitializeHiiDatabase (\r
172 IN EFI_HANDLE ImageHandle,\r
173 IN EFI_SYSTEM_TABLE *SystemTable\r
174 )\r
93e3992d 175{\r
176 EFI_STATUS Status;\r
177 EFI_HANDLE Handle;\r
8a45f80e 178 EFI_EVENT ReadyToBootEvent;\r
93e3992d 179\r
93e3992d 180 //\r
181 // There will be only one HII Database in the system\r
182 // If there is another out there, someone is trying to install us\r
183 // again. Fail that scenario.\r
184 //\r
e90b081a 185 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiDatabaseProtocolGuid);\r
186 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiFontProtocolGuid);\r
187 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiImageProtocolGuid);\r
188 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiStringProtocolGuid);\r
189 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiConfigRoutingProtocolGuid);\r
87bfeb11 190 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiConfigKeywordHandlerProtocolGuid);\r
d1102dba 191\r
93e3992d 192 InitializeListHead (&mPrivate.DatabaseList);\r
193 InitializeListHead (&mPrivate.DatabaseNotifyList);\r
194 InitializeListHead (&mPrivate.HiiHandleList);\r
195 InitializeListHead (&mPrivate.FontInfoList);\r
196\r
197 //\r
198 // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.\r
199 //\r
200 Status = gBS->CreateEventEx (\r
e53a6ea9 201 EVT_NOTIFY_SIGNAL,\r
813acf3a 202 TPL_NOTIFY,\r
203 KeyboardLayoutChangeNullEvent,\r
93e3992d 204 NULL,\r
ea021002 205 &gEfiHiiKeyBoardLayoutGuid,\r
93e3992d 206 &gHiiKeyboardLayoutChanged\r
207 );\r
208 if (EFI_ERROR (Status)) {\r
209 return Status;\r
210 }\r
211\r
212 Handle = NULL;\r
e94358a3 213 Status = gBS->InstallMultipleProtocolInterfaces (\r
214 &Handle,\r
215 &gEfiHiiFontProtocolGuid,\r
216 &mPrivate.HiiFont,\r
217 &gEfiHiiStringProtocolGuid,\r
218 &mPrivate.HiiString,\r
219 &gEfiHiiDatabaseProtocolGuid,\r
220 &mPrivate.HiiDatabase,\r
221 &gEfiHiiConfigRoutingProtocolGuid,\r
222 &mPrivate.ConfigRouting,\r
87bfeb11
ED
223 &gEfiConfigKeywordHandlerProtocolGuid,\r
224 &mPrivate.ConfigKeywordHandler,\r
e94358a3 225 NULL\r
226 );\r
227\r
228 if (EFI_ERROR (Status)) {\r
229 return Status;\r
230 }\r
231\r
232 if (FeaturePcdGet (PcdSupportHiiImageProtocol)) {\r
e94358a3 233 Status = gBS->InstallMultipleProtocolInterfaces (\r
234 &Handle,\r
101a1122
RN
235 &gEfiHiiImageProtocolGuid, &mPrivate.HiiImage,\r
236 &gEfiHiiImageExProtocolGuid, &mPrivate.HiiImageEx,\r
e94358a3 237 NULL\r
238 );\r
239\r
240 }\r
241\r
8a45f80e
DB
242 if (FeaturePcdGet(PcdHiiOsRuntimeSupport)) {\r
243 Status = EfiCreateEventReadyToBootEx (\r
244 TPL_CALLBACK,\r
245 OnReadyToBoot,\r
246 NULL,\r
247 &ReadyToBootEvent\r
248 );\r
249 if (EFI_ERROR (Status)) {\r
250 return Status;\r
251 }\r
252 }\r
253\r
e94358a3 254 return Status;\r
93e3992d 255}\r
256\r