[Cbe-oss-dev] [PATCH 6/7]MARS/core: Hide internal implementation

Yuji Mano yuji.mano at am.sony.com
Wed Oct 29 06:05:45 EST 2008


This moves all internal implementation details from the public API headers and
into internal source headers.

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

---
 core/include/common/mars/mutex_types.h           |   14 --
 core/include/common/mars/task_barrier_types.h    |   19 ---
 core/include/common/mars/task_event_flag_types.h |   19 ---
 core/include/common/mars/task_queue_types.h      |   29 ----
 core/include/common/mars/task_semaphore_types.h  |   15 --
 core/include/common/mars/task_types.h            |   32 -----
 core/include/host/mars/context.h                 |   14 --
 core/include/host/mars/task.h                    |    1 
 core/include/host/mars/task_barrier.h            |    1 
 core/include/host/mars/task_event_flag.h         |    1 
 core/include/host/mars/task_queue.h              |    1 
 core/include/host/mars/task_semaphore.h          |    1 
 core/include/mpu/mars/mutex.h                    |    1 
 core/include/mpu/mars/task.h                     |    1 
 core/include/mpu/mars/task_barrier.h             |    1 
 core/include/mpu/mars/task_event_flag.h          |    1 
 core/include/mpu/mars/task_queue.h               |    1 
 core/include/mpu/mars/task_semaphore.h           |    1 
 core/src/common/kernel_internal_types.h          |   52 ++++++++
 core/src/common/mutex_internal_types.h           |   54 ++++++++
 core/src/common/task_barrier_internal_types.h    |   59 +++++++++
 core/src/common/task_event_flag_internal_types.h |   59 +++++++++
 core/src/common/task_internal_types.h            |   66 ++++++++++
 core/src/common/task_queue_internal_types.h      |   69 +++++++++++
 core/src/common/task_semaphore_internal_types.h  |   55 +++++++++
 core/src/common/workload_internal_types.h        |  139 +++++++++++++++++++++++
 core/src/host/lib/Makefile.am                    |    5 
 core/src/host/lib/context.c                      |    3 
 core/src/host/lib/context_internal_types.h       |   57 +++++++++
 core/src/host/lib/mutex.c                        |    2 
 core/src/host/lib/task.c                         |    2 
 core/src/host/lib/task_barrier.c                 |    4 
 core/src/host/lib/task_event_flag.c              |    3 
 core/src/host/lib/task_queue.c                   |    3 
 core/src/host/lib/task_semaphore.c               |    4 
 core/src/host/lib/task_signal.c                  |    1 
 core/src/host/lib/workload_queue.c               |    3 
 core/src/host/lib/workload_queue.h               |    2 
 core/src/mpu/kernel/Makefile.am                  |    3 
 core/src/mpu/kernel/kernel.h                     |    6 
 core/src/mpu/lib/Makefile.am                     |    7 -
 core/src/mpu/lib/mutex.c                         |    1 
 core/src/mpu/lib/task.c                          |    1 
 core/src/mpu/lib/task_barrier.c                  |    3 
 core/src/mpu/lib/task_event_flag.c               |    3 
 core/src/mpu/lib/task_queue.c                    |    5 
 core/src/mpu/lib/task_semaphore.c                |    3 
 core/src/mpu/lib/task_signal.c                   |    1 
 48 files changed, 682 insertions(+), 146 deletions(-)

--- a/core/include/common/mars/mutex_types.h
+++ b/core/include/common/mars/mutex_types.h
@@ -44,24 +44,12 @@
  * \brief MARS Mutex Types
  */
 
-#include <stdint.h>
-
-/* internal defines */
-#define MARS_MUTEX_SIZE				128
-#define MARS_MUTEX_ALIGN			128
-#define MARS_MUTEX_ALIGN_MASK			0x7f
-#define MARS_MUTEX_LOCKED			0x1
-#define MARS_MUTEX_UNLOCKED			0x0
-
 /**
  * \ingroup group_mars_mutex
  * \brief MARS mutex structure
  *
  * An instance of this structure must be created when using the MARS Mutex API.
  */
-struct mars_mutex {
-	uint32_t lock;
-	uint8_t pad[124];
-} __attribute__((aligned(MARS_MUTEX_ALIGN)));
+struct mars_mutex;
 
 #endif
--- a/core/include/common/mars/task_barrier_types.h
+++ b/core/include/common/mars/task_barrier_types.h
@@ -44,19 +44,12 @@
  * \brief MARS Task Barrier Types
  */
 
-#include <stdint.h>
-
 /**
  * \ingroup group_mars_task_barrier
  * \brief Maximum tasks allowed for single barrier
  */
 #define MARS_TASK_BARRIER_WAIT_MAX		25
 
-/* internal defines */
-#define MARS_TASK_BARRIER_SIZE			128
-#define MARS_TASK_BARRIER_ALIGN			128
-#define MARS_TASK_BARRIER_ALIGN_MASK		0x7f
-
 /**
  * \ingroup group_mars_task_barrier
  * \brief MARS task barrier structure
@@ -64,16 +57,6 @@
  * An instance of this structure must be created when using any of the
  * MARS task barrier API.
  */
