Adding Additional Tools that are needed for Platform Image creation.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@198 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
163
Tools/Source/TianoTools/EfiCompress/EfiCompressMain.c
Normal file
163
Tools/Source/TianoTools/EfiCompress/EfiCompressMain.c
Normal file
@@ -0,0 +1,163 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
|
||||
Module Name:
|
||||
|
||||
EfiCompressMain.c
|
||||
|
||||
Abstract:
|
||||
|
||||
The main function for the compression utility.
|
||||
|
||||
--*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "TianoCommon.h"
|
||||
#include "EfiCompress.h"
|
||||
|
||||
int
|
||||
main (
|
||||
INT32 argc,
|
||||
CHAR8 *argv[]
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Compresses the input files
|
||||
|
||||
Arguments:
|
||||
|
||||
argc - number of arguments passed into the command line.
|
||||
argv[] - files to compress and files to output compressed data to.
|
||||
|
||||
Returns:
|
||||
|
||||
int: 0 for successful execution of the function.
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
FILE *infile;
|
||||
FILE *outfile;
|
||||
UINT32 SrcSize;
|
||||
UINT32 DstSize;
|
||||
UINT8 *SrcBuffer;
|
||||
UINT8 *DstBuffer;
|
||||
UINT8 Buffer[8];
|
||||
|
||||
//
|
||||
// Added for makefile debug - KCE
|
||||
//
|
||||
INT32 arg_counter;
|
||||
printf ("\n\n");
|
||||
for (arg_counter = 0; arg_counter < argc; arg_counter++) {
|
||||
printf ("%s ", argv[arg_counter]);
|
||||
}
|
||||
|
||||
printf ("\n\n");
|
||||
|
||||
SrcBuffer = DstBuffer = NULL;
|
||||
|
||||
infile = outfile = NULL;
|
||||
|
||||
if (argc != 3) {
|
||||
printf ("Usage: EFICOMPRESS <infile> <outfile>\n");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((outfile = fopen (argv[2], "wb")) == NULL) {
|
||||
printf ("Can't open output file\n");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((infile = fopen (argv[1], "rb")) == NULL) {
|
||||
printf ("Can't open input file\n");
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Get the size of source file
|
||||
//
|
||||
SrcSize = 0;
|
||||
while (fread (Buffer, 1, 1, infile)) {
|
||||
SrcSize++;
|
||||
|
||||
}
|
||||
//
|
||||
// Read in the source data
|
||||
//
|
||||
if ((SrcBuffer = malloc (SrcSize)) == NULL) {
|
||||
printf ("Can't allocate memory\n");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
rewind (infile);
|
||||
if (fread (SrcBuffer, 1, SrcSize, infile) != SrcSize) {
|
||||
printf ("Can't read from source\n");
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Get destination data size and do the compression
|
||||
//
|
||||
DstSize = 0;
|
||||
Status = Compress (SrcBuffer, SrcSize, DstBuffer, &DstSize);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
if ((DstBuffer = malloc (DstSize)) == NULL) {
|
||||
printf ("Can't allocate memory\n");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = Compress (SrcBuffer, SrcSize, DstBuffer, &DstSize);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
printf ("Compress Error\n");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
printf ("\nOrig Size = %ld\n", SrcSize);
|
||||
printf ("Comp Size = %ld\n", DstSize);
|
||||
|
||||
if (DstBuffer == NULL) {
|
||||
printf ("No destination to write to.\n");
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Write out the result
|
||||
//
|
||||
if (fwrite (DstBuffer, 1, DstSize, outfile) != DstSize) {
|
||||
printf ("Can't write to destination file\n");
|
||||
}
|
||||
|
||||
Done:
|
||||
if (SrcBuffer) {
|
||||
free (SrcBuffer);
|
||||
}
|
||||
|
||||
if (DstBuffer) {
|
||||
free (DstBuffer);
|
||||
}
|
||||
|
||||
if (infile) {
|
||||
fclose (infile);
|
||||
}
|
||||
|
||||
if (outfile) {
|
||||
fclose (outfile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
77
Tools/Source/TianoTools/EfiCompress/makefile
Normal file
77
Tools/Source/TianoTools/EfiCompress/makefile
Normal file
@@ -0,0 +1,77 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2001 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# This software and associated documentation (if any) is furnished under
|
||||
# a license and may only be used or copied in accordance with the terms
|
||||
# of the license. Except as permitted by such license, no part of this
|
||||
# software or documentation may be reproduced, stored in a retrieval
|
||||
# system, or transmitted in any form or by any means without the express
|
||||
# written consent of Intel Corporation.
|
||||
#
|
||||
# Module Name: makefile
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# This file is used to build the EFI utility.
|
||||
#
|
||||
#--*/
|
||||
|
||||
#
|
||||
# Do this if you want to compile from this directory
|
||||
#
|
||||
!IFNDEF TOOLCHAIN
|
||||
TOOLCHAIN = TOOLCHAIN_MSVC
|
||||
!ENDIF
|
||||
|
||||
!INCLUDE PlatformTools.env
|
||||
|
||||
#
|
||||
# Define some macros we use here. Should get rid of them someday and
|
||||
# get rid of the extra level of indirection.
|
||||
#
|
||||
COMMON_SOURCE = $(EDK_TOOLS_COMMON)
|
||||
|
||||
#
|
||||
# BUGBUG: Override standard flags, cannot be built without warnings.
|
||||
#
|
||||
|
||||
C_FLAGS=/nologo /W4 /GX /Zi /Od /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
|
||||
|
||||
#
|
||||
# Common information
|
||||
#
|
||||
|
||||
INC=$(INC)
|
||||
|
||||
#
|
||||
# Target specific information
|
||||
#
|
||||
|
||||
TARGET_NAME=EfiCompress
|
||||
TARGET_SOURCE_DIR = $(TIANO_TOOLS_SOURCE)\$(TARGET_NAME)
|
||||
|
||||
TARGET_EXE = $(TIANO_TOOLS_OUTPUT)\$(TARGET_NAME).exe
|
||||
|
||||
TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\EfiCompressMain.c"
|
||||
TARGET_EXE_INCLUDE = "$(COMMON_SOURCE)\EfiCompress.h"
|
||||
TARGET_EXE_LIBS = "$(TIANO_TOOLS_OUTPUT)\Common.lib"
|
||||
|
||||
#
|
||||
# Build targets
|
||||
#
|
||||
|
||||
all: $(TARGET_EXE)
|
||||
|
||||
#
|
||||
# Build EXE
|
||||
#
|
||||
|
||||
$(TIANO_TOOLS_OUTPUT)\EfiCompressMain.obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(TIANO_TOOLS_OUTPUT)\EfiCompressMain.obj
|
||||
|
||||
$(TARGET_EXE): $(TIANO_TOOLS_OUTPUT)\EfiCompressMain.obj $(TARGET_EXE_LIBS) $(TARGET_DLL)
|
||||
$(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(TIANO_TOOLS_OUTPUT)\EfiCompressMain.obj $(TARGET_LIB) $(TARGET_EXE_LIBS)
|
||||
|
||||
clean:
|
||||
@if exist $(TIANO_TOOLS_OUTPUT)\$(TARGET_NAME)Main.* del /q $(TIANO_TOOLS_OUTPUT)\$(TARGET_NAME)Main.* > NUL
|
Reference in New Issue
Block a user