[Cbe-oss-dev] [PATCH 02/17]MARS/core: Dont use embedspu

Yuji Mano yuji.mano at am.sony.com
Wed Dec 3 13:58:42 EST 2008


From: Kazunori Asayama <asayama at sm.sony.co.jp>

Stop using embedspu script (core)

This patch stops using embedspu script and embed MPU's ELFs in host's
binaries just as byte streams. This change is a preparation for hybrid
systems.

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>
---
 core/README                   |    2 --
 core/src/host/configure.ac.in |    2 --
 core/src/host/lib/Makefile.am |   24 +++++++++++-------------
 core/src/host/lib/context.c   |    8 ++++++--
 4 files changed, 17 insertions(+), 19 deletions(-)

Index: b/core/README
===================================================================
--- a/core/README	2008-11-27 17:51:44.000000000 +0900
+++ b/core/README	2008-11-27 19:07:31.000000000 +0900
@@ -90,7 +90,6 @@ For example, when using the Cell SDK too
 -------------------
   ./configure \
     --with-mars-platform=cell \
-    PPU_EMBEDSPU=ppu-embedspu \
     PPU_CC=ppu-gcc PPU_CFLAGS="-O3 -funroll-loops -m32" \
     SPU_CC=spu-gcc SPU_CFLAGS="-O3 -funroll-loops"
 
@@ -99,7 +98,6 @@ For example, when using the Cell SDK too
   ./configure \
     --libdir="/usr/lib64" \
     --with-mars-platform=cell \
-    PPU_EMBEDSPU=ppu-embedspu \
     PPU_CC=ppu-gcc PPU_CFLAGS="-O3 -funroll-loops -m64" \
     SPU_CC=spu-gcc SPU_CFLAGS="-O3 -funroll-loops"
 
Index: b/core/src/host/configure.ac.in
===================================================================
--- a/core/src/host/configure.ac.in	2008-11-27 17:51:44.000000000 +0900
+++ b/core/src/host/configure.ac.in	2008-11-27 19:07:31.000000000 +0900
@@ -42,8 +42,6 @@ AC_CONFIG_MARS_HOST
 
 AC_CONFIG_AUX_DIR([.])
 
-AC_CHECK_TOOL([EMBEDSPU], [embedspu], [embedspu-not-found])
-
 AC_PROG_LIBTOOL
 AM_INIT_AUTOMAKE
 AC_SUBST([DESTDIR])
Index: b/core/src/host/lib/Makefile.am
===================================================================
--- a/core/src/host/lib/Makefile.am	2008-11-27 17:51:44.000000000 +0900
+++ b/core/src/host/lib/Makefile.am	2008-11-27 19:17:37.000000000 +0900
@@ -99,19 +99,15 @@ libmars_core_la_SOURCES = \
 	mutex.c \
 	workload_queue.c
 
-nodist_libmars_core_la_SOURCES = mars_kernel.eo
+nodist_libmars_core_la_SOURCES = \
+	mars_kernel.c
 
-libmars_core_la_DEPENDENCIES = mars_kernel.eo
-
-mars_kernel.eo: ${MARS_KERNEL}
-	@mkdir -p .libs
-	$(EMBEDSPU) $(CFLAGS) mars_kernel_entry  $< $@
-	$(EMBEDSPU) $(CFLAGS) -fPIC -DPIC mars_kernel_entry  $< .libs/$@
-
-.eo.lo:
-	@echo "# Generated by ltmain.sh - GNU libtool" > $@
-	@echo "pic_object='.libs/"$<"'" >> $@
-	@echo "non_pic_object='"$<"'" >> $@
+mars_kernel.c: ${MARS_KERNEL}
+	echo '__attribute__((aligned(128))) const unsigned char mars_kernel_entry[] = {' > $@.tmp
+	od -v -A n -t x1 ${MARS_KERNEL} | \
+		sed -e 's/  */,0x/g' -e 's/^,//' -e 's/ *$$/,/' >> $@.tmp
+	echo '};' >> $@.tmp
+	mv -f $@.tmp $@
 
 # library version-info rules (current:revision:age):
 # * increment 'current', if API is changed and compatibility is broken.
@@ -126,4 +122,6 @@ libmars_core_la_LDFLAGS = \
 
 libmars_core_la_LIBADD = -lspe2
 
-CLEANFILES = *.eo *.map
+BUILT_SOURCES = mars_kernel.c
+
+CLEANFILES = mars_kernel.c *.eo *.map
Index: b/core/src/host/lib/context.c
===================================================================
--- a/core/src/host/lib/context.c	2008-11-27 17:51:44.000000000 +0900
+++ b/core/src/host/lib/context.c	2008-11-27 19:07:31.000000000 +0900
@@ -50,7 +50,7 @@
 #include "context_internal_types.h"
 #include "kernel_internal_types.h"
 
-extern struct spe_program_handle mars_kernel_entry;
+extern const unsigned char mars_kernel_entry[];
 static struct mars_context *mars_shared_context;
 static pthread_mutex_t mars_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -87,12 +87,16 @@ static void *mpu_context_thread(void *ar
 	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;
 
-	ret = spe_program_load(spe, &mars_kernel_entry);
+	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;






More information about the cbe-oss-dev mailing list