-struct mars_task_barrier {
-	uint32_t lock;
-	uint32_t total;
-	uint32_t notified_count;
-	uint32_t waited_count;
-	uint16_t notify_wait_count;
-	uint16_t notify_wait_id[MARS_TASK_BARRIER_WAIT_MAX];
-	uint16_t wait_count;
-	uint16_t wait_id[MARS_TASK_BARRIER_WAIT_MAX];
-	uint64_t mars_context_ea;
-} __attribute__((aligned(MARS_TASK_BARRIER_ALIGN)));
+struct mars_task_barrier;
 
 #endif
--- a/core/include/common/mars/task_event_flag_types.h
+++ b/core/include/common/mars/task_event_flag_types.h
@@ -44,8 +44,6 @@
  * \brief MARS Task Event Flag Types
  */
 
-#include <stdint.h>
-
 /**
  * \ingroup group_mars_task_event_flag
  * \brief Event flag direction from PPU to SPU
@@ -94,11 +92,6 @@
  */
 #define MARS_TASK_EVENT_FLAG_WAIT_MAX		15
 
-/* internal defines */
-#define MARS_TASK_EVENT_FLAG_SIZE		128
-#define MARS_TASK_EVENT_FLAG_ALIGN		128
-#define MARS_TASK_EVENT_FLAG_ALIGN_MASK		0x7f
-
 /**
  * \ingroup group_mars_task_event_flag
  * \brief MARS task event flag structure
@@ -106,16 +99,6 @@
  * An instance of this structure must be created when using any of the
  * MARS event flag API.
  */
-struct mars_task_event_flag {
-	uint32_t lock;
-	uint32_t bits;
-	uint8_t direction;
-	uint8_t clear_mode;
-	uint16_t wait_count;
-	uint16_t wait_id[MARS_TASK_EVENT_FLAG_WAIT_MAX + 1];
-	uint32_t wait_mask[MARS_TASK_EVENT_FLAG_WAIT_MAX];
-	uint8_t wait_mask_mode[MARS_TASK_EVENT_FLAG_WAIT_MAX + 1];
-	uint64_t mars_context_ea;
-} __attribute__((aligned(MARS_TASK_EVENT_FLAG_ALIGN)));
+struct mars_task_event_flag;
 
 #endif
--- a/core/include/common/mars/task_queue_types.h
+++ b/core/include/common/mars/task_queue_types.h
@@ -44,8 +44,6 @@
  * \brief MARS Task Queue Types
  */
 
-#include <stdint.h>
-
 /**
  * \ingroup group_mars_task_queue
  * \brief Queue direction from PPU to SPU
@@ -76,16 +74,6 @@
  */
 #define MARS_TASK_QUEUE_ENTRY_SIZE_MAX		16384
 
-/* internal defines */
-#define MARS_TASK_QUEUE_SIZE			128
-#define MARS_TASK_QUEUE_ALIGN			128
-#define MARS_TASK_QUEUE_ALIGN_MASK		0x7f
-#define MARS_TASK_QUEUE_ENTRY_SIZE_MASK		0xf
-#define MARS_TASK_QUEUE_ENTRY_ALIGN		16
-#define MARS_TASK_QUEUE_ENTRY_ALIGN_MASK	0xf
-#define MARS_TASK_QUEUE_BUFFER_ALIGN		16
-#define MARS_TASK_QUEUE_BUFFER_ALIGN_MASK	0xf
-
 /**
  * \ingroup group_mars_task_queue
  * \brief MARS task queue structure
@@ -93,21 +81,6 @@
  * An instance of this structure must be created when using any of the
  * MARS queue API.
  */
-struct mars_task_queue {
-	uint32_t lock;
-	uint32_t size;
-	uint32_t depth;
-	uint32_t count;
-	uint64_t buffer_ea;
-	uint64_t push_ea;
-	uint64_t pop_ea;
-	uint8_t direction;
-	uint8_t pad[3];
-	uint16_t push_wait_count;
-	uint16_t pop_wait_count;
-	uint16_t push_wait_id[MARS_TASK_QUEUE_WAIT_MAX];
-	uint16_t pop_wait_id[MARS_TASK_QUEUE_WAIT_MAX];
-	uint64_t mars_context_ea;
-} __attribute__((aligned(MARS_TASK_QUEUE_ALIGN)));
+struct mars_task_queue;
 
 #endif
--- a/core/include/common/mars/task_semaphore_types.h
+++ b/core/include/common/mars/task_semaphore_types.h
@@ -44,19 +44,12 @@
  * \brief MARS Task Semaphore Types
  */
 
-#include <stdint.h>
-
 /**
  * \ingroup group_mars_task_semaphore
  * \brief Maximum task accesses allowed for single semaphore
  */
 #define MARS_TASK_SEMAPHORE_WAIT_MAX		55
 
-/* internal defines */
-#define MARS_TASK_SEMAPHORE_SIZE		128
-#define MARS_TASK_SEMAPHORE_ALIGN		128
-#define MARS_TASK_SEMAPHORE_ALIGN_MASK		0x7f
-
 /**
  * \ingroup group_mars_task_semaphore
  * \brief MARS task semaphore structure
@@ -64,12 +57,6 @@
  * An instance of this structure must be created when using any of the
  * MARS semaphore API.
  */
-struct mars_task_semaphore {
-	uint32_t lock;
-	int32_t count;
-	uint16_t wait_count;
-	uint16_t wait_id[MARS_TASK_SEMAPHORE_WAIT_MAX];
-	uint64_t mars_context_ea;
-} __attribute__((aligned(MARS_TASK_SEMAPHORE_ALIGN)));
+struct mars_task_semaphore;
 
 #endif
