diff options
author | Kazunori Asayama <asayama@sm.sony.co.jp> | 2009-02-05 18:30:19 -0800 |
---|---|---|
committer | Yuji Mano <yuji.mano@am.sony.com> | 2009-02-11 11:00:59 -0800 |
commit | 64453e4ab72e0a54f3f87846722b8f73e90ccc60 (patch) | |
tree | 12560926b8afb6874830a0ca1c207bf66c89d207 | |
parent | 956329b48af53d75dbcd802fa4406897197cd1bb (diff) | |
download | mars-src-64453e4ab72e0a54f3f87846722b8f73e90ccc60.tar.gz |
base: Prevent use of non volatile regs
Guarantee non-volatile regs are not broken during scheduling workload
This patch guarantees non-volatile registers are not broken during
workload scheduling is performed by using -mfixed-range compiler
option. This patch also removes unnecessary 'noinline' attributes in
the kernel implementation.
Signed-off-by: Kazunori Asayama <asayama@sm.sony.co.jp>
Signed-off-by: Yuji Mano <yuji.mano@am.sony.com>
-rw-r--r-- | base/src/mpu/kernel/Makefile.am | 1 | ||||
-rw-r--r-- | base/src/mpu/kernel/kernel.c | 36 |
2 files changed, 22 insertions, 15 deletions
diff --git a/base/src/mpu/kernel/Makefile.am b/base/src/mpu/kernel/Makefile.am index 43ee36b..e2258a0 100644 --- a/base/src/mpu/kernel/Makefile.am +++ b/base/src/mpu/kernel/Makefile.am @@ -72,6 +72,7 @@ AM_CCASFLAGS = \ AM_CFLAGS = \ $(extra_cflags) \ + -mfixed-range=80-127 \ -W \ -Wall \ -Wunused \ diff --git a/base/src/mpu/kernel/kernel.c b/base/src/mpu/kernel/kernel.c index 95d68f3..e189647 100644 --- a/base/src/mpu/kernel/kernel.c +++ b/base/src/mpu/kernel/kernel.c @@ -575,7 +575,7 @@ static void release_block(int block, int index) notify_host_bits(block_ea, index); } -static int __attribute__((noinline)) reserve_workload(void) +static int reserve_workload(void) { int block; int index = -1; @@ -601,7 +601,7 @@ static int __attribute__((noinline)) reserve_workload(void) return MARS_WORKLOAD_RESERVED; } -static void __attribute__((noinline)) release_workload(void) +static void release_workload(void) { int block = workload_id / MARS_WORKLOAD_PER_BLOCK; int index = workload_id % MARS_WORKLOAD_PER_BLOCK; @@ -613,7 +613,23 @@ static void __attribute__((noinline)) release_workload(void) release_block(block, index); } -static int __attribute__((noinline)) scheduler(void) +static void __attribute__((noinline)) run_workload(void) +{ + /* save kernel stack pointer */ + asm volatile ( + "stqa $sp, _kernel_stack;" + ); + + /* 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) { int status; @@ -642,21 +658,11 @@ static int __attribute__((noinline)) scheduler(void) memset((void *)MARS_WORKLOAD_MODULE_BASE_ADDR + workload.module.exec_size, 0, workload.module.bss_size); - /* save kernel stack pointer */ - asm volatile ( - "stqa $sp, _kernel_stack;" - ); - /* sync before executing loaded code */ spu_sync(); - /* call module entry function */ - ((module_entry)workload.module.entry)(&kernel_syscalls); - - /* label so module can jump back here at exit */ - asm volatile ( - "_module_exit:" - ); + /* run workload */ + run_workload(); /* release reservation of current workload */ release_workload(); |