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