diff options
Diffstat (limited to 'Tools/CCode/Source/GenCRC32Section')
-rw-r--r-- | Tools/CCode/Source/GenCRC32Section/GenCRC32Section.c | 326 | ||||
-rw-r--r-- | Tools/CCode/Source/GenCRC32Section/GenCRC32Section.h | 63 | ||||
-rw-r--r-- | Tools/CCode/Source/GenCRC32Section/build.xml | 68 |
3 files changed, 0 insertions, 457 deletions
diff --git a/Tools/CCode/Source/GenCRC32Section/GenCRC32Section.c b/Tools/CCode/Source/GenCRC32Section/GenCRC32Section.c deleted file mode 100644 index 678275a367..0000000000 --- a/Tools/CCode/Source/GenCRC32Section/GenCRC32Section.c +++ /dev/null @@ -1,326 +0,0 @@ -/*++
-
-Copyright (c) 2004-2007, 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:
-
- GenCRC32Section.c
-
-Abstract:
-
- This file contains functions required to generate a Firmware File System
- file. The code is compliant with the Tiano C Coding standards.
-
---*/
-
-#include "GenCRC32Section.h"
-
-#define UTILITY_NAME "GenCrc32Section"
-#define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 2
-
-EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
-
-EFI_STATUS
-SignSectionWithCrc32 (
- IN OUT UINT8 *FileBuffer,
- IN OUT UINT32 *BufferSize,
- IN UINT32 DataSize
- )
-/*++
-
-Routine Description:
-
- Signs the section with CRC32 and add GUIDed section header for the
- signed data. data stays in same location (overwrites source data).
-
-Arguments:
-
- FileBuffer - Buffer containing data to sign
-
- BufferSize - On input, the size of FileBuffer. On output, the size of
- actual section data (including added section header).
-
- DataSize - Length of data to Sign
-
- Key - Key to use when signing. Currently only CRC32 is supported.
-
-Returns:
-
- EFI_SUCCESS - Successful
- EFI_OUT_OF_RESOURCES - Not enough resource to complete the operation.
-
---*/
-{
-
- UINT32 Crc32Checksum;
- EFI_STATUS Status;
- UINT32 TotalSize;
- CRC32_SECTION_HEADER Crc32Header;
- UINT8 *SwapBuffer;
-
- Crc32Checksum = 0;
- SwapBuffer = NULL;
-
- if (DataSize == 0) {
- *BufferSize = 0;
-
- return EFI_SUCCESS;
- }
-
- Status = CalculateCrc32 (FileBuffer, DataSize, &Crc32Checksum);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- TotalSize = DataSize + CRC32_SECTION_HEADER_SIZE;
- Crc32Header.GuidSectionHeader.CommonHeader.Type = EFI_SECTION_GUID_DEFINED;
- Crc32Header.GuidSectionHeader.CommonHeader.Size[0] = (UINT8) (TotalSize & 0xff);
- Crc32Header.GuidSectionHeader.CommonHeader.Size[1] = (UINT8) ((TotalSize & 0xff00) >> 8);
- Crc32Header.GuidSectionHeader.CommonHeader.Size[2] = (UINT8) ((TotalSize & 0xff0000) >> 16);
- memcpy (&(Crc32Header.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID));
- Crc32Header.GuidSectionHeader.Attributes = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;
- Crc32Header.GuidSectionHeader.DataOffset = CRC32_SECTION_HEADER_SIZE;
- Crc32Header.CRC32Checksum = Crc32Checksum;
-
- SwapBuffer = (UINT8 *) malloc (DataSize);
- if (SwapBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- memcpy (SwapBuffer, FileBuffer, DataSize);
- memcpy (FileBuffer, &Crc32Header, CRC32_SECTION_HEADER_SIZE);
- memcpy (FileBuffer + CRC32_SECTION_HEADER_SIZE, SwapBuffer, DataSize);
-
- //
- // Make sure section ends on a DWORD boundary
- //
- while ((TotalSize & 0x03) != 0) {
- FileBuffer[TotalSize] = 0;
- TotalSize++;
- }
-
- *BufferSize = TotalSize;
-
- if (SwapBuffer != NULL) {
- free (SwapBuffer);
- }
-
- return EFI_SUCCESS;
-}
-
-VOID
-Version (
- VOID
- )
-/*++
-
-Routine Description:
-
- Displays the standard utility information to SDTOUT
-
-Arguments:
-
- None
-
-Returns:
-
- None
-
---*/
-{
- printf (
- "%s v%d.%d -Utility for generating Firmware File System files.\n",
- UTILITY_NAME,
- UTILITY_MAJOR_VERSION,
- UTILITY_MINOR_VERSION
- );
-}
-
-
-VOID
-Usage (
- VOID
- )
-{
- Version();
-
- printf ("\nUsage:\n");
- printf (UTILITY_NAME " -i Inputfile1 Inputfile2 -o Outputfile\n");
- printf (" -i Inputfile: specifies the input files signed to CRC32 Guided section.\n");
- printf (" -o Outputfile: specifies the output file that is a CRC32 Guided section.\n");
-}
-
-INT32
-ReadFilesContentsIntoBuffer (
- IN CHAR8 *argv[],
- IN INT32 Start,
- IN OUT UINT8 **FileBuffer,
- IN OUT UINT32 *BufferSize,
- OUT UINT32 *ContentSize,
- IN INT32 MaximumArguments
- )
-{
- INT32 Index;
- CHAR8 *FileName;
- FILE *InputFile;
- UINT8 Temp;
- UINT32 Size;
-
- FileName = NULL;
- InputFile = NULL;
- Size = 0;
- Index = 0;
-
- //
- // read all input files into one file buffer
- //
- while (argv[Start + Index][0] != '-') {
-
- FileName = argv[Start + Index];
- InputFile = fopen (FileName, "rb");
- if (InputFile == NULL) {
- Error (NULL, 0, 0, FileName, "failed to open input binary file");
- return -1;
- }
-
- fread (&Temp, sizeof (UINT8), 1, InputFile);
- while (!feof (InputFile)) {
- (*FileBuffer)[Size++] = Temp;
- fread (&Temp, sizeof (UINT8), 1, InputFile);
- }
-
- fclose (InputFile);
- InputFile = NULL;
-
- //
- // Make sure section ends on a DWORD boundary
- //
- while ((Size & 0x03) != 0) {
- (*FileBuffer)[Size] = 0;
- Size++;
- }
-
- Index++;
- if (Index == MaximumArguments) {
- break;
- }
- }
-
- *ContentSize = Size;
- return Index;
-}
-
-int
-main (
- INT32 argc,
- CHAR8 *argv[]
- )
-{
- FILE *OutputFile;
- UINT8 *FileBuffer;
- UINT32 BufferSize;
- EFI_STATUS Status;
- UINT32 ContentSize;
- CHAR8 *OutputFileName;
- INT32 ReturnValue;
- INT32 Index;
-
- OutputFile = NULL;
- FileBuffer = NULL;
- ContentSize = 0;
- OutputFileName = NULL;
-
- SetUtilityName (UTILITY_NAME);
-
- if (argc == 1) {
- Usage ();
- return -1;
- }
-
- if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
- (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
- Usage();
- return -1;
- }
-
- if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
- Version();
- return -1;
- }
-
- BufferSize = 1024 * 1024 * 16;
- FileBuffer = (UINT8 *) malloc (BufferSize * sizeof (UINT8));
- if (FileBuffer == NULL) {
- Error (NULL, 0, 0, "memory allocation failed", NULL);
- return -1;
- }
-
- ZeroMem (FileBuffer, BufferSize);
-
- for (Index = 0; Index < argc; Index++) {
- if (strcmpi (argv[Index], "-i") == 0) {
- ReturnValue = ReadFilesContentsIntoBuffer (
- argv,
- (Index + 1),
- &FileBuffer,
- &BufferSize,
- &ContentSize,
- (argc - (Index + 1))
- );
- if (ReturnValue == -1) {
- Error (NULL, 0, 0, "failed to read file contents", NULL);
- return -1;
- }
-
- Index += ReturnValue;
- }
-
- if (strcmpi (argv[Index], "-o") == 0) {
- OutputFileName = argv[Index + 1];
- }
- }
-
- OutputFile = fopen (OutputFileName, "wb");
- if (OutputFile == NULL) {
- Error (NULL, 0, 0, OutputFileName, "failed to open output binary file");
- free (FileBuffer);
- return -1;
- }
-
- /*
- //
- // make sure section ends on a DWORD boundary ??
- //
- while ( (Size & 0x03) != 0 ) {
- FileBuffer[Size] = 0;
- Size ++;
- }
-*/
- Status = SignSectionWithCrc32 (FileBuffer, &BufferSize, ContentSize);
- if (EFI_ERROR (Status)) {
- Error (NULL, 0, 0, "failed to sign section", NULL);
- free (FileBuffer);
- fclose (OutputFile);
- return -1;
- }
-
- ContentSize = fwrite (FileBuffer, sizeof (UINT8), BufferSize, OutputFile);
- if (ContentSize != BufferSize) {
- Error (NULL, 0, 0, "failed to write output buffer", NULL);
- ReturnValue = -1;
- } else {
- ReturnValue = 0;
- }
-
- free (FileBuffer);
- fclose (OutputFile);
- return ReturnValue;
-}
diff --git a/Tools/CCode/Source/GenCRC32Section/GenCRC32Section.h b/Tools/CCode/Source/GenCRC32Section/GenCRC32Section.h deleted file mode 100644 index 0875b82ad4..0000000000 --- a/Tools/CCode/Source/GenCRC32Section/GenCRC32Section.h +++ /dev/null @@ -1,63 +0,0 @@ -/*++
-
-Copyright (c) 2004, 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:
-
- GenCRC32Section.h
-
-Abstract:
-
- Header file for GenFfsFile. Mainly defines the header of section
- header for CRC32 GUID defined sections. Share with GenSection.c
-
---*/
-
-//
-// External Files Referenced
-//
-
-/* Standard Headers */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-/* MDE Headers */
-#include <Common/UefiBaseTypes.h>
-#include <Common/EfiImage.h>
-#include <Common/FirmwareVolumeImageFormat.h>
-#include <Common/FirmwareFileSystem.h>
-#include <Common/FirmwareVolumeHeader.h>
-#include <Protocol/GuidedSectionExtraction.h>
-
-/* Tool Headers */
-#include "CommonLib.h"
-#include "Crc32.h"
-#include "Compress.h"
-#include "EfiUtilityMsgs.h"
-#include "ParseInf.h"
-
-//
-// Module Coded to Tiano Coding Conventions
-//
-#ifndef _EFI_GEN_CRC32_SECTION_H
-#define _EFI_GEN_CRC32_SECTION_H
-
-
-typedef struct {
- EFI_GUID_DEFINED_SECTION GuidSectionHeader;
- UINT32 CRC32Checksum;
-} CRC32_SECTION_HEADER;
-
-#define EFI_SECTION_CRC32_GUID_DEFINED 0
-#define CRC32_SECTION_HEADER_SIZE (sizeof (CRC32_SECTION_HEADER))
-
-#endif
diff --git a/Tools/CCode/Source/GenCRC32Section/build.xml b/Tools/CCode/Source/GenCRC32Section/build.xml deleted file mode 100644 index 3ec9ce5089..0000000000 --- a/Tools/CCode/Source/GenCRC32Section/build.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?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 GenCRC32Section Tool
- Copyright (c) 2006, Intel Corporation
--->
- <property name="ToolName" value="GenCRC32Section"/>
- <property name="FileSet" value="GenCRC32Section.c GenCRC32Section.h"/>
-
- <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"
- debug="true"
- optimize="speed">
-
- <fileset dir="${basedir}/${ToolName}"
- includes="${FileSet}"/>
-
- <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}"/>
- <fileset file="${BIN_DIR}/${ToolName}.pdb"/>
- </delete>
- </target>
-
-</project>
|