00001 #include <stdio.h> 00002 #include <stdlib.h> 00003 #include "CellDmaManager.h" 00004 00013 void 00014 CellDmaManager::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) 00015 { 00016 if (size == 0) return ; 00017 mfc_get((volatile void *)buf, addr, size, mask, 0, 0); 00018 } 00019 00028 void 00029 CellDmaManager::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask) 00030 { 00031 if (size == 0) return ; 00032 mfc_put((volatile void *)buf, addr, size, mask, 0, 0); 00033 } 00034 00040 void 00041 CellDmaManager::start_dmawait_profile() 00042 { 00043 wait_time = spu_readch(SPU_RdDec); 00044 global_busy_time += busy_time - wait_time; 00045 spu_writech(SPU_WrDec, 0xffffffff); 00046 } 00047 00048 void 00049 CellDmaManager::end_dmawait_profile() 00050 { 00051 wait_time = spu_readch(SPU_RdDec); 00052 global_wait_time += 0xffffffff - wait_time; 00053 busy_time = wait_time; 00054 } 00055 00056 void 00057 CellDmaManager::show_dma_wait(int cpu) 00058 { 00059 00060 printf("spu%d: global_wait_time = %lld\n",cpu, global_wait_time); 00061 printf("spu%d: global_busy_time = %lld\n",cpu, global_busy_time); 00062 printf("spu%d: busy_ratio = %g%%\n",cpu, 00063 ((double)global_busy_time)/((double)(global_busy_time+global_wait_time))*100.0); 00064 } 00065 00066 void 00067 CellDmaManager::dma_wait(uint32 mask) 00068 { 00069 #ifdef SPU_PROFILE 00070 start_dmawait_profile(); 00071 #endif 00072 mfc_write_tag_mask(1 << mask); 00073 mfc_write_tag_update_all(); 00074 mfc_read_tag_status(); 00075 #ifdef SPU_PROFILE 00076 end_dmawait_profile(); 00077 #endif 00078 } 00079 00080 void 00081 CellDmaManager::mail_write(uint32 data) 00082 { 00083 spu_write_out_mbox(data); 00084 } 00085 00086 unsigned int 00087 CellDmaManager::mail_read(void) 00088 { 00089 unsigned int mail = spu_read_in_mbox(); 00090 return mail; 00091 } 00092 00093 void 00094 CellDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask) 00095 { 00096 mfc_getl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, 00097 mask, 0, 0); 00098 } 00099 00100 void 00101 CellDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) 00102 { 00103 mfc_putl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, 00104 mask, 0, 0); 00105 }