changeset 180:5cde66c926b4

いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
author gongo@localhost.localdomain
date Mon, 22 Dec 2008 16:09:57 +0900
parents 434846aef389
children a4d17bc4efef
files TaskManager/Cell/spe/CellDmaManager.cc TaskManager/Cell/spe/SchedTask.cc TaskManager/Cell/spe/SchedTaskList.cc TaskManager/Cell/spe/TaskGroup.cc TaskManager/ChangeLog TaskManager/Test/simple_pack/fb.cpp TaskManager/Test/test_render/ChangeLog TaskManager/Test/test_render/Makefile.def TaskManager/Test/test_render/SceneGraph.cpp TaskManager/Test/test_render/SceneGraph.h TaskManager/Test/test_render/Span.h TaskManager/Test/test_render/SpanPack.h TaskManager/Test/test_render/fb.h TaskManager/Test/test_render/main.cpp TaskManager/Test/test_render/spe/CreateSpan.cpp TaskManager/Test/test_render/spe/CreateSpan.h TaskManager/Test/test_render/spe/DrawSpan.cpp TaskManager/Test/test_render/task/CreateSpan.h TaskManager/Test/test_render/viewer.cpp TaskManager/Test/test_render/viewer.h TaskManager/Test/test_render/viewer_types.cpp TaskManager/kernel/schedule/SchedTask.cc include/TaskManager/DmaManager.h include/TaskManager/SchedTask.h
diffstat 24 files changed, 485 insertions(+), 288 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Mon Dec 22 16:09:57 2008 +0900
@@ -1,44 +1,60 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include "CellDmaManager.h"
 
+/**
+ * DMA Load
+ *
+ * @param[in] buf  Buffer of Load Data
+ * @param[in] addr Address of Load Data at Main Memory
+ * @param[in] size Size of Load Data
+ * @param[in] mask DMA tag
+*/
 void
 CellDmaManager::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask)
 {
     if (size == 0) return ;
-    spu_mfcdma32(buf, addr, size, mask, MFC_GET_CMD);
+    mfc_get((volatile void *)buf, addr, size, mask, 0, 0);
 }
 
+/**
+ * DMA Store
+ *
+ * @param[in] buf  Buffer of Store Data at SPE
+ * @param[in] addr Address of Store Data at Main Memory
+ * @param[in] size Size of Store Data
+ * @param[in] mask DMA tag
+*/
 void
 CellDmaManager::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask)
 {
     if (size == 0) return ;
-    spu_mfcdma32(buf, addr, size, mask, MFC_PUT_CMD);
-
-    //spu_mfcdma32(buf, addr, ROUND_UP_ALIGN(size, DEFAULT_ALIGNMENT),
+    mfc_put((volatile void *)buf, addr, size, mask, 0, 0);
 }
 
 /**
- * mask ꤷ DMA žδλԤ
+ * DMA Wait
+ *
+ * @param[in] mask Tag for Wait DMA process
  */
 void
 CellDmaManager::dma_wait(uint32 mask)
 {
-    spu_writech(MFC_WrTagMask, 1 << mask);
-    spu_mfcstat(MFC_TAG_UPDATE_ALL);
+    mfc_write_tag_mask(1 << mask);
+    mfc_write_tag_update_all();
+    mfc_read_tag_status();
 }
 
 void
 CellDmaManager::mail_write(uint32 data)
 {
-    spu_writech(SPU_WrOutMbox, data);
+    spu_write_out_mbox(data);
 }
 
 unsigned int
 CellDmaManager::mail_read(void)
 {
-    unsigned int mail = spu_readch(SPU_RdInMbox);
+    unsigned int mail = spu_read_in_mbox();
     return mail;
 }
 
@@ -55,62 +71,3 @@
     mfc_putl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length,
 	     mask, 0, 0);
 }
-
-
-#if 0
-/**
- * dma_loadList Сn
- */
-
-void**
-CellDmaManager::dmaList_load(uint32 mask)
-{
-    int index = buff_index[buff_flag];
-    DmaListPtr queue = dmaQueue[buff_flag];
-    mfc_list_element_t *mfc_list = mfcList[buff_flag];
-
-    void **buffList;
-    void *buff;
-    int bound;
-    int total_size = 0;
-
-    mfc_list = (mfc_list_element_t *)malloc(sizeof(mfc_list_element_t)*index);
-
-    for (int i = 0; i < index; i++) {
-	mfc_list[i].notify   = 0;
-	mfc_list[i].reserved = 0;
-	mfc_list[i].size     = queue[i].size;
-	mfc_list[i].eal      = queue[i].addr;
-	total_size += queue[i].size;
-    }
-
-    //----------------------------------------------------------------
-    // list element  n Ĥ buff, buffList ι¤
-    //
-    //       +---------------+---------------+--------+-----------------+
-    // buff  | queue[0].size | queue[1].size | ...... | queue[n-1].size |
-    //       +---------------+---------------+--------+-----------------+
-    //       ^               ^               ^        ^
-    //       |               |               |        |
-    //      buffList[0]   buffList[1]    buffList[2] buffList[n-1]
-    //----------------------------------------------------------------
-
-    buff = memalign(DEFAULT_ALIGNMENT, total_size);
-    buffList = (void**)malloc(index);
-
-    bound = (int)buff;
-    buffList[0] = (void*)bound;
-    for (int i = 1; i < index; i++) {
-	bound += queue[i-1].size;
-	buffList[i] = (void*)bound;
-    }
-
-    mfc_getl(buff, 0, mfc_list, sizeof(mfc_list_element_t), mask, 0, 0);
-    dma_wait(mask);
-
-    _buffList[buff_flag] = buffList;
-    _buff[buff_flag] = buff;
-
-    return buffList;
-}
-#endif
--- a/TaskManager/Cell/spe/SchedTask.cc	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Cell/spe/SchedTask.cc	Mon Dec 22 16:09:57 2008 +0900
@@ -74,10 +74,18 @@
 	
 	__taskGroup = new TaskGroup;
 	__taskGroup->command = __task->self;
