]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
MdeModulePkg: Make HII configuration settings available to OS runtime
[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
8a45f80e 5Copyright (c) 2007 - 2016, 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
e94358a3 42 NULL,\r
43 NULL,\r
44 NULL,\r
45 NULL,\r
46 NULL\r
93e3992d 47 },\r
93e3992d 48 {\r
49 HiiNewString,\r
50 HiiGetString,\r
51 HiiSetString,\r
52 HiiGetLanguages,\r
53 HiiGetSecondaryLanguages\r
54 },\r
55 {\r
56 HiiNewPackageList,\r
57 HiiRemovePackageList,\r
58 HiiUpdatePackageList,\r
59 HiiListPackageLists,\r
60 HiiExportPackageLists,\r
61 HiiRegisterPackageNotify,\r
62 HiiUnregisterPackageNotify,\r
63 HiiFindKeyboardLayouts,\r
64 HiiGetKeyboardLayout,\r
65 HiiSetKeyboardLayout,\r
66 HiiGetPackageListHandle\r
67 },\r
68 {\r
69 HiiConfigRoutingExtractConfig,\r
70 HiiConfigRoutingExportConfig,\r
813acf3a 71 HiiConfigRoutingRouteConfig,\r
93e3992d 72 HiiBlockToConfig,\r
73 HiiConfigToBlock,\r
74 HiiGetAltCfg\r
75 },\r
87bfeb11
ED
76 {\r
77 EfiConfigKeywordHandlerSetData,\r
78 EfiConfigKeywordHandlerGetData\r
79 },\r
93e3992d 80 {\r
81 (LIST_ENTRY *) NULL,\r
82 (LIST_ENTRY *) NULL\r
83 },\r
84 0,\r
85 {\r
86 (LIST_ENTRY *) NULL,\r
87 (LIST_ENTRY *) NULL\r
88 },\r
89 EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK),\r
90 {\r
91 0x00000000,\r
92 0x0000,\r
93 0x0000,\r
7fd21395 94 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}\r
93e3992d 95 },\r
96 NULL\r
97};\r
98\r
e94358a3 99GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_IMAGE_PROTOCOL mImageProtocol = {\r
100 HiiNewImage,\r
101 HiiGetImage,\r
102 HiiSetImage,\r
103 HiiDrawImage,\r
104 HiiDrawImageId\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
149}\r
150\r
e90b081a 151/**\r
152 Initialize HII Database.\r
153\r
154\r
155 @param ImageHandle The image handle.\r
156 @param SystemTable The system table.\r
157\r
158 @retval EFI_SUCCESS The Hii database is setup correctly.\r
159 @return Other value if failed to create the default event for\r
160 gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for\r
161 details. Or failed to insatll the protocols.\r
162 Check gBS->InstallMultipleProtocolInterfaces for details.\r
8a45f80e
DB
163 Or failed to create Ready To Boot Event.\r
164 Check EfiCreateEventReadyToBootEx for details.\r
e90b081a 165\r
166**/\r
93e3992d 167EFI_STATUS\r
168EFIAPI\r
169InitializeHiiDatabase (\r
170 IN EFI_HANDLE ImageHandle,\r
171 IN EFI_SYSTEM_TABLE *SystemTable\r
172 )\r
93e3992d 173{\r
174 EFI_STATUS Status;\r
175 EFI_HANDLE Handle;\r
8a45f80e 176 EFI_EVENT ReadyToBootEvent;\r
93e3992d 177\r
93e3992d 178 //\r
179 // There will be only one HII Database in the system\r
180 // If there is another out there, someone is trying to install us\r
181 // again. Fail that scenario.\r
182 //\r
e90b081a 183 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiDatabaseProtocolGuid);\r
184 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiFontProtocolGuid);\r
185 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiImageProtocolGuid);\r
186 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiStringProtocolGuid);\r
187 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiConfigRoutingProtocolGuid);\r
87bfeb11 188 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiConfigKeywordHandlerProtocolGuid);\r
e90b081a 189 \r
93e3992d 190 InitializeListHead (&mPrivate.DatabaseList);\r
191 InitializeListHead (&mPrivate.DatabaseNotifyList);\r
192 InitializeListHead (&mPrivate.HiiHandleList);\r
193 InitializeListHead (&mPrivate.FontInfoList);\r
194\r
195 //\r
196 // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.\r
197 //\r
198 Status = gBS->CreateEventEx (\r
e53a6ea9 199 EVT_NOTIFY_SIGNAL,\r
813acf3a 200 TPL_NOTIFY,\r
201 KeyboardLayoutChangeNullEvent,\r
93e3992d 202 NULL,\r
ea021002 203 &gEfiHiiKeyBoardLayoutGuid,\r
93e3992d 204 &gHiiKeyboardLayoutChanged\r
205 );\r
206 if (EFI_ERROR (Status)) {\r
207 return Status;\r
208 }\r
209\r
210 Handle = NULL;\r
e94358a3 211 Status = gBS->InstallMultipleProtocolInterfaces (\r
212 &Handle,\r
213 &gEfiHiiFontProtocolGuid,\r
214 &mPrivate.HiiFont,\r
215 &gEfiHiiStringProtocolGuid,\r
216 &mPrivate.HiiString,\r
217 &gEfiHiiDatabaseProtocolGuid,\r
218 &mPrivate.HiiDatabase,\r
219 &gEfiHiiConfigRoutingProtocolGuid,\r
220 &mPrivate.ConfigRouting,\r
87bfeb11
ED
221 &gEfiConfigKeywordHandlerProtocolGuid,\r
222 &mPrivate.ConfigKeywordHandler,\r
e94358a3 223 NULL\r
224 );\r
225\r
226 if (EFI_ERROR (Status)) {\r
227 return Status;\r
228 }\r
229\r
230 if (FeaturePcdGet (PcdSupportHiiImageProtocol)) {\r
231 CopyMem (&mPrivate.HiiImage, &mImageProtocol, sizeof (mImageProtocol));\r
232\r
233 Status = gBS->InstallMultipleProtocolInterfaces (\r
234 &Handle,\r
235 &gEfiHiiImageProtocolGuid,\r
236 &mPrivate.HiiImage,\r
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