[Cbe-oss-dev] [PATCH 3/3]MARS/core: Rename platform specific sources

Yuji Mano yuji.mano at am.sony.com
Tue Dec 9 17:27:57 EST 2008


This renames the platform specific sources in core/src/host/lib in preparation
for hybrid system support.

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

---
 core/src/host/lib/Makefile.am        |   12 +-
 core/src/host/lib/cond.c             |   55 ------------
 core/src/host/lib/cond_cell.c        |   55 ++++++++++++
 core/src/host/lib/ea.c               |  147 ---------------------------------
 core/src/host/lib/ea_cell.c          |  147 +++++++++++++++++++++++++++++++++
 core/src/host/lib/host_mutex.c       |   68 ---------------
 core/src/host/lib/host_mutex_linux.c |   68 +++++++++++++++
 core/src/host/lib/mpu.c              |  115 -------------------------
 core/src/host/lib/mpu_cell.c         |  115 +++++++++++++++++++++++++
 core/src/host/lib/mutex.c            |  155 -----------------------------------
 core/src/host/lib/mutex_cell.c       |  155 +++++++++++++++++++++++++++++++++++
 11 files changed, 547 insertions(+), 545 deletions(-)

--- a/core/src/host/lib/Makefile.am
+++ b/core/src/host/lib/Makefile.am
@@ -49,6 +49,12 @@ else
 endif
 
 if MARS_PLATFORM_CELL
+MARS_PLATFORM_SPECIFIC_SOURCES = \
+	cond_cell.c \
+	ea_cell.c \
+	host_mutex_linux.c \
+	mpu_cell.c \
+	mutex_cell.c
 endif
 
 if MARS_PLATFORM_SPURSENGINE
