changeset 430:fb62b7acc92b

code loading (on going...)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 24 Sep 2009 20:21:29 +0900
parents b3d997c05c9e
children 481089375622 c28b3f83ca65
files TaskManager/Cell/spe/CellScheduler.cc TaskManager/kernel/schedule/Scheduler.h example/get_segment/spe/LoadEntry.cc example/get_segment/spe/Makefile example/get_segment/spe/ld.script.ed example/get_segment/spe/spe-main.cc
diffstat 6 files changed, 40 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/spe/CellScheduler.cc	Thu Sep 24 17:45:35 2009 +0900
+++ b/TaskManager/Cell/spe/CellScheduler.cc	Thu Sep 24 20:21:29 2009 +0900
@@ -6,7 +6,7 @@
 
 // ユーザプログラムで定義
 // なんだけど、それは微妙じゃね?
-extern void task_init();
+extern void task_init(Scheduler *scheduler);
 
 void
 CellScheduler::init_impl()
@@ -15,7 +15,7 @@
 
     mainMemNum = 0;
 
-    task_init(); // PPE側ではUser 側で既に呼んでいる...
+    task_init(this); // PPE側ではUser 側で既に呼んでいる...
     // SPE側はここで呼び出す必要がある
     // Fifo ではSPEは無いので呼び出されない
 }
--- a/TaskManager/kernel/schedule/Scheduler.h	Thu Sep 24 17:45:35 2009 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.h	Thu Sep 24 20:21:29 2009 +0900
@@ -171,7 +171,7 @@
 };
 
 extern void register_task(int cmd, TaskObjectCreator creator);
-extern void register_dynamic_task(int cmd, TaskObjectCreator creator,
+extern void register_dynamic_task(int cmd, 
     memaddr start, memaddr end, int entry_offset);
 
 #endif
@@ -200,14 +200,16 @@
     }
 
 #define SchedExternDynamicTask(str,segment)                             \
-    extern memaddr __load_start_##segment,                             \
-           memaddr __loat_stop_##segment,                              \
-           spe_load_entry;                                             \
+    extern char __load_start_##segment[],                             \
+           __load_stop_##segment[];                              \
+    extern void spe_load_entry();                                          \
     extern SchedTask* createTask_##str(Scheduler *manager);
 
 
 #define SchedRegisterDynamicTask(cmd, str, segment)                    \
-    register_dynamic_task(cmd,  __load_start_##segment, __load_stop_##segment, createTask__##str-spe_load_entry);
+    register_dynamic_task(cmd,  (memaddr)__load_start_##segment, \
+                   (memaddr)__load_stop_##segment,\
+                   ((char *)createTask_##str)-(char *)spe_load_entry);
 
 
 /* end */
--- a/example/get_segment/spe/LoadEntry.cc	Thu Sep 24 17:45:35 2009 +0900
+++ b/example/get_segment/spe/LoadEntry.cc	Thu Sep 24 20:21:29 2009 +0900
@@ -1,3 +1,4 @@
+#include "LoadEntry.h"
 
 void spe_load_entry() 
 {
--- a/example/get_segment/spe/Makefile	Thu Sep 24 17:45:35 2009 +0900
+++ b/example/get_segment/spe/Makefile	Thu Sep 24 20:21:29 2009 +0900
@@ -2,25 +2,39 @@
 
 TARGET = ../spe-main
 
-SRCS_TMP = $(wildcard *.cc)
-SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
-OBJS = $(SRCS:.cc=.o)
+SRCS = spe-main.o
+# SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
+SPEOBJS = $(SRCS:.cc=.o)
+OVLOBJS = Hello.o   LoadEntry.o 
 
 CC      = spu-g++
-CFLAGS  = -O9 -g -Wall -fno-exceptions -fno-rtti#-DDEBUG
 INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I..
+CFLAGS  = $(INCLUDE) -O9 -g -Wall -fno-exceptions -fno-rtti#-DDEBUG
 LIBS = -L../${CERIUM}/TaskManager -lspemanager  -Wl,--gc-sections 
+SPELIBS   = -Wl,-T,$(LDSCRIPT) -Wl,-N $(LIBS)
+
+LDSCRIPT      = ld.script
+LDSCRIPT_ORIG = ld.script.orig
+LDSCRIPT_ED   = ld.script.ed
+
+all: $(TARGET)
 
 .SUFFIXES: .cc .o
 
-.cc.o:
-	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+$(SPEOBJS): %.o : %.cc
+	$(CC) $(CFLAGS) -c $< -o $@
+
+$(OVLOBJS): %.o : %.cc
+	$(CC) $(CFLAGS) -c $< -S -o $(<:.cc=.s) 
+	perl fixpic.pl $(<:.cc=.s)  | $(CC) $(SPECFLAGS) -x assembler -c  -o $@ -
 
-all: $(TARGET)
+$(LDSCRIPT): $(LDSCRIPT_ED)
+	cp $(LDSCRIPT_ORIG) $(LDSCRIPT)
+	ed $(LDSCRIPT) < $(LDSCRIPT_ED) > /dev/null 2>&1
 
-$(TARGET): $(OBJS)
-	$(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS)
+$(TARGET): $(SPEOBJS) $(OVLOBJS) $(LDSCRIPT)
+	$(CC) -o $@ $(SPEOBJS) $(SPELIBS)
 
 clean:
 	rm -f $(TARGET) $(OBJS)
-	rm -f *~ \#*
\ No newline at end of file
+	rm -f *~ \#*
--- a/example/get_segment/spe/ld.script.ed	Thu Sep 24 17:45:35 2009 +0900
+++ b/example/get_segment/spe/ld.script.ed	Thu Sep 24 20:21:29 2009 +0900
@@ -1,14 +1,12 @@
 / \.text /
 /\*(\.text/
-s/\*(\.text/*( EXCLUDE_FILE(spe\/olay\/*.o) .text/
+s/\*(\.text/*( EXCLUDE_FILE(Hello.o,LoadEntry.o) .text/
 /} =0/
 a
   OVERLAY :
   {
-    .segment1 { spe/olay/add.o(.text) }
-    .segment2 { spe/olay/mul.o(.text) }
-    .segment3 { spe/olay/div.o(.text) }
-    .segment4 { spe/olay/sub.o(.text) }
+    .Segment0 { LoadEntry.o(.text) }
+    .Segment1 { Hello.o(.text) }
   }
 .
 w
--- a/example/get_segment/spe/spe-main.cc	Thu Sep 24 17:45:35 2009 +0900
+++ b/example/get_segment/spe/spe-main.cc	Thu Sep 24 20:21:29 2009 +0900
@@ -1,5 +1,6 @@
 #include "Func.h"
 #include "Scheduler.h"
+#include "LoadEntry.h"
 
 SchedExternDynamicTask(Hello,Segment1);
 
@@ -8,7 +9,8 @@
  * 必ずこの関数名でお願いします。
  */
 void
-task_init(void)
+task_init(Scheduler *scheduler)
 {
     SchedRegisterDynamicTask(HELLO_TASK, Hello, Segment1);
+    scheduler->allocate_code_segment(4,8024);
 }