changeset 32:f7fd92a1d7bb

*** empty log message ***
author gongo
date Tue, 12 Feb 2008 14:48:35 +0900
parents 6a77b5e755ab
children 1c7c3d73ffc7
files TaskManager/Cell/CellDmaManager.cc TaskManager/Cell/CellTaskInfo.cc include/TaskManager/CellDmaManager.h include/TaskManager/CellTaskInfo.h
diffstat 4 files changed, 144 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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 <spu_mfcio.h>
+#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);
+}
--- /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 <stdio.h>
+#include <stdlib.h>
+#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);
+    }
+}
--- /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
--- /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