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