Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame^] | 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. All rights reserved.<BR>
|
| 6 | 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 |
|
| 24 | HII_DATABASE_PRIVATE_DATA mPrivate = {
|
| 25 | HII_DATABASE_PRIVATE_DATA_SIGNATURE,
|
| 26 | {
|
| 27 | (LIST_ENTRY *) NULL,
|
| 28 | (LIST_ENTRY *) NULL
|
| 29 | },
|
| 30 | {
|
| 31 | (LIST_ENTRY *) NULL,
|
| 32 | (LIST_ENTRY *) NULL
|
| 33 | },
|
| 34 | {
|
| 35 | HiiStringToImage,
|
| 36 | HiiStringIdToImage,
|
| 37 | HiiGetGlyph,
|
| 38 | HiiGetFontInfo
|
| 39 | },
|
| 40 | {
|
| 41 | NULL,
|
| 42 | NULL,
|
| 43 | NULL,
|
| 44 | NULL,
|
| 45 | NULL
|
| 46 | },
|
| 47 | {
|
| 48 | HiiNewString,
|
| 49 | HiiGetString,
|
| 50 | HiiSetString,
|
| 51 | HiiGetLanguages,
|
| 52 | HiiGetSecondaryLanguages
|
| 53 | },
|
| 54 | {
|
| 55 | HiiNewPackageList,
|
| 56 | HiiRemovePackageList,
|
| 57 | HiiUpdatePackageList,
|
| 58 | HiiListPackageLists,
|
| 59 | HiiExportPackageLists,
|
| 60 | HiiRegisterPackageNotify,
|
| 61 | HiiUnregisterPackageNotify,
|
| 62 | HiiFindKeyboardLayouts,
|
| 63 | HiiGetKeyboardLayout,
|
| 64 | HiiSetKeyboardLayout,
|
| 65 | HiiGetPackageListHandle
|
| 66 | },
|
| 67 | {
|
| 68 | HiiConfigRoutingExtractConfig,
|
| 69 | HiiConfigRoutingExportConfig,
|
| 70 | HiiConfigRoutingRouteConfig,
|
| 71 | HiiBlockToConfig,
|
| 72 | HiiConfigToBlock,
|
| 73 | HiiGetAltCfg
|
| 74 | },
|
| 75 | {
|
| 76 | (LIST_ENTRY *) NULL,
|
| 77 | (LIST_ENTRY *) NULL
|
| 78 | },
|
| 79 | 0,
|
| 80 | {
|
| 81 | (LIST_ENTRY *) NULL,
|
| 82 | (LIST_ENTRY *) NULL
|
| 83 | },
|
| 84 | EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK),
|
| 85 | {
|
| 86 | 0x00000000,
|
| 87 | 0x0000,
|
| 88 | 0x0000,
|
| 89 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
| 90 | },
|
| 91 | NULL
|
| 92 | };
|
| 93 |
|
| 94 | GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_IMAGE_PROTOCOL mImageProtocol = {
|
| 95 | HiiNewImage,
|
| 96 | HiiGetImage,
|
| 97 | HiiSetImage,
|
| 98 | HiiDrawImage,
|
| 99 | HiiDrawImageId
|
| 100 | };
|
| 101 |
|
| 102 | /**
|
| 103 | The default event handler for gHiiKeyboardLayoutChanged
|
| 104 | event group.
|
| 105 |
|
| 106 | This is internal function.
|
| 107 |
|
| 108 | @param Event The event that triggered this notification function.
|
| 109 | @param Context Pointer to the notification functions context.
|
| 110 |
|
| 111 | **/
|
| 112 | VOID
|
| 113 | EFIAPI
|
| 114 | KeyboardLayoutChangeNullEvent (
|
| 115 | IN EFI_EVENT Event,
|
| 116 | IN VOID *Context
|
| 117 | )
|
| 118 | {
|
| 119 | return;
|
| 120 | }
|
| 121 |
|
| 122 | /**
|
| 123 | Initialize HII Database.
|
| 124 |
|
| 125 |
|
| 126 | @param ImageHandle The image handle.
|
| 127 | @param SystemTable The system table.
|
| 128 |
|
| 129 | @retval EFI_SUCCESS The Hii database is setup correctly.
|
| 130 | @return Other value if failed to create the default event for
|
| 131 | gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for
|
| 132 | details. Or failed to insatll the protocols.
|
| 133 | Check gBS->InstallMultipleProtocolInterfaces for details.
|
| 134 |
|
| 135 | **/
|
| 136 | EFI_STATUS
|
| 137 | EFIAPI
|
| 138 | InitializeHiiDatabase (
|
| 139 | IN EFI_HANDLE ImageHandle,
|
| 140 | IN EFI_SYSTEM_TABLE *SystemTable
|
| 141 | )
|
| 142 | {
|
| 143 | EFI_STATUS Status;
|
| 144 | EFI_HANDLE Handle;
|
| 145 |
|
| 146 | //
|
| 147 | // There will be only one HII Database in the system
|
| 148 | // If there is another out there, someone is trying to install us
|
| 149 | // again. Fail that scenario.
|
| 150 | //
|
| 151 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiDatabaseProtocolGuid);
|
| 152 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiFontProtocolGuid);
|
| 153 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiImageProtocolGuid);
|
| 154 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiStringProtocolGuid);
|
| 155 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiConfigRoutingProtocolGuid);
|
| 156 |
|
| 157 | InitializeListHead (&mPrivate.DatabaseList);
|
| 158 | InitializeListHead (&mPrivate.DatabaseNotifyList);
|
| 159 | InitializeListHead (&mPrivate.HiiHandleList);
|
| 160 | InitializeListHead (&mPrivate.FontInfoList);
|
| 161 |
|
| 162 | //
|
| 163 | // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.
|
| 164 | //
|
| 165 | Status = gBS->CreateEventEx (
|
| 166 | EVT_NOTIFY_SIGNAL,
|
| 167 | TPL_NOTIFY,
|
| 168 | KeyboardLayoutChangeNullEvent,
|
| 169 | NULL,
|
| 170 | &gEfiHiiKeyBoardLayoutGuid,
|
| 171 | &gHiiKeyboardLayoutChanged
|
| 172 | );
|
| 173 | if (EFI_ERROR (Status)) {
|
| 174 | return Status;
|
| 175 | }
|
| 176 |
|
| 177 | Handle = NULL;
|
| 178 | Status = gBS->InstallMultipleProtocolInterfaces (
|
| 179 | &Handle,
|
| 180 | &gEfiHiiFontProtocolGuid,
|
| 181 | &mPrivate.HiiFont,
|
| 182 | &gEfiHiiStringProtocolGuid,
|
| 183 | &mPrivate.HiiString,
|
| 184 | &gEfiHiiDatabaseProtocolGuid,
|
| 185 | &mPrivate.HiiDatabase,
|
| 186 | &gEfiHiiConfigRoutingProtocolGuid,
|
| 187 | &mPrivate.ConfigRouting,
|
| 188 | NULL
|
| 189 | );
|
| 190 |
|
| 191 | if (EFI_ERROR (Status)) {
|
| 192 | return Status;
|
| 193 | }
|
| 194 |
|
| 195 | if (FeaturePcdGet (PcdSupportHiiImageProtocol)) {
|
| 196 | CopyMem (&mPrivate.HiiImage, &mImageProtocol, sizeof (mImageProtocol));
|
| 197 |
|
| 198 | Status = gBS->InstallMultipleProtocolInterfaces (
|
| 199 | &Handle,
|
| 200 | &gEfiHiiImageProtocolGuid,
|
| 201 | &mPrivate.HiiImage,
|
| 202 | NULL
|
| 203 | );
|
| 204 |
|
| 205 | }
|
| 206 |
|
| 207 | return Status;
|
| 208 | }
|
| 209 |
|