[Cbe-oss-dev] [PATCH 09/22]MARS/base: Kernel remove base library dma dependency

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


Remove kernel dependency on libmars_base.a dma implementation to reduce code
size.

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

---
 base/src/common/kernel_internal_types.h |    2 +
 base/src/mpu/kernel/kernel.c            |   58 +++++++++++++++++---------------
 2 files changed, 34 insertions(+), 26 deletions(-)

--- a/base/src/common/kernel_internal_types.h
+++ b/base/src/common/kernel_internal_types.h
@@ -50,6 +50,8 @@
 #define MARS_KERNEL_PARAMS_ALIGN		128
 #define MARS_KERNEL_PARAMS_SIZE			128
 
+#define MARS_KERNEL_DMA_TAG			31
+
 /* mars kernel syscalls */
 struct mars_kernel_syscalls {
 	uint32_t			(*get_ticks)(void);
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -42,7 +42,6 @@
 
 #include "config.h"
 
-#include "mars/dma.h"
 #include "mars/error.h"
 #include "mars/module.h"
 #include "mars/mutex.h"
@@ -75,6 +74,22 @@ static uint16_t schedule_workload_id;
 typedef void (*module_entry)(
 	const struct mars_kernel_syscalls *kernel_syscalls);
 
+static void dma_put(void *ls, uint64_t ea, uint32_t size)
+{
+	mfc_put((volatile void *)ls, ea, size, MARS_KERNEL_DMA_TAG, 0, 0);
+	mfc_write_tag_mask(1 << MARS_KERNEL_DMA_TAG);
+	mfc_write_tag_update_all();
+	mfc_read_tag_status();
+}
+
+static void dma_get(void *ls, uint64_t ea, uint32_t size)
+{
+	mfc_get((volatile void *)ls, ea, size, MARS_KERNEL_DMA_TAG, 0, 0);
+	mfc_write_tag_mask(1 << MARS_KERNEL_DMA_TAG);
+	mfc_write_tag_update_all();
+	mfc_read_tag_status();
+}
+
 static uint32_t get_ticks(void)
 {
 	return kernel_params.kernel_ticks.offset - spu_read_decrementer();
@@ -115,8 +130,8 @@ static struct mars_workload_context *get
 		return &workload;
 
 	/* get the workload context from workload queue */
-	mars_dma_get_and_wait((void *)&ret_workload, get_workload_ea(id),
-		sizeof(struct mars_workload_context), MARS_DMA_TAG);
+	dma_get((void *)&ret_workload, get_workload_ea(id),
+		sizeof(struct mars_workload_context));
 
 	return &ret_workload;
 }
@@ -327,8 +342,8 @@ static void schedule_begin_callback(uint
 	schedule_workload_id = id;
 
 	/* get the workload context from workload queue */
-	mars_dma_get_and_wait((void *)&schedule_workload, get_workload_ea(id),
-		sizeof(struct mars_workload_context), MARS_DMA_TAG);
+	dma_get((void *)&schedule_workload, get_workload_ea(id),
+		sizeof(struct mars_workload_context));
 }
 
 static int module_workload_schedule_begin(uint16_t id, uint8_t priority,
@@ -361,8 +376,8 @@ static void schedule_end_callback(uint16
 	schedule_workload_id = MARS_WORKLOAD_ID_NONE;
 
 	/* put the workload context into workload queue */
-	mars_dma_put_and_wait((void *)&schedule_workload, get_workload_ea(id),
-		sizeof(struct mars_workload_context), MARS_DMA_TAG);
+	dma_put((void *)&schedule_workload, get_workload_ea(id),
+		sizeof(struct mars_workload_context));
 }
 
 static int module_workload_schedule_end(uint16_t id)
@@ -461,10 +476,8 @@ static int search_block(int block)
 				/* check if workload id is in the same block */
 				if (block != bl) {
 					/* fetch the necessary block */
-					mars_dma_get_and_wait(&wait_block,
-							get_block_ea(bl),
-							sizeof(wait_block),
-							MARS_DMA_TAG);
+					dma_get(&wait_block, get_block_ea(bl),
+						sizeof(wait_block));
 
 					/* set pointer to check fetched block */
 					p_wait_block = &wait_block;
@@ -560,9 +573,7 @@ static int __attribute__((noinline)) res
 	workload_ea = get_workload_ea(workload_id);
 
 	/* get the workload context code from workload queue */
-	mars_dma_get_and_wait(&workload, workload_ea,
-			      sizeof(struct mars_workload_context),
-			      MARS_DMA_TAG);
+	dma_get(&workload, workload_ea, sizeof(struct mars_workload_context));
 
 	return MARS_WORKLOAD_RESERVED;
 }
@@ -573,9 +584,7 @@ static void __attribute__((noinline)) re
 	int index = workload_id % MARS_WORKLOAD_PER_BLOCK;
 
 	/* put the workload context into workload queue */
-	mars_dma_put_and_wait(&workload, workload_ea,
-			      sizeof(struct mars_workload_context),
-			      MARS_DMA_TAG);
+	dma_put(&workload, workload_ea, sizeof(struct mars_workload_context));
 
 	/* release block reservation */
 	release_block(block, index);
@@ -586,11 +595,10 @@ static int __attribute__((noinline)) sch
 	int status;
 
 	/* get the workload queue header */
-	mars_dma_get_and_wait(&queue_header,
-			      kernel_params.workload_queue_ea +
-			      offsetof(struct mars_workload_queue, header),
-			      sizeof(struct mars_workload_queue_header),
-			      MARS_DMA_TAG);
+	dma_get(&queue_header,
+		kernel_params.workload_queue_ea +
+		offsetof(struct mars_workload_queue, header),
+		sizeof(struct mars_workload_queue_header));
 
 	/* return exit status if exit flag is set from host */
 	if (queue_header.flag == MARS_WORKLOAD_QUEUE_FLAG_EXIT)
@@ -604,10 +612,8 @@ static int __attribute__((noinline)) sch
 		return MARS_KERNEL_STATUS_IDLE;
 
 	/* load the exec code into mpu storage from host storage */
-	mars_dma_get_and_wait((void *)MARS_WORKLOAD_MODULE_BASE_ADDR,
-			      workload.module.exec_ea,
-			      workload.module.exec_size,
-			      MARS_DMA_TAG);
+	dma_get((void *)MARS_WORKLOAD_MODULE_BASE_ADDR,
+		workload.module.exec_ea, workload.module.exec_size);
 
 	/* 0 the bss section */
 	memset((void *)MARS_WORKLOAD_MODULE_BASE_ADDR +






More information about the cbe-oss-dev mailing list