mirror of https://github.com/acidanthera/audk.git
Update input of disasmembler to support IfThen construct. Add prototype dos script to build BeagleBoard.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9936 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3b9be4164b
commit
f3198cba84
|
@ -25,6 +25,7 @@
|
|||
@param OpCodePtrPtr Pointer to pointer of ARM Thumb instruction to disassemble.
|
||||
@param Thumb TRUE for Thumb(2), FALSE for ARM instruction stream
|
||||
@param Extended TRUE dump hex for instruction too.
|
||||
@param ItBlock Size of IT Block
|
||||
@param Buf Buffer to sprintf disassembly into.
|
||||
@param Size Size of Buf in bytes.
|
||||
|
||||
|
@ -34,6 +35,7 @@ DisassembleInstruction (
|
|||
IN UINT8 **OpCodePtr,
|
||||
IN BOOLEAN Thumb,
|
||||
IN BOOLEAN Extended,
|
||||
IN OUT UINT32 *ItBlock,
|
||||
OUT CHAR8 *Buf,
|
||||
OUT UINTN Size
|
||||
);
|
||||
|
|
|
@ -57,6 +57,7 @@ extern CHAR8 *gReg[];
|
|||
#define ENDIAN_FORMAT 21
|
||||
#define DATA_CBZ 22
|
||||
#define ADR_FORMAT 23
|
||||
#define IT_BLOCK 24
|
||||
|
||||
// Thumb2 address modes
|
||||
#define B_T3 200
|
||||
|
@ -110,7 +111,7 @@ typedef struct {
|
|||
THUMB_INSTRUCTIONS gOpThumb[] = {
|
||||
// Thumb 16-bit instrucitons
|
||||
// Op Mask Format
|
||||
{ "ADC" , 0x4140, 0xffc0, DATA_FORMAT5 },
|
||||
{ "ADC" , 0x4140, 0xffc0, DATA_FORMAT5 }, // ADC <Rndn>, <Rm>
|
||||
{ "ADR", 0xa000, 0xf800, ADR_FORMAT }, // ADR <Rd>, <label>
|
||||
{ "ADD" , 0x1c00, 0xfe00, DATA_FORMAT2 },
|
||||
{ "ADD" , 0x3000, 0xf800, DATA_FORMAT3 },
|
||||
|
@ -145,15 +146,15 @@ THUMB_INSTRUCTIONS gOpThumb[] = {
|
|||
{ "EOR" , 0x4040, 0xffc0, DATA_FORMAT5 },
|
||||
|
||||
{ "LDMIA" , 0xc800, 0xf800, LOAD_STORE_MULTIPLE_FORMAT1 },
|
||||
{ "LDR" , 0x6800, 0xf800, LOAD_STORE_FORMAT1 },
|
||||
{ "LDR" , 0x5800, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
{ "LDR" , 0x6800, 0xf800, LOAD_STORE_FORMAT1 }, // LDR <Rt>, [<Rn> {,#<imm>}]
|
||||
{ "LDR" , 0x5800, 0xfe00, LOAD_STORE_FORMAT2 }, // STR <Rt>, [<Rn>, <Rm>]
|
||||
{ "LDR" , 0x4800, 0xf800, LOAD_STORE_FORMAT3 },
|
||||
{ "LDR" , 0x9800, 0xf800, LOAD_STORE_FORMAT4 },
|
||||
{ "LDR" , 0x9800, 0xf800, LOAD_STORE_FORMAT4 }, // LDR <Rt>, [SP, #<imm>]
|
||||
{ "LDRB" , 0x7800, 0xf800, LOAD_STORE_FORMAT1_B },
|
||||
{ "LDRB" , 0x5c00, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
{ "LDRB" , 0x5c00, 0xfe00, LOAD_STORE_FORMAT2 }, // STR <Rt>, [<Rn>, <Rm>]
|
||||
{ "LDRH" , 0x8800, 0xf800, LOAD_STORE_FORMAT1_H },
|
||||
{ "LDRH" , 0x7a00, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
{ "LDRSB" , 0x5600, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
{ "LDRSB" , 0x5600, 0xfe00, LOAD_STORE_FORMAT2 }, // STR <Rt>, [<Rn>, <Rm>]
|
||||
{ "LDRSH" , 0x5e00, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
|
||||
{ "MOVS", 0x0000, 0xffc0, DATA_FORMAT5 }, // LSL with imm5 == 0 is a MOVS, so this must go before LSL
|
||||
|
@ -170,7 +171,7 @@ THUMB_INSTRUCTIONS gOpThumb[] = {
|
|||
{ "MUL" , 0x4340, 0xffc0, DATA_FORMAT5 },
|
||||
{ "MVN" , 0x41c0, 0xffc0, DATA_FORMAT5 },
|
||||
{ "NEG" , 0x4240, 0xffc0, DATA_FORMAT5 },
|
||||
{ "ORR" , 0x4180, 0xffc0, DATA_FORMAT5 },
|
||||
{ "ORR" , 0x4300, 0xffc0, DATA_FORMAT5 },
|
||||
{ "POP" , 0xbc00, 0xfe00, POP_FORMAT },
|
||||
{ "PUSH", 0xb400, 0xfe00, PUSH_FORMAT },
|
||||
|
||||
|
@ -183,26 +184,29 @@ THUMB_INSTRUCTIONS gOpThumb[] = {
|
|||
{ "SETEND" , 0xb650, 0xfff0, ENDIAN_FORMAT },
|
||||
|
||||
{ "STMIA" , 0xc000, 0xf800, LOAD_STORE_MULTIPLE_FORMAT1 },
|
||||
{ "STR" , 0x6000, 0xf800, LOAD_STORE_FORMAT1 },
|
||||
{ "STR" , 0x5000, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
{ "STR" , 0x4000, 0xf800, LOAD_STORE_FORMAT3 },
|
||||
{ "STR" , 0x9000, 0xf800, LOAD_STORE_FORMAT4 },
|
||||
{ "STRB" , 0x7000, 0xf800, LOAD_STORE_FORMAT1_B },
|
||||
{ "STRB" , 0x5800, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
{ "STRH" , 0x8000, 0xf800, LOAD_STORE_FORMAT1_H },
|
||||
{ "STRH" , 0x5200, 0xfe00, LOAD_STORE_FORMAT2 },
|
||||
{ "STR" , 0x6000, 0xf800, LOAD_STORE_FORMAT1 }, // STR <Rt>, [<Rn> {,#<imm>}]
|
||||
{ "STR" , 0x5000, 0xfe00, LOAD_STORE_FORMAT2 }, // STR <Rt>, [<Rn>, <Rm>]
|
||||
{ "STR" , 0x9000, 0xf800, LOAD_STORE_FORMAT4 }, // STR <Rt>, [SP, #<imm>]
|
||||
{ "STRB" , 0x7000, 0xf800, LOAD_STORE_FORMAT1_B }, // STRB <Rt>, [<Rn>, #<imm5>]
|
||||
{ "STRB" , 0x5400, 0xfe00, LOAD_STORE_FORMAT2 }, // STRB <Rt>, [<Rn>, <Rm>]
|
||||
{ "STRH" , 0x8000, 0xf800, LOAD_STORE_FORMAT1_H }, // STRH <Rt>, [<Rn>{,#<imm>}]
|
||||
{ "STRH" , 0x5200, 0xfe00, LOAD_STORE_FORMAT2 }, // STRH <Rt>, [<Rn>, <Rm>]
|
||||
|
||||
{ "SUB" , 0x1e00, 0xfe00, DATA_FORMAT2 },
|
||||
{ "SUB" , 0x3800, 0xf800, DATA_FORMAT3 },
|
||||
{ "SUB" , 0x1a00, 0xfe00, DATA_FORMAT1 },
|
||||
{ "SUB" , 0xb080, 0xff80, DATA_FORMAT7 },
|
||||
|
||||
{ "SBC" , 0x4180, 0xffc0, DATA_FORMAT5 },
|
||||
|
||||
{ "SWI" , 0xdf00, 0xff00, IMMED_8 },
|
||||
{ "SXTB", 0xb240, 0xffc0, DATA_FORMAT5 },
|
||||
{ "SXTH", 0xb200, 0xffc0, DATA_FORMAT5 },
|
||||
{ "TST" , 0x4200, 0xffc0, DATA_FORMAT5 },
|
||||
{ "UXTB", 0xb2c0, 0xffc0, DATA_FORMAT5 },
|
||||
{ "UXTH", 0xb280, 0xffc0, DATA_FORMAT5 }
|
||||
{ "UXTH", 0xb280, 0xffc0, DATA_FORMAT5 },
|
||||
|
||||
{ "IT", 0xbf00, 0xff00, IT_BLOCK }
|
||||
|
||||
};
|
||||
|
||||
|
@ -480,6 +484,7 @@ DisassembleThumbInstruction (
|
|||
IN UINT16 **OpCodePtrPtr,
|
||||
OUT CHAR8 *Buf,
|
||||
OUT UINTN Size,
|
||||
OUT UINT32 *ItBlock,
|
||||
IN BOOLEAN Extended
|
||||
)
|
||||
{
|
||||
|
@ -490,10 +495,12 @@ DisassembleThumbInstruction (
|
|||
UINT32 Offset;
|
||||
UINT16 Rd, Rn, Rm, Rt, Rt2;
|
||||
BOOLEAN H1, H2, imod;
|
||||
BOOLEAN ItFlag;
|
||||
UINT32 PC, Target, msbit, lsbit;
|
||||
CHAR8 *Cond;
|
||||
BOOLEAN S, J1, J2, P, U, W;
|
||||
UINT32 coproc, opc1, opc2, CRd, CRn, CRm;
|
||||
UINT32 Mask;
|
||||
|
||||
OpCodePtr = *OpCodePtrPtr;
|
||||
OpCode = **OpCodePtrPtr;
|
||||
|
@ -513,6 +520,14 @@ DisassembleThumbInstruction (
|
|||
// Increment by the minimum instruction size, Thumb2 could be bigger
|
||||
*OpCodePtrPtr += 1;
|
||||
|
||||
// Manage IT Block ItFlag TRUE means we are in an IT block
|
||||
if (*ItBlock != 0) {
|
||||
ItFlag = TRUE;
|
||||
*ItBlock -= 1;
|
||||
} else {
|
||||
ItFlag = FALSE;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < sizeof (gOpThumb)/sizeof (THUMB_INSTRUCTIONS); Index++) {
|
||||
if ((OpCode & gOpThumb[Index].Mask) == gOpThumb[Index].OpCode) {
|
||||
if (Extended) {
|
||||
|
@ -646,6 +661,31 @@ DisassembleThumbInstruction (
|
|||
Target = (OpCode & 0xff) << 2;
|
||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a, %08x", gReg[(OpCode >> 8) & 7], PCAlign4 (PC) + Target);
|
||||
return;
|
||||
|
||||
case IT_BLOCK:
|
||||
// ITSTATE = cond:mask OpCode[7:4]:OpCode[3:0]
|
||||
// ITSTATE[7:5] == cond[3:1]
|
||||
// ITSTATE[4] == 1st Instruction cond[0]
|
||||
// ITSTATE[3] == 2st Instruction cond[0]
|
||||
// ITSTATE[2] == 3st Instruction cond[0]
|
||||
// ITSTATE[1] == 4st Instruction cond[0]
|
||||
// ITSTATE[0] == 1 4 instruction IT block. 0 means 0,1,2 or 3 instructions
|
||||
// 1st one in ITSTATE low bits defines the number of instructions
|
||||
Mask = (OpCode & 0xf);
|
||||
if ((Mask & 0x1) == 0x1) {
|
||||
*ItBlock = 4;
|
||||
Offset += AsciiSPrint (&Buf[Offset], Size - Offset, "%a%a%a", (Mask & BIT3)?"T":"E", (Mask & BIT2)?"T":"E", (Mask & BIT1)?"T":"E");
|
||||
} else if ((OpCode & 0x3) == 0x2) {
|
||||
*ItBlock = 3;
|
||||
Offset += AsciiSPrint (&Buf[Offset], Size - Offset, "%a%a", (Mask & BIT3)?"T":"E", (Mask & BIT2)?"T":"E");
|
||||
} else if ((OpCode & 0x7) == 0x4) {
|
||||
*ItBlock = 2;
|
||||
Offset += AsciiSPrint (&Buf[Offset], Size - Offset, "%a", (Mask & BIT3)?"T":"E");
|
||||
} else if ((OpCode & 0xf) == 0x8) {
|
||||
*ItBlock = 1;
|
||||
}
|
||||
AsciiSPrint (&Buf[Offset], Size - Offset, " %a", gCondition[(OpCode >> 4) & 0xf]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1001,6 +1041,7 @@ DisassembleArmInstruction (
|
|||
@param OpCodePtrPtr Pointer to pointer of ARM Thumb instruction to disassemble.
|
||||
@param Thumb TRUE for Thumb(2), FALSE for ARM instruction stream
|
||||
@param Extended TRUE dump hex for instruction too.
|
||||
@param ItBlock Size of IT Block
|
||||
@param Buf Buffer to sprintf disassembly into.
|
||||
@param Size Size of Buf in bytes.
|
||||
|
||||
|
@ -1010,12 +1051,13 @@ DisassembleInstruction (
|
|||
IN UINT8 **OpCodePtr,
|
||||
IN BOOLEAN Thumb,
|
||||
IN BOOLEAN Extended,
|
||||
IN OUT UINT32 *ItBlock,
|
||||
OUT CHAR8 *Buf,
|
||||
OUT UINTN Size
|
||||
)
|
||||
{
|
||||
if (Thumb) {
|
||||
DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size, Extended);
|
||||
DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size, &ItBlock, Extended);
|
||||
} else {
|
||||
DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size, Extended);
|
||||
}
|
||||
|
|
|
@ -235,6 +235,7 @@ DefaultExceptionHandler (
|
|||
CHAR8 CpsrStr[32]; // char per bit. Lower 5-bits are mode that is a 3 char string
|
||||
CHAR8 Buffer[80];
|
||||
UINT8 *DisAsm;
|
||||
UINT32 ItBlock;
|
||||
|
||||
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
|
||||
DEBUG ((EFI_D_ERROR, "%a\n", CpsrStr));
|
||||
|
@ -256,7 +257,8 @@ DefaultExceptionHandler (
|
|||
|
||||
// If we come from an image it is safe to show the instruction. We know it should not fault
|
||||
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
|
||||
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, Buffer, sizeof (Buffer));
|
||||
ItBlock = 0;
|
||||
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
|
||||
DEBUG ((EFI_D_ERROR, "\n%a", Buffer));
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ EblDisassembler (
|
|||
UINT32 Address;
|
||||
UINT32 Count;
|
||||
CHAR8 Buffer[80];
|
||||
UINT32 ItBlock;
|
||||
|
||||
if (Argc < 2) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -60,9 +61,10 @@ EblDisassembler (
|
|||
Count = (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 20;
|
||||
|
||||
Ptr = (UINT8 *)(UINTN)Address;
|
||||
ItBlock = 0;
|
||||
do {
|
||||
CurrentAddress = Ptr;
|
||||
DisassembleInstruction (&Ptr, TRUE, TRUE, Buffer, sizeof (Buffer));
|
||||
DisassembleInstruction (&Ptr, TRUE, TRUE, &ItBlock, Buffer, sizeof (Buffer));
|
||||
AsciiPrint ("0x%08x: %a\n", CurrentAddress, Buffer);
|
||||
} while (Count-- > 0);
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
//TOC structure as defined by OMAP35XX TRM.
|
||||
typedef struct {
|
||||
|
@ -353,53 +353,52 @@ ConstructImage (
|
|||
fclose(OutputFile);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
)
|
||||
{
|
||||
char Ch;
|
||||
char Ch;
|
||||
unsigned char *ptr;
|
||||
int i;
|
||||
int TwoArg;
|
||||
|
||||
if (argc == 1) {
|
||||
PrintUsage ();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((Ch = getopt(argc, argv, "D:E:I:O:")) != -1) {
|
||||
switch (Ch) {
|
||||
case 'E': /* Image execution address */
|
||||
gImageExecutionAddress = strtoul (optarg, (char **)&ptr, 16);
|
||||
break;
|
||||
|
||||
case 'I': /* Input image file */
|
||||
gInputImageFile = optarg;
|
||||
break;
|
||||
for (i=1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
// TwoArg TRUE -E 0x123, FALSE -E0x1234
|
||||
TwoArg = (argv[i][2] != ' ');
|
||||
switch (argv[i][1]) {
|
||||
case 'E': /* Image execution address */
|
||||
gImageExecutionAddress = strtoul (TwoArg ? argv[i+1] : &argv[i][2], (char **)&ptr, 16);
|
||||
break;
|
||||
|
||||
case 'I': /* Input image file */
|
||||
gInputImageFile = TwoArg ? argv[i+1] : &argv[i][2];
|
||||
break;
|
||||
|
||||
case 'O': /* Output image file */
|
||||
gOutputImageFile = optarg;
|
||||
break;
|
||||
|
||||
case 'D': /* Data file */
|
||||
gDataFile = optarg;
|
||||
break;
|
||||
case 'O': /* Output image file */
|
||||
gOutputImageFile = TwoArg ? argv[i+1] : &argv[i][2];
|
||||
break;
|
||||
|
||||
case 'D': /* Data file */
|
||||
gDataFile = TwoArg ? argv[i+1] : &argv[i][2];
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if ((optopt == 'E') || (optopt == 'I') || (optopt == 'O')) {
|
||||
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
|
||||
} else if (isprint (optopt)) {
|
||||
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
||||
} else {
|
||||
fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
|
||||
}
|
||||
return 1;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
printf ("\n%d(%x) - %s %s", i, TwoArg, argv[i], TwoArg ? argv[i+1] : &argv[i][2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Prepare configuration header
|
||||
PrepareConfigurationHeader ();
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#
|
||||
# Copyright (c) 2008-2009, Apple Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
all: GenerateImage replace
|
||||
|
||||
GenerateImage: generate_image.c
|
||||
$(CC) $(CCFLAGS) $(LDFLAGS) -o GenerateImage.exe generate_image.c
|
||||
|
||||
replace: replace.c
|
||||
$(CC) $(CCFLAGS) $(LDFLAGS) -o replace.exe replace.c
|
||||
|
||||
clean:
|
||||
del GenerateImage.exe generate_image.obj replace.exe replace.obj
|
|
@ -0,0 +1,123 @@
|
|||
//
|
||||
// Quick hack to work around not having sed, or any other reasonable
|
||||
// way to edit a file from a script on Windows......
|
||||
//
|
||||
// Copyright (c) 2010, Apple Inc. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
typedef struct {
|
||||
char *Match;
|
||||
int MatchSize;
|
||||
char *Replace;
|
||||
} MATCH_PAIR;
|
||||
|
||||
//
|
||||
// argv[1] - Old File
|
||||
// argv[2] - New File
|
||||
// argv[3+n] - Match String
|
||||
// argv[4+n] - Replace string
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
FILE *In, *Out;
|
||||
char *Key, *Replace;
|
||||
int c, i, n, Len, MaxLenKey = 0, MinLenKey = INT_MAX;
|
||||
unsigned long InFileSize, InFilePos;
|
||||
MATCH_PAIR *Match;
|
||||
int MaxMatch;
|
||||
int ReadCount;
|
||||
int Found;
|
||||
|
||||
if (argc < 5) {
|
||||
// Need at least two files and two strings
|
||||
return -1;
|
||||
} else if ((argc % 2) == 0) {
|
||||
// Match and Replace string must come in pairs
|
||||
return -4;
|
||||
}
|
||||
|
||||
In = fopen (argv[1], "r");
|
||||
fseek (In, 0, SEEK_END);
|
||||
InFileSize = ftell (In);
|
||||
if (InFileSize == 0) {
|
||||
return -6;
|
||||
}
|
||||
fseek (In, 0, SEEK_SET);
|
||||
|
||||
|
||||
Out = fopen (argv[2], "w+");
|
||||
if ((In == NULL) || (Out == NULL)) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
MaxMatch = (argc - 2)/2;
|
||||
printf ("\nMaxMatch = %d:%d\n", MaxMatch, argc);
|
||||
Match = calloc (MaxMatch, sizeof (MATCH_PAIR));
|
||||
if (Match == NULL) {
|
||||
return -7;
|
||||
}
|
||||
|
||||
for (n=0; n < MaxMatch; n++) {
|
||||
Match[n].Match = argv[3 + n*2];
|
||||
Match[n].MatchSize = strlen (argv[3 + n*2]);
|
||||
Match[n].Replace = argv[3 + n*2 + 1];
|
||||
printf ("%s > %s\n", Match[n].Match, Match[n].Replace);
|
||||
if (Match[n].MatchSize > MaxLenKey) {
|
||||
// Max size of match/replace string pair
|
||||
MaxLenKey = Match[n].MatchSize;
|
||||
}
|
||||
if (Match[n].MatchSize < MinLenKey) {
|
||||
MinLenKey = Match[n].MatchSize;
|
||||
}
|
||||
}
|
||||
|
||||
Key = malloc (MaxLenKey);
|
||||
if (Key == NULL) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
InFilePos = 0;
|
||||
while (InFilePos < (InFileSize - MinLenKey)) {
|
||||
fseek (In, InFilePos, SEEK_SET);
|
||||
ReadCount = fread (Key, 1, MaxLenKey, In);
|
||||
for (i = 0, Found = FALSE;i < MaxMatch; i++) {
|
||||
if (ReadCount >= Match[i].MatchSize) {
|
||||
if (!memcmp (Key, Match[i].Match, Match[i].MatchSize)) {
|
||||
printf ("Found [%s] @ %u\n", Match[i].Match, InFilePos);
|
||||
InFilePos += (Match[i].MatchSize - 1);
|
||||
printf ("InFilePos = %u", InFilePos);
|
||||
fputs (Match[i].Replace, Out);
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Found) {
|
||||
fputc (Key[0], Out);
|
||||
}
|
||||
|
||||
InFilePos++;
|
||||
}
|
||||
|
||||
|
||||
fclose (In);
|
||||
fclose (Out);
|
||||
free (Key);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
@REM Copyright (c) 2008 - 2010, Apple, Inc. All rights reserved.
|
||||
@REM All rights reserved. This program and the accompanying materials
|
||||
@REM are licensed and made available under the terms and conditions of the BSD License
|
||||
@REM which accompanies this distribution. The full text of the license may be found at
|
||||
@REM http://opensource.org/licenses/bsd-license.php
|
||||
@REM
|
||||
@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
@REM
|
||||
|
||||
@REM Example usage of this script. default is a DEBUG build
|
||||
@REM b
|
||||
@REM b clean
|
||||
@REM b release
|
||||
@REM b release clean
|
||||
@REM b -v -y build.log
|
||||
|
||||
|
||||
CALL ..\edksetup.bat
|
||||
SET TARGET_TOOLS=RVCT31
|
||||
SET TARGET=DEBUG
|
||||
|
||||
@if /I "%1"=="RELEASE" (
|
||||
SET TARGET=RELEASE
|
||||
shift /1
|
||||
)
|
||||
|
||||
SET BUILD_ROOT=%WORKSPACE%\Build\BeagleBoard\%TARGET%_%TARGET_TOOLS%
|
||||
BUILD_ROOT=$WORKSPACE/Build/BeagleBoard/"$TARGET"_"$TARGET_TOOLS"
|
||||
|
||||
CALL build -p BeagleBoardPkg\BeagleBoardPkg.dsc -a ARM -t RVCT31 -b %TARGET% %1 %2 %3 %4 %5 %6 %7 %8
|
||||
|
||||
@if /I "%1"=="CLEAN" goto Clean
|
||||
|
||||
@REM
|
||||
@REM Ram starts at 0x80000000
|
||||
@REM OMAP 3530 TRM defines 0x80008208 as the entry point
|
||||
@REM The reset vector is caught by the mask ROM in the OMAP 3530 so that is why this entry
|
||||
@REM point looks so strange.
|
||||
@REM OMAP 3430 TRM section 26.4.8 has Image header information. (missing in OMAP 3530 TRM)
|
||||
@REM
|
||||
cd Tools
|
||||
|
||||
ECHO Building tools...
|
||||
CALL nmake
|
||||
|
||||
ECHO Patching image with ConfigurationHeader.dat
|
||||
CALL GenerateImage -D ConfigurationHeader.dat -E 0x80008208 -I ../../Build/FV/BEAGLEBOARD_EFI.fd -O ../../Build/FV/BeagleBoard_EFI_flashboot.fd
|
||||
|
||||
ECHO Patching ..\Debugger_scripts ...
|
||||
SET DEBUGGER_SCRIPT=..\Debugger_scripts
|
||||
for /f %%a IN ('dir /b %DEBUGGER_SCRIPT%\*.inc %DEBUGGER_SCRIPT%\*.cmm') do (
|
||||
CALL replace %DEBUGGER_SCRIPT%\%%a %BUILD_ROOT%\%%a ZZZZZZ %BUILD_ROOT% WWWWWW %WORKSPACE%
|
||||
)
|
||||
|
||||
cd ..
|
||||
EXIT /B
|
||||
|
||||
:Clean
|
||||
cd Tools
|
||||
CALL nmake clean
|
||||
cd ..
|
Loading…
Reference in New Issue