--- a/core/include/common/mars/task_types.h
+++ b/core/include/common/mars/task_types.h
@@ -76,19 +76,6 @@
  */
 #define MARS_TASK_NAME_LEN_MAX			21
 
-/* internal task context defines */
-#define MARS_TASK_ID_SIZE				32
-#define MARS_TASK_ID_ALIGN				16
-#define MARS_TASK_ARGS_SIZE				32
-#define MARS_TASK_ARGS_ALIGN				16
-#define MARS_TASK_CONTEXT_SIZE				128
-#define MARS_TASK_CONTEXT_ALIGN				16
-#define MARS_TASK_CONTEXT_SAVE_ALIGN			128
-#define MARS_TASK_CONTEXT_SAVE_UNIT_SIZE		8
-#define MARS_TASK_CONTEXT_SAVE_UNIT_ALIGN		128
-#define MARS_TASK_CONTEXT_SAVE_UNIT_ADDR_ALIGN_MASK	0xf
-#define MARS_TASK_CONTEXT_SAVE_UNIT_SIZE_ALIGN_MASK	0xf
-
 /**
  * \ingroup group_mars_task
  * \brief MARS task id structure
@@ -103,7 +90,7 @@ struct mars_task_id {
 	uint64_t mars_context_ea;
 	uint16_t workload_id;
 	uint8_t name[MARS_TASK_NAME_LEN_MAX + 1];
-} __attribute__((aligned(MARS_TASK_ID_ALIGN)));
+};
 
 /**
  * \ingroup group_mars_task
@@ -126,7 +113,7 @@ struct mars_task_args {
 		/** array of 4 64-bit unsigned ints */
 		uint64_t u64[4];
 	} type;
-} __attribute__((aligned(MARS_TASK_ARGS_ALIGN)));
+};
 
 /**
  * \ingroup group_mars_task
@@ -147,19 +134,4 @@ struct mars_task_context_save_unit {
 
 extern const struct mars_task_context_save_unit mars_task_context_save_all[];
 
-struct mars_task_context {
-	struct mars_task_id id;		/* task id */
-	struct mars_task_args args;	/* task args */
-	uint64_t exec_ea;		/* ea of exec */
-	uint32_t exec_size;		/* size of text and data of exec */
-	uint32_t bss_size;		/* size of bss in memory of exec */
-	uint32_t vaddr;			/* vaddr address of exec */
-	uint32_t entry;			/* entry address of exec */
-	uint32_t stack;			/* stack pointer of exec */
-	int32_t exit_code;		/* exit code */
-	uint64_t context_save_area_ea;	/* ea of context save area */
-	uint64_t context_save_unit_ea;	/* ea of context save unit list */
-	uint8_t pad[16];		/* padding */
-} __attribute__((aligned(MARS_TASK_CONTEXT_ALIGN)));
-
 #endif
--- a/core/include/host/mars/context.h
+++ b/core/include/host/mars/context.h
@@ -45,7 +45,6 @@
  */
 
 #include <stdint.h>
-#include <pthread.h>
 
 /**
  * \ingroup group_mars_context
@@ -54,18 +53,7 @@
  * An instance of this structure must be created and initialized before
  * using any of the MARS API.
  */
