42
|
1 #ifndef INCLUDED_SCHED_TASK
|
|
2 #define INCLUDED_SCHED_TASK
|
|
3
|
308
|
4 #include "base.h"
|
|
5 #include "Scheduler.h"
|
|
6 #include "SchedTaskBase.h"
|
|
7 #include "ListData.h"
|
|
8 #include "TaskGroup.h"
|
109
|
9
|
308
|
10 class SchedTask : public SchedTaskBase {
|
|
11 public:
|
109
|
12 /* constructor */
|
308
|
13 SchedTask();
|
|
14 virtual ~SchedTask();
|
88
|
15
|
109
|
16 BASE_NEW_DELETE(SchedTask);
|
42
|
17
|
308
|
18 private:
|
|
19 /* variables */
|
|
20
|
|
21 // Task を実行するスケジューラ自身
|
|
22 Scheduler *__scheduler;
|
|
23
|
|
24 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task
|
|
25 TaskListPtr __list;
|
|
26 TaskPtr __task;
|
|
27
|
|
28 // read/write 用の ListData
|
|
29 ListDataPtr __inListData;
|
|
30 ListDataPtr __outListData;
|
|
31
|
|
32 /**
|
|
33 * read データ、write 用のバッファ
|
|
34 * readbuf には タスク登録時に設定した入力データが入っている。
|
|
35 * writebuf にデータを描き込んでおくと、
|
|
36 * タスク登録時に設定した出力先に書き込む
|
|
37 */
|
|
38 void *__readbuf;
|
|
39 void *__writebuf;
|
|
40
|
|
41 // Task の、Tasklist での位置。(task = &list[cur_index-1])
|
|
42 int __cur_index;
|
|
43
|
|
44 // タスク内で生成されたタスクのグループ
|
|
45 TaskGroup *__taskGroup;
|
|
46
|
|
47 // このタスク内で生成されたタスクの数
|
|
48 int __renew_flag;
|
|
49
|
|
50 // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No
|
|
51 int __flag_renewTask;
|
|
52
|
|
53 // タスクがメインメモリ側で生成されたものか、
|
|
54 // SPE で生成されたものかによって、データの扱いが変わってくる。
|
|
55 // そのために if (__flag_renewTask) を連発するのはよくないので
|
|
56 // 関数ポインタで持っておく
|
|
57 void (SchedTask::*ex_init)();
|
|
58 void (SchedTask::*ex_read)();
|
|
59 void (SchedTask::*ex_exec)();
|
|
60 void (SchedTask::*ex_write)();
|
|
61 SchedTaskBase* (SchedTask::*ex_next)();
|
|
62
|
|
63 /* functions */
|
|
64
|
|
65 // override
|
|
66 void read();
|
|
67 void exec();
|
|
68 void write();
|
|
69 SchedTaskBase* next(Scheduler *, SchedTaskBase *);
|
|
70
|
298
|
71 // ここをユーザが継承して
|
|
72 // それぞれのタスクに対応した処理を記述する
|
308
|
73 virtual int run(void* r, void *w) { return 0; }
|
|
74
|
|
75 int (SchedTask::*run_func)(void* r, void *w);
|
|
76
|
|
77 //--- System API ---
|
|
78 SchedTask* get_nextTask(TaskListPtr list);
|
|
79
|
|
80 /**
|
|
81 * PPE で生成されたタスクに対する
|
|
82 * __init__, read,exec,write,next の付属(?)処理
|
|
83 */
|
|
84 void ex_init_normal();
|
|
85 void ex_read_normal();
|
|
86 void ex_exec_normal();
|
|
87 void ex_write_normal();
|
|
88 SchedTaskBase* ex_next_normal();
|
|
89
|
|
90 /**
|
|
91 * SPE で生成されたタスクに対する
|
|
92 * __inti__, ead,exec,write,next の付属(?)処理
|
|
93 */
|
|
94 void ex_init_renew();
|
|
95 void ex_read_renew();
|
|
96 void ex_exec_renew();
|
|
97 void ex_write_renew();
|
|
98 SchedTaskBase* ex_next_renew();
|
|
99
|
|
100 public:
|
|
101 /* functions */
|
|
102
|
|
103 void __setRenew();
|
|
104 void __init__(TaskListPtr _list, TaskPtr _task, int index,
|
|
105 ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc);
|
|
106
|
|
107 //--- User API ---
|
|
108 int get_cpuid();
|
|
109
|
|
110 void* get_input(void *buff, int index);
|
|
111 void* get_output(void *buff, int index);
|
|
112 uint32 get_inputAddr(int index);
|
|
113 uint32 get_outputAddr(int index);
|
|
114 int get_inputSize(int index);
|
|
115 int get_outputSize(int index);
|
|
116 int get_param(int index);
|
|
117
|
|
118 TaskPtr create_task(int cmd);
|
|
119 void wait_task(TaskPtr waitTask);
|
|
120
|
|
121 void* global_alloc(int id, int size);
|
|
122 void* global_get(int id);
|
|
123 void global_free(int id);
|
|
124
|
|
125 void mainMem_alloc(int id, int size);
|
|
126 void mainMem_wait();
|
|
127 void* mainMem_get(int id);
|
|
128
|
|
129 void *allocate(int size);
|
|
130
|
|
131 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
|
|
132 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask);
|
|
133 void dma_wait(uint32 mask);
|
|
134
|
310
|
135
|
|
136 /*!
|
|
137 SPU用の get_input, get_output
|
|
138 */
|
308
|
139
|
310
|
140 void* get_input(int index) {
|
|
141 return get_input(__readbuf, index);
|
|
142 }
|
|
143
|
|
144 void* get_output(int index) {
|
|
145 return get_output(__writebuf, index);
|
|
146 }
|
302
|
147 };
|
109
|
148
|
308
|
149 const int SCHED_TASK_NORMAL = 0;
|
|
150 const int SCHED_TASK_RENEW = 1;
|
|
151
|
184
|
152 extern SchedTask* createSchedTask(TaskPtr);
|
302
|
153
|
|
154 #endif
|
308
|
155
|