+
+	ex_read  = &SchedTask::ex_read_normal;
+	ex_exec  = &SchedTask::ex_exec_normal;
+	ex_write = &SchedTask::ex_write_normal;
     } else {
 	__inListData = __task->inData;
 	__outListData = __task->outData;
 	__taskGroup = (TaskGroupPtr)__task->self;
+
+	ex_read  = &SchedTask::ex_read_renew;
+	ex_exec  = &SchedTask::ex_exec_renew;
+	ex_write = &SchedTask::ex_write_renew;
     }
 }
 
@@ -105,6 +113,8 @@
     // load Input Data
     __readbuf = __scheduler->allocate(__inListData->size);
     __scheduler->dma_loadList(__inListData, __readbuf, DMA_READ);
+
+    (this->*ex_read)();
 }
 
 void
@@ -114,7 +124,6 @@
 
     // wait for load outListData 
     __scheduler->dma_wait(DMA_READ_OUT_LIST);
-
     __writebuf = __scheduler->allocate(__outListData->size);
 
     __debug("  task->command  = %d\n", __task->command);
@@ -130,17 +139,22 @@
 
     free(__readbuf);
 
-    // 񤭹ΰ褬פʤ̵
-    if (__outListData->size > 0) {
-	__scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE);
-	__scheduler->dma_wait(DMA_WRITE);
-    }
-
     if (__taskGroup->status() != 0) {
 	__task->self = __taskGroup->command;
 	delete __taskGroup;
 	__taskGroup = NULL;
     }
+
+    // 񤭹ΰ褬פʤ̵
+    if (__outListData->size > 0 || __outListData->length > 0) {
+	__scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE);
+	// SchedTask::write(void) Ǥ wait ݤƤɡ
+        // ºݤˤϤ wait ʤȤȽ񤭹ޤƤʤ
+	// wait ϤƤϤʤʡ
+	__scheduler->dma_wait(DMA_WRITE);
+    }
+
+    (this->*ex_exec)();
 }
 
 void
@@ -148,31 +162,98 @@
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
-    __scheduler->dma_wait(DMA_WRITE);
-
+    //__scheduler->dma_wait(DMA_WRITE);
     free(__writebuf);
 
     /**
-     * Ƥ硢
-     * ΥäƤ餳Υλޥɤ롣
-     * # ޥɤ줿˰Ѥ
+     * ΥSPE줿
+     * ΥνλԤɬפϤʤȤ꤬Ƥ뤿ᡢ
+     *   (wait_task() ƤФƤʤ)
+     * ǽλ롣ex_write ϼ¹Ԥʤ
      */
     if (__task->self == MY_SPE_NOP) return;
 
-    if (__flag_renewTask) {
-	uint32 cmd;
-	
-	__taskGroup->remove(__task);
-	cmd = __taskGroup->status();
+    (this->*ex_write)();
+}
+
+/**
+ * PPE 줿 ex_read()
+ */
+void
+SchedTask::ex_read_normal(void)
+{
+}
+
+/**
+ * SPE 줿 ex_read()
+ */
+void
+SchedTask::ex_read_renew(void)
+{
+}
+
+/**
+ * PPE 줿 ex_exec()
+ */
+void
+SchedTask::ex_exec_normal(void)
+{
+}
+
+/**
+ * SPE 줿 ex_exec()
+ */
+void
+SchedTask::ex_exec_renew(void)
+{
+}
+
+
 
-	if (cmd != 0) {
-	    delete __taskGroup;
-	    __scheduler->mail_write(cmd);
-	}
-    } else {
-	if (__renew_flag == 0) {
-	    __scheduler->mail_write(__task->self);
-	}
+/**
+ * PPE 줿 ex_write()
+ * 
+ * Υǿ˥졢
+ * ĤΥνλԤɬפ硢
+ * PPE ˽λȤΤ餻ʤ(command ʤ)
+ */
+void
+SchedTask::ex_write_normal(void)
+{
+    /**
+     * Υǿ˥ʤä
+     * or 줿ΥνλԤɬפ̵
+     */
+    if (__renew_flag == 0) {
+	__scheduler->mail_write(__task->self);
+    }
+}
+
+/**
+ * SPE 줿 ex_write()
+ *
+ *  A <- ƥ
+ *  | \
+ *  B   C <- SPE 줿
+ *
+ * A  SPE  B, C Ȥ롣
+ * B  C λ顢A  PPE Ϥäޥɤ
+ * ҥ˰ѤƤΤǡǸ˼¹Ԥ줿ҥ
+ * PPE  mail 롣
+ */
+void
+SchedTask::ex_write_renew(void)
+{
+    uint32 cmd;
+	
+    __taskGroup->remove(__task);
+    cmd = __taskGroup->status();
+    
+
+    // Ǻ줿ƤΥλ
+    if (cmd != 0) {
+	delete __taskGroup;
+	__scheduler->mail_write(cmd);
     }
 }
     
@@ -258,7 +339,10 @@
 }
 
 /**
- * ̾
+ * λƤ顢ᥤ󥹥塼(PPE) 
+ * λݤΤ餻롣
+ *
+ * @param[in] waitTask 
  */
 void
 SchedTask::wait_task(TaskPtr waitTask)
