OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /amber/trunk/sw/tools
    from Rev 36 to Rev 61
    Reverse comparison

Rev 36 → Rev 61

/amber-elfsplitter.c
207,16 → 207,18
int main(int argc,char *argv[])
{
FILE *infile,*outfile;
unsigned char *buf;
unsigned char *inbuf;
unsigned char *outbuf;
int buf_size;
unsigned int length,i;
unsigned int StringSectionOffset;
unsigned int StringSectionOffsetFound = 0;
 
unsigned int outP;
char filename_mem[80], filename_nopath[80];
char tmp[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
FILE *file_mem;
unsigned int j, k;
unsigned int j, k, last_k;
int m;
ElfHeader *elfHeader;
Elf32_Phdr *elfProgram;
225,6 → 227,8
char* ptr=argv[1];
 
int infile_size;
int boffset;
int max_out = 0;
if (argc<2){
printf("%s ERROR: no input file specified. Quitting\n", argv[0]);
239,8 → 243,9
}
infile_size = fsize(infile);
buf=(unsigned char*)malloc(infile_size);
buf_size=fread(buf,1,infile_size,infile);
inbuf =(unsigned char*)malloc(infile_size);
outbuf=(unsigned char*)malloc(infile_size*2);
buf_size=fread(inbuf,1,infile_size,infile);
fclose(infile);
 
if ( buf_size != infile_size ) {
255,7 → 260,7
argv[0], argv[1], infile_size);
}
elfHeader=(ElfHeader*)buf;
elfHeader=(ElfHeader*)inbuf;
 
#ifdef DEBUG
strncpy(tmp, (char*)elfHeader->e_ident+1, 3);
281,7 → 286,7
#endif
 
for(i=0;i<elfHeader->e_phnum;++i) {
elfProgram = (Elf32_Phdr*)(buf+elfHeader->e_phoff+elfHeader->e_phentsize*i);
elfProgram = (Elf32_Phdr*)(inbuf+elfHeader->e_phoff+elfHeader->e_phentsize*i);
 
length=elfProgram->p_vaddr+elfProgram->p_memsz;
#ifdef DEBUG
294,7 → 299,7
containing the section names
*/
for(i=0;i<elfHeader->e_shnum;++i) {
elfSection=(Elf32_Shdr*)(buf+elfHeader->e_shoff+elfHeader->e_shentsize*i);
elfSection=(Elf32_Shdr*)(inbuf+elfHeader->e_shoff+elfHeader->e_shentsize*i);
if (elfSection->sh_type == SHT_STRTAB && !StringSectionOffsetFound) {
StringSectionOffset = elfSection->sh_offset;
StringSectionOffsetFound = 1;
302,39 → 307,50
}
 
for(i=0;i<elfHeader->e_shnum;++i) {
elfSection=(Elf32_Shdr*)(buf+elfHeader->e_shoff+elfHeader->e_shentsize*i);
elfSection=(Elf32_Shdr*)(inbuf+elfHeader->e_shoff+elfHeader->e_shentsize*i);
 
/* Get the byte offset and use it to word-align the data */
boffset = elfSection->sh_offset & 3;
 
if (elfSection->sh_type != SHT_NULL) {
printf("// Section name %s\n", (char*)(buf+StringSectionOffset+elfSection->sh_name));
printf("// Type %s, Size 0x%x, Start address 0x%08x, File offset 0x%x\n",
printf("// Section name %s\n", (char*)(inbuf+StringSectionOffset+elfSection->sh_name));
printf("// Type %s, Size 0x%x, Start address 0x%08x, File offset 0x%x, boffset %d\n",
pSHT(elfSection->sh_type),
elfSection->sh_size,
elfSection->sh_addr,
elfSection->sh_offset);
elfSection->sh_offset,
boffset);
}
 
/* section with non-zero bits, can be either text or data */
if (elfSection->sh_type == SHT_PROGBITS && elfSection->sh_size != 0) {
for (j=0; j<elfSection->sh_size; j=j+4) {
for (j=0; j<elfSection->sh_size; j++) {
k = j + elfSection->sh_offset;
printf("@%08x %02x%02x%02x%02x\n",
(elfSection->sh_addr + j), /* use word addresses */
buf[k+3], buf[k+2], buf[k+1], buf[k+0]);
outP = elfSection->sh_addr + j;
outbuf[outP] = inbuf[k];
if (outP > max_out) max_out = outP;
}
}
if (elfSection->sh_type == SHT_NOBITS && elfSection->sh_size != 0) {
printf("// .bss Dump Zeros\n");
for (j=elfSection->sh_offset; j<elfSection->sh_offset+elfSection->sh_size; j=j+4) {
printf("@%08x 00000000\n",
(j + elfSection->sh_addr - elfSection->sh_offset)); /* use word addresses */
for (j=0; j<elfSection->sh_size; j++) {
outP = j + elfSection->sh_addr;
outbuf[outP] = 0;
if (outP > max_out) max_out = outP;
}
}
}
 
 
}
free(buf);
for(j=0;j<max_out+3;j=j+4) {
printf("@%08x %02x%02x%02x%02x\n", j, outbuf[j+3], outbuf[j+2], outbuf[j+1], outbuf[j+0]);
}
free(inbuf);
free(outbuf);
 
return 0;
}
/amber-memparams32.sh
42,7 → 42,9
 
grep '@' $1 | awk '{print $2}' | awk -F '' '{print $1 $2}' |\
paste -d" " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | \
awk '{printf " .SRAM0_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM0_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM4_INIT_" NR-65 " ( 256%ch", 39 }} \
$32=="" {printf "00"} \
$31=="" {printf "00"} \
$30=="" {printf "00"} \
$29=="" {printf "00"} \
79,7 → 81,9
 
grep '@' $1 | awk '{print $2}' | awk -F '' '{print $3 $4}' |\
paste -d" " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | \
awk '{printf " .SRAM1_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM1_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM5_INIT_" NR-65 " ( 256%ch", 39 }} \
$32=="" {printf "00"} \
$31=="" {printf "00"} \
$30=="" {printf "00"} \
$29=="" {printf "00"} \
116,7 → 120,9
grep '@' $1 | awk '{print $2}' | awk -F '' '{print $5 $6}' |\
paste -d" " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | \
awk '{printf " .SRAM2_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM2_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM6_INIT_" NR-65 " ( 256%ch", 39 }} \
$32=="" {printf "00"} \
$31=="" {printf "00"} \
$30=="" {printf "00"} \
$29=="" {printf "00"} \
153,7 → 159,9
grep '@' $1 | awk '{print $2}' | awk -F '' '{print $7 $8}' |\
paste -d" " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | \
awk '{printf " .SRAM3_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM3_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM7_INIT_" NR-65 " ( 256%ch", 39 }} \
$32=="" {printf "00"} \
$31=="" {printf "00"} \
$30=="" {printf "00"} \
$29=="" {printf "00"} \
/amber-memparams128.sh
42,7 → 42,8
 
grep '@' $1 | awk '{print $2}' | awk 'NR%4==1' |\
paste -d" " - - - - - - - - | \
awk '{printf " .SRAM0_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM0_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM4_INIT_" NR-65 " ( 256%ch", 39 }} \
$8=="" {printf "00000000"} \
$7=="" {printf "00000000"} \
$6=="" {printf "00000000"} \
55,7 → 56,8
 
grep '@' $1 | awk '{print $2}' | awk 'NR%4==2' |\
paste -d" " - - - - - - - - | \
awk '{printf " .SRAM1_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM1_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM5_INIT_" NR-65 " ( 256%ch", 39 }} \
$8=="" {printf "00000000"} \
$7=="" {printf "00000000"} \
$6=="" {printf "00000000"} \
68,7 → 70,8
 
grep '@' $1 | awk '{print $2}' | awk 'NR%4==3' |\
paste -d" " - - - - - - - - | \
awk '{printf " .SRAM2_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM2_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM6_INIT_" NR-65 " ( 256%ch", 39 }} \
$8=="" {printf "00000000"} \
$7=="" {printf "00000000"} \
$6=="" {printf "00000000"} \
82,7 → 85,8
 
grep '@' $1 | awk '{print $2}' | awk 'NR%4==0' |\
paste -d" " - - - - - - - - | \
awk '{printf " .SRAM3_INIT_" NR-1 " ( 256%ch", 39 } \
awk '{ if (NR<=64) { printf " .SRAM3_INIT_" NR-1 " ( 256%ch", 39 } \
else if (NR<=128) { printf " .SRAM7_INIT_" NR-65 " ( 256%ch", 39 }} \
$8=="" {printf "00000000"} \
$7=="" {printf "00000000"} \
$6=="" {printf "00000000"} \
/amber-jumps.sh
78,7 → 78,7
fi
 
 
grep jump amber.dis | awk '{print $1, $4, $6, $8}' | sed 's/,//' > /tmp/jumps
grep jump amber.dis | awk '{print $1, $4, $6, $8, $10}' | sed 's/,//g' > /tmp/jumps
 
grep '>:' $TEST_DIS | sed 's/<//' | sed 's/>://' > /tmp/funcsx
 
/amber-func-jumps.c
93,9 → 93,10
 
struct func_name func_names [NAMES_SIZE];
char a[12], n[48];
char s_clk_count[12], s_from_addr[12], s_to_addr[12], s_r0[12];
char s_clk_count[12], s_from_addr[12], s_to_addr[12], s_r0[12], s_r1[12];
unsigned int from_addr, to_addr, clk_count;
unsigned int x;
char current_func_name [48] = "none";
 
unsigned int slen;
 
154,7 → 155,7
/* Assign names to jumps */
while ( (bytes_read = getline (&line_buffer, &nbytes, jumps_file)) > 0)
{
sscanf(line_buffer, "%s %s %s %s", s_clk_count, s_from_addr, s_to_addr, s_r0);
sscanf(line_buffer, "%s %s %s %s %s", s_clk_count, s_from_addr, s_to_addr, s_r0, s_r1);
if ( !conv_hstring(s_from_addr, &from_addr) )
{
185,8 → 186,8
{
mid = (start + end) / 2;
if ( to_addr >= func_names[mid].address &&
to_addr < func_names[mid+1].address )
if ( to_addr >= func_names[mid].address &&
(to_addr < func_names[mid+1].address || mid == end) )
{
found = 1;
to_func_num = mid;
203,7 → 204,11
end = mid;
}
}
if (!found)
fprintf(stderr,"WARNING: to_addr 0x%08x not found\n", to_addr);
/*
now assign a function to the from_address
this just assigns a function within the range
219,8 → 224,8
{
mid = (start + end) / 2;
if ( from_addr >= func_names[mid].address &&
from_addr < func_names[mid+1].address )
if ( from_addr >= func_names[mid].address &&
(from_addr < func_names[mid+1].address || mid == end) )
{
found = 1;
if ( strcmp ( func_names[mid].name, func_names[to_func_num].name ) )
227,10 → 232,7
{
 
if ( exact ) {
if ( func_names[to_func_num].address < 0x02000000 )
printf("%9d u %s ->", clk_count, func_names[mid].name);
else
printf("%9d %s ->", clk_count, func_names[mid].name);
printf("%9d %s ->", clk_count, func_names[mid].name);
slen = 35 - strlen ( func_names[mid].name );
if ( slen > 0 ) {
237,19 → 239,16
for (x=0;x<slen;x++) printf(" ");
}
printf("( r0 %s, r1 %s ) %s\n",
s_r0,
s_r1,
func_names[to_func_num].name);
if ( func_names[to_func_num].address < 0x02000000 )
printf("( %s ) %s u\n",
s_r0,
func_names[to_func_num].name);
else
printf("( %s ) %s\n",
s_r0,
func_names[to_func_num].name);
strcpy(current_func_name, func_names[to_func_num].name);
}
else {
printf("%9d %s <-",
else if ( strcmp(func_names[to_func_num].name, current_func_name)) {
printf("%9d %s <-",
clk_count,
func_names[to_func_num].name);
259,8 → 258,8
}
printf("( %s )\n",
s_r0);
printf("( r0 %s, r1 %s )\n",
s_r0, s_r1);
}
}
}
/Makefile
41,7 → 41,7
 
CC = gcc
 
all : amber-elfsplitter amber-func-jumps amber-bin2mem amber-mem-ascii amber-ascii-mem
all : amber-elfsplitter amber-func-jumps amber-bin2mem amber-mem-ascii amber-ascii-mem amber-pkt2mem
 
amber-elfsplitter : amber-elfsplitter.c
$(CC) amber-elfsplitter.c -o amber-elfsplitter

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.