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