[Cbe-oss-dev] [PATCH 15/22]MARS/task: Module cleanup duplicate code
Yuji Mano
yuji.mano at am.sony.com
Wed Jan 21 11:29:39 EST 2009
This cleans up as much duplicate code as possible from task module
implementation to reduce task module elf size.
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
task/src/mpu/module/task_module.c | 67 ++++++++++++++++----------------------
task/src/mpu/module/task_module.h | 2 -
2 files changed, 30 insertions(+), 39 deletions(-)
--- a/task/src/mpu/module/task_module.c
+++ b/task/src/mpu/module/task_module.c
@@ -195,20 +195,14 @@ static void __attribute__((noinline)) re
);
}
-static void __attribute__((noinline)) context_save(void)
+static void process_context_save_list(int save)
{
int i, offset = 0;
- /* save registers state */
- registers_save();
-
- /* save workload stack pointer */
- task->stack = (uint32_t)_task_stack;
-
- /* get context save unit list */
mars_dma_get_and_wait(list, task->context_save_unit_ea,
- MARS_TASK_CONTEXT_SAVE_UNIT_SIZE *
- MARS_TASK_CONTEXT_SAVE_UNIT_MAX, MARS_DMA_TAG);
+ MARS_TASK_CONTEXT_SAVE_UNIT_SIZE *
+ MARS_TASK_CONTEXT_SAVE_UNIT_MAX,
+ MARS_DMA_TAG);
/* loop through save unit list */
for (i = 0; i < MARS_TASK_CONTEXT_SAVE_UNIT_MAX; i++) {
@@ -216,10 +210,18 @@ static void __attribute__((noinline)) co
if (!list[i].size)
break;
- /* request dma put of the context save unit specified */
- mars_dma_put((void *)(MARS_TASK_BASE_ADDR + list[i].addr),
- task->context_save_area_ea + offset,
- list[i].size, MARS_DMA_TAG);
+ /* save or restore context save unit specified */
+ if (save) {
+ mars_dma_put(
+ (void *)(MARS_TASK_BASE_ADDR + list[i].addr),
+ task->context_save_area_ea + offset,
+ list[i].size, MARS_DMA_TAG);
+ } else {
+ mars_dma_get(
+ (void *)(MARS_TASK_BASE_ADDR + list[i].addr),
+ task->context_save_area_ea + offset,
+ list[i].size, MARS_DMA_TAG);
+ }
offset += list[i].size;
}
@@ -228,31 +230,20 @@ static void __attribute__((noinline)) co
mars_dma_wait(MARS_DMA_TAG);
}
-static void __attribute__((noinline)) context_restore(void)
+static void __attribute__((noinline)) context_save(void)
{
- int i, offset = 0;
-
- /* get save context save unit list */
- mars_dma_get_and_wait(list, task->context_save_unit_ea,
- MARS_TASK_CONTEXT_SAVE_UNIT_SIZE *
- MARS_TASK_CONTEXT_SAVE_UNIT_MAX, MARS_DMA_TAG);
-
- /* loop through save unit list */
- for (i = 0; i < MARS_TASK_CONTEXT_SAVE_UNIT_MAX; i++) {
- /* list terminator so exit loop */
- if (!list[i].size)
- break;
+ /* save registers state */
+ registers_save();
- /* request dma get of the context save unit specified */
- mars_dma_get((void *)(MARS_TASK_BASE_ADDR + list[i].addr),
- task->context_save_area_ea + offset,
- list[i].size, MARS_DMA_TAG);
+ /* save workload stack pointer */
+ task->stack = (uint32_t)_task_stack;
- offset += list[i].size;
- }
+ process_context_save_list(1);
+}
- /* wait for all dmas to complete */
- mars_dma_wait(MARS_DMA_TAG);
+static void __attribute__((noinline)) context_restore(void)
+{
+ process_context_save_list(0);
/* restore workload stack pointer */
_task_stack = (void *)task->stack;
@@ -327,14 +318,14 @@ static void task_yield(void)
}
static int task_schedule(uint16_t workload_id, struct mars_task_args *args,
- uint8_t priority)
+ uint8_t priority)
{
int ret;
struct mars_task_context *schedule_task;
struct mars_workload_context *schedule_workload;
ret = mars_module_workload_schedule_begin(workload_id, priority,
- &schedule_workload);
+ &schedule_workload);
if (ret != MARS_SUCCESS)
return ret;
@@ -345,7 +336,7 @@ static int task_schedule(uint16_t worklo
schedule_task->stack = 0;
if (args)
memcpy(&schedule_task->args, args,
- sizeof(struct mars_task_args));
+ sizeof(struct mars_task_args));
/* end process to schedule the workload in the workload queue */
ret = mars_module_workload_schedule_end(workload_id);
--- a/task/src/mpu/module/task_module.h
+++ b/task/src/mpu/module/task_module.h
@@ -55,7 +55,7 @@ struct mars_task_module_syscalls {
void (*exit)(void);
void (*yield)(void);
int (*schedule)(uint16_t workload_id, struct mars_task_args *args,
- uint8_t priority);
+ uint8_t priority);
int (*wait)(uint16_t workload_id);
int (*try_wait)(uint16_t workload_id);
int (*signal_send)(uint16_t workload_id);
More information about the cbe-oss-dev
mailing list