Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
208
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
Normal file
208
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
Normal file
@@ -0,0 +1,208 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
FindFiles.c
|
||||
|
||||
Abstract:
|
||||
|
||||
OS-specific functions to assist in finding files in
|
||||
subdirectories.
|
||||
|
||||
--*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
//
|
||||
// #include <io.h> // for _chmod()
|
||||
//
|
||||
#include <sys/stat.h>
|
||||
//
|
||||
// #include <errno.h> // for errno
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "HiiPack.h"
|
||||
|
||||
extern
|
||||
void
|
||||
Error (
|
||||
char *Name,
|
||||
UINT32 LineNumber,
|
||||
UINT32 MessageCode,
|
||||
char *Text,
|
||||
char *MsgFmt,
|
||||
...
|
||||
);
|
||||
|
||||
static
|
||||
int
|
||||
ProcessDirectory (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
);
|
||||
|
||||
/*****************************************************************************/
|
||||
int
|
||||
FindFiles (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Find files of a given name under a root directory
|
||||
|
||||
Arguments:
|
||||
RootDirectory - base directory -- look in this directory and
|
||||
all its subdirectories for files matching FileMask.
|
||||
FileMask - file mask of files to find
|
||||
Callback - function to call for each file found
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
char FullPath[MAX_PATH];
|
||||
//
|
||||
// If RootDirectory is relative, then append to cwd.
|
||||
//
|
||||
if (isalpha (RootDirectory[0]) && (RootDirectory[1] == ':')) {
|
||||
strcpy (FullPath, RootDirectory);
|
||||
} else {
|
||||
//
|
||||
// Get current working directory
|
||||
//
|
||||
if (_getcwd (FullPath, sizeof (FullPath)) == NULL) {
|
||||
Error (NULL, 0, 0, "failed to get current working directory", NULL);
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
// Append the relative path they passed in
|
||||
//
|
||||
if (FullPath[strlen (FullPath) - 1] != '\\') {
|
||||
strcat (FullPath, "\\");
|
||||
}
|
||||
|
||||
strcat (FullPath, RootDirectory);
|
||||
}
|
||||
|
||||
if (FullPath[strlen (FullPath) - 1] == '\\') {
|
||||
FullPath[strlen (FullPath) - 1] = 0;
|
||||
}
|
||||
//
|
||||
// Process the directory
|
||||
//
|
||||
return ProcessDirectory (FullPath, FileMask, Callback);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
ProcessDirectory (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Process a directory to find all files matching a given file mask
|
||||
|
||||
Arguments:
|
||||
RootDirectory - base directory -- look in this directory and
|
||||
all its subdirectories for files matching FileMask.
|
||||
FileMask - file mask of files to find
|
||||
Callback - function to call for each file found
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
HANDLE Handle;
|
||||
WIN32_FIND_DATA FindData;
|
||||
char TempName[MAX_PATH];
|
||||
|
||||
Handle = INVALID_HANDLE_VALUE;
|
||||
//
|
||||
// Concatenate the filemask to the directory to create the full
|
||||
// path\mask path name.
|
||||
//
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\");
|
||||
strcat (TempName, FileMask);
|
||||
memset (&FindData, 0, sizeof (FindData));
|
||||
Handle = FindFirstFile (TempName, &FindData);
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\");
|
||||
strcat (TempName, FindData.cFileName);
|
||||
if (Callback (TempName) != 0) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
} while (FindNextFile (Handle, &FindData));
|
||||
}
|
||||
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
FindClose (Handle);
|
||||
Handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//
|
||||
// Now create a *.* file mask to get all subdirectories and recursive call this
|
||||
// function to handle each one found.
|
||||
//
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\*.*");
|
||||
memset (&FindData, 0, sizeof (FindData));
|
||||
Handle = FindFirstFile (TempName, &FindData);
|
||||
//
|
||||
// Loop until no more files/directories
|
||||
//
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
//
|
||||
// Make sure it's not "." or ".."
|
||||
//
|
||||
if ((strcmp (FindData.cFileName, ".") != 0) && (strcmp (FindData.cFileName, "..") != 0)) {
|
||||
//
|
||||
// Found a valid directory. Put it all together and make a recursive call
|
||||
// to process it.
|
||||
//
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\");
|
||||
strcat (TempName, FindData.cFileName);
|
||||
if (ProcessDirectory (TempName, FileMask, Callback) != 0) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (FindNextFile (Handle, &FindData));
|
||||
}
|
||||
|
||||
Done:
|
||||
//
|
||||
// Free the handle
|
||||
//
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
FindClose (Handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
2561
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
Normal file
2561
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
Normal file
File diff suppressed because it is too large
Load Diff
63
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
Normal file
63
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
HiiPack.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Common defines and prototypes for the HII pack tool.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _HII_PACK_H_
|
||||
#define _HII_PACK_H_
|
||||
|
||||
#define DEFAULT_VARIABLE_NAME_L L"Setup"
|
||||
#define DEFAULT_VARIABLE_NAME "Setup"
|
||||
|
||||
#define MAX_VARIABLE_NAME 256
|
||||
#define FIRST_HII_PACK_HANDLE 1
|
||||
|
||||
typedef
|
||||
int
|
||||
(*FIND_FILE_CALLBACK) (
|
||||
char *FileName
|
||||
);
|
||||
|
||||
extern
|
||||
int
|
||||
FindFiles (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
RootDirectory - GC_TODO: add argument description
|
||||
FileMask - GC_TODO: add argument description
|
||||
Callback - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif // #ifndef _HII_PACK_H_
|
2533
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
Normal file
2533
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
Normal file
File diff suppressed because it is too large
Load Diff
267
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
Normal file
267
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
Normal file
@@ -0,0 +1,267 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
IfrParse.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Prototypes and defines for the IFR parsing services.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _IFR_PARSE_H_
|
||||
#define _IFR_PARSE_H_
|
||||
|
||||
#define DEFAULT_HII_PACK_FILENAME_EXTENSION ".hpk"
|
||||
//
|
||||
// When we parse IFR, we'll keep the IFR in a linked list of
|
||||
// these.
|
||||
//
|
||||
typedef struct _IFR_PARSE_ENTRY {
|
||||
struct _IFR_PARSE_ENTRY *Next;
|
||||
int Tag; // for debugging
|
||||
EFI_IFR_OP_HEADER *RawIfrHeader;
|
||||
//
|
||||
// GUIDs for variable storage
|
||||
//
|
||||
EFI_GUID *VarStoreGuid1;
|
||||
char *VarStoreName1;
|
||||
EFI_GUID *VarStoreGuid2;
|
||||
char *VarStoreName2;
|
||||
} IFR_PARSE_ENTRY;
|
||||
|
||||
typedef struct _IFR_PARSE_CONTEXT {
|
||||
struct _IFR_PARSE_CONTEXT *Next;
|
||||
EFI_HII_IFR_PACK *PackHeader;
|
||||
char *IfrBufferStart;
|
||||
char *CurrentPos;
|
||||
long IfrBufferLen;
|
||||
int Handle;
|
||||
IFR_PARSE_ENTRY *Ifr;
|
||||
IFR_PARSE_ENTRY *LastIfr;
|
||||
IFR_PARSE_ENTRY *CurrentIfr;
|
||||
FILE *OutFptr;
|
||||
CHAR16 *Language;
|
||||
EFI_GUID *FormsetGuid;
|
||||
EFI_GUID NullGuid; // for use until we set the Guid field correctly
|
||||
EFI_GUID PackageGuid; // from the PackageGuid in the HII data table
|
||||
} IFR_PARSE_CONTEXT;
|
||||
|
||||
STATUS
|
||||
IfrGetVarPack (
|
||||
int VarIndex,
|
||||
EFI_HII_VARIABLE_PACK **VarPack
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
VarIndex - GC_TODO: add argument description
|
||||
VarPack - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParsePack (
|
||||
int Handle,
|
||||
EFI_HII_IFR_PACK *PackHeader,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
PackHeader - GC_TODO: add argument description
|
||||
PackageGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseCheck (
|
||||
char *Buffer,
|
||||
long BufferSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Buffer - GC_TODO: add argument description
|
||||
BufferSize - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseInit (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseEnd (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseDump (
|
||||
int Handle,
|
||||
CHAR16 *Language,
|
||||
FILE *OutFptr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
Language - GC_TODO: add argument description
|
||||
OutFptr - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrSetDefaults (
|
||||
int MfgDefaults
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
MfgDefaults - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrGetIfrPack (
|
||||
int Handle,
|
||||
EFI_HII_IFR_PACK **PackHeader,
|
||||
EFI_GUID *FormsetGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
PackHeader - GC_TODO: add argument description
|
||||
FormsetGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrReferencesVarPack (
|
||||
int IfrHandle,
|
||||
EFI_HII_VARIABLE_PACK *VarPack
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
IfrHandle - GC_TODO: add argument description
|
||||
VarPack - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif // #ifndef _IFR_PARSE_H_
|
103
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
Normal file
103
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
Normal file
@@ -0,0 +1,103 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# This file is used to build the HiiPack utility
|
||||
#
|
||||
#--*/
|
||||
|
||||
#
|
||||
# Make sure environmental variable EDK_SOURCE is set
|
||||
#
|
||||
!IFNDEF EDK_SOURCE
|
||||
!ERROR EDK_SOURCE environmental variable not set
|
||||
!ENDIF
|
||||
|
||||
#
|
||||
# Do this if you want to compile from this directory
|
||||
#
|
||||
!IFNDEF TOOLCHAIN
|
||||
TOOLCHAIN = TOOLCHAIN_MSVC
|
||||
!ENDIF
|
||||
|
||||
!INCLUDE $(BUILD_DIR)\PlatformTools.env
|
||||
|
||||
#
|
||||
# Target specific information
|
||||
#
|
||||
|
||||
TARGET_NAME = HiiPack
|
||||
TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)
|
||||
TARGET_EXE = $(EDK_TOOLS_OUTPUT)\HiiPack.exe
|
||||
|
||||
#
|
||||
# Build targets
|
||||
#
|
||||
|
||||
all: $(TARGET_EXE)
|
||||
|
||||
INC = $(INC) -I "$(EDK_SOURCE)\Foundation\Framework\Protocol\Hii"
|
||||
|
||||
INC_DEPS = "$(TARGET_SRC_DIR)\HiiPack.h" "$(TARGET_SRC_DIR)\IfrParse.h" "$(TARGET_SRC_DIR)\StringParse.h"
|
||||
|
||||
LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"
|
||||
|
||||
OBJECTS = $(EDK_TOOLS_OUTPUT)\FindFiles.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\HiiPack.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\IfrParse.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\StringParse.obj
|
||||
|
||||
#
|
||||
# Build EXE
|
||||
#
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\FindFiles.obj : $(TARGET_SRC_DIR)\FindFiles.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\FindFiles.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SRC_DIR)\HiiPack.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\HiiPack.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\IfrParse.obj : $(TARGET_SRC_DIR)\IfrParse.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\IfrParse.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\StringParse.obj : $(TARGET_SRC_DIR)\StringParse.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\StringParse.c /Fo$@
|
||||
|
||||
#
|
||||
# Add Binary Build description for this tool.
|
||||
#
|
||||
|
||||
!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
|
||||
$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
|
||||
if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
|
||||
!ELSE
|
||||
$(TARGET_EXE) : $(OBJECTS) $(LIBS)
|
||||
$(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
|
||||
!IF ("$(EFI_BINARY_BUILD)" == "YES")
|
||||
if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
|
||||
if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
|
||||
if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
|
||||
copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
clean:
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\FindFiles.* del $(EDK_TOOLS_OUTPUT)\FindFiles.* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\IfrParse* del $(EDK_TOOLS_OUTPUT)\IfrParse.* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\StringParse.* del $(EDK_TOOLS_OUTPUT)\StringParse.* > NUL
|
244
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
Normal file
244
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
Normal file
@@ -0,0 +1,244 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
StringParse.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Routines for parsing HII string packs
|
||||
|
||||
--*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Tiano.h"
|
||||
#include "EfiUtilityMsgs.h"
|
||||
#include "EfiInternalFormRepresentation.h"
|
||||
#include "Hii.h"
|
||||
#include "StringParse.h"
|
||||
#include "HiiPack.h"
|
||||
|
||||
typedef struct _STRING_PACK_RECORD {
|
||||
struct _STRING_PACK_RECORD *Next;
|
||||
int Handle;
|
||||
EFI_GUID PackageGuid;
|
||||
EFI_GUID FormsetGuid;
|
||||
EFI_HII_STRING_PACK *StringPack;
|
||||
int StringPackSize;
|
||||
int NumStringPacks;
|
||||
} STRING_PACK_RECORD;
|
||||
|
||||
static STRING_PACK_RECORD *mStringPacks = NULL;
|
||||
|
||||
STATUS
|
||||
StringGetPack (
|
||||
int Handle, // matches handle passed in with StringParsePack()
|
||||
EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
|
||||
int *StringPackSize, // sizeof buffer pointed to by StringPack
|
||||
int *NumStringPacks, // in the array pointed to by StringPack
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Get a string pack given to us previously
|
||||
|
||||
Arguments:
|
||||
Handle - handle of string pack to get
|
||||
StringPack - outgoing pointer to string pack on the given handle
|
||||
StringPackSize - outgoing size of string pack pointed to by StringPack
|
||||
NumStringPacks - outgoing number of string packs in StringPack[] array
|
||||
FormsetGuid - outgoing GUID passed in with the string pack when it was parsed
|
||||
PackageGuid - outgoing GUID passed in with the string pack when it was parsed
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - string pack with matching handle was found
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
STRING_PACK_RECORD *Rec;
|
||||
|
||||
for (Rec = mStringPacks; Rec != NULL; Rec = Rec->Next) {
|
||||
if (Rec->Handle == Handle) {
|
||||
*StringPack = Rec->StringPack;
|
||||
*StringPackSize = Rec->StringPackSize;
|
||||
*NumStringPacks = Rec->NumStringPacks;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
STATUS
|
||||
StringParsePack (
|
||||
int Handle,
|
||||
EFI_HII_STRING_PACK *StringPack,
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse a string pack, saving the information for later retrieval by the caller
|
||||
|
||||
Arguments:
|
||||
Handle - handle of string pack
|
||||
StringPack - pointer to string pack array to parse
|
||||
FormsetGuid - GUID of the string pack
|
||||
PackageGuid - package GUID from the HII data table from which this string pack orginated
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - Stringpack processed successfully
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
STRING_PACK_RECORD *Rec;
|
||||
|
||||
STRING_PACK_RECORD *TempRec;
|
||||
int PackSize;
|
||||
EFI_HII_STRING_PACK *TempPack;
|
||||
//
|
||||
// Allocate a new string pack record
|
||||
//
|
||||
Rec = (STRING_PACK_RECORD *) malloc (sizeof (STRING_PACK_RECORD));
|
||||
if (Rec == NULL) {
|
||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memset (Rec, 0, sizeof (STRING_PACK_RECORD));
|
||||
Rec->Handle = Handle;
|
||||
if (PackageGuid != NULL) {
|
||||
memcpy (&Rec->PackageGuid, PackageGuid, sizeof (EFI_GUID));
|
||||
}
|
||||
|
||||
if (FormsetGuid != NULL) {
|
||||
memcpy (&Rec->FormsetGuid, FormsetGuid, sizeof (EFI_GUID));
|
||||
}
|
||||
//
|
||||
// Walk the string packs to find the terminator
|
||||
//
|
||||
TempPack = StringPack;
|
||||
PackSize = 0;
|
||||
while (TempPack->Header.Length > 0) {
|
||||
if (TempPack->Header.Type != EFI_HII_STRING) {
|
||||
Error (NULL, 0, 0, "found a non-string pack in the string pack array", NULL);
|
||||
free (Rec);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
PackSize += TempPack->Header.Length;
|
||||
Rec->NumStringPacks++;
|
||||
TempPack = (EFI_HII_STRING_PACK *) ((char *) TempPack + TempPack->Header.Length);
|
||||
}
|
||||
//
|
||||
// Add space for the terminator
|
||||
//
|
||||
PackSize += sizeof (EFI_HII_STRING_PACK);
|
||||
Rec->StringPackSize = PackSize;
|
||||
//
|
||||
// Make a copy of the incoming string pack
|
||||
//
|
||||
Rec->StringPack = (EFI_HII_STRING_PACK *) malloc (PackSize);
|
||||
if (Rec->StringPack == NULL) {
|
||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||
free (Rec);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memcpy ((void *) Rec->StringPack, StringPack, PackSize);
|
||||
//
|
||||
// Add this record to our list
|
||||
//
|
||||
if (mStringPacks == NULL) {
|
||||
mStringPacks = Rec;
|
||||
} else {
|
||||
for (TempRec = mStringPacks; TempRec->Next != NULL; TempRec = TempRec->Next)
|
||||
;
|
||||
TempRec->Next = Rec;
|
||||
}
|
||||
free (Rec->StringPack);
|
||||
free (Rec);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
STATUS
|
||||
StringInit (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
{
|
||||
StringEnd ();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
STATUS
|
||||
StringEnd (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
{
|
||||
STRING_PACK_RECORD *Next;
|
||||
//
|
||||
// Free up all the memory we've allocated
|
||||
//
|
||||
while (mStringPacks != NULL) {
|
||||
if (mStringPacks->StringPack != NULL) {
|
||||
free (mStringPacks->StringPack);
|
||||
}
|
||||
|
||||
Next = mStringPacks->Next;
|
||||
free (mStringPacks);
|
||||
mStringPacks = Next;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
125
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
Normal file
125
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
StringParse.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Prototypes and defines for the string pack parsing services.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _STRING_PARSE_H_
|
||||
#define _STRING_PARSE_H_
|
||||
|
||||
STATUS
|
||||
StringGetPack (
|
||||
int Handle, // matches handle passed in with StringParsePack()
|
||||
EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
|
||||
int *StringPackSize, // sizeof buffer pointed to by StringPack
|
||||
int *NumStringPacks, // in the array pointed to by StringPack
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
StringPack - GC_TODO: add argument description
|
||||
StringPackSize - GC_TODO: add argument description
|
||||
NumStringPacks - GC_TODO: add argument description
|
||||
FormsetGuid - GC_TODO: add argument description
|
||||
PackageGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringParsePack (
|
||||
int Handle,
|
||||
EFI_HII_STRING_PACK *StringPack,
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
StringPack - GC_TODO: add argument description
|
||||
FormsetGuid - GC_TODO: add argument description
|
||||
PackageGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringInit (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringEnd (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif // #ifndef _STRING_PARSE_H_
|
Reference in New Issue
Block a user