mirror of https://github.com/acidanthera/audk.git
Remove Framework HiiDatabase
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4769 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3531be0158
commit
ae55729b76
|
@ -1,260 +0,0 @@
|
||||||
/**@file
|
|
||||||
|
|
||||||
This file contains the keyboard processing code to the HII database.
|
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
#include "HiiDatabase.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// We only need to define a wide glyph, since we will seed the narrow glyph with EFI_NARROW_GLYPH size of
|
|
||||||
// this data structure
|
|
||||||
//
|
|
||||||
UINT8 mUnknownGlyph[38] = {
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xAA,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xaa,
|
|
||||||
0x55,
|
|
||||||
0xAA
|
|
||||||
};
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetGlyph (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN CHAR16 *Source,
|
|
||||||
IN OUT UINT16 *Index,
|
|
||||||
OUT UINT8 **GlyphBuffer,
|
|
||||||
OUT UINT16 *BitWidth,
|
|
||||||
IN OUT UINT32 *InternalStatus
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Translates a Unicode character into the corresponding font glyph.
|
|
||||||
If the Source was pointing to a non-spacing character, the next Source[*Index]
|
|
||||||
character will be parsed and OR'd to the GlyphBuffer until a spacing character
|
|
||||||
is found in the Source. Since non-spacing characters are considered to be the
|
|
||||||
same pixel width as a regular character their BitWidth will be reflected correctly
|
|
||||||
however due to their special attribute, they are considered to be zero advancing width.
|
|
||||||
This basically means that the cursor would not advance, thus the character that follows
|
|
||||||
it would overlay the non-spacing character. The Index is modified to reflect both the
|
|
||||||
incoming array entry into the Source string but also the outgoing array entry after having
|
|
||||||
parsed the equivalent of a single Glyph's worth of data.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_HII_GLOBAL_DATA *GlobalData;
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
UINTN Count;
|
|
||||||
BOOLEAN Narrow;
|
|
||||||
UINTN Location;
|
|
||||||
UINTN SearchLocation;
|
|
||||||
UINTN Value;
|
|
||||||
CHAR16 Character;
|
|
||||||
UINTN Attributes;
|
|
||||||
|
|
||||||
if (This == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = EFI_HII_DATA_FROM_THIS (This);
|
|
||||||
|
|
||||||
GlobalData = HiiData->GlobalData;
|
|
||||||
Count = sizeof (GlobalData->NarrowGlyphs->GlyphCol1);
|
|
||||||
|
|
||||||
Location = *Index;
|
|
||||||
SearchLocation = *Index;
|
|
||||||
Narrow = TRUE;
|
|
||||||
|
|
||||||
if (Source[Location] == NARROW_CHAR || Source[Location] == WIDE_CHAR) {
|
|
||||||
*InternalStatus = 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// We don't know what glyph database to look in - let's figure it out
|
|
||||||
//
|
|
||||||
if (*InternalStatus == 0) {
|
|
||||||
//
|
|
||||||
// Determine if we are looking for narrow or wide glyph data
|
|
||||||
//
|
|
||||||
do {
|
|
||||||
if (Source[SearchLocation] == NARROW_CHAR || Source[SearchLocation] == WIDE_CHAR) {
|
|
||||||
//
|
|
||||||
// We found something that identifies what glyph database to look in
|
|
||||||
//
|
|
||||||
if (Source[SearchLocation] == WIDE_CHAR) {
|
|
||||||
Narrow = FALSE;
|
|
||||||
*BitWidth = WIDE_WIDTH;
|
|
||||||
*InternalStatus = WIDE_CHAR;
|
|
||||||
Location++;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
Narrow = TRUE;
|
|
||||||
*BitWidth = NARROW_WIDTH;
|
|
||||||
*InternalStatus = NARROW_CHAR;
|
|
||||||
Location++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (SearchLocation-- > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*InternalStatus == NARROW_CHAR) {
|
|
||||||
Narrow = TRUE;
|
|
||||||
*BitWidth = NARROW_WIDTH;
|
|
||||||
} else if (*InternalStatus == WIDE_CHAR) {
|
|
||||||
Narrow = FALSE;
|
|
||||||
*BitWidth = WIDE_WIDTH;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Without otherwise knowing what the width is narrow (e.g. someone passed in a string with index of 0
|
|
||||||
// we wouldn't be able to determine the width of the data.)
|
|
||||||
// BUGBUG - do we go to wide database and if exist, ignore narrow? Check Unicode spec....
|
|
||||||
//
|
|
||||||
Narrow = TRUE;
|
|
||||||
*BitWidth = NARROW_WIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
Character = Source[Location];
|
|
||||||
|
|
||||||
if (Narrow) {
|
|
||||||
if (GlobalData->NarrowGlyphs[Character].UnicodeWeight != 0x0000) {
|
|
||||||
*GlyphBuffer = (UINT8 *) (&GlobalData->NarrowGlyphs[Character]);
|
|
||||||
Attributes = GlobalData->NarrowGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Glyph is uninitialized - return an error, but hand back the glyph
|
|
||||||
//
|
|
||||||
*GlyphBuffer = (UINT8 *) (&GlobalData->NarrowGlyphs[Character]);
|
|
||||||
*Index = (UINT16) (Location + 1);
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Wide character
|
|
||||||
//
|
|
||||||
if (GlobalData->WideGlyphs[Character].UnicodeWeight != 0x0000) {
|
|
||||||
*GlyphBuffer = (UINT8 *) (&GlobalData->WideGlyphs[Character]);
|
|
||||||
Attributes = GlobalData->WideGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Glyph is uninitialized - return an error, but hand back the glyph
|
|
||||||
//
|
|
||||||
*GlyphBuffer = (UINT8 *) (&GlobalData->WideGlyphs[Character]);
|
|
||||||
*Index = (UINT16) (Location + 1);
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// This is a non-spacing character. It will be followed by either more non-spacing
|
|
||||||
// characters or a regular character. We need to OR together the data associated with each.
|
|
||||||
//
|
|
||||||
for (; Attributes != 0; Location++) {
|
|
||||||
//
|
|
||||||
// Character is the Unicode value which is the index into the Glyph array.
|
|
||||||
//
|
|
||||||
Character = Source[Location];
|
|
||||||
|
|
||||||
if (Narrow) {
|
|
||||||
for (Value = 0; Value != Count; Value++) {
|
|
||||||
*GlyphBuffer[Location + Value] = (UINT8) (*GlyphBuffer[Location + Value] |
|
|
||||||
GlobalData->NarrowGlyphs[Character].GlyphCol1[Value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Attributes = GlobalData->NarrowGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;
|
|
||||||
} else {
|
|
||||||
for (Value = 0; Value != Count; Value++) {
|
|
||||||
*GlyphBuffer[Location + Value] = (UINT8) (*GlyphBuffer[Location + Value] |
|
|
||||||
GlobalData->WideGlyphs[Character].GlyphCol1[Value]);
|
|
||||||
*GlyphBuffer[Location + Value + Count] = (UINT8) (*GlyphBuffer[Location + Value + Count] |
|
|
||||||
GlobalData->WideGlyphs[Character].GlyphCol2[Value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Attributes = GlobalData->WideGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Source[*Index] should point to the next character to process
|
|
||||||
//
|
|
||||||
*Index = (UINT16) (Location + 1);
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGlyphToBlt (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN UINT8 *GlyphBuffer,
|
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
|
||||||
IN UINTN Count,
|
|
||||||
IN UINTN Width,
|
|
||||||
IN UINTN Height,
|
|
||||||
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
UINTN X;
|
|
||||||
UINTN Y;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Convert Monochrome bitmap of the Glyph to BltBuffer structure
|
|
||||||
//
|
|
||||||
for (Y = 0; Y < Height; Y++) {
|
|
||||||
for (X = 0; X < Width; X++) {
|
|
||||||
if ((((EFI_NARROW_GLYPH *) GlyphBuffer)->GlyphCol1[Y] & (1 << X)) != 0) {
|
|
||||||
BltBuffer[Y * Width * Count + (Width - X - 1)] = Foreground;
|
|
||||||
} else {
|
|
||||||
BltBuffer[Y * Width * Count + (Width - X - 1)] = Background;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,402 +0,0 @@
|
||||||
/**@file
|
|
||||||
|
|
||||||
This file contains the keyboard processing code to the HII database.
|
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "HiiDatabase.h"
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
InitializeHiiDatabase (
|
|
||||||
IN EFI_HANDLE ImageHandle,
|
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Initialize HII Database
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
(Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
EFI_SUCCESS - Setup loaded.
|
|
||||||
other - Setup Error
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
EFI_HII_GLOBAL_DATA *GlobalData;
|
|
||||||
EFI_HANDLE *HandleBuffer;
|
|
||||||
EFI_HANDLE Handle;
|
|
||||||
UINTN HandleCount;
|
|
||||||
UINTN Index;
|
|
||||||
|
|
||||||
//
|
|
||||||
// There will be only one HII Database in the system
|
|
||||||
// If there is another out there, someone is trying to install us
|
|
||||||
// again. Fail that scenario.
|
|
||||||
//
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
|
||||||
ByProtocol,
|
|
||||||
&gEfiHiiProtocolGuid,
|
|
||||||
NULL,
|
|
||||||
&HandleCount,
|
|
||||||
&HandleBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// If there was no error, assume there is an installation and fail to load
|
|
||||||
//
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
if (HandleBuffer != NULL) {
|
|
||||||
FreePool (HandleBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = AllocatePool (sizeof (EFI_HII_DATA));
|
|
||||||
|
|
||||||
ASSERT (HiiData);
|
|
||||||
|
|
||||||
GlobalData = AllocateZeroPool (sizeof (EFI_HII_GLOBAL_DATA));
|
|
||||||
|
|
||||||
ASSERT (GlobalData);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Seed the Font Database with a known non-character glyph
|
|
||||||
//
|
|
||||||
for (Index = 0; Index <= MAX_GLYPH_COUNT; Index++) {
|
|
||||||
//
|
|
||||||
// Seeding the UnicodeWeight with 0 signifies that it is uninitialized
|
|
||||||
//
|
|
||||||
GlobalData->NarrowGlyphs[Index].UnicodeWeight = 0;
|
|
||||||
GlobalData->WideGlyphs[Index].UnicodeWeight = 0;
|
|
||||||
GlobalData->NarrowGlyphs[Index].Attributes = 0;
|
|
||||||
GlobalData->WideGlyphs[Index].Attributes = 0;
|
|
||||||
CopyMem (GlobalData->NarrowGlyphs[Index].GlyphCol1, &mUnknownGlyph, NARROW_GLYPH_ARRAY_SIZE);
|
|
||||||
CopyMem (GlobalData->WideGlyphs[Index].GlyphCol1, &mUnknownGlyph, WIDE_GLYPH_ARRAY_SIZE);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Fill in HII data
|
|
||||||
//
|
|
||||||
HiiData->Signature = EFI_HII_DATA_SIGNATURE;
|
|
||||||
HiiData->GlobalData = GlobalData;
|
|
||||||
HiiData->GlobalData->SystemKeyboardUpdate = FALSE;
|
|
||||||
HiiData->DatabaseHead = NULL;
|
|
||||||
HiiData->Hii.NewPack = HiiNewPack;
|
|
||||||
HiiData->Hii.RemovePack = HiiRemovePack;
|
|
||||||
HiiData->Hii.FindHandles = HiiFindHandles;
|
|
||||||
HiiData->Hii.ExportDatabase = HiiExportDatabase;
|
|
||||||
HiiData->Hii.GetGlyph = HiiGetGlyph;
|
|
||||||
HiiData->Hii.GetPrimaryLanguages = HiiGetPrimaryLanguages;
|
|
||||||
HiiData->Hii.GetSecondaryLanguages = HiiGetSecondaryLanguages;
|
|
||||||
HiiData->Hii.NewString = HiiNewString;
|
|
||||||
HiiData->Hii.GetString = HiiGetString;
|
|
||||||
HiiData->Hii.ResetStrings = HiiResetStrings;
|
|
||||||
HiiData->Hii.TestString = HiiTestString;
|
|
||||||
HiiData->Hii.GetLine = HiiGetLine;
|
|
||||||
HiiData->Hii.GetForms = HiiGetForms;
|
|
||||||
HiiData->Hii.GetDefaultImage = HiiGetDefaultImage;
|
|
||||||
HiiData->Hii.UpdateForm = HiiUpdateForm;
|
|
||||||
HiiData->Hii.GetKeyboardLayout = HiiGetKeyboardLayout;
|
|
||||||
HiiData->Hii.GlyphToBlt = HiiGlyphToBlt;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Install protocol interface
|
|
||||||
//
|
|
||||||
Handle = NULL;
|
|
||||||
Status = gBS->InstallProtocolInterface (
|
|
||||||
&Handle,
|
|
||||||
&gEfiHiiProtocolGuid,
|
|
||||||
EFI_NATIVE_INTERFACE,
|
|
||||||
&HiiData->Hii
|
|
||||||
);
|
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiFindHandles (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN OUT UINT16 *HandleBufferLength,
|
|
||||||
OUT FRAMEWORK_EFI_HII_HANDLE Handle[1]
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Determines the handles that are currently active in the database.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_HII_HANDLE_DATABASE *Database;
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
UINTN HandleCount;
|
|
||||||
|
|
||||||
if (This == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = EFI_HII_DATA_FROM_THIS (This);
|
|
||||||
|
|
||||||
Database = HiiData->DatabaseHead;
|
|
||||||
|
|
||||||
if (Database == NULL) {
|
|
||||||
*HandleBufferLength = 0;
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (HandleCount = 0; Database != NULL; HandleCount++) {
|
|
||||||
Database = Database->NextHandleDatabase;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Is there a sufficient buffer for the data being passed back?
|
|
||||||
//
|
|
||||||
if (*HandleBufferLength >= (sizeof (FRAMEWORK_EFI_HII_HANDLE ) * HandleCount)) {
|
|
||||||
Database = HiiData->DatabaseHead;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Copy the Head information
|
|
||||||
//
|
|
||||||
if (Database->Handle != 0) {
|
|
||||||
CopyMem (&Handle[0], &Database->Handle, sizeof (FRAMEWORK_EFI_HII_HANDLE ));
|
|
||||||
Database = Database->NextHandleDatabase;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Copy more data if appropriate
|
|
||||||
//
|
|
||||||
for (HandleCount = 1; Database != NULL; HandleCount++) {
|
|
||||||
CopyMem (&Handle[HandleCount], &Database->Handle, sizeof (FRAMEWORK_EFI_HII_HANDLE ));
|
|
||||||
Database = Database->NextHandleDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
*HandleBufferLength = (UINT16) (sizeof (FRAMEWORK_EFI_HII_HANDLE ) * HandleCount);
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Insufficient buffer length
|
|
||||||
//
|
|
||||||
*HandleBufferLength = (UINT16) (sizeof (FRAMEWORK_EFI_HII_HANDLE ) * HandleCount);
|
|
||||||
return EFI_BUFFER_TOO_SMALL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetPrimaryLanguages (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
OUT EFI_STRING *LanguageString
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function allows a program to determine what the primary languages that are supported on a given handle.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
UINTN Count;
|
|
||||||
EFI_HII_PACKAGE_INSTANCE *PackageInstance;
|
|
||||||
EFI_HII_PACKAGE_INSTANCE *StringPackageInstance;
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
EFI_HII_HANDLE_DATABASE *HandleDatabase;
|
|
||||||
EFI_HII_STRING_PACK *StringPack;
|
|
||||||
EFI_HII_STRING_PACK *Location;
|
|
||||||
UINT32 Length;
|
|
||||||
RELOFST Token;
|
|
||||||
|
|
||||||
if (This == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = EFI_HII_DATA_FROM_THIS (This);
|
|
||||||
|
|
||||||
PackageInstance = NULL;
|
|
||||||
//
|
|
||||||
// Find matching handle in the handle database. Then get the package instance.
|
|
||||||
//
|
|
||||||
for (HandleDatabase = HiiData->DatabaseHead;
|
|
||||||
HandleDatabase != NULL;
|
|
||||||
HandleDatabase = HandleDatabase->NextHandleDatabase
|
|
||||||
) {
|
|
||||||
if (Handle == HandleDatabase->Handle) {
|
|
||||||
PackageInstance = HandleDatabase->Buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// No handle was found - error condition
|
|
||||||
//
|
|
||||||
if (PackageInstance == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValidatePack (This, PackageInstance, &StringPackageInstance, NULL);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Based on if there is IFR data in this package instance, determine
|
|
||||||
// what the location is of the beginning of the string data.
|
|
||||||
//
|
|
||||||
if (StringPackageInstance->IfrSize > 0) {
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (&StringPackageInstance->IfrData) + StringPackageInstance->IfrSize);
|
|
||||||
} else {
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) (&StringPackageInstance->IfrData);
|
|
||||||
}
|
|
||||||
|
|
||||||
Location = StringPack;
|
|
||||||
//
|
|
||||||
// Remember that the string packages are formed into contiguous blocks of language data.
|
|
||||||
//
|
|
||||||
CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));
|
|
||||||
for (Count = 0; Length != 0; Count = Count + 3) {
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + Length);
|
|
||||||
CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));
|
|
||||||
}
|
|
||||||
|
|
||||||
*LanguageString = AllocateZeroPool (2 * (Count + 1));
|
|
||||||
|
|
||||||
ASSERT (*LanguageString);
|
|
||||||
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) Location;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Copy the 6 bytes to LanguageString - keep concatenating it. Shouldn't we just store uint8's since the ISO
|
|
||||||
// standard defines the lettering as all US English characters anyway? Save a few bytes.
|
|
||||||
//
|
|
||||||
CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));
|
|
||||||
for (Count = 0; Length != 0; Count = Count + 3) {
|
|
||||||
CopyMem (&Token, &StringPack->LanguageNameString, sizeof (RELOFST));
|
|
||||||
CopyMem (*LanguageString + Count, (VOID *) ((CHAR8 *) (StringPack) + Token), 6);
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + Length);
|
|
||||||
CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetSecondaryLanguages (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN CHAR16 *PrimaryLanguage,
|
|
||||||
OUT EFI_STRING *LanguageString
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function allows a program to determine which secondary languages are supported
|
|
||||||
on a given handle for a given primary language.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
UINTN Count;
|
|
||||||
EFI_HII_PACKAGE_INSTANCE *PackageInstance;
|
|
||||||
EFI_HII_PACKAGE_INSTANCE *StringPackageInstance;
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
EFI_HII_HANDLE_DATABASE *HandleDatabase;
|
|
||||||
EFI_HII_STRING_PACK *StringPack;
|
|
||||||
RELOFST Token;
|
|
||||||
UINT32 Length;
|
|
||||||
|
|
||||||
if (This == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = EFI_HII_DATA_FROM_THIS (This);
|
|
||||||
//
|
|
||||||
// Check numeric value against the head of the database
|
|
||||||
//
|
|
||||||
PackageInstance = NULL;
|
|
||||||
for (HandleDatabase = HiiData->DatabaseHead;
|
|
||||||
HandleDatabase != NULL;
|
|
||||||
HandleDatabase = HandleDatabase->NextHandleDatabase
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
// Match the numeric value with the database entry - if matched, extract PackageInstance
|
|
||||||
//
|
|
||||||
if (Handle == HandleDatabase->Handle) {
|
|
||||||
PackageInstance = HandleDatabase->Buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// No handle was found - error condition
|
|
||||||
//
|
|
||||||
if (PackageInstance == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValidatePack (This, PackageInstance, &StringPackageInstance, NULL);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Based on if there is IFR data in this package instance, determine
|
|
||||||
// what the location is of the beginning of the string data.
|
|
||||||
//
|
|
||||||
if (StringPackageInstance->IfrSize > 0) {
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (&StringPackageInstance->IfrData) + StringPackageInstance->IfrSize);
|
|
||||||
} else {
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) (&StringPackageInstance->IfrData);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Remember that the string packages are formed into contiguous blocks of language data.
|
|
||||||
//
|
|
||||||
for (; StringPack->Header.Length != 0;) {
|
|
||||||
//
|
|
||||||
// Find the PrimaryLanguage being requested
|
|
||||||
//
|
|
||||||
Token = StringPack->LanguageNameString;
|
|
||||||
if (CompareMem ((VOID *) ((CHAR8 *) (StringPack) + Token), PrimaryLanguage, 3) == 0) {
|
|
||||||
//
|
|
||||||
// Now that we found the primary, the secondary languages will follow immediately
|
|
||||||
// or the next character is a NULL if there are no secondary languages. We determine
|
|
||||||
// the number by getting the stringsize based on the StringPack origination + the LanguageNameString
|
|
||||||
// offset + 6 (which is the size of the first 3 letter ISO primary language name). If we get 2, there
|
|
||||||
// are no secondary languages (2 = null-terminator).
|
|
||||||
//
|
|
||||||
Count = StrSize ((VOID *) ((CHAR8 *) (StringPack) + Token + 6));
|
|
||||||
|
|
||||||
*LanguageString = AllocateZeroPool (2 * (Count + 1));
|
|
||||||
|
|
||||||
ASSERT (*LanguageString);
|
|
||||||
|
|
||||||
CopyMem (*LanguageString, (VOID *) ((CHAR8 *) (StringPack) + Token + 6), Count);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,312 +0,0 @@
|
||||||
/**@file
|
|
||||||
|
|
||||||
This file contains global defines and prototype definitions
|
|
||||||
for the HII database.
|
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _HIIDATABASE_H
|
|
||||||
#define _HIIDATABASE_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <FrameworkDxe.h>
|
|
||||||
|
|
||||||
#include <Guid/GlobalVariable.h>
|
|
||||||
#include <Protocol/FrameworkFormCallback.h>
|
|
||||||
#include <Protocol/FrameworkHii.h>
|
|
||||||
|
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/UefiDriverEntryPoint.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
||||||
#include <Library/FrameworkIfrSupportLib.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// HII Database Global data
|
|
||||||
//
|
|
||||||
#define EFI_HII_DATA_SIGNATURE EFI_SIGNATURE_32 ('H', 'i', 'i', 'P')
|
|
||||||
|
|
||||||
#define MAX_GLYPH_COUNT 65535
|
|
||||||
#define NARROW_GLYPH_ARRAY_SIZE 19
|
|
||||||
#define WIDE_GLYPH_ARRAY_SIZE 38
|
|
||||||
|
|
||||||
#define SETUP_MAP_NAME L"Setup"
|
|
||||||
#define HII_VARIABLE_SUFFIX_USER_DATA L"UserSavedData"
|
|
||||||
#define HII_VARIABLE_SUFFIX_DEFAULT_OVERRIDE L"DefaultOverride"
|
|
||||||
#define HII_VARIABLE_SUFFIX_MANUFACTURING_OVERRIDE L"ManufacturingOverride"
|
|
||||||
|
|
||||||
typedef struct _EFI_HII_HANDLE_DATABASE {
|
|
||||||
VOID *Buffer; // Actual buffer pointer
|
|
||||||
FRAMEWORK_EFI_HII_HANDLE Handle; // Monotonically increasing value to signify the value returned to caller
|
|
||||||
UINT32 NumberOfTokens; // The initial number of tokens when first registered
|
|
||||||
struct _EFI_HII_HANDLE_DATABASE *NextHandleDatabase;
|
|
||||||
} EFI_HII_HANDLE_DATABASE;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
EFI_NARROW_GLYPH NarrowGlyphs[MAX_GLYPH_COUNT];
|
|
||||||
EFI_WIDE_GLYPH WideGlyphs[MAX_GLYPH_COUNT];
|
|
||||||
FRAMEWORK_EFI_KEY_DESCRIPTOR SystemKeyboardLayout[106];
|
|
||||||
FRAMEWORK_EFI_KEY_DESCRIPTOR OverrideKeyboardLayout[106];
|
|
||||||
BOOLEAN SystemKeyboardUpdate; // Has the SystemKeyboard been updated?
|
|
||||||
} EFI_HII_GLOBAL_DATA;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINTN Signature;
|
|
||||||
|
|
||||||
EFI_HII_GLOBAL_DATA *GlobalData;
|
|
||||||
EFI_HII_HANDLE_DATABASE *DatabaseHead; // Head of the Null-terminated singly-linked list of handles.
|
|
||||||
EFI_HII_PROTOCOL Hii;
|
|
||||||
} EFI_HII_DATA;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
FRAMEWORK_EFI_HII_HANDLE Handle;
|
|
||||||
EFI_GUID Guid;
|
|
||||||
EFI_HII_HANDLE_PACK HandlePack;
|
|
||||||
UINTN IfrSize;
|
|
||||||
UINTN StringSize;
|
|
||||||
EFI_HII_IFR_PACK *IfrData; // All the IFR data stored here
|
|
||||||
EFI_HII_STRING_PACK *StringData; // All the String data stored at &IfrData + IfrSize (StringData is just a label - never referenced)
|
|
||||||
} EFI_HII_PACKAGE_INSTANCE;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
EFI_HII_PACK_HEADER Header;
|
|
||||||
FRAMEWORK_EFI_IFR_FORM_SET FormSet;
|
|
||||||
FRAMEWORK_EFI_IFR_END_FORM_SET EndFormSet;
|
|
||||||
} EFI_FORM_SET_STUB;
|
|
||||||
|
|
||||||
#define EFI_HII_DATA_FROM_THIS(a) CR (a, EFI_HII_DATA, Hii, EFI_HII_DATA_SIGNATURE)
|
|
||||||
|
|
||||||
#define NARROW_WIDTH 8
|
|
||||||
#define WIDE_WIDTH 16
|
|
||||||
|
|
||||||
extern UINT8 mUnknownGlyph[38];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prototypes
|
|
||||||
//
|
|
||||||
EFI_STATUS
|
|
||||||
GetPackSize (
|
|
||||||
IN VOID *Pack,
|
|
||||||
OUT UINTN *PackSize,
|
|
||||||
OUT UINT32 *NumberOfTokens
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
ValidatePack (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN EFI_HII_PACKAGE_INSTANCE *PackageInstance,
|
|
||||||
OUT EFI_HII_PACKAGE_INSTANCE **StringPackageInstance,
|
|
||||||
OUT UINT32 *TotalStringCount
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Public Interface Prototypes
|
|
||||||
//
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
InitializeHiiDatabase (
|
|
||||||
IN EFI_HANDLE ImageHandle,
|
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiNewPack (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN EFI_HII_PACKAGES *PackageList,
|
|
||||||
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiRemovePack (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiFindHandles (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN OUT UINT16 *HandleBufferLength,
|
|
||||||
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiExportDatabase (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN OUT UINTN *BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetGlyph (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN CHAR16 *Source,
|
|
||||||
IN OUT UINT16 *Index,
|
|
||||||
OUT UINT8 **GlyphBuffer,
|
|
||||||
OUT UINT16 *BitWidth,
|
|
||||||
IN OUT UINT32 *InternalStatus
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGlyphToBlt (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN UINT8 *GlyphBuffer,
|
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
|
||||||
IN UINTN Count,
|
|
||||||
IN UINTN Width,
|
|
||||||
IN UINTN Height,
|
|
||||||
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiNewString (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN CHAR16 *Language,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN OUT STRING_REF *Reference,
|
|
||||||
IN CHAR16 *NewString
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetString (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN STRING_REF Token,
|
|
||||||
IN BOOLEAN Raw,
|
|
||||||
IN CHAR16 *LanguageString,
|
|
||||||
IN OUT UINTN *BufferLength,
|
|
||||||
OUT EFI_STRING StringBuffer
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiResetStrings (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiTestString (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN CHAR16 *StringToTest,
|
|
||||||
IN OUT UINT32 *FirstMissing,
|
|
||||||
OUT UINT32 *GlyphBufferSize
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetPrimaryLanguages (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
OUT EFI_STRING *LanguageString
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetSecondaryLanguages (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN CHAR16 *PrimaryLanguage,
|
|
||||||
OUT EFI_STRING *LanguageString
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetLine (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN STRING_REF Token,
|
|
||||||
IN OUT UINT16 *Index,
|
|
||||||
IN UINT16 LineWidth,
|
|
||||||
IN CHAR16 *LanguageString,
|
|
||||||
IN OUT UINT16 *BufferLength,
|
|
||||||
OUT EFI_STRING StringBuffer
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetForms (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN EFI_FORM_ID FormId,
|
|
||||||
IN OUT UINTN *BufferLength,
|
|
||||||
OUT UINT8 *Buffer
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetDefaultImage (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN UINTN DefaultMask,
|
|
||||||
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiUpdateForm (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
||||||
IN EFI_FORM_LABEL Label,
|
|
||||||
IN BOOLEAN AddData,
|
|
||||||
IN EFI_HII_UPDATE_DATA *Data
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetKeyboardLayout (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
OUT UINT16 *DescriptorCount,
|
|
||||||
OUT FRAMEWORK_EFI_KEY_DESCRIPTOR *Descriptor
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
HiiCompareLanguage (
|
|
||||||
IN CHAR16 *LanguageStringLocation,
|
|
||||||
IN CHAR16 *Language
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,68 +0,0 @@
|
||||||
#/** @file
|
|
||||||
# Component description file for HiiDatabase module.
|
|
||||||
#
|
|
||||||
# This module inits HII database and installs HII protocol.
|
|
||||||
# Copyright (c) 2006 - 2007, Intel Corporation
|
|
||||||
#
|
|
||||||
# All rights reserved. This program and the accompanying materials
|
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
# which accompanies this distribution. The full text of the license may be found at
|
|
||||||
# http://opensource.org/licenses/bsd-license.php
|
|
||||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#**/
|
|
||||||
|
|
||||||
[Defines]
|
|
||||||
INF_VERSION = 0x00010005
|
|
||||||
BASE_NAME = HiiDatabase
|
|
||||||
FILE_GUID = FCD337AB-B1D3-4EF8-957C-8048606FF670
|
|
||||||
MODULE_TYPE = DXE_DRIVER
|
|
||||||
VERSION_STRING = 1.0
|
|
||||||
EDK_RELEASE_VERSION = 0x00020000
|
|
||||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
|
||||||
|
|
||||||
ENTRY_POINT = InitializeHiiDatabase
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following information is for reference only and not required by the build tools.
|
|
||||||
#
|
|
||||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
|
||||||
#
|
|
||||||
|
|
||||||
[Sources.common]
|
|
||||||
Keyboard.c
|
|
||||||
Fonts.c
|
|
||||||
Package.c
|
|
||||||
Strings.c
|
|
||||||
Forms.c
|
|
||||||
HiiDatabase.h
|
|
||||||
HiiDatabase.c
|
|
||||||
|
|
||||||
|
|
||||||
[Packages]
|
|
||||||
MdePkg/MdePkg.dec
|
|
||||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
|
||||||
|
|
||||||
[LibraryClasses]
|
|
||||||
FrameworkIfrSupportLib
|
|
||||||
UefiRuntimeServicesTableLib
|
|
||||||
UefiBootServicesTableLib
|
|
||||||
BaseMemoryLib
|
|
||||||
MemoryAllocationLib
|
|
||||||
UefiDriverEntryPoint
|
|
||||||
DebugLib
|
|
||||||
BaseLib
|
|
||||||
|
|
||||||
|
|
||||||
[Guids]
|
|
||||||
gEfiGlobalVariableGuid # SOMETIMES_CONSUMED L"Lang"
|
|
||||||
|
|
||||||
|
|
||||||
[Protocols]
|
|
||||||
gEfiFormCallbackProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiHiiProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
|
||||||
|
|
||||||
[Depex]
|
|
||||||
TRUE
|
|
|
@ -1,87 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
|
|
||||||
<MsaHeader>
|
|
||||||
<ModuleName>HiiDatabase</ModuleName>
|
|
||||||
<ModuleType>DXE_DRIVER</ModuleType>
|
|
||||||
<GuidValue>FCD337AB-B1D3-4EF8-957C-8048606FF670</GuidValue>
|
|
||||||
<Version>1.0</Version>
|
|
||||||
<Abstract>Component description file for HiiDatabase module.</Abstract>
|
|
||||||
<Description>This module inits HII database and installs HII protocol.</Description>
|
|
||||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
|
|
||||||
<License>All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
|
|
||||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
|
||||||
</MsaHeader>
|
|
||||||
<ModuleDefinitions>
|
|
||||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
|
||||||
<BinaryModule>false</BinaryModule>
|
|
||||||
<OutputFileBasename>HiiDatabase</OutputFileBasename>
|
|
||||||
</ModuleDefinitions>
|
|
||||||
<LibraryClassDefinitions>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>BaseLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">
|
|
||||||
<Keyword>DebugLib</Keyword>
|
|
||||||
<HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>UefiDriverEntryPoint</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>MemoryAllocationLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>BaseMemoryLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>UefiRuntimeServicesTableLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>EdkIfrSupportLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
</LibraryClassDefinitions>
|
|
||||||
<SourceFiles>
|
|
||||||
<Filename>HiiDatabase.c</Filename>
|
|
||||||
<Filename>HiiDatabase.h</Filename>
|
|
||||||
<Filename>Forms.c</Filename>
|
|
||||||
<Filename>Strings.c</Filename>
|
|
||||||
<Filename>Package.c</Filename>
|
|
||||||
<Filename>Fonts.c</Filename>
|
|
||||||
<Filename>Keyboard.c</Filename>
|
|
||||||
<Filename>HiiDatabase.dxs</Filename>
|
|
||||||
</SourceFiles>
|
|
||||||
<PackageDependencies>
|
|
||||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
|
||||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
|
||||||
</PackageDependencies>
|
|
||||||
<Protocols>
|
|
||||||
<Protocol Usage="ALWAYS_PRODUCED">
|
|
||||||
<ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiFormCallbackProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
</Protocols>
|
|
||||||
<Variables>
|
|
||||||
<Variable Usage="SOMETIMES_CONSUMED">
|
|
||||||
<VariableName>0x004C 0x0061 0x006E 0x0067</VariableName>
|
|
||||||
<GuidC_Name>gEfiGlobalVariableGuid</GuidC_Name>
|
|
||||||
<HelpText>L"Lang" global variable is used as system default language.</HelpText>
|
|
||||||
</Variable>
|
|
||||||
</Variables>
|
|
||||||
<Externs>
|
|
||||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
|
||||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
|
||||||
<Extern>
|
|
||||||
<ModuleEntryPoint>InitializeHiiDatabase</ModuleEntryPoint>
|
|
||||||
</Extern>
|
|
||||||
</Externs>
|
|
||||||
</ModuleSurfaceArea>
|
|
|
@ -1,37 +0,0 @@
|
||||||
/**@file
|
|
||||||
|
|
||||||
This file contains the keyboard processing code to the HII database.
|
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
#include "HiiDatabase.h"
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiGetKeyboardLayout (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
OUT UINT16 *DescriptorCount,
|
|
||||||
OUT FRAMEWORK_EFI_KEY_DESCRIPTOR *Descriptor
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
|
@ -1,667 +0,0 @@
|
||||||
/**@file
|
|
||||||
|
|
||||||
This file contains the keyboard processing code to the HII database.
|
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
#include "HiiDatabase.h"
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
GetPackSize (
|
|
||||||
IN VOID *Pack,
|
|
||||||
OUT UINTN *PackSize,
|
|
||||||
OUT UINT32 *NumberOfTokens
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Determines the passed in Pack's size and returns the value.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_HII_STRING_PACK *StringPack;
|
|
||||||
UINT16 Type;
|
|
||||||
UINT32 Length;
|
|
||||||
|
|
||||||
*PackSize = 0;
|
|
||||||
|
|
||||||
Type = EFI_HII_IFR;
|
|
||||||
if (!CompareMem (&((EFI_HII_PACK_HEADER *) Pack)->Type, &Type, sizeof (UINT16))) {
|
|
||||||
//
|
|
||||||
// The header contains the full IFR length
|
|
||||||
//
|
|
||||||
CopyMem (&Length, &((EFI_HII_PACK_HEADER *) Pack)->Length, sizeof (Length));
|
|
||||||
*PackSize = (UINTN) Length;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type = EFI_HII_STRING;
|
|
||||||
if (!CompareMem (&((EFI_HII_PACK_HEADER *) Pack)->Type, &Type, sizeof (UINT16))) {
|
|
||||||
//
|
|
||||||
// The header contains the STRING package length
|
|
||||||
// The assumption is that the strings for all languages
|
|
||||||
// are a contiguous block of data and there is a series of
|
|
||||||
// these package instances which will terminate with a NULL package
|
|
||||||
// instance.
|
|
||||||
//
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) Pack;
|
|
||||||
|
|
||||||
//
|
|
||||||
// There may be multiple instances packed together of strings
|
|
||||||
// so we must walk the self describing structures until we encounter
|
|
||||||
// the NULL structure to determine the full size.
|
|
||||||
//
|
|
||||||
CopyMem (&Length, &StringPack->Header.Length, sizeof (Length));
|
|
||||||
if (NumberOfTokens != NULL) {
|
|
||||||
CopyMem (NumberOfTokens, &StringPack->NumStringPointers, sizeof (UINT32));
|
|
||||||
}
|
|
||||||
|
|
||||||
while (Length != 0) {
|
|
||||||
*PackSize = *PackSize + Length;
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) StringPack + Length);
|
|
||||||
CopyMem (&Length, &StringPack->Header.Length, sizeof (Length));
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Encountered a length of 0, so let's add the space for the NULL terminator
|
|
||||||
// pack's length and call it done.
|
|
||||||
//
|
|
||||||
*PackSize = *PackSize + sizeof (EFI_HII_STRING_PACK);
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// We only determine the size of the non-global Package types.
|
|
||||||
// If neither IFR or STRING data were found, return an error
|
|
||||||
//
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
ValidatePack (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN EFI_HII_PACKAGE_INSTANCE *PackageInstance,
|
|
||||||
OUT EFI_HII_PACKAGE_INSTANCE **StringPackageInstance,
|
|
||||||
OUT UINT32 *TotalStringCount
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Verifies that the package instance is using the correct handle for string operations.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
EFI_HII_HANDLE_DATABASE *HandleDatabase;
|
|
||||||
EFI_HII_PACKAGE_INSTANCE *HandlePackageInstance;
|
|
||||||
UINT8 *RawData;
|
|
||||||
EFI_GUID Guid;
|
|
||||||
EFI_HII_IFR_PACK *FormPack;
|
|
||||||
UINTN Index;
|
|
||||||
|
|
||||||
if (This == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = EFI_HII_DATA_FROM_THIS (This);
|
|
||||||
|
|
||||||
HandleDatabase = HiiData->DatabaseHead;
|
|
||||||
ZeroMem (&Guid, sizeof (EFI_GUID));
|
|
||||||
|
|
||||||
*StringPackageInstance = PackageInstance;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Based on if there is IFR data in this package instance, determine
|
|
||||||
// what the location is of the beginning of the string data.
|
|
||||||
//
|
|
||||||
if (PackageInstance->IfrSize > 0) {
|
|
||||||
FormPack = (EFI_HII_IFR_PACK *) ((CHAR8 *) (&PackageInstance->IfrData) + sizeof (EFI_HII_PACK_HEADER));
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// If there is no IFR data assume the caller knows what they are doing.
|
|
||||||
//
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
RawData = (UINT8 *) FormPack;
|
|
||||||
|
|
||||||
for (Index = 0; RawData[Index] != FRAMEWORK_EFI_IFR_END_FORM_SET_OP;) {
|
|
||||||
if (RawData[Index] == FRAMEWORK_EFI_IFR_FORM_SET_OP) {
|
|
||||||
//
|
|
||||||
// Cache the guid for this formset
|
|
||||||
//
|
|
||||||
CopyMem (&Guid, &((FRAMEWORK_EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Index = RawData[Index + 1] + Index;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If there is no string package, and the PackageInstance->IfrPack.Guid and PackageInstance->Guid are
|
|
||||||
// different, we should return the correct handle for the caller to use for strings.
|
|
||||||
//
|
|
||||||
if ((PackageInstance->StringSize == 0) && (!CompareGuid (&Guid, &PackageInstance->Guid))) {
|
|
||||||
//
|
|
||||||
// Search the database for a handle that matches the PackageInstance->Guid
|
|
||||||
//
|
|
||||||
for (; HandleDatabase != NULL; HandleDatabase = HandleDatabase->NextHandleDatabase) {
|
|
||||||
//
|
|
||||||
// Get Ifrdata and extract the Guid for it
|
|
||||||
//
|
|
||||||
HandlePackageInstance = HandleDatabase->Buffer;
|
|
||||||
|
|
||||||
ASSERT (HandlePackageInstance->IfrSize != 0);
|
|
||||||
|
|
||||||
FormPack = (EFI_HII_IFR_PACK *) ((CHAR8 *) (&HandlePackageInstance->IfrData) + sizeof (EFI_HII_PACK_HEADER));
|
|
||||||
RawData = (UINT8 *) FormPack;
|
|
||||||
|
|
||||||
for (Index = 0; RawData[Index] != FRAMEWORK_EFI_IFR_END_FORM_SET_OP;) {
|
|
||||||
if (RawData[Index] == FRAMEWORK_EFI_IFR_FORM_SET_OP) {
|
|
||||||
//
|
|
||||||
// Cache the guid for this formset
|
|
||||||
//
|
|
||||||
CopyMem (&Guid, &((FRAMEWORK_EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Index = RawData[Index + 1] + Index;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If the Guid from the new handle matches the original Guid referenced in the original package data
|
|
||||||
// return the appropriate package instance data to use.
|
|
||||||
//
|
|
||||||
if (CompareGuid (&Guid, &PackageInstance->Guid)) {
|
|
||||||
if (TotalStringCount != NULL) {
|
|
||||||
*TotalStringCount = HandleDatabase->NumberOfTokens;
|
|
||||||
}
|
|
||||||
|
|
||||||
*StringPackageInstance = HandlePackageInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// end for
|
|
||||||
//
|
|
||||||
} else {
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiNewPack (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN EFI_HII_PACKAGES *Packages,
|
|
||||||
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Extracts the various packs from a package list.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
This - Pointer of HII protocol.
|
|
||||||
Packages - Pointer of HII packages.
|
|
||||||
Handle - Handle value to be returned.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - Pacakges has added to HII database successfully.
|
|
||||||
EFI_INVALID_PARAMETER - Invalid parameter.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_HII_PACKAGE_INSTANCE *PackageInstance;
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
EFI_HII_HANDLE_DATABASE *HandleDatabase;
|
|
||||||
EFI_HII_HANDLE_DATABASE *Database;
|
|
||||||
EFI_HII_PACK_HEADER *PackageHeader;
|
|
||||||
EFI_HII_GLOBAL_DATA *GlobalData;
|
|
||||||
EFI_HII_IFR_PACK *IfrPack;
|
|
||||||
EFI_HII_STRING_PACK *StringPack;
|
|
||||||
EFI_HII_FONT_PACK *FontPack;
|
|
||||||
EFI_HII_KEYBOARD_PACK *KeyboardPack;
|
|
||||||
EFI_STATUS Status;
|
|
||||||
UINTN IfrSize;
|
|
||||||
UINTN StringSize;
|
|
||||||
UINTN TotalStringSize;
|
|
||||||
UINTN InstanceSize;
|
|
||||||
UINTN Count;
|
|
||||||
UINTN Index;
|
|
||||||
UINT16 Member;
|
|
||||||
EFI_GUID Guid;
|
|
||||||
EFI_FORM_SET_STUB FormSetStub;
|
|
||||||
UINT8 *Location;
|
|
||||||
UINT16 Unicode;
|
|
||||||
UINT16 NumWideGlyphs;
|
|
||||||
UINT16 NumNarrowGlyphs;
|
|
||||||
UINT32 NumberOfTokens;
|
|
||||||
UINT32 TotalTokenNumber;
|
|
||||||
UINT8 *Local;
|
|
||||||
EFI_NARROW_GLYPH *NarrowGlyph;
|
|
||||||
|
|
||||||
if (Packages->NumberOfPackages == 0 || This == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = EFI_HII_DATA_FROM_THIS (This);
|
|
||||||
|
|
||||||
GlobalData = HiiData->GlobalData;
|
|
||||||
|
|
||||||
Database = HiiData->DatabaseHead;
|
|
||||||
|
|
||||||
PackageInstance = NULL;
|
|
||||||
IfrPack = NULL;
|
|
||||||
StringPack = NULL;
|
|
||||||
InstanceSize = 0;
|
|
||||||
IfrSize = 0;
|
|
||||||
StringSize = 0;
|
|
||||||
TotalStringSize = 0;
|
|
||||||
NumberOfTokens = 0;
|
|
||||||
TotalTokenNumber = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Search through the passed in Packages for the IfrPack and any StringPack.
|
|
||||||
//
|
|
||||||
for (Index = 0; Index < Packages->NumberOfPackages; Index++) {
|
|
||||||
|
|
||||||
PackageHeader = *(EFI_HII_PACK_HEADER **) (((UINT8 *) Packages) + sizeof (EFI_HII_PACKAGES) + Index * sizeof (VOID *));
|
|
||||||
|
|
||||||
switch (PackageHeader->Type) {
|
|
||||||
case EFI_HII_IFR:
|
|
||||||
//
|
|
||||||
// There shoule be only one Ifr package.
|
|
||||||
//
|
|
||||||
ASSERT (IfrPack == NULL);
|
|
||||||
IfrPack = (EFI_HII_IFR_PACK *) PackageHeader;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EFI_HII_STRING:
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) PackageHeader;
|
|
||||||
//
|
|
||||||
// Sending me a String Package. Get its size.
|
|
||||||
//
|
|
||||||
Status = GetPackSize ((VOID *) StringPack, &StringSize, &NumberOfTokens);
|
|
||||||
ASSERT (!EFI_ERROR (Status));
|
|
||||||
|
|
||||||
//
|
|
||||||
// The size which GetPackSize() returns include the null terminator. So if multiple
|
|
||||||
// string packages are passed in, merge all these packages, and only pad one null terminator.
|
|
||||||
//
|
|
||||||
if (TotalStringSize > 0) {
|
|
||||||
TotalStringSize -= sizeof (EFI_HII_STRING_PACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
TotalStringSize += StringSize;
|
|
||||||
TotalTokenNumber += NumberOfTokens;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If sending a StringPack without an IfrPack, you must include a GuidId
|
|
||||||
//
|
|
||||||
if ((StringPack != NULL) && (IfrPack == NULL)) {
|
|
||||||
if (Packages->GuidId == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If passing in an IfrPack and a GuidId is provided, ensure they are the same value.
|
|
||||||
//
|
|
||||||
if ((IfrPack != NULL) && (Packages->GuidId != NULL)) {
|
|
||||||
Location = ((UINT8 *) IfrPack);
|
|
||||||
Location = (UINT8 *) (((UINTN) Location) + sizeof (EFI_HII_PACK_HEADER));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Advance to the Form Set Op-code
|
|
||||||
//
|
|
||||||
for (Count = 0; ((FRAMEWORK_EFI_IFR_OP_HEADER *) &Location[Count])->OpCode != FRAMEWORK_EFI_IFR_FORM_SET_OP;) {
|
|
||||||
Count = Count + ((FRAMEWORK_EFI_IFR_OP_HEADER *) &Location[Count])->Length;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Copy to local variable
|
|
||||||
//
|
|
||||||
CopyMem (&Guid, &((FRAMEWORK_EFI_IFR_FORM_SET *) &Location[Count])->Guid, sizeof (EFI_GUID));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check to see if IfrPack->Guid != GuidId
|
|
||||||
//
|
|
||||||
if (!CompareGuid (&Guid, Packages->GuidId)) {
|
|
||||||
//
|
|
||||||
// If a string package is present, the GUIDs should have agreed. Return an error
|
|
||||||
//
|
|
||||||
if (StringPack != NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If someone is passing in a string only, create a dummy IfrPack with a Guid
|
|
||||||
// to enable future searching of this data.
|
|
||||||
//
|
|
||||||
if ((IfrPack == NULL) && (StringPack != NULL)) {
|
|
||||||
ZeroMem (&FormSetStub, sizeof (FormSetStub));
|
|
||||||
|
|
||||||
FormSetStub.Header.Type = EFI_HII_IFR;
|
|
||||||
FormSetStub.Header.Length = sizeof (EFI_FORM_SET_STUB);
|
|
||||||
|
|
||||||
FormSetStub.FormSet.Header.OpCode = FRAMEWORK_EFI_IFR_FORM_SET_OP;
|
|
||||||
FormSetStub.FormSet.Header.Length = (UINT8) sizeof (FRAMEWORK_EFI_IFR_FORM_SET);
|
|
||||||
//
|
|
||||||
// Dummy string
|
|
||||||
//
|
|
||||||
FormSetStub.FormSet.FormSetTitle = 0x02;
|
|
||||||
CopyMem (&FormSetStub.FormSet.Guid, Packages->GuidId, sizeof (EFI_GUID));
|
|
||||||
|
|
||||||
FormSetStub.EndFormSet.Header.OpCode = FRAMEWORK_EFI_IFR_END_FORM_SET_OP;
|
|
||||||
FormSetStub.EndFormSet.Header.Length = (UINT8) sizeof (FRAMEWORK_EFI_IFR_END_FORM_SET);
|
|
||||||
IfrPack = (EFI_HII_IFR_PACK *) &FormSetStub;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IfrPack != NULL) {
|
|
||||||
//
|
|
||||||
// Sending me an IFR Package. Get its size.
|
|
||||||
//
|
|
||||||
Status = GetPackSize ((VOID *) IfrPack, &IfrSize, NULL);
|
|
||||||
ASSERT (!EFI_ERROR (Status));
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Prepare the internal package instace buffer to store package data.
|
|
||||||
//
|
|
||||||
InstanceSize = IfrSize + TotalStringSize;
|
|
||||||
|
|
||||||
if (InstanceSize != 0) {
|
|
||||||
PackageInstance = AllocateZeroPool (InstanceSize + sizeof (EFI_HII_PACKAGE_INSTANCE));
|
|
||||||
|
|
||||||
ASSERT (PackageInstance);
|
|
||||||
|
|
||||||
//
|
|
||||||
// If there is no DatabaseHead allocated - allocate one
|
|
||||||
//
|
|
||||||
if (HiiData->DatabaseHead == NULL) {
|
|
||||||
HiiData->DatabaseHead = AllocateZeroPool (sizeof (EFI_HII_HANDLE_DATABASE));
|
|
||||||
ASSERT (HiiData->DatabaseHead);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If the head is being used (Handle is non-zero), allocate next Database and
|
|
||||||
// add it to the linked-list
|
|
||||||
//
|
|
||||||
if (HiiData->DatabaseHead->Handle != 0) {
|
|
||||||
HandleDatabase = AllocateZeroPool (sizeof (EFI_HII_HANDLE_DATABASE));
|
|
||||||
|
|
||||||
ASSERT (HandleDatabase);
|
|
||||||
|
|
||||||
for (; Database->NextHandleDatabase != NULL; Database = Database->NextHandleDatabase)
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// We are sitting on the Database entry which contains the null Next pointer. Fix it.
|
|
||||||
//
|
|
||||||
Database->NextHandleDatabase = HandleDatabase;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Database = HiiData->DatabaseHead;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize this instance data
|
|
||||||
//
|
|
||||||
for (*Handle = 1; Database->NextHandleDatabase != NULL; Database = Database->NextHandleDatabase) {
|
|
||||||
//
|
|
||||||
// Since the first Database instance will have a passed back handle of 1, we will continue
|
|
||||||
// down the linked list of entries until we encounter the end of the linked list. Each time
|
|
||||||
// we go down one level deeper, increment the handle value that will be passed back.
|
|
||||||
//
|
|
||||||
if (Database->Handle >= *Handle) {
|
|
||||||
*Handle = (FRAMEWORK_EFI_HII_HANDLE ) (Database->Handle + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PackageInstance->Handle = *Handle;
|
|
||||||
PackageInstance->IfrSize = IfrSize;
|
|
||||||
PackageInstance->StringSize = TotalStringSize;
|
|
||||||
if (Packages->GuidId != NULL) {
|
|
||||||
CopyMem (&PackageInstance->Guid, Packages->GuidId, sizeof (EFI_GUID));
|
|
||||||
}
|
|
||||||
|
|
||||||
Database->Buffer = PackageInstance;
|
|
||||||
Database->Handle = PackageInstance->Handle;
|
|
||||||
Database->NumberOfTokens = TotalTokenNumber;
|
|
||||||
Database->NextHandleDatabase = NULL;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Copy the Ifr package data into package instance.
|
|
||||||
//
|
|
||||||
if (IfrSize > 0) {
|
|
||||||
CopyMem (&PackageInstance->IfrData, IfrPack, IfrSize);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Main loop to store package data into HII database.
|
|
||||||
//
|
|
||||||
StringSize = 0;
|
|
||||||
TotalStringSize = 0;
|
|
||||||
|
|
||||||
for (Index = 0; Index < Packages->NumberOfPackages; Index++) {
|
|
||||||
|
|
||||||
PackageHeader = *(EFI_HII_PACK_HEADER **) (((UINT8 *) Packages) + sizeof (EFI_HII_PACKAGES) + Index * sizeof (VOID *));
|
|
||||||
|
|
||||||
switch (PackageHeader->Type) {
|
|
||||||
case EFI_HII_STRING:
|
|
||||||
StringPack = (EFI_HII_STRING_PACK *) PackageHeader;
|
|
||||||
//
|
|
||||||
// The size which GetPackSize() returns include the null terminator. So if multiple
|
|
||||||
// string packages are passed in, merge all these packages, and only pad one null terminator.
|
|
||||||
//
|
|
||||||
if (TotalStringSize > 0) {
|
|
||||||
TotalStringSize -= sizeof (EFI_HII_STRING_PACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
GetPackSize ((VOID *) StringPack, &StringSize, &NumberOfTokens);
|
|
||||||
CopyMem ((CHAR8 *) (&PackageInstance->IfrData) + IfrSize + TotalStringSize, StringPack, StringSize);
|
|
||||||
|
|
||||||
TotalStringSize += StringSize;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EFI_HII_HANDLES:
|
|
||||||
CopyMem (&PackageInstance->HandlePack, PackageHeader, sizeof (EFI_HII_HANDLE_PACK));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EFI_HII_FONT:
|
|
||||||
FontPack = (EFI_HII_FONT_PACK *) PackageHeader;
|
|
||||||
//
|
|
||||||
// Add whatever narrow glyphs were passed to us if undefined
|
|
||||||
//
|
|
||||||
CopyMem (&NumNarrowGlyphs, &FontPack->NumberOfNarrowGlyphs, sizeof (UINT16));
|
|
||||||
for (Count = 0; Count <= NumNarrowGlyphs; Count++) {
|
|
||||||
Local = (UINT8 *) (&FontPack->NumberOfWideGlyphs + sizeof (UINT8)) + (sizeof (EFI_NARROW_GLYPH)) * Count;
|
|
||||||
NarrowGlyph = (EFI_NARROW_GLYPH *) Local;
|
|
||||||
CopyMem (&Member, &NarrowGlyph->UnicodeWeight, sizeof (UINT16));
|
|
||||||
//
|
|
||||||
// If the glyph is already defined, do not overwrite it. It is what it is.
|
|
||||||
//
|
|
||||||
CopyMem (&Unicode, &GlobalData->NarrowGlyphs[Member].UnicodeWeight, sizeof (UINT16));
|
|
||||||
if (Unicode == 0) {
|
|
||||||
CopyMem (&GlobalData->NarrowGlyphs[Member], Local, sizeof (EFI_NARROW_GLYPH));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Add whatever wide glyphs were passed to us if undefined
|
|
||||||
//
|
|
||||||
CopyMem (&NumWideGlyphs, &FontPack->NumberOfWideGlyphs, sizeof (UINT16));
|
|
||||||
for (Count = 0; Count <= NumWideGlyphs; Count++) {
|
|
||||||
Local = (UINT8 *) (&FontPack->NumberOfWideGlyphs + sizeof (UINT8)) +
|
|
||||||
(sizeof (EFI_NARROW_GLYPH)) *
|
|
||||||
NumNarrowGlyphs;
|
|
||||||
CopyMem (
|
|
||||||
&Member,
|
|
||||||
(UINTN *) (Local + sizeof (EFI_WIDE_GLYPH) * Count),
|
|
||||||
sizeof (UINT16)
|
|
||||||
);
|
|
||||||
//
|
|
||||||
// If the glyph is already defined, do not overwrite it. It is what it is.
|
|
||||||
//
|
|
||||||
CopyMem (&Unicode, &GlobalData->WideGlyphs[Member].UnicodeWeight, sizeof (UINT16));
|
|
||||||
if (Unicode == 0) {
|
|
||||||
Local = (UINT8*)(&FontPack->NumberOfWideGlyphs + sizeof(UINT8)) + (sizeof(EFI_NARROW_GLYPH)) * NumNarrowGlyphs;
|
|
||||||
CopyMem (
|
|
||||||
&GlobalData->WideGlyphs[Member],
|
|
||||||
(UINTN *) (Local + sizeof (EFI_WIDE_GLYPH) * Count),
|
|
||||||
sizeof (EFI_WIDE_GLYPH)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EFI_HII_KEYBOARD:
|
|
||||||
KeyboardPack = (EFI_HII_KEYBOARD_PACK *) PackageHeader;
|
|
||||||
//
|
|
||||||
// Sending me a Keyboard Package
|
|
||||||
//
|
|
||||||
if (KeyboardPack->DescriptorCount > 105) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If someone updates the Descriptors with a count of 0, blow aware the overrides.
|
|
||||||
//
|
|
||||||
if (KeyboardPack->DescriptorCount == 0) {
|
|
||||||
ZeroMem (GlobalData->OverrideKeyboardLayout, sizeof (FRAMEWORK_EFI_KEY_DESCRIPTOR) * 106);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (KeyboardPack->DescriptorCount < 106 && KeyboardPack->DescriptorCount > 0) {
|
|
||||||
//
|
|
||||||
// If SystemKeyboard was updated already, then steer changes to the override database
|
|
||||||
//
|
|
||||||
if (GlobalData->SystemKeyboardUpdate) {
|
|
||||||
ZeroMem (GlobalData->OverrideKeyboardLayout, sizeof (FRAMEWORK_EFI_KEY_DESCRIPTOR) * 106);
|
|
||||||
for (Count = 0; Count < KeyboardPack->DescriptorCount; Count++) {
|
|
||||||
CopyMem (&Member, &KeyboardPack->Descriptor[Count].Key, sizeof (UINT16));
|
|
||||||
CopyMem (
|
|
||||||
&GlobalData->OverrideKeyboardLayout[Member],
|
|
||||||
&KeyboardPack->Descriptor[Count],
|
|
||||||
sizeof (FRAMEWORK_EFI_KEY_DESCRIPTOR)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// SystemKeyboard was never updated, so this is likely the keyboard driver setting the System database.
|
|
||||||
//
|
|
||||||
ZeroMem (GlobalData->SystemKeyboardLayout, sizeof (FRAMEWORK_EFI_KEY_DESCRIPTOR) * 106);
|
|
||||||
for (Count = 0; Count < KeyboardPack->DescriptorCount; Count++) {
|
|
||||||
CopyMem (&Member, &KeyboardPack->Descriptor->Key, sizeof (UINT16));
|
|
||||||
CopyMem (
|
|
||||||
&GlobalData->SystemKeyboardLayout[Member],
|
|
||||||
&KeyboardPack->Descriptor[Count],
|
|
||||||
sizeof (FRAMEWORK_EFI_KEY_DESCRIPTOR)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Just updated the system keyboard database, reflect that in the global flag.
|
|
||||||
//
|
|
||||||
GlobalData->SystemKeyboardUpdate = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
HiiRemovePack (
|
|
||||||
IN EFI_HII_PROTOCOL *This,
|
|
||||||
IN FRAMEWORK_EFI_HII_HANDLE Handle
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Removes the various packs from a Handle
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_HII_PACKAGE_INSTANCE *PackageInstance;
|
|
||||||
EFI_HII_DATA *HiiData;
|
|
||||||
EFI_HII_HANDLE_DATABASE *HandleDatabase;
|
|
||||||
EFI_HII_HANDLE_DATABASE *PreviousHandleDatabase;
|
|
||||||
|
|
||||||
if (This == NULL || Handle == 0) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
HiiData = EFI_HII_DATA_FROM_THIS (This);
|
|
||||||
|
|
||||||
HandleDatabase = HiiData->DatabaseHead;
|
|
||||||
PackageInstance = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize the Previous with the Head of the Database
|
|
||||||
//
|
|
||||||
PreviousHandleDatabase = HandleDatabase;
|
|
||||||
|
|
||||||
for (; HandleDatabase != NULL; HandleDatabase = HandleDatabase->NextHandleDatabase) {
|
|
||||||
//
|
|
||||||
// Match the numeric value with the database entry - if matched,
|
|
||||||
// free the package instance and apply fix-up to database linked list
|
|
||||||
//
|
|
||||||
if (Handle == HandleDatabase->Handle) {
|
|
||||||
PackageInstance = HandleDatabase->Buffer;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Free the Package Instance
|
|
||||||
//
|
|
||||||
FreePool (PackageInstance);
|
|
||||||
|
|
||||||
//
|
|
||||||
// If this was the only Handle in the database
|
|
||||||
//
|
|
||||||
if (HiiData->DatabaseHead == HandleDatabase) {
|
|
||||||
HiiData->DatabaseHead = NULL;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Make the parent->Next point to the current->Next
|
|
||||||
//
|
|
||||||
PreviousHandleDatabase->NextHandleDatabase = HandleDatabase->NextHandleDatabase;
|
|
||||||
FreePool (HandleDatabase);
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If this was not the HandleDatabase entry we were looking for, cache it just in case the next one is
|
|
||||||
//
|
|
||||||
PreviousHandleDatabase = HandleDatabase;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// No handle was found - error condition
|
|
||||||
//
|
|
||||||
if (PackageInstance == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue