Mercurial > hg > Members > kono > Cerium
annotate TaskManager/kernel/schedule/Scheduler.cc @ 619:0decff4e867b
RenewTask removal
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Nov 2009 02:02:30 +0900 |
parents | 42c94f85c779 |
children | 5b178db5988a |
rev | line source |
---|---|
48 | 1 #include <stdio.h> |
50 | 2 #include <stdlib.h> |
42 | 3 #include "Scheduler.h" |
4 #include "SchedNop.h" | |
5 #include "error.h" | |
386 | 6 #include <assert.h> |
42 | 7 |
313
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
8 /* |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
9 * Edit kernel/schedule/xx.cc, Cell/spe/xx.cc will be over writen by this. |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
10 * Do not edit Cell/spe/xx.cc unless there is no kernel/schedule/xx.cc files. |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
11 */ |
c9f8cfcdc5c2
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
12 |
109 | 13 Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; |
14 | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
15 Scheduler::~Scheduler() |
109 | 16 { |
17 delete connector; | |
18 } | |
19 | |
301
bcb81858aa62
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
20 /*! @brief speTaskの入出力のパイプラインバッファを確保する |
bcb81858aa62
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
21 */ |
bcb81858aa62
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
22 |
42 | 23 void |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
24 Scheduler::init() |
42 | 25 { |
388
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
26 hash = 0; |
42 | 27 init_impl(); |
109 | 28 |
29 for (int i = 0; i < 2; i++) { | |
373 | 30 buff_taskList[i] = (TaskListPtr)allocate(sizeof(TaskList)); |
109 | 31 } |
373 | 32 |
109 | 33 buffFlag_taskList = 0; |
34 | |
298 | 35 // bzero でもいいけど |
109 | 36 for (int i = 0; i < MAX_GLOBAL_AREA; i++) { |
373 | 37 globalList[i] = NULL; |
109 | 38 } |
39 | |
40 for (int i = 0; i < MAX_MAINMEM_AREA; i++) { | |
373 | 41 mainMemList[i] = NULL; |
109 | 42 } |
373 | 43 |
109 | 44 |
42 | 45 } |
46 | |
47 void | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
48 Scheduler::run() |
42 | 49 { |
50 task1 = new SchedNop(); | |
51 task2 = new SchedNop(); | |
52 task3 = new SchedNop(); | |
53 | |
54 // main loop | |
55 do { | |
373 | 56 __debug("----------\n"); |
57 task3->write(); | |
58 task2->exec(); | |
59 task1->read(); | |
468
bd5b93d39597
test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
60 delete task3; |
42 | 61 |
373 | 62 task3 = task2; |
63 task2 = task1; | |
468
bd5b93d39597
test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
64 task1 = task1->next(this, 0); |
42 | 65 } while (task1); |
66 | |
67 delete task3; | |
68 delete task2; | |
50 | 69 } |
48 | 70 |
50 | 71 |
72 void | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
73 Scheduler::finish() |
50 | 74 { |
109 | 75 free(buff_taskList[0]); |
76 free(buff_taskList[1]); | |
42 | 77 } |
78 | |
109 | 79 /** |
298 | 80 * あらかじめ memory allocte してある TaskList の領域を |
81 * パイプラインの各処理が交代して使う。 | |
109 | 82 */ |
42 | 83 TaskListPtr |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
84 Scheduler::get_curListBuf() |
42 | 85 { |
109 | 86 buffFlag_taskList ^= 1; |
87 | |
88 return buff_taskList[buffFlag_taskList]; | |
89 } | |
90 | |
91 | |
92 void | |
93 Scheduler::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) | |
94 { | |
95 connector->dma_load(buf, addr, size, mask); | |
96 } | |
97 | |
98 void | |
99 Scheduler::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask) | |
100 { | |
101 connector->dma_store(buf, addr, size, mask); | |
102 } | |
103 | |
104 void | |
105 Scheduler::dma_wait(uint32 mask) | |
106 { | |
107 connector->dma_wait(mask); | |
108 } | |
109 | |
110 void | |
111 Scheduler::dma_loadList(ListDataPtr list, void *buff, uint32 mask) | |
112 { | |
113 connector->dma_loadList(list, buff, mask); | |
42 | 114 } |
115 | |
116 | |
109 | 117 void |
118 Scheduler::dma_storeList(ListDataPtr list, void *buff, uint32 mask) | |
119 { | |
120 return connector->dma_storeList(list, buff, mask); | |
121 } | |
122 | |
123 void | |
124 Scheduler::mail_write(uint32 data) | |
125 { | |
126 connector->mail_write(data); | |
127 } | |
128 | |
129 uint32 | |
501
4a2c9ff53605
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
130 Scheduler::mail_read() |
109 | 131 { |
132 return connector->mail_read(); | |
133 } | |
134 | |
135 | |
386 | 136 /* |
137 ここから下は、memory 以下にあるべき | |
138 */ | |
139 | |
109 | 140 void* |
141 Scheduler::global_alloc(int id, int size) | |
142 { | |
143 globalList[id] = allocate(size); | |
144 return globalList[id]; | |
145 } | |
146 | |
147 void* | |
148 Scheduler::global_get(int id) | |
149 { | |
150 return globalList[id]; | |
151 } | |
152 | |
153 void | |
373 | 154 Scheduler::global_set(int id, void *addr) |
155 { | |
156 globalList[id] = addr; | |
157 } | |
158 | |
159 void | |
109 | 160 Scheduler::global_free(int id) |
161 { | |
162 free(globalList[id]); | |
163 globalList[id] = NULL; | |
164 } | |
165 | |
166 /** | |
298 | 167 * mainMem_alloc で確保したメインメモリの領域アドレスを返す。 |
168 * これは Fifo, Cell で共通 | |
109 | 169 */ |
170 void* | |
171 Scheduler::mainMem_get(int id) | |
172 { | |
173 return mainMemList[id]; | |
42 | 174 } |
175 | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
176 /** |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
177 * Task load API |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
178 */ |
425 | 179 void |
442 | 180 Scheduler::allocate_code_segment(int size, int count) |
425 | 181 { |
437 | 182 // 既に overlay 領域があるので、それを追加する必要がある... |
442 | 183 code_segment_pool = createMemList(size, count); |
425 | 184 } |
42 | 185 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
186 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
187 load_task(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
188 { |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
189 MemorySegment *s = m->get_segment( |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
190 task_list[task_id].location, |
437 | 191 m->code_segment_pool, |
192 task_list[task_id].end-task_list[task_id].location); | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
193 task_list[task_id].segment = s; |
506 | 194 #if 0 |
461 | 195 fprintf(stderr,"loadng task id %d at 0x%x entry 0x%x\n",task_id, |
196 (unsigned int)(task_list[task_id].segment->data ), | |
197 (unsigned int)( | |
198 (char*)task_list[task_id].segment->data + | |
199 task_list[task_id].entry_offset)); | |
506 | 200 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
201 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
202 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
203 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
204 null_loader(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
205 { |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
206 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
207 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
208 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
209 wait_load(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
210 { |
523 | 211 #if 0 |
442 | 212 MemorySegment *s = task_list[task_id].segment; |
213 if (s) | |
214 fprintf(stderr,"wait load task id %d 0x%x\n",task_id,(int)s->data); | |
215 else | |
216 fprintf(stderr,"wait load task id %d 000000\n",task_id); | |
506 | 217 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
218 // wait for code segment load |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
219 m->wait_segment(task_list[task_id].segment); |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
220 // calcurate call address |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
221 TaskObjectRun run = |
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
222 (TaskObjectRun)( |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
223 (char*)task_list[task_id].segment->data + |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
224 task_list[task_id].entry_offset); |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
225 task_list[task_id].run = run; |
506 | 226 #if 0 |
439 | 227 fprintf(stderr,"wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
228 (unsigned int)run, |
439 | 229 task_list[task_id].entry_offset); |
506 | 230 #endif |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
231 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
232 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
233 static void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
234 null_waiter(Scheduler *m, int task_id) |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
235 { |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
236 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
237 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
238 extern void |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
239 register_task(int cmd, TaskObjectRun run) |
42 | 240 { |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
241 task_list[cmd].run = run; |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
242 task_list[cmd].load = null_loader; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
243 task_list[cmd].wait = null_waiter; |
42 | 244 } |
373 | 245 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
246 extern void |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
247 register_dynamic_task(int cmd, |
441 | 248 memaddr start, int size, |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
249 TaskObjectRun run, int entry_offset) |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
250 { |
464
01b321c86747
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
251 task_list[cmd].run = run; |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
252 task_list[cmd].location = start; |
442 | 253 size &= 0xfffffffe; |
441 | 254 task_list[cmd].end = start+size; |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
255 task_list[cmd].entry_offset = entry_offset; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
256 task_list[cmd].load = load_task; |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
257 task_list[cmd].wait = wait_load; |
506 | 258 #if 0 |
439 | 259 fprintf(stderr,"cmd = %d\n",cmd); |
441 | 260 fprintf(stderr,"locatation = 0x%x\n",start); |
261 fprintf(stderr,"end = 0x%x\n",start+size); | |
262 fprintf(stderr,"size = 0x%x\n",size); | |
439 | 263 fprintf(stderr,"entry = 0x%x\n",entry_offset); |
506 | 264 #endif |
439 | 265 |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
266 } |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
267 |
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
268 |
373 | 269 /*! |
386 | 270 |
271 size 単位のMemory Segment を count 個作る | |
272 | |
373 | 273 @param [size] リストの要素1つのサイズ |
274 @param [count] 要素数 | |
275 @return allocate した領域のポインタ | |
276 | |
277 */ | |
278 MemList* | |
279 Scheduler::createMemList(int size, int count) | |
280 { | |
281 uint32 head_size = round_up16(sizeof(MemorySegment)); | |
282 uint32 seg_size = round_up16(head_size+size); | |
283 char* mseg = (char*)allocate(seg_size*count); | |
284 MemList* mlist = new MemList((MemorySegment*)mseg); | |
285 | |
388
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
286 if (!hash) { |
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
287 hash = new MemHash(); |
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
288 } |
82cb9368e3ff
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
289 |
373 | 290 for(int i = 0; i < count; i++) { |
291 MemorySegment* next = (MemorySegment*)(mseg+seg_size*i); | |
292 char* data = (char*)next+head_size; | |
293 next->data = (void*)data; | |
386 | 294 next->size = size; |
395 | 295 next->address = (memaddr)next; |
373 | 296 mlist->addLast(next); |
297 } | |
298 | |
299 return mlist; | |
300 } | |
386 | 301 |
302 /*! | |
303 | |
304 Main Memory のSegmentを取得する | |
305 | |
306 @param [addr] Main Memory のアドレス | |
307 @param [m] Mem List | |
308 @return allocate した領域のポインタ | |
309 memory directory にあるべきだが... | |
310 | |
311 */ | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
312 MemorySegment * |
386 | 313 Scheduler::get_segment(memaddr addr, MemList *m) |
314 { | |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
442
diff
changeset
|
315 MemorySegment *s = m->getFirst(); |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
442
diff
changeset
|
316 return get_segment(addr, m, s->size); |
437 | 317 } |
318 | |
319 MemorySegment * | |
320 Scheduler::get_segment(memaddr addr, MemList *m, int size) | |
321 { | |
322 // memory segment のsizeをoverride する場合がある | |
386 | 323 MemorySegment *s = hash->get(addr); |
324 if (s) { | |
325 /* 既に load されている */ | |
439 | 326 // fprintf(stderr,"get_segement loaded %llx 0x%x size 0x%d\n",addr,s->data,size); |
391 | 327 m->moveToFirst(s); |
386 | 328 return s; |
329 } | |
330 | |
331 /* LRU なので、もっとも使われてない segment を上書きする */ | |
332 s = m->getLast(); | |
333 m->moveToFirst(s); | |
334 | |
335 memaddr old_addr = s->address; | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
336 s->tag = get_tag(); |
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
337 dma_load(s->data, addr, |
437 | 338 size, s->tag); |
386 | 339 /* 前のをhashから削除 */ |
340 hash->remove(old_addr); | |
341 /* 新しいaddress を登録 */ | |
342 s->address = addr; | |
343 hash->put(s->address, s); | |
344 | |
439 | 345 // fprintf(stderr,"get_segement %llx 0x%x size 0x%d\n",addr, s->data,size); |
346 | |
386 | 347 return s; |
348 } | |
349 | |
421
cd77224d4224
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
350 |
386 | 351 uint32 |
352 Scheduler::get_tag() | |
353 { | |
458 | 354 static int tag = 16; |
355 tag ++; | |
356 tag &= 0x0f; | |
357 return tag+16; | |
386 | 358 } |
359 | |
360 /*! | |
361 | |
362 Main Memory のSegmentを書き出す | |
363 Segment は get_segement されていて、 | |
364 追い出されていてはいけない。 | |
365 それを保証するのは難しい? | |
366 | |
367 @param [addr] Main Memory のアドレス | |
368 @param [m] Mem List | |
369 @return allocate した領域のポインタ | |
370 | |
371 */ | |
372 void | |
373 Scheduler::put_segment(MemorySegment *s) | |
374 { | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
375 dma_store(s->data, s->address, |
386 | 376 s->size, s->tag); |
377 } | |
378 | |
379 /*! | |
380 | |
381 Main Memory のSegmentを読込、書き出しを待つ | |
382 | |
383 @param [id] MemorySegment のid | |
384 | |
385 */ | |
386 void | |
387
5e2d30bfbf23
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
387 Scheduler::wait_segment(MemorySegment *s) |
386 | 388 { |
391 | 389 // えーと、dma してない時には、skip しないとだめなんじゃないの? |
390 | |
391 if (s->tag) dma_wait(s->tag); | |
392 s->tag = 0; | |
386 | 393 } |
394 | |
395 /* end */ |