# HG changeset patch # User gongo # Date 1202795315 -32400 # Node ID f7fd92a1d7bb28cc5f5b208a10d35a3f4b835b03 # Parent 6a77b5e755ab379ed8e19c652ef1d4fd72335348 *** empty log message *** diff -r 6a77b5e755ab -r f7fd92a1d7bb TaskManager/Cell/CellDmaManager.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/CellDmaManager.cc Tue Feb 12 14:48:35 2008 +0900 @@ -0,0 +1,40 @@ +#include +#include "CellDmaManager.h" + +void +CellDmaManager::dma_load(void *buf, unsigned int addr, int size, int mask) +{ + if (buf == NULL || (void*)addr == NULL) return; + spu_mfcdma32(buf, addr, ROUND_UP_ALIGN(size, DEFAULT_ALIGNMENT), + mask, MFC_GET_CMD); +} + +void +CellDmaManager::dma_store(void *buf, unsigned int addr, int size, int mask) +{ + if (buf == NULL || (void*)addr == NULL) return; + spu_mfcdma32(buf, addr, ROUND_UP_ALIGN(size, DEFAULT_ALIGNMENT), + mask, MFC_PUT_CMD); +} + +/** + * mask で設定した DMA 転送の完了を待つ + */ +void +CellDmaManager::dma_wait(int mask) +{ + spu_writech(MFC_WrTagMask, 1 << mask); + spu_mfcstat(MFC_TAG_UPDATE_ALL); +} + +void +CellDmaManager::mail_write(unsigned int data) +{ + spu_writech(SPU_WrOutMbox, data); +} + +unsigned int +CellDmaManager::mail_read(void) +{ + return spu_readch(SPU_RdInMbox); +} diff -r 6a77b5e755ab -r f7fd92a1d7bb TaskManager/Cell/CellTaskInfo.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/CellTaskInfo.cc Tue Feb 12 14:48:35 2008 +0900 @@ -0,0 +1,69 @@ +#include +#include +#include "CellTaskInfo.h" + +#define ROUND_UP_ALIGN(value, alignment) \ + (((value) + ((alignment) - 1))&(~((alignment)-1))) + +#define NEXT_ADDR(addr, size) \ + (TaskListPtr)((int)(addr) + (size)) +int +CellTaskInfo::extend_pool_taskList(int num) +{ + TaskListPtr q, p; + int unit_size; + + + unit_size = (ROUND_UP_ALIGN(sizeof(TaskList), 16)); + posix_memalign((void**)&q, 16, unit_size*(num+1)); + + if (q == NULL) { + return -1; + } + + q->next = taskListPool; + taskListPool = q; + + /* Connect all free pack_list in the pool */ + q = NEXT_ADDR(taskListPool,unit_size); // q = taskListPool + 1; + for (; --num > 0; q = NEXT_ADDR(q + unit_size)) { + q->next = NEXT_ADDR(q, unit_size) // q->next = q + 1; + } + q->next = freeTaskList; + freeTaskList = NEXT_ADDR(taskListPool, unit_size); + + return 0; +} + +TaskListPtr +CellTaskInfo::get_available_taskList(void) +{ + TaskListPtr list, q; + + list = machineTaskList[0]; + + while (list->next) list = list->next; + + if (list->length < TASK_MAX_SIZE) { + return list; + } else { + q = get_free_taskList(); + machineTaskList[0] = append_taskList(machineTaskList[0], q); + return q; + } +} + +void +CellTaskInfo::clear_taskList(void) +{ + TaskListPtr p, p1; + + machineTaskList[0]->length = 0; + + p = machineTaskList[0]->next; + while (p) { + p1 = p; + p = p->next; + free_taskList(p1); + } +} diff -r 6a77b5e755ab -r f7fd92a1d7bb include/TaskManager/CellDmaManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/TaskManager/CellDmaManager.h Tue Feb 12 14:48:35 2008 +0900 @@ -0,0 +1,19 @@ +#ifndef INCLUDED_CELL_DMA_MANAGER +#define INCLUDED_CELL_DMA_MANAGER + +#ifndef INCLUDED_DMA_MANAGER +# include "DmaManager.h" +#endif + +class CellDmaManager : public DmaManager { +public: + /* functions */ + void dma_load(void *buf, unsigned int addr, int size, int mask); + void dma_store(void *buf, unsigned int addr, int size, int mask); + void dma_wait(int mask) ; + + void mail_write(unsigned int data); + unsigned int mail_read(void); +}; + +#endif diff -r 6a77b5e755ab -r f7fd92a1d7bb include/TaskManager/CellTaskInfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/TaskManager/CellTaskInfo.h Tue Feb 12 14:48:35 2008 +0900 @@ -0,0 +1,16 @@ +#ifndef INCLUDED_CELL_TASK_INFO +#define INCLUDED_CELL_TASK_INFO + +#ifndef INCLUDED_TASK_INFO +# include "TaskInfo.h" +#endif + +class CellTaskInfo : public TaskInfo { +public: + /* function */ + int extend_pool_taskList(int num); + TaskListPtr get_available_taskList(void); + void clear_taskList(void); +}; + +#endif