summaryrefslogtreecommitdiff
path: root/Tools/CCode/Source/EfiCompress
diff options
context:
space:
mode:
authorlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-05 23:24:16 +0000
committerlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-05 23:24:16 +0000
commit604371b98d3ad2472e96be8d126df92b2fcf68df (patch)
treec51c0d63bf3517ed48b28b111cf744dd5da4c866 /Tools/CCode/Source/EfiCompress
parent28305207ea586d0b5ceb530b0e2a436cad9fdd8f (diff)
downloadedk2-604371b98d3ad2472e96be8d126df92b2fcf68df.zip
edk2-604371b98d3ad2472e96be8d126df92b2fcf68df.tar.gz
edk2-604371b98d3ad2472e96be8d126df92b2fcf68df.tar.bz2
More moves for Tool Packages
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1676 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/CCode/Source/EfiCompress')
-rw-r--r--Tools/CCode/Source/EfiCompress/EfiCompressMain.c165
-rw-r--r--Tools/CCode/Source/EfiCompress/build.xml70
2 files changed, 235 insertions, 0 deletions
diff --git a/Tools/CCode/Source/EfiCompress/EfiCompressMain.c b/Tools/CCode/Source/EfiCompress/EfiCompressMain.c
new file mode 100644
index 0000000..492210f
--- /dev/null
+++ b/Tools/CCode/Source/EfiCompress/EfiCompressMain.c
@@ -0,0 +1,165 @@
+/*++
+
+Copyright (c) 1999-2006 Intel Corporation. All rights reserved
+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:
+
+ 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 <Common/UefiBaseTypes.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;
+}
diff --git a/Tools/CCode/Source/EfiCompress/build.xml b/Tools/CCode/Source/EfiCompress/build.xml
new file mode 100644
index 0000000..94f6055
--- /dev/null
+++ b/Tools/CCode/Source/EfiCompress/build.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>
+<!--
+Copyright (c) 2006, Intel Corporation
+All rights reserved. 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.
+-->
+<project default="GenTool" basedir=".">
+<!--
+ EDK EfiCompress Tool
+ Copyright (c) 2006, Intel Corporation
+-->
+ <property name="ToolName" value="EfiCompress"/>
+ <property name="FileSet" value="*.c"/>
+
+ <taskdef resource="cpptasks.tasks"/>
+ <typedef resource="cpptasks.types"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+
+ <property name="LINK_OUTPUT_TYPE" value="static"/>
+ <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>
+
+ <target name="GenTool" depends="init, Tool">
+ <echo message="The EDK Tool: ${ToolName} build has completed!"/>
+ </target>
+
+ <target name="init">
+ <echo message="Building the EDK Tool: ${ToolName}"/>
+ <mkdir dir="${BUILD_DIR}"/>
+ </target>
+
+ <target name="Tool" depends="init">
+ <cc name="${ToolChain}" objdir="${BUILD_DIR}"
+ outfile="${BIN_DIR}/${ToolName}"
+ outtype="executable"
+ optimize="speed"
+ debug="true">
+
+ <fileset dir="${basedir}/${ToolName}"
+ includes="${FileSet}"
+ defaultexcludes="TRUE"
+ excludes="*.xml *.inf"/>
+
+ <includepath path="${PACKAGE_DIR}/Include"/>
+ <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>
+ <includepath path="${PACKAGE_DIR}/Common"/>
+ <libset dir="${LIB_DIR}" libs="CommonTools"/>
+ </cc>
+ </target>
+
+ <target name="clean">
+ <echo message="Removing Intermediate Files Only"/>
+ <delete>
+ <fileset dir="${BUILD_DIR}" includes="*.obj"/>
+ </delete>
+ </target>
+
+ <target name="cleanall">
+ <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>
+ <delete failonerror="false" quiet="true" includeEmptyDirs="true">
+ <fileset dir="${BUILD_DIR}"/>
+ <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>
+ </delete>
+ </target>
+
+</project>