[Cbe-oss-dev] [PATCH 2/2]MARS/task: use dma kernel syscalls
Yuji Mano
yuji.mano at am.sony.com
Tue Feb 10 10:31:12 EST 2009
This removes the internal dma implementation and replaces all dma calls with
the dma routines provided by the module API.
The purpose of this change is to reduce task module code size and make use of
new module API provided by the kernel.
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
task/src/mpu/module/task_module.c | 105 +++++++++++---------------------------
task/src/mpu/module/task_module.h | 18 +++---
2 files changed, 42 insertions(+), 81 deletions(-)
--- a/task/src/mpu/module/task_module.c
+++ b/task/src/mpu/module/task_module.c
@@ -192,38 +192,11 @@ static void registers_restore(void)
: : [ptr] "r" (__task_stack));
}
-static void dma_large(void *ls, uint64_t ea, uint32_t size, uint32_t tag,
- int put)
-{
- while (size) {
- unsigned int block_size;
-
- block_size = (size < MARS_TASK_MODULE_DMA_SIZE_MAX) ?
- size : MARS_TASK_MODULE_DMA_SIZE_MAX;
-
- if (put)
- mfc_put((volatile void *)ls, ea, block_size, tag, 0, 0);
- else
- mfc_get((volatile void *)ls, ea, block_size, tag, 0, 0);
-
- ls += block_size;
- ea += block_size;
- size -= block_size;
- }
-}
-
-static void dma_wait(uint32_t tag)
-{
- mfc_write_tag_mask(1 << tag);
- mfc_write_tag_update_all();
- mfc_read_tag_status();
-}
-
static void dma_context(int save, void *task_heap)
{
- int offset = 0;
uint32_t low_size, high_size;
+ /* save or restore context */
if (save) {
/* text, data and heap (low address) */
low_size =
@@ -250,27 +223,35 @@ static void dma_context(int save, void *
/* save save sizes to task context */
task->context_save_area_low_size = low_size;
task->context_save_area_high_size = high_size;
- }
- else {
+
+ /* save text and heap (low address) */
+ mars_module_dma_put((void *)MARS_TASK_BASE_ADDR,
+ task->context_save_area_ea,
+ low_size, MARS_TASK_MODULE_DMA_TAG);
+
+ /* save stack (high address) */
+ mars_module_dma_put((void *)(MARS_TASK_BASE_ADDR +
+ MARS_TASK_CONTEXT_SAVE_SIZE_MAX - high_size),
+ task->context_save_area_ea + low_size,
+ high_size, MARS_TASK_MODULE_DMA_TAG);
+ } else {
/* restore save sizes from task context */
low_size = task->context_save_area_low_size;
high_size = task->context_save_area_high_size;
- }
- /* save or restore text and heap (low address) */
- dma_large((void *)MARS_TASK_BASE_ADDR,
- task->context_save_area_ea + offset,
- low_size, MARS_TASK_MODULE_DMA_TAG, save);
- offset += low_size;
-
- /* save or restore stack (high addres) */
- dma_large((void *)(MARS_TASK_BASE_ADDR +
- MARS_TASK_CONTEXT_SAVE_SIZE_MAX - high_size),
- task->context_save_area_ea + offset,
- high_size, MARS_TASK_MODULE_DMA_TAG, save);
- offset += high_size;
+ /* restore text and heap (low address) */
+ mars_module_dma_get((void *)MARS_TASK_BASE_ADDR,
+ task->context_save_area_ea,
+ low_size, MARS_TASK_MODULE_DMA_TAG);
+
+ /* restore stack (high address) */
+ mars_module_dma_get((void *)(MARS_TASK_BASE_ADDR +
+ MARS_TASK_CONTEXT_SAVE_SIZE_MAX - high_size),
+ task->context_save_area_ea + low_size,
+ high_size, MARS_TASK_MODULE_DMA_TAG);
+ }
- dma_wait(MARS_TASK_MODULE_DMA_TAG);
+ mars_module_dma_wait(MARS_TASK_MODULE_DMA_TAG);
}
static void __attribute__((noinline)) context_save(void *task_heap)
@@ -432,26 +413,6 @@ static int task_signal_try_wait(void)
return mars_module_workload_signal_reset();
}
-static int mutex_lock_get(uint64_t mutex_ea, struct mars_mutex *mutex)
-{
- return mars_module_mutex_lock_get(mutex_ea, mutex);
-}
-
-static int mutex_unlock_put(uint64_t mutex_ea, struct mars_mutex *mutex)
-{
- return mars_module_mutex_unlock_put(mutex_ea, mutex);
-}
-
-static void dma_get(void *ls, uint64_t ea, uint32_t size, uint32_t tag)
-{
- dma_large(ls, ea, size, tag, 0);
-}
-
-static void dma_put(const void *ls, uint64_t ea, uint32_t size, uint32_t tag)
-{
- dma_large((void *)ls, ea, size, tag, 1);
-}
-
static struct mars_task_module_syscalls task_module_syscalls =
{
get_ticks,
@@ -469,12 +430,12 @@ static struct mars_task_module_syscalls
task_signal_wait,
task_signal_try_wait,
- mutex_lock_get,
- mutex_unlock_put,
+ mars_module_mutex_lock_get,
+ mars_module_mutex_unlock_put,
- dma_get,
- dma_put,
- dma_wait
+ mars_module_dma_get,
+ mars_module_dma_put,
+ mars_module_dma_wait
};
static void context_start(void)
@@ -491,9 +452,9 @@ static void context_start(void)
*bss_ptr++ = spu_splats((unsigned char)0);
/* dma the text and data section */
- dma_large((void *)MARS_TASK_BASE_ADDR, task->exec_ea, task->exec_size,
- MARS_TASK_MODULE_DMA_TAG, 0);
- dma_wait(MARS_TASK_MODULE_DMA_TAG);
+ mars_module_dma_get((void *)MARS_TASK_BASE_ADDR, task->exec_ea,
+ task->exec_size, MARS_TASK_MODULE_DMA_TAG);
+ mars_module_dma_wait(MARS_TASK_MODULE_DMA_TAG);
/* sync before executing loaded code */
spu_sync();
--- a/task/src/mpu/module/task_module.h
+++ b/task/src/mpu/module/task_module.h
@@ -73,10 +73,10 @@ struct mars_task_module_syscalls {
int (*mutex_unlock_put)(uint64_t mutex_ea,
struct mars_mutex *mutex);
- void (*dma_get)(void *ls, uint64_t ea, uint32_t size, uint32_t tag);
- void (*dma_put)(const void *ls, uint64_t ea, uint32_t size,
+ int (*dma_get)(void *ls, uint64_t ea, uint32_t size, uint32_t tag);
+ int (*dma_put)(const void *ls, uint64_t ea, uint32_t size,
uint32_t tag);
- void (*dma_wait)(uint32_t tag);
+ int (*dma_wait)(uint32_t tag);
};
#if defined(__cplusplus)
@@ -171,21 +171,21 @@ static inline int mars_mutex_unlock_put(
return (*mars_task_module_syscalls->mutex_unlock_put)(mutex_ea, mutex);
}
-static inline void mars_dma_get(void *ls, uint64_t ea, uint32_t size,
+static inline int mars_dma_get(void *ls, uint64_t ea, uint32_t size,
uint32_t tag)
{
- (*mars_task_module_syscalls->dma_get)(ls, ea, size, tag);
+ return (*mars_task_module_syscalls->dma_get)(ls, ea, size, tag);
}
-static inline void mars_dma_put(const void *ls, uint64_t ea, uint32_t size,
+static inline int mars_dma_put(const void *ls, uint64_t ea, uint32_t size,
uint32_t tag)
{
- (*mars_task_module_syscalls->dma_put)(ls, ea, size, tag);
+ return (*mars_task_module_syscalls->dma_put)(ls, ea, size, tag);
}
-static inline void mars_dma_wait(uint32_t tag)
+static inline int mars_dma_wait(uint32_t tag)
{
- (*mars_task_module_syscalls->dma_wait)(tag);
+ return (*mars_task_module_syscalls->dma_wait)(tag);
}
#if defined(__cplusplus)
More information about the cbe-oss-dev
mailing list