annotate TaskManager/Fifo/FifoDmaManager.cc @ 318:a5ae1fbbafd6 draft

Document/Cerium_2009.mm
author aaa
date Tue, 09 Jun 2009 22:55:00 +0900
parents 768452fab95e
children f22280772f20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdio.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <stdlib.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include <string.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "FifoDmaManager.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 FifoDmaManager::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9 if (size == 0) return;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 memcpy(buf, (void*)addr, size);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14 FifoDmaManager::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16 if (size == 0) return;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 memcpy((void*)addr, buf, size);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 /**
318
a5ae1fbbafd6 Document/Cerium_2009.mm
aaa
parents: 298
diff changeset
21 * mask で設定した DMA 転送の完了を待つ
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24 FifoDmaManager::dma_wait(uint32 mask)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 //spu_writech(MFC_WrTagMask, 1 << mask);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 //spu_mfcstat(MFC_TAG_UPDATE_ALL);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 FifoDmaManager::mail_write(uint32 data)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 mail_sendQueue
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 = MailManager::append_mailQueue(mail_sendQueue,
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 mailManager->create(data));
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 unsigned int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 FifoDmaManager::mail_read(void)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 MailQueuePtr q;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 uint32 ret;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 q = mail_recvQueue;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 if (q == NULL) {
318
a5ae1fbbafd6 Document/Cerium_2009.mm
aaa
parents: 298
diff changeset
47 return 0; // error か 正しい値か判断できないな・・・
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50 mail_recvQueue = mail_recvQueue->next;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 ret = q->data;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 mailManager->free(q);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 return ret;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 FifoDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 int list_size = list->length;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62 int bound;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64 bound = (int)(buff);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66 for (int i = 0; i < list_size; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67 ListElementPtr elm = &list->element[i];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68 memcpy((void*)bound, (void*)elm->addr, elm->size);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 bound += elm->size;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
71 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
72
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
73 #if 0
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
74 void*
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 FifoDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77 void **buffList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 int bound;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 dma_wait(mask);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82 if (list->length == 1) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83 return buff;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
85
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86 bound = (int)buff;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
87 buffList = (void**)malloc(list->length);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 buffList[0] = (void*)bound;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
90 for (int i = 1; i < list->length; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
91 bound += list->element[i-1].size;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
92 buffList[i] = (void*)(bound);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
93 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
94
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
95 return (void*)buffList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
96 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
97 #endif
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
98
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
99 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100 FifoDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
102 int list_size = list->length;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
103 int bound;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
104
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
105 bound = (int)(buff);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
106
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
107 for (int i = 0; i < list_size; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
108 ListElementPtr elm = &list->element[i];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
109 memcpy((void*)elm->addr, (void*)bound, elm->size);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
110 bound += elm->size;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
111 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
112 }