diff options
author | lhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-10-05 23:12:07 +0000 |
---|---|---|
committer | lhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-10-05 23:12:07 +0000 |
commit | feccee87a78e68d575dbdf44b34ca0cb5a21ea8d (patch) | |
tree | c70bdaea30cf92a8555e1013fc15565138203134 /Tools/CodeTools/TianoTools/CreateMtFile | |
parent | 214b0d1914b48d651b25e58f321ddb77a46903b8 (diff) | |
download | edk2-platforms-feccee87a78e68d575dbdf44b34ca0cb5a21ea8d.tar.xz |
Restructuring for better separation of Tool packages.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1674 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/CodeTools/TianoTools/CreateMtFile')
-rw-r--r-- | Tools/CodeTools/TianoTools/CreateMtFile/CreateMtFile.c | 247 | ||||
-rw-r--r-- | Tools/CodeTools/TianoTools/CreateMtFile/build.xml | 70 |
2 files changed, 317 insertions, 0 deletions
diff --git a/Tools/CodeTools/TianoTools/CreateMtFile/CreateMtFile.c b/Tools/CodeTools/TianoTools/CreateMtFile/CreateMtFile.c new file mode 100644 index 0000000000..1c17b3de23 --- /dev/null +++ b/Tools/CodeTools/TianoTools/CreateMtFile/CreateMtFile.c @@ -0,0 +1,247 @@ +/*++
+
+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:
+
+ CreateMtFile.c
+
+Abstract:
+
+ Simple utility to create a pad file containing fixed data.
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <Common/UefiBaseTypes.h>
+
+#define PROGRAM_NAME "CreateMtFile"
+
+typedef struct {
+ INT8 *OutFileName;
+ INT8 ByteValue;
+ UINT32 FileSize;
+} OPTIONS;
+
+static
+EFI_STATUS
+ProcessArgs (
+ IN INT32 Argc,
+ IN INT8 *Argv[],
+ IN OUT OPTIONS *Options
+ );
+
+static
+void
+Usage (
+ VOID
+ );
+
+int
+main (
+ IN INT32 Argc,
+ IN INT8 *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Main entry point for this utility.
+
+Arguments:
+
+ Standard C entry point args Argc and Argv
+
+Returns:
+
+ EFI_SUCCESS if good to go
+
+--*/
+// GC_TODO: ] - add argument and description to function comment
+// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
+{
+ FILE *OutFptr;
+ OPTIONS Options;
+
+ //
+ // Process the command-line arguments.
+ //
+ if (ProcessArgs (Argc, Argv, &Options) != EFI_SUCCESS) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Open the output file
+ //
+ if ((OutFptr = fopen (Options.OutFileName, "wb")) == NULL) {
+ fprintf (
+ stdout,
+ PROGRAM_NAME " ERROR: Could not open output file '%s' for writing\n",
+ Options.OutFileName
+ );
+ return EFI_DEVICE_ERROR;
+ }
+ //
+ // Write the pad bytes. Do it the slow way (one at a time) for now.
+ //
+ while (Options.FileSize > 0) {
+ if (fwrite (&Options.ByteValue, 1, 1, OutFptr) != 1) {
+ fclose (OutFptr);
+ fprintf (stdout, PROGRAM_NAME " ERROR: Failed to write to output file\n");
+ return EFI_DEVICE_ERROR;
+ }
+
+ Options.FileSize--;
+ }
+ //
+ // Close the file
+ //
+ fclose (OutFptr);
+ return EFI_SUCCESS;
+}
+
+static
+EFI_STATUS
+ProcessArgs (
+ IN INT32 Argc,
+ IN INT8 *Argv[],
+ IN OUT OPTIONS *Options
+ )
+/*++
+
+Routine Description:
+
+ Process the command line arguments.
+
+Arguments:
+
+ Argc - argument count as passed in to the entry point function
+ Argv - array of arguments as passed in to the entry point function
+ Options - stucture of where to put the values of the parsed arguments
+
+Returns:
+
+ EFI_SUCCESS if everything looks good
+ EFI_INVALID_PARAMETER otherwise
+
+--*/
+// GC_TODO: ] - add argument and description to function comment
+{
+ UINT32 Multiplier;
+
+ //
+ // Clear the options
+ //
+ memset ((char *) Options, 0, sizeof (OPTIONS));
+
+ //
+ // Skip program name
+ //
+ Argv++;
+ Argc--;
+ if (Argc < 2) {
+ Usage ();
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // If first arg is dash-option, then print usage.
+ //
+ if (Argv[0][0] == '-') {
+ Usage ();
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // First arg is file name
+ //
+ Options->OutFileName = Argv[0];
+ Argc--;
+ Argv++;
+
+ //
+ // Second arg is file size. Allow 0x1000, 0x100K, 1024, 1K
+ //
+ Multiplier = 1;
+ if ((Argv[0][strlen (Argv[0]) - 1] == 'k') || (Argv[0][strlen (Argv[0]) - 1] == 'K')) {
+ Multiplier = 1024;
+ }
+ //
+ // Look for 0x prefix on file size
+ //
+ if ((Argv[0][0] == '0') && ((Argv[0][1] == 'x') || (Argv[0][1] == 'X'))) {
+ if (sscanf (Argv[0], "%x", &Options->FileSize) != 1) {
+ fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);
+ Usage ();
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Otherwise must be a decimal number
+ //
+ } else {
+ if (sscanf (Argv[0], "%d", &Options->FileSize) != 1) {
+ fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);
+ Usage ();
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ Options->FileSize *= Multiplier;
+ //
+ // Assume byte value of 0xff
+ //
+ Options->ByteValue = (INT8) (UINT8) 0xFF;
+ return EFI_SUCCESS;
+}
+//
+// Print utility usage info
+//
+static
+void
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ UINT32 Index;
+ static const INT8 *Text[] = {
+ " ",
+ "Usage: "PROGRAM_NAME " OutFileName FileSize",
+ " where:",
+ " OutFileName is the name of the output file to generate",
+ " FileSize is the size of the file to create",
+ " Examples:",
+ " "PROGRAM_NAME " OutFile.bin 32K",
+ " "PROGRAM_NAME " OutFile.bin 0x1000",
+ " ",
+ NULL
+ };
+
+ for (Index = 0; Text[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Text[Index]);
+ }
+}
diff --git a/Tools/CodeTools/TianoTools/CreateMtFile/build.xml b/Tools/CodeTools/TianoTools/CreateMtFile/build.xml new file mode 100644 index 0000000000..b2272244cd --- /dev/null +++ b/Tools/CodeTools/TianoTools/CreateMtFile/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 CreateMtFile Tool
+ Copyright (c) 2006, Intel Corporation
+-->
+ <property name="ToolName" value="CreateMtFile"/>
+ <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">
+ <compilerarg value="${ExtraArgus}" if="ExtraArgus" />
+
+ <fileset dir="${basedir}/${ToolName}"
+ includes="${FileSet}"
+ defaultexcludes="TRUE"
+ excludes="*.xml *.inf"/>
+
+ <includepath path="${PACKAGE_DIR}/Include"/>
+ <includepath path="${PACKAGE_DIR}/Include/Ia32"/>
+ <includepath path="${PACKAGE_DIR}/Common"/>
+ </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>
|