Roll back changes to apply GetBestLanguage() in HiiDataBase. Exact language match...
[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
813acf3a 5Copyright (c) 2007 - 2008, Intel Corporation\r
93e3992d 6All rights reserved. This program and the accompanying materials\r
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
fe1e36e5 23EFI_GUID gHiiSetKbdLayoutEventGuid = EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID;\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
76 {\r
77 (LIST_ENTRY *) NULL,\r
78 (LIST_ENTRY *) NULL\r
79 },\r
80 0,\r
81 {\r
82 (LIST_ENTRY *) NULL,\r
83 (LIST_ENTRY *) NULL\r
84 },\r
85 EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK),\r
86 {\r
87 0x00000000,\r
88 0x0000,\r
89 0x0000,\r
7fd21395 90 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}\r
93e3992d 91 },\r
92 NULL\r
93};\r
94\r
e94358a3 95GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_IMAGE_PROTOCOL mImageProtocol = {\r
96 HiiNewImage,\r
97 HiiGetImage,\r
98 HiiSetImage,\r
99 HiiDrawImage,\r
100 HiiDrawImageId\r
101};\r
102\r
e90b081a 103/**\r
104 The default event handler for gHiiKeyboardLayoutChanged\r
105 event group.\r
106\r
107 This is internal function.\r
108\r
109 @param Event The event that triggered this notification function.\r
110 @param Context Pointer to the notification functions context.\r
111\r
112**/\r
813acf3a 113VOID\r
114EFIAPI\r
115KeyboardLayoutChangeNullEvent (\r
116 IN EFI_EVENT Event,\r
117 IN VOID *Context\r
118 )\r
119{\r
120 return;\r
121}\r
122\r
e90b081a 123/**\r
124 Initialize HII Database.\r
125\r
126\r
127 @param ImageHandle The image handle.\r
128 @param SystemTable The system table.\r
129\r
130 @retval EFI_SUCCESS The Hii database is setup correctly.\r
131 @return Other value if failed to create the default event for\r
132 gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for\r
133 details. Or failed to insatll the protocols.\r
134 Check gBS->InstallMultipleProtocolInterfaces for details.\r
135\r
136**/\r
93e3992d 137EFI_STATUS\r
138EFIAPI\r
139InitializeHiiDatabase (\r
140 IN EFI_HANDLE ImageHandle,\r
141 IN EFI_SYSTEM_TABLE *SystemTable\r
142 )\r
93e3992d 143{\r
144 EFI_STATUS Status;\r
145 EFI_HANDLE Handle;\r
93e3992d 146\r
93e3992d 147 //\r
148 // There will be only one HII Database in the system\r
149 // If there is another out there, someone is trying to install us\r
150 // again. Fail that scenario.\r
151 //\r
e90b081a 152 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiDatabaseProtocolGuid);\r
153 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiFontProtocolGuid);\r
154 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiImageProtocolGuid);\r
155 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiStringProtocolGuid);\r
156 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiConfigRoutingProtocolGuid);\r
157 \r
93e3992d 158 InitializeListHead (&mPrivate.DatabaseList);\r
159 InitializeListHead (&mPrivate.DatabaseNotifyList);\r
160 InitializeListHead (&mPrivate.HiiHandleList);\r
161 InitializeListHead (&mPrivate.FontInfoList);\r
162\r
163 //\r
164 // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.\r
165 //\r
166 Status = gBS->CreateEventEx (\r
e53a6ea9 167 EVT_NOTIFY_SIGNAL,\r
813acf3a 168 TPL_NOTIFY,\r
169 KeyboardLayoutChangeNullEvent,\r
93e3992d 170 NULL,\r
171 &gHiiSetKbdLayoutEventGuid,\r
172 &gHiiKeyboardLayoutChanged\r
173 );\r
174 if (EFI_ERROR (Status)) {\r
175 return Status;\r
176 }\r
177\r
178 Handle = NULL;\r
e94358a3 179 Status = gBS->InstallMultipleProtocolInterfaces (\r
180 &Handle,\r
181 &gEfiHiiFontProtocolGuid,\r
182 &mPrivate.HiiFont,\r
183 &gEfiHiiStringProtocolGuid,\r
184 &mPrivate.HiiString,\r
185 &gEfiHiiDatabaseProtocolGuid,\r
186 &mPrivate.HiiDatabase,\r
187 &gEfiHiiConfigRoutingProtocolGuid,\r
188 &mPrivate.ConfigRouting,\r
189 NULL\r
190 );\r
191\r
192 if (EFI_ERROR (Status)) {\r
193 return Status;\r
194 }\r
195\r
196 if (FeaturePcdGet (PcdSupportHiiImageProtocol)) {\r
197 CopyMem (&mPrivate.HiiImage, &mImageProtocol, sizeof (mImageProtocol));\r
198\r
199 Status = gBS->InstallMultipleProtocolInterfaces (\r
200 &Handle,\r
201 &gEfiHiiImageProtocolGuid,\r
202 &mPrivate.HiiImage,\r
203 NULL\r
204 );\r
205\r
206 }\r
207\r
208 return Status;\r
93e3992d 209}\r
210\r