Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/SchedTask.h @ 638:671fca057ad3
hmmmm
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 Nov 2009 18:18:20 +0900 |
parents | 8cc609285bbe |
children | 0692b08f1cd6 |
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" | |
619 | 10 #include "HTask.h" |
373 | 11 #include "MemList.h" |
109 | 12 |
634 | 13 #ifdef SIMPLE_TASK |
14 #define Task SimpleTask | |
15 #define TaskPtr SimpleTaskPtr | |
16 #endif | |
17 | |
308 | 18 class SchedTask : public SchedTaskBase { |
19 public: | |
109 | 20 /* constructor */ |
308 | 21 SchedTask(); |
22 virtual ~SchedTask(); | |
88 | 23 |
109 | 24 BASE_NEW_DELETE(SchedTask); |
42 | 25 |
308 | 26 private: |
27 /* variables */ | |
28 | |
29 // Task を実行するスケジューラ自身 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
30 Scheduler *scheduler; |
395 | 31 |
308 | 32 // 現在スケジューラが実行している TaskList と、このタスクに対応する Task |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
33 TaskListPtr list; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
34 TaskPtr task; |
308 | 35 |
567 | 36 // read/write 用の ListData |
37 ListDataPtr inListData; | |
38 ListDataPtr outListData; | |
634 | 39 #ifdef SIMPLE_TASK |
40 memaddr *param; | |
41 #endif | |
567 | 42 |
308 | 43 /** |
44 * read データ、write 用のバッファ | |
45 * readbuf には タスク登録時に設定した入力データが入っている。 | |
46 * writebuf にデータを描き込んでおくと、 | |
47 * タスク登録時に設定した出力先に書き込む | |
48 */ | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
49 void *readbuf; |
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
50 void *writebuf; |
308 | 51 |
52 // 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
|
53 int cur_index; |
308 | 54 |
55 /* functions */ | |
56 | |
57 // override | |
58 void read(); | |
59 void exec(); | |
60 void write(); | |
61 SchedTaskBase* next(Scheduler *, SchedTaskBase *); | |
62 | |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
463
diff
changeset
|
63 // タスクの処理は、task_list に登録された C の関数によっておこなう |
308 | 64 |
65 //--- System API --- | |
66 SchedTask* get_nextTask(TaskListPtr list); | |
373 | 67 |
308 | 68 |
69 public: | |
70 /* functions */ | |
71 | |
483
0b933bef0328
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
72 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
|
73 // ListDataPtr rbuf, ListDataPtr wbuf, |
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
74 Scheduler* sc); |
308 | 75 |
76 //--- User API --- | |
634 | 77 #ifdef SIMPLE_TASK |
78 int read_size() { return task->r_size; } | |
79 int write_size() { return task->w_size; } | |
80 void set_write_size(int w) { task->w_size = w; } | |
81 #endif | |
308 | 82 int get_cpuid(); |
83 | |
84 void* get_input(void *buff, int index); | |
85 void* get_output(void *buff, int index); | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
86 memaddr get_inputAddr(int index); |
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
87 memaddr get_outputAddr(int index); |
506 | 88 // 書き出しを追加する API がない... |
308 | 89 int get_inputSize(int index); |
90 int get_outputSize(int index); | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
91 memaddr get_param(int index); |
308 | 92 |
93 void* global_alloc(int id, int size); | |
94 void* global_get(int id); | |
373 | 95 void global_set(int id, void *addr); |
308 | 96 void global_free(int id); |
373 | 97 MemList* createMemList(int size, int count); |
308 | 98 |
99 void mainMem_alloc(int id, int size); | |
100 void mainMem_wait(); | |
629
8843edf37c0e
Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
101 memaddr mainMem_get(int id); |
308 | 102 |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
103 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
|
104 uint32 get_tag(); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
105 void put_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
106 void wait_segment(MemorySegment *s); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
107 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
108 |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
109 |
308 | 110 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
|
111 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
|
112 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
|
113 } |
308 | 114 |
506 | 115 /* これは禁止するべき */ |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
116 void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask); |
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
117 void dma_store(void *buf,memaddr addr, uint32 size, uint32 mask); |
308 | 118 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
|
119 void show_dma_wait(); |
373 | 120 |
310 | 121 /*! |
122 SPU用の get_input, get_output | |
123 */ | |
308 | 124 |
310 | 125 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
|
126 return get_input(readbuf, index); |
310 | 127 } |
373 | 128 |
310 | 129 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
|
130 return get_output(writebuf, index); |
373 | 131 } |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
132 |
619 | 133 // user |
134 HTaskPtr create_task(int cmd); | |
634 | 135 HTaskPtr create_task(int cmd, memaddr r, long rs, memaddr w, long ws); |
136 | |
619 | 137 void set_task_depend(HTaskPtr master, HTaskPtr slave); |
138 void spawn_task(HTaskPtr); | |
139 void set_task_cpu(HTaskPtr, CPU_TYPE); | |
140 void* allocate(int size,int align); | |
141 Scheduler* get_scheduler(); | |
142 | |
466
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
143 /* system call */ |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
144 |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
145 FILE *stdout_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
146 FILE *stderr_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
147 FILE *stdin_; |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
148 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
|
149 int printf(const char * format, ...); |
4fa8760e18c2
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
150 |
302 | 151 }; |
109 | 152 |
308 | 153 |
403
8611780d479f
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
154 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
|
155 |
302 | 156 |
157 #endif | |
308 | 158 |