42
|
1 #ifndef INCLUDED_SCHED_TASK
|
|
2 #define INCLUDED_SCHED_TASK
|
|
3
|
109
|
4 #ifndef INCLUDED_BASE_H_
|
|
5 # include "base.h"
|
|
6 #endif
|
|
7
|
42
|
8 #ifndef INCLUDED_SCHEDULER
|
|
9 # include "Scheduler.h"
|
|
10 #endif
|
|
11
|
|
12 #ifndef INCLUDED_SCHED_TASK_BASE
|
|
13 # include "SchedTaskBase.h"
|
|
14 #endif
|
|
15
|
109
|
16 #ifndef INCLUDED_LIST_DATA
|
|
17 # include "ListData.h"
|
|
18 #endif
|
|
19
|
|
20 #ifndef INCLUDED_TASK_GROUP
|
|
21 # include "TaskGroup.h"
|
|
22 #endif
|
|
23
|
|
24
|
42
|
25 class SchedTask : public SchedTaskBase {
|
|
26 public:
|
109
|
27 /* constructor */
|
|
28 SchedTask(TaskListPtr, TaskPtr, ListDataPtr, ListDataPtr, Scheduler*);
|
|
29 ~SchedTask(void);
|
88
|
30
|
109
|
31 BASE_NEW_DELETE(SchedTask);
|
42
|
32
|
|
33 /* variables */
|
109
|
34 // 現在スケジューラが持つ TaskList と、このタスクに対応する Task
|
|
35 TaskListPtr __list;
|
|
36 TaskPtr __task;
|
|
37
|
|
38 // read/write 用の ListData
|
|
39 ListDataPtr __inListData;
|
|
40 ListDataPtr __outListData;
|
42
|
41
|
109
|
42 // read データ、write 用のバッファ
|
|
43 // readbuf には タスク登録時に設定した入力データが入っている。
|
|
44 // writebuf にデータを描き込んでおくと、
|
|
45 // タスク登録時に設定した出力先に書き込む
|
|
46 void *__readbuf;
|
|
47 void *__writebuf;
|
|
48
|
|
49 Scheduler *__scheduler;
|
|
50 TaskGroup *__taskGroup;
|
|
51
|
|
52 int __renew_flag; // タスクが生成されたフラグ
|
|
53 int __flag_renewTask;
|
42
|
54
|
|
55 /* functions */
|
|
56 SchedTaskBase* next(Scheduler *, SchedTaskBase *);
|
|
57
|
109
|
58 void __init__(void);
|
|
59
|
42
|
60 // override
|
|
61 void read(void);
|
|
62 void exec(void);
|
|
63 void write(void);
|
82
|
64
|
109
|
65 // ここをユーザが継承して
|
|
66 // それぞれのタスクに対応した処理を記述する
|
82
|
67 virtual int run(void* r, void *w) { return 0; }
|
109
|
68
|
|
69 void* get_input(void *buff, int index);
|
|
70 void* get_output(void *buff, int index);
|
|
71 int get_param(int index);
|
|
72
|
|
73 TaskPtr create_task(int cmd);
|
|
74 void wait_task(TaskPtr waitTask);
|
|
75
|
|
76 void* global_alloc(int id, int size);
|
|
77 void* global_get(int id);
|
|
78 void global_free(int id);
|
|
79
|
|
80 void mainMem_alloc(int id, int size);
|
|
81 void mainMem_wait(void);
|
|
82 void* mainMem_get(int id);
|
|
83
|
|
84 void *allocate(int size);
|
|
85
|
|
86 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
|
|
87 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask);
|
|
88 void dma_wait(uint32 mask);
|
|
89
|
|
90 class STaskManager {
|
|
91 public:
|
|
92 STaskManager(SchedTask *_t) {
|
|
93 outer = _t;
|
|
94 }
|
|
95
|
|
96 BASE_NEW_DELETE(STaskManager);
|
|
97
|
|
98 SchedTask *outer;
|
|
99
|
|
100 void* get_input(int index) {
|
|
101 return outer->get_input(outer->__readbuf, index);
|
|
102 }
|
|
103
|
|
104 void* get_output(int index) {
|
|
105 return outer->get_output(outer->__writebuf, index);
|
|
106 }
|
|
107
|
|
108 int get_param(int index) {
|
|
109 return outer->get_param(index);
|
|
110 }
|
|
111
|
|
112 TaskPtr create_task(int cmd) {
|
|
113 return outer->create_task(cmd);
|
|
114 }
|
|
115
|
|
116 void wait_task(TaskPtr waitTask) {
|
|
117 outer->wait_task(waitTask);
|
|
118 }
|
|
119
|
|
120 void* global_alloc(int id, int size) {
|
|
121 return outer->global_alloc(id, size);
|
|
122 }
|
|
123
|
|
124 void* global_get(int id) {
|
|
125 return outer->global_get(id);
|
|
126 }
|
|
127
|
|
128 void global_free(int id) {
|
|
129 outer->global_free(id);
|
|
130 }
|
|
131
|
|
132 void mainMem_alloc(int id, int size) {
|
|
133 outer->mainMem_alloc(id, size);
|
|
134 }
|
|
135
|
|
136 void mainMem_wait(void) {
|
|
137 outer->mainMem_wait();
|
|
138 }
|
|
139
|
|
140 void* mainMem_get(int id) {
|
|
141 return outer->mainMem_get(id);
|
|
142 }
|
|
143
|
|
144 void *allocate(int size) {
|
|
145 return outer->allocate(size);
|
|
146 }
|
|
147
|
|
148 void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) {
|
|
149 outer->dma_load(buf, addr, size, mask);
|
|
150 }
|
|
151
|
|
152 void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) {
|
|
153 outer->dma_store(buf, addr, size, mask);
|
|
154 }
|
|
155
|
|
156 void dma_wait(uint32 mask) {
|
|
157 outer->dma_wait(mask);
|
|
158 }
|
|
159 };
|
|
160
|
|
161 STaskManager *smanager;
|
42
|
162 };
|
|
163
|
|
164 #endif
|
109
|
165
|
|
166 extern SchedTask* CreateSchedTask(TaskListPtr, Scheduler *);
|