Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/SchedTask.h @ 501:4a2c9ff53605
Cell inData/outData DMA removal
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 11 Oct 2009 18:20:33 +0900 |
parents | 0b933bef0328 |
children | 1d4a8a86f26b |
rev | line source |
---|---|
42 | 1 #ifndef INCLUDED_SCHED_TASK |
2 #define INCLUDED_SCHED_TASK | |
3 | |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
4 #include <stdio.h> |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
5 #include <stdlib.h> |
308 | 6 #include "base.h" |
7 #include "Scheduler.h" | |
8 #include "SchedTaskBase.h" | |
9 #include "ListData.h" | |
10 #include "TaskGroup.h" | |
373 | 11 #include "MemList.h" |
109 | 12 |
308 | 13 class SchedTask : public SchedTaskBase { |
14 public: | |
109 | 15 /* constructor */ |
308 | 16 SchedTask(); |
17 virtual ~SchedTask(); | |
88 | 18 |
109 | 19 BASE_NEW_DELETE(SchedTask); |
42 | 20 |
308 | 21 private: |
22 /* variables */ | |
23 | |
24 // Task を実行するスケジューラ自身 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
25 Scheduler *scheduler; |
395 | 26 |
308 | 27 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
28 TaskListPtr list; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
29 TaskPtr task; |
308 | 30 |
31 // read/write 用の ListData | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
32 ListDataPtr inListData; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
33 ListDataPtr outListData; |
308 | 34 |
35 /** | |
36 * read データ、write 用のバッファ | |
37 * readbuf には タスク登録時に設定した入力データが入っている。 | |
38 * writebuf にデータを描き込んでおくと、 | |
39 * タスク登録時に設定した出力先に書き込む | |
40 */ | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
41 void *readbuf; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
42 void *writebuf; |
308 | 43 |
44 // Task の、Tasklist での位置。(task = &list[cur_index-1]) | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
45 int cur_index; |
308 | 46 |
47 // タスク内で生成されたタスクのグループ | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
48 TaskGroup *taskGroup; |
308 | 49 |
50 // このタスク内で生成されたタスクの数 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
51 int renew_flag; |
308 | 52 |
53 // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
54 int flag_renewTask; |
308 | 55 |
56 // タスクがメインメモリ側で生成されたものか、 | |
57 // SPE で生成されたものかによって、データの扱いが変わってくる。 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
58 // そのために if (flag_renewTask) を連発するのはよくないので |
308 | 59 // 関数ポインタで持っておく |
60 void (SchedTask::*ex_init)(); | |
61 void (SchedTask::*ex_read)(); | |
62 void (SchedTask::*ex_exec)(); | |
63 void (SchedTask::*ex_write)(); | |
64 SchedTaskBase* (SchedTask::*ex_next)(); | |
373 | 65 |
308 | 66 /* functions */ |
67 | |
68 // override | |
69 void read(); | |
70 void exec(); | |
71 void write(); | |
72 SchedTaskBase* next(Scheduler *, SchedTaskBase *); | |
73 | |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
463
diff
changeset
|
74 // タスクの処理は、task_list に登録された C の関数によっておこなう |
308 | 75 |
76 //--- System API --- | |
77 SchedTask* get_nextTask(TaskListPtr list); | |
373 | 78 |
308 | 79 /** |
80 * PPE で生成されたタスクに対する | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
81 * init, read,exec,write,next の付属(?)処理 |
308 | 82 */ |
83 void ex_init_normal(); | |
84 void ex_read_normal(); | |
85 void ex_exec_normal(); | |
86 void ex_write_normal(); | |
87 SchedTaskBase* ex_next_normal(); | |
88 | |
89 /** | |
90 * SPE で生成されたタスクに対する | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
91 * inti, ead,exec,write,next の付属(?)処理 |
308 | 92 */ |
93 void ex_init_renew(); | |
94 void ex_read_renew(); | |
95 void ex_exec_renew(); | |
96 void ex_write_renew(); | |
97 SchedTaskBase* ex_next_renew(); | |
98 | |
99 public: | |
100 /* functions */ | |
101 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
102 void setRenew(); |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
103 void init(TaskListPtr _list, TaskPtr _task, int index, |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
104 // ListDataPtr rbuf, ListDataPtr wbuf, |
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
105 Scheduler* sc); |
308 | 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); | |
373 | 123 void global_set(int id, void *addr); |
308 | 124 void global_free(int id); |
373 | 125 MemList* createMemList(int size, int count); |
308 | 126 |
127 void mainMem_alloc(int id, int size); | |
128 void mainMem_wait(); | |
129 void* mainMem_get(int id); | |
130 | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
131 MemorySegment * get_segment(memaddr addr, MemList *m); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
132 uint32 get_tag(); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
133 void put_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
134 void wait_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
135 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
136 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
137 |
308 | 138 void *allocate(int size); |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
139 void free_(void *p) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
140 scheduler->free_(p); |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
141 } |
308 | 142 |
143 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask); | |
144 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask); | |
145 void dma_wait(uint32 mask); | |
334
20f2459041cb
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
316
diff
changeset
|
146 void show_dma_wait(); |
373 | 147 |
310 | 148 /*! |
149 SPU用の get_input, get_output | |
150 */ | |
308 | 151 |
310 | 152 void* get_input(int index) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
153 return get_input(readbuf, index); |
310 | 154 } |
373 | 155 |
310 | 156 void* get_output(int index) { |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
157 return get_output(writebuf, index); |
373 | 158 } |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
159 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
160 /* system call */ |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
161 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
162 FILE *stdout_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
163 FILE *stderr_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
164 FILE *stdin_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
165 int fprintf(FILE * stream, const char * format, ...); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
166 int printf(const char * format, ...); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
167 |
302 | 168 }; |
109 | 169 |
308 | 170 const int SCHED_TASK_NORMAL = 0; |
171 const int SCHED_TASK_RENEW = 1; | |
172 | |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
173 extern SchedTask* createSchedTask(Scheduler *,TaskPtr); |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
174 extern void loadSchedTask(Scheduler *scheduler,TaskPtr task); |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
175 |
302 | 176 |
177 #endif | |
308 | 178 |