[Cbe-oss-dev] [PATCH 06/17]MARS/core: module get ticks

Yuji Mano yuji.mano at am.sony.com
Wed Dec 3 13:58:55 EST 2008


This adds the kernel syscall to get ticks from kernel through the module API.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>

---
 core/include/mpu/mars/module.h          |    1 +
 core/src/common/kernel_internal_types.h |    1 +
 core/src/mpu/kernel/kernel.c            |    6 ++++++
 core/src/mpu/lib/module.c               |    5 +++++
 4 files changed, 13 insertions(+)

--- a/core/include/mpu/mars/module.h
+++ b/core/include/mpu/mars/module.h
@@ -54,6 +54,7 @@ extern "C" {
 
 void mars_module_main(void);
 
+uint32_t mars_module_get_ticks(void);
 uint64_t mars_module_get_mars_context_ea(void);
 uint32_t mars_module_get_kernel_id(void);
 uint16_t mars_module_get_workload_id(void);
--- a/core/src/common/kernel_internal_types.h
+++ b/core/src/common/kernel_internal_types.h
@@ -51,6 +51,7 @@
 /* mars kernel syscalls */
 struct mars_kernel_syscalls {
 	void				   (*module_exit)(uint8_t state);
+	uint32_t			   (*get_ticks)(void);
 	uint64_t			   (*get_mars_context_ea)(void);
 	uint32_t			   (*get_kernel_id)(void);
 	uint16_t			   (*get_workload_id)(void);
--- a/core/src/mpu/kernel/kernel.c
+++ b/core/src/mpu/kernel/kernel.c
@@ -81,6 +81,11 @@ static void module_exit(uint8_t state)
 	);
 }
 
+static uint32_t get_ticks(void)
+{
+	return kernel_params.kernel_ticks.offset - spu_read_decrementer();
+}
+
 static uint64_t get_mars_context_ea(void)
 {
 	return kernel_params.mars_context_ea;
@@ -114,6 +119,7 @@ static struct mars_workload_queue_block 
 static struct mars_kernel_syscalls kernel_syscalls =
 {
 	module_exit,
+	get_ticks,
 	get_mars_context_ea,
 	get_kernel_id,
 	get_workload_id,
--- a/core/src/mpu/lib/module.c
+++ b/core/src/mpu/lib/module.c
@@ -86,6 +86,11 @@ void mars_module_entry(struct mars_kerne
 	(*kernel_syscalls->module_exit)(MARS_WORKLOAD_STATE_FINISHED);
 }
 
+uint32_t mars_module_get_ticks(void)
+{
+	return (*kernel_syscalls->get_ticks)();
+}
+
 uint64_t mars_module_get_mars_context_ea(void)
 {
 	return (*kernel_syscalls->get_mars_context_ea)();






More information about the cbe-oss-dev mailing list