BaseTools: Introduce new HII section design

This commit is contained in:
Mikhail Krichanov 2023-06-26 11:32:29 +03:00
parent c57cc69793
commit 047d1b2f88
20 changed files with 144 additions and 403 deletions

View File

@ -378,45 +378,6 @@
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
[Dynamic-Library-File.UEFI_HII]
<InputFile>
?.dll
<OutputFile>
$(OUTPUT_DIR)(+)$(MODULE_NAME).efi
$(DEBUG_DIR)(+)$(MODULE_NAME).efi
$(OUTPUT_DIR)(+)$(MODULE_NAME).map
<ExtraDependency>
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
<Command.MSFT, Command.INTEL, Command.CLANGPDB>
ImageTool GenImage -c PE -t $(MODULE_TYPE) -h $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -o ${dst} ${src}
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
-$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR)
<Command.GCC, Command.CLANGGCC>
$(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
$(OBJCOPY) $(OBJCOPY_STRIPFLAG) $(DEBUG_DIR)(+)$(MODULE_NAME).strip
ImageTool GenImage -c PE -t $(MODULE_TYPE) -h $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
<Command.XCODE>
# tool to convert Mach-O to PE/COFF
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
# create symbol file for GDB debug
-$(DSYMUTIL) ${src}
ImageTool GenImage -c PE -t $(MODULE_TYPE) -h $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
[Dependency-Expression-File]
<InputFile>
?.dxs, ?.Dxs, ?.DXS
@ -642,7 +603,7 @@
*.hpk
<OutputFile>
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.c
<Command>
ImageTool HiiBin $(MODULE_GUID) -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc $(HII_BINARY_PACKAGES)
ImageTool HiiSrc $(MODULE_GUID) -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.c $(HII_BINARY_PACKAGES)

View File

@ -25,6 +25,19 @@
IDENTIFIER = Default TOOL_CHAIN_CONF
#
# FIXME: For GCC, the linker script must be utilized to merge image sections.
# Currently, there is no easy way to perform conditional merges due to the lack
# of conditions or preprocessing.
#
!ifdef $(EDK2_SEPARATE_HII)
DEFINE MSFT_HII =
DEFINE XCODE_HII =
!else
DEFINE MSFT_HII = /MERGE:.hii=.rdata
DEFINE XCODE_HII = -rename_section __HII __hii __DATA_CONST __hii
!endif
!ifdef $(EDK2_MERGE_RODATA_INTO_TEXT)
DEFINE DLINK_SCRIPT = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/Merge.lds
DEFINE MSFT_MERGE = /MERGE:.rdata=.text
@ -120,7 +133,7 @@ DEFINE MSFT_DEPS_FLAGS = /showIncludes
DEFINE MSFT_ASLPP_FLAGS = /nologo /E /C /FIAutoGen.h
DEFINE MSFT_ASLCC_FLAGS = /nologo /c /FIAutoGen.h /TC /Dmain=ReferenceAcpiTable
DEFINE MSFT_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:CONSOLE
DEFINE MSFT_DLINK_COMMON = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER DEF(MSFT_ALIGN) DEF(MSFT_MERGE)
DEFINE MSFT_DLINK_COMMON = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER DEF(MSFT_ALIGN) DEF(MSFT_HII) DEF(MSFT_MERGE)
DEFINE DTCPP_BIN = ENV(DTCPP_PREFIX)cpp
DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
@ -1741,7 +1754,7 @@ RELEASE_CLANGDWARF_RISCV64_DLINK_FLAGS = DEF(CLANGDWARF_RISCV64_DLINK_FLAGS) -fl
# image. This also makes the usage of "-read_only_relocs suppress" safe, as
# relocations can now target __TEXT without triggering the same issue.
#
DEFINE XCODE5_RORELOCS_ARGS = -segprot __RO_RELOCS rw- rw- -segment_order __RO_RELOCS:__TEXT:__DATA_CONST:__DATA -rename_section __TEXT __text __RO_RELOCS __text -rename_section __RO_RELOCS __text __TEXT __text
DEFINE XCODE5_RORELOCS_ARGS = -segprot __RO_RELOCS rw- rw- -segment_order __RO_RELOCS:__TEXT:__DATA_CONST:__DATA:__HII -rename_section __TEXT __text __RO_RELOCS __text -rename_section __RO_RELOCS __text __TEXT __text
DEFINE XCODE5_RODATA_ARGS = DEF(XCODE5_RORELOCS_ARGS) -segprot __DATA_CONST r-- r-- -rename_section __DATA __const __DATA_CONST __const -rename_section __TEXT __const __DATA_CONST __text_const -rename_section __TEXT __cstring __DATA_CONST __cstring -rename_section __TEXT __ustring __DATA_CONST __ustring
##################
@ -1764,9 +1777,9 @@ RELEASE_XCODE5_*_MTOC_FLAGS = -align DEF(XCODE_ALIGN) -require_read_only_relocs
####################
# IA-32 definitions
####################
DEBUG_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
NOOPT_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
RELEASE_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
DEBUG_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_HII) DEF(XCODE_MERGE)
NOOPT_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_HII) DEF(XCODE_MERGE)
RELEASE_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_HII) DEF(XCODE_MERGE)
*_XCODE5_IA32_SLINK_FLAGS = -static -o
DEBUG_XCODE5_IA32_ASM_FLAGS = -arch i386 -g
@ -1782,9 +1795,9 @@ RELEASE_XCODE5_IA32_CC_FLAGS = -arch i386 -c -Os -Wall -Werror -inclu
##################
# X64 definitions
##################
DEBUG_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
NOOPT_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
RELEASE_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
DEBUG_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_HII) DEF(XCODE_MERGE)
NOOPT_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_HII) DEF(XCODE_MERGE)
RELEASE_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_HII) DEF(XCODE_MERGE)
*_XCODE5_X64_SLINK_FLAGS = -static -o
DEBUG_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g

