[Cbe-oss-dev] [PATCH 16/22]MARS/task: Module remove base library dma dependency

Yuji Mano yuji.mano at am.sony.com
Wed Jan 21 11:29:47 EST 2009


Remove dependency on dma functions in libmars_base.a to reduce task module code
size.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>

---
 task/src/mpu/module/task_module.c |   63 ++++++++++++++++++++++++++------------
 1 file changed, 44 insertions(+), 19 deletions(-)

--- a/task/src/mpu/module/task_module.c
+++ b/task/src/mpu/module/task_module.c
@@ -48,6 +48,9 @@
 
 #include "task_module.h"
 
+#define MARS_TASK_MODULE_DMA_TAG	31
+#define MARS_TASK_MODULE_DMA_SIZE_MAX	16384
+
 /* stack pointer storage */
 void *_module_stack;
 void *_task_stack;
@@ -60,6 +63,34 @@ static struct mars_task_context_save_uni
 typedef void (*mars_task_entry)(struct mars_task_args *args,
 	struct mars_task_module_syscalls *task_module_syscalls);
 
+static void dma_large(void *ls, uint64_t ea, uint32_t size, int put)
+{
+	while (size) {
+		unsigned int block_size;
+
+		block_size = (size < MARS_TASK_MODULE_DMA_SIZE_MAX) ?
+			size : MARS_TASK_MODULE_DMA_SIZE_MAX;
+
+		if (put)
+			mfc_put((volatile void *)ls, ea, block_size,
+				MARS_TASK_MODULE_DMA_TAG, 0, 0);
+		else
+			mfc_get((volatile void *)ls, ea, block_size,
+				MARS_TASK_MODULE_DMA_TAG, 0, 0);
+
+		ls += block_size;
+		ea += block_size;
+		size -= block_size;
+	}
+}
+
+static void dma_wait(void)
+{
+	mfc_write_tag_mask(1 << MARS_TASK_MODULE_DMA_TAG);
+	mfc_write_tag_update_all();
+	mfc_read_tag_status();
+}
+
 static uint32_t get_ticks(void)
 {
 	return mars_module_get_ticks();
@@ -199,10 +230,11 @@ static void process_context_save_list(in
 {
 	int i, offset = 0;
 
-	mars_dma_get_and_wait(list, task->context_save_unit_ea,
-			      MARS_TASK_CONTEXT_SAVE_UNIT_SIZE *
-			      MARS_TASK_CONTEXT_SAVE_UNIT_MAX,
-			      MARS_DMA_TAG);
+	mfc_get(list, task->context_save_unit_ea,
+		MARS_TASK_CONTEXT_SAVE_UNIT_SIZE *
+		MARS_TASK_CONTEXT_SAVE_UNIT_MAX,
+		MARS_TASK_MODULE_DMA_TAG, 0, 0);
+	dma_wait();
 
 	/* loop through save unit list */
 	for (i = 0; i < MARS_TASK_CONTEXT_SAVE_UNIT_MAX; i++) {
@@ -211,23 +243,15 @@ static void process_context_save_list(in
 			break;
 
 		/* save or restore context save unit specified */
-		if (save) {
-			mars_dma_put(
-				(void *)(MARS_TASK_BASE_ADDR + list[i].addr),
-				task->context_save_area_ea + offset,
-				list[i].size, MARS_DMA_TAG);
-		} else {
-			mars_dma_get(
-				(void *)(MARS_TASK_BASE_ADDR + list[i].addr),
-				task->context_save_area_ea + offset,
-				list[i].size, MARS_DMA_TAG);
-		}
+		dma_large((void *)(MARS_TASK_BASE_ADDR + list[i].addr),
+			  task->context_save_area_ea + offset,
+			  list[i].size, save);
 
 		offset += list[i].size;
 	}
 
 	/* wait for all dmas to complete */
-	mars_dma_wait(MARS_DMA_TAG);
+	dma_wait();
 }
 
 static void __attribute__((noinline)) context_save(void)
@@ -428,12 +452,13 @@ void mars_module_main(void)
 	/* if stack pointer is uninitialized run fresh, otherwise resume */
 	if (!task->stack) {
 		/* dma the exec code into mpu storage from host storage */
-		mars_dma_get_and_wait((void *)MARS_TASK_BASE_ADDR,
-			task->exec_ea, task->exec_size, MARS_DMA_TAG);
+		dma_large((void *)MARS_TASK_BASE_ADDR,
+			  task->exec_ea, task->exec_size, 0);
+		dma_wait();
 
 		/* 0 the bss section */
 		memset((void *)MARS_TASK_BASE_ADDR + task->exec_size, 0,
-			task->bss_size);
+		       task->bss_size);
 
 		/* sync before executing loaded code */
 		spu_sync();






More information about the cbe-oss-dev mailing list