Mercurial > hg > Members > kono > Cerium
changeset 473:7777761e8e02
string offset for get_segment relocation code...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 03 Oct 2009 10:49:51 +0900 |
parents | 699ee087234e |
children | 077845279741 |
files | example/get_segment/spe/Hello.cc example/get_segment/spe/Hello1.cc example/get_segment/spe/fixpic.pl example/get_segment/spe/spe-main.cc |
diffstat | 4 files changed, 53 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/example/get_segment/spe/Hello.cc Fri Oct 02 23:20:25 2009 +0900 +++ b/example/get_segment/spe/Hello.cc Sat Oct 03 10:49:51 2009 +0900 @@ -6,18 +6,37 @@ SchedDefineDynamicTask(Hello,0); static int +rel_offset() +{ + unsigned int pc; + unsigned int label; + __asm__ __volatile__( +" brsl %0,____LLLL\n" +"____LLLL:" +" ila %1,____LLLL" + : "=r" (pc), "=r" (label)); + return pc-label; +} + + +static int run(SchedTask *smanager, void *rbuf, void *wbuf) { int task_id = smanager->get_param(0); unsigned int pc; __asm__ __volatile__( -" brsl %0,____LLLL\n" -"____LLLL:" +" brsl %0,____LLLL1\n" +"____LLLL1:" : "=r" (pc)); - smanager->fprintf(smanager->stderr_,"[%d] Hello, World!! Seg1 \n", task_id); - smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello); + char *fmt = "char [%0x] offset [%0x]\n"; + int offset = rel_offset(); + + smanager->fprintf(smanager->stderr_,fmt+offset, fmt, offset); + + smanager->fprintf(smanager->stderr_,"[%d] Hello, World!! Seg1 \n"+offset, task_id); + smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0x\n"+offset,pc, (unsigned int)&runTask_Hello); return 0; }
--- a/example/get_segment/spe/Hello1.cc Fri Oct 02 23:20:25 2009 +0900 +++ b/example/get_segment/spe/Hello1.cc Sat Oct 03 10:49:51 2009 +0900 @@ -5,18 +5,38 @@ SchedDefineDynamicTask(Hello1,1); static int +rel_offset() +{ + unsigned int pc; + unsigned int label; + __asm__ __volatile__( +" brsl %0,_LLLL\n" +"_LLLL:" +" ila %1,_LLLL" + : "=r" (pc), "=r" (label)); + return pc-label; +} + + +static int run(SchedTask *smanager, void *rbuf, void *wbuf) { int task_id = smanager->get_param(0); unsigned int pc; __asm__ __volatile__( -" brsl %0,____LLLL\n" -"____LLLL:" +" brsl %0,1f\n" +"1:" : "=r" (pc)); - smanager->fprintf(smanager->stderr_,"[%d] Hello, World Seg 2!!\n", task_id); - smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello1); + char *fmt = "char [%0x] offset [%0x]\n"; + int offset = rel_offset(); + + smanager->fprintf(smanager->stderr_,fmt+offset, fmt, offset); + + + smanager->fprintf(smanager->stderr_,"[%d] Hello, World Seg 2!!\n"+offset, task_id); + smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0x\n"+offset,pc, (unsigned int)&runTask_Hello1); return 0; }
--- a/example/get_segment/spe/fixpic.pl Fri Oct 02 23:20:25 2009 +0900 +++ b/example/get_segment/spe/fixpic.pl Sat Oct 03 10:49:51 2009 +0900 @@ -46,14 +46,17 @@ for(@line) { if (! /^#/) { - next if (/\.section\s+\.rodata/); - if(/\s(br)\s+([^\s]+)/||/\s(brsl|hbrr)\s+[^\s]+,\s*([^\s]+)/) { + next if (/\.section\s+\.rodata/); + if (/\s(brsl|hbrr|br)\s+[^\s]+,\s*(\d+[fb])/) { + } elsif(/\s(br)\s+([^\s]+)/||/\s(brsl|hbrr)\s+[^\s]+,\s*([^\s]+)/) { my $name = $2; if (! defined $local{$name} || defined $weak{$name} ) { s/hbrr/hbra/ || s/brsl/brasl/ || s/br/bra/ ; } + } + # } elsif(/\s(lqr)\s+(\$\d+),([^\s]+)/) { # my $name = $2; # if (! defined $local{$name} || defined $weak{$name} ) { @@ -66,7 +69,6 @@ # } else { # $_ = "\tai\t$2,\$0,$3-.\n"; # } - } } print ; }
--- a/example/get_segment/spe/spe-main.cc Fri Oct 02 23:20:25 2009 +0900 +++ b/example/get_segment/spe/spe-main.cc Sat Oct 03 10:49:51 2009 +0900 @@ -47,7 +47,7 @@ ov = _ovly_table; - fprintf(stderr,"memaddr = %d\n",sizeof(memaddr)); + fprintf(stderr,"memaddr = %ld\n",sizeof(memaddr)); for(i=0;i<2;i++) { unsigned long long adr = _EAR_; fprintf(stderr,"ovly_table[%d] vma=%08x size=%08x offset=%08x address=%08llx\n",