@@ -93,14 +99,10 @@ lib_LTLIBRARIES = libmars_core.la
 
 libmars_core_la_SOURCES = \
 	$(srcdir)/../../../src/common/*.h \
+	${MARS_PLATFORM_SPECIFIC_SOURCES} \
 	alloc.c \
-	cond.c \
 	context.c \
 	context_internal_types.h \
-	ea.c \
-	host_mutex.c \
-	mpu.c \
-	mutex.c \
 	workload_queue.c
 
 nodist_libmars_core_la_SOURCES = \
--- a/core/src/host/lib/cond.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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 "config.h"
-
-#include "mars/core.h"
-
-int mars_ea_cond_wait(uint64_t watch_point_ea,
-		      int (*test_cond)(uint32_t , void *),
-		      void *test_cond_param)
-{
-	int ret;
-
-	while ((ret = (*test_cond)(mars_ea_get_uint32(watch_point_ea),
-				   test_cond_param)) < 0)
-		sched_yield();
-
-	return ret;
-}
--- /dev/null
+++ b/core/src/host/lib/cond_cell.c
@@ -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.
+ */
+
+#include <sched.h>
+
+#include "config.h"
+
+#include "mars/core.h"
+
+int mars_ea_cond_wait(uint64_t watch_point_ea,
+		      int (*test_cond)(uint32_t , void *),
+		      void *test_cond_param)
+{
+	int ret;
+
+	while ((ret = (*test_cond)(mars_ea_get_uint32(watch_point_ea),
+				   test_cond_param)) < 0)
+		sched_yield();
+
+	return ret;
+}
--- a/core/src/host/lib/ea.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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 <malloc.h>
-#include <string.h>
-#include <ppu_intrinsics.h>
-
-#include "config.h"
-
-#include "mars/core.h"
-
-uint64_t mars_ea_memalign(size_t boundary, size_t size)
-{
-	void *ptr = memalign(boundary, size);
-
-	return mars_ptr_to_ea(ptr);
-}
-
-void mars_ea_free(uint64_t ea)
-{
-	free(mars_ea_to_ptr(ea));
-}
-
-/* copy data from host to EA */
-void mars_ea_put(uint64_t ea, const void *mem, size_t size)
-{
-	void *dst = mars_ea_to_ptr(ea);
-	if (dst != mem)
-		memcpy(dst, mem, size);
-}
-
-/* copy data from EA to host */
-void mars_ea_get(uint64_t ea, void *mem, size_t size)
-{
-	const void *src = mars_ea_to_ptr(ea);
-	if (src != mem)
-		memcpy(mem, src, size);
-}
-
-/* map readonly area on host memory to EA */
-uint64_t mars_ea_map(void *ptr, size_t size)
-{
-#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
-	uint64_t copy_ea;
-
-	copy_ea = mars_ea_memalign(16, size); /* FIXME: 16 -> any macro */
-	if (!copy_ea)
-		return 0;
-
-	mars_ea_put(copy_ea, ptr, size);
-	mars_ea_sync();
-
-	return copy_ea;
-#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-	(void)size;
-	return mars_ptr_to_ea(ptr);
-#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-}
-
-/* unmap area mapped by mars_ea_map */
-void mars_ea_unmap(uint64_t ea, size_t size)
-{
-	(void)size;
-
-#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
-	mars_ea_free(ea);
-#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-	(void)ea;
-#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-}
-
-/* sync EA */
-void mars_ea_sync(void)
-{
-	__lwsync();
-}
-
-/* get uint16 value from EA */
-uint16_t mars_ea_get_uint16(uint64_t ea)
-{
-	return *(uint16_t *)mars_ea_to_ptr(ea);
-}
-
-/* put uint16 value to EA */
-void mars_ea_put_uint16(uint64_t ea, uint16_t value)
-{
-	*(uint16_t *)mars_ea_to_ptr(ea) = value;
-}
-
-/* get uint32 value from EA */
-uint32_t mars_ea_get_uint32(uint64_t ea)
-{
-	return *(uint32_t *)mars_ea_to_ptr(ea);
-}
-
-/* put uint32 value to EA */
-void mars_ea_put_uint32(uint64_t ea, uint32_t value)
-{
-	*(uint32_t *)mars_ea_to_ptr(ea) = value;
-}
-
-/* get uint64 value from EA */
-uint64_t mars_ea_get_uint64(uint64_t ea)
-{
-	return *(uint64_t *)mars_ea_to_ptr(ea);
-}
-
-/* put uint64 value to EA */
-void mars_ea_put_uint64(uint64_t ea, uint64_t value)
-{
-	*(uint64_t *)mars_ea_to_ptr(ea) = value;
-}
--- /dev/null
+++ b/core/src/host/lib/ea_cell.c
@@ -0,0 +1,147 @@
+/*
+ * 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 <malloc.h>
+#include <string.h>
+#include <ppu_intrinsics.h>
+
+#include "config.h"
+
+#include "mars/core.h"
+
+uint64_t mars_ea_memalign(size_t boundary, size_t size)
+{
+	void *ptr = memalign(boundary, size);
+
+	return mars_ptr_to_ea(ptr);
+}
+
+void mars_ea_free(uint64_t ea)
+{
+	free(mars_ea_to_ptr(ea));
+}
+
+/* copy data from host to EA */
+void mars_ea_put(uint64_t ea, const void *mem, size_t size)
+{
+	void *dst = mars_ea_to_ptr(ea);
+	if (dst != mem)
+		memcpy(dst, mem, size);
+}
+
+/* copy data from EA to host */
+void mars_ea_get(uint64_t ea, void *mem, size_t size)
+{
+	const void *src = mars_ea_to_ptr(ea);
+	if (src != mem)
+		memcpy(mem, src, size);
+}
+
+/* map readonly area on host memory to EA */
+uint64_t mars_ea_map(void *ptr, size_t size)
+{
+#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
+	uint64_t copy_ea;
+
+	copy_ea = mars_ea_memalign(16, size); /* FIXME: 16 -> any macro */
+	if (!copy_ea)
+		return 0;
+
+	mars_ea_put(copy_ea, ptr, size);
+	mars_ea_sync();
+
+	return copy_ea;
+#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+	(void)size;
+	return mars_ptr_to_ea(ptr);
+#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+}
+
+/* unmap area mapped by mars_ea_map */
+void mars_ea_unmap(uint64_t ea, size_t size)
+{
+	(void)size;
+
+#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
+	mars_ea_free(ea);
+#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+	(void)ea;
+#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+}
+
+/* sync EA */
+void mars_ea_sync(void)
+{
+	__lwsync();
+}
+
+/* get uint16 value from EA */
+uint16_t mars_ea_get_uint16(uint64_t ea)
+{
+	return *(uint16_t *)mars_ea_to_ptr(ea);
+}
+
+/* put uint16 value to EA */
+void mars_ea_put_uint16(uint64_t ea, uint16_t value)
+{
+	*(uint16_t *)mars_ea_to_ptr(ea) = value;
+}
+
+/* get uint32 value from EA */
+uint32_t mars_ea_get_uint32(uint64_t ea)
+{
+	return *(uint32_t *)mars_ea_to_ptr(ea);
+}
+
+/* put uint32 value to EA */
+void mars_ea_put_uint32(uint64_t ea, uint32_t value)
+{
+	*(uint32_t *)mars_ea_to_ptr(ea) = value;
+}
+
+/* get uint64 value from EA */
+uint64_t mars_ea_get_uint64(uint64_t ea)
+{
+	return *(uint64_t *)mars_ea_to_ptr(ea);
+}
+
+/* put uint64 value to EA */
+void mars_ea_put_uint64(uint64_t ea, uint64_t value)
+{
+	*(uint64_t *)mars_ea_to_ptr(ea) = value;
+}
--- a/core/src/host/lib/host_mutex.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 "config.h"
-
-#include "mars/error.h"
-
-#include "context_internal_types.h"
-
-/* global locks */
-pthread_mutex_t mars_shared_context_lock = PTHREAD_MUTEX_INITIALIZER;
-
-int mars_host_mutex_lock(mars_host_mutex_t *mutex)
-{
-	int ret;
-
-	ret = pthread_mutex_lock(mutex);
-	if (ret)
-		return MARS_ERROR_INTERNAL;
-
-	return MARS_SUCCESS;
-}
-
-int mars_host_mutex_unlock(mars_host_mutex_t *mutex)
-{
-	int ret;
-
-	ret = pthread_mutex_unlock(mutex);
-	if (ret)
-		return MARS_ERROR_INTERNAL;
-
-	return MARS_SUCCESS;
-}
--- /dev/null
+++ b/core/src/host/lib/host_mutex_linux.c
@@ -0,0 +1,68 @@
+/*
+ * 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 "config.h"
+
+#include "mars/error.h"
+
+#include "context_internal_types.h"
+
+/* global locks */
+pthread_mutex_t mars_shared_context_lock = PTHREAD_MUTEX_INITIALIZER;
+
+int mars_host_mutex_lock(mars_host_mutex_t *mutex)
+{
+	int ret;
+
+	ret = pthread_mutex_lock(mutex);
+	if (ret)
+		return MARS_ERROR_INTERNAL;
+
+	return MARS_SUCCESS;
+}
+
+int mars_host_mutex_unlock(mars_host_mutex_t *mutex)
+{
+	int ret;
+
+	ret = pthread_mutex_unlock(mutex);
+	if (ret)
+		return MARS_ERROR_INTERNAL;
+
+	return MARS_SUCCESS;
+}
--- a/core/src/host/lib/mpu.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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 <libspe2.h>
-
-#include "config.h"
-
-#include "mars/context.h"
-#include "mars/error.h"
-
-#include "context_internal_types.h"
-
-extern const unsigned char mars_kernel_entry[];
-
-int mars_mpu_max(int *num)
-{
-	*num = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
-	if (*num <= 0)
-		return MARS_ERROR_INTERNAL;
-
-	return MARS_SUCCESS;
-}
-
-static void *mpu_context_thread(void *arg)
-{
-	int ret;
-	unsigned int entry = SPE_DEFAULT_ENTRY;
-	struct mars_kernel_params *params = (struct mars_kernel_params *)arg;
-	struct spe_context *spe;
-	spe_program_handle_t prog;
-
-	spe = spe_context_create(0, NULL);
-	if (!spe)
-		return (void *)MARS_ERROR_INTERNAL;
-
-	memset(&prog, 0, sizeof(prog));
-	prog.handle_size = sizeof(prog);
-	prog.elf_image = (void *)mars_kernel_entry;
-	ret = spe_program_load(spe, &prog);
-	if (ret) {
-		spe_context_destroy(spe);
-		return (void *)MARS_ERROR_INTERNAL;
-	}
-
-	ret = spe_context_run(spe, &entry, 0, params, NULL, NULL);
-	if (ret) {
-		spe_context_destroy(spe);
-		return (void *)MARS_ERROR_INTERNAL;
-	}
-
-	ret = spe_context_destroy(spe);
-	if (ret)
-		return (void *)MARS_ERROR_INTERNAL;
-
-	return (void *)MARS_SUCCESS;
-}
-
-int mars_mpu_run(mars_mpu_context_t *mpu, uint64_t params_ea)
-{
-	int ret;
-
-	ret = pthread_create(mpu, NULL, mpu_context_thread,
-			     (void *)(uintptr_t)params_ea);
-	if (ret)
-		return MARS_ERROR_INTERNAL;
-
-	return MARS_SUCCESS;
-}
-
-int mars_mpu_wait(mars_mpu_context_t *mpu)
-{
-	int ret;
-	void *p_ret;
-
-	ret = pthread_join(*mpu, &p_ret);
-	if (ret || p_ret)
-		return MARS_ERROR_INTERNAL;
-
-	return MARS_SUCCESS;
-}
--- /dev/null
+++ b/core/src/host/lib/mpu_cell.c
@@ -0,0 +1,115 @@
+/*
+ * 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 <libspe2.h>
+
+#include "config.h"
+
+#include "mars/context.h"
+#include "mars/error.h"
+
+#include "context_internal_types.h"
+
+extern const unsigned char mars_kernel_entry[];
+
+int mars_mpu_max(int *num)
+{
+	*num = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
+	if (*num <= 0)
+		return MARS_ERROR_INTERNAL;
+
+	return MARS_SUCCESS;
+}
+
+static void *mpu_context_thread(void *arg)
+{
+	int ret;
+	unsigned int entry = SPE_DEFAULT_ENTRY;
+	struct mars_kernel_params *params = (struct mars_kernel_params *)arg;
+	struct spe_context *spe;
+	spe_program_handle_t prog;
+
+	spe = spe_context_create(0, NULL);
+	if (!spe)
+		return (void *)MARS_ERROR_INTERNAL;
+
+	memset(&prog, 0, sizeof(prog));
+	prog.handle_size = sizeof(prog);
+	prog.elf_image = (void *)mars_kernel_entry;
+	ret = spe_program_load(spe, &prog);
+	if (ret) {
+		spe_context_destroy(spe);
+		return (void *)MARS_ERROR_INTERNAL;
+	}
+
+	ret = spe_context_run(spe, &entry, 0, params, NULL, NULL);
+	if (ret) {
+		spe_context_destroy(spe);
+		return (void *)MARS_ERROR_INTERNAL;
+	}
+
+	ret = spe_context_destroy(spe);
+	if (ret)
+		return (void *)MARS_ERROR_INTERNAL;
+
+	return (void *)MARS_SUCCESS;
+}
+
+int mars_mpu_run(mars_mpu_context_t *mpu, uint64_t params_ea)
+{
+	int ret;
+
+	ret = pthread_create(mpu, NULL, mpu_context_thread,
+			     (void *)(uintptr_t)params_ea);
+	if (ret)
+		return MARS_ERROR_INTERNAL;
+
+	return MARS_SUCCESS;
+}
+
+int mars_mpu_wait(mars_mpu_context_t *mpu)
+{
+	int ret;
+	void *p_ret;
+
+	ret = pthread_join(*mpu, &p_ret);
+	if (ret || p_ret)
+		return MARS_ERROR_INTERNAL;
+
+	return MARS_SUCCESS;
+}
--- a/core/src/host/lib/mutex.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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 <ppu_intrinsics.h>
-
-#include "config.h"
-
-#include "mars/core.h"
-#include "mars/error.h"
-#include "mars/mutex.h"
-
-int mars_mutex_create(uint64_t *mutex_ea_ret)
-{
-	struct mars_mutex *mutex;
-	uint64_t mutex_ea;
-
-	if (!mutex_ea_ret)
-		return MARS_ERROR_NULL;
-
-	mutex_ea = mars_ea_memalign(
-		MARS_MUTEX_ALIGN, sizeof(struct mars_mutex));
-	if (!mutex_ea)
-		return MARS_ERROR_MEMORY;
-
-	mutex = mars_ea_to_ptr(mutex_ea);
-
-	mutex->lock = MARS_MUTEX_UNLOCKED;
-	__lwsync();
-
-	*mutex_ea_ret = mutex_ea;
-
-	return MARS_SUCCESS;
-}
-
-int mars_mutex_destroy(uint64_t mutex_ea)
-{
-	if (!mutex_ea)
-		return MARS_ERROR_NULL;
-
-	mars_ea_free(mutex_ea);
-
-	return MARS_SUCCESS;
-}
-
-int mars_mutex_reset(uint64_t mutex_ea)
-{
-	struct mars_mutex *mutex = mars_ea_to_ptr(mutex_ea);
-
-	if (!mutex_ea)
-		return MARS_ERROR_NULL;
-
-	mutex->lock = MARS_MUTEX_UNLOCKED;
-	__lwsync();
-
-	return MARS_SUCCESS;
-}
-
-int mars_mutex_lock(uint64_t mutex_ea)
-{
-	struct mars_mutex *mutex = mars_ea_to_ptr(mutex_ea);
-
-	if (!mutex_ea) {
-		return MARS_ERROR_NULL;
-	}
-
-	do {
-		do {
-		} while (__lwarx(&mutex->lock) == MARS_MUTEX_LOCKED);
-	} while (!__stwcx(&mutex->lock, MARS_MUTEX_LOCKED));
-
-	__isync();
-
-	return MARS_SUCCESS;
-}
-
-int mars_mutex_unlock(uint64_t mutex_ea)
-{
-	struct mars_mutex *mutex = mars_ea_to_ptr(mutex_ea);
-
-	if (!mutex_ea)
-		return MARS_ERROR_NULL;
-	if (mutex->lock != MARS_MUTEX_LOCKED)
-		return MARS_ERROR_STATE;
-
-	__lwsync();
-	mutex->lock = MARS_MUTEX_UNLOCKED;
-
-	return MARS_SUCCESS;
-}
-
-int mars_mutex_lock_get(uint64_t mutex_ea, struct mars_mutex *mutex)
-{
-#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
-	int ret;
-	ret = mars_mutex_lock(mutex_ea);
-	if (ret != MARS_SUCCESS)
-		return ret;
-	mars_ea_get(mutex_ea, mutex, sizeof(struct mars_mutex));
-	return MARS_SUCCESS;
-#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-	(void)mutex; /* ignored */
-	return mars_mutex_lock(mutex_ea);
-#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-}
-
-int mars_mutex_unlock_put(uint64_t mutex_ea, struct mars_mutex *mutex)
-{
-#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
-	int ret;
-	mars_ea_put(
-		mutex_ea + offsetof(struct mars_mutex, pad),
-		mutex->pad, sizeof(mutex->pad));
-	ret = mars_mutex_unlock(mutex_ea);
-	if (ret == MARS_SUCCESS)
-		mutex->lock = MARS_MUTEX_UNLOCKED;
-	return ret;
-#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-	(void)mutex; /* ignored */
-	return mars_mutex_unlock(mutex_ea);
-#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
-}
--- /dev/null
+++ b/core/src/host/lib/mutex_cell.c
@@ -0,0 +1,155 @@
+/*
+ * 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 <ppu_intrinsics.h>
+
+#include "config.h"
+
+#include "mars/core.h"
+#include "mars/error.h"
+#include "mars/mutex.h"
+
+int mars_mutex_create(uint64_t *mutex_ea_ret)
+{
+	struct mars_mutex *mutex;
+	uint64_t mutex_ea;
+
+	if (!mutex_ea_ret)
+		return MARS_ERROR_NULL;
+
+	mutex_ea = mars_ea_memalign(
+		MARS_MUTEX_ALIGN, sizeof(struct mars_mutex));
+	if (!mutex_ea)
+		return MARS_ERROR_MEMORY;
+
+	mutex = mars_ea_to_ptr(mutex_ea);
+
+	mutex->lock = MARS_MUTEX_UNLOCKED;
+	__lwsync();
+
+	*mutex_ea_ret = mutex_ea;
+
+	return MARS_SUCCESS;
+}
+
+int mars_mutex_destroy(uint64_t mutex_ea)
+{
+	if (!mutex_ea)
+		return MARS_ERROR_NULL;
+
+	mars_ea_free(mutex_ea);
+
+	return MARS_SUCCESS;
+}
+
+int mars_mutex_reset(uint64_t mutex_ea)
+{
+	struct mars_mutex *mutex = mars_ea_to_ptr(mutex_ea);
+
+	if (!mutex_ea)
+		return MARS_ERROR_NULL;
+
+	mutex->lock = MARS_MUTEX_UNLOCKED;
+	__lwsync();
+
+	return MARS_SUCCESS;
+}
+
+int mars_mutex_lock(uint64_t mutex_ea)
+{
+	struct mars_mutex *mutex = mars_ea_to_ptr(mutex_ea);
+
+	if (!mutex_ea) {
+		return MARS_ERROR_NULL;
+	}
+
+	do {
+		do {
+		} while (__lwarx(&mutex->lock) == MARS_MUTEX_LOCKED);
+	} while (!__stwcx(&mutex->lock, MARS_MUTEX_LOCKED));
+
+	__isync();
+
+	return MARS_SUCCESS;
+}
+
+int mars_mutex_unlock(uint64_t mutex_ea)
+{
+	struct mars_mutex *mutex = mars_ea_to_ptr(mutex_ea);
+
+	if (!mutex_ea)
+		return MARS_ERROR_NULL;
+	if (mutex->lock != MARS_MUTEX_LOCKED)
+		return MARS_ERROR_STATE;
+
+	__lwsync();
+	mutex->lock = MARS_MUTEX_UNLOCKED;
+
+	return MARS_SUCCESS;
+}
+
+int mars_mutex_lock_get(uint64_t mutex_ea, struct mars_mutex *mutex)
+{
+#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
+	int ret;
+	ret = mars_mutex_lock(mutex_ea);
+	if (ret != MARS_SUCCESS)
+		return ret;
+	mars_ea_get(mutex_ea, mutex, sizeof(struct mars_mutex));
+	return MARS_SUCCESS;
+#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+	(void)mutex; /* ignored */
+	return mars_mutex_lock(mutex_ea);
+#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+}
+
+int mars_mutex_unlock_put(uint64_t mutex_ea, struct mars_mutex *mutex)
+{
+#ifdef MARS_ENABLE_DISCRETE_SHARED_MEMORY
+	int ret;
+	mars_ea_put(
+		mutex_ea + offsetof(struct mars_mutex, pad),
+		mutex->pad, sizeof(mutex->pad));
+	ret = mars_mutex_unlock(mutex_ea);
+	if (ret == MARS_SUCCESS)
+		mutex->lock = MARS_MUTEX_UNLOCKED;
+	return ret;
+#else /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+	(void)mutex; /* ignored */
+	return mars_mutex_unlock(mutex_ea);
+#endif /* !MARS_ENABLE_DISCRETE_SHARED_MEMORY */
+}






More information about the cbe-oss-dev mailing list