Mercurial > hg > Game > Cerium
comparison TaskManager/kernel/schedule/SchedTask.cc @ 42:aa11038dbdc1
*** empty log message ***
author | gongo |
---|---|
date | Thu, 14 Feb 2008 18:27:37 +0900 |
parents | |
children | 70a0ac46133e |
comparison
equal
deleted
inserted
replaced
41:68fb5bfee6b7 | 42:aa11038dbdc1 |
---|---|
1 #include "SchedTask.h" | |
2 #include "SchedTaskList.h" | |
3 #include "SchedNop2Ready.h" | |
4 #include "DmaManager.h" | |
5 #include "error.h" | |
6 #include "TaskManager.h" | |
7 #include "SymTable.h" | |
8 | |
9 SymTable *TaskManager::symtb; | |
10 | |
11 SchedTask::SchedTask(TaskListPtr _list, TaskPtr _task, void *rbuf, void *wbuf, | |
12 DmaManager* cn) | |
13 { | |
14 list = _list; | |
15 task = _task; | |
16 readbuf = rbuf; | |
17 writebuf = wbuf; | |
18 connector = cn; | |
19 } | |
20 | |
21 void | |
22 SchedTask::read(void) | |
23 { | |
24 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
25 | |
26 //task = &list->tasks[--list->length]; | |
27 connector->dma_load(readbuf, task->in_addr, task->in_size, DMA_READ); | |
28 } | |
29 | |
30 void | |
31 SchedTask::exec(void) | |
32 { | |
33 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
34 | |
35 connector->dma_wait(DMA_READ); | |
36 | |
37 __debug(" task->command = %d\n", task->command); | |
38 __debug(" task->in_size = %d\n", task->in_size); | |
39 __debug(" task->in_addr = 0x%x\n", task->in_addr); | |
40 __debug(" task->out_addr = 0x%x\n", task->out_addr); | |
41 __debug(" list->next = 0x%x\n", (unsigned int)list->next); | |
42 __debug(" list->length = 0x%x\n", (unsigned int)list->length); | |
43 | |
44 // obsolute | |
45 // task->in_size = func_list[task->command](writebuf, readbuf); | |
46 | |
47 // ごちゃごちゃしてるな | |
48 // 最初から void* じゃなくて 関数ポインタ としていれるべきか? | |
49 int (*func)(void*, void*) | |
50 = (int (*)(void*,void*))TaskManager::get_address(task->command); | |
51 task->in_size = func(writebuf, readbuf); | |
52 connector->dma_store(writebuf, task->out_addr, task->in_size, DMA_WRITE); | |
53 } | |
54 | |
55 void | |
56 SchedTask::write(void) | |
57 { | |
58 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
59 | |
60 connector->dma_wait(DMA_WRITE); | |
61 connector->mail_write((unsigned int)task->self); | |
62 } | |
63 | |
64 SchedTaskBase* | |
65 SchedTask::next(Scheduler *m, SchedTaskBase *p) | |
66 { | |
67 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
68 | |
69 delete p; | |
70 | |
71 // ここ直さねば。どうやって if 文消そう? | |
72 // オブジェクト増やせばいいのかな | |
73 if (list->length == 0) { | |
74 if (list->next == 0) { | |
75 return new SchedNop2Ready(connector); | |
76 } else { | |
77 return new SchedTaskList((unsigned int)list->next, | |
78 m->get_curListBuf(), connector); | |
79 } | |
80 } else { | |
81 //return new SchedTask(list, m->get_curReadBuf(), | |
82 //m->get_curWriteBuf(), connector); | |
83 | |
84 // 本当は、ここで task->command に対応する、 | |
85 // SchedTask を継承する class を作ればいい。。。はず | |
86 return new SchedTask(list, &list->tasks[--list->length], | |
87 m->get_curReadBuf(), m->get_curWriteBuf(), | |
88 connector); | |
89 } | |
90 } | |
91 | |
92 #if 0 | |
93 SchedTask | |
94 createSchedTask(TaskListPtr list, void *rbuf, void *wbuf, DmaManager *cn) | |
95 { | |
96 TaskPtr task; | |
97 | |
98 task = &list->tasks[--list->length]; | |
99 | |
100 } | |
101 #endif |