Mercurial > hg > Members > kono > Cerium
changeset 441:7bae2117f239
slightly worked...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 25 Sep 2009 03:49:01 +0900 |
parents | 0f3605d1ee73 |
children | 95a856a2d552 |
files | TaskManager/kernel/schedule/Scheduler.cc TaskManager/kernel/schedule/Scheduler.h example/get_segment/spe/Hello.cc example/get_segment/spe/Hello1.cc example/get_segment/spe/LoadEntry.cc example/get_segment/spe/LoadEntry.h example/get_segment/spe/Makefile example/get_segment/spe/ld.script.ed example/get_segment/spe/spe-main.cc |
diffstat | 9 files changed, 85 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/schedule/Scheduler.cc Fri Sep 25 01:47:03 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Sep 25 03:49:01 2009 +0900 @@ -362,7 +362,7 @@ (TaskObjectCreator)( (char*)task_list[task_id].segment->data + task_list[task_id].entry_offset); - // task_list[task_id].creator = creator; + task_list[task_id].creator = creator; fprintf(stderr,"wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, (unsigned int)creator, task_list[task_id].entry_offset); @@ -383,18 +383,19 @@ extern void register_dynamic_task(int cmd, - memaddr start, memaddr end, + memaddr start, int size, TaskObjectCreator creator, int entry_offset) { task_list[cmd].creator = creator; task_list[cmd].location = start; - task_list[cmd].end = end; + task_list[cmd].end = start+size; task_list[cmd].entry_offset = entry_offset; task_list[cmd].load = load_task; task_list[cmd].wait = wait_load; fprintf(stderr,"cmd = %d\n",cmd); -fprintf(stderr,"locatation = 0x%llx\n",start); -fprintf(stderr,"end = 0x%llx\n",end); +fprintf(stderr,"locatation = 0x%x\n",start); +fprintf(stderr,"end = 0x%x\n",start+size); +fprintf(stderr,"size = 0x%x\n",size); fprintf(stderr,"entry = 0x%x\n",entry_offset); }
--- a/TaskManager/kernel/schedule/Scheduler.h Fri Sep 25 01:47:03 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Fri Sep 25 03:49:01 2009 +0900 @@ -99,8 +99,8 @@ // 大きいので、SPEには置かない方が本当は良い... typedef struct { TaskObjectCreator creator; - uint64 location; // location address in a.out - uint64 end; + memaddr location; // location address in a.out + memaddr end; uint32 entry_offset; // offset for create(); MemorySegment *segment; void (*load)(Scheduler *,int); @@ -173,9 +173,16 @@ extern void register_task(int cmd, TaskObjectCreator creator); extern void register_dynamic_task(int cmd, - memaddr start, memaddr end, TaskObjectCreator creator, + memaddr start, int size, TaskObjectCreator creator, int entry_offset); +struct tbl { + unsigned int vma; + unsigned int size; + unsigned int file_offset; + unsigned int buf; +}; + #endif @@ -196,18 +203,20 @@ register_task(cmd, createTask_##str); #define SchedDefineDynamicTask(str,segment) \ + extern "C" { \ SchedTask* createTask_##str(Scheduler *manager) \ { \ return new str(); \ + } \ } #ifndef NO_OVERLAY #define SchedExternDynamicTask(str,segment) \ - extern char __load_start_##segment[], \ - __load_stop_##segment[]; \ - extern void spe_load_entry(); \ - extern SchedTask* createTask_##str(Scheduler *manager); \ - extern unsigned long long _EAR_; + extern "C" { \ + extern unsigned long long _EAR_; \ + extern struct tbl _ovly_table[]; \ + extern SchedTask* createTask_##str(Scheduler *manager) ; \ + } #else #define SchedExternDynamicTask(str,segment) SchedExternTask(str) #endif @@ -215,10 +224,10 @@ #ifndef NO_OVERLAY #define SchedRegisterDynamicTask(cmd, str, segment) \ - register_dynamic_task(cmd, _EAR_+(memaddr)__load_start_##segment, \ - _EAR_+(memaddr)__load_stop_##segment,\ + register_dynamic_task(cmd, _EAR_+_ovly_table[segment].file_offset, \ + _ovly_table[segment].size, \ createTask_##str, \ - ((char *)createTask_##str)-(char *)spe_load_entry); + createTask_##str##_offset); #else #define SchedRegisterDynamicTask(cmd, str, segment) SchedRegisterTask(cmd, str) #endif
--- a/example/get_segment/spe/Hello.cc Fri Sep 25 01:47:03 2009 +0900 +++ b/example/get_segment/spe/Hello.cc Fri Sep 25 03:49:01 2009 +0900 @@ -3,7 +3,7 @@ #include "Func.h" /* これは必須 */ -SchedDefineDynamicTask(Hello,segment1); +SchedDefineDynamicTask(Hello,0); int Hello::run(SchedTask *smanager, void *rbuf, void *wbuf)
--- a/example/get_segment/spe/Hello1.cc Fri Sep 25 01:47:03 2009 +0900 +++ b/example/get_segment/spe/Hello1.cc Fri Sep 25 03:49:01 2009 +0900 @@ -3,7 +3,7 @@ #include "Func.h" /* これは必須 */ -SchedDefineDynamicTask(Hello1,segment2); +SchedDefineDynamicTask(Hello1,1); int Hello1::run(SchedTask *smanager, void *rbuf, void *wbuf)
--- a/example/get_segment/spe/LoadEntry.cc Fri Sep 25 01:47:03 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -#include "LoadEntry.h" - -void spe_load_entry() -{ -}
--- a/example/get_segment/spe/LoadEntry.h Fri Sep 25 01:47:03 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -#ifndef INCLUDED_LOAD_ENTRY -#define INCLUDED_LOAD_ENTRY - -extern void spe_load_entry(); - -#endif
--- a/example/get_segment/spe/Makefile Fri Sep 25 01:47:03 2009 +0900 +++ b/example/get_segment/spe/Makefile Fri Sep 25 03:49:01 2009 +0900 @@ -5,11 +5,11 @@ SRCS = spe-main.o # SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) SPEOBJS = $(SRCS:.cc=.o) -OVLOBJS = Hello.o Hello1.o LoadEntry.o +OVLOBJS = Hello.o Hello1.o CC = spu-g++ INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I.. -CFLAGS = $(INCLUDE) -O2 -g -Wall -fno-exceptions -fno-rtti#-DDEBUG +CFLAGS = $(INCLUDE) -O0 -g -Wall -fno-exceptions -fno-rtti#-DDEBUG # CFLAGS = -DNO_OVERLAY=1 $(CFLAGS) LIBS = -L../${CERIUM}/TaskManager -lspemanager -Wl,--gc-sections @@ -19,11 +19,16 @@ LDSCRIPT_ORIG = ld.script.orig LDSCRIPT_ED = ld.script.ed +OFFSET_H = createTask_offset.h + all: $(TARGET) .SUFFIXES: .cc .o -$(SPEOBJS): %.o : %.cc +$(OFFSET_H) : + perl ovly_table.pl $(TARGET) > $(OFFSET_H) + +$(SPEOBJS): %.o : %.cc $(OFFSET_H) $(CC) $(CFLAGS) -c $< -o $@ $(OVLOBJS): %.o : %.cc
--- a/example/get_segment/spe/ld.script.ed Fri Sep 25 01:47:03 2009 +0900 +++ b/example/get_segment/spe/ld.script.ed Fri Sep 25 03:49:01 2009 +0900 @@ -5,9 +5,8 @@ a OVERLAY : { - .segment0 { LoadEntry.o(.text) } - .segment1 { Hello.o(.text) } - .segment2 { Hello1.o(.text) } + .segment0 { Hello.o(.text) } + .segment1 { Hello1.o(.text) } } . w
--- a/example/get_segment/spe/spe-main.cc Fri Sep 25 01:47:03 2009 +0900 +++ b/example/get_segment/spe/spe-main.cc Fri Sep 25 03:49:01 2009 +0900 @@ -2,8 +2,12 @@ #include "Scheduler.h" #include "LoadEntry.h" -SchedExternDynamicTask(Hello,segment1); -SchedExternDynamicTask(Hello1,segment2); +#include "createTask_offset.h" + +SchedExternDynamicTask(Hello,0); +SchedExternDynamicTask(Hello1,1); + +void print_ovly_table(); /** * この関数は SpeScheduler から呼ばれるので @@ -12,7 +16,46 @@ void task_init(Scheduler *scheduler) { - SchedRegisterDynamicTask(HELLO_TASK, Hello, segment1); - SchedRegisterDynamicTask(HELLO_TASK1, Hello1, segment2); + SchedRegisterDynamicTask(HELLO_TASK, Hello, 0); + SchedRegisterDynamicTask(HELLO_TASK1, Hello1, 1); scheduler->allocate_code_segment(4,1024); + print_ovly_table(); } + +typedef unsigned int u32; +extern unsigned long long _EAR_; + +/* +extern struct tbl1 { + u32 vma; + u32 size; + u32 file_offset; + u32 buf; +} _ovly_table; + */ + +#if 0 +unsigned long long _EAR_ = 0; +struct tbl _ovly_table; +#endif + +void +print_ovly_table() +{ + int i; + struct tbl *ov; + + ov = _ovly_table; + + fprintf(stderr,"memaddr = %d\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", + i, + ov[i].vma, + ov[i].size, ov[i].file_offset, + (adr) + ov[i].file_offset); + } +} + +/* end */