[Cbe-oss-dev] [PATCH 08/10]MARS/modules: Task add source files

Yuji Mano yuji.mano at am.sony.com
Fri Nov 21 11:06:54 EST 2008


This re-adds all the task sources previously inside the core library into the
task module library.

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

---
 modules/task/include/common/mars/task_barrier_types.h    |   62 +
 modules/task/include/common/mars/task_event_flag_types.h |  104 ++
 modules/task/include/common/mars/task_queue_types.h      |   86 ++
 modules/task/include/common/mars/task_semaphore_types.h  |   62 +
 modules/task/include/common/mars/task_types.h            |  137 +++
 modules/task/include/host/mars/task.h                    |  175 ++++
 modules/task/include/host/mars/task_barrier.h            |  103 ++
 modules/task/include/host/mars/task_event_flag.h         |  249 ++++++
 modules/task/include/host/mars/task_queue.h              |  314 ++++++++
 modules/task/include/host/mars/task_semaphore.h          |  102 ++
 modules/task/include/host/mars/task_signal.h             |   62 +
 modules/task/include/mpu/mars/task.h                     |  261 ++++++
 modules/task/include/mpu/mars/task_barrier.h             |  159 ++++
 modules/task/include/mpu/mars/task_event_flag.h          |  198 +++++
 modules/task/include/mpu/mars/task_queue.h               |  585 +++++++++++++++
 modules/task/include/mpu/mars/task_semaphore.h           |  100 ++
 modules/task/include/mpu/mars/task_signal.h              |  114 ++
 modules/task/src/common/task_barrier_internal_types.h    |   59 +
 modules/task/src/common/task_event_flag_internal_types.h |   59 +
 modules/task/src/common/task_internal_types.h            |   66 +
 modules/task/src/common/task_queue_internal_types.h      |   69 +
 modules/task/src/common/task_semaphore_internal_types.h  |   55 +
 modules/task/src/host/lib/task.c                         |  329 ++++++++
 modules/task/src/host/lib/task_barrier.c                 |   92 ++
 modules/task/src/host/lib/task_event_flag.c              |  258 ++++++
 modules/task/src/host/lib/task_queue.c                   |  325 ++++++++
 modules/task/src/host/lib/task_semaphore.c               |   89 ++
 modules/task/src/host/lib/task_signal.c                  |   65 +
 modules/task/src/mpu/lib/task.c                          |  167 ++++
 modules/task/src/mpu/lib/task_barrier.c                  |  202 +++++
 modules/task/src/mpu/lib/task_event_flag.c               |  236 ++++++
 modules/task/src/mpu/lib/task_queue.c                    |  427 ++++++++++
 modules/task/src/mpu/lib/task_semaphore.c                |  133 +++
 modules/task/src/mpu/lib/task_signal.c                   |   73 +
 34 files changed, 5577 insertions(+)

