1) Add in IfrParser so that the FrameworkHii->GetDefaultImage can scan UEFI IFR opcodes and get the default value embedded in the IFR.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5119 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12
2008-04-24 07:08:46 +00:00
parent c7ec71b4ed
commit 59336178ac
20 changed files with 5774 additions and 63 deletions

View File

@@ -0,0 +1,78 @@
#include <PiDxe.h>
#include <Library/DebugLib.h>
#include <Library/HiiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
CHAR16 *gEmptyString = L" ";
/**
Get the string based on the StringId and HII Package List Handle.
@param Token The String's ID.
@param HiiHandle The package list in the HII database to search for
the specified string.
@return The output string.
**/
CHAR16 *
GetToken (
IN EFI_STRING_ID Token,
IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
CHAR16 *String;
UINTN BufferLength;
//
// Set default string size assumption at no more than 256 bytes
//
BufferLength = 0x100;
String = AllocateZeroPool (BufferLength);
ASSERT (String != NULL);
Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
if (Status == EFI_BUFFER_TOO_SMALL) {
gBS->FreePool (String);
String = AllocateZeroPool (BufferLength);
ASSERT (String != NULL);
Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
}
ASSERT_EFI_ERROR (Status);
return String;
}
/**
Create a new string in HII Package List.
@param String The String to be added
@param HiiHandle The package list in the HII database to insert the
specified string.
@return The output string.
**/
EFI_STRING_ID
NewString (
IN CHAR16 *String,
IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STRING_ID StringId;
EFI_STATUS Status;
StringId = 0;
Status = HiiLibNewString (HiiHandle, &StringId, String);
ASSERT_EFI_ERROR (Status);
return StringId;
}