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