mirror of https://github.com/acidanthera/audk.git
Adding tools for IPF development.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1865 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
a7a7033316
commit
71ea530c37
|
@ -0,0 +1,490 @@
|
||||||
|
/*++
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
GenBsfFixup.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Utility to Fixup the SEC component for IA32. This is an
|
||||||
|
interim tool in place of the full GenBsfImage support for
|
||||||
|
IA32.
|
||||||
|
This tool supports the Synch3 update
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
#include "BaseTypes.h"
|
||||||
|
#include "UefiBaseTypes.h"
|
||||||
|
#include "EfiImage.h"
|
||||||
|
#include "FirmwareVolumeHeader.h"
|
||||||
|
#include "FirmwareVolumeImageFormat.h"
|
||||||
|
#include "ParseInf.h"
|
||||||
|
#include "CommonLib.h"
|
||||||
|
#include "FirmwareFileSystem.h"
|
||||||
|
#include "FvLib.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// BugBug -- this port to the new FFS is really weird.
|
||||||
|
// A lot of the file-header stuff has been ported, but
|
||||||
|
// not the section information.
|
||||||
|
//
|
||||||
|
#define TOOLVERSION "0.1"
|
||||||
|
|
||||||
|
UINT32 gFixup;
|
||||||
|
|
||||||
|
UINT32
|
||||||
|
GetOccupiedSize (
|
||||||
|
IN UINT32 ActualSize,
|
||||||
|
IN UINT32 Alignment
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
GC_TODO: Add function description
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
ActualSize - GC_TODO: add argument description
|
||||||
|
Alignment - GC_TODO: add argument description
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
GC_TODO: add return values
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINT32 OccupiedSize;
|
||||||
|
|
||||||
|
OccupiedSize = ActualSize;
|
||||||
|
while ((OccupiedSize & (Alignment - 1)) != 0) {
|
||||||
|
OccupiedSize++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OccupiedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ReadHeader (
|
||||||
|
FILE *In,
|
||||||
|
UINT32 *FvSize
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Reads in Firmware Volume information from the volume header file.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
In: Firmware Volume header file to read from
|
||||||
|
FvSize: Size of Firmware Volume
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
int: Number of bytes read
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
|
||||||
|
EFI_FV_BLOCK_MAP_ENTRY BlockMap;
|
||||||
|
INT32 SigTemp[2];
|
||||||
|
INT32 Invert;
|
||||||
|
INT32 bytesread;
|
||||||
|
UINT32 size;
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
Invert = 0;
|
||||||
|
bytesread = 0;
|
||||||
|
|
||||||
|
if (In == NULL) {
|
||||||
|
printf ("Error: Input file is NULL.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fread (&VolumeHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, In);
|
||||||
|
bytesread = sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY);
|
||||||
|
SigTemp[0] = VolumeHeader.Signature;
|
||||||
|
SigTemp[1] = 0;
|
||||||
|
|
||||||
|
if (VolumeHeader.Attributes & EFI_FVB_ERASE_POLARITY) {
|
||||||
|
Invert = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
fread (&BlockMap, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, In);
|
||||||
|
bytesread += sizeof (EFI_FV_BLOCK_MAP_ENTRY);
|
||||||
|
|
||||||
|
if (BlockMap.NumBlocks != 0) {
|
||||||
|
size += BlockMap.NumBlocks * BlockMap.BlockLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (BlockMap.NumBlocks != 0);
|
||||||
|
|
||||||
|
*FvSize = size;
|
||||||
|
rewind (In);
|
||||||
|
|
||||||
|
if (Invert == 1) {
|
||||||
|
bytesread *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytesread;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32
|
||||||
|
GetSectionLength (
|
||||||
|
IN UINT32 *Length
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Converts a UINT8[3] array to a UINT32
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Length A pointer to a 3 byte array
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
UINT32: The length.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
return *Length & 0x00FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Readfile (
|
||||||
|
UINT8 *FvImage,
|
||||||
|
int bytes,
|
||||||
|
int Invert
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
GC_TODO: Add function description
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
FvImage - GC_TODO: add argument description
|
||||||
|
bytes - GC_TODO: add argument description
|
||||||
|
Invert - GC_TODO: add argument description
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
GC_TODO: add return values
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINT32 FileLength;
|
||||||
|
UINT32 OccupiedFileLength;
|
||||||
|
EFI_FFS_FILE_HEADER *FileHeader;
|
||||||
|
UINT8 FileState;
|
||||||
|
UINT8 Checksum;
|
||||||
|
UINT8 *Ptr;
|
||||||
|
UINT32 SectionLength;
|
||||||
|
EFI_COMMON_SECTION_HEADER *SectionHeader;
|
||||||
|
EFI_IMAGE_NT_HEADERS *PeHeader;
|
||||||
|
UINT32 PeiCoreOffset;
|
||||||
|
|
||||||
|
Ptr = FvImage + bytes;
|
||||||
|
|
||||||
|
FileHeader = (EFI_FFS_FILE_HEADER *) Ptr;
|
||||||
|
|
||||||
|
FileState = GetFileState ((UINT8) Invert, FileHeader);
|
||||||
|
|
||||||
|
switch (FileState) {
|
||||||
|
case EFI_FILE_HEADER_CONSTRUCTION:
|
||||||
|
case EFI_FILE_HEADER_INVALID:
|
||||||
|
return sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
|
||||||
|
case EFI_FILE_HEADER_VALID:
|
||||||
|
Checksum = CalculateSum8 ((UINT8 *) FileHeader, sizeof (EFI_FFS_FILE_HEADER));
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->IntegrityCheck.Checksum.File);
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->State);
|
||||||
|
if (Checksum != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Now do the fixup stuff - begin
|
||||||
|
//
|
||||||
|
if (FileHeader->Type == EFI_FV_FILETYPE_PEI_CORE) {
|
||||||
|
SectionHeader = (EFI_COMMON_SECTION_HEADER *) FileHeader + sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
SectionLength = GetSectionLength ((UINT32 *) &SectionHeader->Size[0]);
|
||||||
|
|
||||||
|
printf ("Section length is 0x%X\n", SectionLength);
|
||||||
|
|
||||||
|
if (SectionHeader->Type == EFI_SECTION_PE32) {
|
||||||
|
|
||||||
|
gFixup = bytes + sizeof (EFI_FFS_FILE_HEADER) + sizeof (EFI_COMMON_SECTION_HEADER);
|
||||||
|
|
||||||
|
PeHeader = (EFI_IMAGE_NT_HEADERS *) Ptr + sizeof (EFI_FFS_FILE_HEADER) + sizeof (EFI_COMMON_SECTION_HEADER);
|
||||||
|
|
||||||
|
if (((EFI_IMAGE_DOS_HEADER *) PeHeader)->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
|
||||||
|
//
|
||||||
|
// DOS image header is present, so read the PE header after the DOS image header
|
||||||
|
//
|
||||||
|
PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) PeHeader + (UINTN) ((((EFI_IMAGE_DOS_HEADER *) PeHeader)->e_lfanew) & 0x0ffff));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PeiCoreOffset = (UINTN) ((UINTN) (PeHeader->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));
|
||||||
|
|
||||||
|
gFixup += PeiCoreOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileLength = GetLength (FileHeader->Size);
|
||||||
|
OccupiedFileLength = GetOccupiedSize (FileLength, 8);
|
||||||
|
return OccupiedFileLength;
|
||||||
|
|
||||||
|
case EFI_FILE_DATA_VALID:
|
||||||
|
//
|
||||||
|
// Calculate header checksum
|
||||||
|
//
|
||||||
|
Checksum = CalculateSum8 ((UINT8 *) FileHeader, sizeof (EFI_FFS_FILE_HEADER));
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->IntegrityCheck.Checksum.File);
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->State);
|
||||||
|
if (Checksum != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Determine file length
|
||||||
|
//
|
||||||
|
FileLength = GetLength (FileHeader->Size);
|
||||||
|
OccupiedFileLength = GetOccupiedSize (FileLength, 8);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if file checksum is valid or fixed
|
||||||
|
//
|
||||||
|
if (FileHeader->Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||||
|
Checksum = CalculateSum8 (Ptr, FileLength);
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->State);
|
||||||
|
if (Checksum != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (FileHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EFI_FILE_MARKED_FOR_UPDATE:
|
||||||
|
case EFI_FILE_DELETED:
|
||||||
|
//
|
||||||
|
// Calculate header checksum
|
||||||
|
//
|
||||||
|
Checksum = CalculateSum8 ((UINT8 *) FileHeader, sizeof (EFI_FFS_FILE_HEADER));
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->IntegrityCheck.Checksum.File);
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->State);
|
||||||
|
if (Checksum != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Determine file length
|
||||||
|
//
|
||||||
|
FileLength = GetLength (FileHeader->Size);
|
||||||
|
OccupiedFileLength = GetOccupiedSize (FileLength, 8);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if file checksum is valid or fixed
|
||||||
|
//
|
||||||
|
if (FileHeader->Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||||
|
Checksum = CalculateSum8 (Ptr, FileLength);
|
||||||
|
Checksum = (UINT8) (Checksum - FileHeader->State);
|
||||||
|
if (Checksum != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (FileHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return OccupiedFileLength;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OccupiedFileLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
int argc,
|
||||||
|
char*argv[]
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Runs GenBsfFixup
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
argc: number of command line arguments
|
||||||
|
|
||||||
|
arg[0] = This file name
|
||||||
|
arg[1] = Firmware Volume Name
|
||||||
|
arg[2] = Base Address to relocate
|
||||||
|
arg[3] = Relative offset of the fixup to perform
|
||||||
|
arg[4] = Output File Name
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
int: 0 code success, -1 code failure
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
FILE *In;
|
||||||
|
FILE *Out;
|
||||||
|
int ByteStart;
|
||||||
|
int Invert;
|
||||||
|
int Index;
|
||||||
|
int cnt;
|
||||||
|
UINT8 *FvImage;
|
||||||
|
int ByteRead;
|
||||||
|
UINT32 FvSize;
|
||||||
|
UINT64 delta;
|
||||||
|
UINT32 Idx;
|
||||||
|
UINT64 FvOffset;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Index = 0;
|
||||||
|
Invert = 0;
|
||||||
|
printf (
|
||||||
|
"GenBsfFixup EFI 2.0. Version %s, %s\n""Copyright (c) 2000-2001, Intel Corporation\n\n",
|
||||||
|
TOOLVERSION,
|
||||||
|
__DATE__
|
||||||
|
);
|
||||||
|
|
||||||
|
if (argc != 5) {
|
||||||
|
printf ("Usage:\n"" GenBsfFixup FvVolumeImageFile AddressOfFvInMemory OffsetOfFixup OutputFileName\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
In = fopen (argv[1], "rb");
|
||||||
|
|
||||||
|
if (In == NULL) {
|
||||||
|
printf ("Unable to open FV image file \"%s\"\n", argv[1]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteStart = ReadHeader (In, &FvSize);
|
||||||
|
|
||||||
|
if (ByteStart < 0) {
|
||||||
|
Invert = 1;
|
||||||
|
ByteStart *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FvImage = malloc (FvSize);
|
||||||
|
if (FvImage == NULL) {
|
||||||
|
printf ("Cannot allocate memory\n");
|
||||||
|
fclose (In);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteRead = fread (FvImage, 1, FvSize, In);
|
||||||
|
|
||||||
|
if ((unsigned int) ByteRead != FvSize) {
|
||||||
|
printf ("Read File error\n");
|
||||||
|
fclose (In);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cnt = 0;
|
||||||
|
while ((unsigned int) ByteStart < FvSize && cnt != -1) {
|
||||||
|
cnt = Readfile (FvImage, ByteStart, Invert);
|
||||||
|
|
||||||
|
if (cnt != -1) {
|
||||||
|
ByteStart += cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cnt != sizeof (EFI_FFS_FILE_HEADER)) {
|
||||||
|
Index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cnt == -1) {
|
||||||
|
printf ("Firmware Volume image corrupted\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (In);
|
||||||
|
|
||||||
|
Out = fopen (argv[4], "wb");
|
||||||
|
|
||||||
|
if (Out == NULL) {
|
||||||
|
printf ("Unable to open FV image file \"%s\"\n", argv[4]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
In = fopen (argv[1], "rb");
|
||||||
|
|
||||||
|
if (In == NULL) {
|
||||||
|
printf ("Unable to open FV image file \"%s\"\n", argv[1]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gFixup != 0) {
|
||||||
|
|
||||||
|
printf ("Fixup of 0x%X\n", gFixup);
|
||||||
|
|
||||||
|
Status = AsciiStringToUint64 (argv[2], TRUE, &FvOffset);
|
||||||
|
|
||||||
|
gFixup += (UINT32) FvOffset;
|
||||||
|
|
||||||
|
ByteStart = ReadHeader (In, &FvSize);
|
||||||
|
|
||||||
|
Readfile (FvImage, ByteStart, Invert);
|
||||||
|
|
||||||
|
cnt = 0;
|
||||||
|
Status = AsciiStringToUint64 (argv[3], TRUE, &delta);
|
||||||
|
|
||||||
|
fclose (In);
|
||||||
|
In = fopen (argv[1], "rb");
|
||||||
|
|
||||||
|
if (In == NULL) {
|
||||||
|
printf ("Unable to open FV image file \"%s\"\n", argv[1]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Idx = 0; Idx < delta - FvOffset; Idx++) {
|
||||||
|
fputc (fgetc (In), Out);
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite (&gFixup, sizeof (UINT32), 1, Out);
|
||||||
|
fseek (In, sizeof (UINT32), SEEK_CUR);
|
||||||
|
|
||||||
|
for (Idx = 0; Idx < FvSize - (delta - FvOffset) - sizeof (UINT32); Idx++) {
|
||||||
|
fputc (fgetc (In), Out);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (In);
|
||||||
|
fclose (Out);
|
||||||
|
} else {
|
||||||
|
printf ("There was no fixup to perform\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
free (FvImage);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?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 GenFvImage Tool
|
||||||
|
Copyright (c) 2006, Intel Corporation
|
||||||
|
-->
|
||||||
|
<property name="ToolName" value="GenBsfFixup"/>
|
||||||
|
<property name="FileSet" value="GenBsfFixup.c"/>
|
||||||
|
|
||||||
|
<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}"/>
|
||||||
|
<if>
|
||||||
|
<istrue value="${OSX}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value=""/>
|
||||||
|
<property name="syslibs" value=""/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<istrue value="${cygwin}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs"/>
|
||||||
|
<property name="syslibs" value="uuid"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<istrue value="${msft}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value=""/>
|
||||||
|
<property name="syslibs" value="uuid"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<istrue value="${linux}"/>
|
||||||
|
<then>
|
||||||
|
<if>
|
||||||
|
<istrue value="${x86_64_linux}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value="/lib64"/>
|
||||||
|
</then>
|
||||||
|
<else>
|
||||||
|
<property name="syslibdirs" value="/usr/lib"/>
|
||||||
|
</else>
|
||||||
|
</if>
|
||||||
|
<property name="syslibs" value="uuid"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
<echo message="syslibdirs set to: ${syslibdirs}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="Tool" depends="init, GenBsfFixup"/>
|
||||||
|
|
||||||
|
<target name="GenBsfFixup" >
|
||||||
|
<cc name="${ToolChain}" objdir="${BUILD_DIR}"
|
||||||
|
outfile="${BIN_DIR}/${ToolName}"
|
||||||
|
outtype="executable"
|
||||||
|
debug="true"
|
||||||
|
optimize="speed">
|
||||||
|
<compilerarg value="${ExtraArgus}" if="ExtraArgus" />
|
||||||
|
|
||||||
|
<defineset>
|
||||||
|
<define name="BUILDING_TOOLS"/>
|
||||||
|
<define name="TOOL_BUILD_IA32_TARGET"/>
|
||||||
|
</defineset>
|
||||||
|
|
||||||
|
<fileset dir="${basedir}/${ToolName}"
|
||||||
|
includes="${FileSet}"/>
|
||||||
|
|
||||||
|
<includepath path="${PACKAGE_DIR}/${ToolName}"/>
|
||||||
|
<includepath path="${PACKAGE_DIR}/Include"/>
|
||||||
|
<includepath path="${PACKAGE_DIR}/Include/Common"/>
|
||||||
|
<includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>
|
||||||
|
<includepath path="${PACKAGE_DIR}/Common"/>
|
||||||
|
<libset dir="${LIB_DIR}" libs="CommonTools"/>
|
||||||
|
|
||||||
|
<linkerarg value="/nodefaultlib:libc.lib" if="msft"/>
|
||||||
|
<syslibset dir="${syslibdirs}" libs="${syslibs}" if="cyglinux"/>
|
||||||
|
<syslibset libs="RpcRT4" if="msft"/>
|
||||||
|
</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}_Ia32${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_X64${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_Ipf${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_Ia32.pdb"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_X64.pdb"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}.pdb"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_Ipf.pdb"/>
|
||||||
|
</delete>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,633 @@
|
||||||
|
/*++
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
GenBsfImage.h
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
This file contains the relevant declarations required
|
||||||
|
to generate Boot Strap File
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// Module Coded to EFI 2.0 Coding Conventions
|
||||||
|
//
|
||||||
|
#ifndef _EFI_GEN_BSF_IMAGE_H
|
||||||
|
#define _EFI_GEN_BSF_IMAGE_H
|
||||||
|
|
||||||
|
//
|
||||||
|
// External Files Referenced
|
||||||
|
//
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include "assert.h"
|
||||||
|
// #include "TianoCommon.h"
|
||||||
|
#include "Common/FirmwareFileSystem.h"
|
||||||
|
#include "Common/FirmwareVolumeHeader.h"
|
||||||
|
#include "ParseInf.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Internal Constants
|
||||||
|
//
|
||||||
|
#define EFI_IPF_VTF1_GUID \
|
||||||
|
{ \
|
||||||
|
0xfa371c9b, 0x5a86, 0x4198, 0xab, 0xc2, 0xed, 0x3f, 0xaa, 0xce, 0xb0, 0x8b \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define EFI_IPF_VTF2_GUID \
|
||||||
|
{ \
|
||||||
|
0x624a0d5a, 0x315f, 0x40b6, 0xa6, 0x33, 0xe5, 0xf7, 0xde, 0x58, 0x20, 0xa0 \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define EFI_IA32_BOOT_STRAP_GUID \
|
||||||
|
{ \
|
||||||
|
0xd4260a8d, 0x356, 0x4f45, 0x85, 0xe9, 0xad, 0x1d, 0x79, 0x22, 0x79, 0xf0 \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CV_N_TYPE(a,b) (UINT8)(((UINT8)a << 7) + (UINT8)b) // Keeps the CV and Type in same byte field
|
||||||
|
#define MAKE_VERSION(a,b) (UINT16)(((UINT16)a << 8) + (UINT16)b)
|
||||||
|
|
||||||
|
#define FILE_NAME_SIZE 256
|
||||||
|
#define COMPONENT_NAME_SIZE 128
|
||||||
|
#define BSF_INPUT_FILE "BSF.INF"
|
||||||
|
#define BSF_OUTPUT_FILE "Bsf.RAW"
|
||||||
|
#define BSF_SYM_FILE "Bsf.SYM"
|
||||||
|
#define FIT_SIGNATURE "_FIT_ "
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is IA32 seccore
|
||||||
|
//
|
||||||
|
#define COMP_TYPE_SECCORE 0x0F
|
||||||
|
|
||||||
|
//
|
||||||
|
//Fit Type Definition
|
||||||
|
//
|
||||||
|
#define COMP_TYPE_FIT_HEADER 0x00
|
||||||
|
#define COMP_TYPE_FIT_PAL_B 0x01
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is generic PAL_A
|
||||||
|
//
|
||||||
|
#define COMP_TYPE_FIT_PAL_A 0x0F
|
||||||
|
#define COMP_TYPE_FIT_PEICORE 0x10
|
||||||
|
#define COMP_TYPE_FIT_AUTOSCAN 0x30
|
||||||
|
#define COMP_TYPE_FIT_FV_BOOT 0x7E
|
||||||
|
|
||||||
|
//
|
||||||
|
//This is processor Specific PAL_A
|
||||||
|
//
|
||||||
|
#define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E
|
||||||
|
#define COMP_TYPE_FIT_UNUSED 0x7F
|
||||||
|
|
||||||
|
#define FIT_TYPE_MASK 0x7F
|
||||||
|
#define CHECKSUM_BIT_MASK 0x80
|
||||||
|
|
||||||
|
//
|
||||||
|
// IPF processor address is cached bit
|
||||||
|
//
|
||||||
|
#define IPF_CACHE_BIT 0x8000000000000000
|
||||||
|
|
||||||
|
//
|
||||||
|
// Size definition to calculate the location from top of address for
|
||||||
|
// each component
|
||||||
|
//
|
||||||
|
#define SIZE_IA32_RESET_VECT 0x10 // 16 Bytes
|
||||||
|
#define SIZE_SALE_ENTRY_POINT 0x08 // 8 Byte
|
||||||
|
#define SIZE_FIT_TABLE_ADD 0x08 // 8 Byte
|
||||||
|
#define SIZE_FIT_TABLE_PAL_A 0x10
|
||||||
|
#define SIZE_RESERVED 0x10
|
||||||
|
|
||||||
|
|
||||||
|
#define SIZE_TO_OFFSET_PAL_A_END (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
|
||||||
|
SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A + \
|
||||||
|
SIZE_RESERVED)
|
||||||
|
#define SIZE_TO_PAL_A_FIT (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
|
||||||
|
SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A)
|
||||||
|
|
||||||
|
#define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header
|
||||||
|
|
||||||
|
//
|
||||||
|
// Utility Name
|
||||||
|
//
|
||||||
|
#define UTILITY_NAME "GenBsfImage"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Utility version information
|
||||||
|
//
|
||||||
|
#define UTILITY_MAJOR_VERSION 0
|
||||||
|
#define UTILITY_MINOR_VERSION 0
|
||||||
|
#define UTILITY_DATE __DATE__
|
||||||
|
|
||||||
|
//
|
||||||
|
// The maximum number of arguments accepted from the command line.
|
||||||
|
//
|
||||||
|
#define ONE_BSF_ARGS 5
|
||||||
|
#define TWO_BSF_ARGS 9
|
||||||
|
|
||||||
|
//
|
||||||
|
// The number of IA32 bsf arguments accepted from the command line.
|
||||||
|
//
|
||||||
|
#define IA32_ARGS 3
|
||||||
|
|
||||||
|
#define IA32_SOFT_FIT "IA32BsfAddress.inf"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Internal Data Structure
|
||||||
|
//
|
||||||
|
typedef enum _LOC_TYPE
|
||||||
|
{
|
||||||
|
NONE, // In case there is - INF file
|
||||||
|
FIRST_VTF, // First VTF
|
||||||
|
SECOND_VTF, // Outside BSF
|
||||||
|
} LOC_TYPE;
|
||||||
|
|
||||||
|
typedef struct _PARSED_BSF_INFO {
|
||||||
|
CHAR8 CompName[COMPONENT_NAME_SIZE];
|
||||||
|
LOC_TYPE LocationType;
|
||||||
|
UINT8 CompType;
|
||||||
|
UINT8 MajorVer;
|
||||||
|
UINT8 MinorVer;
|
||||||
|
UINT8 CheckSumRequired;
|
||||||
|
BOOLEAN VersionPresent; // If it is TRUE, then, Version is in INF file
|
||||||
|
BOOLEAN PreferredSize;
|
||||||
|
BOOLEAN PreferredAddress;
|
||||||
|
CHAR8 CompBinName[FILE_NAME_SIZE];
|
||||||
|
CHAR8 CompSymName[FILE_NAME_SIZE];
|
||||||
|
UINTN CompSize;
|
||||||
|
UINT64 CompPreferredAddress;
|
||||||
|
UINT32 Align;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
|
||||||
|
// Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
|
||||||
|
// Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
|
||||||
|
// Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedBsfInfo *' to 'struct _PARSED_BSF_INFO *'
|
||||||
|
//
|
||||||
|
struct _PARSED_BSF_INFO *NextBsfInfo;
|
||||||
|
} PARSED_BSF_INFO;
|
||||||
|
|
||||||
|
#pragma pack (1)
|
||||||
|
typedef struct {
|
||||||
|
UINT64 CompAddress;
|
||||||
|
UINT32 CompSize;
|
||||||
|
UINT16 CompVersion;
|
||||||
|
UINT8 CvAndType;
|
||||||
|
UINT8 CheckSum;
|
||||||
|
} FIT_TABLE;
|
||||||
|
#pragma pack ()
|
||||||
|
|
||||||
|
//
|
||||||
|
// The function that displays general utility information
|
||||||
|
//
|
||||||
|
VOID
|
||||||
|
PrintUtilityInfo (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Displays the standard utility information to SDTOUT
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// The function that displays the utility usage message.
|
||||||
|
//
|
||||||
|
VOID
|
||||||
|
PrintUsage (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Displays the utility usage syntax to STDOUT
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Other Function Prototype Declarations
|
||||||
|
//
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
UpdateBsfBuffer(
|
||||||
|
IN UINT64 StartAddress,
|
||||||
|
IN UINT8 *Buffer,
|
||||||
|
IN UINT64 DataSize,
|
||||||
|
IN LOC_TYPE LocType
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Update the Firmware Volume Buffer with requested buffer data
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
StartAddress - StartAddress in buffer. This number will automatically
|
||||||
|
point to right address in buffer where data needed
|
||||||
|
to be updated.
|
||||||
|
Buffer - Buffer pointer from data will be copied to memory mapped buffer.
|
||||||
|
DataSize - Size of the data needed to be copied.
|
||||||
|
LocType - The type of the BSF
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_ABORTED - The input parameter is error
|
||||||
|
EFI_SUCCESS - The function completed successfully
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
UpdateSymFile (
|
||||||
|
IN UINT64 BaseAddress,
|
||||||
|
IN CHAR8 *DestFileName,
|
||||||
|
IN CHAR8 *SourceFileName
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function adds the SYM tokens in the source file to the destination file.
|
||||||
|
The SYM tokens are updated to reflect the base address.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
BaseAddress - The base address for the new SYM tokens.
|
||||||
|
DestFileName - The destination file.
|
||||||
|
SourceFileName - The source file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The function completed successfully.
|
||||||
|
EFI_INVALID_PARAMETER - One of the input parameters was invalid.
|
||||||
|
EFI_ABORTED - An error occurred.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
CalculateFitTableChecksum (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function will perform byte checksum on the FIT table, if the the checksum required
|
||||||
|
field is set to CheckSum required. If the checksum is not required then checksum byte
|
||||||
|
will have value as 0;.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
NONE
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Status - Value returned by call to CalculateChecksum8 ()
|
||||||
|
EFI_SUCCESS - The function completed successfully
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
GenerateBsfImage (
|
||||||
|
IN UINT64 StartAddress1,
|
||||||
|
IN UINT64 Size1,
|
||||||
|
IN UINT64 StartAddress2,
|
||||||
|
IN UINT64 Size2
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This is the main function which will be called from application.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
StartAddress1 - The start address of the first BSF
|
||||||
|
Size1 - The size of the first BSF
|
||||||
|
StartAddress2 - The start address of the second BSF
|
||||||
|
Size2 - The size of the second BSF
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_OUT_OF_RESOURCES - Can not allocate memory
|
||||||
|
The return value can be any of the values
|
||||||
|
returned by the calls to following functions:
|
||||||
|
GetBsfRelatedInfoFromInfFile
|
||||||
|
ProcessAndCreateBsf
|
||||||
|
UpdateIA32ResetVector
|
||||||
|
UpdateFfsHeader
|
||||||
|
WriteBsfBinary
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
PeimFixupInFitTable (
|
||||||
|
IN UINT64 StartAddress
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function is an entry point to fixup SAL-E entry point.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
StartAddress - StartAddress for PEIM.....
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The function completed successfully
|
||||||
|
EFI_ABORTED - Error Opening File
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
Generate32BsfImage (
|
||||||
|
IN UINT64 BootFileStartAddress
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This is the main IA32 function which will be called from application.
|
||||||
|
(Now this tool is not used for IA32 platform, if it will be used in future,
|
||||||
|
the relative functions need to be updated, the updating can refer to IPF
|
||||||
|
functions)
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
BootFileStartAddress - Top Address of Boot File
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
The return value can be any of the values
|
||||||
|
returned by the calls to following functions:
|
||||||
|
Get32BsfRelatedInfoFromInfFile
|
||||||
|
CreateBsfBuffer
|
||||||
|
ProcessAndCreate32Bsf
|
||||||
|
Update32FfsHeader
|
||||||
|
WriteBsfBinary
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
GetTotal32BsfSize(
|
||||||
|
IN UINT32 *BsfSize
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function calculates total size for IA32 BSF which would be needed to create
|
||||||
|
the buffer. This will be done using Passed Info link list and looking for the
|
||||||
|
size of the components which belong to BSF. The addtional file header is accounted.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
BSFSize - Pointer to the size of IA32 BSF
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_ABORTED - Returned due to one of the following resons:
|
||||||
|
(a) Error Opening File
|
||||||
|
EFI_SUCCESS - The fuction completes successfully
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
ProcessAndCreate32Bsf (
|
||||||
|
IN UINT64 Size
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function process the link list created during INF file parsing
|
||||||
|
and create component in IA32 BSF
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Size - Size of the Firmware Volume of which, this BSF belongs to.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_UNSUPPORTED - Unknown component type
|
||||||
|
EFI_SUCCESS - The function completed successfully
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
CreateAndUpdateSeccore (
|
||||||
|
IN PARSED_BSF_INFO *BsfInfo
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function reads the binary file for seccore and update them
|
||||||
|
in IA32 BSF Buffer
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
BsfInfo - Pointer to Parsed Info
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_ABORTED - Due to one of the following reasons:
|
||||||
|
(a)Error Opening File
|
||||||
|
(b)The PAL_A Size is more than specified size status
|
||||||
|
One of the values mentioned below returned from
|
||||||
|
call to UpdateSymFile
|
||||||
|
EFI_SUCCESS - The function completed successfully.
|
||||||
|
EFI_INVALID_PARAMETER - One of the input parameters was invalid.
|
||||||
|
EFI_ABORTED - An error occurred.UpdateSymFile
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
CreateAndUpdate32Component (
|
||||||
|
IN PARSED_BSF_INFO *BsfInfo
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function reads the binary file for each components. Add it at aligned address.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
BsfInfo - Pointer to Parsed Info
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The function completed successful
|
||||||
|
EFI_ABORTED - Aborted due to one of the many reasons like:
|
||||||
|
(a) Component Size greater than the specified size.
|
||||||
|
(b) Error opening files.
|
||||||
|
EFI_INVALID_PARAMETER - Value returned from call to UpdateEntryPoint()
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
Update32FfsHeader(
|
||||||
|
IN UINT32 BsfSize
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Update the Firmware Volume Buffer with requested buffer data
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
BsfSize - Size of the IA32 BSF
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - The function completed successfully
|
||||||
|
EFI_INVALID_PARAMETER - The Ffs File Header Pointer is NULL
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
Get32BsfRelatedInfoFromInfFile (
|
||||||
|
IN CHAR8 *FileName
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function reads the input file, parse it and create a list of tokens
|
||||||
|
which is parsed and used, to intialize the data related to IA32 BSF
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
FileName FileName which needed to be read to parse data
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_ABORTED Error in opening file
|
||||||
|
EFI_INVALID_PARAMETER File doesn't contain any valid informations
|
||||||
|
EFI_OUT_OF_RESOURCES Malloc Failed
|
||||||
|
EFI_SUCCESS The function completed successfully
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
Initialize32InFileInfo (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function intializes the relevant global variable which is being
|
||||||
|
used to store the information retrieved from IA32 INF file.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
NONE
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
NONE
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ParseAndUpdate32Components (
|
||||||
|
IN PARSED_BSF_INFO *BsfInfo
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This function intializes the relevant global variable which is being
|
||||||
|
used to store the information retrieved from INF file.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
BsfInfo - A pointer to the BSF Info Structure
|
||||||
|
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
Write32SoftFit(
|
||||||
|
IN CHAR8 *FileName,
|
||||||
|
IN PARSED_BSF_INFO *BsfInfo
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Write IA32 Firmware Volume component address from memory to a file.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
FileName Output File Name which needed to be created/
|
||||||
|
BsfInfo Parsed info link
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_ABORTED - Returned due to one of the following resons:
|
||||||
|
(a) Error Opening File
|
||||||
|
(b) Failing to copy buffers
|
||||||
|
EFI_SUCCESS - The fuction completes successfully
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,126 @@
|
||||||
|
<?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 GenFvImage Tool
|
||||||
|
Copyright (c) 2006, Intel Corporation
|
||||||
|
-->
|
||||||
|
<property name="ToolName" value="GenBsfImage"/>
|
||||||
|
<property name="FileSet" value="GenBsfImage.c"/>
|
||||||
|
|
||||||
|
<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}"/>
|
||||||
|
<if>
|
||||||
|
<istrue value="${OSX}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value=""/>
|
||||||
|
<property name="syslibs" value=""/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<istrue value="${cygwin}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs"/>
|
||||||
|
<property name="syslibs" value="uuid"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<istrue value="${msft}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value=""/>
|
||||||
|
<property name="syslibs" value="uuid"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<istrue value="${linux}"/>
|
||||||
|
<then>
|
||||||
|
<if>
|
||||||
|
<istrue value="${x86_64_linux}"/>
|
||||||
|
<then>
|
||||||
|
<property name="syslibdirs" value="/lib64"/>
|
||||||
|
</then>
|
||||||
|
<else>
|
||||||
|
<property name="syslibdirs" value="/usr/lib"/>
|
||||||
|
</else>
|
||||||
|
</if>
|
||||||
|
<property name="syslibs" value="uuid"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
<echo message="syslibdirs set to: ${syslibdirs}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="Tool" depends="init, GenBsfImage"/>
|
||||||
|
|
||||||
|
<target name="GenBsfImage" >
|
||||||
|
<cc name="${ToolChain}" objdir="${BUILD_DIR}"
|
||||||
|
outfile="${BIN_DIR}/${ToolName}"
|
||||||
|
outtype="executable"
|
||||||
|
debug="true"
|
||||||
|
optimize="speed">
|
||||||
|
<compilerarg value="${ExtraArgus}" if="ExtraArgus" />
|
||||||
|
|
||||||
|
<defineset>
|
||||||
|
<define name="BUILDING_TOOLS"/>
|
||||||
|
<define name="TOOL_BUILD_IA32_TARGET"/>
|
||||||
|
</defineset>
|
||||||
|
|
||||||
|
<fileset dir="${basedir}/${ToolName}"
|
||||||
|
includes="${FileSet}"/>
|
||||||
|
|
||||||
|
<includepath path="${PACKAGE_DIR}/${ToolName}"/>
|
||||||
|
<includepath path="${PACKAGE_DIR}/Include"/>
|
||||||
|
<includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>
|
||||||
|
<includepath path="${PACKAGE_DIR}/Common"/>
|
||||||
|
<libset dir="${LIB_DIR}" libs="CommonTools"/>
|
||||||
|
|
||||||
|
<!-- <linkerarg value="/nodefaultlib:libc.lib" if="msft"/>
|
||||||
|
<syslibset dir="${syslibdirs}" libs="${syslibs}" if="cyglinux"/>
|
||||||
|
<syslibset libs="RpcRT4" if="msft"/> -->
|
||||||
|
</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}_Ia32${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_X64${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_Ipf${ext_exe}"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_Ia32.pdb"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_X64.pdb"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}.pdb"/>
|
||||||
|
<fileset file="${BIN_DIR}/${ToolName}_Ipf.pdb"/>
|
||||||
|
</delete>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
Loading…
Reference in New Issue