Mercurial > hg > Game > Cerium
changeset 465:3aaa9da117f4 draft
fix get_segement
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 30 Sep 2009 11:37:15 +0900 |
parents | 0d64bdb63005 |
children | c73aff02db67 |
files | example/get_segment/README example/get_segment/spe/Hello.cc example/get_segment/spe/Hello1.cc example/get_segment/spe/Makefile example/get_segment/spe/fixpic.pl example/get_segment/spe/ovly_table.pl example/get_segment/spe/spe-main.cc |
diffstat | 7 files changed, 36 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/example/get_segment/README Wed Sep 30 10:12:26 2009 +0900 +++ b/example/get_segment/README Wed Sep 30 11:37:15 2009 +0900 @@ -19,3 +19,8 @@ ふーむ、なんか、動いたけど、-O2 だと動かない。なんか、 同期が必要なのか? + +Wed Sep 30 11:35:36 JST 2009 + +なんか、あんまりよろしくないな〜 $pc relative なaddress 計算が +ないのね。
--- a/example/get_segment/spe/Hello.cc Wed Sep 30 10:12:26 2009 +0900 +++ b/example/get_segment/spe/Hello.cc Wed Sep 30 11:37:15 2009 +0900 @@ -8,13 +8,13 @@ static int run(SchedTask *smanager, void *rbuf, void *wbuf) { - int task_id = get_param(0); + int task_id = smanager->get_param(0); unsigned int pc; __asm__ __volatile__("ai %0,$0,0 ### here" : "=r" (pc)); fprintf(stderr,"[%d] Hello, World!! Seg1 \n", task_id); - fprintf(stderr,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&createTask_Hello); + fprintf(stderr,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello); return 0; }
--- a/example/get_segment/spe/Hello1.cc Wed Sep 30 10:12:26 2009 +0900 +++ b/example/get_segment/spe/Hello1.cc Wed Sep 30 11:37:15 2009 +0900 @@ -8,14 +8,14 @@ static int run(SchedTask *smanager, void *rbuf, void *wbuf) { - int task_id = get_param(0); + int task_id = smanager->get_param(0); unsigned int pc; __asm__ __volatile__("ai %0,$0,0 ### here" : "=r" (pc)); fprintf(stderr,"[%d] Hello, World Seg 2!!\n", task_id); - fprintf(stderr,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&createTask_Hello1); + fprintf(stderr,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello1); return 0; }
--- a/example/get_segment/spe/Makefile Wed Sep 30 10:12:26 2009 +0900 +++ b/example/get_segment/spe/Makefile Wed Sep 30 11:37:15 2009 +0900 @@ -21,7 +21,7 @@ LDSCRIPT_ORIG = ld.script.orig LDSCRIPT_ED = ld.script.ed -OFFSET_H = createTask_offset.h +OFFSET_H = runTask_offset.h all: $(TARGET) @@ -45,5 +45,5 @@ $(CC) -o $@ $(SPEOBJS) $(SPELIBS) clean: - rm -f $(TARGET) $(SPEOBJS) $(OVLOBJS) + rm -f $(TARGET) $(SPEOBJS) $(OVLOBJS) $(OFFSET_H) rm -f *~ \#*
--- a/example/get_segment/spe/fixpic.pl Wed Sep 30 10:12:26 2009 +0900 +++ b/example/get_segment/spe/fixpic.pl Wed Sep 30 11:37:15 2009 +0900 @@ -27,6 +27,9 @@ # brsl -> brasl # brnz cannot be global +# lqr -> li (for global) +# ila global -> a $0,.LC0-.,$1 + while(<>) { push(@line,$_); if(/\.global\s+([^\s]+)/) { @@ -43,6 +46,7 @@ for(@line) { if (! /^#/) { + next if (/\.section\s+\.rodata/); if(/\s(br)\s+([^\s]+)/||/\s(brsl|hbrr)\s+[^\s]+,\s*([^\s]+)/) { my $name = $2; if (! defined $local{$name} || defined $weak{$name} ) { @@ -50,6 +54,18 @@ s/brsl/brasl/ || s/br/bra/ ; } + } elsif(/\s(lqr)\s+(\$\d+),([^\s]+)/) { + my $name = $2; + if (! defined $local{$name} || defined $weak{$name} ) { +# s/lqr/lqd/; + } + } elsif(/\s(ila)\s+(\$\d+),([^\s]+)/) { + my $name = $3; + if (! defined $local{$name} || defined $weak{$name} ) { + $_ = $_; + } else { + $_ = "\tai\t$2,\$0,$3-.\n"; + } } } print ;
--- a/example/get_segment/spe/ovly_table.pl Wed Sep 30 10:12:26 2009 +0900 +++ b/example/get_segment/spe/ovly_table.pl Wed Sep 30 11:37:15 2009 +0900 @@ -77,7 +77,7 @@ my $file = shift; if (! -e $file) { - open(H,">createTask_offset.h"); + open(H,">runTask_offset.h"); for my $header (@ARGV) { open(HD,"<$header") or die("Can't open $header"); my $class = $header; @@ -85,7 +85,7 @@ $class =~ s/\.cc//; while(<HD>) { if (/SchedDefineDynamicTask\(\s*(\w+)\s*,\s*(\d+)\s*\)/) { - print H "#define createTask_${class}_offset 0x$entry\n"; + print H "#define runTask_${class}_offset 0x$entry\n"; last; } } @@ -100,15 +100,17 @@ my @ldfiles; my $ldsegment = ""; -open(H,">createTask_offset.h"); +open(H,">runTask_offset.h"); +print H "#ifndef RUNTASK_OFFSET_H\n"; +print H "#define RUNTASK_OFFSET_H\n"; for my $header (@ARGV) { open(HD,"<$header") or die("Can't open $header"); while(<HD>) { if (/SchedDefineDynamicTask\(\s*(\w+)\s*,\s*(\d+)\s*\)/) { my $class = $1; my $segment = $2; - my $entry = $elf->symbol("createTask_$class")->{value}; - print H "#define createTask_${class}_offset (0x$entry-0x$base)\n"; + my $entry = $elf->symbol("runTask_$class")->{value}; + print H "#define runTask_${class}_offset (0x$entry-0x$base)\n"; my $ofile = $header; $ofile =~ s/\.cc/.o/; push(@ldfiles,$ofile); @@ -117,6 +119,7 @@ } } } +print H "#endif\n"; my $ld_script = <<"EOFEOF"; / \\.text /
--- a/example/get_segment/spe/spe-main.cc Wed Sep 30 10:12:26 2009 +0900 +++ b/example/get_segment/spe/spe-main.cc Wed Sep 30 11:37:15 2009 +0900 @@ -1,7 +1,7 @@ #include "Func.h" #include "Scheduler.h" -#include "createTask_offset.h" +#include "runTask_offset.h" SchedExternDynamicTask(Hello,0); SchedExternDynamicTask(Hello1,1);