summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-10 07:18:20 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-10 07:18:20 +0000
commit64b2609fcff9d6412eea4c74c8e74bed33dc3235 (patch)
treeb2fa2c1493272b91a04ff4f12384f3ceaa23f1a7 /BaseTools/Source/C
parent09e4dbeb5c0ef7d9e178e81f73c9e43f8ef48559 (diff)
downloadedk2-platforms-64b2609fcff9d6412eea4c74c8e74bed33dc3235.tar.xz
Sync BaseTools Trunk (version r2518) to EDKII main trunk.
Signed-off-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13178 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/C')
-rw-r--r--BaseTools/Source/C/GNUmakefile7
-rw-r--r--BaseTools/Source/C/Include/Common/BuildVersion.h2
-rw-r--r--BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h4
-rw-r--r--BaseTools/Source/C/LzmaCompress/GNUmakefile5
-rw-r--r--BaseTools/Source/C/LzmaCompress/LzmaCompress.c240
-rw-r--r--BaseTools/Source/C/LzmaCompress/LzmaF86Compress.bat31
-rw-r--r--BaseTools/Source/C/LzmaCompress/Makefile14
-rw-r--r--BaseTools/Source/C/LzmaCompress/Sdk/C/Bra.h60
-rw-r--r--BaseTools/Source/C/LzmaCompress/Sdk/C/Bra86.c85
-rw-r--r--BaseTools/Source/C/Makefile3
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp4
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.h6
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp86
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.h7
14 files changed, 433 insertions, 121 deletions
diff --git a/BaseTools/Source/C/GNUmakefile b/BaseTools/Source/C/GNUmakefile
index ad034be538..e0dde3e085 100644
--- a/BaseTools/Source/C/GNUmakefile
+++ b/BaseTools/Source/C/GNUmakefile
@@ -1,7 +1,7 @@
## @file
# GNU Make makefile for C tools build.
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2012, 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
@@ -22,10 +22,7 @@ ifndef ARCH
ifeq ($(uname_m),x86_64)
ARCH=X64
endif
- ifeq ($(uname_m),i386)
- ARCH=IA32
- endif
- ifeq ($(uname_m),i686)
+ ifeq ($(patsubst i%86,IA32,$(uname_m)),IA32)
ARCH=IA32
endif
ifndef ARCH
diff --git a/BaseTools/Source/C/Include/Common/BuildVersion.h b/BaseTools/Source/C/Include/Common/BuildVersion.h
index 22327e7ec7..f9144e5f01 100644
--- a/BaseTools/Source/C/Include/Common/BuildVersion.h
+++ b/BaseTools/Source/C/Include/Common/BuildVersion.h
@@ -14,4 +14,4 @@
**/
-#define __BUILD_VERSION "Build 2474"
+#define __BUILD_VERSION "Build 2518"
diff --git a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
index 1cabc959d8..82d391ce3a 100644
--- a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
+++ b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
@@ -3,7 +3,7 @@
IFR is primarily consumed by the EFI presentation engine, and produced by EFI
internal application and drivers as well as all add-in card option-ROM drivers
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2012, 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
@@ -613,7 +613,7 @@ typedef union {
#define EFI_IFR_INCONSISTENT_IF_OP 0x11
#define EFI_IFR_EQ_ID_VAL_OP 0x12
#define EFI_IFR_EQ_ID_ID_OP 0x13
-#define EFI_IFR_EQ_ID_LIST_OP 0x14
+#define EFI_IFR_EQ_ID_VAL_LIST_OP 0x14
#define EFI_IFR_AND_OP 0x15
#define EFI_IFR_OR_OP 0x16
#define EFI_IFR_NOT_OP 0x17
diff --git a/BaseTools/Source/C/LzmaCompress/GNUmakefile b/BaseTools/Source/C/LzmaCompress/GNUmakefile
index 99e9cbbeb0..07f0a90b60 100644
--- a/BaseTools/Source/C/LzmaCompress/GNUmakefile
+++ b/BaseTools/Source/C/LzmaCompress/GNUmakefile
@@ -1,7 +1,7 @@
## @file
# Windows makefile for 'LzmaCompress' module build.
#
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2012, 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
@@ -24,7 +24,8 @@ OBJECTS = \
$(SDK_C)/LzmaDec.o \
$(SDK_C)/LzmaEnc.o \
$(SDK_C)/7zFile.o \
- $(SDK_C)/7zStream.o
+ $(SDK_C)/7zStream.o \
+ $(SDK_C)/Bra86.o
include $(MAKEROOT)/Makefiles/app.makefile
diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
index 7d254ed49a..b569b4e4d9 100644
--- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
+++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
@@ -5,7 +5,7 @@
LzmaUtil.c -- Test application for LZMA compression
2008-11-23 : Igor Pavlov : Public domain
- Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2012, 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
@@ -27,8 +27,17 @@
#include "Sdk/C/7zVersion.h"
#include "Sdk/C/LzmaDec.h"
#include "Sdk/C/LzmaEnc.h"
+#include "Sdk/C/Bra.h"
#include "CommonLib.h"
+#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
+
+typedef enum {
+ NoConverter,
+ X86Converter,
+ MaxConverter
+} CONVERTER_TYPE;
+
const char *kCantReadMessage = "Can not read input file";
const char *kCantWriteMessage = "Can not write output file";
const char *kCantAllocateMessage = "Can not allocate memory";
@@ -39,12 +48,13 @@ static void SzFree(void *p, void *address) { p = p; MyFree(address); }
static ISzAlloc g_Alloc = { SzAlloc, SzFree };
static Bool mQuietMode = False;
+static CONVERTER_TYPE mConType = NoConverter;
#define UTILITY_NAME "LzmaCompress"
#define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 1
+#define UTILITY_MINOR_VERSION 2
#define INTEL_COPYRIGHT \
- "Copyright (c) 2009, Intel Corporation. All rights reserved."
+ "Copyright (c) 2009-2012, Intel Corporation. All rights reserved."
void PrintHelp(char *buffer)
{
strcat(buffer,
@@ -54,6 +64,7 @@ void PrintHelp(char *buffer)
" -e: encode file\n"
" -d: decode file\n"
" -o FileName, --output FileName: specify the output filename\n"
+ " --f86: enable converter for x86 code\n"
" -v, --verbose: increase output messages\n"
" -q, --quiet: reduce output messages\n"
" --debug [0-9]: set debug level\n"
@@ -86,121 +97,151 @@ void PrintVersion(char *buffer)
sprintf (buffer, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
}
-#define IN_BUF_SIZE (1 << 16)
-#define OUT_BUF_SIZE (1 << 16)
-
-static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream,
- UInt64 unpackSize)
+static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize)
{
- int thereIsSize = (unpackSize != (UInt64)(Int64)-1);
- Byte inBuf[IN_BUF_SIZE];
- Byte outBuf[OUT_BUF_SIZE];
- size_t inPos = 0, inSize = 0, outPos = 0;
- LzmaDec_Init(state);
- for (;;)
- {
- if (inPos == inSize)
- {
- inSize = IN_BUF_SIZE;
- RINOK(inStream->Read(inStream, inBuf, &inSize));
- inPos = 0;
- }
- {
- SRes res;
- SizeT inProcessed = inSize - inPos;
- SizeT outProcessed = OUT_BUF_SIZE - outPos;
- ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
- ELzmaStatus status;
- if (thereIsSize && outProcessed > unpackSize)
- {
- outProcessed = (SizeT)unpackSize;
- finishMode = LZMA_FINISH_END;
- }
-
- res = LzmaDec_DecodeToBuf(state, outBuf + outPos, &outProcessed,
- inBuf + inPos, &inProcessed, finishMode, &status);
- inPos += inProcessed;
- outPos += outProcessed;
- unpackSize -= outProcessed;
-
- if (outStream)
- if (outStream->Write(outStream, outBuf, outPos) != outPos)
- return SZ_ERROR_WRITE;
+ SRes res;
+ size_t inSize = (size_t)fileSize;
+ Byte *inBuffer = 0;
+ Byte *outBuffer = 0;
+ Byte *filteredStream = 0;
+ size_t outSize;
+ CLzmaEncProps props;
- outPos = 0;
+ LzmaEncProps_Init(&props);
+ LzmaEncProps_Normalize(&props);
+
+ if (inSize != 0) {
+ inBuffer = (Byte *)MyAlloc(inSize);
+ if (inBuffer == 0)
+ return SZ_ERROR_MEM;
+ } else {
+ return SZ_ERROR_INPUT_EOF;
+ }
+
+ if (SeqInStream_Read(inStream, inBuffer, inSize) != SZ_OK) {
+ res = SZ_ERROR_READ;
+ goto Done;
+ }
- if (res != SZ_OK || (thereIsSize && unpackSize == 0))
- return res;
+ // we allocate 105% of original size + 64KB for output buffer
+ outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
+ outBuffer = (Byte *)MyAlloc(outSize);
+ if (outBuffer == 0) {
+ res = SZ_ERROR_MEM;
+ goto Done;
+ }
+
+ {
+ int i;
+ for (i = 0; i < 8; i++)
+ outBuffer[i + LZMA_PROPS_SIZE] = (Byte)(fileSize >> (8 * i));
+ }
- if (inProcessed == 0 && outProcessed == 0)
+ if (mConType != NoConverter)
+ {
+ filteredStream = (Byte *)MyAlloc(inSize);
+ if (filteredStream == 0) {
+ res = SZ_ERROR_MEM;
+ goto Done;
+ }
+ memcpy(filteredStream, inBuffer, inSize);
+
+ if (mConType == X86Converter) {
{
- if (thereIsSize || status != LZMA_STATUS_FINISHED_WITH_MARK)
- return SZ_ERROR_DATA;
- return res;
+ UInt32 x86State;
+ x86_Convert_Init(x86State);
+ x86_Convert(filteredStream, (SizeT) inSize, 0, &x86State, 1);
}
}
}
-}
-
-static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream)
-{
- UInt64 unpackSize;
- int i;
- SRes res = 0;
- CLzmaDec state;
-
- /* header: 5 bytes of LZMA properties and 8 bytes of uncompressed size */
- unsigned char header[LZMA_PROPS_SIZE + 8];
-
- /* Read and parse header */
+ {
+ size_t outSizeProcessed = outSize - LZMA_HEADER_SIZE;
+ size_t outPropsSize = LZMA_PROPS_SIZE;
+
+ res = LzmaEncode(outBuffer + LZMA_HEADER_SIZE, &outSizeProcessed,
+ mConType != NoConverter ? filteredStream : inBuffer, inSize,
+ &props, outBuffer, &outPropsSize, 0,
+ NULL, &g_Alloc, &g_Alloc);
+
+ if (res != SZ_OK)
+ goto Done;
+
+ outSize = LZMA_HEADER_SIZE + outSizeProcessed;
+ }
- RINOK(SeqInStream_Read(inStream, header, sizeof(header)));
+ if (outStream->Write(outStream, outBuffer, outSize) != outSize)
+ res = SZ_ERROR_WRITE;
- unpackSize = 0;
- for (i = 0; i < 8; i++)
- unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8);
+Done:
+ MyFree(outBuffer);
+ MyFree(inBuffer);
+ MyFree(filteredStream);
- LzmaDec_Construct(&state);
- RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc));
- res = Decode2(&state, outStream, inStream, unpackSize);
- LzmaDec_Free(&state, &g_Alloc);
return res;
}
-static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs)
+static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize)
{
- CLzmaEncHandle enc;
SRes res;
- CLzmaEncProps props;
+ size_t inSize = (size_t)fileSize;
+ Byte *inBuffer = 0;
+ Byte *outBuffer = 0;
+ size_t outSize = 0;
+ size_t inSizePure;
+ ELzmaStatus status;
+ UInt64 outSize64 = 0;
- rs = rs;
+ int i;
+
+ if (inSize < LZMA_HEADER_SIZE)
+ return SZ_ERROR_INPUT_EOF;
- enc = LzmaEnc_Create(&g_Alloc);
- if (enc == 0)
+ inBuffer = (Byte *)MyAlloc(inSize);
+ if (inBuffer == 0)
return SZ_ERROR_MEM;
+
+ if (SeqInStream_Read(inStream, inBuffer, inSize) != SZ_OK) {
+ res = SZ_ERROR_READ;
+ goto Done;
+ }
- LzmaEncProps_Init(&props);
- res = LzmaEnc_SetProps(enc, &props);
+ for (i = 0; i < 8; i++)
+ outSize64 += ((UInt64)inBuffer[LZMA_PROPS_SIZE + i]) << (i * 8);
+
+ outSize = (size_t)outSize64;
+ if (outSize != 0) {
+ outBuffer = (Byte *)MyAlloc(outSize);
+ if (outBuffer == 0) {
+ res = SZ_ERROR_MEM;
+ goto Done;
+ }
+ } else {
+ res = SZ_OK;
+ goto Done;
+ }
- if (res == SZ_OK)
- {
- Byte header[LZMA_PROPS_SIZE + 8];
- size_t headerSize = LZMA_PROPS_SIZE;
- int i;
+ inSizePure = inSize - LZMA_HEADER_SIZE;
+ res = LzmaDecode(outBuffer, &outSize, inBuffer + LZMA_HEADER_SIZE, &inSizePure,
+ inBuffer, LZMA_PROPS_SIZE, LZMA_FINISH_END, &status, &g_Alloc);
- res = LzmaEnc_WriteProperties(enc, header, &headerSize);
- for (i = 0; i < 8; i++)
- header[headerSize++] = (Byte)(fileSize >> (8 * i));
- if (outStream->Write(outStream, header, headerSize) != headerSize)
- res = SZ_ERROR_WRITE;
- else
- {
- if (res == SZ_OK)
- res = LzmaEnc_Encode(enc, outStream, inStream, NULL, &g_Alloc, &g_Alloc);
- }
+ if (res != SZ_OK)
+ goto Done;
+
+ if (mConType == X86Converter)
+ {
+ UInt32 x86State;
+ x86_Convert_Init(x86State);
+ x86_Convert(outBuffer, (SizeT) outSize, 0, &x86State, 0);
}
- LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc);
+
+ if (outStream->Write(outStream, outBuffer, outSize) != outSize)
+ res = SZ_ERROR_WRITE;
+
+Done:
+ MyFree(outBuffer);
+ MyFree(inBuffer);
+
return res;
}
@@ -214,6 +255,7 @@ int main2(int numArgs, const char *args[], char *rs)
const char *inputFile = NULL;
const char *outputFile = "file.tmp";
int param;
+ UInt64 fileSize;
FileSeqInStream_CreateVTable(&inStream);
File_Construct(&inStream.file);
@@ -231,6 +273,8 @@ int main2(int numArgs, const char *args[], char *rs)
if (strcmp(args[param], "-e") == 0 || strcmp(args[param], "-d") == 0) {
encodeMode = (args[param][1] == 'e');
modeWasSet = True;
+ } else if (strcmp(args[param], "--f86") == 0) {
+ mConType = X86Converter;
} else if (strcmp(args[param], "-o") == 0 ||
strcmp(args[param], "--output") == 0) {
if (numArgs < (param + 2)) {
@@ -292,21 +336,21 @@ int main2(int numArgs, const char *args[], char *rs)
if (OutFile_Open(&outStream.file, outputFile) != 0)
return PrintError(rs, "Can not open output file");
+ File_GetLength(&inStream.file, &fileSize);
+
if (encodeMode)
{
- UInt64 fileSize;
- File_GetLength(&inStream.file, &fileSize);
if (!mQuietMode) {
printf("Encoding\n");
}
- res = Encode(&outStream.s, &inStream.s, fileSize, rs);
+ res = Encode(&outStream.s, &inStream.s, fileSize);
}
else
{
if (!mQuietMode) {
printf("Decoding\n");
}
- res = Decode(&outStream.s, &inStream.s);
+ res = Decode(&outStream.s, &inStream.s, fileSize);
}
File_Close(&outStream.file);
diff --git a/BaseTools/Source/C/LzmaCompress/LzmaF86Compress.bat b/BaseTools/Source/C/LzmaCompress/LzmaF86Compress.bat
new file mode 100644
index 0000000000..77749dfd16
--- /dev/null
+++ b/BaseTools/Source/C/LzmaCompress/LzmaF86Compress.bat
@@ -0,0 +1,31 @@
+@REM
+@REM This script will exec LzmaCompress tool with --f86 option that enables converter for x86 code.
+@REM
+@REM Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+@REM This program and the accompanying materials
+@REM are licensed and made available under the terms and conditions of the BSD License
+@REM which accompanies this distribution. The full text of the license may be found at
+@REM http://opensource.org/licenses/bsd-license.php
+@REM
+@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+@REM
+
+@echo off
+@setlocal
+
+:Begin
+if "%1"=="" goto End
+if "%1"=="-e" (
+ set FLAG=--f86
+)
+if "%1"=="-d" (
+ set FLAG=--f86
+)
+set ARGS=%ARGS% %1
+shift
+goto Begin
+
+:End
+LzmaCompress %ARGS% %FLAG%
+@echo on
diff --git a/BaseTools/Source/C/LzmaCompress/Makefile b/BaseTools/Source/C/LzmaCompress/Makefile
index 1c1ba2bc38..872e899512 100644
--- a/BaseTools/Source/C/LzmaCompress/Makefile
+++ b/BaseTools/Source/C/LzmaCompress/Makefile
@@ -1,7 +1,7 @@
## @file
# Windows makefile for 'LzmaCompress' module build.
#
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2012, 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
@@ -25,7 +25,17 @@ OBJECTS = \
$(SDK_C)\LzmaDec.obj \
$(SDK_C)\LzmaEnc.obj \
$(SDK_C)\7zFile.obj \
- $(SDK_C)\7zStream.obj
+ $(SDK_C)\7zStream.obj \
+ $(SDK_C)\Bra86.obj
!INCLUDE ..\Makefiles\ms.app
+all: $(BIN_PATH)\LzmaF86Compress.bat
+
+$(BIN_PATH)\LzmaF86Compress.bat: LzmaF86Compress.bat
+ copy LzmaF86Compress.bat $(BIN_PATH)\LzmaF86Compress.bat /Y
+
+cleanall: localCleanall
+
+localCleanall:
+ del /f /q $(BIN_PATH)\LzmaF86Compress.bat > nul
diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/Bra.h b/BaseTools/Source/C/LzmaCompress/Sdk/C/Bra.h
new file mode 100644
index 0000000000..b9018eb991
--- /dev/null
+++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/Bra.h
@@ -0,0 +1,60 @@
+/* Bra.h -- Branch converters for executables
+2008-10-04 : Igor Pavlov : Public domain */
+
+#ifndef __BRA_H
+#define __BRA_H
+
+#include "Types.h"
+
+/*
+These functions convert relative addresses to absolute addresses
+in CALL instructions to increase the compression ratio.
+
+ In:
+ data - data buffer
+ size - size of data
+ ip - current virtual Instruction Pinter (IP) value
+ state - state variable for x86 converter
+ encoding - 0 (for decoding), 1 (for encoding)
+
+ Out:
+ state - state variable for x86 converter
+
+ Returns:
+ The number of processed bytes. If you call these functions with multiple calls,
+ you must start next call with first byte after block of processed bytes.
+
+ Type Endian Alignment LookAhead
+
+ x86 little 1 4
+ ARMT little 2 2
+ ARM little 4 0
+ PPC big 4 0
+ SPARC big 4 0
+ IA64 little 16 0
+
+ size must be >= Alignment + LookAhead, if it's not last block.
+ If (size < Alignment + LookAhead), converter returns 0.
+
+ Example:
+
+ UInt32 ip = 0;
+ for ()
+ {
+ ; size must be >= Alignment + LookAhead, if it's not last block
+ SizeT processed = Convert(data, size, ip, 1);
+ data += processed;
+ size -= processed;
+ ip += processed;
+ }
+*/
+
+#define x86_Convert_Init(state) { state = 0; }
+SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);
+SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+
+#endif
diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/Bra86.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/Bra86.c
new file mode 100644
index 0000000000..93566cb212
--- /dev/null
+++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/Bra86.c
@@ -0,0 +1,85 @@
+/* Bra86.c -- Converter for x86 code (BCJ)
+2008-10-04 : Igor Pavlov : Public domain */
+
+#include "Bra.h"
+
+#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
+
+const Byte kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
+const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
+
+SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
+{
+ SizeT bufferPos = 0, prevPosT;
+ UInt32 prevMask = *state & 0x7;
+ if (size < 5)
+ return 0;
+ ip += 5;
+ prevPosT = (SizeT)0 - 1;
+
+ for (;;)
+ {
+ Byte *p = data + bufferPos;
+ Byte *limit = data + size - 4;
+ for (; p < limit; p++)
+ if ((*p & 0xFE) == 0xE8)
+ break;
+ bufferPos = (SizeT)(p - data);
+ if (p >= limit)
+ break;
+ prevPosT = bufferPos - prevPosT;
+ if (prevPosT > 3)
+ prevMask = 0;
+ else
+ {
+ prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7;
+ if (prevMask != 0)
+ {
+ Byte b = p[4 - kMaskToBitNumber[prevMask]];
+ if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b))
+ {
+ prevPosT = bufferPos;
+ prevMask = ((prevMask << 1) & 0x7) | 1;
+ bufferPos++;
+ continue;
+ }
+ }
+ }
+ prevPosT = bufferPos;
+
+ if (Test86MSByte(p[4]))
+ {
+ UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
+ UInt32 dest;
+ for (;;)
+ {
+ Byte b;
+ int index;
+ if (encoding)
+ dest = (ip + (UInt32)bufferPos) + src;
+ else
+ dest = src - (ip + (UInt32)bufferPos);
+ if (prevMask == 0)
+ break;
+ index = kMaskToBitNumber[prevMask] * 8;
+ b = (Byte)(dest >> (24 - index));
+ if (!Test86MSByte(b))
+ break;
+ src = dest ^ ((1 << (32 - index)) - 1);
+ }
+ p[4] = (Byte)(~(((dest >> 24) & 1) - 1));
+ p[3] = (Byte)(dest >> 16);
+ p[2] = (Byte)(dest >> 8);
+ p[1] = (Byte)dest;
+ bufferPos += 5;
+ }
+ else
+ {
+ prevMask = ((prevMask << 1) & 0x7) | 1;
+ bufferPos++;
+ }
+ }
+ prevPosT = bufferPos - prevPosT;
+ *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7));
+ return bufferPos;
+}
diff --git a/BaseTools/Source/C/Makefile b/BaseTools/Source/C/Makefile
index 367a5dbead..789e06f18d 100644
--- a/BaseTools/Source/C/Makefile
+++ b/BaseTools/Source/C/Makefile
@@ -1,7 +1,7 @@
## @file
# Windows makefile for C tools build.
#
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2012, 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
@@ -59,6 +59,7 @@ install: $(LIB_PATH) $(BIN_PATH)
@echo ######################
@-xcopy $(LIB_PATH)\*.lib $(SYS_LIB_PATH) /I /D /E /F /Y > NUL 2>&1
@-xcopy $(BIN_PATH)\*.exe $(SYS_BIN_PATH) /I /D /E /F /Y > NUL 2>&1
+ @-xcopy $(BIN_PATH)\*.bat $(SYS_BIN_PATH) /I /D /E /F /Y > NUL 2>&1
.PHONY: clean
clean:
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index b4f9d8fd7f..2e859b8dfa 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -2,7 +2,7 @@
The definition of CFormPkg's member function
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2012, 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
@@ -963,7 +963,7 @@ CIfrRecordInfoDB::CheckIdOpCode (
switch (OpCode) {
case EFI_IFR_EQ_ID_VAL_OP:
case EFI_IFR_EQ_ID_ID_OP:
- case EFI_IFR_EQ_ID_LIST_OP:
+ case EFI_IFR_EQ_ID_VAL_LIST_OP:
case EFI_IFR_QUESTION_REF1_OP:
return TRUE;
default:
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 92e47d97a3..5f4d87aa0a 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -2,7 +2,7 @@
The definition of CFormPkg's member function
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2012, 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
@@ -1885,8 +1885,8 @@ private:
public:
CIfrEqIdList (
IN UINT32 LineNo
- ) : CIfrObj (EFI_IFR_EQ_ID_LIST_OP, (CHAR8 **)&mEqIdVList, sizeof (EFI_IFR_EQ_ID_VAL_LIST), TRUE),
- CIfrOpHeader (EFI_IFR_EQ_ID_LIST_OP, &mEqIdVList->Header) {
+ ) : CIfrObj (EFI_IFR_EQ_ID_VAL_LIST_OP, (CHAR8 **)&mEqIdVList, sizeof (EFI_IFR_EQ_ID_VAL_LIST), TRUE),
+ CIfrOpHeader (EFI_IFR_EQ_ID_VAL_LIST_OP, &mEqIdVList->Header) {
SetLineNo (LineNo);
mEqIdVList->QuestionId = EFI_QUESTION_ID_INVALID;
mEqIdVList->ListLength = 0;
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index c3a729eabf..0444677e86 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -2,7 +2,7 @@
Vfr common library functions.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2012, 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
@@ -3067,6 +3067,83 @@ CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName)
mStringFileName[FileLen - 1] = '\0';
}
+
+/**
+ Returns TRUE or FALSE whether SupportedLanguages contains the best matching language
+ from a set of supported languages.
+
+ @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string that
+ contains a set of language codes.
+ @param[in] Language A variable that contains pointers to Null-terminated
+ ASCII strings that contain one language codes.
+
+ @retval FALSE The best matching language could not be found in SupportedLanguages.
+ @retval TRUE The best matching language could be found in SupportedLanguages.
+
+**/
+BOOLEAN
+CVfrStringDB::GetBestLanguage (
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CHAR8 *Language
+ )
+{
+ UINTN CompareLength;
+ UINTN LanguageLength;
+ CONST CHAR8 *Supported;
+
+ if (SupportedLanguages == NULL || Language == NULL){
+ return FALSE;
+ }
+
+ //
+ // Determine the length of the first RFC 4646 language code in Language
+ //
+ for (LanguageLength = 0; Language[LanguageLength] != 0 && Language[LanguageLength] != ';'; LanguageLength++);
+
+ //
+ // Trim back the length of Language used until it is empty
+ //
+ while (LanguageLength > 0) {
+ //
+ // Loop through all language codes in SupportedLanguages
+ //
+ for (Supported = SupportedLanguages; *Supported != '\0'; Supported += CompareLength) {
+ //
+ // Skip ';' characters in Supported
+ //
+ for (; *Supported != '\0' && *Supported == ';'; Supported++);
+ //
+ // Determine the length of the next language code in Supported
+ //
+ for (CompareLength = 0; Supported[CompareLength] != 0 && Supported[CompareLength] != ';'; CompareLength++);
+ //
+ // If Language is longer than the Supported, then skip to the next language
+ //
+ if (LanguageLength > CompareLength) {
+ continue;
+ }
+
+ //
+ // See if the first LanguageLength characters in Supported match Language
+ //
+ if (strncmp (Supported, Language, LanguageLength) == 0) {
+ return TRUE;
+ }
+ }
+
+ //
+ // Trim Language from the right to the next '-' character
+ //
+ for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--);
+ }
+
+ //
+ // No matches were found
+ //
+ return FALSE;
+}
+
+
CHAR8 *
CVfrStringDB::GetVarStoreNameFormStringId (
IN EFI_STRING_ID StringId
@@ -3122,17 +3199,18 @@ CVfrStringDB::GetVarStoreNameFormStringId (
}
//
- // Search the language, only search the "en-US".
+ // Search the language, get best language base on RFC 4647 matching algorithm.
//
Current = StringPtr;
- while (strcmp (PkgHeader->Language, "en-US") != 0) {
+ while (!GetBestLanguage ("en", PkgHeader->Language)) {
Current += PkgHeader->Header.Length;
PkgHeader = (EFI_HII_STRING_PACKAGE_HDR *) Current;
//
- // If can't find "en-US" string package, just return the first string package.
+ // If can't find string package base on language, just return the first string package.
//
if (Current - StringPtr >= Length) {
Current = StringPtr;
+ PkgHeader = (EFI_HII_STRING_PACKAGE_HDR *) StringPtr;
break;
}
}
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
index 9facce8149..2c0ed7bd54 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
@@ -2,7 +2,7 @@
Vfr common library functions.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2012, 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
@@ -438,6 +438,11 @@ private:
UINT32 GetUnicodeStringTextSize (
IN UINT8 *StringSrc
);
+
+ BOOLEAN GetBestLanguage (
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CHAR8 *Language
+ );
public:
CVfrStringDB ();