--- /dev/null
+++ b/modules/task/include/common/mars/task_barrier_types.h
@@ -0,0 +1,62 @@
+/*
+ * 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_TYPES_H
+#define MARS_TASK_BARRIER_TYPES_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_barrier
+ * \brief MARS Task Barrier Types
+ */
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief Maximum tasks allowed for single barrier
+ */
+#define MARS_TASK_BARRIER_WAIT_MAX		25
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief MARS task barrier structure
+ *
+ * An instance of this structure must be created when using any of the
+ * MARS task barrier API.
+ */
+struct mars_task_barrier;
+
+#endif
--- /dev/null
+++ b/modules/task/include/common/mars/task_event_flag_types.h
@@ -0,0 +1,104 @@
+/*
+ * 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_TYPES_H
+#define MARS_TASK_EVENT_FLAG_TYPES_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_event_flag
+ * \brief MARS Task Event Flag Types
+ */
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Event flag direction from PPU to SPU
+ */
+#define MARS_TASK_EVENT_FLAG_HOST_TO_MPU	0x10
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Event flag direction from SPU to PPU
+ */
+#define MARS_TASK_EVENT_FLAG_MPU_TO_HOST	0x11
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Event flag direction from SPU to SPU
+ */
+#define MARS_TASK_EVENT_FLAG_MPU_TO_MPU		0x12
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Event flag clear mode automatic
+ */
+#define MARS_TASK_EVENT_FLAG_CLEAR_AUTO		0x20
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Event flag clear mode manual
+ */
+#define MARS_TASK_EVENT_FLAG_CLEAR_MANUAL	0x21
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Event flag mask mode bitwise OR
+ */
+#define MARS_TASK_EVENT_FLAG_MASK_OR		0x30
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Event flag mask mode bitwise AND
+ */
+#define MARS_TASK_EVENT_FLAG_MASK_AND		0x31
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief Maximum tasks allowed to wait on a single event flag
+ */
+#define MARS_TASK_EVENT_FLAG_WAIT_MAX		15
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief MARS task event flag structure
+ *
+ * An instance of this structure must be created when using any of the
+ * MARS event flag API.
+ */
+struct mars_task_event_flag;
+
+#endif
--- /dev/null
+++ b/modules/task/include/common/mars/task_queue_types.h
@@ -0,0 +1,86 @@
+/*
+ * 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_TYPES_H
+#define MARS_TASK_QUEUE_TYPES_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_queue
+ * \brief MARS Task Queue Types
+ */
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief Queue direction from PPU to SPU
+ */
+#define MARS_TASK_QUEUE_HOST_TO_MPU		0x10
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief Queue direction from SPU to PPU
+ */
+#define MARS_TASK_QUEUE_MPU_TO_HOST		0x11
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief Queue direction from SPU to SPU
+ */
+#define MARS_TASK_QUEUE_MPU_TO_MPU		0x12
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief Maximum tasks allowed to wait on a queue
+ */
+#define MARS_TASK_QUEUE_WAIT_MAX		18
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief Maximum size allowed for queue entry
+ */
+#define MARS_TASK_QUEUE_ENTRY_SIZE_MAX		16384
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief MARS task queue structure
+ *
+ * An instance of this structure must be created when using any of the
+ * MARS queue API.
+ */
+struct mars_task_queue;
+
+#endif
--- /dev/null
+++ b/modules/task/include/common/mars/task_semaphore_types.h
@@ -0,0 +1,62 @@
+/*
+ * 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_TYPES_H
+#define MARS_TASK_SEMAPHORE_TYPES_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_semaphore
+ * \brief MARS Task Semaphore Types
+ */
+
+/**
+ * \ingroup group_mars_task_semaphore
+ * \brief Maximum task accesses allowed for single semaphore
+ */
+#define MARS_TASK_SEMAPHORE_WAIT_MAX		55
+
+/**
+ * \ingroup group_mars_task_semaphore
+ * \brief MARS task semaphore structure
+ *
+ * An instance of this structure must be created when using any of the
+ * MARS semaphore API.
+ */
+struct mars_task_semaphore;
+
+#endif
--- /dev/null
+++ b/modules/task/include/common/mars/task_types.h
@@ -0,0 +1,137 @@
+/*
+ * 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_TYPES_H
+#define MARS_TASK_TYPES_H
+
+/**
+ * \file
+ * \ingroup group_mars_task
+ * \brief MARS Task Types
+ */
+
+#include <stdint.h>
+
+/**
+ * \ingroup group_mars_task
+ * \brief Base address of task elf
+ */
+#define MARS_TASK_BASE_ADDR			0x10000
+
+/**
+ * \ingroup group_mars_task
+ * \brief Max size of context save area
+ */
+#define MARS_TASK_CONTEXT_SAVE_SIZE_MAX		0x30000
+
+/**
+ * \ingroup group_mars_task
+ * \brief Max number of context save units
+ */
+#define MARS_TASK_CONTEXT_SAVE_UNIT_MAX		16
+
+/**
+ * \ingroup group_mars_task
+ * \brief Parameter for full context switch
+ */
+#define MARS_TASK_CONTEXT_SAVE_ALL		mars_task_context_save_all
+
+/**
+ * \ingroup group_mars_task
+ * \brief Max length of task name
+ */
+#define MARS_TASK_NAME_LEN_MAX			21
+
+/**
+ * \ingroup group_mars_task
+ * \brief MARS task id structure
+ *
+ * This structure is initialized during MARS task creation and returned when
+ * calling \ref mars_task_create.
+ *
+ * An instance of this structure must be kept until the task is destroyed by
+ * calling \ref mars_task_destroy.
+ */
+struct mars_task_id {
+	uint64_t mars_context_ea;
+	uint16_t workload_id;
+	uint8_t name[MARS_TASK_NAME_LEN_MAX + 1];
+};
+
+/**
+ * \ingroup group_mars_task
+ * \brief MARS task argument structure
+ *
+ * This structure is initialized by the user and passed into
+ * \ref mars_task_schedule for MARS task scheduling.
+ *
+ * This argument structure is directly passed into the MARS
+ * task's \ref mars_task_main function at task execution.
+ */
+struct mars_task_args {
+	union {
+		/** array of 32 8-bit unsigned ints */
+		uint8_t  u8[32];
+		/** array of 16 16-bit unsigned ints */
+		uint16_t u16[16];
+		/** array of 8 32-bit unsigned ints */
+		uint32_t u32[8];
+		/** array of 4 64-bit unsigned ints */
+		uint64_t u64[4];
+	} type;
+};
+
+/**
+ * \ingroup group_mars_task
+ * \brief MARS task context save unit structure
+ *
+ * This structure is initialized by the user and passed into
+ * \ref mars_task_create for MARS task creation.
+ *
+ * A list of this structure determines what areas of MPU storage
+ * to save and restore during a task context switch.
+ */
+struct mars_task_context_save_unit {
+	/** address relative to the base address of task */
+	uint32_t addr;
+	/** size of context save unit */
+	uint32_t size;
+};
+
+extern const struct mars_task_context_save_unit mars_task_context_save_all[];
+
+#endif
--- /dev/null
+++ b/modules/task/include/host/mars/task.h
@@ -0,0 +1,175 @@
+/*
+ * 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_H
+#define MARS_TASK_H
+
+/**
+ * \file
+ * \ingroup group_mars_task
+ * \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>
+#include <mars/task_semaphore.h>
+#include <mars/task_signal.h>
+#include <mars/task_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[host]</b> Creates a MARS task.
+ *
+ * This function creates a single task and adds it the MARS context's
+ * workload queue.
+ * Upon success, a valid task id will be returned.
+ * You must call \ref mars_task_schedule in order for it to be scheduled for
+ * execution by the kernel.
+ * The task is in the finished state upon creation and may be destroyed by
+ * \ref mars_task_destroy without ever being scheduled for execution.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e name
+ * - The name is optional, but if specified to other than NULL its
+ * length must not exceed \ref MARS_TASK_NAME_LEN_MAX.
+ * - An empty string will be treated the same as passing NULL, and will return
+ * NULL if \ref mars_task_get_name is called on the task.
+ *
+ * \e elf_image
+ * - The address of MPU program elf image in host storage that will be to be run
+ * by this task.
+ *
+ * \e save_units
+ * - A list of structures defining the areas of MPU storage to save and restore
+ * during a task context switch.
+ * - If NULL is specified, then no context save area will be allocated for
+ * the task and therefore the task must be a run-complete task.
+ * - A run-complete task will run and occupy an MPU until it has completed
+ * running and exits.
+ * - A run-complete task cannot context switch, and therefore cannot call
+ * functions that will enter that task into a wait state.
+ * - If \ref MARS_TASK_CONTEXT_SAVE_ALL is specified, the maximum size context
+ * save area will be allocated and all of the MPU storage not occuppied
+ * by the MARS kernel will be saved and restored.
+ * This will guarantee all necessary areas of the task context will be
+ * saved and restored during a context switch.
+ * However, this also may not be the most efficient, since areas of MPU
+ * storage not needed by the task may be saved and restored.
+ * - For maximum efficiency, the user should initialize a static list of
+ * struct \ref mars_task_context_save_unit that define each memory areas
+ * to save and restore during a task context switch.
+ * - A maximum of \ref MARS_TASK_CONTEXT_SAVE_UNIT_MAX separate context save
+ * units can be specified.
+ * - If you want to specify a context save unit list of size less than
+ * \ref MARS_TASK_CONTEXT_SAVE_UNIT_MAX, you must specify a terminating unit
+ * with an address and size of 0.
+ * - Each context save unit defines an address offset from the task program's
+ * base address (\ref MARS_TASK_BASE_ADDR) and the size of the unit.
+ * - The address must be aligned to a 16-byte address and the size must be a
+ * multiple of 16 bytes. Otherwise \ref MARS_ERROR_PARAMS will be returned.
+ *
+ * \note The efficiency and validity of the specified context save unit
+ * list is left up to the responsibility of the user.
+ *
+ * \param[in] mars		- pointer to MARS context
+ * \param[out] id		- address of pointer to task id instance
+ * \param[in] name		- name of task
+ * \param[in] elf_image		- address of MPU program elf image
+ * \param[in] save_units	- pointer to list of context save units
+ * \return
+ *	MARS_SUCCESS		- successfully created MARS task
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- bad task params specified
+ * \n	MARS_ERROR_MEMORY	- not enough memory
+ * \n	MARS_ERROR_LIMIT	- task queue is currently full
+ */
+int mars_task_create(struct mars_context *mars,
+		struct mars_task_id *id,
+		const char *name,
+		const void *elf_image,
+		const struct mars_task_context_save_unit *save_units);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[host]</b> Destroys a MARS task.
+ *
+ * This function destroys a task created by \ref mars_task_create.
+ * The task will only be destroyed if the task is in the finished state.
+ * Once this function returns successfully and the task is destroyed, the task
+ * id is no longer valid.
+ * To guarantee the task has finished before calling this function, you should
+ * wait for task completion by calling \ref mars_task_wait or
+ * \ref mars_task_try_wait.
+ *
+ * \param[in] id		- pointer to task id instance
+ * \return
+ *	MARS_SUCCESS		- successfully destroyed MARS task
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- bad task id specified
+ * \n	MARS_ERROR_STATE	- task is in an invalid state
+ */
+int mars_task_destroy(struct mars_task_id *id);
+
+/**
+ * \ingroup group_mars_task
+ */
+int mars_task_schedule(struct mars_task_id *id, struct mars_task_args *args,
+			uint8_t priority);
+
+/**
+ * \ingroup group_mars_task
+ */
+int mars_task_wait(struct mars_task_id *id, int32_t *exit_code);
+
+/**
+ * \ingroup group_mars_task
+ */
+int mars_task_try_wait(struct mars_task_id *id, int32_t *exit_code);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/host/mars/task_barrier.h
@@ -0,0 +1,103 @@
+/*
+ * 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_H
+#define MARS_TASK_BARRIER_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[host]</b> MARS Task Barrier API
+ */
+
+#include <stdint.h>
+#include <mars/task_barrier_types.h>
+
+struct mars_context;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[host]</b> Creates a task barrier.
+ *
+ * This function will allocate an instance of the task barrier.
+ * The barrier allows for tasks within the barrier group to wait until all
+ * tasks arrive at some synchronization point and notify the barrier.
+ * All tasks included in the barrier group should call the notify and wait in
+ * pairs.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e total
+ * - Specify total number of tasks that will be associated with this barrier.
+ * - Total must be a value between 1 and \ref MARS_TASK_BARRIER_WAIT_MAX.
+ *
+ * \param[in] mars		- pointer to MARS context
+ * \param[out] barrier		- address of pointer to barrier instance
+ * \param[in] total		- number of notifies before barrier released
+ * \return
+ *	MARS_SUCCESS		- successfully created barrier
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- total exceeds allowed limit
+ */
+int mars_task_barrier_create(struct mars_context *mars,
+				struct mars_task_barrier **barrier,
+				uint32_t total);
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[host]</b> Destroys a task barrier.
+ *
+ * This function will free any resources allocated during creation of the task
+ * barrier.
+ *
+ * \param[in] barrier		- pointer to barrier instance
+ * \return
+ *	MARS_SUCCESS		- successfully destroyed barrier
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not properly aligned
+ */
+int mars_task_barrier_destroy(struct mars_task_barrier *barrier);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/host/mars/task_event_flag.h
@@ -0,0 +1,249 @@
+/*
+ * 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_H
+#define MARS_TASK_EVENT_FLAG_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[host]</b> MARS Task Event Flag API
+ */
+
+#include <stdint.h>
+#include <mars/task_event_flag_types.h>
+
+struct mars_context;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[host]</b> Creates a task event flag.
+ *
+ * This function will allocate an instance of the task event flag.
+ * The event flag allows for tasks to wait on specific events.
+ * The event flag should be used in pairs with calls to set an event flag and
+ * wait for an event flag.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e direction
+ * - Specify the communication direction of the event flag.
+ * - Must be one of \ref MARS_TASK_EVENT_FLAG_HOST_TO_MPU,
+ * \ref MARS_TASK_EVENT_FLAG_MPU_TO_HOST, \ref MARS_TASK_EVENT_FLAG_MPU_TO_MPU.
+ *
+ * \e clear_mode
+ * - Specify when the event flag is cleared.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_CLEAR_AUTO to have event flag bits
+ * cleared automatically when a task waiting on the event flag bits has been
+ * notified of the event.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_CLEAR_MANUAL to have the event flag bits
+ * remain set until the user manually clears them through
+ * \ref mars_task_event_flag_clear.
+ *
+ * \param[in] mars		- pointer to MARS context
+ * \param[out] event_flag	- address of pointer to event flag instance
+ * \param[in] direction		- direction of the event flag
+ * \param[in] clear_mode	- behavior of how the event flag is cleared
+ * \return
+ *	MARS_SUCCESS		- successfully created event flag
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- invalid direction or clear mode specified
+ */
+int mars_task_event_flag_create(struct mars_context *mars,
+				struct mars_task_event_flag **event_flag,
+				uint8_t direction,
+				uint8_t clear_mode);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[host]</b> Destroys a task event flag.
+ *
+ * This function will free any resources allocated during creation of the task
+ * event flag.
+ *
+ * \param[in] event_flag	- pointer to event flag instance
+ * \return
+ *	MARS_SUCCESS		- successfully destroyed event flag
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not properly aligned
+ */
+int mars_task_event_flag_destroy(struct mars_task_event_flag *event_flag);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[host]</b> Clears the bits specified in the task event flag.
+ *
+ * This function will clear all bits currently set in the event flag.
+ * Tasks waiting on some events will remain in the waiting state.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e bits
+ * - Specify only the bits you want to be cleared from the event flag bits.
+ *
+ * \param[in] event_flag	- pointer to event flag instance
+ * \param[in] bits		- bits to clear
+ * \return
+ *	MARS_SUCCESS		- successfully cleared event flag bits
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ */
+int mars_task_event_flag_clear(struct mars_task_event_flag *event_flag,
+				uint32_t bits);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[host]</b> Sets the bits specified in the task event flag.
+ *
+ * This function will set the bits specified. The bits are OR'd with bits
+ * already set in the event flag at the time of this call.
+ * If there are any tasks in the waiting state, and this call satisfies the
+ * release condition of those tasks, all those tasks will be returned to the
+ * ready state.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e bits
+ * - Specify only the bits you want to set in the event flag bits.
+ *
+ * \param[in] event_flag	- pointer to event flag instance
+ * \param[in] bits		- bits to set
+ * \return
+ *	MARS_SUCCESS		- successfully cleared event flag bits
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_event_flag_set(struct mars_task_event_flag *event_flag,
+				uint32_t bits);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[host]</b> Waits on a task event flag.
+ *
+ * This call will block until the specified event flag condition is met.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e mask
+ * - Specify only the bits you want to test against in the event flag bits set.
+ * - Whether the test condition is satisfied or not will depend on \e mask_mode.
+ *
+ * \e mask_mode
+ * - Specify how to test the mask bits against the event flag bits set.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_OR (\e mask | event flag bits), so
+ * the condition is satisfied if any bits specified in \e mask is set in the
+ * event flag bits.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_AND (\e mask & event flag bits) so
+ * the condition is satisfied if all bits specified in \e mask are set in the
+ * event flag bits.
+ *
+ * \e bits
+ * - Specify a pointer to a variable where the event flag bits can be returned.
+ * - The resulting bits will be the state of bits in the event flag prior to any
+ * automatic clearing of bits (if \ref MARS_TASK_EVENT_FLAG_CLEAR_AUTO was
+ * specified at creation).
+ *
+ * \param[in] event_flag	- pointer to event flag instance
+ * \param[in] mask		- bit mask to test event flag bits against
+ * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_PARAMS	- invalid mask mode
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_event_flag_wait(struct mars_task_event_flag *event_flag,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[host]</b> Waits on a task event flag.
+ *
+ * This call will test to see if the specified event flag condition is met
+ * without blocking and returns immediately with \ref  MARS_ERROR_BUSY if it did
+ * not.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e mask
+ * - Specify only the bits you want to test against in the event flag bits set.
+ * - Whether the test condition is satisfied or not will depend on \e mask_mode.
+ *
+ * \e mask_mode
+ * - Specify how to test the mask bits against the event flag bits set.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_OR (\e mask | event flag bits), so
+ * the condition is satisfied if any bits specified in \e mask is set in the
+ * event flag bits.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_AND (\e mask & event flag bits) so
+ * the condition is satisfied if all bits specified in \e mask are set in the
+ * event flag bits.
+ *
+ * \e bits
+ * - Specify a pointer to a variable where the event flag bits can be returned.
+ * - The resulting bits will be the state of bits in the event flag prior to any
+ * automatic clearing of bits (if \ref MARS_TASK_EVENT_FLAG_CLEAR_AUTO was
+ * specified at creation).
+ *
+ * \param[in] event_flag	- pointer to event flag instance
+ * \param[in] mask		- bit mask to test event flag bits against
+ * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_PARAMS	- invalid mask_mode
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_BUSY		- event not yet received
+ */
+int mars_task_event_flag_try_wait(struct mars_task_event_flag *event_flag,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/host/mars/task_queue.h
@@ -0,0 +1,314 @@
+/*
+ * 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_H
+#define MARS_TASK_QUEUE_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> MARS Task Queue Flag API
+ */
+
+#include <stdint.h>
+#include <mars/task_queue_types.h>
+
+struct mars_context;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Creates a task queue.
+ *
+ * This function will allocate an instance of the task queue.
+ * The queue allows for tasks to wait until data is available from a FIFO
+ * data queue.
+ * The queue should be used in pairs with various calls to push and pop the
+ * the queue
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e size
+ * - Specify the size of each data item in the queue.
+ * - The size needs to be a multiple of 16 bytes and no larger than
+ * \ref MARS_TASK_QUEUE_ENTRY_SIZE_MAX.
+ *
+ * \e depth
+ * - Specify the depth of the total queue.
+ * - The number specified here is the total number of data items the queue
+ * can hold at a time.
+ * - The size of the total queue is \e size * \e depth.
+ *
+ * \e direction
+ * - Specify the communication direction of the queue.
+ * - Must be one of \ref MARS_TASK_QUEUE_HOST_TO_MPU,
+ * \ref MARS_TASK_QUEUE_MPU_TO_HOST, \ref MARS_TASK_QUEUE_MPU_TO_MPU.
+ *
+ * \param[in] mars		- pointer to MARS context
+ * \param[out] queue		- address of pointer to queue instance
+ * \param[in] size		- size of each data item in data buffer
+ * \param[in] depth		- maximum number of data entries in data buffer
+ * \param[in] direction		- direction of the event flag
+ * \return
+ *	MARS_SUCCESS		- successfully created queue
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- size is not multiple of 16 bytes or is greater
+ *				  than 16KB maximum
+ * \n	MARS_ERROR_PARAMS	- depth exceeds allowed limit
+ * \n	MARS_ERROR_PARAMS	- invalid direction specified
+ */
+int mars_task_queue_create(struct mars_context *mars,
+				struct mars_task_queue **queue,
+				uint32_t size,
+				uint32_t depth,
+				uint8_t direction);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Destroys a task queue.
+ *
+ * This function will free any resources allocated during creation of the task
+ * queue.
+ *
+ * \param[in] queue		- pointer to queue instance
+ * \return
+ *	MARS_SUCCESS		- successfully destroyed queue
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not properly aligned
+ */
+int mars_task_queue_destroy(struct mars_task_queue *queue);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Returns the number of data items in the task queue.
+ *
+ * This function will return the total number of data items in the queue at the
+ * time of the call.
+ *
+ * \param[in] queue		- pointer to queue instance
+ * \param[out] count		- pointer to variable to store return count
+ * \return
+ *	MARS_SUCCESS		- successfully returned count
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ */
+int mars_task_queue_count(struct mars_task_queue *queue, uint32_t *count);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Clears the data items in the task queue.
+ *
+ * This function will clear all data items currently in the queue.
+ * Tasks waiting to pop data from the queue will remain waiting.
+ * Tasks waiting to push data into the queue will resume.
+ *
+ * \param[in] queue		- pointer to queue instance
+ * \return
+ *	MARS_SUCCESS		- successfully cleared queue
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ */
+int mars_task_queue_clear(struct mars_task_queue *queue);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Pushes the data specified into the task queue.
+ *
+ * This function will push the data specified into the queue.
+ * The task waiting longest to pop data from the queue can resume.
+ *
+ * If the queue is full at the time of this call, this function will block until
+ * there is room in the queue to push the data.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to user data to copy into the queue.
+ * - The size of data should be equal to the size specified at queue creation.
+ *
+ * \param[in] queue		- pointer to queue instance
+ * \param[in] data		- address of data to be pushed into queue
+ * \return
+ *	MARS_SUCCESS		- successfully pushed data into queue
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_push(struct mars_task_queue *queue, const void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Pushes the data specified into the task queue.
+ *
+ * This function will push the data specified into the queue.
+ * The task waiting longest to pop data from the queue can resume.
+ *
+ * If the queue is full at the time of this call, this function will not block
+ * and returns immediately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to user data to copy into the queue.
+ * - The size of data should be equal to the size specified at queue creation.
+ *
+ * \param[in] queue		- pointer to queue instance
+ * \param[in] data		- address of data to be pushed into queue
+ * \return
+ *	MARS_SUCCESS		- successfully pushed data into queue
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is full
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_try_push(struct mars_task_queue *queue, const void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Pops data from a task queue.
+ *
+ * This function will pop data from the queue.
+ *
+ * If the queue is empty at the time of this call, this function will block
+ * until there is data to be popped from the queue.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue		- pointer to task instance
+ * \param[in] data		- address of data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_pop(struct mars_task_queue *queue, void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Pops data from a task queue.
+ *
+ * This function will pop data from the queue.
+ *
+ * If the queue is empty at the time of this call, this function will not block
+ * and returns immediately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue		- pointer to task instance
+ * \param[in] data		- address of data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is empty
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_try_pop(struct mars_task_queue *queue, void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Pops data from a task queue without removing it.
+ *
+ * This function will retrieve data from the queue without removing it from the
+ * queue.
+ *
+ * If the queue is empty at the time of this call, this function will block
+ * until there is data to be retrieved from the queue.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue		- pointer to task instance
+ * \param[in] data		- address of data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_peek(struct mars_task_queue *queue, void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[host]</b> Pops data from a task queue without removing it.
+ *
+ * This function will retrieve data from the queue.
+ *
+ * If the queue is empty at the time of this call, this function will not block
+ * and returns immediately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue		- pointer to task instance
+ * \param[in] data		- address of data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is empty
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_try_peek(struct mars_task_queue *queue, void *data);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/host/mars/task_semaphore.h
@@ -0,0 +1,102 @@
+/*
+ * 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_H
+#define MARS_TASK_SEMAPHORE_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_semaphore
+ * \brief <b>[host]</b> MARS Task Semaphore API
+ */
+
+#include <stdint.h>
+#include <mars/task_semaphore_types.h>
+
+struct mars_context;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_semaphore
+ * \brief <b>[host]</b> Creates a task semaphore.
+ *
+ * This function will allocate an instance of the task semaphore.
+ * The semaphore allows for tasks to wait until a semaphore can be obtained.
+ * The semaphore should be used in pairs with calls to acquire and release.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e count
+ * - Specify the total number of entities that can have access to the semaphore
+ * simultaneously.
+ * - Must not be greater than \ref MARS_TASK_SEMAPHORE_WAIT_MAX.
+ *
+ * \param[in] mars		- pointer to MARS context
+ * \param[out] semaphore	- address of pointer to semaphore instance
+ * \param[in] count		- initial number of task accesses allowed
+ * \return
+ *	MARS_SUCCESS		- successfully created semaphore
+ * \n	MARS_ERROR_NULL		- null pointer is specified
+ * \n	MARS_ERROR_PARAMS	- count exceeds allowed limit
+ */
+int mars_task_semaphore_create(struct mars_context *mars,
+				struct mars_task_semaphore **semaphore,
+				int32_t count);
+
+/**
+ * \ingroup group_mars_task_semaphore
+ * \brief <b>[host]</b> Destroys a task semaphore.
+ *
+ * This function will free any resources allocated during creation of the task
+ * semaphore.
+ *
+ * \param[in] semaphore		- pointer to semaphore instance
+ * \return
+ *	MARS_SUCCESS		- successfully destroyed semaphore
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_ALIGN	- instance not properly aligned
+ */
+int mars_task_semaphore_destroy(struct mars_task_semaphore *semaphore);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/host/mars/task_signal.h
@@ -0,0 +1,62 @@
+/*
+ * 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_SIGNAL_H
+#define MARS_TASK_SIGNAL_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_signal
+ * \brief <b>[host]</b> MARS Task Signal API
+ */
+
+#include <mars/task_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_signal
+ */
+int mars_task_signal_send(struct mars_task_id *id);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/mpu/mars/task.h
@@ -0,0 +1,261 @@
+/*
+ * 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_H
+#define MARS_TASK_H
+
+/**
+ * \file
+ * \ingroup group_mars_task
+ * \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>
+#include <mars/task_semaphore.h>
+#include <mars/task_signal.h>
+#include <mars/task_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[MPU]</b> Entry point for task.
+ *
+ * This function is the main entry point for the task program. All task
+ * programs will need to have a definition of this function. The arguments
+ * passed into this function are specified during task scheduling through
+ * the call to \ref mars_task_schedule.
+ *
+ * \note If NULL was specified for \e args when calling \ref mars_task_schedule,
+ * the contents of args are undefined.
+ *
+ * \param[in] args		- pointer to task args structure in MPU storage
+ * \return
+ *	user specified
+ */
+int mars_task_main(const struct mars_task_args *args);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[MPU]</b> Exits and terminates task.
+ *
+ * This function causes the task to exit and terminate execution. Calling this
+ * function will cause the task to enter the finished state, and will no
+ * longer be scheduled to run. This function does not need to be called when
+ * returning from \ref mars_task_main since it is called automatically.
+ *
+ * \note This function is a scheduling call and will put the caller task into a
+ * finished state.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e exit_code
+ * - The value passed into here can be obtained when calling \ref mars_task_wait
+ * or \ref mars_task_try_wait.
+ *
+ * \param[in] exit_code		- value to be returned to the task wait call
+ */
+void mars_task_exit(int32_t exit_code);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[MPU]</b> Yields caller task so other workloads can run.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function causes the task to yield and allow other tasks to be
+ * scheduled to run if available. If other tasks are available to be scheduled
+ * to run then this task enters the waiting state until the next time it is
+ * scheduled to run. If there are no other tasks available to be scheduled at
+ * the time of this function call, then this function has no effect and will
+ * return immediately.
+ *
+ * \note This function is a scheduling call and may cause a task switch and put
+ * the caller task into a waiting state.
+ *
+ * \return
+ *	MARS_SUCCESS		- successfully yielded task
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_yield(void);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[host/MPU]</b> Schedules a MARS task for execution.
+ *
+ * This function schedules the task specified for execution.
+ * The actual time of execution is determined by the scheduler.
+ * Once the task is scheduled for execution by this function, it may not be
+ * scheduled for execution until previous execution has finished.
+ * You can wait for task completion by calling \ref mars_task_wait or
+ * \ref mars_task_try_wait.
+ *
+ * You can call this function with a valid task id returned by
+ * \ref mars_task_create as many times as you want after each scheduled
+ * execution has completed. The task id is valid until the task is destroyed by
+ * \ref mars_task_destroy.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e args
+ * - The task args (\ref mars_task_args) are optional, and only
+ * need to be passed in if the task executable expects it.
+ * - If NULL is specified the task args passed into the task executable's main
+ * function will not be initialized.
+ *
+ * \e priority
+ * - This is the priority of the task between 0 to 255, 0 being the lowest
+ * priority and 255 being the highest priority.
+ * - Tasks with higher priority will be prioritized during scheduling if both
+ * tasks are ready to run at the time of scheduling.
+ *
+ * \param[in] id		- pointer to task id to schedule
+ * \param[in] args		- pointer to task args to pass into task main
+ * \param[out] priority		- priority of scheduling for the task
+ * \return
+ *	MARS_SUCCESS		- successfully scheduled MARS task for execution
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- bad task id specified
+ * \n	MARS_ERROR_STATE	- task is in an invalid state
+ */
+int mars_task_schedule(struct mars_task_id *id, struct mars_task_args *args,
+			uint8_t priority);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[host/MPU]</b> Waits for task completion.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will block until the scheduled task specified is finished.
+ *
+ * Any number of host threads or tasks can wait for a specific task to complete
+ * execution as long as it holds the task's id. However, the task being waited
+ * on should not be re-scheduled until all wait calls for the task have
+ * returned. Otherwise it is not guaranteed that all wait calls will return
+ * after the completion of the initial schedule call.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e exit_code
+ * - Pass in a pointer to store the task exit code.
+ * - If NULL is specified, no exit code can be obtained when the task
+ * completes and returns.
+ *
+ * \note This function is a scheduling call and may cause a task switch and put
+ * the caller task into a waiting state.
+ *
+ * \param[in] id		- pointer to task id to wait for
+ * \param[in] exit_code		- pointer to variable to store task exit code
+ * \return
+ *	MARS_SUCCESS		- task execution finished
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- bad task id specified
+ * \n	MARS_ERROR_STATE	- task is in an invalid state
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_wait(struct mars_task_id *id, int32_t *exit_code);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[host/MPU]</b> Waits for a task completion.
+ *
+ * This function will check whether the scheduled task specified is finished
+ * or not and return immediately without blocking.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e exit_code
+ * - Pass in a pointer to store the task exit code.
+ * - If NULL is specified, no exit code can be obtained when the task
+ * completes and returns.
+ *
+ * \param[in] id		- pointer to task id to wait for
+ * \param[in] exit_code		- pointer to variable to store task exit code
+ * \return
+ *	MARS_SUCCESS		- task execution finished
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- bad task id specified
+ * \n	MARS_ERROR_STATE	- task is in an invalid state
+ * \n	MARS_ERROR_BUSY		- task has not yet finished execution
+ */
+int mars_task_try_wait(struct mars_task_id *id, int32_t *exit_code);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[MPU]</b> Gets id of kernel that the task is being executed on.
+ *
+ * \return
+ *	id of MARS kernel [0 to number of MPUS used by MARS context]
+ */
+uint32_t mars_task_get_kernel_id(void);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[MPU]</b> Gets id of caller task.
+ *
+ * \return
+ *	pointer to task id in MPU storage
+ */
+const struct mars_task_id *mars_task_get_id(void);
+
+/**
+ * \ingroup group_mars_task
+ * \brief <b>[MPU]</b> Gets name of caller task.
+ *
+ * \return
+ *	pointer to task name in MPU storage
+ */
+const char *mars_task_get_name(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/mpu/mars/task_barrier.h
@@ -0,0 +1,159 @@
+/*
+ * 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_H
+#define MARS_TASK_BARRIER_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[MPU]</b> MARS Task Barrier API
+ */
+
+#include <stdint.h>
+#include <mars/task_barrier_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[MPU]</b> Notifies a task barrier.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function notifies the barrier that the caller task has reached the
+ * synchronization point. Once a task reaches the synchronization point and
+ * notifies the barrier, it may handle other processing before calling the
+ * required \ref mars_task_barrier_wait.
+ *
+ * If all tasks from the previous barrier cycle have not reached the
+ * synchronization point and notified the barrier yet, the caller task will
+ * enter a waiting state until the previous barrier cycle is released.
+ *
+ * \param[in] barrier_ea	- ea of initialized barrier instance
+ * \return
+ *	MARS_SUCCESS		- successfully notified barrier
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not properly aligned
+ * \n	MARS_ERROR_LIMIT	- maximum number of tasks already waiting
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_barrier_notify(uint64_t barrier_ea);
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[MPU]</b> Notifies a task barrier.
+ *
+ * This function notifies the barrier that the caller task has reached the
+ * synchronization point. Once a task reaches the synchronization point and
+ * notifies the barrier, it may handle other processing before calling the
+ * required \ref mars_task_barrier_wait.
+ *
+ * If all tasks from the previous barrier cycle have not reached the
+ * synchronization point and notified the barrier yet, this function will
+ * return immediately with \ref MARS_ERROR_BUSY.
+ *
+ * \param[in] barrier_ea	- ea of initialized barrier instance
+ * \return
+ *	MARS_SUCCESS		- successfully notified barrier
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not properly aligned
+ * \n	MARS_ERROR_BUSY		- previous waits have not completed
+ */
+int mars_task_barrier_try_notify(uint64_t barrier_ea);
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[MPU]</b> Waits on a task barrier.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function should be called after the caller task has previously called
+ * \ref mars_task_barrier_notify. This function should be called when the task
+ * that reached the synchronization point is ready to wait for others to arrive
+ * at the synchronization point.
+ *
+ * If not all tasks associated with the barrier have reached the synchronization
+ * point and notified the barrier at the time of this call, the caller task will
+ * enter a waiting state until all notifications are received from the other
+ * tasks and the barrier is released.
+ *
+ * \param[in] barrier_ea	- ea of initialized barrier instance
+ * \return
+ *	MARS_SUCCESS		- barrier is released
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not properly aligned
+ * \n	MARS_ERROR_LIMIT	- maximum number of tasks already waiting
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_barrier_wait(uint64_t barrier_ea);
+
+/**
+ * \ingroup group_mars_task_barrier
+ * \brief <b>[MPU]</b> Waits on a task barrier.
+ *
+ * This function should be called after the caller task has previously called
+ * \ref mars_task_barrier_notify. This function should be called when the task
+ * that reached the synchronization point is ready to wait for others to arrive
+ * at the synchronization point.
+ *
+ * If not all tasks associated with the barrier have reached the synchronization
+ * point and notified the barrier at the time of this call, this function will
+ * return immediately with \ref MARS_ERROR_BUSY.
+ *
+ * \param[in] barrier_ea	- ea of initialized barrier instance
+ * \return
+ *	MARS_SUCCESS		- barrier is released
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not properly aligned
+ * \n	MARS_ERROR_BUSY		- not all notifications arrived yet
+ */
+int mars_task_barrier_try_wait(uint64_t barrier_ea);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/mpu/mars/task_event_flag.h
@@ -0,0 +1,198 @@
+/*
+ * 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_H
+#define MARS_TASK_EVENT_FLAG_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[MPU]</b> MARS Task Event Flag API
+ */
+
+#include <stdint.h>
+#include <mars/task_event_flag_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[MPU]</b> Clears the bits specified in the task event flag.
+ *
+ * This function will clear all bits currently set in the event flag.
+ * Tasks waiting on some events will remain in the waiting state.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e bits
+ * - Specify only the bits you want to be cleared from the event flag bits.
+ *
+ * \param[in] event_flag_ea	- ea of initialized event flag instance
+ * \param[in] bits		- bits to clear
+ * \return
+ *	MARS_SUCCESS		- successfully cleared event flag bits
+ * \n	MARS_ERROR_NULL		- ea is 0\n
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ */
+int mars_task_event_flag_clear(uint64_t event_flag_ea, uint32_t bits);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[MPU]</b> Sets the bits specified in the task event flag.
+ *
+ * This function will set the bits specified. The bits are OR'd with bits
+ * already set in the event flag at the time of this call.
+ * If there are any tasks in the waiting state, and this call satisfies the
+ * release condition of those tasks, all those tasks will be returned to the
+ * ready state.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e bits
+ * - Specify only the bits you want to set in the event flag bits.
+ *
+ * \param[in] event_flag_ea	- ea of initialized event flag instance
+ * \param[in] bits		- bits to set
+ * \return
+ *	MARS_SUCCESS		- successfully cleared event flag bits
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_event_flag_set(uint64_t event_flag_ea, uint32_t bits);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[MPU]</b> Waits on a task event flag.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This call will put the task into a waiting state until the specified event
+ * flag condition is met.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e mask
+ * - Specify only the bits you want to test against in the event flag bits set.
+ * - Whether the test condition is satisfied or not will depend on \e mask_mode.
+ *
+ * \e mask_mode
+ * - Specify how to test the mask bits against the event flag bits set.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_OR (\e mask | event flag bits), so
+ * the condition is satisfied if any bits specified in \e mask is set in the
+ * event flag bits.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_AND (\e mask & event flag bits) so
+ * the condition is satisfied if all bits specified in \e mask are set in the
+ * event flag bits.
+ *
+ * \e bits
+ * - Specify a pointer to a variable where the event flag bits can be returned.
+ * - The resulting bits will be the state of bits in the event flag prior to any
+ * automatic clearing of bits (if \ref MARS_TASK_EVENT_FLAG_CLEAR_AUTO was
+ * specified at creation).
+ *
+ * \param[in] event_flag_ea	- ea of initialized event flag instance
+ * \param[in] mask		- bit mask to test event flag bits against
+ * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_PARAMS	- invalid mask_mode
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_event_flag_wait(uint64_t event_flag_ea,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
+
+/**
+ * \ingroup group_mars_task_event_flag
+ * \brief <b>[MPU]</b> Waits on a task event flag.
+ *
+ * This call will test to see if the specified event flag condition is met
+ * returns immediately with \ref  MARS_ERROR_BUSY if it did not.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e mask
+ * - Specify only the bits you want to test against in the event flag bits set.
+ * - Whether the test condition is satisfied or not will depend on \e mask_mode.
+ *
+ * \e mask_mode
+ * - Specify how to test the mask bits against the event flag bits set.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_OR (\e mask | event flag bits), so
+ * the condition is satisfied if any bits specified in \e mask is set in the
+ * event flag bits.
+ * - Specify \ref MARS_TASK_EVENT_FLAG_MASK_AND (\e mask & event flag bits) so
+ * the condition is satisfied if all bits specified in \e mask are set in the
+ * event flag bits.
+ *
+ * \e bits
+ * - Specify a pointer to a variable where the event flag bits can be returned.
+ * - The resulting bits will be the state of bits in the event flag prior to any
+ * automatic clearing of bits (if \ref MARS_TASK_EVENT_FLAG_CLEAR_AUTO was
+ * specified at creation).
+ *
+ * \param[in] event_flag_ea	- ea of initialized event flag instance
+ * \param[in] mask		- bit mask to test event flag bits against
+ * \param[in] mask_mode		- specifies how to mask bits (AND, OR)
+ * \param[out] bits		- pointer to instance to store bits upon release
+ * \return
+ *	MARS_SUCCESS		- successfully received event
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_PARAMS	- invalid mask_mode
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_BUSY		- event not yet received
+ */
+int mars_task_event_flag_try_wait(uint64_t event_flag_ea,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/mpu/mars/task_queue.h
@@ -0,0 +1,585 @@
+/*
+ * 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_H
+#define MARS_TASK_QUEUE_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> MARS Task Queue API
+ */
+
+#include <stdint.h>
+#include <mars/task_queue_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Returns the number of data items in the task queue.
+ *
+ * This function will return the total number of data items in the queue at the
+ * time of the call.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[out] count		- pointer to variable to store return count
+ * \return
+ *	MARS_SUCCESS		- successfully returned count
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ */
+int mars_task_queue_count(uint64_t queue_ea, uint32_t *count);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Clears the data items in the task queue.
+ *
+ * This function will clear all data items currently in the queue.
+ * Entities waiting to pop data from the queue will remain waiting.
+ * Entities waiting to push data into the queue will resume.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \return
+ *	MARS_SUCCESS		- successfully cleared queue
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ */
+int mars_task_queue_clear(uint64_t queue_ea);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Pushes the data specified into the task queue.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will push the data specified into the queue.
+ * The entity waiting longest to pop data from the queue can resume.
+ *
+ * If the queue is full at the time of this call, this function will cause the
+ * caller task to enter a waiting state until there is room in the queue to push
+ * the data.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to user data to copy into the queue.
+ * - The size of data should be equal to the size specified at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be pushed into queue
+ * \return
+ *	MARS_SUCCESS		- successfully pushed data into queue
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_queue_push(uint64_t queue_ea, const void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Begins push operation on a task queue.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will begin pushing the data specified into the queue.
+ * This only initiates the memory transfer of data into the queue.
+ * This function must be completed with a matching call to
+ * \ref mars_task_queue_push_end to guarantee the completion of the push.
+ *
+ * If the queue is full at the time of this call, this function will cause the
+ * caller task to enter a waiting state until there is room in the queue to push
+ * the data.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to user data to copy into the queue.
+ * - The size of data should be equal to the size specified at queue creation.
+ *
+ * \e tag
+ * - Specify a memory transfer tag value between 0-31.
+ * - Multiple push operations can be initiated concurrently, and each can be
+ * waited for independently if different memory tranfer tags are specified.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be pushed into queue
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully pushed data into queue
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_queue_push_begin(uint64_t queue_ea, const void *data,
+				uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Completes push operation on a task queue.
+ *
+ * This function will complete a push operation initiated with
+ * \ref mars_task_queue_push_begin or \ref mars_task_queue_try_push_begin.
+ * This function must be called in pair for each call to
+ * \ref mars_task_queue_push_begin or \ref mars_task_queue_try_push_begin to
+ * guarantee the completion of the initiated push operation.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e tag
+ * - Specify the memory transfer tag specified at push operation initialization.
+ * - If multiple push operations were initiated concurrently, this call must
+ * wait for all memory transfers initiated with the same tag to complete.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully pushed data into queue
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ */
+int mars_task_queue_push_end(uint64_t queue_ea, uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Pushes the data specified into the task queue.
+ *
+ * This function will push the data specified into the queue.
+ * The entity waiting longest to pop data from the queue can resume.
+ *
+ * If the queue is full at the time of this call, this function will return
+ * immedately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to user data to copy into the queue.
+ * - The size of data should be equal to the size specified at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be pushed into queue
+ * \return
+ *	MARS_SUCCESS		- successfully pushed data into queue
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is full
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_try_push(uint64_t queue_ea, const void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Begins push operation on a task queue.
+ *
+ * This function will begin pushing the data specified into the queue.
+ * This only initiates the memory transfer of data into the queue.
+ * This function must be completed with a matching call to
+ * \ref mars_task_queue_push_end to guarantee the completion of the push.
+ *
+ * If the queue is full at the time of this call, this function will return
+ * immedately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to user data to copy into the queue.
+ * - The size of data should be equal to the size specified at queue creation.
+ *
+ * \e tag
+ * - Specify a memory transfer tag value between 0-31.
+ * - Multiple push operations can be initiated concurrently, and each can be
+ * waited for independently if different memory tranfer tags are specified.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be pushed into queue
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully pushed data into queue
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is full
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ */
+int mars_task_queue_try_push_begin(uint64_t queue_ea, const void *data,
+				uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Pops data from a task queue.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will pop data from the queue.
+ *
+ * If the queue is empty at the time of this call, this function will cause the
+ * caller task to enter a waiting state until there is data in the queue to
+ * pop.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_queue_pop(uint64_t queue_ea, void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Begins pop operation on a task queue.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will begin popping data from the queue.
+ * This only initiates the memory transfer of data from the queue.
+ * This function must be completed with a matching call to
+ * \ref mars_task_queue_pop_end to guarantee the completion of the pop.
+ *
+ * If the queue is empty at the time of this call, this function will cause the
+ * caller task to enter a waiting state until there is data in the queue to
+ * pop.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be popped from queue
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_queue_pop_begin(uint64_t queue_ea, void *data, uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Completes pop operation on a task queue.
+ *
+ * This function will complete a pop operation initiated with
+ * \ref mars_task_queue_pop_begin or \ref mars_task_queue_try_pop_begin.
+ * This function must be called in pair for each call to
+ * \ref mars_task_queue_pop_begin or \ref mars_task_queue_try_pop_begin to
+ * guarantee the completion of the initiated pop operation.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e tag
+ * - Specify the memory transfer tag specified at pop operation initialization.
+ * - If multiple pop operations were initiated concurrently, this call must
+ * wait for all memory transfers initiated with the same tag to complete.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ */
+int mars_task_queue_pop_end(uint64_t queue_ea, uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Pops data from a task queue.
+ *
+ * This function will pop data from the queue.
+ *
+ * If the queue is empty at the time of this call, this function will return
+ * immedately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address for data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is empty
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_try_pop(uint64_t queue_ea, void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Begins pop operation on a task queue.
+ *
+ * This function will begin popping data from the queue.
+ * This only initiates the memory transfer of data from the queue.
+ * This function must be completed with a matching call to
+ * \ref mars_task_queue_pop_end to guarantee the completion of the pop.
+ *
+ * If the queue is empty at the time of this call, this function will return
+ * immedately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address for data to be popped from queue
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is empty
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ */
+int mars_task_queue_try_pop_begin(uint64_t queue_ea, void *data, uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Pops data from a task queue without removing it.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will retrieve data from the queue without removing it from the
+ * queue.
+ *
+ * If the queue is empty at the time of this call, this function will cause the
+ * caller task to enter a waiting state until there is data in the queue to
+ * be retrieved.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_queue_peek(uint64_t queue_ea, void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Begins peek operation on a task queue.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will begin retriveing data from the queue without removing the
+ * data from the queue.
+ * This only initiates the memory transfer of data from the queue.
+ * This function must be completed with a matching call to
+ * \ref mars_task_queue_peek_end to guarantee the completion of the peek.
+ *
+ * If the queue is empty at the time of this call, this function will cause the
+ * caller task to enter a waiting state until there is data in the queue to
+ * be retrived.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be popped from queue
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_LIMIT	- exceeded limit of max waiting tasks
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_queue_peek_begin(uint64_t queue_ea, void *data, uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Completes peek operation on a task queue.
+ *
+ * This function will complete a peek operation initiated with
+ * \ref mars_task_queue_peek_begin or \ref mars_task_queue_try_peek_begin.
+ * This function must be called in pair for each call to
+ * \ref mars_task_queue_peek_begin or \ref mars_task_queue_try_peek_begin to
+ * guarantee the completion of the initiated peek operation.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e tag
+ * - Specify the memory transfer tag specified at peek operation initialization.
+ * - If multiple peek operations were initiated concurrently, this call must
+ * wait for all memory transfers initiated with the same tag to complete.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ */
+int mars_task_queue_peek_end(uint64_t queue_ea, uint32_t tag);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Pops data from a task queue without removing it.
+ *
+ * This function will retrieve data from the queue without removing it from the
+ * queue.
+ *
+ * If the queue is empty at the time of this call, this function will return
+ * immedately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be popped from queue
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is empty
+ * \n	MARS_ERROR_STATE	- invalid direction
+ */
+int mars_task_queue_try_peek(uint64_t queue_ea, void *data);
+
+/**
+ * \ingroup group_mars_task_queue
+ * \brief <b>[MPU]</b> Begins peek operation on a task queue.
+ *
+ * This function will begin retriveing data from the queue without removing the
+ * data from the queue.
+ * This only initiates the memory transfer of data from the queue.
+ * This function must be completed with a matching call to
+ * \ref mars_task_queue_peek_end to guarantee the completion of the peek.
+ *
+ * If the queue is empty at the time of this call, this function will return
+ * immedately with \ref MARS_ERROR_BUSY.
+ *
+ * <b>Key Parameters</b>:
+ * \n \n
+ * \e data
+ * - Specify the pointer to some allocated memory to copy the popped data.
+ * - The size of the allocated memory area should be equal to the size specified
+ * at queue creation.
+ *
+ * \param[in] queue_ea		- ea of initialized queue instance
+ * \param[in] data		- address of data to be popped from queue
+ * \param[in] tag		- tag identifier for memory transfer
+ * \return
+ *	MARS_SUCCESS		- successfully popped data from queue
+ * \n	MARS_ERROR_NULL		- ea or data is 0
+ * \n	MARS_ERROR_ALIGN	- ea or data not aligned properly
+ * \n	MARS_ERROR_BUSY		- queue is empty
+ * \n	MARS_ERROR_STATE	- invalid direction
+ * \n	MARS_ERROR_PARAMS	- invalid tag
+ */
+int mars_task_queue_try_peek_begin(uint64_t queue_ea, void *data, uint32_t tag);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/mpu/mars/task_semaphore.h
@@ -0,0 +1,100 @@
+/*
+ * 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_H
+#define MARS_TASK_SEMAPHORE_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_semaphore
+ * \brief <b>[MPU]</b> MARS Task Semaphore API
+ */
+
+#include <stdint.h>
+#include <mars/task_semaphore_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_semaphore
+ * \brief <b>[MPU]</b> Acquires a task semaphore.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will attempt to acquire the semaphore.
+ * If the total number of current accesses of the semaphore is greater than or
+ * equal to the total allowed specified at semaphore creation, the caller task
+ * will enter a waiting state until some other tasks release the semaphore and
+ * becomes available for acquiring.
+ *
+ * \param[in] semaphore_ea	- ea of initialized semaphore instance
+ * \return
+ *	MARS_SUCCESS		- successfully acquired semaphore
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ * \n	MARS_ERROR_LIMIT	- maximum number of tasks already waiting
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_semaphore_acquire(uint64_t semaphore_ea);
+
+/**
+ * \ingroup group_mars_task_semaphore
+ * \brief <b>[MPU]</b> Releases a task semaphore.
+ *
+ * This function will release a previously acquired semaphore.
+ * If their are other tasks currently waiting to acquire a semaphore, calling
+ * this function will resume a waiting task to allow it to acquire the
+ * semaphore.
+ *
+ * \param[in] semaphore_ea	- ea of initialized semaphore instance
+ * \return
+ *	MARS_SUCCESS		- successfully released semaphore
+ * \n	MARS_ERROR_NULL		- ea is 0
+ * \n	MARS_ERROR_ALIGN	- ea not aligned properly
+ */
+int mars_task_semaphore_release(uint64_t semaphore_ea);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/include/mpu/mars/task_signal.h
@@ -0,0 +1,114 @@
+/*
+ * 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_SIGNAL_H
+#define MARS_TASK_SIGNAL_H
+
+/**
+ * \file
+ * \ingroup group_mars_task_signal
+ * \brief <b>[MPU]</b> MARS Task Signal API
+ */
+
+#include <mars/task_types.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * \ingroup group_mars_task_signal
+ * \brief <b>[host/MPU]</b> Sends a signal to the specified task.
+ *
+ * This function sends a signal to the task specified. If the task had
+ * previously called \ref mars_task_signal_wait and was in the waiting state,
+ * this function will cause that task to switch to a ready state and scheduled
+ * to run accordingly. If the task has not yet called
+ * \ref mars_task_signal_wait, the tasks's signal buffer will be set and the
+ * same order of events will occur as previously explained once
+ * \ref mars_task_signal_wait is called. The task signal buffer depth is 1.
+ * Therefore if the signal buffer is already set when a another signal is
+ * received, it has no effect.
+ *
+ * \param[in] id		- pointer to task id in MPU storage to signal
+ * \return
+ *	MARS_SUCCESS		- successfully yielded task
+ * \n	MARS_ERROR_NULL		- null pointer specified
+ * \n	MARS_ERROR_PARAMS	- bad task id specified
+ * \n	MARS_ERROR_STATE	- task is in an invalid state
+ */
+int mars_task_signal_send(struct mars_task_id *id);
+
+/**
+ * \ingroup group_mars_task_signal
+ * \brief <b>[MPU]</b> Waits and yields caller task until receiving signal.
+ * <b>(Task Switch Call)</b>
+ *
+ * \note The <b>[MPU]</b> call may result in a task switch and put this
+ * task into the waiting state. Understand all the limitations before calling
+ * a <b>Task Switch Call</b> (<b>See</b> \ref sec_6_5).
+ *
+ * This function will cause the task to enter a waiting state until some other
+ * entity calls \ref mars_task_signal_send to this task to return it to the
+ * ready state. The task will not be scheduled to run until it receives the
+ * signal and returned to the ready state.
+ *
+ * \return
+ *	MARS_SUCCESS		- successfully yielded task
+ * \n	MARS_ERROR_FORMAT	- no context save area specified
+ */
+int mars_task_signal_wait(void);
+
+/**
+ * \ingroup group_mars_task_signal
+ * \brief <b>[MPU]</b> Waits for task until receiving signal.
+ *
+ * This function will check the state of a task to see if some other entity
+ * has called \ref mars_task_signal_send to this task and returns immediately
+ * with the result.
+ *
+ * \return
+ *	MARS_SUCCESS		- successfully yielded task
+ * \n	MARS_ERROR_BUSY		- signal not yet received
+ */
+int mars_task_signal_try_wait(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
--- /dev/null
+++ b/modules/task/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/modules/task/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/modules/task/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/modules/task/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/modules/task/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/modules/task/src/host/lib/task.c
@@ -0,0 +1,329 @@
+/*
+ * 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.
+ */
+
+#include <elf.h>
+#include <string.h>
+
+#include "mars/task.h"
+#include "mars/core.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[] =
+{
+	{ .addr = 0, .size = MARS_TASK_CONTEXT_SAVE_SIZE_MAX },
+	{ .addr = 0, .size = 0 },
+};
+
+int mars_task_create(struct mars_context *mars,
+		struct mars_task_id *id_ret,
+		const char *name, const void *elf_image,
+		const struct mars_task_context_save_unit *context_save_unit)
+{
+	int ret;
+	Elf32_Ehdr *ehdr;
+	Elf32_Phdr *phdr;
+	uint16_t workload_id;
+	struct mars_task_context *task;
+	struct mars_workload_context *workload;
+
+	int context_save_area_size = 0;
+	int context_save_unit_count = 1;
+	const struct mars_task_context_save_unit *p = context_save_unit;
+
+	/* check function params */
+	if (!mars)
+		return MARS_ERROR_NULL;
+	if (!id_ret)
+		return MARS_ERROR_NULL;
+	if (!elf_image)
+		return MARS_ERROR_NULL;
+	if (name && strlen(name) > MARS_TASK_NAME_LEN_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* process elf header information */
+	ehdr = (Elf32_Ehdr *)elf_image;
+	phdr = (Elf32_Phdr *)((void *)ehdr + ehdr->e_phoff);
+
+	if (phdr->p_type != PT_LOAD)
+		return MARS_ERROR_FORMAT;
+	if (phdr->p_vaddr != MARS_TASK_BASE_ADDR)
+		return MARS_ERROR_FORMAT;
+
+	/* begin process to add the task to the workload queue */
+	ret = mars_workload_queue_add_begin(mars, &workload_id,
+		MARS_WORKLOAD_TYPE_TASK, &workload);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	/* cast workload context to task context */
+	task = (struct mars_task_context *)workload;
+
+	/* initialize task id */
+	task->id.mars_context_ea = mars_ptr_to_ea(mars);
+	task->id.workload_id = workload_id;
+	if (name)
+		strcpy((char *)task->id.name, name);
+	else
+		task->id.name[0] = 0;
+
+	/* initialize the elf parameters */
+	task->exec_ea = mars_ptr_to_ea((void *)ehdr + phdr->p_offset);
+	task->exec_size = phdr->p_filesz;
+	task->bss_size = phdr->p_memsz - phdr->p_filesz;
+	task->vaddr = phdr->p_vaddr;
+	task->entry = ehdr->e_entry;
+
+	/* no context save - run complete */
+	if (!context_save_unit) {
+		task->context_save_unit_ea = 0;
+		task->context_save_area_ea = 0;
+		goto done;
+	}
+
+	/* calculate save unit count and save area size */
+	while (p->size) {
+		if (p->addr & MARS_TASK_CONTEXT_SAVE_UNIT_ADDR_ALIGN_MASK ||
+			p->size & MARS_TASK_CONTEXT_SAVE_UNIT_SIZE_ALIGN_MASK) {
+			ret = MARS_ERROR_PARAMS;
+			goto error_context_save_unit_addr_align;
+		}
+
+		context_save_area_size += context_save_unit->size;
+		context_save_unit_count++;
+		p++;
+
+		if (context_save_unit_count == MARS_TASK_CONTEXT_SAVE_UNIT_MAX)
+			break;
+	}
+
+	/* allocate context save unit storage */
+	task->context_save_unit_ea = mars_ptr_to_ea(mars_ea_memalign(
+		MARS_TASK_CONTEXT_SAVE_UNIT_ALIGN,
+		context_save_unit_count * MARS_TASK_CONTEXT_SAVE_UNIT_SIZE));
+	if (!task->context_save_unit_ea) {
+		ret = MARS_ERROR_MEMORY;
+		goto error_malloc_context_save_unit;
+	}
+
+	/* allocate context save area */
+	task->context_save_area_ea = mars_ptr_to_ea(mars_ea_memalign(
+		MARS_TASK_CONTEXT_SAVE_ALIGN, context_save_area_size));
+	if (!task->context_save_area_ea) {
+		ret = MARS_ERROR_MEMORY;
+		goto error_malloc_context_save_area;
+	}
+
+	/* copy the context save struct into allocated storage */
+	memcpy(mars_ea_to_ptr(task->context_save_unit_ea),
+		context_save_unit,
+		context_save_unit_count * MARS_TASK_CONTEXT_SAVE_UNIT_SIZE);
+
+done:
+	/* end process to add the task to the workload queue */
+	ret = mars_workload_queue_add_end(mars, workload_id);
+	if (ret != MARS_SUCCESS)
+		goto error_workload_queue_add_end;
+
+	/* return id to caller */
+	*id_ret = task->id;
+
+	return MARS_SUCCESS;
+
+error_workload_queue_add_end:
+	mars_ea_free(mars_ea_to_ptr(task->context_save_area_ea));
+error_malloc_context_save_area:
+	mars_ea_free(mars_ea_to_ptr(task->context_save_unit_ea));
+error_malloc_context_save_unit:
+error_context_save_unit_addr_align:
+	mars_workload_queue_add_cancel(mars, workload_id);
+
+	return ret;
+}
+
+int mars_task_destroy(struct mars_task_id *id)
+{
+	int ret;
+	struct mars_context *mars;
+	struct mars_task_context *task;
+	struct mars_workload_context *workload;
+
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+	if (!id->mars_context_ea)
+		return MARS_ERROR_PARAMS;
+	if (!id->workload_id >= MARS_WORKLOAD_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* get mars context pointer from task id */
+	mars = mars_ea_to_ptr(id->mars_context_ea);
+
+	/* begin process to remove the task from the workload queue */
+	ret = mars_workload_queue_remove_begin(mars, id->workload_id,
+		&workload);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	/* cast workload context to task context */
+	task = (struct mars_task_context *)workload;
+
+	/* free the allocated context save area if it has one */
+	if (task->context_save_area_ea)
+		mars_ea_free(mars_ea_to_ptr(task->context_save_area_ea));
+
+	/* free the allocated context save unit storage if it has one */
+	if (task->context_save_unit_ea)
+		mars_ea_free(mars_ea_to_ptr(task->context_save_unit_ea));
+
+	/* end process to remove the task from the workload queue */
+	ret = mars_workload_queue_remove_end(mars, id->workload_id);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_schedule(struct mars_task_id *id, struct mars_task_args *args,
+			uint8_t priority)
+{
+	int ret;
+	struct mars_context *mars;
+	struct mars_task_context *task;
+	struct mars_workload_context *workload;
+
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+	if (!id->mars_context_ea)
+		return MARS_ERROR_PARAMS;
+	if (!id->workload_id >= MARS_WORKLOAD_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* get mars context pointer from task id */
+	mars = mars_ea_to_ptr(id->mars_context_ea);
+
+	/* begin process to schedule the workload in the workload queue */
+	ret = mars_workload_queue_schedule_begin(mars, id->workload_id,
+		priority, &workload);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	/* cast workload context to task context */
+	task = (struct mars_task_context *)workload;
+
+	/* initialize task specific context variables */
+	task->stack = 0;
+	if (args)
+		memcpy(&task->args, args, sizeof(struct mars_task_args));
+
+	/* end process to schedule the workload in the workload queue */
+	ret = mars_workload_queue_schedule_end(mars, id->workload_id);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_wait(struct mars_task_id *id, int32_t *exit_code)
+{
+	int ret;
+	struct mars_context *mars;
+	struct mars_task_context *task;
+	struct mars_workload_context *workload;
+
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+	if (!id->mars_context_ea)
+		return MARS_ERROR_PARAMS;
+	if (!id->workload_id >= MARS_WORKLOAD_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* get mars context pointer from task id */
+	mars = mars_ea_to_ptr(id->mars_context_ea);
+
+	/* blocking wait for workload completion */
+	ret = mars_workload_queue_wait(mars, id->workload_id, &workload);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	/* cast workload context to task context */
+	task = (struct mars_task_context *)workload;
+
+	/* exit_code requested so return it to caller */
+	if (exit_code)
+		*exit_code = task->exit_code;
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_try_wait(struct mars_task_id *id, int32_t *exit_code)
+{
+	int ret;
+	struct mars_context *mars;
+	struct mars_task_context *task;
+	struct mars_workload_context *workload;
+
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+	if (!id->mars_context_ea)
+		return MARS_ERROR_PARAMS;
+	if (!id->workload_id >= MARS_WORKLOAD_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* get mars context pointer from task id */
+	mars = mars_ea_to_ptr(id->mars_context_ea);
+
+	/* non-blocking wait for workload completion */
+	ret = mars_workload_queue_try_wait(mars, id->workload_id, &workload);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	/* cast workload context to task context */
+	task = (struct mars_task_context *)workload;
+
+	/* exit_code requested so return it to caller */
+	if (exit_code)
+		*exit_code = task->exit_code;
+
+	return MARS_SUCCESS;
+}
--- /dev/null
+++ b/modules/task/src/host/lib/task_barrier.c
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+#include "mars/task_barrier.h"
+#include "mars/core.h"
+#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)
+{
+	struct mars_task_barrier *barrier;
+
+	/* check function params */
+	if (!mars)
+		return MARS_ERROR_NULL;
+	if (!barrier_ret)
+		return MARS_ERROR_NULL;
+	if (!total || total > MARS_TASK_BARRIER_WAIT_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* allocate barrier instance */
+	barrier = (struct mars_task_barrier *)mars_ea_memalign(
+		MARS_TASK_BARRIER_ALIGN, MARS_TASK_BARRIER_SIZE);
+	if (!barrier)
+		return MARS_ERROR_MEMORY;
+
+	mars_mutex_reset((struct mars_mutex *)barrier);
+
+	/* initialize barrier instance */
+	barrier->mars_context_ea = mars_ptr_to_ea(mars);
+	barrier->total = total;
+	barrier->notified_count = 0;
+	barrier->waited_count = 0;
+	barrier->notify_wait_count = 0;
+	barrier->wait_count = 0;
+
+	/* return barrier instance pointer */
+	*barrier_ret = barrier;
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_barrier_destroy(struct mars_task_barrier *barrier)
+{
+	/* check function params */
+	if (!barrier)
+		return MARS_ERROR_NULL;
+
+	mars_ea_free(barrier);
+
+	return MARS_SUCCESS;
+}
--- /dev/null
+++ b/modules/task/src/host/lib/task_event_flag.c
@@ -0,0 +1,258 @@
+/*
+ * 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.
+ */
+
+#include <sched.h>
+#include <string.h>
+
+#include "mars/task_event_flag.h"
+#include "mars/core.h"
+#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,
+				struct mars_task_event_flag **event_flag_ret,
+				uint8_t direction,
+				uint8_t clear_mode)
+{
+	struct mars_task_event_flag *event_flag;
+
+	/* check function params */
+	if (!mars)
+		return MARS_ERROR_NULL;
+	if (!event_flag_ret)
+		return MARS_ERROR_NULL;
+	if (direction != MARS_TASK_EVENT_FLAG_HOST_TO_MPU &&
+		direction != MARS_TASK_EVENT_FLAG_MPU_TO_HOST &&
+		direction != MARS_TASK_EVENT_FLAG_MPU_TO_MPU)
+		return MARS_ERROR_PARAMS;
+	if (clear_mode != MARS_TASK_EVENT_FLAG_CLEAR_AUTO &&
+		clear_mode != MARS_TASK_EVENT_FLAG_CLEAR_MANUAL)
+		return MARS_ERROR_PARAMS;
+
+	/* allocate event flag instance */
+	event_flag = (struct mars_task_event_flag *)mars_ea_memalign(
+		MARS_TASK_EVENT_FLAG_ALIGN, MARS_TASK_EVENT_FLAG_SIZE);
+	if (!event_flag)
+		return MARS_ERROR_MEMORY;
+
+	mars_mutex_reset((struct mars_mutex *)event_flag);
+
+	/* intialize event flag instance */
+	event_flag->mars_context_ea = mars_ptr_to_ea(mars);
+	event_flag->bits = 0;
+	event_flag->direction = direction;
+	event_flag->clear_mode = clear_mode;
+	event_flag->wait_count = 0;
+
+	/* return event flag instance pointer */
+	*event_flag_ret = event_flag;
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_event_flag_destroy(struct mars_task_event_flag *event_flag)
+{
+	/* check function params */
+	if (!event_flag)
+		return MARS_ERROR_NULL;
+
+	mars_ea_free(event_flag);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_event_flag_clear(struct mars_task_event_flag *event_flag,
+				uint32_t bits)
+{
+	if (!event_flag)
+		return MARS_ERROR_NULL;
+
+	mars_mutex_lock((struct mars_mutex *)event_flag);
+
+	/* clear the necessary bits */
+	event_flag->bits &= ~bits;
+
+	mars_mutex_unlock((struct mars_mutex *)event_flag);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_event_flag_set(struct mars_task_event_flag *event_flag,
+				uint32_t bits)
+{
+	int ret;
+	int i;
+	struct mars_context *mars;
+
+	/* check function params */
+	if (!event_flag)
+		return MARS_ERROR_NULL;
+	if (!event_flag->mars_context_ea)
+		return MARS_ERROR_NULL;
+	if (event_flag->direction != MARS_TASK_EVENT_FLAG_HOST_TO_MPU)
+		return MARS_ERROR_STATE;
+
+	mars_mutex_lock((struct mars_mutex *)event_flag);
+
+	/* get mars context pointer */
+	mars = mars_ea_to_ptr(event_flag->mars_context_ea);
+
+	/* set the necessary bits */
+	event_flag->bits |= bits;
+
+	/* save current set bits */
+	bits = event_flag->bits;
+
+	/* search through wait list for tasks to be signalled */
+	for (i = 0; i < event_flag->wait_count; i++) {
+		/* check condition based on wait mode */
+		switch (event_flag->wait_mask_mode[i]) {
+		case MARS_TASK_EVENT_FLAG_MASK_OR:
+			if ((bits & event_flag->wait_mask[i]) == 0)
+				continue;
+			break;
+		case MARS_TASK_EVENT_FLAG_MASK_AND:
+			if ((bits & event_flag->wait_mask[i]) !=
+				event_flag->wait_mask[i])
+				continue;
+			break;
+		}
+
+		/* signal the task to go to ready state */
+		ret = mars_workload_queue_signal_send(mars,
+			event_flag->wait_id[i]);
+		if (ret != MARS_SUCCESS)
+			return ret;
+
+		/* flush id from wait list */
+		event_flag->wait_count--;
+		memmove(&event_flag->wait_id[i],
+			&event_flag->wait_id[i + 1],
+			sizeof(uint16_t) * (event_flag->wait_count - i));
+		memmove(&event_flag->wait_mask[i],
+			&event_flag->wait_mask[i + 1],
+			sizeof(uint32_t) * (event_flag->wait_count - i));
+		memmove(&event_flag->wait_mask_mode[i],
+			&event_flag->wait_mask_mode[i + 1],
+			sizeof(uint8_t) * (event_flag->wait_count - i));
+		i--;
+	}
+
+	mars_mutex_unlock((struct mars_mutex *)event_flag);
+
+	return MARS_SUCCESS;
+}
+
+static int wait(struct mars_task_event_flag *event_flag,
+		uint32_t mask, uint8_t mask_mode, uint32_t *bits, int try)
+{
+	/* check function params */
+	if (!event_flag)
+		return MARS_ERROR_NULL;
+	if (event_flag->direction != MARS_TASK_EVENT_FLAG_MPU_TO_HOST)
+		return MARS_ERROR_STATE;
+	if (mask_mode != MARS_TASK_EVENT_FLAG_MASK_OR &&
+		mask_mode != MARS_TASK_EVENT_FLAG_MASK_AND)
+		return MARS_ERROR_PARAMS;
+
+	mars_mutex_lock((struct mars_mutex *)event_flag);
+
+	/* check condition based on wait mode */
+	switch (mask_mode) {
+	case MARS_TASK_EVENT_FLAG_MASK_OR:
+		while ((event_flag->bits & mask) == 0) {
+			mars_mutex_unlock((struct mars_mutex *)event_flag);
+
+			/* only try so return busy */
+			if (try)
+				return MARS_ERROR_BUSY;
+
+			/* yield until condition is met */
+			while ((event_flag->bits & mask) == 0)
+				sched_yield();
+
+			mars_mutex_lock((struct mars_mutex *)event_flag);
+		}
+		break;
+	case MARS_TASK_EVENT_FLAG_MASK_AND:
+		while ((event_flag->bits & mask) != mask) {
+			mars_mutex_unlock((struct mars_mutex *)event_flag);
+
+			/* only try so return busy */
+			if (try)
+				return MARS_ERROR_BUSY;
+
+			/* yield until condition is met */
+			while ((event_flag->bits & mask) != mask)
+				sched_yield();
+
+			mars_mutex_lock((struct mars_mutex *)event_flag);
+		}
+		break;
+	}
+
+	/* return bits if requested */
+	if (bits)
+		*bits = event_flag->bits;
+
+	/* clear event if clear mode is auto */
+	if (event_flag->clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
+		event_flag->bits &= ~mask;
+
+	mars_mutex_unlock((struct mars_mutex *)event_flag);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_event_flag_wait(struct mars_task_event_flag *event_flag,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
+{
+	return wait(event_flag, mask, mask_mode, bits, 0);
+}
+
+int mars_task_event_flag_try_wait(struct mars_task_event_flag *event_flag,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
+{
+	return wait(event_flag, mask, mask_mode, bits, 1);
+}
--- /dev/null
+++ b/modules/task/src/host/lib/task_queue.c
@@ -0,0 +1,325 @@
+/*
+ * 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.
+ */
+
+#include <sched.h>
+#include <string.h>
+
+#include "mars/task_queue.h"
+#include "mars/core.h"
+#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,
+				struct mars_task_queue **queue_ret,
+				uint32_t size,
+				uint32_t depth,
+				uint8_t direction)
+{
+	struct mars_task_queue *queue;
+	void *buffer;
+
+	/* check function params */
+	if (!mars)
+		return MARS_ERROR_NULL;
+	if (!queue_ret)
+		return MARS_ERROR_NULL;
+	if (size & MARS_TASK_QUEUE_ENTRY_SIZE_MASK)
+		return MARS_ERROR_PARAMS;
+	if (size > MARS_TASK_QUEUE_ENTRY_SIZE_MAX)
+		return MARS_ERROR_PARAMS;
+	if (direction != MARS_TASK_QUEUE_HOST_TO_MPU &&
+		direction != MARS_TASK_QUEUE_MPU_TO_HOST &&
+		direction != MARS_TASK_QUEUE_MPU_TO_MPU)
+		return MARS_ERROR_PARAMS;
+
+	/* allocate queue instance */
+	queue = (struct mars_task_queue *)mars_ea_memalign(
+		MARS_TASK_QUEUE_ALIGN, MARS_TASK_QUEUE_SIZE);
+	if (!queue)
+		return MARS_ERROR_MEMORY;
+
+	/* allocate queue buffer instance */
+	buffer = mars_ea_memalign(MARS_TASK_QUEUE_BUFFER_ALIGN, size * depth);
+	if (!buffer)
+		return MARS_ERROR_MEMORY;
+
+	mars_mutex_reset((struct mars_mutex *)queue);
+
+	/* initialize queue instance */
+	queue->mars_context_ea = mars_ptr_to_ea(mars);
+	queue->buffer_ea = mars_ptr_to_ea(buffer);
+	queue->push_ea = mars_ptr_to_ea(buffer);
+	queue->pop_ea = mars_ptr_to_ea(buffer);
+	queue->size = size;
+	queue->depth = depth;
+	queue->direction = direction;
+	queue->count = 0;
+	queue->push_wait_count = 0;
+	queue->pop_wait_count = 0;
+
+	/* return queue instance pointer */
+	*queue_ret = queue;
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_destroy(struct mars_task_queue *queue)
+{
+	/* check function params */
+	if (!queue)
+		return MARS_ERROR_NULL;
+
+	mars_ea_free(mars_ea_to_ptr(queue->buffer_ea));
+	mars_ea_free(queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_count(struct mars_task_queue *queue, uint32_t *count)
+{
+	/* check function params */
+	if (!queue)
+		return MARS_ERROR_NULL;
+	if (!count)
+		return MARS_ERROR_NULL;
+	if ((uintptr_t)queue & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	mars_mutex_lock((struct mars_mutex *)queue);
+
+	/* return current items in queue */
+	*count = queue->count;
+
+	mars_mutex_unlock((struct mars_mutex *)queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_clear(struct mars_task_queue *queue)
+{
+	int i;
+	struct mars_context *mars;
+
+	/* check function params */
+	if (!queue)
+		return MARS_ERROR_NULL;
+	if ((uintptr_t)queue & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	mars_mutex_lock((struct mars_mutex *)queue);
+
+	/* get mars context pointer */
+	mars = mars_ea_to_ptr(queue->mars_context_ea);
+
+	/* signal all waiting tasks that queue is ready for push */
+	for (i = 0; i < queue->push_wait_count; i++)
+		mars_workload_queue_signal_send(mars, queue->push_wait_id[0]);
+
+	/* flush all ids from push wait list */
+	queue->push_wait_count = 0;
+
+	/* clear the queue count and push/pop ea */
+	queue->count = 0;
+	queue->push_ea = queue->buffer_ea;
+	queue->pop_ea = queue->buffer_ea;
+
+	mars_mutex_unlock((struct mars_mutex *)queue);
+
+	return MARS_SUCCESS;
+}
+
+static void push_update(struct mars_task_queue *queue)
+{
+	struct mars_context *mars = mars_ea_to_ptr(queue->mars_context_ea);
+
+	/* signal waiting task that queue is ready for pop */
+	if (queue->pop_wait_count) {
+		/* signal waiting task */
+		mars_workload_queue_signal_send(mars, queue->pop_wait_id[0]);
+
+		/* flush id from pop wait list */
+		queue->pop_wait_count--;
+		memmove(&queue->pop_wait_id[0], &queue->pop_wait_id[1],
+			sizeof(uint16_t) * queue->pop_wait_count);
+	}
+
+	/* increment queue count */
+	queue->count++;
+
+	/* increment queue push ea */
+	queue->push_ea += queue->size;
+
+	/* wrap to front of queue if necessary */
+	if (queue->push_ea == queue->buffer_ea + (queue->size * queue->depth))
+		queue->push_ea = queue->buffer_ea;
+}
+
+static int push(struct mars_task_queue *queue, const void *data, int try)
+{
+	/* check function params */
+	if (!queue)
+		return MARS_ERROR_NULL;
+	if ((uintptr_t)queue & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (queue->direction != MARS_TASK_QUEUE_HOST_TO_MPU)
+		return MARS_ERROR_STATE;
+
+	mars_mutex_lock((struct mars_mutex *)queue);
+
+	/* queue is full so wait */
+	while (queue->count == queue->depth) {
+		mars_mutex_unlock((struct mars_mutex *)queue);
+
+		/* only try so return busy */
+		if (try)
+			return MARS_ERROR_BUSY;
+
+		while (queue->count == queue->depth)
+			sched_yield();
+
+		mars_mutex_lock((struct mars_mutex *)queue);
+	}
+
+	/* copy data into queue */
+	memcpy(mars_ea_to_ptr(queue->push_ea), data, queue->size);
+
+	/* update queue data */
+	push_update(queue);
+
+	mars_mutex_unlock((struct mars_mutex *)queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_push(struct mars_task_queue *queue, const void *data)
+{
+	return push(queue, data, 0);
+}
+
+int mars_task_queue_try_push(struct mars_task_queue *queue, const void *data)
+{
+	return push(queue, data, 1);
+}
+
+static void pop_update(struct mars_task_queue *queue)
+{
+	struct mars_context *mars = mars_ea_to_ptr(queue->mars_context_ea);
+
+	/* signal waiting task that queue is ready for push */
+	if (queue->push_wait_count) {
+		/* signal waiting task */
+		mars_workload_queue_signal_send(mars, queue->push_wait_id[0]);
+
+		/* flush id from push wait list */
+		queue->push_wait_count--;
+		memmove(&queue->push_wait_id[0], &queue->push_wait_id[1],
+			sizeof(uint16_t) * queue->push_wait_count);
+	}
+
+	/* decrement queue count */
+	queue->count--;
+
+	/* increment queue pop ea */
+	queue->pop_ea += queue->size;
+
+	/* wrap to front of queue if necessary */
+	if (queue->pop_ea == queue->buffer_ea + (queue->size * queue->depth))
+		queue->pop_ea = queue->buffer_ea;
+}
+
+static int pop(struct mars_task_queue *queue, void *data, int peek, int try)
+{
+	/* check function params */
+	if (!queue)
+		return MARS_ERROR_NULL;
+	if ((uintptr_t)queue & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (queue->direction != MARS_TASK_QUEUE_MPU_TO_HOST)
+		return MARS_ERROR_STATE;
+
+	mars_mutex_lock((struct mars_mutex *)queue);
+
+	/* queue is empty so wait */
+	while (!queue->count) {
+		mars_mutex_unlock((struct mars_mutex *)queue);
+
+		/* only try so return busy */
+		if (try)
+			return MARS_ERROR_BUSY;
+
+		while (!queue->count)
+			sched_yield();
+
+		mars_mutex_lock((struct mars_mutex *)queue);
+	}
+
+	/* copy data from queue */
+	memcpy(data, mars_ea_to_ptr(queue->pop_ea), queue->size);
+
+	/* update queue data only if this is not a peek operation */
+	if (!peek)
+		pop_update(queue);
+
+	mars_mutex_unlock((struct mars_mutex *)queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_pop(struct mars_task_queue *queue, void *data)
+{
+	return pop(queue, data, 0, 0);
+}
+
+int mars_task_queue_try_pop(struct mars_task_queue *queue, void *data)
+{
+	return pop(queue, data, 0, 1);
+}
+
+int mars_task_queue_peek(struct mars_task_queue *queue, void *data)
+{
+	return pop(queue, data, 1, 0);
+}
+
+int mars_task_queue_try_peek(struct mars_task_queue *queue, void *data)
+{
+	return pop(queue, data, 1, 1);
+}
--- /dev/null
+++ b/modules/task/src/host/lib/task_semaphore.c
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+#include <stdlib.h>
+
+#include "mars/task_semaphore.h"
+#include "mars/core.h"
+#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)
+{
+	struct mars_task_semaphore *semaphore;
+
+	/* check function params */
+	if (!mars)
+		return MARS_ERROR_NULL;
+	if (!semaphore_ret)
+		return MARS_ERROR_NULL;
+
+	/* allocate semaphore instance */
+	semaphore = (struct mars_task_semaphore *)mars_ea_memalign(
+		MARS_TASK_SEMAPHORE_ALIGN, MARS_TASK_SEMAPHORE_SIZE);
+	if (!semaphore)
+		return MARS_ERROR_MEMORY;
+
+	mars_mutex_reset((struct mars_mutex *)semaphore);
+
+	/* initialize semaphore instance */
+	semaphore->mars_context_ea = mars_ptr_to_ea(mars);
+	semaphore->count = count;
+	semaphore->wait_count = 0;
+
+	/* return semaphore instance */
+	*semaphore_ret = semaphore;
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_semaphore_destroy(struct mars_task_semaphore *semaphore)
+{
+	/* check function params */
+	if (!semaphore)
+		return MARS_ERROR_NULL;
+
+	mars_ea_free(semaphore);
+
+	return MARS_SUCCESS;
+}
--- /dev/null
+++ b/modules/task/src/host/lib/task_signal.c
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "mars/task_signal.h"
+#include "mars/core.h"
+#include "mars/error.h"
+
+#include "context_internal_types.h"
+#include "workload_queue.h"
+
+int mars_task_signal_send(struct mars_task_id *id)
+{
+	int ret;
+	struct mars_context *mars;
+
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+
+	/* get mars context pointer */
+	mars = mars_ea_to_ptr(id->mars_context_ea);
+	if (!mars)
+		return MARS_ERROR_PARAMS;
+
+	/* send signal to workload */
+	ret = mars_workload_queue_signal_send(mars, id->workload_id);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	return MARS_SUCCESS;
+}
--- /dev/null
+++ b/modules/task/src/mpu/lib/task.c
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ */
+
+#include <stdlib.h>
+
+#include "mars/task.h"
+#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)
+{
+	struct mars_task_context *task;
+
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* save the exit code in the task context */
+	task->exit_code = exit_code;
+
+	mars_exit();
+}
+
+int mars_task_yield(void)
+{
+	struct mars_task_context *task;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea)
+		return MARS_ERROR_FORMAT;
+
+	mars_yield();
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_schedule(struct mars_task_id *id, struct mars_task_args *args,
+			uint8_t priority)
+{
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+
+	return mars_schedule(id->workload_id, args, priority);
+}
+
+int mars_task_wait(struct mars_task_id *id, int32_t *exit_code)
+{
+	int ret;
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea)
+		return MARS_ERROR_FORMAT;
+
+	ret = mars_wait(id->workload_id);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	mars_signal_wait();
+
+	/* exit code requested so get it from the task context and return it */
+	if (exit_code) {
+		task = (struct mars_task_context *)
+			mars_get_workload_by_id(id->workload_id);
+		if (!task)
+			return MARS_ERROR_INTERNAL;
+
+		*exit_code = task->exit_code;
+	}
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_try_wait(struct mars_task_id *id, int32_t *exit_code)
+{
+	int ret;
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+
+	ret = mars_try_wait(id->workload_id);
+	if (ret != MARS_SUCCESS)
+		return ret;
+
+	/* exit code requested so get it from the task context and return it */
+	if (exit_code) {
+		task = (struct mars_task_context *)
+			mars_get_workload_by_id(id->workload_id);
+		if (!task)
+			return MARS_ERROR_INTERNAL;
+
+		*exit_code = task->exit_code;
+	}
+
+	return MARS_SUCCESS;
+}
+
+uint32_t mars_task_get_kernel_id(void)
+{
+	return mars_get_kernel_id();
+}
+
+const struct mars_task_id *mars_task_get_id(void)
+{
+	struct mars_task_context *task;
+
+	task = (struct mars_task_context *)mars_get_workload();
+
+	return &task->id;
+}
+
+const char *mars_task_get_name(void)
+{
+	struct mars_task_context *task;
+
+	task = (struct mars_task_context *)mars_get_workload();
+
+	return task->id.name[0] ? (const char *)task->id.name : NULL;
+}
--- /dev/null
+++ b/modules/task/src/mpu/lib/task_barrier.c
@@ -0,0 +1,202 @@
+/*
+ * 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.
+ */
+
+#include "mars/task_barrier.h"
+#include "mars/task_types.h"
+#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;
+
+static int notify(uint64_t barrier_ea, int try)
+{
+	int i;
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!barrier_ea)
+		return MARS_ERROR_NULL;
+	if (barrier_ea & MARS_TASK_BARRIER_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea && !try)
+		return MARS_ERROR_FORMAT;
+
+	mars_mutex_lock_get(barrier_ea, (struct mars_mutex *)&barrier);
+
+	/* previous barrier wait not complete so wait */
+	if (barrier.notified_count == barrier.total) {
+		/* only try so return busy */
+		if (try) {
+			mars_mutex_unlock_put(barrier_ea,
+				(struct mars_mutex *)&barrier);
+			return MARS_ERROR_BUSY;
+		}
+
+		/* check if barrier notify wait limit reached */
+		if (barrier.notify_wait_count == barrier.total) {
+			mars_mutex_unlock_put(barrier_ea,
+				(struct mars_mutex *)&barrier);
+			return MARS_ERROR_LIMIT;
+		}
+
+		/* add id to wait list */
+		barrier.notify_wait_id[barrier.notify_wait_count] =
+			mars_get_workload_id();
+		barrier.notify_wait_count++;
+
+		mars_mutex_unlock_put(barrier_ea,
+			(struct mars_mutex *)&barrier);
+
+		/* wait for signal */
+		mars_signal_wait();
+
+		mars_mutex_lock_get(barrier_ea, (struct mars_mutex *)&barrier);
+	}
+
+	/* increment notified count */
+	barrier.notified_count++;
+
+	/* notified count reached total so release barrier */
+	if (barrier.notified_count == barrier.total) {
+		/* signal all task ids in wait list */
+		for (i = 0; i < barrier.wait_count; i++)
+			mars_signal_send(barrier.wait_id[i]);
+		barrier.wait_count = 0;
+	}
+
+	mars_mutex_unlock_put(barrier_ea, (struct mars_mutex *)&barrier);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_barrier_notify(uint64_t barrier_ea)
+{
+	return notify(barrier_ea, 0);
+}
+
+int mars_task_barrier_try_notify(uint64_t barrier_ea)
+{
+	return notify(barrier_ea, 1);
+}
+
+static int wait(uint64_t barrier_ea, int try)
+{
+	int i;
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!barrier_ea)
+		return MARS_ERROR_NULL;
+	if (barrier_ea & MARS_TASK_BARRIER_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea)
+		return MARS_ERROR_FORMAT;
+
+	mars_mutex_lock_get(barrier_ea, (struct mars_mutex *)&barrier);
+
+	/* not all tasks notified barrier so need to wait */
+	if (barrier.notified_count != barrier.total) {
+		/* only try so return busy */
+		if (try) {
+			mars_mutex_unlock_put(barrier_ea,
+				(struct mars_mutex *)&barrier);
+			return MARS_ERROR_BUSY;
+		}
+
+		/* check if barrier wait limit reached */
+		if (barrier.wait_count == barrier.total) {
+			mars_mutex_unlock_put(barrier_ea,
+				(struct mars_mutex *)&barrier);
+			return MARS_ERROR_LIMIT;
+		}
+
+		/* add id to wait list */
+		barrier.wait_id[barrier.wait_count] = mars_get_workload_id();
+		barrier.wait_count++;
+
+		mars_mutex_unlock_put(barrier_ea,
+			(struct mars_mutex *)&barrier);
+
+		/* wait for signal */
+		mars_signal_wait();
+
+		mars_mutex_lock_get(barrier_ea, (struct mars_mutex *)&barrier);
+	}
+
+	/* increment waited count */
+	barrier.waited_count++;
+
+	/* all tasks have called wait so reset barrier */
+	if (barrier.waited_count == barrier.total) {
+		barrier.notified_count = 0;
+		barrier.waited_count = 0;
+
+		/* signal all task ids in notify wait list */
+		for (i = 0; i < barrier.notify_wait_count; i++)
+			mars_signal_send(barrier.notify_wait_id[i]);
+		barrier.notify_wait_count = 0;
+	}
+
+	mars_mutex_unlock_put(barrier_ea, (struct mars_mutex *)&barrier);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_barrier_wait(uint64_t barrier_ea)
+{
+	return wait(barrier_ea, 0);
+}
+
+int mars_task_barrier_try_wait(uint64_t barrier_ea)
+{
+	return wait(barrier_ea, 1);
+}
--- /dev/null
+++ b/modules/task/src/mpu/lib/task_event_flag.c
@@ -0,0 +1,236 @@
+/*
+ * 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.
+ */
+
+#include <string.h>
+
+#include "mars/task_event_flag.h"
+#include "mars/task_types.h"
+#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;
+
+int mars_task_event_flag_clear(uint64_t event_flag_ea, uint32_t bits)
+{
+	/* check function params */
+	if (!event_flag_ea)
+		return MARS_ERROR_NULL;
+	if (event_flag_ea & MARS_TASK_EVENT_FLAG_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	mars_mutex_lock_get(event_flag_ea, (struct mars_mutex *)&event_flag);
+
+	/* clear the necessary bits */
+	event_flag.bits &= ~bits;
+
+	mars_mutex_unlock_put(event_flag_ea, (struct mars_mutex *)&event_flag);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_event_flag_set(uint64_t event_flag_ea, uint32_t bits)
+{
+	int i;
+
+	/* check function params */
+	if (!event_flag_ea)
+		return MARS_ERROR_NULL;
+	if (event_flag_ea & MARS_TASK_EVENT_FLAG_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	mars_mutex_lock_get(event_flag_ea, (struct mars_mutex *)&event_flag);
+
+	/* check for valid direction */
+	if (event_flag.direction != MARS_TASK_EVENT_FLAG_MPU_TO_HOST &&
+		event_flag.direction != MARS_TASK_EVENT_FLAG_MPU_TO_MPU) {
+		mars_mutex_unlock_put(event_flag_ea,
+			(struct mars_mutex *)&event_flag);
+		return MARS_ERROR_STATE;
+	}
+
+	/* set the necessary bits */
+	event_flag.bits |= bits;
+
+	/* save current set bits */
+	bits = event_flag.bits;
+
+	/* search through wait list for tasks to be signalled */
+	for (i = 0; i < event_flag.wait_count; i++) {
+		/* check condition based on wait mode */
+		switch (event_flag.wait_mask_mode[i]) {
+		case MARS_TASK_EVENT_FLAG_MASK_OR:
+			if ((bits & event_flag.wait_mask[i]) == 0)
+				continue;
+			break;
+		case MARS_TASK_EVENT_FLAG_MASK_AND:
+			if ((bits & event_flag.wait_mask[i])
+				!= event_flag.wait_mask[i])
+				continue;
+			break;
+		}
+
+		/* signal the waiting tasks */
+		mars_signal_send(event_flag.wait_id[i]);
+
+		/* flush id from wait list */
+		event_flag.wait_count--;
+		memmove(&event_flag.wait_id[i],
+			&event_flag.wait_id[i + 1],
+			sizeof(uint16_t) * (event_flag.wait_count - i));
+		memmove(&event_flag.wait_mask[i],
+			&event_flag.wait_mask[i + 1],
+			sizeof(uint32_t) * (event_flag.wait_count - i));
+		memmove(&event_flag.wait_mask_mode[i],
+			&event_flag.wait_mask_mode[i + 1],
+			sizeof(uint8_t) * (event_flag.wait_count - i));
+		i--;
+	}
+
+	mars_mutex_unlock_put(event_flag_ea, (struct mars_mutex *)&event_flag);
+
+	return MARS_SUCCESS;
+}
+
+static int wait(uint64_t event_flag_ea,uint32_t mask, uint8_t mask_mode,
+		uint32_t *bits, int try)
+{
+	int wait = 0;
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!event_flag_ea)
+		return MARS_ERROR_NULL;
+	if (event_flag_ea & MARS_TASK_EVENT_FLAG_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (mask_mode != MARS_TASK_EVENT_FLAG_MASK_OR &&
+		mask_mode != MARS_TASK_EVENT_FLAG_MASK_AND)
+		return MARS_ERROR_PARAMS;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea && !try)
+		return MARS_ERROR_FORMAT;
+
+	mars_mutex_lock_get(event_flag_ea, (struct mars_mutex *)&event_flag);
+
+	/* check for valid direction */
+	if (event_flag.direction != MARS_TASK_EVENT_FLAG_HOST_TO_MPU &&
+		event_flag.direction != MARS_TASK_EVENT_FLAG_MPU_TO_MPU) {
+		mars_mutex_unlock_put(event_flag_ea,
+			(struct mars_mutex *)&event_flag);
+		return MARS_ERROR_STATE;
+	}
+
+	/* check condition based on wait mode */
+	switch (mask_mode) {
+	case MARS_TASK_EVENT_FLAG_MASK_OR:
+		if ((event_flag.bits & mask) == 0)
+			wait = 1;
+		break;
+	case MARS_TASK_EVENT_FLAG_MASK_AND:
+		if ((event_flag.bits & mask) != mask)
+			wait = 1;
+		break;
+	}
+
+	if (wait) {
+		/* only try so return busy */
+		if (try) {
+			mars_mutex_unlock_put(event_flag_ea,
+				(struct mars_mutex *)&event_flag);
+			return MARS_ERROR_BUSY;
+		}
+
+		/* check if event flag wait limit reached */
+		if (event_flag.wait_count == MARS_TASK_EVENT_FLAG_WAIT_MAX) {
+			mars_mutex_unlock_put(event_flag_ea,
+				(struct mars_mutex *)&event_flag);
+			return MARS_ERROR_LIMIT;
+		}
+
+		/* add id to wait list */
+		event_flag.wait_id[event_flag.wait_count]
+				= mars_get_workload_id();
+		event_flag.wait_mask[event_flag.wait_count]
+				= mask;
+		event_flag.wait_mask_mode[event_flag.wait_count]
+				= mask_mode;
+		event_flag.wait_count++;
+
+		mars_mutex_unlock_put(event_flag_ea,
+				(struct mars_mutex *)&event_flag);
+
+		/* wait for signal */
+		mars_signal_wait();
+
+		mars_mutex_lock_get(event_flag_ea,
+				(struct mars_mutex *)&event_flag);
+	}
+
+	/* return bits if requested */
+	if (bits)
+		*bits = event_flag.bits;
+
+	/* clear event if clear mode is auto */
+	if (event_flag.clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
+		event_flag.bits &= ~mask;
+
+	mars_mutex_unlock_put(event_flag_ea, (struct mars_mutex *)&event_flag);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_event_flag_wait(uint64_t event_flag_ea,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
+{
+	return wait(event_flag_ea, mask, mask_mode, bits, 0);
+}
+
+int mars_task_event_flag_try_wait(uint64_t event_flag_ea,
+				uint32_t mask, uint8_t mask_mode,
+				uint32_t *bits)
+{
+	return wait(event_flag_ea, mask, mask_mode, bits, 1);
+}
--- /dev/null
+++ b/modules/task/src/mpu/lib/task_queue.c
@@ -0,0 +1,427 @@
+/*
+ * 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.
+ */
+
+#include <string.h>
+
+#include "mars/task_queue.h"
+#include "mars/task_types.h"
+#include "mars/mutex.h"
+#include "mars/error.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;
+
+int mars_task_queue_count(uint64_t queue_ea, uint32_t *count)
+{
+	/* check function params */
+	if (!queue_ea)
+		return MARS_ERROR_NULL;
+	if (!count)
+		return MARS_ERROR_NULL;
+	if (queue_ea & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	mars_mutex_lock_get(queue_ea, (struct mars_mutex *)&queue);
+
+	/* return current items in queue */
+	*count = queue.count;
+
+	mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_clear(uint64_t queue_ea)
+{
+	int i;
+
+	/* check function params */
+	if (!queue_ea)
+		return MARS_ERROR_NULL;
+	if (queue_ea & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	mars_mutex_lock_get(queue_ea, (struct mars_mutex *)&queue);
+
+	/* signal all waiting tasks that queue is ready for push */
+	for (i = 0; i < queue.push_wait_count; i++)
+		mars_signal_send(queue.push_wait_id[i]);
+
+	/* flush all ids from push wait list */
+	queue.push_wait_count = 0;
+
+	/* clear the queue count and push/pop ea */
+	queue.count = 0;
+	queue.push_ea = queue.buffer_ea;
+	queue.pop_ea = queue.buffer_ea;
+
+	mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+	return MARS_SUCCESS;
+}
+
+static void push_update(void)
+{
+	/* signal waiting task that queue is ready for pop */
+	if (queue.pop_wait_count) {
+		/* signal waiting task */
+		mars_signal_send(queue.pop_wait_id[0]);
+
+		/* flush id from pop wait list */
+		queue.pop_wait_count--;
+		memmove(&queue.pop_wait_id[0], &queue.pop_wait_id[1],
+			sizeof(uint16_t) * queue.pop_wait_count);
+	}
+
+	/* increment queue count */
+	queue.count++;
+
+	/* increment queue push ea */
+	queue.push_ea += queue.size;
+
+	/* wrap to front of queue if necessary */
+	if (queue.push_ea == queue.buffer_ea + (queue.size * queue.depth))
+		queue.push_ea = queue.buffer_ea;
+}
+
+static int push(uint64_t queue_ea, const void *data,
+		int try, int begin, uint32_t tag)
+{
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!queue_ea)
+		return MARS_ERROR_NULL;
+	if (queue_ea & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if ((uintptr_t)data & MARS_TASK_QUEUE_ENTRY_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (tag > MARS_DMA_TAG_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea && !try)
+		return MARS_ERROR_FORMAT;
+
+	mars_mutex_lock_get(queue_ea, (struct mars_mutex *)&queue);
+
+	/* check for valid direction */
+	if (queue.direction != MARS_TASK_QUEUE_MPU_TO_HOST &&
+		queue.direction != MARS_TASK_QUEUE_MPU_TO_MPU) {
+		mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+		return MARS_ERROR_STATE;
+	}
+
+	/* queue is full so wait */
+	while (queue.count == queue.depth) {
+		/* only try so return busy */
+		if (try) {
+			mars_mutex_unlock_put(queue_ea,
+				(struct mars_mutex *)&queue);
+			return MARS_ERROR_BUSY;
+		}
+
+		/* check if push wait list full */
+		if (queue.push_wait_count == MARS_TASK_QUEUE_WAIT_MAX) {
+			mars_mutex_unlock_put(queue_ea,
+				(struct mars_mutex *)&queue);
+			return MARS_ERROR_LIMIT;
+		}
+
+		/* add id to push wait list */
+		queue.push_wait_id[queue.push_wait_count]
+			= mars_get_workload_id();
+		queue.push_wait_count++;
+
+		mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+		/* wait for signal */
+		mars_signal_wait();
+
+		mars_mutex_lock_get(queue_ea, (struct mars_mutex *)&queue);
+	}
+
+	/* begin data transfer into queue */
+	mars_dma_put(data, queue.push_ea, queue.size, tag);
+
+	/* only begin data transfer so return */
+	if (begin)
+		return MARS_SUCCESS;
+
+	/* wait for dma completion */
+	mars_dma_wait(tag);
+
+	/* update queue data */
+	push_update();
+
+	mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_push(uint64_t queue_ea, const void *data)
+{
+	return push(queue_ea, data, 0, 0, MARS_DMA_TAG);
+}
+
+int mars_task_queue_push_begin(uint64_t queue_ea, const void *data,
+				uint32_t tag)
+{
+	return push(queue_ea, data, 0, 1, tag);
+}
+
+int mars_task_queue_push_end(uint64_t queue_ea, uint32_t tag)
+{
+	/* check function params */
+	if (!queue_ea)
+		return MARS_ERROR_NULL;
+	if (queue_ea & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (tag > MARS_DMA_TAG_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* wait for dma completion */
+	mars_dma_wait(tag);
+
+	/* update queue data */
+	push_update();
+
+	mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_try_push(uint64_t queue_ea, const void *data)
+{
+	return push(queue_ea, data, 1, 0, MARS_DMA_TAG);
+}
+
+int mars_task_queue_try_push_begin(uint64_t queue_ea, const void *data,
+				uint32_t tag)
+{
+	return push(queue_ea, data, 1, 1, tag);
+}
+
+static void pop_update(void)
+{
+	/* signal waiting task that queue is ready for push */
+	if (queue.push_wait_count) {
+		/* signal waiting task */
+		mars_signal_send(queue.push_wait_id[0]);
+
+		/* flush id from push wait list */
+		queue.push_wait_count--;
+		memmove(&queue.push_wait_id[0], &queue.push_wait_id[1],
+			sizeof(uint16_t) * queue.push_wait_count);
+	}
+
+	/* decrement queue count */
+	queue.count--;
+
+	/* increment queue pop ea */
+	queue.pop_ea += queue.size;
+
+	/* wrap to front of queue if necessary */
+	if (queue.pop_ea == queue.buffer_ea + (queue.size * queue.depth))
+		queue.pop_ea = queue.buffer_ea;
+}
+
+static int pop(uint64_t queue_ea, void *data,
+		int peek, int try, int begin, uint32_t tag)
+{
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!queue_ea)
+		return MARS_ERROR_NULL;
+	if (queue_ea & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if ((uintptr_t)data & MARS_TASK_QUEUE_ENTRY_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (tag > MARS_DMA_TAG_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea && !try)
+		return MARS_ERROR_FORMAT;
+
+	mars_mutex_lock_get(queue_ea, (struct mars_mutex *)&queue);
+
+	/* check for valid direction */
+	if (queue.direction != MARS_TASK_QUEUE_HOST_TO_MPU &&
+		queue.direction != MARS_TASK_QUEUE_MPU_TO_MPU) {
+		mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+		return MARS_ERROR_STATE;
+	}
+
+	/* queue is empty so wait */
+	while (!queue.count) {
+		/* only try so return busy */
+		if (try) {
+			mars_mutex_unlock_put(queue_ea,
+				(struct mars_mutex *)&queue);
+			return MARS_ERROR_BUSY;
+		}
+
+		/* check if pop wait list full */
+		if (queue.pop_wait_count == MARS_TASK_QUEUE_WAIT_MAX) {
+			mars_mutex_unlock_put(queue_ea,
+				(struct mars_mutex *)&queue);
+			return MARS_ERROR_LIMIT;
+		}
+
+		/* add id to pop wait list */
+		queue.pop_wait_id[queue.pop_wait_count]
+			= mars_get_workload_id();
+		queue.pop_wait_count++;
+
+		mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+		/* wait for signal */
+		mars_signal_wait();
+
+		mars_mutex_lock_get(queue_ea, (struct mars_mutex *)&queue);
+	}
+
+	/* begin data transfer from queue */
+	mars_dma_get(data, queue.pop_ea, queue.size, tag);
+
+	/* only begin data transfer so return */
+	if (begin)
+		return MARS_SUCCESS;
+
+	/* wait for dma completion */
+	mars_dma_wait(tag);
+
+	/* update queue data only if this is not a peek operation */
+	if (!peek)
+		pop_update();
+
+	mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_pop(uint64_t queue_ea, void *data)
+{
+	return pop(queue_ea, data, 0, 0, 0, MARS_DMA_TAG);
+}
+
+int mars_task_queue_pop_begin(uint64_t queue_ea, void *data, uint32_t tag)
+{
+	return pop(queue_ea, data, 0, 0, 1, tag);
+}
+
+int mars_task_queue_pop_end(uint64_t queue_ea, uint32_t tag)
+{
+	/* check function params */
+	if (!queue_ea)
+		return MARS_ERROR_NULL;
+	if (queue_ea & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (tag > MARS_DMA_TAG_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* wait for dma completion */
+	mars_dma_wait(tag);
+
+	/* update queue data */
+	pop_update();
+
+	mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_try_pop(uint64_t queue_ea, void *data)
+{
+	return pop(queue_ea, data, 0, 1, 0, MARS_DMA_TAG);
+}
+
+int mars_task_queue_try_pop_begin(uint64_t queue_ea, void *data, uint32_t tag)
+{
+	return pop(queue_ea, data, 0, 1, 1, tag);
+}
+
+int mars_task_queue_peek(uint64_t queue_ea, void *data)
+{
+	return pop(queue_ea, data, 1, 0, 0, MARS_DMA_TAG);
+}
+
+int mars_task_queue_peek_begin(uint64_t queue_ea, void *data, uint32_t tag)
+{
+	return pop(queue_ea, data, 1, 0, 1, tag);
+}
+
+int mars_task_queue_peek_end(uint64_t queue_ea, uint32_t tag)
+{
+	/* check function params */
+	if (!queue_ea)
+		return MARS_ERROR_NULL;
+	if (queue_ea & MARS_TASK_QUEUE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+	if (tag > MARS_DMA_TAG_MAX)
+		return MARS_ERROR_PARAMS;
+
+	/* wait for dma completion */
+	mars_dma_wait(tag);
+
+	mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_queue_try_peek(uint64_t queue_ea, void *data)
+{
+	return pop(queue_ea, data, 1, 1, 0, MARS_DMA_TAG);
+}
+
+int mars_task_queue_try_peek_begin(uint64_t queue_ea, void *data, uint32_t tag)
+{
+	return pop(queue_ea, data, 1, 1, 1, tag);
+}
--- /dev/null
+++ b/modules/task/src/mpu/lib/task_semaphore.c
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "mars/task_semaphore.h"
+#include "mars/task_types.h"
+#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;
+
+int mars_task_semaphore_acquire(uint64_t semaphore_ea)
+{
+	struct mars_task_context *task;
+
+	/* check function params */
+	if (!semaphore_ea)
+		return MARS_ERROR_NULL;
+	if (semaphore_ea & MARS_TASK_SEMAPHORE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea)
+		return MARS_ERROR_FORMAT;
+
+	mars_mutex_lock_get(semaphore_ea, (struct mars_mutex *)&semaphore);
+
+	/* check if semaphore wait limit reached */
+	if (semaphore.wait_count == MARS_TASK_SEMAPHORE_WAIT_MAX) {
+		mars_mutex_unlock_put(semaphore_ea,
+			(struct mars_mutex *)&semaphore);
+		return MARS_ERROR_LIMIT;
+	}
+
+	if (semaphore.count <= 0) {
+		/* add id to wait list */
+		semaphore.wait_id[semaphore.wait_count] =
+			mars_get_workload_id();
+		semaphore.wait_count++;
+
+		mars_mutex_unlock_put(semaphore_ea,
+				(struct mars_mutex *)&semaphore);
+
+		/* wait for signal */
+		mars_signal_wait();
+
+		return MARS_SUCCESS;
+	}
+
+	/* decrement semaphore count */
+	semaphore.count--;
+
+	mars_mutex_unlock_put(semaphore_ea, (struct mars_mutex *)&semaphore);
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_semaphore_release(uint64_t semaphore_ea)
+{
+	/* check function params */
+	if (!semaphore_ea)
+		return MARS_ERROR_NULL;
+	if (semaphore_ea & MARS_TASK_SEMAPHORE_ALIGN_MASK)
+		return MARS_ERROR_ALIGN;
+
+	mars_mutex_lock_get(semaphore_ea, (struct mars_mutex *)&semaphore);
+
+	/* increment semaphore count */
+	semaphore.count++;
+
+	/* signal those that are waiting */
+	if (semaphore.count > 0 && semaphore.wait_count) {
+		/* decrement semaphore count */
+		semaphore.count--;
+
+		/* signal waiting task */
+		mars_signal_send(semaphore.wait_id[0]);
+
+		/* flush id from wait list */
+		semaphore.wait_count--;
+		memmove(&semaphore.wait_id[0],
+			&semaphore.wait_id[1],
+			sizeof(uint16_t) * semaphore.wait_count);
+	}
+
+	mars_mutex_unlock_put(semaphore_ea, (struct mars_mutex *)&semaphore);
+
+	return MARS_SUCCESS;
+}
--- /dev/null
+++ b/modules/task/src/mpu/lib/task_signal.c
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+#include "mars/task_signal.h"
+#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)
+{
+	/* check function params */
+	if (!id)
+		return MARS_ERROR_NULL;
+
+	return mars_signal_send(id->workload_id);
+}
+
+int mars_task_signal_wait(void)
+{
+	struct mars_task_context *task;
+
+	/* get task context */
+	task = (struct mars_task_context *)mars_get_workload();
+
+	/* make sure task context has a context save area */
+	if (!task->context_save_area_ea)
+		return MARS_ERROR_FORMAT;
+
+	mars_signal_wait();
+
+	return MARS_SUCCESS;
+}
+
+int mars_task_signal_try_wait(void)
+{
+	return mars_signal_try_wait();
+}






More information about the cbe-oss-dev mailing list