-struct mars_context {
-	/* parameters for the MARS kernel */
-	struct mars_kernel_params *kernel_params;
-	/* process queue where process requests are added */
-	struct mars_workload_queue *workload_queue;
-	/* array of mpu context threads */
-	pthread_t *mpu_context_threads;
-	/* num of mpu context threads */
-	uint32_t mpu_context_count;
-	/* reference count */
-	uint32_t reference_count;
-};
+struct mars_context;
 
 #if defined(__cplusplus)
 extern "C" {
--- a/core/include/host/mars/task.h
+++ b/core/include/host/mars/task.h
@@ -44,6 +44,7 @@
  * \brief <b>[host]</b> MARS Task API
  */
 
+#include <stdint.h>
 #include <mars/task_barrier.h>
 #include <mars/task_event_flag.h>
 #include <mars/task_queue.h>
--- a/core/include/host/mars/task_barrier.h
+++ b/core/include/host/mars/task_barrier.h
@@ -44,6 +44,7 @@
  * \brief <b>[host]</b> MARS Task Barrier API
  */
 
+#include <stdint.h>
 #include <mars/task_barrier_types.h>
 
 struct mars_context;
--- a/core/include/host/mars/task_event_flag.h
+++ b/core/include/host/mars/task_event_flag.h
@@ -44,6 +44,7 @@
  * \brief <b>[host]</b> MARS Task Event Flag API
  */
 
+#include <stdint.h>
 #include <mars/task_event_flag_types.h>
 
 struct mars_context;
--- a/core/include/host/mars/task_queue.h
+++ b/core/include/host/mars/task_queue.h
@@ -44,6 +44,7 @@
  * \brief <b>[host]</b> MARS Task Queue Flag API
  */
 
+#include <stdint.h>
 #include <mars/task_queue_types.h>
 
 struct mars_context;
--- a/core/include/host/mars/task_semaphore.h
+++ b/core/include/host/mars/task_semaphore.h
@@ -44,6 +44,7 @@
  * \brief <b>[host]</b> MARS Task Semaphore API
  */
 
+#include <stdint.h>
 #include <mars/task_semaphore_types.h>
 
 struct mars_context;
--- a/core/include/mpu/mars/mutex.h
+++ b/core/include/mpu/mars/mutex.h
@@ -44,6 +44,7 @@
  * \brief <b>[MPU]</b> MARS Mutex API
  */
 
+#include <stdint.h>
 #include <mars/mutex_types.h>
 
 #if defined(__cplusplus)
--- a/core/include/mpu/mars/task.h
+++ b/core/include/mpu/mars/task.h
@@ -44,6 +44,7 @@
  * \brief <b>[MPU]</b> MARS Task API
  */
 
+#include <stdint.h>
 #include <mars/task_barrier.h>
 #include <mars/task_event_flag.h>
 #include <mars/task_queue.h>
--- a/core/include/mpu/mars/task_barrier.h
+++ b/core/include/mpu/mars/task_barrier.h
@@ -44,6 +44,7 @@
  * \brief <b>[MPU]</b> MARS Task Barrier API
  */
 
+#include <stdint.h>
 #include <mars/task_barrier_types.h>
 
 #if defined(__cplusplus)
--- a/core/include/mpu/mars/task_event_flag.h
+++ b/core/include/mpu/mars/task_event_flag.h
@@ -44,6 +44,7 @@
  * \brief <b>[MPU]</b> MARS Task Event Flag API
  */
 
+#include <stdint.h>
 #include <mars/task_event_flag_types.h>
 
 #if defined(__cplusplus)
--- a/core/include/mpu/mars/task_queue.h
+++ b/core/include/mpu/mars/task_queue.h
@@ -44,6 +44,7 @@
  * \brief <b>[MPU]</b> MARS Task Queue API
  */
 
+#include <stdint.h>
 #include <mars/task_queue_types.h>
 
 #if defined(__cplusplus)
--- a/core/include/mpu/mars/task_semaphore.h
+++ b/core/include/mpu/mars/task_semaphore.h
@@ -44,6 +44,7 @@
  * \brief <b>[MPU]</b> MARS Task Semaphore API
  */
 
+#include <stdint.h>
 #include <mars/task_semaphore_types.h>
 
 #if defined(__cplusplus)
--- /dev/null
+++ b/core/src/common/kernel_internal_types.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_KERNEL_INTERNAL_TYPES_H
+#define MARS_KERNEL_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_KERNEL_PARAMS_ALIGN	128
+
+/* mars kernel parameters */
+struct mars_kernel_params {
+	uint32_t id;
+	uint64_t mars_context_ea;
+	uint64_t workload_queue_ea;
+} __attribute__((aligned(MARS_KERNEL_PARAMS_ALIGN)));
+
+#endif
--- /dev/null
+++ b/core/src/common/mutex_internal_types.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_MUTEX_INTERNAL_TYPES_H
+#define MARS_MUTEX_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_MUTEX_SIZE				128
+#define MARS_MUTEX_ALIGN			128
+#define MARS_MUTEX_ALIGN_MASK			0x7f
+#define MARS_MUTEX_LOCKED			0x1
+#define MARS_MUTEX_UNLOCKED			0x0
+
+struct mars_mutex {
+	uint32_t lock;
+	uint8_t pad[124];
+} __attribute__((aligned(MARS_MUTEX_ALIGN)));
+
+#endif
--- /dev/null
+++ b/core/src/common/task_barrier_internal_types.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_TASK_BARRIER_INTERNAL_TYPES_H
+#define MARS_TASK_BARRIER_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_TASK_BARRIER_SIZE			128
+#define MARS_TASK_BARRIER_ALIGN			128
+#define MARS_TASK_BARRIER_ALIGN_MASK		0x7f
+
+struct mars_task_barrier {
+	uint32_t lock;
+	uint32_t total;
+	uint32_t notified_count;
+	uint32_t waited_count;
+	uint16_t notify_wait_count;
+	uint16_t notify_wait_id[MARS_TASK_BARRIER_WAIT_MAX];
+	uint16_t wait_count;
+	uint16_t wait_id[MARS_TASK_BARRIER_WAIT_MAX];
+	uint64_t mars_context_ea;
+} __attribute__((aligned(MARS_TASK_BARRIER_ALIGN)));
+
+#endif
--- /dev/null
+++ b/core/src/common/task_event_flag_internal_types.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_TASK_EVENT_FLAG_INTERNAL_TYPES_H
+#define MARS_TASK_EVENT_FLAG_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_TASK_EVENT_FLAG_SIZE		128
+#define MARS_TASK_EVENT_FLAG_ALIGN		128
+#define MARS_TASK_EVENT_FLAG_ALIGN_MASK		0x7f
+
+struct mars_task_event_flag {
+	uint32_t lock;
+	uint32_t bits;
+	uint8_t direction;
+	uint8_t clear_mode;
+	uint16_t wait_count;
+	uint16_t wait_id[MARS_TASK_EVENT_FLAG_WAIT_MAX + 1];
+	uint32_t wait_mask[MARS_TASK_EVENT_FLAG_WAIT_MAX];
+	uint8_t wait_mask_mode[MARS_TASK_EVENT_FLAG_WAIT_MAX + 1];
+	uint64_t mars_context_ea;
+} __attribute__((aligned(MARS_TASK_EVENT_FLAG_ALIGN)));
+
+#endif
--- /dev/null
+++ b/core/src/common/task_internal_types.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_TASK_INTERNAL_TYPES_H
+#define MARS_TASK_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_TASK_CONTEXT_SIZE				128
+#define MARS_TASK_CONTEXT_ALIGN				16
+#define MARS_TASK_CONTEXT_SAVE_ALIGN			128
+#define MARS_TASK_CONTEXT_SAVE_UNIT_SIZE		8
+#define MARS_TASK_CONTEXT_SAVE_UNIT_ALIGN		128
+#define MARS_TASK_CONTEXT_SAVE_UNIT_ADDR_ALIGN_MASK	0xf
+#define MARS_TASK_CONTEXT_SAVE_UNIT_SIZE_ALIGN_MASK	0xf
+
+struct mars_task_context {
+	struct mars_task_id id;		/* task id */
+	struct mars_task_args args;	/* task args */
+	uint64_t exec_ea;		/* ea of exec */
+	uint32_t exec_size;		/* size of text and data of exec */
+	uint32_t bss_size;		/* size of bss in memory of exec */
+	uint32_t vaddr;			/* vaddr address of exec */
+	uint32_t entry;			/* entry address of exec */
+	uint32_t stack;			/* stack pointer of exec */
+	int32_t exit_code;		/* exit code */
+	uint64_t context_save_area_ea;	/* ea of context save area */
+	uint64_t context_save_unit_ea;	/* ea of context save unit list */
+	uint8_t pad[16];		/* padding */
+} __attribute__((aligned(MARS_TASK_CONTEXT_ALIGN)));
+
+#endif
--- /dev/null
+++ b/core/src/common/task_queue_internal_types.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_TASK_QUEUE_INTERNAL_TYPES_H
+#define MARS_TASK_QUEUE_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_TASK_QUEUE_SIZE			128
+#define MARS_TASK_QUEUE_ALIGN			128
+#define MARS_TASK_QUEUE_ALIGN_MASK		0x7f
+#define MARS_TASK_QUEUE_ENTRY_SIZE_MASK		0xf
+#define MARS_TASK_QUEUE_ENTRY_ALIGN		16
+#define MARS_TASK_QUEUE_ENTRY_ALIGN_MASK	0xf
+#define MARS_TASK_QUEUE_BUFFER_ALIGN		16
+#define MARS_TASK_QUEUE_BUFFER_ALIGN_MASK	0xf
+
+struct mars_task_queue {
+	uint32_t lock;
+	uint32_t size;
+	uint32_t depth;
+	uint32_t count;
+	uint64_t buffer_ea;
+	uint64_t push_ea;
+	uint64_t pop_ea;
+	uint8_t direction;
+	uint8_t pad[3];
+	uint16_t push_wait_count;
+	uint16_t pop_wait_count;
+	uint16_t push_wait_id[MARS_TASK_QUEUE_WAIT_MAX];
+	uint16_t pop_wait_id[MARS_TASK_QUEUE_WAIT_MAX];
+	uint64_t mars_context_ea;
+} __attribute__((aligned(MARS_TASK_QUEUE_ALIGN)));
+
+#endif
--- /dev/null
+++ b/core/src/common/task_semaphore_internal_types.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_TASK_SEMAPHORE_INTERNAL_TYPES_H
+#define MARS_TASK_SEMAPHORE_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_TASK_SEMAPHORE_SIZE		128
+#define MARS_TASK_SEMAPHORE_ALIGN		128
+#define MARS_TASK_SEMAPHORE_ALIGN_MASK		0x7f
+
+struct mars_task_semaphore {
+	uint32_t lock;
+	int32_t count;
+	uint16_t wait_count;
+	uint16_t wait_id[MARS_TASK_SEMAPHORE_WAIT_MAX];
+	uint64_t mars_context_ea;
+} __attribute__((aligned(MARS_TASK_SEMAPHORE_ALIGN)));
+
+#endif
--- /dev/null
+++ b/core/src/common/workload_internal_types.h
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_WORKLOAD_INTERNAL_TYPES_H
+#define MARS_WORKLOAD_INTERNAL_TYPES_H
+
+#include <stdint.h>
+
+#define MARS_WORKLOAD_ID_NONE			0xffff	/* workload id none */
+
+#define MARS_WORKLOAD_TYPE_NONE			0x00	/* workload undefined */
+#define MARS_WORKLOAD_TYPE_TASK			0x01	/* workload type */
+
+#define MARS_WORKLOAD_STATE_NONE		0x00	/* workload undefined */
+#define MARS_WORKLOAD_STATE_ADDING		0x01	/* adding now */
+#define MARS_WORKLOAD_STATE_REMOVING		0x02	/* removing now */
+#define MARS_WORKLOAD_STATE_SCHEDULING		0x03	/* scheduling now */
+#define MARS_WORKLOAD_STATE_READY		0x04	/* ready to schedule */
+#define MARS_WORKLOAD_STATE_WAITING		0x05	/* waiting for sync */
+#define MARS_WORKLOAD_STATE_RUNNING		0x06	/* currently running */
+#define MARS_WORKLOAD_STATE_FINISHED		0x07	/* not allow schedule */
+
+#define MARS_WORKLOAD_PRIORITY_MIN		0x00	/* minimum priority */
+#define MARS_WORKLOAD_PRIORITY_MAX		0xff	/* maximum priority */
+
+#define MARS_WORKLOAD_COUNTER_MIN		0x0000	/* minimum counter */
+#define MARS_WORKLOAD_COUNTER_MAX		0xffff	/* maximum counter */
+
+#define MARS_WORKLOAD_SIGNAL_OFF		0x0	/* signal set off */
+#define MARS_WORKLOAD_SIGNAL_ON			0x1	/* signal set on */
+
+#define MARS_WORKLOAD_PER_BLOCK			15	/* wl/block */
+#define MARS_WORKLOAD_NUM_BLOCKS		100	/* total blocks */
+#define MARS_WORKLOAD_MAX			1500	/* blocks * wl/block */
+
+#define MARS_WORKLOAD_CONTEXT_SIZE		128	/* size of 128 bytes */
+#define MARS_WORKLOAD_CONTEXT_ALIGN		128	/* align to 128 bytes */
+
+#define MARS_WORKLOAD_QUEUE_ALIGN		128	/* align to 128 bytes */
+#define MARS_WORKLOAD_QUEUE_HEADER_ALIGN	128	/* align to 128 bytes */
+#define MARS_WORKLOAD_QUEUE_BLOCK_ALIGN		128	/* align to 128 bytes */
+
+#define MARS_WORKLOAD_QUEUE_FLAG_NONE		0x0	/* no flag set */
+#define MARS_WORKLOAD_QUEUE_FLAG_EXIT		0x1	/* exit flag */
+
+/*
+ * MARS workload queue block bits
+ * ----------------------------------------------------------------------------
+ * |[63...60]|[59...56]|[55....48]|[  47  ]|[46....32]|[31.....16]|[15......0]|
+ * ----------------------------------------------------------------------------
+ * |  4-bits |  4-bits |  8-bits  |  1-bit |  15-bits |  16-bits  |  16-bits  |
+ * ----------------------------------------------------------------------------
+ * |   TYPE  |  STATE  | PRIORITY | SIGNAL | RESERVED |  WAIT_ID  |  COUNTER  |
+ * ----------------------------------------------------------------------------
+ */
+#define MARS_BITS_SIZE				64
+
+#define MARS_BITS_SHIFT_TYPE			60
+#define MARS_BITS_SHIFT_STATE			56
+#define MARS_BITS_SHIFT_PRIORITY		48
+#define MARS_BITS_SHIFT_SIGNAL			47
+#define MARS_BITS_SHIFT_WAIT_ID			16
+#define MARS_BITS_SHIFT_COUNTER			0
+
+#define MARS_BITS_MASK_TYPE			0xf000000000000000ULL
+#define MARS_BITS_MASK_STATE			0x0f00000000000000ULL
+#define MARS_BITS_MASK_PRIORITY			0x00ff000000000000ULL
+#define MARS_BITS_MASK_SIGNAL			0x0000800000000000ULL
+#define MARS_BITS_MASK_WAIT_ID			0x00000000ffff0000ULL
+#define MARS_BITS_MASK_COUNTER			0x000000000000ffffULL
+
+#define MARS_BITS_GET(bits, name)  \
+	((*(bits) & MARS_BITS_MASK_##name) >> MARS_BITS_SHIFT_##name)
+
+#define MARS_BITS_SET(bits, name, val) \
+	(*bits) = ((*(bits) & ~MARS_BITS_MASK_##name) | \
+		((uint64_t)(val) << MARS_BITS_SHIFT_##name))
+
+/* mars workload context */
+struct mars_workload_context {
+	uint8_t context[MARS_WORKLOAD_CONTEXT_SIZE];
+} __attribute__((aligned(MARS_WORKLOAD_CONTEXT_ALIGN)));
+
+/* 128 byte workload queue header structure */
+struct mars_workload_queue_header {
+	uint64_t queue_ea;
+	uint64_t context_ea;
+	uint8_t flag;
+} __attribute__((aligned(MARS_WORKLOAD_QUEUE_HEADER_ALIGN)));
+
+/* 128 byte workload queue block structure */
+struct mars_workload_queue_block {
+	uint32_t lock;
+	uint32_t pad;
+	uint64_t bits[MARS_WORKLOAD_PER_BLOCK];
+} __attribute__((aligned(MARS_WORKLOAD_QUEUE_BLOCK_ALIGN)));
+
+/* mars workload queue structure */
+struct mars_workload_queue {
+	struct mars_workload_queue_header header;
+	struct mars_workload_queue_block block[MARS_WORKLOAD_NUM_BLOCKS];
+	struct mars_workload_context context[MARS_WORKLOAD_MAX];
+} __attribute__((aligned(MARS_WORKLOAD_QUEUE_ALIGN)));
+
+#endif
--- a/core/src/host/lib/Makefile.am
+++ b/core/src/host/lib/Makefile.am
@@ -78,8 +78,7 @@ AM_CPPFLAGS = \
 	$(extra_cppflags) \
 	-I$(srcdir)/../../../include/host \
 	-I$(srcdir)/../../../include/common \
-	-I$(srcdir)/../../../src/mpu/kernel \
-	-I$(srcdir)/../../../src/mpu/lib
+	-I$(srcdir)/../../../src/common
 
 AM_CFLAGS = \
 	$(extra_cflags) \
@@ -98,7 +97,9 @@ AM_LDFLAGS = \
 lib_LTLIBRARIES = libmars.la
 
 libmars_la_SOURCES = \
+	$(srcdir)/../../../src/common/*.h \
 	context.c \
+	context_internal_types.h \
 	mutex.c \
 	task.c \
 	task_barrier.c \
--- a/core/src/host/lib/context.c
+++ b/core/src/host/lib/context.c
@@ -43,8 +43,9 @@
 #include "mars/context.h"
 #include "mars/error.h"
 
+#include "context_internal_types.h"
+#include "kernel_internal_types.h"
 #include "workload_queue.h"
-#include "kernel_types.h"
 
 extern struct spe_program_handle mars_kernel_entry;
 static struct mars_context *mars_shared_context;
--- /dev/null
+++ b/core/src/host/lib/context_internal_types.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2008 Sony Corporation of America
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this Library and associated documentation files (the
+ * "Library"), to deal in the Library without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Library, and to
+ * permit persons to whom the Library is furnished to do so, subject to
+ * the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Library.
+ *
+ *  If you modify the Library, you may copy and distribute your modified
+ *  version of the Library in object code or as an executable provided
+ *  that you also do one of the following:
+ *
+ *   Accompany the modified version of the Library with the complete
+ *   corresponding machine-readable source code for the modified version
+ *   of the Library; or,
+ *
+ *   Accompany the modified version of the Library with a written offer
+ *   for a complete machine-readable copy of the corresponding source
+ *   code of the modified version of the Library.
+ *
+ *
+ * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
+ */
+
+#ifndef MARS_CONTEXT_INTERNAL_TYPES_H
+#define MARS_CONTEXT_INTERNAL_TYPES_H
+
+#include <stdint.h>
+#include <pthread.h>
+
+struct mars_context {
+	/* parameters for the MARS kernel */
+	struct mars_kernel_params *kernel_params;
+	/* process queue where process requests are added */
+	struct mars_workload_queue *workload_queue;
+	/* array of mpu context threads */
+	pthread_t *mpu_context_threads;
+	/* num of mpu context threads */
+	uint32_t mpu_context_count;
+	/* reference count */
+	uint32_t reference_count;
+};
+
+#endif
--- a/core/src/host/lib/mutex.c
+++ b/core/src/host/lib/mutex.c
@@ -41,6 +41,8 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "mutex_internal_types.h"
+
 int mars_mutex_create(struct mars_mutex **mutex_ret)
 {
 	struct mars_mutex *mutex;
--- a/core/src/host/lib/task.c
+++ b/core/src/host/lib/task.c
@@ -43,6 +43,8 @@
 #include "mars/context.h"
 #include "mars/error.h"
 
+#include "task_internal_types.h"
+#include "context_internal_types.h"
 #include "workload_queue.h"
 
 const struct mars_task_context_save_unit mars_task_context_save_all[] =
--- a/core/src/host/lib/task_barrier.c
+++ b/core/src/host/lib/task_barrier.c
@@ -42,6 +42,10 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "task_barrier_internal_types.h"
+#include "context_internal_types.h"
+#include "mutex_internal_types.h"
+
 int mars_task_barrier_create(struct mars_context *mars,
 				struct mars_task_barrier **barrier_ret,
 				uint32_t total)
--- a/core/src/host/lib/task_event_flag.c
+++ b/core/src/host/lib/task_event_flag.c
@@ -44,6 +44,9 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "task_event_flag_internal_types.h"
+#include "context_internal_types.h"
+#include "mutex_internal_types.h"
 #include "workload_queue.h"
 
 int mars_task_event_flag_create(struct mars_context *mars,
--- a/core/src/host/lib/task_queue.c
+++ b/core/src/host/lib/task_queue.c
@@ -44,6 +44,9 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "task_queue_internal_types.h"
+#include "context_internal_types.h"
+#include "mutex_internal_types.h"
 #include "workload_queue.h"
 
 int mars_task_queue_create(struct mars_context *mars,
--- a/core/src/host/lib/task_semaphore.c
+++ b/core/src/host/lib/task_semaphore.c
@@ -43,6 +43,10 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "task_semaphore_internal_types.h"
+#include "context_internal_types.h"
+#include "mutex_internal_types.h"
+
 int mars_task_semaphore_create(struct mars_context *mars,
 				struct mars_task_semaphore **semaphore_ret,
 				int32_t count)
--- a/core/src/host/lib/task_signal.c
+++ b/core/src/host/lib/task_signal.c
@@ -39,6 +39,7 @@
 #include "mars/context.h"
 #include "mars/error.h"
 
+#include "context_internal_types.h"
 #include "workload_queue.h"
 
 int mars_task_signal_send(struct mars_task_id *id)
--- a/core/src/host/lib/workload_queue.c
+++ b/core/src/host/lib/workload_queue.c
@@ -44,8 +44,9 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "mutex_internal_types.h"
+#include "kernel_internal_types.h"
 #include "workload_queue.h"
-#include "kernel_types.h"
 
 int mars_workload_queue_create(struct mars_workload_queue **queue_ret)
 {
--- a/core/src/host/lib/workload_queue.h
+++ b/core/src/host/lib/workload_queue.h
@@ -38,7 +38,7 @@
 #ifndef MARS_WORKLOAD_QUEUE_H
 #define MARS_WORKLOAD_QUEUE_H
 
-#include "workload_types.h"
+#include "workload_internal_types.h"
 
 #if defined(__cplusplus)
 extern "C" {
--- a/core/src/mpu/kernel/Makefile.am
+++ b/core/src/mpu/kernel/Makefile.am
@@ -63,6 +63,7 @@ AM_CPPFLAGS = \
 	$(extra_cppflags) \
 	-I$(srcdir)/../../../include/mpu \
 	-I$(srcdir)/../../../include/common \
+	-I$(srcdir)/../../../src/common \
 	-I$(srcdir)/../../../src/mpu/lib
 
 AM_CCASFLAGS = \
@@ -91,13 +92,13 @@ noinst_PROGRAMS = mars_kernel
 mars_kernel_LDADD = $(builddir)/../lib/libmars.a
 
 mars_kernel_SOURCES = \
+	$(srcdir)/../../../src/common/*.h \
 	kernel.c \
 	kernel.h \
 	kernel_registers.c \
 	kernel_scheduler.c \
 	kernel_syscalls.c \
 	kernel_task.c \
-	kernel_types.h \
 	kernel_workload.c
 
 CLEANFILES = *.map
--- a/core/src/mpu/kernel/kernel.h
+++ b/core/src/mpu/kernel/kernel.h
@@ -45,8 +45,10 @@
 #include "mars/error.h"
 #include "mars/task_types.h"
 
-#include "kernel_types.h"
-#include "workload_types.h"
+#include "kernel_internal_types.h"
+#include "mutex_internal_types.h"
+#include "workload_internal_types.h"
+#include "task_internal_types.h"
 #include "syscalls.h"
 #include "dma.h"
 
--- a/core/src/mpu/lib/Makefile.am
+++ b/core/src/mpu/lib/Makefile.am
@@ -74,7 +74,8 @@ pkginclude_HEADERS = \
 AM_CPPFLAGS = \
 	$(extra_cppflags) \
 	-I$(srcdir)/../../../include/mpu \
-	-I$(srcdir)/../../../include/common
+	-I$(srcdir)/../../../include/common \
+	-I$(srcdir)/../../../src/common
 
 AM_CFLAGS = \
 	-W \
@@ -89,6 +90,7 @@ AM_CFLAGS = \
 lib_LIBRARIES = libmars.a
 
 libmars_a_SOURCES = \
+	$(srcdir)/../../../src/common/*.h \
 	dma.h \
 	entry.S \
 	mutex.c \
@@ -99,5 +101,4 @@ libmars_a_SOURCES = \
 	task_event_flag.c \
 	task_queue.c \
 	task_semaphore.c \
-	task_signal.c \
-	workload_types.h
+	task_signal.c
--- a/core/src/mpu/lib/mutex.c
+++ b/core/src/mpu/lib/mutex.c
@@ -40,6 +40,7 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "mutex_internal_types.h"
 #include "dma.h"
 
 static struct mars_mutex mutex;
--- a/core/src/mpu/lib/task.c
+++ b/core/src/mpu/lib/task.c
@@ -41,6 +41,7 @@
 #include "mars/task_types.h"
 #include "mars/error.h"
 
+#include "task_internal_types.h"
 #include "syscalls.h"
 
 void mars_task_exit(int32_t exit_code)
--- a/core/src/mpu/lib/task_barrier.c
+++ b/core/src/mpu/lib/task_barrier.c
@@ -40,6 +40,9 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "task_barrier_internal_types.h"
+#include "task_internal_types.h"
+#include "mutex_internal_types.h"
 #include "syscalls.h"
 
 static struct mars_task_barrier barrier;
--- a/core/src/mpu/lib/task_event_flag.c
+++ b/core/src/mpu/lib/task_event_flag.c
@@ -42,6 +42,9 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "task_event_flag_internal_types.h"
+#include "task_internal_types.h"
+#include "mutex_internal_types.h"
 #include "syscalls.h"
 
 static struct mars_task_event_flag event_flag;
--- a/core/src/mpu/lib/task_queue.c
+++ b/core/src/mpu/lib/task_queue.c
@@ -42,8 +42,11 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
-#include "dma.h"
+#include "task_queue_internal_types.h"
+#include "task_internal_types.h"
+#include "mutex_internal_types.h"
 #include "syscalls.h"
+#include "dma.h"
 
 static struct mars_task_queue queue;
 
--- a/core/src/mpu/lib/task_semaphore.c
+++ b/core/src/mpu/lib/task_semaphore.c
@@ -43,6 +43,9 @@
 #include "mars/mutex.h"
 #include "mars/error.h"
 
+#include "task_semaphore_internal_types.h"
+#include "task_internal_types.h"
+#include "mutex_internal_types.h"
 #include "syscalls.h"
 
 static struct mars_task_semaphore semaphore;
--- a/core/src/mpu/lib/task_signal.c
+++ b/core/src/mpu/lib/task_signal.c
@@ -39,6 +39,7 @@
 #include "mars/task_types.h"
 #include "mars/error.h"
 
+#include "task_internal_types.h"
 #include "syscalls.h"
 
 int mars_task_signal_send(struct mars_task_id *id)






More information about the cbe-oss-dev mailing list