View File

@ -16,9 +16,14 @@
#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x0
#define DO_NOT_EDIT_HEADER \
"//\n" \
"// DO NOT EDIT -- auto-generated file\n" \
"//\n"
static
RETURN_STATUS
HiiBin (
HiiSrc (
IN const char *HiiName,
IN const char *Guid,
IN const char *FileNames[],
@ -29,6 +34,8 @@ HiiBin (
void *Hii;
UINT32 HiiSize;
GUID HiiGuid;
FILE *FilePtr;
UINT32 Index;
assert (FileNames != NULL);
assert (HiiName != NULL);
@ -42,11 +49,69 @@ HiiBin (
Status = ConstructHii (FileNames, NumOfFiles, &HiiGuid, &Hii, &HiiSize);
if (RETURN_ERROR (Status)) {
fprintf (stderr, "ImageTool: Could not construct HiiBin\n");
fprintf (stderr, "ImageTool: Could not construct HiiSrc\n");
return Status;
}
UserWriteFile (HiiName, Hii, HiiSize);
FilePtr = fopen (HiiName, "w");
if (FilePtr == NULL) {
free (Hii);
return RETURN_NO_MEDIA;
}
fprintf (
FilePtr,
DO_NOT_EDIT_HEADER
"\n"
"#include \"AutoGen.h\"\n"
"\n"
"typedef struct {\n"
" UINT32 Size;\n"
" UINT8 Data[%u];\n"
"} MODULE_HII_PACKAGE_LIST_%u;\n"
"\n"
"STATIC_ASSERT (\n"
" OFFSET_OF (MODULE_HII_PACKAGE_LIST_%u, Size) == OFFSET_OF (MODULE_HII_PACKAGE_LIST, Size) &&\n"
" OFFSET_OF (MODULE_HII_PACKAGE_LIST_%u, Data) == OFFSET_OF (MODULE_HII_PACKAGE_LIST, Header) &&\n"
" sizeof (MODULE_HII_PACKAGE_LIST) == sizeof (UINT32) + sizeof (EFI_HII_PACKAGE_LIST_HEADER),\n"
" \"MODULE_HII_PACKAGE_LIST does not have the expected structure.\"\n"
" );\n"
"\n"
"#if defined (__APPLE__)\n"
"__attribute__ ((section (\"__HII,__hii\")))\n"
"#elif defined (__GNUC__) || defined (__clang__)\n"
"__attribute__ ((section (\".hii\")))\n"
"#elif defined (_MSC_EXTENSIONS)\n"
"#pragma section (\".hii\", read)\n"
"__declspec (allocate(\".hii\"))\n"
"#endif\n"
"STATIC CONST MODULE_HII_PACKAGE_LIST_%u mModuleHiiPackageList = {\n"
" %u,\n"
" {",
HiiSize,
HiiSize,
HiiSize,
HiiSize,
HiiSize,
HiiSize
);
for (Index = 0; Index < HiiSize; ++Index) {
if (Index % 12 == 0) {
fprintf (FilePtr, "\n ");
}
fprintf (FilePtr, " 0x%02X,", ((const uint8_t *)Hii)[Index]);
}
fprintf (
FilePtr,
"\n"
" }\n"
"};\n"
"\n"
"GLOBAL_REMOVE_IF_UNREFERENCED CONST MODULE_HII_PACKAGE_LIST *gModuleHiiPackageList =\n"
" (CONST MODULE_HII_PACKAGE_LIST *)&mModuleHiiPackageList;\n"
);
free (Hii);
@ -290,7 +355,6 @@ GenExecutable (
IN const char *InputFileName,
IN const char *FormatName,
IN const char *TypeName,
IN const char *HiiFileName,
IN const char *BaseAddress,
IN bool Strip,
IN bool FixedAddress
@ -300,8 +364,6 @@ GenExecutable (
VOID *InputFile;
int8_t Format;
int32_t Type;
UINT32 HiiFileSize;
VOID *HiiFile;
RETURN_STATUS Status;
UINT64 NewBaseAddress;
void *OutputFile;
@ -340,24 +402,12 @@ GenExecutable (
return RETURN_ABORTED;
}
HiiFile = NULL;
HiiFileSize = 0;
if (HiiFileName != NULL) {
HiiFile = UserReadFile (HiiFileName, &HiiFileSize);
if (HiiFile == NULL) {
fprintf (stderr, "ImageTool: Could not open %s: %s\n", HiiFileName, strerror (errno));
return RETURN_ABORTED;
}
}
OutputFile = ToolImageEmit (
&OutputFileSize,
InputFile,
InputFileSize,
Format,
Type,
HiiFile,
HiiFileSize,
BaseAddress != NULL,
NewBaseAddress,
InputFileName,
@ -366,7 +416,6 @@ GenExecutable (
);
if (OutputFile == NULL) {
free (HiiFile);
return RETURN_ABORTED;
}
@ -385,7 +434,6 @@ int main (int argc, const char *argv[])
const char *InputName;
const char *FormatName;
const char *TypeName;
const char *HiiFileName;
const char *BaseAddress;
bool Strip;
bool FixedAddress;
@ -404,7 +452,7 @@ int main (int argc, const char *argv[])
if (strcmp (argv[1], "GenImage") == 0) {
if (argc < 5) {
fprintf (stderr, "ImageTool: Command arguments are missing\n");
fprintf (stderr, " Usage: ImageTool GenImage [-c Format] [-t ModuleType] [-h HiiRc] [-b BaseAddress] [-s] [-f] -o OutputFile InputFile\n");
fprintf (stderr, " Usage: ImageTool GenImage [-c Format] [-t ModuleType] [-b BaseAddress] [-s] [-f] -o OutputFile InputFile\n");
raise ();
return -1;
}
@ -413,7 +461,6 @@ int main (int argc, const char *argv[])
InputName = NULL;
FormatName = NULL;
TypeName = NULL;
HiiFileName = NULL;
BaseAddress = NULL;
Strip = false;
FixedAddress = false;
@ -442,14 +489,6 @@ int main (int argc, const char *argv[])
}
TypeName = argv[ArgIndex];
} else if (strcmp (argv[ArgIndex], "-h") == 0) {
++ArgIndex;
if (ArgIndex == argc) {
fprintf (stderr, "Must specify an argument to -h\n");
return -1;
}
HiiFileName = argv[ArgIndex];
} else if (strcmp (argv[ArgIndex], "-b") == 0) {
++ArgIndex;
if (ArgIndex == argc) {
@ -487,7 +526,6 @@ int main (int argc, const char *argv[])
InputName,
FormatName,
TypeName,
HiiFileName,
BaseAddress,
Strip,
FixedAddress
@ -496,7 +534,7 @@ int main (int argc, const char *argv[])
raise ();
return -1;
}
} else if (strcmp (argv[1], "HiiBin") == 0) {
} else if (strcmp (argv[1], "HiiSrc") == 0) {
if (argc < 5 || strcmp (argv[3], "-o") != 0) {
fprintf (stderr, "ImageTool: Command arguments are missing\n");
fprintf (stderr, " Usage: ImageTool HiiBin GUID -o OutputFile InputFile1 InputFile2 ...\n");
@ -506,7 +544,7 @@ int main (int argc, const char *argv[])
NumOfFiles = (UINT32)argc - 5U;
Status = HiiBin (argv[4], argv[2], &argv[5], NumOfFiles);
Status = HiiSrc (argv[4], argv[2], &argv[5], NumOfFiles);
if (RETURN_ERROR (Status)) {
raise ();
return -1;

View File

@ -91,8 +91,6 @@ ToolImageEmit (
IN uint32_t BufferSize,
IN int8_t Format,
IN int32_t Type,
IN void *HiiFile,
IN uint32_t HiiFileSize,
IN bool Relocate,
IN uint64_t BaseAddress,
IN const char *SymbolsPath OPTIONAL,
@ -136,13 +134,6 @@ ToolImageEmit (
ImageInfo.HeaderInfo.Subsystem = (uint16_t)Type;
}
if (HiiFile != NULL) {
free (ImageInfo.HiiInfo.Data);
ImageInfo.HiiInfo.Data = HiiFile;
ImageInfo.HiiInfo.DataSize = HiiFileSize;
}
ToolImageSortRelocs (&ImageInfo);
Success = CheckToolImage (&ImageInfo);

View File

@ -17,8 +17,6 @@ ToolImageEmit (
IN uint32_t BufferSize,
IN int8_t Format,
IN int32_t Type,
IN void *HiiFile,
IN uint32_t HiiFileSize,
IN bool Relocate,
IN uint64_t BaseAddress,
IN const char *SymbolsPath OPTIONAL,

View File

@ -20,7 +20,7 @@ SECTIONS {
}
.rodata : ALIGN(CONSTANT(MAXPAGESIZE)) {
*(.rodata .rodata.* .data.rel.ro .data.rel.ro.* .gnu.linkonce.r.*)
*(.rodata .rodata.* .data.rel.ro .data.rel.ro.* .gnu.linkonce.r.* .hii)
*(.got .got.*)
/*
@ -39,10 +39,6 @@ SECTIONS {
*(.bss .bss.*)
}
.hii : ALIGN(CONSTANT(MAXPAGESIZE)) {
KEEP (*(.hii))
}
.eh_frame : ALIGN(CONSTANT(MAXPAGESIZE)) {
KEEP (*(.eh_frame))
}

View File

@ -17,7 +17,7 @@ SECTIONS {
.text : ALIGN(CONSTANT(MAXPAGESIZE)) {
*(.text .text.* .stub .gnu.linkonce.t.*)
*(.rodata .rodata.* .data.rel.ro .data.rel.ro.* .gnu.linkonce.r.*)
*(.rodata .rodata.* .data.rel.ro .data.rel.ro.* .gnu.linkonce.r.* .hii)
*(.got .got.*)
/*
@ -36,10 +36,6 @@ SECTIONS {
*(.bss .bss.*)
}
.hii : ALIGN(CONSTANT(MAXPAGESIZE)) {
KEEP (*(.hii))
}
.eh_frame : ALIGN(CONSTANT(MAXPAGESIZE)) {
KEEP (*(.eh_frame))
}

View File

@ -3723,8 +3723,6 @@ Returns:
UefiImageFileSize,
ImageFormat,
-1,
NULL,
0,
true,
NewBaseAddress,
NULL,

View File

@ -1453,8 +1453,6 @@ Returns:
FileBufferSize,
-1,
-1,
NULL,
0,
true,
NewBaseAddress,
NULL,

View File

@ -1991,6 +1991,14 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH):
AutoGenH.Append('\nextern GUID gEdkiiDscPlatformGuid;')
AutoGenH.Append('\nextern CHAR8 *gEfiCallerBaseName;\n\n')
if Info.BuildType == 'UEFI_HII':
AutoGenH.Append('typedef struct {\n')
AutoGenH.Append(' UINT32 Size;\n')
AutoGenH.Append(' EFI_HII_PACKAGE_LIST_HEADER Header;\n')
AutoGenH.Append('} MODULE_HII_PACKAGE_LIST;\n')
AutoGenH.Append('\nextern CONST MODULE_HII_PACKAGE_LIST *gModuleHiiPackageList;\n\n')
if Info.IsLibrary:
return

View File

@ -789,7 +789,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
if not os.path.exists(FileBeforeStrip) or \
(os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):
CopyLongFilePath(File, FileBeforeStrip)
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stripped')
GenFdsGlobalVariable.GenerateFirmwareImage(
StrippedFile,
File,
@ -823,7 +823,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
(os.path.getmtime(GenSecInputFile) > os.path.getmtime(FileBeforeStrip)):
CopyLongFilePath(GenSecInputFile, FileBeforeStrip)
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stripped')
GenFdsGlobalVariable.GenerateFirmwareImage(
StrippedFile,
GenSecInputFile,

View File

@ -99,10 +99,9 @@ InitializeLogo (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
EFI_HANDLE Handle;
EFI_STATUS Status;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
EFI_HANDLE Handle;
Status = gBS->LocateProtocol (
&gEfiHiiDatabaseProtocolGuid,
@ -118,28 +117,12 @@ InitializeLogo (
);
ASSERT_EFI_ERROR (Status);
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "HII Image Package with logo not found in PE/COFF resource section\n"));
return Status;
}
//
// Publish HII package list to HII Database.
//
Status = HiiDatabase->NewPackageList (
HiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
NULL,
&mHiiHandle
);

View File

@ -67,23 +67,7 @@ HiiResourcesSampleInit (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
EFI_STATUS Status;
//
// Publish sample Fromset
@ -103,7 +87,7 @@ HiiResourcesSampleInit (
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
mDriverHandle,
&mHiiHandle
);

View File

@ -606,34 +606,18 @@ VlanConfigMain (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
LIST_ENTRY *List;
CONST CHAR16 *Str;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_STATUS Status;
LIST_ENTRY *List;
CONST CHAR16 *Str;
EFI_STATUS Status;
mImageHandle = ImageHandle;
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
NULL,
&mHiiHandle
);

View File

@ -441,32 +441,15 @@ InitializeHiiPackage (
EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
//
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
NULL,
&HiiHandle
);

View File

@ -678,30 +678,14 @@ UefiMain (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
//
// Retrieve the HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
EFI_STATUS Status;
//
// Publish the HII package list to the HII Database
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
NULL,
&mPrmInfoHiiHandle
);

View File

@ -560,19 +560,14 @@ ProcessManFile (
OUT CHAR16 **HelpText
)
{
CHAR16 *TempString;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE CmdFileImgHandle;
EFI_STATUS Status;
UINTN HelpSize;
UINTN BriefSize;
UINTN StringIdWalker;
BOOLEAN Ascii;
CHAR16 *CmdFileName;
CHAR16 *CmdFilePathName;
EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
CHAR16 *TempString;
SHELL_FILE_HANDLE FileHandle;
EFI_STATUS Status;
UINTN HelpSize;
UINTN BriefSize;
BOOLEAN Ascii;
EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
EFI_DEVICE_PATH_PROTOCOL *DevPath;
if ( (ManFileName == NULL)
|| (Command == NULL)
@ -582,17 +577,12 @@ ProcessManFile (
return (EFI_INVALID_PARAMETER);
}
HelpSize = 0;
BriefSize = 0;
StringIdWalker = 0;
TempString = NULL;
Ascii = FALSE;
CmdFileName = NULL;
CmdFilePathName = NULL;
CmdFileImgHandle = NULL;
PackageListHeader = NULL;
FileDevPath = NULL;
DevPath = NULL;
HelpSize = 0;
BriefSize = 0;
TempString = NULL;
Ascii = FALSE;
FileDevPath = NULL;
DevPath = NULL;
//
// See if it's in HII first
@ -646,113 +636,6 @@ ProcessManFile (
goto Done;
}
}
//
// Load the app image to check EFI_HII_PACKAGE_LIST_PROTOCOL.
//
CmdFileName = GetExecuatableFileName (TempString);
if (CmdFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
//
// If the file in CWD then use the file name, else use the full
// path name.
//
CmdFilePathName = ShellFindFilePath (CmdFileName);
if (CmdFilePathName == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath (CmdFilePathName);
Status = gBS->LoadImage (FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle);
if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
// with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
// If the caller doesn't have the option to defer the execution of an image, we should
// unload image for the EFI_SECURITY_VIOLATION to avoid the resource leak.
//
if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (CmdFileImgHandle);
}
*HelpText = NULL;
goto Done;
}
Status = gBS->OpenProtocol (
CmdFileImgHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageListHeader,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
*HelpText = NULL;
goto Done;
}
//
// If get package list on image handle, install it on HiiDatabase.
//
Status = gBS->InstallProtocolInterface (
&mShellManDriverHandle,
&gEfiDevicePathProtocolGuid,
EFI_NATIVE_INTERFACE,
&mShellManHiiDevicePath
);
if (EFI_ERROR (Status)) {
goto Done;
}
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageListHeader,
mShellManDriverHandle,
&mShellManHiiHandle
);
if (EFI_ERROR (Status)) {
goto Done;
}
StringIdWalker = 1;
do {
SHELL_FREE_NON_NULL (TempString);
if (BriefDesc != NULL) {
SHELL_FREE_NON_NULL (*BriefDesc);
}
TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL);
if (TempString == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
HelpSize = StrLen (TempString) * sizeof (CHAR16);
ShellWriteFile (FileHandle, &HelpSize, TempString);
ShellSetFilePosition (FileHandle, 0);
HelpSize = 0;
BriefSize = 0;
Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
if (!EFI_ERROR (Status) && (HelpText != NULL)) {
Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
}
ShellCloseFile (&FileHandle);
if (!EFI_ERROR (Status)) {
//
// Found what we need and return
//
goto Done;
}
StringIdWalker += 1;
} while (StringIdWalker < 0xFFFF && TempString != NULL);
}
Done:
@ -770,13 +653,7 @@ Done:
mShellManHiiHandle = NULL;
}
if (CmdFileImgHandle != NULL) {
Status = gBS->UnloadImage (CmdFileImgHandle);
}
SHELL_FREE_NON_NULL (TempString);
SHELL_FREE_NON_NULL (CmdFileName);
SHELL_FREE_NON_NULL (CmdFilePathName);
SHELL_FREE_NON_NULL (FileDevPath);
SHELL_FREE_NON_NULL (DevPath);

View File

@ -993,32 +993,15 @@ InitializeHiiPackage (
EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
//
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
NULL,
&HiiHandle
);

View File

@ -1866,32 +1866,15 @@ InitializeHiiPackage (
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle.
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
//
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
NULL,
&HiiHandle
);

View File

@ -1210,32 +1210,15 @@ InitializeHiiPackage (
EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
//
// Publish HII package list to HII Database.
//
Status = gHiiDatabase->NewPackageList (
gHiiDatabase,
PackageList,
&gModuleHiiPackageList->Header,
NULL,
&HiiHandle
);