[Cbe-oss-dev] [PATCH 18/28]MARS/task: prevent use of non volatile regs

Yuji Mano yuji.mano at am.sony.com
Fri Feb 6 13:32:09 EST 2009


From: Kazunori Asayama <asayama at sm.sony.co.jp>

Guarantee non-volatile regs are not broken during context switching

This patch guarantees non-volatile registers are not broken during
context switching is performed by using -mfixed-range compiler
option. This patch also removes unnecessary 'noinline' attributes in
the task module implementation.

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>
---
 task/src/mpu/module/Makefile.am   |    1 
 task/src/mpu/module/task_module.c |   42 ++++++++++++++------------------------
 2 files changed, 17 insertions(+), 26 deletions(-)

--- a/task/src/mpu/module/Makefile.am
+++ b/task/src/mpu/module/Makefile.am
@@ -75,6 +75,7 @@ AM_CCASFLAGS = \
 
 AM_CFLAGS = \
 	$(extra_cflags) \
+	-mfixed-range=80-127 \
 	-W \
 	-Wall \
 	-Wunused \
--- a/task/src/mpu/module/task_module.c
+++ b/task/src/mpu/module/task_module.c
@@ -112,7 +112,7 @@ static struct mars_task_context *get_tas
 		mars_module_get_workload_by_id(task_id->workload_id);
 }
 
-static void __attribute__((noinline)) registers_save(void)
+static void registers_save(void)
 {
 	/* push non-volatile registers on to the workload stack */
 	asm volatile (
@@ -169,7 +169,7 @@ static void __attribute__((noinline)) re
 	);
 }
 
-static void __attribute__((noinline)) registers_restore(void)
+static void registers_restore(void)
 {
 	/* pop non-volatile registers from saved workload stack */
 	asm volatile (
@@ -276,21 +276,6 @@ static void __attribute__((noinline)) co
 	registers_restore();
 }
 
-static void __attribute__((noinline)) context_yield(void)
-{
-	/* save task stack pointer and restore module stack pointer */
-	asm volatile (
-		"stqa	$sp, _task_stack;"
-		"lqa	$sp, _module_stack;"
-	);
-
-	/* save task context */
-	context_save();
-
-	/* yield workload and put into ready state */
-	mars_module_workload_yield();
-}
-
 static void __attribute__((noinline)) context_wait(void)
 {
 	/* save task stack pointer and restore module stack pointer */
@@ -320,25 +305,30 @@ static void __attribute__((noinline)) co
 	spu_sync();
 }
 
-static void __attribute__((noinline)) context_finish(void)
+static void task_yield(void *task_heap)
 {
-	/* restore module stack pointer */
+	/* save task stack pointer and restore module stack pointer */
 	asm volatile (
+		"stqa	$sp, _task_stack;"
 		"lqa	$sp, _module_stack;"
 	);
 
-	/* put workload into finished state */
-	mars_module_workload_finish();
+	/* save task context */
+	context_save(task_heap);
+
+	/* yield workload and put into ready state */
+	mars_module_workload_yield();
 }
 
 static void task_exit(void)
 {
-	context_finish();
-}
+	/* restore module stack pointer */
+	asm volatile (
+		"lqa	$sp, _module_stack;"
+	);
 
-static void task_yield(void)
-{
-	context_yield();
+	/* put workload into finished state */
+	mars_module_workload_finish();
 }
 
 static int task_schedule(uint16_t workload_id, struct mars_task_args *args,






More information about the cbe-oss-dev mailing list