Mercurial > hg > Game > Cerium
view TaskManager/kernel/ppe/Task.h @ 706:b2b4a1243961 draft simple-task-regression
no compile error on Cell. Regression Test.
Cell failed some how.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2009 20:21:59 +0900 |
parents | 0c8ad8d99656 |
children | 97adb3fe85c6 |
line wrap: on
line source
#ifndef INCLUDED_TASK #define INCLUDED_TASK #include "base.h" #include "types.h" #include "ListData.h" #include "SimpleTask.h" #define MAX_PARAMS 8 #ifndef SIMPLE_TASK class Task : public SimpleTask { public: // variables BASE_NEW_DELETE(Task); int param_count; // 4 byte memaddr param[MAX_PARAMS]; // 4*MAX_PARAMS byte ListData inData __attribute__ ((aligned (DEFAULT_ALIGNMENT))); ListData outData __attribute__ ((aligned (DEFAULT_ALIGNMENT))); public: // functions int add_inData_t(memaddr addr, int size); // unsigned int ではなく 64bit int add_outData_t(memaddr addr, int size); // unsigned int ではなく 64bit int add_data(ListData &list, memaddr addr, int size); int add_param_t(memaddr param); // obsolete. do not use. int set_param_t(int index, memaddr param); #define add_param(param) add_param_t((memaddr)(param)) #define set_param(index,param) set_param_t(index, (memaddr) (param)) #define add_inData(addr, size) \ add_inData_t((memaddr)(addr), (size)); #define add_outData(addr, size) \ add_outData_t((memaddr)(addr), (size)); }; #else class SchedTask; class Task { public: // variables int task_size; int command; int param_count; int inData_count; int outData_count; int inData_offset; int outData_offset; void *data[] __attribute__ ((aligned (DEFAULT_ALIGNMENT))); public: // functions void print(); memaddr *param(int index) { memaddr p = (memaddr)data + sizeof(memaddr)*index; return (memaddr *)p; } ListElement *inData(int index) { memaddr p = (memaddr)data + inData_offset; p += sizeof(ListElement)*index; return (ListElement*)p; } ListElement *outData(int index) { memaddr p = (memaddr)data + outData_offset; p += sizeof(ListElement)* index; return (ListElement*)p; } static int calc_size(int params, int ins, int outs) { int size = round_up16(sizeof(Task)) + round_up16(sizeof(memaddr)*params) + round_up16(sizeof(ListElement)*ins) + round_up16(sizeof(ListElement)*outs); #if 0 printf(" calc_size 0x%x\n",size); #endif return size; } void init(int task_id, int params, int ins, int outs) { set_task_id(task_id); param_count = params; inData_count = ins; outData_count = outs; inData_offset = round_up16(sizeof(memaddr)*params); outData_offset = round_up16(inData_offset+sizeof(ListElement)*ins); task_size = round_up16(sizeof(Task)+outData_offset+sizeof(ListElement)*outs); #if 0 printf("task_id %d params %d ins %d outs %d\n",task_id, params, ins, outs); printf(" inData_offset %d\n",inData_offset); printf(" outData_offset %d\n",outData_offset); printf(" task_size 0x%x\n",task_size); this->print(); #endif } int size() { return task_size; } int inData_total_size() { int size = 0; ListElement *in= inData(0); for(int i=0; i< inData_count; i++) { size += in[i].size; } return size; } int outData_total_size() { int size = 0; ListElement *out= outData(0); for(int i=0; i< outData_count; i++) { size += out[i].size; } return size; } void set_inData_t( int index, memaddr addr, int size) { ListElement *list = inData(index); #ifdef __CERIUM_CELL__ list->addr = (uint32)addr; #else list->addr = addr; #endif list->size = size; } void set_outData_t(int index, memaddr addr, int size) { ListElement *list = outData(index); #ifdef __CERIUM_CELL__ list->addr = (uint32)addr; #else list->addr = addr; #endif list->size = size; } void set_task_id(int id) { command = id; } void set_param_t(int index, memaddr param) { memaddr *p = (memaddr*)this->param(index); *p = param; } Task * next() { char *p = (char*)this; p += size(); return (Task*)p; } #define set_param(index,param) set_param_t(index, (memaddr) (param)) #define set_inData(index, addr, size) \ set_inData_t(index, (memaddr)(addr), (size)); #define set_outData(index, addr, size) \ set_outData_t(index, (memaddr)(addr), (size)); }; #endif typedef Task* TaskPtr; #endif