Mercurial > hg > Game > Cerium
view TaskManager/kernel/ppe/Task.h @ 800:54f0180cea0f draft
run16 word count ( not yet worked. )
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 21 May 2010 07:47:25 +0900 |
parents | 64f1d80dc650 |
children | b662e9dd26b0 |
line wrap: on
line source
#ifndef INCLUDED_TASK #define INCLUDED_TASK #include "base.h" #include "types.h" #include "ListData.h" #include "SimpleTask.h" class SchedTask; class Scheduler; 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(Scheduler *s); 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); 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); } 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)); }; typedef Task* TaskPtr; #endif