--- a/TaskManager/Cell/spe/SchedTaskList.cc	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Cell/spe/SchedTaskList.cc	Mon Dec 22 16:09:57 2008 +0900
@@ -23,7 +23,8 @@
     __debug("[SchedTaskList:%s]\n", __FUNCTION__);
 
     if (flag_renewTaskList == 0) {
-	scheduler->dma_load(list,params_addr,sizeof(TaskList),DMA_READ_TASKLIST);
+	scheduler->dma_load(list, params_addr, 
+			    sizeof(TaskList), DMA_READ_TASKLIST);
 	scheduler->dma_wait(DMA_READ_TASKLIST);
     } else {
 	list = (TaskListPtr)params_addr;
--- a/TaskManager/Cell/spe/TaskGroup.cc	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Cell/spe/TaskGroup.cc	Mon Dec 22 16:09:57 2008 +0900
@@ -29,7 +29,12 @@
     }
 }
 
-
+/**
+ * 自分が持つ TaskGroup に Task が残っていれば NULL を返す。
+ * もう全てのタスクが終了していれば、この TaskGroup を作った
+ * (一番最初にタスク内タスク生成を行った)タスクが PPE に返すべきだった
+ * command を返す。
+ */
 unsigned int
 TaskGroup::status(void) {
     /**                                                                     
--- a/TaskManager/ChangeLog	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/ChangeLog	Mon Dec 22 16:09:57 2008 +0900
@@ -1,3 +1,54 @@
+2008-12-22  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
+
+	* Cell/spe/SchedTask.cc (SchedTask::__init__, SchedTask::read)
+	(SchedTask::exec, SchedTask::write): fix
+	(SchedTask::ex_read_normal, SchedTask::ex_read_renew)
+	(SchedTask::ex_exec_normal, SchedTask::ex_exec_renew)
+	(SchedTask::ex_write_normal, SchedTask::ex_write_renew): add
+
+	SPE 内で生成されたタスクは、PPE で生成されたものと違い
+
+	- add->inData
+	  : PPE から DMA or SPE 内のものをそのまま使う
+	- PPE にタスクが終了したことを知らせる
+	  : 生成されたタスクを待つ必要があるなら、その時点では送らない
+
+	とか、まあいろいろ処理が違うわけです。
+	そして、タスク内生成タスクの判断をする
+
+	__flag_renewTask ? 0 = PPE で生成 : 1 = SPE で生成
+
+	という変数がある。これでいくつか処理を分けてるんだけど、
+	今までは
+
+	if (__flag_renewTask) {
+	} else {
+	}
+
+	ってやってた。これではいかんという事で、
+	__init__() 内で、関数ポインタに、
+
+	ex_xxxx_normal: PPE で生成されたタスクに対する処理
+	ex_xxxx_renew: SPE で生成されたタスクに対する処理
+
+	と入れて、if 文無しでやってみた。
+	今は ex_write_xxx しか書いてないが、これからread/exec でも
+	出てくると思うので、作っておいた
+	
+
+2008-12-19  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
+
+	* Cell/spe/CellDmaManager.cc (CellDmaManager::dma_wait)
+	(CellDmaManager::mail_write, CellDmaManager::mail_read): fix
+	writech、readch の関数を、wrap (って言い方でおk?)された関数に変更。
+	最適化掛かってるっぽいし、長いよりはわかりやすいし。そのための wrap。
+
+	例:
+	- before
+	    spu_readch(SPU_RdInMspu_readch(SPU_RdInMbox);
+	- after
+	    spu_read_in_mbox(void);
+
 2008-11-05  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
 
 	* add: Task 内での API
--- a/TaskManager/Test/simple_pack/fb.cpp	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/simple_pack/fb.cpp	Mon Dec 22 16:09:57 2008 +0900
@@ -30,73 +30,73 @@
 #define COLOR_YELLOW 0xffe0
 
 /* function prototype */
-void send_current_error_msg(char *ptr);
-void send_current_information(char *ptr);
+void send_current_error_msg(const char *ptr);
+void send_current_information(const char *ptr);
 
 int get_fbdev_addr(void)
 {
-	int fd_framebuffer ;
-	struct fb_var_screeninfo vinfo;
-	struct fb_fix_screeninfo finfo;
-	long int screensize ;
-	long int location;
-	char *fbptr ;
-	char tmp[DIV_BYTE*10];
+    int fd_framebuffer ;
+    struct fb_var_screeninfo vinfo;
+    struct fb_fix_screeninfo finfo;
+    long int screensize ;
+    long int location;
+    char *fbptr ;
+    char tmp[DIV_BYTE*10];
 
-	int x , y ;
-	int xres,yres,vbpp,line_len;
-	unsigned short tcolor ;
+    int x , y ;
+    int xres,yres,vbpp,line_len;
+    unsigned short tcolor ;
 
-	/* 読み書き用にファイルを開く */
-	fd_framebuffer = open( DEVICE_NAME , O_RDWR);
-	if ( !fd_framebuffer ) {
-		send_current_error_msg("Framebuffer device open error !");
-		exit(1);
-	}
-	send_current_information("The framebuffer device was opened !");
+    /* 読み書き用にファイルを開く */
+    fd_framebuffer = open( DEVICE_NAME , O_RDWR);
+    if ( !fd_framebuffer ) {
+	send_current_error_msg("Framebuffer device open error !");
+	exit(1);
+    }
+    send_current_information("The framebuffer device was opened !");
 
-	/* 固定スクリーン情報取得 */
-	if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) {
-		send_current_error_msg("Fixed information not gotton !");
-		exit(2);
-	}
+    /* 固定スクリーン情報取得 */
+    if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) {
+	send_current_error_msg("Fixed information not gotton !");
+	exit(2);
+    }
 
