]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
99084db068dc1dd5c62c992f4db87248a43b9615
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / HiiDatabaseEntry.c
1 /** @file
2
3 Copyright (c) 2007, 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 HiiConfigRoutingRoutConfig,
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 //@MT: EFI_DRIVER_ENTRY_POINT (InitializeHiiDatabase)
108
109 EFI_STATUS
110 EFIAPI
111 InitializeHiiDatabase (
112 IN EFI_HANDLE ImageHandle,
113 IN EFI_SYSTEM_TABLE *SystemTable
114 )
115 /*++
116
117 Routine Description:
118 Initialize HII Database
119
120 Arguments:
121 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
122
123 Returns:
124 EFI_SUCCESS -
125 other -
126
127 --*/
128 {
129 EFI_STATUS Status;
130 EFI_HANDLE Handle;
131 EFI_HANDLE *HandleBuffer;
132 UINTN HandleCount;
133
134 //@MT: EfiInitializeDriverLib (ImageHandle, SystemTable);
135
136 //
137 // There will be only one HII Database in the system
138 // If there is another out there, someone is trying to install us
139 // again. Fail that scenario.
140 //
141 Status = gBS->LocateHandleBuffer (
142 ByProtocol,
143 &gEfiHiiDatabaseProtocolGuid,
144 NULL,
145 &HandleCount,
146 &HandleBuffer
147 );
148
149 //
150 // If there was no error, assume there is an installation and fail to load
151 //
152 if (!EFI_ERROR (Status)) {
153 if (HandleBuffer != NULL) {
154 gBS->FreePool (HandleBuffer);
155 }
156 return EFI_DEVICE_ERROR;
157 }
158
159 InitializeListHead (&mPrivate.DatabaseList);
160 InitializeListHead (&mPrivate.DatabaseNotifyList);
161 InitializeListHead (&mPrivate.HiiHandleList);
162 InitializeListHead (&mPrivate.FontInfoList);
163
164 //
165 // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.
166 //
167 Status = gBS->CreateEventEx (
168 0,
169 0,
170 NULL,
171 NULL,
172 &gHiiSetKbdLayoutEventGuid,
173 &gHiiKeyboardLayoutChanged
174 );
175 if (EFI_ERROR (Status)) {
176 return Status;
177 }
178
179 Handle = NULL;
180 return gBS->InstallMultipleProtocolInterfaces (
181 &Handle,
182 &gEfiHiiFontProtocolGuid,
183 &mPrivate.HiiFont,
184 #ifndef DISABLE_UNUSED_HII_PROTOCOLS
185 &gEfiHiiImageProtocolGuid,
186 &mPrivate.HiiImage,
187 #endif
188 &gEfiHiiStringProtocolGuid,
189 &mPrivate.HiiString,
190 &gEfiHiiDatabaseProtocolGuid,
191 &mPrivate.HiiDatabase,
192 &gEfiHiiConfigRoutingProtocolGuid,
193 &mPrivate.ConfigRouting,
194 NULL
195 );
196 }
197