109
|
1 #include <stdlib.h>
|
|
2 #include <string.h>
|
42
|
3 #include "SchedTaskList.h"
|
|
4 #include "SchedTask.h"
|
|
5 #include "SchedNop2Ready.h"
|
|
6 #include "DmaManager.h"
|
|
7 #include "error.h"
|
|
8
|
184
|
9 /**
|
|
10 * SchedTaskList を返す
|
|
11 *
|
|
12 * @param[in] next_list 次の実行する TaskList のアドレス
|
|
13 * @param[in] next_list がメインメモリのアドレスか、
|
|
14 * SPE で生成されたアドレスかのフラグ
|
|
15 * SPE で生成されている場合、DMA の必要は無い
|
|
16 * 0: メインメモリ, 1: SPE
|
|
17 */
|
|
18 SchedTaskList*
|
|
19 createSchedTaskList(uint32 next_list, Scheduler* scheduler, int renew_flag)
|
|
20 {
|
|
21 SchedTaskList* sched = new SchedTaskList(next_list, scheduler);
|
|
22 sched->flag_renewTaskList = renew_flag;
|
|
23 return sched;
|
|
24 }
|
|
25
|
109
|
26 SchedTaskList::SchedTaskList(unsigned int addr, Scheduler *sched)
|
42
|
27 {
|
|
28 params_addr = addr;
|
184
|
29 list = NULL;
|
109
|
30 scheduler = sched;
|
|
31
|
|
32 flag_renewTaskList = 0;
|
42
|
33 }
|
|
34
|
109
|
35
|
42
|
36 void
|
|
37 SchedTaskList::read(void)
|
|
38 {
|
|
39 __debug("[SchedTaskList:%s]\n", __FUNCTION__);
|
|
40
|
184
|
41 if (flag_renewTaskList == SCHED_TASKLIST_NORMAL) {
|
|
42 list = scheduler->get_curListBuf();
|
|
43 scheduler->dma_load(list, params_addr,
|
|
44 sizeof(TaskList), DMA_READ_TASKLIST);
|
109
|
45 scheduler->dma_wait(DMA_READ_TASKLIST);
|
|
46 } else {
|
|
47 list = (TaskListPtr)params_addr;
|
|
48 }
|
42
|
49 }
|
|
50
|
|
51 SchedTaskBase*
|
|
52 SchedTaskList::next(Scheduler *m, SchedTaskBase *p)
|
|
53 {
|
184
|
54 SchedTaskBase *nextSched;
|
|
55
|
42
|
56 __debug("[SchedTaskList:%s]\n", __FUNCTION__);
|
|
57
|
|
58 delete p;
|
|
59
|
|
60 if (list->length < 1) {
|
184
|
61 nextSched = new SchedNop2Ready(scheduler);
|
|
62
|
|
63 if (flag_renewTaskList == SCHED_TASKLIST_RENEW) {
|
|
64 free(list);
|
|
65 }
|
|
66
|
42
|
67 } else {
|
184
|
68 TaskPtr nextTask = &list->tasks[0];
|
|
69 nextSched = createSchedTask(nextTask);
|
|
70
|
|
71 if (flag_renewTaskList == SCHED_TASKLIST_RENEW) {
|
|
72 ((SchedTask*)nextSched)->__setRenew();
|
|
73 }
|
|
74
|
|
75 ((SchedTask*)nextSched)->__init__(list, nextTask, 1,
|
|
76 scheduler->get_curReadBuf(),
|
|
77 scheduler->get_curWriteBuf(),
|
|
78 scheduler);
|
42
|
79 }
|
184
|
80
|
|
81 return nextSched;
|
42
|
82 }
|
88
|
83
|