-	/* 変動スクリーン情報取得 */
-	if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) {
-		send_current_error_msg("Variable information not gotton !");
-		exit(3);
-	}
-	xres = vinfo.xres ;
-	yres = vinfo.yres ;
-	vbpp = vinfo.bits_per_pixel ;
-	line_len = finfo.line_length ;
-	sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp);
-	send_current_information( tmp );
+    /* 変動スクリーン情報取得 */
+    if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) {
+	send_current_error_msg("Variable information not gotton !");
+	exit(3);
+    }
+    xres = vinfo.xres ;
+    yres = vinfo.yres ;
+    vbpp = vinfo.bits_per_pixel ;
+    line_len = finfo.line_length ;
+    sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp);
+    send_current_information( tmp );
 
-	/* バイト単位でのスクリーンのサイズを計算 */
-	screensize = xres * yres * vbpp / DIV_BYTE ;
+    /* バイト単位でのスクリーンのサイズを計算 */
+    screensize = xres * yres * vbpp / DIV_BYTE ;
 
-	/* デバイスをメモリにマップする */
-	fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0);
-	if ( (int)fbptr == -1 ) {
-		send_current_error_msg("Don't get framebuffer device to memory !");
-		exit(4);
-	}
-	send_current_information("The framebuffer device was mapped !");
+    /* デバイスをメモリにマップする */
+    fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0);
+    if ( (int)fbptr == -1 ) {
+	send_current_error_msg("Don't get framebuffer device to memory !");
+	exit(4);
+    }
+    send_current_information("The framebuffer device was mapped !");
 
-	printf("fb: %x \n",fbptr);
-	return (int)fbptr;
-	//munmap(fbptr,screensize);
-	//close(fd_framebuffer);
-	//return 0;
+    printf("fb: %x \n",fbptr);
+    return (int)fbptr;
+    //munmap(fbptr,screensize);
+    //close(fd_framebuffer);
+    //return 0;
 }
 
-void send_current_error_msg(char *ptr)
+void send_current_error_msg(const char *ptr)
 {
-	fprintf( stderr , "%s\n" , ptr );
+    fprintf( stderr , "%s\n" , ptr );
 }
 
-void send_current_information(char *ptr)
+void send_current_information(const char *ptr)
 {
-	fprintf( stdout , "%s\n" , ptr );
+    fprintf( stdout , "%s\n" , ptr );
 }
--- a/TaskManager/Test/test_render/ChangeLog	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/ChangeLog	Mon Dec 22 16:09:57 2008 +0900
@@ -1,5 +1,28 @@
+2008-12-22  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
+
+	* fix
+	charles を Fedora 10 に上げて、コンパイラが新しくなったせいか、
+	以下のような warning が出始めた
+
+	warning: deprecated conversion from string constant to 'char *'
+
+	まあよくわからんが、例えば
+
+	char *str = "hoge";
+
+	みたいな所だとこの warning が出る。これを
+
+	const char *str = "hoge";
+
+	にすると消えた。
+	以後こういう形に統一しろよ的なやつなのかな。
+
 2008-12-19  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
 
+	* viewer.cpp (Viewer::run_draw): fix
+	startx, endx に対して、start_y, end_y って名前は統一されてなくて
+	わかりづらいので、starty, endy に変更
+
 	* main.cpp (init): fix
 	bpp (BitsPerPixel) の値がデフォルトで 0 になっていた。
 	今のレンダリング方式では 32 がデフォルトなので、間違ってた。
--- a/TaskManager/Test/test_render/Makefile.def	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/Makefile.def	Mon Dec 22 16:09:57 2008 +0900
@@ -3,10 +3,10 @@
 # include/library path
 # ex: macosx
 #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium
-CERIUM = /Users/gongo/Source/hg/Cerium
+#CERIUM = /Users/gongo/Source/hg/Cerium
 
 # ex: linux/ps3
-#CERIUM = /home/gongo/Cerium
+CERIUM = /home/gongo/Cerium
 #CERIUM = /Users/tkaito/hg/Game/Cerium
 
 #CERIUM = ../../..
--- a/TaskManager/Test/test_render/SceneGraph.cpp	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/SceneGraph.cpp	Mon Dec 22 16:09:57 2008 +0900
@@ -146,7 +146,7 @@
 
 /* XMLファイルからポリゴンを作成  */
 void
-SceneGraph::createFromXMLfile(char *xmlfile)
+SceneGraph::createFromXMLfile(const char *xmlfile)
 {
     xmlDocPtr doc;
     xmlNodePtr cur;
--- a/TaskManager/Test/test_render/SceneGraph.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/SceneGraph.h	Mon Dec 22 16:09:57 2008 +0900
@@ -58,7 +58,7 @@
     void set_move_collision(move_func new_move, collision_func new_collision);
 
 
-    static void createFromXMLfile(char *);
+    static void createFromXMLfile(const char *);
 
     void tree_check(void);
     void print_member(void);
--- a/TaskManager/Test/test_render/Span.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/Span.h	Mon Dec 22 16:09:57 2008 +0900
@@ -11,6 +11,7 @@
 
 #define MAX_TILE_LIST 64
 
+#if 0
 typedef struct tile {
     void *tile;
     int tix, tiy;
@@ -28,6 +29,7 @@
 	next = 0;
     }
 } TileInfoList, *TileInfoListPtr; // 4*4+64*sizeof(Tile) = 16+768
