Mercurial > hg > Game > Cerium
view TaskManager/Fifo/FifoDmaManager.cc @ 596:f1c2e11a2ef4 draft
add xdr_getpos
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 04 Nov 2009 22:52:06 +0900 |
parents | f22280772f20 |
children | 92b0d490e839 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "FifoDmaManager.h" void FifoDmaManager::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) { if (size == 0) return; memcpy(buf, (void*)addr, size); } void FifoDmaManager::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask) { if (size == 0) return; memcpy((void*)addr, buf, size); } /** * mask で設定した DMA 転送の完了を待つ */ void FifoDmaManager::dma_wait(uint32 mask) { //spu_writech(MFC_WrTagMask, 1 << mask); //spu_mfcstat(MFC_TAG_UPDATE_ALL); } void FifoDmaManager::mail_write(uint32 data) { mail_sendQueue = MailManager::append_mailQueue(mail_sendQueue, mailManager->create(data)); } unsigned int FifoDmaManager::mail_read(void) { MailQueuePtr q; uint32 ret; q = mail_recvQueue; if (q == NULL) { return 0; // error か 正しい値か判断できないな・・・ } mail_recvQueue = mail_recvQueue->next; ret = q->data; mailManager->free(q); return ret; } void FifoDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask) { int list_size = list->length; int bound; bound = (int)(buff); for (int i = 0; i < list_size; i++) { ListElementPtr elm = &list->element[i]; memcpy((void*)bound, (void*)elm->addr, elm->size); bound += elm->size; } } #if 0 void* FifoDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask) { void **buffList; int bound; dma_wait(mask); if (list->length == 1) { return buff; } bound = (int)buff; buffList = (void**)malloc(list->length); buffList[0] = (void*)bound; for (int i = 1; i < list->length; i++) { bound += list->element[i-1].size; buffList[i] = (void*)(bound); } return (void*)buffList; } #endif void FifoDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) { int list_size = list->length; int bound; bound = (int)(buff); for (int i = 0; i < list_size; i++) { ListElementPtr elm = &list->element[i]; memcpy((void*)elm->addr, (void*)bound, elm->size); bound += elm->size; } }