Mercurial > hg > Game > Cerium
view TaskManager/kernel/ppe/Task.h @ 689:ecf63089f5bb draft
Task Array generation worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 06 Dec 2009 23:03:28 +0900 |
parents | 77c89477daa8 |
children | 107e6e77f482 |
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_size; // 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_size; int inData_size; int outData_size; int inData_offset; int outData_offset; void *data[] __attribute__ ((aligned (DEFAULT_ALIGNMENT))); // memaddr param[param_size]; // ListEelemnt inData[inData_size]; // ListElement outData[outData_size]; public: // functions // int add_inData_t(memaddr addr, int size); // int add_outData_t(memaddr addr, int size); void print(); memaddr param(int index) { return (memaddr)data + sizeof(memaddr)*index; } memaddr inData(int index) { memaddr p = (memaddr)data + inData_offset; return p + sizeof(ListElement)*index; } memaddr outData(int index) { memaddr p = (memaddr)data + outData_offset; return p + sizeof(ListElement)* index; } void set_param_length(int i) { param_size = i; inData_offset = round_up16(sizeof(Task))+param_size*sizeof(memaddr); } void set_inData_length(int length) { inData_size = length; if (inData_offset==0) { printf("call set_param_length before\n"); } outData_offset = round_up16(inData_offset+inData_size*sizeof(ListElement)); } void set_outData_length(int length) { outData_size = length; if (outData_offset==0) { printf("call set_outData_length before\n"); } task_size = round_up16(outData_offset+outData_size*sizeof(ListElement)); } int size() { if (task_size==0) { printf("call set_outData_length before\n"); } return task_size; } void set_inData_t( int index, memaddr addr, int size); void set_outData_t(int index, memaddr addr, int 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; } static int count_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); return size; } // #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)); #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