From patchwork Thu Sep 11 19:34:47 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuji Mano X-Patchwork-Id: 238 X-Patchwork-Delegate: yuji.mano@am.sony.com Return-Path: X-Original-To: patchwork@ozlabs.org Delivered-To: patchwork@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id C69D9DE417 for ; Fri, 12 Sep 2008 06:37:43 +1000 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from WA4EHSOBE002.bigfish.com (outbound-wa4.frontbridge.com [216.32.181.16]) by ozlabs.org (Postfix) with ESMTP id CE836DE00B for ; Fri, 12 Sep 2008 06:37:14 +1000 (EST) Received: from mail175-wa4-R.bigfish.com (10.8.14.253) by WA4EHSOBE002.bigfish.com (10.8.40.22) with Microsoft SMTP Server id 8.1.291.1; Thu, 11 Sep 2008 20:37:11 +0000 Received: from mail175-wa4 (localhost.localdomain [127.0.0.1]) by mail175-wa4-R.bigfish.com (Postfix) with ESMTP id B1180A285A7 for ; Thu, 11 Sep 2008 20:37:11 +0000 (UTC) X-BigFish: VS3(zzzz10c0j10d3izzz2dh6bh61h) X-Spam-TCS-SCL: 0:0 X-FB-SS: 5, Received: by mail175-wa4 (MessageSwitch) id 1221165429300407_22161; Thu, 11 Sep 2008 20:37:09 +0000 (UCT) Received: from mail8.fw-sd.sony.com (mail8.fw-sd.sony.com [160.33.66.75]) by mail175-wa4.bigfish.com (Postfix) with ESMTP id 2FB74158058 for ; Thu, 11 Sep 2008 20:37:09 +0000 (UTC) Received: from mail3.sjc.in.sel.sony.com (mail3.sjc.in.sel.sony.com [43.134.1.211]) by mail8.fw-sd.sony.com (8.14.2/8.14.2) with ESMTP id m8BKb8Il021155 for ; Thu, 11 Sep 2008 20:37:08 GMT Received: from USSDIXIM02.am.sony.com (ussdixim02.am.sony.com [43.130.140.34]) by mail3.sjc.in.sel.sony.com (8.12.11/8.12.11) with ESMTP id m8BKb7t9021726 for ; Thu, 11 Sep 2008 20:37:08 GMT Received: from ussdixms03.am.sony.com ([43.130.140.23]) by USSDIXIM02.am.sony.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 11 Sep 2008 13:37:07 -0700 Received: from [43.135.148.175] ([43.135.148.175]) by ussdixms03.am.sony.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 11 Sep 2008 13:37:07 -0700 Message-ID: <48C972D7.3030009@am.sony.com> Date: Thu, 11 Sep 2008 12:34:47 -0700 From: Yuji Mano User-Agent: Thunderbird 2.0.0.5 (X11/20070719) MIME-Version: 1.0 To: CBE Development X-Enigmail-Version: 0.95.7 X-OriginalArrivalTime: 11 Sep 2008 20:37:07.0241 (UTC) FILETIME=[28456190:01C9144E] X-SEL-encryption-scan: scanned Subject: [Cbe-oss-dev] [PATCH 05/11]MARS: Kernel syscall add get workload by id X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org This adds a new MARS kernel syscall 'mars_get_workload_by_id' to allow for the task library to grab an instance of a workload context other than the one currently running. This is needed when a task waits for completion of another task, and needs to obtain the exit_code of the completed task from the task context. This also renames the previously existing MARS kernel syscall 'mars_get_workload_context' to 'mars_get_workload'. Signed-off-by: Yuji Mano Acked-by: Kazunori Asayama --- a/include/mpu/mars/mars_kernel.h +++ b/include/mpu/mars/mars_kernel.h @@ -62,7 +62,9 @@ struct mars_kernel_syscalls { uint32_t (*get_kernel_id)(void); uint16_t (*get_workload_id)(void); uint64_t (*get_workload_ea)(void); - struct mars_workload_context *(*get_workload_context)(void); + struct mars_workload_context *(*get_workload)(void); + struct mars_workload_context *(*get_workload_by_id) + (uint16_t workload_id); void (*init)(void); void (*exit)(void); @@ -86,7 +88,8 @@ uint64_t syscall_get_mars_context_ea(voi uint32_t syscall_get_kernel_id(void); uint16_t syscall_get_workload_id(void); uint64_t syscall_get_workload_ea(void); -struct mars_workload_context *syscall_get_workload_context(void); +struct mars_workload_context *syscall_get_workload(void); +struct mars_workload_context *syscall_get_workload_by_id(uint16_t workload_id); void syscall_setup(void); void syscall_init(void); @@ -107,7 +110,8 @@ void registers_restore(void); /* workload specific functions */ uint16_t workload_get_id(void); uint64_t workload_get_ea(void); -struct mars_workload_context * workload_get_context(void); +struct mars_workload_context *workload_get(void); +struct mars_workload_context *workload_get_by_id(uint16_t workload_id); void workload_exec(void); void workload_exit(void); --- a/include/mpu/mars/mars_syscalls.h +++ b/include/mpu/mars/mars_syscalls.h @@ -48,7 +48,8 @@ uint64_t mars_get_mars_context_ea(void); uint32_t mars_get_kernel_id(void); uint16_t mars_get_workload_id(void); uint64_t mars_get_workload_ea(void); -struct mars_workload_context *mars_get_workload_context(void); +struct mars_workload_context *mars_get_workload(void); +struct mars_workload_context *mars_get_workload_by_id(uint16_t workload_id); void mars_init(void); void mars_exit(void); --- a/src/mpu/kernel/mars_kernel_syscalls.c +++ b/src/mpu/kernel/mars_kernel_syscalls.c @@ -53,7 +53,8 @@ void syscall_setup(void) kernel_syscalls.get_kernel_id = syscall_get_kernel_id; kernel_syscalls.get_workload_id = syscall_get_workload_id; kernel_syscalls.get_workload_ea = syscall_get_workload_ea; - kernel_syscalls.get_workload_context = syscall_get_workload_context; + kernel_syscalls.get_workload = syscall_get_workload; + kernel_syscalls.get_workload_by_id = syscall_get_workload_by_id; kernel_syscalls.init = syscall_init; kernel_syscalls.exit = syscall_exit; kernel_syscalls.yield = syscall_yield; @@ -85,9 +86,14 @@ uint64_t syscall_get_workload_ea(void) return workload_get_ea(); } -struct mars_workload_context *syscall_get_workload_context(void) +struct mars_workload_context *syscall_get_workload(void) { - return workload_get_context(); + return workload_get(); +} + +struct mars_workload_context *syscall_get_workload_by_id(uint16_t workload_id) +{ + return workload_get_by_id(workload_id); } void syscall_init(void) --- a/src/mpu/kernel/mars_kernel_workload.c +++ b/src/mpu/kernel/mars_kernel_workload.c @@ -55,11 +55,35 @@ uint64_t workload_get_ea(void) return workload_ea; } -struct mars_workload_context *workload_get_context(void) +struct mars_workload_context *workload_get(void) { return &workload; } +struct mars_workload_context *workload_get_by_id(uint16_t workload_id) +{ + MARS_CHECK_RET(workload_id < MARS_WORKLOAD_MAX, NULL); + + static struct mars_workload_context requested_workload; + uint64_t requested_workload_ea; + + /* workload id is same as current workload so return local copy */ + if (workload_id == workload_index) + return &workload; + + /* get ea of workload to get */ + requested_workload_ea = queue_header.context_ea + + workload_id * sizeof(struct mars_workload_context); + + /* dma the workload context code into LS from main memory */ + mars_dma_get_and_wait((void *)&requested_workload, + requested_workload_ea, + sizeof(struct mars_workload_context), + MARS_DMA_TAG); + + return &requested_workload; +} + void workload_exec(void) { /* set current workload state to running */ --- a/src/mpu/lib/mars_syscalls.c +++ b/src/mpu/lib/mars_syscalls.c @@ -60,9 +60,14 @@ uint64_t mars_get_workload_ea(void) return (*mars_kernel_syscalls->get_workload_ea)(); } -struct mars_workload_context *mars_get_workload_context(void) +struct mars_workload_context *mars_get_workload(void) { - return (*mars_kernel_syscalls->get_workload_context)(); + return (*mars_kernel_syscalls->get_workload)(); +} + +struct mars_workload_context *mars_get_workload_by_id(uint16_t workload_id) +{ + return (*mars_kernel_syscalls->get_workload_by_id)(workload_id); } void mars_init(void) --- a/src/mpu/lib/mars_task.c +++ b/src/mpu/lib/mars_task.c @@ -50,7 +50,7 @@ int mars_task_yield(void) { struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area, @@ -77,7 +77,7 @@ int mars_task_wait(struct mars_task_id * int ret; struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area, @@ -107,7 +107,7 @@ const struct mars_task_id *mars_task_get { struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); return &task->id; } @@ -116,7 +116,7 @@ const char *mars_task_get_name(void) { struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); return (const char *)task->id.name; } --- a/src/mpu/lib/mars_task_barrier.c +++ b/src/mpu/lib/mars_task_barrier.c @@ -75,7 +75,7 @@ int mars_task_barrier_notify(uint64_t ba int i; struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area, @@ -157,7 +157,7 @@ int mars_task_barrier_wait(uint64_t barr int i; struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area, --- a/src/mpu/lib/mars_task_event_flag.c +++ b/src/mpu/lib/mars_task_event_flag.c @@ -172,7 +172,7 @@ int mars_task_event_flag_wait(uint64_t e int wait = 0; struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area, --- a/src/mpu/lib/mars_task_queue.c +++ b/src/mpu/lib/mars_task_queue.c @@ -296,7 +296,7 @@ static int pop(uint64_t queue_ea, void * struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area, --- a/src/mpu/lib/mars_task_semaphore.c +++ b/src/mpu/lib/mars_task_semaphore.c @@ -75,7 +75,7 @@ int mars_task_semaphore_acquire(uint64_t struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area, --- a/src/mpu/lib/mars_task_signal.c +++ b/src/mpu/lib/mars_task_signal.c @@ -52,7 +52,7 @@ int mars_task_signal_wait(void) { struct mars_task_context *task; - task = (struct mars_task_context *)mars_get_workload_context(); + task = (struct mars_task_context *)mars_get_workload(); /* make sure task context has a context save area */ MARS_CHECK_RET(task->context_save_size && task->context_save_area,