[Cbe-oss-dev] [PATCH 07/22]MARS/base: context system sanity check
Yuji Mano
yuji.mano at am.sony.com
Fri Mar 20 07:54:07 EST 2009
This patch adds a simple system sanity check at MARS context creation.
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
base/src/host/lib/context.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
--- a/base/src/host/lib/context.c
+++ b/base/src/host/lib/context.c
@@ -43,10 +43,14 @@
#include "mars/base.h"
#include "mars/context.h"
#include "mars/error.h"
+#include "mars/mutex.h"
#include "mars/workload_queue.h"
-#include "context_internal.h"
+#include "callback_internal_types.h"
#include "kernel_internal_types.h"
+#include "workload_internal_types.h"
+
+#include "context_internal.h"
uint32_t mars_get_ticks(void)
{
@@ -148,6 +152,33 @@ static int mpu_contexts_destroy(struct m
return MARS_SUCCESS;
}
+static int system_sanity_check(void)
+{
+ if ((MARS_CALLBACK_ARGS_SIZE !=
+ sizeof(struct mars_callback_args)) ||
+ (MARS_CALLBACK_QUEUE_SIZE !=
+ sizeof(struct mars_callback_queue)) ||
+ (MARS_KERNEL_PARAMS_SIZE !=
+ sizeof(struct mars_kernel_params)) ||
+ (MARS_MUTEX_SIZE !=
+ sizeof(struct mars_mutex)) ||
+ (MARS_WORKLOAD_CALLBACK_SIZE !=
+ sizeof(struct mars_workload_callback)) ||
+ (MARS_WORKLOAD_CONTEXT_SIZE !=
+ sizeof(struct mars_workload_context)) ||
+ (MARS_WORKLOAD_MODULE_SIZE !=
+ sizeof(struct mars_workload_module)) ||
+ (MARS_WORKLOAD_QUEUE_SIZE !=
+ sizeof(struct mars_workload_queue)) ||
+ (MARS_WORKLOAD_QUEUE_HEADER_SIZE !=
+ sizeof(struct mars_workload_queue_header)) ||
+ (MARS_WORKLOAD_QUEUE_BLOCK_SIZE !=
+ sizeof(struct mars_workload_queue_block)))
+ return MARS_ERROR_INTERNAL;
+
+ return MARS_SUCCESS;
+}
+
int mars_context_create(struct mars_context **mars_ret, uint32_t num_mpus,
uint8_t shared)
{
@@ -168,6 +199,11 @@ int mars_context_create(struct mars_cont
if (!num_mpus)
num_mpus = num_mpus_max;
+ /* system sanity check */
+ ret = system_sanity_check();
+ if (ret != MARS_SUCCESS)
+ return ret;
+
/* lock mutex */
ret = mars_host_mutex_lock(&mars_shared_context_lock);
if (ret != MARS_SUCCESS)
More information about the cbe-oss-dev
mailing list