aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuji Mano <yuji.mano@am.sony.com>2009-03-23 12:16:44 -0700
committerYuji Mano <yuji.mano@am.sony.com>2009-03-23 12:16:44 -0700
commit00933e3504facf3b56914112c4f7c2f9362addc7 (patch)
tree13899db5e01525488da0c938d7f999e266f0212c
parentaa8b9e7a7477aa711b5157d70126fec2ec265541 (diff)
downloadmars-src-00933e3504facf3b56914112c4f7c2f9362addc7.tar.gz
base: Workload query api
This patch updates the task module for compability with changes in the base library mars_module_workload_query macros. Signed-off-by: Yuji Mano <yuji.mano@am.sony.com> Acked-by: Kazunori Asayama <asayama@sm.sony.co.jp>
-rw-r--r--base/include/common/mars/workload_types.h16
-rw-r--r--base/include/host/mars/workload_queue.h20
-rw-r--r--base/include/mpu/mars/module.h16
-rw-r--r--base/src/host/lib/workload_queue.c60
-rw-r--r--base/src/mpu/kernel/kernel.c34
5 files changed, 117 insertions, 29 deletions
diff --git a/base/include/common/mars/workload_types.h b/base/include/common/mars/workload_types.h
index 82ae0aa..0350d5c 100644
--- a/base/include/common/mars/workload_types.h
+++ b/base/include/common/mars/workload_types.h
@@ -95,4 +95,20 @@ struct mars_workload_context {
uint8_t context[MARS_WORKLOAD_CONTEXT_SIZE - MARS_WORKLOAD_MODULE_SIZE];
} __attribute__((aligned(MARS_WORKLOAD_CONTEXT_ALIGN)));
+/**
+ * \brief MARS workload query types
+ *
+ * These are the query types you can pass into \ref mars_module_workload_query
+ */
+enum mars_workload_query {
+ MARS_WORKLOAD_QUERY_IS_MODULE_CACHED = 0, /**< module cached? */
+ MARS_WORKLOAD_QUERY_IS_CONTEXT_CACHED, /**< context cached? */
+ MARS_WORKLOAD_QUERY_IS_INITIALIZED, /**< is initialized? */
+ MARS_WORKLOAD_QUERY_IS_READY, /**< is ready? */
+ MARS_WORKLOAD_QUERY_IS_WAITING, /**< is waiting? */
+ MARS_WORKLOAD_QUERY_IS_RUNNING, /**< is running? */
+ MARS_WORKLOAD_QUERY_IS_FINISHED, /**< is finished? */
+ MARS_WORKLOAD_QUERY_IS_SIGNAL_SET /**< has signal set? */
+};
+
#endif
diff --git a/base/include/host/mars/workload_queue.h b/base/include/host/mars/workload_queue.h
index f941cf4..a81b911 100644
--- a/base/include/host/mars/workload_queue.h
+++ b/base/include/host/mars/workload_queue.h
@@ -59,6 +59,26 @@ int mars_workload_queue_exit(struct mars_context *mars);
/**
* \ingroup group_mars_workload_queue
+ * \brief <b>[host]</b> Returns whether or not specified query is satisfied.
+ *
+ * \note Query type \ref MARS_WORKLOAD_QUERY_IS_MODULE_CACHED and
+ * \ref MARS_WORKLOAD_QUERY_IS_CONTEXT_CACHED are only valid queries for the
+ * MPU-side call to \ref mars_module_workload_query.
+ * Calling \ref mars_workload_queue_query with these queries will always return
+ * 0.
+ *
+ * \param[in] mars - address of pointer to MARS context
+ * \param[in] id - id of workload
+ * \param[in] query - query type
+ * \return
+ * int - non-zero if query satisfied
+ */
+int mars_workload_queue_query(struct mars_context *mars,
+ uint16_t id,
+ int query);
+
+/**
+ * \ingroup group_mars_workload_queue
* \brief <b>[host]</b> Begins adding workload to workload queue.
*
* This function will begin the process to add a workload to the workload queue.
diff --git a/base/include/mpu/mars/module.h b/base/include/mpu/mars/module.h
index 0c631dc..be5caaa 100644
--- a/base/include/mpu/mars/module.h
+++ b/base/include/mpu/mars/module.h
@@ -125,21 +125,6 @@ struct mars_workload_context *mars_module_get_workload(void);
struct mars_workload_context *mars_module_get_workload_by_id(uint16_t id);
/**
- * \brief MARS workload module query types
- *
- * These are the query types you can pass into \ref mars_module_workload_query
- */
-enum {
- MARS_QUERY_IS_CACHED = 0, /**< query if workload is cached */
- MARS_QUERY_IS_INITIALIZED, /**< query if workload is initialized */
- MARS_QUERY_IS_READY, /**< query if workload is ready */
- MARS_QUERY_IS_WAITING, /**< query if workload is waiting */
- MARS_QUERY_IS_RUNNING, /**< query if workload is running */
- MARS_QUERY_IS_FINISHED, /**< query if workload is finished */
- MARS_QUERY_IS_SIGNAL_SET, /**< query if workload signal is set */
-};
-
-/**
* \ingroup group_mars_workload_module
* \brief <b>[MPU]</b> Returns whether or not specified query is satisfied.
*
@@ -147,6 +132,7 @@ enum {
* \param[in] query - query type
* \return
* int - non-zero if query satisfied
+
*/
int mars_module_workload_query(uint16_t id, int query);
diff --git a/base/src/host/lib/workload_queue.c b/base/src/host/lib/workload_queue.c
index 8b974c3..ab95a19 100644
--- a/base/src/host/lib/workload_queue.c
+++ b/base/src/host/lib/workload_queue.c
@@ -338,6 +338,66 @@ int mars_workload_queue_exit(struct mars_context *mars)
return MARS_SUCCESS;
}
+int mars_workload_queue_query(struct mars_context *mars,
+ uint16_t id,
+ int query)
+{
+ int block;
+ int index;
+ uint64_t queue_ea;
+ uint64_t block_ea;
+ uint64_t bits_ea;
+ uint64_t bits;
+
+ /* check function params */
+ if (!mars)
+ return 0;
+ if (!mars->workload_queue_ea)
+ return 0;
+ if (id > MARS_WORKLOAD_ID_MAX || !(id % MARS_WORKLOAD_PER_BLOCK))
+ return 0;
+
+ queue_ea = mars->workload_queue_ea;
+
+ /* calculate block/index from id */
+ block = id / MARS_WORKLOAD_PER_BLOCK;
+ index = id % MARS_WORKLOAD_PER_BLOCK;
+
+ /* prepare work area for queue block */
+ block_ea = get_block_ea(queue_ea, block);
+
+ mars_mutex_lock(block_ea);
+
+ /* get bits from workload queue block */
+ bits_ea = get_block_bits_ea(block_ea, index);
+ bits = mars_ea_get_uint64(bits_ea);
+
+ mars_mutex_unlock(block_ea);
+
+ switch (query) {
+ case MARS_WORKLOAD_QUERY_IS_INITIALIZED:
+ return (MARS_BITS_GET(&bits, WORKLOAD_STATE) !=
+ MARS_WORKLOAD_STATE_NONE);
+ case MARS_WORKLOAD_QUERY_IS_READY:
+ return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
+ MARS_WORKLOAD_STATE_READY);
+ case MARS_WORKLOAD_QUERY_IS_WAITING:
+ return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
+ MARS_WORKLOAD_STATE_WAITING);
+ case MARS_WORKLOAD_QUERY_IS_RUNNING:
+ return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
+ MARS_WORKLOAD_STATE_RUNNING);
+ case MARS_WORKLOAD_QUERY_IS_FINISHED:
+ return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
+ MARS_WORKLOAD_STATE_FINISHED);
+ case MARS_WORKLOAD_QUERY_IS_SIGNAL_SET:
+ return (MARS_BITS_GET(&bits, WORKLOAD_SIGNAL) ==
+ MARS_WORKLOAD_SIGNAL_ON);
+ }
+
+ return 0;
+}
+
static int alloc_block(uint64_t block_ea)
{
int ret = -1;
diff --git a/base/src/mpu/kernel/kernel.c b/base/src/mpu/kernel/kernel.c
index b2de697..848926c 100644
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -60,15 +60,16 @@ static struct mars_workload_context workload;
static uint16_t workload_id;
static uint64_t workload_ea;
static uint8_t workload_state;
-static uint8_t workload_cached;
+static uint8_t workload_is_cached;
/* workload to schedule */
static struct mars_workload_context schedule_workload;
static uint16_t schedule_workload_id;
/* workload module */
-static struct mars_workload_module *workload_module;
static struct mars_workload_module cached_workload_module;
+static struct mars_workload_module *workload_module;
+static uint8_t workload_module_is_cached;
/* workload module entry */
typedef void (*module_entry)(
@@ -341,29 +342,31 @@ static int workload_query(uint16_t id, int query)
uint64_t bits = get_block_bits(id);
switch (query) {
- case MARS_QUERY_IS_CACHED:
- return (id == workload_id && workload_cached);
- case MARS_QUERY_IS_INITIALIZED:
+ case MARS_WORKLOAD_QUERY_IS_MODULE_CACHED:
+ return workload_module_is_cached;
+ case MARS_WORKLOAD_QUERY_IS_CONTEXT_CACHED:
+ return (id == workload_id && workload_is_cached);
+ case MARS_WORKLOAD_QUERY_IS_INITIALIZED:
return (MARS_BITS_GET(&bits, WORKLOAD_STATE) !=
MARS_WORKLOAD_STATE_NONE);
- case MARS_QUERY_IS_READY:
+ case MARS_WORKLOAD_QUERY_IS_READY:
return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
MARS_WORKLOAD_STATE_READY);
- case MARS_QUERY_IS_WAITING:
+ case MARS_WORKLOAD_QUERY_IS_WAITING:
return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
MARS_WORKLOAD_STATE_WAITING);
- case MARS_QUERY_IS_RUNNING:
+ case MARS_WORKLOAD_QUERY_IS_RUNNING:
return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
MARS_WORKLOAD_STATE_RUNNING);
- case MARS_QUERY_IS_FINISHED:
+ case MARS_WORKLOAD_QUERY_IS_FINISHED:
return (MARS_BITS_GET(&bits, WORKLOAD_STATE) ==
MARS_WORKLOAD_STATE_FINISHED);
- case MARS_QUERY_IS_SIGNAL_SET:
+ case MARS_WORKLOAD_QUERY_IS_SIGNAL_SET:
return (MARS_BITS_GET(&bits, WORKLOAD_SIGNAL) ==
MARS_WORKLOAD_SIGNAL_ON);
}
- return MARS_ERROR_PARAMS;
+ return 0;
}
static uint64_t set_wait_id_bits(uint64_t bits, uint64_t id)
@@ -647,7 +650,7 @@ static int search_block(int block, int ready)
MARS_WORKLOAD_COUNTER_MIN);
/* check if this kernel ran this workload most recently */
- workload_cached =
+ workload_is_cached =
(workload_id ==
MARS_WORKLOAD_PER_BLOCK * block + index) &&
(kernel_params.kernel_id ==
@@ -779,9 +782,12 @@ static void workload_module_load(void)
{
__vector unsigned char *bss_ptr, *bss_end;
+ workload_module_is_cached =
+ !(kernel_memcmp(&cached_workload_module, workload_module,
+ sizeof(struct mars_workload_module)));
+
/* only reload the readonly text segment if different from cached */
- if (kernel_memcmp(&cached_workload_module, workload_module,
- sizeof(struct mars_workload_module))) {
+ if (!workload_module_is_cached) {
/* store the current cached workload module ea */
kernel_memcpy(&cached_workload_module, workload_module,
sizeof(struct mars_workload_module));