+#endif
 
 class Span {
 public:
@@ -44,9 +46,11 @@
     float tex_y1;
     float tex_y2;
 
+#if 0
     TileInfoListPtr tilelist;
-    int pad[3];
+#endif
 
+#if 0
     void init(void) {
 	tilelist = 0;
     }
@@ -63,6 +67,7 @@
 
 	tilelist = 0;
     }
+#endif
 };
 
 typedef Span* SpanPtr;
--- a/TaskManager/Test/test_render/SpanPack.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/SpanPack.h	Mon Dec 22 16:09:57 2008 +0900
@@ -5,32 +5,31 @@
 #  include "Span.h"
 #endif
 
-#define MAX_SIZE_SPAN 70
+#define MAX_SIZE_SPAN 64
 
 class SpanPack {
 public: /* fields */
     struct SpanInfo {
-	int size; // 4
-	int y_top; // 4
-	int light_pos[3]; // 4*3
-	int light_rgb[3]; // 4*3
-    } info; // 32
+	int start;
+	int size;
+	int y_top;
+	int light_pos[3];
+	int light_rgb[3];
+    } info; // 36
 
-    Span span[MAX_SIZE_SPAN]; // 48*MAX_SIZE_SPAN = 3360
+    Span span[MAX_SIZE_SPAN]; // 48*MAX_SIZE_SPAN = 3072
     SpanPack *next; // 4
 
-    int pad[3]; // 12
+    int pad[2]; // 8
 
     void init(int ytop) {
+	this->info.start = 0;
 	this->info.size = 0;
 	this->info.y_top = ytop;
 	this->next = NULL;
     }
 
     void reinit(int ytop) {
-	/**
-	 * かっこわるすぐる
-	 */ 
 	SpanPack* top = this;
 	SpanPack* p;
 	SpanPack* p1;
@@ -38,19 +37,11 @@
 	p = top->next;
 	while (p != NULL) {
 	    p1 = p->next;
-	    for (int i = 0; i < p->info.size; i++) {
-		Span* span = &p->span[i];
-		span->reinit();
-	    }
 	    free(p);
 	    p = p1;
 	}
-
-	for (int i = 0; i < this->info.size; i++) {
-	    Span* span = &this->span[i];
-	    span->reinit();
-	}
 	
+	this->info.start = 0;
 	this->info.size = 0;
 	this->info.y_top = ytop;
 	this->next = NULL;
--- a/TaskManager/Test/test_render/fb.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/fb.h	Mon Dec 22 16:09:57 2008 +0900
@@ -27,8 +27,8 @@
 #define COLOR_YELLOW 0xffe0
 
 /* function prototype */
-void send_current_error_msg(char *ptr);
-void send_current_information(char *ptr);
+void send_current_error_msg(const char *ptr);
+void send_current_information(const char *ptr);
 
 int get_fbdev_addr(void)
 {
@@ -47,15 +47,15 @@
 	/* ɤ߽Ѥ˥ե򳫤 */
 	fd_framebuffer = open( DEVICE_NAME , O_RDWR);
 	if ( !fd_framebuffer ) {
-		send_current_error_msg("Framebuffer device open error !");
-		exit(1);
+	    send_current_error_msg("Framebuffer device open error !");
+	    exit(1);
 	}
 	send_current_information("The framebuffer device was opened !");
-
+	
 	/* ꥹ꡼ */
 	if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) {
-		send_current_error_msg("Fixed information not gotton !");
-		exit(2);
+	    send_current_error_msg("Fixed information not gotton !");
+	    exit(2);
 	}
 
 	/* ư꡼ */
@@ -88,14 +88,14 @@
 	//return 0;
 }
 
-void send_current_error_msg(char *ptr)
+void send_current_error_msg(const char *ptr)
 {
-	fprintf( stderr , "%s\n" , ptr );
+    fprintf( stderr , "%s\n" , ptr );
 }
 
-void send_current_information(char *ptr)
+void send_current_information(const char *ptr)
 {
-	fprintf( stdout , "%s\n" , ptr );
+    fprintf( stdout , "%s\n" , ptr );
 }
 #else /* !defined(__linux__) */
 int get_fbdev_addr(void) {return 0;}
--- a/TaskManager/Test/test_render/main.cpp	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/main.cpp	Mon Dec 22 16:09:57 2008 +0900
@@ -13,7 +13,7 @@
 
 static int sg_number = 0;
 
-static char *help_str = "Usage: ./test_nogl [OPTION]\n\
+static const char *help_str = "Usage: ./test_nogl [OPTION]\n\
   -cpu Number of SPE (default 1)\n\
   -width, -height window size (default 640x480)\n\
   -sg Draw SceneGraph\n\
@@ -31,7 +31,7 @@
     int width  = 640;
     int height = 480;
     int spenum = 1;
-    char *xml  = "xml_file/cube.xml";
+    const char *xml  = "xml_file/cube.xml";
     video_type vtype = VTYPE_SDL;
 
     for(int i = 1; argv[i]; ++i)
