[Cbe-oss-dev] [PATCH 03/28]MARS/base: fix asm usage

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


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

Fix inline asm usage (base)

This patch modifies use of inline ASMs to 'specified registers'
syntax, and removes unnecessary inline ASMs.

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 base/src/mpu/kernel/kernel.c |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -53,7 +53,7 @@
 #define MARS_WORKLOAD_RESERVED		1
 
 /* kernel */
-void *_kernel_stack;
+void *__kernel_stack;
 static struct mars_kernel_params kernel_params;
 
 /* workload queue */
@@ -412,16 +412,21 @@ static int module_host_signal_send(uint6
 	return MARS_SUCCESS;
 }
 
-static void module_exit(uint8_t state)
+static void __attribute__((noinline)) save_workload_state(uint8_t state)
 {
 	workload_state = state;
+}
+
+static void module_exit(uint8_t state)
+{
+	register void *sp asm("$sp");
 
-	/* restore kernel stack pointer and goto to exit label */
-	asm volatile (
-		"lqa	$sp, _kernel_stack;"
-		"br	_module_exit;"
-	);
+	save_workload_state(state);
+
+	/* restore kernel stack pointer */
+	sp = __kernel_stack;
 }
+
 static struct mars_kernel_syscalls kernel_syscalls =
 {
 	get_ticks,
@@ -615,18 +620,13 @@ static void release_workload(void)
 
 static void __attribute__((noinline)) run_workload(void)
 {
+	register void *sp asm("$sp");
+
 	/* save kernel stack pointer */
-	asm volatile (
-		"stqa	$sp, _kernel_stack;"
-	);
+	__kernel_stack = sp;
 
 	/* call module entry function */
 	((module_entry)workload.module.entry)(&kernel_syscalls);
-
-	/* label so module can jump back here at exit */
-	asm volatile (
-		"_module_exit:"
-	);
 }
 
 static int scheduler(void)







More information about the cbe-oss-dev mailing list