[Cbe-oss-dev] [PATCH 04/11]MARS: Kernel internal implementation cleanup
Yuji Mano
yuji.mano at am.sony.com
Fri Sep 12 05:34:37 EST 2008
This cleans up some internal implementation of the MARS kernel. The changes
mainly consists of renaming some internal function names for consistency and
replacing the term "process" with "workload" for consistency with MARS design
and documentation.
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
include/host/mars/mars_task.h | 6 ++----
include/mpu/mars/mars_kernel.h | 16 ++++++++--------
include/mpu/mars/mars_task.h | 3 +--
src/host/lib/mars_task.c | 6 ++----
src/mpu/kernel/mars_kernel_registers.c | 8 ++++----
src/mpu/kernel/mars_kernel_scheduler.c | 4 ++--
src/mpu/kernel/mars_kernel_syscalls.c | 26 +++++++++++++-------------
src/mpu/kernel/mars_kernel_task.c | 18 +++++++++---------
src/mpu/kernel/mars_kernel_workload.c | 24 ++++++++++++------------
9 files changed, 53 insertions(+), 58 deletions(-)
--- a/include/host/mars/mars_task.h
+++ b/include/host/mars/mars_task.h
@@ -115,8 +115,7 @@ struct mars_task_params {
* \n MARS_ERROR_MEMORY - not enough memory
* \n MARS_ERROR_LIMIT - task queue is currently full
*/
-int mars_task_initialize(struct mars_context *mars,
- struct mars_task_id *id,
+int mars_task_initialize(struct mars_context *mars, struct mars_task_id *id,
struct mars_task_params *params);
/**
@@ -170,8 +169,7 @@ int mars_task_finalize(struct mars_task_
* \n MARS_ERROR_PARAMS - bad task id specified
* \n MARS_ERROR_STATE - task is in an invalid state
*/
-int mars_task_schedule(struct mars_task_id *id,
- struct mars_task_args *args,
+int mars_task_schedule(struct mars_task_id *id, struct mars_task_args *args,
uint8_t priority);
/**
--- a/include/mpu/mars/mars_kernel.h
+++ b/include/mpu/mars/mars_kernel.h
@@ -109,10 +109,10 @@ uint16_t workload_get_id(void);
uint64_t workload_get_ea(void);
struct mars_workload_context * workload_get_context(void);
-void workload_run(void);
-void workload_stop(void);
-void workload_save(void);
-void workload_restore(void);
+void workload_exec(void);
+void workload_exit(void);
+void workload_yield(void);
+void workload_resume(void);
int workload_schedule(uint16_t workload_id, void *args, uint8_t priority);
int workload_wait(uint16_t workload_id);
int workload_try_wait(uint16_t workload_id);
@@ -121,10 +121,10 @@ void workload_signal_wait(void);
int workload_signal_try_wait(void);
/* task specific functions */
-void task_run(struct mars_task_context *task);
-void task_stop(struct mars_task_context *task);
-void task_save(struct mars_task_context *task);
-void task_restore(struct mars_task_context *task);
+void task_exec(struct mars_task_context *task);
+void task_exit(struct mars_task_context *task);
+void task_yield(struct mars_task_context *task);
+void task_resume(struct mars_task_context *task);
void task_schedule(struct mars_task_context *task, struct mars_task_args *args);
extern struct mars_kernel_params kernel_params;
--- a/include/mpu/mars/mars_task.h
+++ b/include/mpu/mars/mars_task.h
@@ -128,8 +128,7 @@ int mars_task_yield(void);
* \n MARS_ERROR_PARAMS - bad task id specified
* \n MARS_ERROR_STATE - task is in an invalid state
*/
-int mars_task_schedule(struct mars_task_id *id,
- struct mars_task_args *args,
+int mars_task_schedule(struct mars_task_id *id, struct mars_task_args *args,
uint8_t priority);
/**
--- a/src/host/lib/mars_task.c
+++ b/src/host/lib/mars_task.c
@@ -45,8 +45,7 @@
#include "mars/mars_error.h"
#include "mars/mars_debug.h"
-int mars_task_initialize(struct mars_context *mars,
- struct mars_task_id *id,
+int mars_task_initialize(struct mars_context *mars, struct mars_task_id *id,
struct mars_task_params *params)
{
MARS_CHECK_RET(mars, MARS_ERROR_NULL);
@@ -154,8 +153,7 @@ int mars_task_finalize(struct mars_task_
return MARS_SUCCESS;
}
-int mars_task_schedule(struct mars_task_id *id,
- struct mars_task_args *args,
+int mars_task_schedule(struct mars_task_id *id, struct mars_task_args *args,
uint8_t priority)
{
MARS_CHECK_RET(id, MARS_ERROR_NULL);
--- a/src/mpu/kernel/mars_kernel_registers.c
+++ b/src/mpu/kernel/mars_kernel_registers.c
@@ -39,9 +39,9 @@
void registers_save(void)
{
- /* push non-volatile registers on to the stack */
+ /* push non-volatile registers on to the workload stack */
asm volatile (
- "lqa $75, process_stack;"
+ "lqa $75, workload_stack;"
"stqd $80, -16($75);"
"stqd $81, -32($75);"
@@ -96,9 +96,9 @@ void registers_save(void)
void registers_restore(void)
{
- /* pop non-volatile registers from saved process stack */
+ /* pop non-volatile registers from saved workload stack */
asm volatile (
- "lqa $75, process_stack;"
+ "lqa $75, workload_stack;"
"lqd $80, -16($75);"
"lqd $81, -32($75);"
--- a/src/mpu/kernel/mars_kernel_scheduler.c
+++ b/src/mpu/kernel/mars_kernel_scheduler.c
@@ -257,8 +257,8 @@ int scheduler(void)
if (status == MARS_WORKLOAD_RESERVED_NONE)
return MARS_KERNEL_STATUS_IDLE;
- /* run the reserved workload */
- workload_run();
+ /* execute the reserved workload */
+ workload_exec();
/* release reservation of current workload */
release_workload();
--- a/src/mpu/kernel/mars_kernel_syscalls.c
+++ b/src/mpu/kernel/mars_kernel_syscalls.c
@@ -40,7 +40,7 @@
struct mars_kernel_syscalls kernel_syscalls;
void *kernel_stack;
-void *process_stack;
+void *workload_stack;
void mars_reentry(void)
{
@@ -115,31 +115,31 @@ void syscall_exit(void)
"lqa $sp, kernel_stack;"
);
- /* exit current process */
- workload_stop();
+ /* exit current workload */
+ workload_exit();
}
void syscall_yield(void)
{
- /* save process stack and restore kernel stack */
+ /* save workload stack and restore kernel stack */
asm volatile (
- "stqa $sp, process_stack;"
+ "stqa $sp, workload_stack;"
"lqa $sp, kernel_stack;"
);
- /* save current process */
- workload_save();
+ /* yield current workload */
+ workload_yield();
}
void syscall_resume(void)
{
- /* restore current process */
- workload_restore();
+ /* resume current workload */
+ workload_resume();
- /* save kernel stack and restore process stack */
+ /* save kernel stack and restore workload stack */
asm volatile (
"stqa $sp, kernel_stack;"
- "lqa $sp, process_stack;"
+ "lqa $sp, workload_stack;"
);
}
@@ -165,9 +165,9 @@ int syscall_signal_send(uint16_t workloa
void syscall_signal_wait(void)
{
- /* save process stack and restore kernel stack */
+ /* save workload stack and restore kernel stack */
asm volatile (
- "stqa $sp, process_stack;"
+ "stqa $sp, workload_stack;"
"lqa $sp, kernel_stack;"
);
--- a/src/mpu/kernel/mars_kernel_task.c
+++ b/src/mpu/kernel/mars_kernel_task.c
@@ -38,9 +38,9 @@
#include <string.h>
#include "mars/mars_kernel.h"
-extern void *process_stack;
+extern void *workload_stack;
-void task_run(struct mars_task_context *task)
+void task_exec(struct mars_task_context *task)
{
MARS_ASSERT(task);
@@ -62,19 +62,19 @@ void task_run(struct mars_task_context *
}
}
-void task_stop(struct mars_task_context *task)
+void task_exit(struct mars_task_context *task)
{
MARS_ASSERT(task);
}
-void task_save(struct mars_task_context *task)
+void task_yield(struct mars_task_context *task)
{
MARS_ASSERT(task);
MARS_ASSERT(task->context_save_area);
MARS_ASSERT(task->context_save_size);
- /* save process stack pointer */
- task->stack = (uint32_t)process_stack;
+ /* save workload stack pointer */
+ task->stack = (uint32_t)workload_stack;
/* dma context into context save area in host storage */
mars_dma_large_put_and_wait((void *)task->vaddr,
@@ -83,14 +83,14 @@ void task_save(struct mars_task_context
MARS_DMA_TAG);
}
-void task_restore(struct mars_task_context *task)
+void task_resume(struct mars_task_context *task)
{
MARS_ASSERT(task);
MARS_ASSERT(task->context_save_area);
MARS_ASSERT(task->context_save_size);
- /* restore process stack pointer */
- process_stack = (void *)task->stack;
+ /* restore workload stack pointer */
+ workload_stack = (void *)task->stack;
/* dma context to mpu storage from context save area in host storage */
mars_dma_large_get_and_wait((void *)task->vaddr,
--- a/src/mpu/kernel/mars_kernel_workload.c
+++ b/src/mpu/kernel/mars_kernel_workload.c
@@ -60,7 +60,7 @@ struct mars_workload_context *workload_g
return &workload;
}
-void workload_run(void)
+void workload_exec(void)
{
/* set current workload state to running */
workload_state = MARS_WORKLOAD_STATE_RUNNING;
@@ -68,12 +68,12 @@ void workload_run(void)
/* workload type specific handling */
switch (workload_type) {
case MARS_WORKLOAD_TYPE_TASK:
- task_run((struct mars_task_context *)&workload);
+ task_exec((struct mars_task_context *)&workload);
break;
}
}
-void workload_stop(void)
+void workload_exit(void)
{
/* set current workload state to finished */
workload_state = MARS_WORKLOAD_STATE_FINISHED;
@@ -81,12 +81,12 @@ void workload_stop(void)
/* workload type specific handling */
switch (workload_type) {
case MARS_WORKLOAD_TYPE_TASK:
- task_stop((struct mars_task_context *)&workload);
+ task_exit((struct mars_task_context *)&workload);
break;
}
}
-void workload_save(void)
+void workload_yield(void)
{
/* set current workload state to ready */
workload_state = MARS_WORKLOAD_STATE_READY;
@@ -97,13 +97,13 @@ void workload_save(void)
/* save non-volatile registers */
registers_save();
- /* save the task context to main memory */
- task_save((struct mars_task_context *)&workload);
+ /* yield the task context */
+ task_yield((struct mars_task_context *)&workload);
break;
}
}
-void workload_restore(void)
+void workload_resume(void)
{
/* set current workload state to running */
workload_state = MARS_WORKLOAD_STATE_RUNNING;
@@ -111,8 +111,8 @@ void workload_restore(void)
/* workload type specific handling */
switch (workload_type) {
case MARS_WORKLOAD_TYPE_TASK:
- /* restore the task context from main memory */
- task_restore((struct mars_task_context *)&workload);
+ /* resume the task context */
+ task_resume((struct mars_task_context *)&workload);
/* restore non-volatile registers */
registers_restore();
@@ -289,8 +289,8 @@ void workload_signal_wait(void)
/* save non-volatile registers */
registers_save();
- /* save the task context to main memory */
- task_save((struct mars_task_context *)&workload);
+ /* yield the task context */
+ task_yield((struct mars_task_context *)&workload);
break;
}
}
More information about the cbe-oss-dev
mailing list