--- a/TaskManager/Test/test_render/spe/CreateSpan.cpp	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/spe/CreateSpan.cpp	Mon Dec 22 16:09:57 2008 +0900
@@ -128,7 +128,8 @@
 
 
 /**
- * span の width,height と texture の width,height を比べて
+ * span の width と Triangle の height に対して、
+ * texture の width,height をそれぞれ比べて
  * span を描画する際に使う texture の比率を求める
  *
  * @param[in] width      Width of span
@@ -431,40 +432,11 @@
 
 	for (int i = 0; i < pp->info.size; i++) {
 	    triPack = &pp->tri[i];
-	    
-#if 0
+
+	    // 参照渡しだからレジスタに乗らないでほげほげ〜で
+	    // 最適化でいうと微妙?
 	    make_vertex(triPack, &vMin, &vMid, &vMax);
-#else
-	    if (triPack->ver1.y <= triPack->ver2.y) {
-		if (triPack->ver2.y <= triPack->ver3.y) {
-		    vMin = &triPack->ver1;
-		    vMid = &triPack->ver2;
-		    vMax = &triPack->ver3;
-		} else if (triPack->ver3.y <= triPack->ver1.y) {
-		    vMin = &triPack->ver3;
-		    vMid = &triPack->ver1;
-		    vMax = &triPack->ver2;
-		} else {
-		    vMin = &triPack->ver1;
-		    vMid = &triPack->ver3;
-		    vMax = &triPack->ver2;
-		}
-	    } else {
-		if (triPack->ver1.y <= triPack->ver3.y) {
-		    vMin = &triPack->ver2;
-		    vMid = &triPack->ver1;
-		    vMax = &triPack->ver3;
-		} else if (triPack->ver3.y <= triPack->ver2.y) {
-		    vMin = &triPack->ver3;
-		    vMid = &triPack->ver2;
-		    vMax = &triPack->ver1;
-		} else {
-		    vMin = &triPack->ver2;
-		    vMid = &triPack->ver3;
-		    vMax = &triPack->ver1;
-		}
-	    }
-#endif
+
 	    make_vMid10(vMid10, vMin, vMid, vMax);
 
 	    /**
--- a/TaskManager/Test/test_render/spe/CreateSpan.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/spe/CreateSpan.h	Mon Dec 22 16:09:57 2008 +0900
@@ -24,9 +24,11 @@
 		       int tex_scale_max,
 		       VertexPack *vMin,VertexPack *vMid,VertexPack *vMid1,
 		       int length_y, float tex_y_len);
+#if 0
     void setTileInfoList(SpanPtr span);
     void setTileInfo(TileInfoPtr tile, int xpos, int ypos,
 		     int tex_width, uint32* tex_addr_top);
+#endif
 };
 
 #endif
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Mon Dec 22 16:09:57 2008 +0900
@@ -159,7 +159,7 @@
 	    next_sp = NULL;
 	}
 
-	for (int t = 0; t < sp->info.size; t++) {	  
+	for (int t = sp->info.start; t < sp->info.size; t++) {	  
 	    span = &sp->span[t];
 
 	    Uint32 rgb = 0x00ff00;
--- a/TaskManager/Test/test_render/task/CreateSpan.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/task/CreateSpan.h	Mon Dec 22 16:09:57 2008 +0900
@@ -24,9 +24,11 @@
 		       int tex_scale_max,
 		       VertexPack *vMin,VertexPack *vMid,VertexPack *vMid1,
 		       int length_y, float tex_y_len);
+#if 0
     void setTileInfoList(SpanPtr span);
     void setTileInfo(TileInfoPtr tile, int xpos, int ypos,
 		     int tex_width, uint32* tex_addr_top);
+#endif
 };
 
 #endif
--- a/TaskManager/Test/test_render/viewer.cpp	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/viewer.cpp	Mon Dec 22 16:09:57 2008 +0900
@@ -112,7 +112,7 @@
 extern void universe_init(void);
 
 void
-Viewer::run_init(char *xml, int sg_number)
+Viewer::run_init(const char *xml, int sg_number)
 {
     HTaskPtr task_next;
     HTaskPtr task_tex;
@@ -323,10 +323,10 @@
 	int startx = 1;
 	int endx = split_screen_w;
 
-	int start_y = spack->info.y_top - split_screen_h + 1;
-	//int end_y = spack->info.y_top;
-	int rangey = (start_y + split_screen_h - 1 > this->height)
-	    ? this->height - start_y + 1 : split_screen_h;
+	int starty = spack->info.y_top - split_screen_h + 1;
+	//int endy = spack->info.y_top;
+	int rangey = (starty + split_screen_h - 1 > this->height)
+	    ? this->height - starty + 1 : split_screen_h;
 
 	while (startx < this->width) {
 	    if (spack->info.size > 0) {
@@ -344,7 +344,7 @@
 	    
 	    for (int k = 0; k < rangey; k++) {
 		task_draw->add_outData(
-		    &pixels[(startx-1)+this->width*(k+start_y-1)],
+		    &pixels[(startx-1)+this->width*(k+starty-1)],
 		    (endx - startx + 1)*sizeof(int));
 	    }
 
--- a/TaskManager/Test/test_render/viewer.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/viewer.h	Mon Dec 22 16:09:57 2008 +0900
@@ -34,7 +34,7 @@
     virtual void swap_buffers();
     virtual void clean_pixels() {}
 
-    virtual void run_init(char *xml, int sg_number);
+    virtual void run_init(const char *xml, int sg_number);
     virtual void run_loop(void);
     virtual void run_draw(void);
     virtual void run_finish(void);
--- a/TaskManager/Test/test_render/viewer_types.cpp	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/Test/test_render/viewer_types.cpp	Mon Dec 22 16:09:57 2008 +0900
@@ -8,10 +8,10 @@
      * 現在は offset は 2 の冪乗のみなので
      * これで問題ないけどどうなの?
      */
