aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuji Mano <yuji.mano@am.sony.com>2009-03-13 18:18:21 -0700
committerYuji Mano <yuji.mano@am.sony.com>2009-03-17 11:08:09 -0700
commit97dc905a135cff3ed3e009ada9d5bdb356988116 (patch)
tree2d1ca10390ea8765b0a4d5de67ef8a1b3b9a15df
parent24a37c16d752aeae65abddae7e0e841c3d224336 (diff)
downloadmars-src-97dc905a135cff3ed3e009ada9d5bdb356988116.tar.gz
base: Kernel shared buffer reduce code size
This is patch to share a 128-byte global buffer for use by multiple functions in the kernel in order to keep code size and stack usage to a minimum. Signed-off-by: Yuji Mano <yuji.mano@am.sony.com> Acked-by: Kazunori Asayama <asayama@sm.sony.co.jp>
-rw-r--r--base/src/common/kernel_internal_types.h11
-rw-r--r--base/src/mpu/kernel/kernel.c26
-rw-r--r--base/src/mpu/kernel/mutex.c7
3 files changed, 28 insertions, 16 deletions
diff --git a/base/src/common/kernel_internal_types.h b/base/src/common/kernel_internal_types.h
index e38c0f6..4df701e 100644
--- a/base/src/common/kernel_internal_types.h
+++ b/base/src/common/kernel_internal_types.h
@@ -42,6 +42,8 @@
#include "mars/mutex_types.h"
+#include "workload_internal_types.h"
+
#define MARS_KERNEL_ID_NONE 0xffff
#define MARS_KERNEL_STATUS_BUSY 0x0
@@ -102,6 +104,15 @@ struct mars_kernel_params {
uint8_t pad[MARS_KERNEL_PARAMS_SIZE - 26];
} __attribute__((aligned(MARS_KERNEL_PARAMS_ALIGN)));
+/* mars kernel buffer */
+union mars_kernel_buffer {
+ struct mars_mutex mutex;
+ struct mars_workload_queue_header workload_queue_header;
+ struct mars_workload_queue_block workload_queue_block;
+};
+
+extern union mars_kernel_buffer kernel_buffer;
+
/* mars kernel mutex */
int mutex_lock_get(uint64_t mutex_ea, struct mars_mutex *mutex);
int mutex_unlock_put(uint64_t mutex_ea, struct mars_mutex *mutex);
diff --git a/base/src/mpu/kernel/kernel.c b/base/src/mpu/kernel/kernel.c
index 2803ba0..fe1138c 100644
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -49,6 +49,7 @@
/* kernel */
void *__kernel_stack;
+union mars_kernel_buffer kernel_buffer;
static struct mars_kernel_params kernel_params;
/* workload queue */
@@ -67,7 +68,7 @@ static struct mars_workload_context schedule_workload;
static uint16_t schedule_workload_id;
/* workload module cached */
-static struct mars_workload_module cached_workload_module = {0, 0, 0, 0};
+static struct mars_workload_module cached_workload_module;
/* workload module entry */
typedef void (*module_entry)(
@@ -586,8 +587,7 @@ static int search_block(int block, int ready)
} else if (!ready && state == MARS_WORKLOAD_STATE_WAITING) {
/* waiting for workload to finish so check status */
if (wait_id != MARS_WORKLOAD_ID_NONE) {
- struct mars_workload_queue_block wait_block;
- struct mars_workload_queue_block *p_wait_block;
+ struct mars_workload_queue_block *wait_block;
uint8_t wait_state;
int bl = wait_id / MARS_WORKLOAD_PER_BLOCK;
@@ -595,22 +595,23 @@ static int search_block(int block, int ready)
/* check if workload id is in the same block */
if (block != bl) {
+ /* set pointer to check buffer block */
+ wait_block =
+ &kernel_buffer.workload_queue_block;
+
/* fetch the necessary block */
- dma_get(&wait_block, get_block_ea(bl),
+ dma_get(wait_block, get_block_ea(bl),
sizeof(wait_block),
MARS_KERNEL_DMA_TAG);
dma_wait(MARS_KERNEL_DMA_TAG);
-
- /* set pointer to check fetched block */
- p_wait_block = &wait_block;
} else {
/* set pointer to check current block */
- p_wait_block = &queue_block;
+ wait_block = &queue_block;
}
/* get state of workload its waiting for */
wait_state =
- MARS_BITS_GET(&p_wait_block->bits[id],
+ MARS_BITS_GET(&wait_block->bits[id],
WORKLOAD_STATE);
/* check if workload is finished and reset */
@@ -839,7 +840,8 @@ static int scheduler(void)
static void scheduler_idle_wait(void)
{
int mask;
- struct mars_workload_queue_header cur_queue_header;
+ struct mars_workload_queue_header *cur_queue_header =
+ &kernel_buffer.workload_queue_header;
/* save event mask */
mask = spu_read_event_mask();
@@ -848,11 +850,11 @@ static void scheduler_idle_wait(void)
spu_write_event_mask(MFC_LLR_LOST_EVENT);
/* get current atomic state of queue header */
- mfc_getllar(&cur_queue_header, kernel_params.workload_queue_ea, 0, 0);
+ mfc_getllar(cur_queue_header, kernel_params.workload_queue_ea, 0, 0);
mfc_read_atomic_status();
/* check if queue header has been modified since we last fetched it */
- if (!kernel_memcmp(&queue_header, &cur_queue_header,
+ if (!kernel_memcmp(&queue_header, cur_queue_header,
sizeof(struct mars_workload_queue_header))) {
/* wait until queue header is modified */
spu_read_event_status();
diff --git a/base/src/mpu/kernel/mutex.c b/base/src/mpu/kernel/mutex.c
index 3608a06..7bcba54 100644
--- a/base/src/mpu/kernel/mutex.c
+++ b/base/src/mpu/kernel/mutex.c
@@ -46,8 +46,6 @@
#define MARS_MUTEX_STATE_NONE 0
#define MARS_MUTEX_STATE_DONE 2
-static struct mars_mutex mutex_buffer;
-
int mutex_lock_get(uint64_t mutex_ea, struct mars_mutex *mutex)
{
int mask;
@@ -112,6 +110,7 @@ int mutex_lock_get(uint64_t mutex_ea, struct mars_mutex *mutex)
int mutex_unlock_put(uint64_t mutex_ea, struct mars_mutex *mutex)
{
int status, mask;
+ struct mars_mutex *mutex_buffer = &kernel_buffer.mutex;
/* check function params */
if (!mutex_ea)
@@ -134,10 +133,10 @@ int mutex_unlock_put(uint64_t mutex_ea, struct mars_mutex *mutex)
spu_write_event_mask(MFC_LLR_LOST_EVENT);
do {
- mfc_getllar(&mutex_buffer, mutex_ea, 0, 0);
+ mfc_getllar(mutex_buffer, mutex_ea, 0, 0);
mfc_read_atomic_status();
- mutex->status = mutex_buffer.status;
+ mutex->status = mutex_buffer->status;
mutex->status.lock = MARS_MUTEX_UNLOCKED;
spu_dsync();