aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuji Mano <yuji.mano@am.sony.com>2009-02-05 18:33:20 -0800
committerYuji Mano <yuji.mano@am.sony.com>2009-02-11 11:40:02 -0800
commitdac0ba355dcddcc5c9fcbc40910ccced5319acd5 (patch)
treed16ec72c5f983013d23b539b9c12a5e12f80ebbf
parent76da906a3d05b1a31b38feaff6b721e5dea698cf (diff)
downloadmars-src-dac0ba355dcddcc5c9fcbc40910ccced5319acd5.tar.gz
task: Cache workload context
This patch queries the kernel to check if the task context state is cached in MPU storage. If it is cached, then no context restore is necessary when resuming the task. Signed-off-by: Yuji Mano <yuji.mano@am.sony.com> Acked-by: Kazunori Asayama <asayama@sm.sony.co.jp>
-rw-r--r--task/include/mpu/mars/task.h4
-rw-r--r--task/src/mpu/lib/task.c2
-rw-r--r--task/src/mpu/module/task_module.c14
-rw-r--r--task/src/mpu/module/task_module.h4
4 files changed, 16 insertions, 8 deletions
diff --git a/task/include/mpu/mars/task.h b/task/include/mpu/mars/task.h
index 3bf07f5..ef9e0cc 100644
--- a/task/include/mpu/mars/task.h
+++ b/task/include/mpu/mars/task.h
@@ -248,9 +248,9 @@ uint32_t mars_task_get_ticks(void);
* will range from 0 to (# of MPUs initiialized for MARS context) - 1.
*
* \return
- * uint32_t - id of MARS kernel
+ * uint16_t - id of MARS kernel
*/
-uint32_t mars_task_get_kernel_id(void);
+uint16_t mars_task_get_kernel_id(void);
/**
* \ingroup group_mars_task
diff --git a/task/src/mpu/lib/task.c b/task/src/mpu/lib/task.c
index af882cc..9ced30f 100644
--- a/task/src/mpu/lib/task.c
+++ b/task/src/mpu/lib/task.c
@@ -165,7 +165,7 @@ uint32_t mars_task_get_ticks(void)
return mars_task_module_get_ticks();
}
-uint32_t mars_task_get_kernel_id(void)
+uint16_t mars_task_get_kernel_id(void)
{
return mars_task_module_get_kernel_id();
}
diff --git a/task/src/mpu/module/task_module.c b/task/src/mpu/module/task_module.c
index 69e6f66..2a6c8de 100644
--- a/task/src/mpu/module/task_module.c
+++ b/task/src/mpu/module/task_module.c
@@ -53,8 +53,9 @@
void *__module_stack;
void *__task_stack;
-/* global task structs */
+/* global task variables */
static struct mars_task_context *task;
+static int task_cached;
/* task entry */
typedef void (*mars_task_entry)(struct mars_task_args *args,
@@ -65,7 +66,7 @@ static uint32_t get_ticks(void)
return mars_module_get_ticks();
}
-static uint32_t get_kernel_id(void)
+static uint16_t get_kernel_id(void)
{
return mars_module_get_kernel_id();
}
@@ -280,12 +281,15 @@ static void __attribute__((noinline)) context_save(void *task_heap)
/* save workload stack pointer */
task->stack = (uint32_t)__task_stack;
+ /* save context MPU storage state */
dma_context(1, task_heap);
}
static void __attribute__((noinline)) context_restore(void)
{
- dma_context(0, NULL);
+ /* if task not cashed restore context MPU storage state */
+ if (!task_cached)
+ dma_context(0, NULL);
/* restore workload stack pointer */
__task_stack = (void *)task->stack;
@@ -508,6 +512,10 @@ void mars_module_main(void)
/* get task context */
task = get_task();
+ /* check if task context is cached in mpu storage */
+ task_cached = mars_module_workload_query(mars_module_get_workload_id(),
+ MARS_QUERY_IS_CACHED);
+
/* if stack pointer is uninitialized run fresh, otherwise resume */
if (!task->stack)
context_start();
diff --git a/task/src/mpu/module/task_module.h b/task/src/mpu/module/task_module.h
index 3434f1d..877b33d 100644
--- a/task/src/mpu/module/task_module.h
+++ b/task/src/mpu/module/task_module.h
@@ -52,7 +52,7 @@
/* mars task module syscalls */
struct mars_task_module_syscalls {
uint32_t (*get_ticks)(void);
- uint32_t (*get_kernel_id)(void);
+ uint16_t (*get_kernel_id)(void);
struct mars_task_context * (*get_task)(void);
struct mars_task_context * (*get_task_by_id)
(struct mars_task_id *task_id);
@@ -95,7 +95,7 @@ static inline uint32_t mars_task_module_get_ticks(void)
return (*mars_task_module_syscalls->get_ticks)();
}
-static inline uint32_t mars_task_module_get_kernel_id(void)
+static inline uint16_t mars_task_module_get_kernel_id(void)
{
return (*mars_task_module_syscalls->get_kernel_id)();
}