-    return d & (offset-1);
+    //return d & (offset-1);
 
     // offset が 2 の冪乗以外はこれにしないとだめ
-    //return d % offset;
+    return d % offset;
 }
 
 /**
--- a/TaskManager/kernel/schedule/SchedTask.cc	Fri Dec 19 14:21:29 2008 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Mon Dec 22 16:09:57 2008 +0900
@@ -66,9 +66,6 @@
      * PPE ΤΤSPE ΤΤä
      * ɥ쥹ȽǤгڤˤʤȻפ
      */
-    /**
-     * ؿݥ󥿤Ǥ뤫
-     */
     if (__flag_renewTask == 0) {
 	__scheduler->dma_load(__inListData, (uint32)__task->inData,
 			      sizeof(ListData), DMA_READ_IN_LIST);
@@ -77,10 +74,18 @@
 	
 	__taskGroup = new TaskGroup;
 	__taskGroup->command = __task->self;
+
+	ex_read  = &SchedTask::ex_read_normal;
+	ex_exec  = &SchedTask::ex_exec_normal;
+	ex_write = &SchedTask::ex_write_normal;
     } else {
 	__inListData = __task->inData;
 	__outListData = __task->outData;
 	__taskGroup = (TaskGroupPtr)__task->self;
+
+	ex_read  = &SchedTask::ex_read_renew;
+	ex_exec  = &SchedTask::ex_exec_renew;
+	ex_write = &SchedTask::ex_write_renew;
     }
 }
 
@@ -108,6 +113,8 @@
     // load Input Data
     __readbuf = __scheduler->allocate(__inListData->size);
     __scheduler->dma_loadList(__inListData, __readbuf, DMA_READ);
+
+    (this->*ex_read)();
 }
 
 void
@@ -117,8 +124,6 @@
 
     // wait for load outListData 
     __scheduler->dma_wait(DMA_READ_OUT_LIST);
-    __scheduler->dma_wait(DMA_READ);
-
     __writebuf = __scheduler->allocate(__outListData->size);
 
     __debug("  task->command  = %d\n", __task->command);
@@ -128,12 +133,11 @@
     __debug("  list->next     = 0x%x\n", (unsigned int)__list->next);
     __debug("  list->length   = 0x%x\n", (unsigned int)__list->length);
 
+    __scheduler->dma_wait(DMA_READ);
+
     run(__readbuf, __writebuf);
 
-    // 񤭹ΰ褬פʤ̵
-    if (__outListData->size > 0) {
-	__scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE);
-    }
+    free(__readbuf);
 
     if (__taskGroup->status() != 0) {
 	__task->self = __taskGroup->command;
@@ -141,7 +145,16 @@
 	__taskGroup = NULL;
     }
 
-    free(__readbuf);
+    // 񤭹ΰ褬פʤ̵
+    if (__outListData->size > 0 || __outListData->length > 0) {
+	__scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE);
+	// SchedTask::write(void) Ǥ wait ݤƤɡ
+        // ºݤˤϤ wait ʤȤȽ񤭹ޤƤʤ
+	// wait ϤƤϤʤʡ
+	__scheduler->dma_wait(DMA_WRITE);
+    }
+
+    (this->*ex_exec)();
 }
 
 void
@@ -149,31 +162,98 @@
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
-    __scheduler->dma_wait(DMA_WRITE);
-
+    //__scheduler->dma_wait(DMA_WRITE);
     free(__writebuf);
 
     /**
-     * Ƥ硢
-     * ΥäƤ餳Υλޥɤ롣
-     * # ޥɤ줿˰Ѥ
+     * ΥSPE줿
+     * ΥνλԤɬפϤʤȤ꤬Ƥ뤿ᡢ
+     *   (wait_task() ƤФƤʤ)
+     * ǽλ롣ex_write ϼ¹Ԥʤ
      */
     if (__task->self == MY_SPE_NOP) return;
 
-    if (__flag_renewTask) {
-	uint32 cmd;
-	
-	__taskGroup->remove(__task);
-	cmd = __taskGroup->status();
+    (this->*ex_write)();
+}
+
+/**
+ * PPE 줿 ex_read()
+ */
+void
+SchedTask::ex_read_normal(void)
+{
+}
+
+/**
+ * SPE 줿 ex_read()
+ */
+void
+SchedTask::ex_read_renew(void)
+{
+}
+
+/**
+ * PPE 줿 ex_exec()
+ */
+void
+SchedTask::ex_exec_normal(void)
+{
+}
+
+/**
+ * SPE 줿 ex_exec()
+ */
+void
+SchedTask::ex_exec_renew(void)
+{
+}
+
+
 
