]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
Merged in the following trackers from EDK:
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / HiiDatabaseEntry.c
1 /** @file
2
3 Copyright (c) 2007 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 HiiDatabaseEntry.c
15
16 Abstract:
17
18 This file contains the entry code to the HII database, which is defined by
19 UEFI 2.1 specification.
20
21 Revision History
22
23
24 **/
25
26
27 #include "HiiDatabase.h"
28
29 //
30 // Global variables
31 //
32 EFI_EVENT gHiiKeyboardLayoutChanged;
33 STATIC EFI_GUID gHiiSetKbdLayoutEventGuid = EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID;
34
35 STATIC HII_DATABASE_PRIVATE_DATA mPrivate = {
36 HII_DATABASE_PRIVATE_DATA_SIGNATURE,
37 {
38 (LIST_ENTRY *) NULL,
39 (LIST_ENTRY *) NULL
40 },
41 {
42 (LIST_ENTRY *) NULL,
43 (LIST_ENTRY *) NULL
44 },
45 {
46 HiiStringToImage,
47 HiiStringIdToImage,
48 HiiGetGlyph,
49 HiiGetFontInfo
50 },
51 #ifndef DISABLE_UNUSED_HII_PROTOCOLS
52 {
53 HiiNewImage,
54 HiiGetImage,
55 HiiSetImage,
56 HiiDrawImage,
57 HiiDrawImageId
58 },
59 #endif
60 {
61 HiiNewString,
62 HiiGetString,
63 HiiSetString,
64 HiiGetLanguages,
65 HiiGetSecondaryLanguages
66 },
67 {
68 HiiNewPackageList,
69 HiiRemovePackageList,
70 HiiUpdatePackageList,
71 HiiListPackageLists,
72 HiiExportPackageLists,
73 HiiRegisterPackageNotify,
74 HiiUnregisterPackageNotify,
75 HiiFindKeyboardLayouts,
76 HiiGetKeyboardLayout,
77 HiiSetKeyboardLayout,
78 HiiGetPackageListHandle
79 },
80 {
81 HiiConfigRoutingExtractConfig,
82 HiiConfigRoutingExportConfig,
83 HiiConfigRoutingRouteConfig,
84 HiiBlockToConfig,
85 HiiConfigToBlock,
86 HiiGetAltCfg
87 },
88 {
89 (LIST_ENTRY *) NULL,
90 (LIST_ENTRY *) NULL
91 },
92 0,
93 {
94 (LIST_ENTRY *) NULL,
95 (LIST_ENTRY *) NULL
96 },
97 EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK),
98 {
99 0x00000000,
100 0x0000,
101 0x0000,
102 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
103 },
104 NULL
105 };
106
107 STATIC
108 VOID
109 EFIAPI
110 KeyboardLayoutChangeNullEvent (
111 IN EFI_EVENT Event,
112 IN VOID *Context
113 )
114 {
115 return;
116 }
117
118 EFI_STATUS
119 EFIAPI
120 InitializeHiiDatabase (
121 IN EFI_HANDLE ImageHandle,
122 IN EFI_SYSTEM_TABLE *SystemTable
123 )
124 /*++
125
126 Routine Description:
127 Initialize HII Database
128
129 Arguments:
130 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
131
132 Returns:
133 EFI_SUCCESS -
134 other -
135
136 --*/
137 {
138 EFI_STATUS Status;
139 EFI_HANDLE Handle;
140 EFI_HANDLE *HandleBuffer;
141 UINTN HandleCount;
142
143 //
144 // There will be only one HII Database in the system
145 // If there is another out there, someone is trying to install us
146 // again. Fail that scenario.
147 //
148 Status = gBS->LocateHandleBuffer (
149 ByProtocol,
150 &gEfiHiiDatabaseProtocolGuid,
151 NULL,
152 &HandleCount,
153 &HandleBuffer
154 );
155
156 //
157 // If there was no error, assume there is an installation and fail to load
158 //
159 if (!EFI_ERROR (Status)) {
160 if (HandleBuffer != NULL) {
161 gBS->FreePool (HandleBuffer);
162 }
163 return EFI_DEVICE_ERROR;
164 }
165
166 InitializeListHead (&mPrivate.DatabaseList);
167 InitializeListHead (&mPrivate.DatabaseNotifyList);
168 InitializeListHead (&mPrivate.HiiHandleList);
169 InitializeListHead (&mPrivate.FontInfoList);
170
171 //
172 // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.
173 //
174 Status = gBS->CreateEventEx (
175 EFI_EVENT_NOTIFY_SIGNAL,
176 TPL_NOTIFY,
177 KeyboardLayoutChangeNullEvent,
178 NULL,
179 &gHiiSetKbdLayoutEventGuid,
180 &gHiiKeyboardLayoutChanged
181 );
182 if (EFI_ERROR (Status)) {
183 return Status;
184 }
185
186 Handle = NULL;
187 return gBS->InstallMultipleProtocolInterfaces (
188 &Handle,
189 &gEfiHiiFontProtocolGuid,
190 &mPrivate.HiiFont,
191 #ifndef DISABLE_UNUSED_HII_PROTOCOLS
192 &gEfiHiiImageProtocolGuid,
193 &mPrivate.HiiImage,
194 #endif
195 &gEfiHiiStringProtocolGuid,
196 &mPrivate.HiiString,
197 &gEfiHiiDatabaseProtocolGuid,
198 &mPrivate.HiiDatabase,
199 &gEfiHiiConfigRoutingProtocolGuid,
200 &mPrivate.ConfigRouting,
201 NULL
202 );
203 }
204