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