-	if (cmd != 0) {
-	    delete __taskGroup;
-	    __scheduler->mail_write(cmd);
-	}
-    } else {
-	if (__renew_flag == 0) {
-	    __scheduler->mail_write(__task->self);
-	}
+/**
+ * PPE 줿 ex_write()
+ * 
+ * Υǿ˥졢
+ * ĤΥνλԤɬפ硢
+ * PPE ˽λȤΤ餻ʤ(command ʤ)
+ */
+void
+SchedTask::ex_write_normal(void)
+{
+    /**
+     * Υǿ˥ʤä
+     * or 줿ΥνλԤɬפ̵
+     */
+    if (__renew_flag == 0) {
+	__scheduler->mail_write(__task->self);
+    }
+}
+
+/**
+ * SPE 줿 ex_write()
+ *
+ *  A <- ƥ
+ *  | \
+ *  B   C <- SPE 줿
+ *
+ * A  SPE  B, C Ȥ롣
+ * B  C λ顢A  PPE Ϥäޥɤ
+ * ҥ˰ѤƤΤǡǸ˼¹Ԥ줿ҥ
+ * PPE  mail 롣
+ */
+void
+SchedTask::ex_write_renew(void)
+{
+    uint32 cmd;
+	
+    __taskGroup->remove(__task);
+    cmd = __taskGroup->status();
+    
+
+    // Ǻ줿ƤΥλ
+    if (cmd != 0) {
+	delete __taskGroup;
+	__scheduler->mail_write(cmd);
     }
 }
     
@@ -259,7 +339,10 @@
 }
 
 /**
- * ̾
+ * λƤ顢ᥤ󥹥塼(PPE) 
+ * λݤΤ餻롣
+ *
+ * @param[in] waitTask 
  */
 void
 SchedTask::wait_task(TaskPtr waitTask)
--- a/include/TaskManager/DmaManager.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/include/TaskManager/DmaManager.h	Mon Dec 22 16:09:57 2008 +0900
@@ -5,30 +5,21 @@
 #  include "base.h"
 #endif
 
-
-enum dma_tag {
-#if 0
-    DMA_READ  = 27,
-    DMA_WRITE = 28,
-    DMA_READ_TASKLIST = 29,
-    DMA_READ_IN_LIST  = 30,
-    DMA_READ_OUT_LIST = 31,
-#else
-    DMA_READ_TASKLIST = 27,
-    DMA_READ_IN_LIST  = 28,
-    DMA_READ_OUT_LIST = 29,
-    DMA_READ  = 30,
-    DMA_WRITE = 31,
-#endif
-};
-
 #ifndef INCLUDED_LIST_DATA
 #  include "ListData.h"
 #endif
 
 #ifndef INCLUDED_TYPES
 #  include "types.h"
-#endif
+ #endif
+
+enum dma_tag {
+    DMA_READ_TASKLIST = 27,
+    DMA_READ_IN_LIST  = 28,
+    DMA_READ_OUT_LIST = 29,
+    DMA_READ  = 30,
+    DMA_WRITE = 31,
+};
 
 class DmaManager {
 public:
--- a/include/TaskManager/SchedTask.h	Fri Dec 19 14:21:29 2008 +0900
+++ b/include/TaskManager/SchedTask.h	Mon Dec 22 16:09:57 2008 +0900
@@ -31,7 +31,11 @@
     BASE_NEW_DELETE(SchedTask);
 
     /* variables */
-    // ߥ塼餬 TaskList ȡΥб Task
+
+    // Task ¹Ԥ륹塼鼫
+    Scheduler *__scheduler;
+
+    // ߥ塼餬¹ԤƤ TaskList ȡΥб Task
     TaskListPtr __list;
     TaskPtr __task;
 
@@ -39,33 +43,59 @@
     ListDataPtr __inListData;
     ListDataPtr __outListData;
 
-    // read ǡwrite ѤΥХåե
-    // readbuf ˤ ϿꤷϥǡäƤ롣
-    // writebuf ˥ǡǤȡ
-    // Ͽꤷ˽񤭹
+    /**
+     * read ǡwrite ѤΥХåե
+     * readbuf ˤ ϿꤷϥǡäƤ롣
+     * writebuf ˥ǡǤȡ
+     * Ͽꤷ˽񤭹
+     */
     void *__readbuf;
     void *__writebuf;
 
-    Scheduler *__scheduler;
+    // 줿Υ롼
     TaskGroup *__taskGroup;
 
-    int __renew_flag; // 줿ե饰
+    // Υ줿ο
+    int __renew_flag;
+
+    // Υ SPE 줿ݤ 1: Yes, 0: No
     int __flag_renewTask;
 
+    // ᥤ¦줿Τ
+    // SPE 줿ΤˤäơǡΰѤäƤ롣
+    // Τ if (__flag_renewTask) ϢȯΤϤ褯ʤΤ
+    // ؿݥ󥿤ǻäƤ
+    void (SchedTask::*ex_read)(void);
+    void (SchedTask::*ex_exec)(void);
+    void (SchedTask::*ex_write)(void);
+    
     /* functions */
-    SchedTaskBase* next(Scheduler *, SchedTaskBase *);
-
     void __init__(void);
 
     // override
     void read(void);
     void exec(void);
     void write(void);
+    SchedTaskBase* next(Scheduler *, SchedTaskBase *);
 
     // 桼Ѿ
     // 줾Υб򵭽Ҥ
     virtual int run(void* r, void *w) { return 0; }
 
+    /**
+     * PPE 줿Ф롢read,exec,write °(?)
+     */
+    void ex_read_normal(void);
+    void ex_exec_normal(void);
+    void ex_write_normal(void);
+
+    /**
+     * SPE 줿Ф롢read,exec,write °(?)
+     */
+    void ex_read_renew(void);
+    void ex_exec_renew(void);
+    void ex_write_renew(void);
+
     void* get_input(void *buff, int index);
     void* get_output(void *buff, int index);
     int get_param(int index);