Mercurial > hg > Game > Cerium
annotate TaskManager/Cell/spe/CellDmaManager.cc @ 675:daff9d9fd6a0 draft
fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 06 Dec 2009 01:20:41 +0900 |
parents | 27fec8c70c9c |
children | fbccad536db1 |
rev | line source |
---|---|
61 | 1 #include <stdio.h> |
88 | 2 #include <stdlib.h> |
59 | 3 #include "CellDmaManager.h" |
4 | |
672 | 5 |
6 | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
7 /** |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
8 * DMA Load |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
9 * |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
10 * @param[in] buf Buffer of Load Data |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
11 * @param[in] addr Address of Load Data at Main Memory |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
12 * @param[in] size Size of Load Data |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
13 * @param[in] mask DMA tag |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
14 */ |
672 | 15 void CellDmaManager::dma_load(void *buf, memaddr addr, uint32 size, uint32 mask) |
59 | 16 { |
88 | 17 if (size == 0) return ; |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
18 mfc_get((volatile void *)buf, addr, size, mask, 0, 0); |
59 | 19 } |
20 | |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
21 /** |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
22 * DMA Store |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
23 * |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
24 * @param[in] buf Buffer of Store Data at SPE |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
25 * @param[in] addr Address of Store Data at Main Memory |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
26 * @param[in] size Size of Store Data |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
27 * @param[in] mask DMA tag |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
28 */ |
672 | 29 void CellDmaManager::dma_store(void *buf, memaddr addr, uint32 size, uint32 mask) |
59 | 30 { |
88 | 31 if (size == 0) return ; |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
32 mfc_put((volatile void *)buf, addr, size, mask, 0, 0); |
59 | 33 } |
34 | |
672 | 35 void CellDmaManager::dma_wait(uint32 mask) |
36 { | |
37 (this->*start_dmawait_profile)(); | |
38 mfc_write_tag_mask(1 << mask); | |
39 mfc_write_tag_update_all(); | |
40 mfc_read_tag_status(); | |
675 | 41 (this->*end_dmawait_profile)(&global_wait_time); |
672 | 42 } |
43 | |
44 void CellDmaManager::mail_write(memaddr data) | |
45 { | |
46 (this->*start_dmawait_profile)(); | |
47 spu_write_out_mbox((uint32)data); | |
48 if (ABIBIT>32) { | |
49 unsigned long data0 = (unsigned long)data; | |
50 spu_write_out_mbox((uint32)(data0>>4)); | |
51 } | |
675 | 52 (this->*end_dmawait_profile)(&global_mail_time); |
672 | 53 } |
54 | |
55 memaddr CellDmaManager::mail_read() | |
56 { | |
57 (this->*start_dmawait_profile)(); | |
58 memaddr data = (memaddr)spu_read_in_mbox(); | |
59 if (ABIBIT>32) { | |
60 data += (spu_read_in_mbox()<<4); | |
61 } | |
675 | 62 (this->*end_dmawait_profile)(&global_mail_time); |
672 | 63 return data; |
64 } | |
65 | |
66 void CellDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask) | |
67 { | |
68 mfc_getl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, | |
69 mask, 0, 0); | |
70 } | |
71 | |
72 void CellDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) | |
73 { | |
74 mfc_putl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, | |
75 mask, 0, 0); | |
76 } | |
77 | |
78 | |
79 CellDmaManager::CellDmaManager() | |
80 { | |
81 stop_profile(); | |
82 } | |
83 | |
84 void | |
85 CellDmaManager::start_profile() | |
86 { | |
87 start_dmawait_profile = &CellDmaManager::do_start_dmawait_profile; | |
88 end_dmawait_profile = &CellDmaManager::do_end_dmawait_profile; | |
89 } | |
90 | |
91 void | |
92 CellDmaManager::stop_profile() | |
93 { | |
94 start_dmawait_profile = &CellDmaManager::null_start_dmawait_profile; | |
95 end_dmawait_profile = &CellDmaManager::null_end_dmawait_profile; | |
96 } | |
97 | |
59 | 98 /** |
180
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
99 * DMA Wait |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
100 * |
e3b7776b1420
いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents:
109
diff
changeset
|
101 * @param[in] mask Tag for Wait DMA process |
59 | 102 */ |
275 | 103 void |
672 | 104 CellDmaManager::do_start_dmawait_profile() |
242 | 105 { |
106 wait_time = spu_readch(SPU_RdDec); | |
107 global_busy_time += busy_time - wait_time; | |
108 spu_writech(SPU_WrDec, 0xffffffff); | |
109 } | |
110 | |
275 | 111 void |
675 | 112 CellDmaManager::do_end_dmawait_profile(long long *counter) |
242 | 113 { |
114 wait_time = spu_readch(SPU_RdDec); | |
675 | 115 *counter += 0xffffffff - wait_time; |
242 | 116 busy_time = wait_time; |
117 } | |
239 | 118 |
672 | 119 void CellDmaManager::null_start_dmawait_profile() {} |
120 void CellDmaManager::null_end_dmawait_profile() {} | |
121 | |
239 | 122 void |
255 | 123 CellDmaManager::show_dma_wait(int cpu) |
124 { | |
125 | |
675 | 126 double r = ((double)global_busy_time)/((double)( |
127 global_busy_time+global_wait_time+global_mail_time | |
128 ))*100.0); | |
129 printf("spu%d: busy_time = %lld",cpu, global_busy_time); | |
130 printf(" wait_time = %lld", global_wait_time); | |
131 printf(" mail_time = %lld", global_mail_time); | |
132 printf(" busy_ratio = %g%%\n",r); | |
255 | 133 } |
134 | |
604 | 135 |
136 /* end */ |