Index: soft/giet_vm/libs/barrier.c
===================================================================
--- soft/giet_vm/libs/barrier.c	(revision 159)
+++ soft/giet_vm/libs/barrier.c	(revision 160)
@@ -5,19 +5,10 @@
 // Copyright (c) UPMC-LIP6
 ///////////////////////////////////////////////////////////////////////////////////
-// The barrier.c and barrier.h files are part of the GIET nano-kernel.
+// These barrier.c and barrier.h files are part of the GIET nano-kernel.
 // This user-level library provides a synchronisation service between several
 // tasks sharing the same address space in a parallel multi-tasks application.
-//
-// The barrier_init(), and the barrier_wait() functions do not require a syscall.
-// The barrier itself must have been allocated in a non cacheable segment,
-// if the platform does not provide hardwate cache coherence.
-//
-// ALL barriers must be defined in the mapping_info data structure, 
-// to be initialised by the GIET in the boot phase.
-// The vobj_get_vbase() system call (defined in stdio.c and stdio.h files)
-// can be used to get the virtual base address of the barrier from it's name.
+// Neither the barrier_init(), nor the barrier_wait() function require a syscall.
+// The barrier itself must have been allocated in a shared data segment.
 ///////////////////////////////////////////////////////////////////////////////////
-
-#include <barrier.h>
 
 ///////////////////////////////////////////////////////////////////////////////////
Index: soft/giet_vm/libs/common.c
===================================================================
--- soft/giet_vm/libs/common.c	(revision 160)
+++ soft/giet_vm/libs/common.c	(revision 160)
@@ -0,0 +1,35 @@
+
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+void *memcpy(void *_dst, const void *_src, unsigned int size)
+{
+    unsigned int *dst = _dst;
+    const unsigned int *src = _src;
+    if ( ! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3) )
+        while (size > 3) {
+            *dst++ = *src++;
+            size -= 4;
+        }
+
+    unsigned char *cdst = (unsigned char*)dst;
+    unsigned char *csrc = (unsigned char*)src;
+
+    while (size--) {
+        *cdst++ = *csrc++;
+    }
+    return _dst;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+inline void * memset(void *dst, int s, unsigned int count)
+{
+	char *a = (char *) dst;
+	while (count--)
+		*a++ = (char)s;
+	return dst;
+}
Index: soft/giet_vm/libs/libsrl/srl_barrier.c
===================================================================
--- soft/giet_vm/libs/libsrl/srl_barrier.c	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_barrier.c	(revision 160)
@@ -0,0 +1,60 @@
+#include "srl_barrier.h"
+/*
+int srl_barrier_init(srl_barrier_t barrier)
+{
+
+    register int* pinit 	= (int*)&barrier->init_val;
+    register int* pcount 	= (int*)&barrier->count;
+
+    // parallel initialisation using atomic instructions LL/SC
+    asm volatile ("_barrier_init_test:          	\n"
+                  "ll   $2,     0(%0)           	\n"	// read initial value
+                  "bnez $2,     _barrier_init_done	\n"
+                  "move $3,     %2			\n"
+                  "sc   $3,     0(%0)    	      	\n"	// try to write initial value
+                  "beqz $3,     _barrier_init_test	\n"
+                  "move $3,	%2			\n"
+                  "sw   $3,	0(%1)			\n"	// write count
+				  "sync"
+                  "_barrier_init_done:			\n"
+                  ::"r"(pinit),"r"(pcount),"r"(value):"$2","$3");
+    return 0 ;
+}
+*/
+
+void srl_barrier_wait( srl_barrier_t barrier)
+{
+    register int* pcount 	= (int*)&barrier->count;
+    register int  maxcount 	= (int)barrier->init_val;
+    register int  count;
+
+    // parallel decrement barrier counter using atomic instructions LL/SC
+    // input : pointer on the barrier counter 
+    // output : counter value 
+    asm volatile ("_barrier_decrement:          		\n"
+                  "ll   %0,     0(%1)           		\n"
+                  "addi $3,     %0,     -1      		\n"
+                  "sc   $3,     0(%1)           		\n"
+                  "beqz $3,     _barrier_decrement		\n"
+                  :"=r"(count):"r"(pcount):"$2","$3");
+
+    // the last task re-initializes the barrier counter 
+    // to the max value, waking up all other waiting tasks
+
+//TODO:check it out
+    if ( count == 0 ) 	 // last task
+    {
+        //*pcount = maxcount;
+		asm volatile( "sw %0,	(%1)\n"
+					  "sync			\n"
+					  ::"r"(maxcount),"r"(pcount));
+        return ;
+    }
+    else 		// other tasks
+    {
+//        while ( *pcount != maxcount ) 	{ }	// busy waiting 
+		srl_sched_wait_eq(pcount, maxcount);	// busy waiting 
+        return ;
+    }
+
+}
Index: soft/giet_vm/libs/libsrl/srl_barrier.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_barrier.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_barrier.h	(revision 160)
@@ -0,0 +1,42 @@
+/*
+ * This file is part of DSX, development environment for static
+ * SoC applications.
+ * 
+ * This file is distributed under the terms of the GNU General Public
+ * License.
+ * 
+ * Copyright (c) 2006, Nicolas Pouillon, <nipo@ssji.net>
+ *     Laboratoire d'informatique de Paris 6 / ASIM, France
+ * 
+ *  $Id$
+ */
+
+#ifndef SRL_BARRIER_H_
+#define SRL_BARRIER_H_
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Barrier operations
+ */
+
+#include "stdio.h"
+#include "srl_log.h"
+#include "srl_sched_wait.h"
+
+
+typedef struct srl_abstract_barrier_s
+{
+	unsigned int init_val;
+	unsigned int count;
+	
+} srl_barrier_s;
+
+# define SRL_BARRIER_INITIALIZER(n){ .init_val=(n) , .count =(n)}
+
+typedef srl_barrier_s *srl_barrier_t;
+
+void srl_barrier_wait( srl_barrier_t barrier );
+
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_endianness.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_endianness.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_endianness.h	(revision 160)
@@ -0,0 +1,82 @@
+#ifndef SRL_ENDIANNESS_H_
+#define SRL_ENDIANNESS_H_
+
+#include "srl_public_types.h"
+
+/** @this reads a big endian 16 bits value */
+#  define endian_le16(x)	(x)
+/** @this reads a big endian 32 bits value */
+#  define endian_le32(x)	(x)
+/** @this reads a big endian 64 bits value */
+//#  define endian_le64(x)	(x)
+/** @this reads a little endian 16 bits value */
+#  define endian_be16(x)	endian_swap16(x)
+/** @this reads a little endian 32 bits value */
+#  define endian_be32(x)	endian_swap32(x)
+/** @this reads a little endian 64 bits value */
+//#  define endian_be64(x)	endian_swap64(x)
+
+/** @internal */
+static inline uint16_t endian_swap16(uint16_t x)
+{
+  return (x >> 8) | (x << 8);
+}
+
+/** @internal */
+static inline uint32_t endian_swap32(uint32_t x)
+{
+  return (((x >> 24) & 0x000000ff) |
+	  ((x >> 8 ) & 0x0000ff00) |
+	  ((x << 8 ) & 0x00ff0000) |
+	  ((x << 24) & 0xff000000));
+}
+
+/** @internal *//*
+static inline uint64_t __endian_swap64(uint64_t x)
+{
+  return (((uint64_t)endian_swap32(x      ) << 32) |
+	  ((uint64_t)endian_swap32(x >> 32)      ));
+}*/
+
+static inline uint32_t srl_uint32_le_to_machine(uint32_t x)
+{
+	return endian_le32(x);
+}
+
+static inline uint32_t srl_uint32_machine_to_le(uint32_t x)
+{
+	return endian_le32(x);
+}
+
+static inline uint32_t srl_uint32_be_to_machine(uint32_t x)
+{
+	return endian_be32(x);
+}
+
+static inline uint32_t srl_uint32_machine_to_be(uint32_t x)
+{
+	return endian_be32(x);
+}
+
+static inline uint16_t srl_uint16_le_to_machine(uint16_t x)
+{
+	return endian_le16(x);
+}
+
+static inline uint16_t srl_uint16_machine_to_le(uint16_t x)
+{
+	return endian_le16(x);
+}
+
+static inline uint16_t srl_uint16_be_to_machine(uint16_t x)
+{
+	return endian_be16(x);
+}
+
+static inline uint16_t srl_uint16_machine_to_be(uint16_t x)
+{
+	return endian_be16(x);
+}
+
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_hw_helpers.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_hw_helpers.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_hw_helpers.h	(revision 160)
@@ -0,0 +1,81 @@
+#ifndef SRL_HW_HELPERS_H
+#define SRL_HW_HELPERS_H
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Miscellaneous APIs
+ */
+
+#include "stdio.h"
+
+typedef struct __ldscript_symbol_s __ldscript_symbol_t;
+
+#define BASE_ADDR_OF(id) 									   \
+	({																   \
+		extern __ldscript_symbol_t _dsx_##id##_region_begin;		   \
+		(void*)&_dsx_##id##_region_begin;								   \
+	})
+
+
+/**
+   Standard API call, expands to nothing for this implementation.
+ */
+#define srl_busy_cycles(n) do{}while(0)
+
+//void useless(void *pointless,...){}
+/**
+   @this flushes the cache line containing the address.
+ */
+//TODO
+#define srl_dcache_flush_addr 0
+
+/*
+static inline cpu_dcache_invld(void *ptr){
+	 asm volatile (								
+        " cache %0, %1"							
+        : : "i" (0x11) , "R" (*(uint8_t*)(ptr))	
+        : "memory"								
+        );							
+}
+*/
+
+/**
+   @this flushes a memory zone from cache.
+ */
+//TODO
+//void dcache_flush(const void * addr, size_t size)
+#define srl_dcache_flush_zone dcache_flush
+
+/**
+   @this waits for at least the given time (in cycles). The actual
+   time spent in this call is not predictable.
+
+   @param time Number of cycles to wait for
+ */
+void srl_sleep_cycles( unsigned int time );
+
+/**
+   @this returns the absolute timestamp counter from the
+   initialization of the platform.
+
+   @return Cycles from the initialization of the system
+ */
+
+
+static inline unsigned int srl_cycle_count()
+{
+	return proctime();
+}
+
+/**
+   @this aborts the current execution. On most systems, @this will
+   simply hang.
+ */
+static inline void srl_abort()
+{
+	asm volatile ("break 0");
+	while(1);
+}
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_lock.c
===================================================================
--- soft/giet_vm/libs/libsrl/srl_lock.c	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_lock.c	(revision 160)
@@ -0,0 +1,46 @@
+#include "srl_lock.h"
+
+int srl_lock_lock(srl_lock_t slock )
+{
+   register int delay= rand();
+
+    asm volatile ("_locks_llsc:			        \n"
+                  "ll   $2,    0(%0)		    \n"	// $2 <= _locks_lock
+                  "bnez $2,    _locks_delay	    \n" // random delay if busy
+                  "li   $3,    1   			    \n"	// prepare argument for sc  
+                  "sc   $3,    0(%0)       	    \n" // try to set _locks_busy
+                  "bnez $3,    _locks_ok     	\n" // exit if atomic 
+                  "_locks_delay:				\n"
+                  "move $4,    %1			    \n"	// $4 <= delay
+                  "_locks_loop:				    \n"
+                  "addi $4,    $4,    -1	    \n"	// $4 <= $4 - 1
+                  "beqz $4,    _locks_loop	    \n"	// test end delay
+                  "j           _locks_llsc    	\n"	// retry
+                  "_locks_ok:			            \n"
+                  ::"r"(&(slock.lock)),"r"(delay):"$2","$3","$4");
+    return 0;
+}
+
+void srl_lock_unlock( srl_lock_t slock )
+{
+	asm volatile( "sw $0,	(%0)\n"
+				  "sync			  "
+				  ::"r"(&(slock.lock)));
+}
+
+int srl_lock_try_lock( srl_lock_t slock )
+{
+	register int ret = 0;	
+	asm volatile ("ll   $2,    0(%1)		    \n"	// $2 <= _locks_lock
+                  "bnez $2,    _lock_done	    \n" // exitif busy
+                  "li   $3,    1   			    \n"	// prepare argument for sc  
+                  "sc   $3,    0(%1)       	    \n" // try to set _locks_busy
+                  "add  %0, $0, $3       	    \n" // ret(exit) value
+                  "_lock_done:			        \n"
+                  :"=r"(ret)
+                  :"r"(&(slock.lock))
+                  :"$2","$3");
+    return ret;
+}
+
+
Index: soft/giet_vm/libs/libsrl/srl_lock.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_lock.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_lock.h	(revision 160)
@@ -0,0 +1,55 @@
+/*
+ * This file is part of DSX, development environment for static
+ * SoC applications.
+ * 
+ * This file is distributed under the terms of the GNU General Public
+ * License.
+ * 
+ * Copyright (c) 2006, Nicolas Pouillon, <nipo@ssji.net>
+ *     Laboratoire d'informatique de Paris 6 / ASIM, France
+ * 
+ *  $Id$
+ */
+
+#ifndef SRL_LOCK_H_
+#define SRL_LOCK_H_
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Lock operations
+ */
+
+#include "srl_public_types.h"
+#include "stdio.h"
+
+typedef struct {
+	unsigned int lock;
+}srl_lock_t;
+
+#define SRL_LOCK_INITIALIZER { 0 }
+
+/**
+   @this takes a lock.
+
+   @param lock The lock object
+ */
+int srl_lock_lock( srl_lock_t lock );
+
+/**
+   @this releases a l-ock.
+
+   @param lock The lock object
+ */
+void srl_lock_unlock( srl_lock_t lock );
+
+/**
+   @this tries to take a lock. @this returns whether the lock was
+   actually taken.
+
+   @param lock The lock object
+   @return 0 if the lock was taken successfully
+ */
+int srl_lock_try_lock( srl_lock_t lock );
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_log.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_log.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_log.h	(revision 160)
@@ -0,0 +1,79 @@
+/*
+ * This file is part of DSX, development environment for static
+ * SoC applications.
+ * 
+ * This file is distributed under the terms of the GNU General Public
+ * License.
+ * 
+ * Copyright (c) 2006, Nicolas Pouillon, <nipo@ssji.net>
+ *     Laboratoire d'informatique de Paris 6 / ASIM, France
+ * 
+ *  $Id$
+ */
+
+#ifndef SRL_LOG_H_
+#define SRL_LOG_H_
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Debug messages
+ */
+
+#include "stdio.h"
+#include "giet_config.h"
+#include "srl_hw_helpers.h"
+
+/** @internal */
+enum __srl_verbosity {
+    VERB_NONE,
+    VERB_TRACE,
+    VERB_DEBUG,
+    VERB_MAX,
+};
+
+
+void _srl_log(const char *);
+void _srl_log_printf(const char *, ...);
+
+#define GET_VERB_(x,y) x##y
+#define GET_VERB(x) GET_VERB_(VERB_,x)
+
+/**
+   @this prints a message if the current verbosity is sufficient.
+
+   @param l Minimal verbosity of the message
+   @param c Message to print
+ */
+#define srl_log( l, c ) do {										   \
+		if (GET_VERB(l) <= GET_VERB(CONFIG_SRL_VERBOSITY)) {		   \
+            tty_printf(c);                                             \
+		}															   \
+	} while (0)
+
+/**
+   @this prints a message if the current verbosity is sufficient.
+
+   @param l Minimal verbosity of the message
+   @param c Message to print, with a printf-like syntax
+ */
+#define srl_log_printf( l, ... ) do {                                   \
+		if (GET_VERB(l) <= GET_VERB(CONFIG_SRL_VERBOSITY)) {		    \
+            tty_printf(__VA_ARGS__);                                    \
+		}															    \
+	} while (0)
+
+/**
+   @this is the same as @ref #assert.
+    TODO change the location?
+ */
+#define srl_assert(expr)												\
+    do {																\
+        if ( ! (expr) ) {												\
+            srl_log_printf(NONE, "assertion (%s) failed on %s:%d !\n",  \
+						   #expr, __FILE__, __LINE__ );					\
+            srl_abort();													\
+        }																\
+    } while(0)
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_memspace.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_memspace.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_memspace.h	(revision 160)
@@ -0,0 +1,45 @@
+#ifndef SRL_MEMSPACE_H
+#define SRL_MEMSPACE_H
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Memory resources
+ */
+
+/**
+   @internal
+ */
+typedef struct srl_memspace_s {
+	void *buffer;
+	uint32_t size;
+} srl_memspace_s;
+
+/**
+   The memspace abstract type.
+ */
+typedef struct srl_memspace_s *srl_memspace_t;
+
+#define SRL_MEMSPACE_INITIALIZER( b, s ) \
+{\
+	.buffer = b,\
+		 .size = s,\
+		 }
+
+/**
+   @this retrieves the base address of a memspace
+
+   @param memsp The memspace
+   @return the base address of the memspace
+ */
+#define SRL_MEMSPACE_ADDR(memsp) ((memsp)->buffer)
+
+/**
+   @this retrieves the size of a memspace
+
+   @param memsp The memspace
+   @return the size of the memspace
+ */
+#define SRL_MEMSPACE_SIZE(memsp) ((memsp)->size)
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_mwmr.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_mwmr.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_mwmr.h	(revision 160)
@@ -0,0 +1,22 @@
+#ifndef SRL_MWMR_H_
+#define SRL_MWMR_H_
+
+#include "mwmr.h"
+
+#define  srl_mwmr_t mwmr_channel_t*
+
+#define srl_mwmr_write mwmr_write
+#define srl_mwmr_read mwmr_read  
+
+
+
+
+
+
+
+
+
+
+
+
+#endif //fin de SRL_MWMR_H_
Index: soft/giet_vm/libs/libsrl/srl_private_types.c
===================================================================
--- soft/giet_vm/libs/libsrl/srl_private_types.c	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_private_types.c	(revision 160)
@@ -0,0 +1,59 @@
+#include "srl_private_types.h"
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+void *memcpy(void *_dst, const void *_src, unsigned int size)
+{
+    unsigned int *dst = _dst;
+    const unsigned int *src = _src;
+    if ( ! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3) )
+        while (size > 3) {
+            *dst++ = *src++;
+            size -= 4;
+        }
+
+    unsigned char *cdst = (unsigned char*)dst;
+    unsigned char *csrc = (unsigned char*)src;
+
+    while (size--) {
+        *cdst++ = *csrc++;
+    }
+    return _dst;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+//  mempcy()
+// GCC requires this function. Taken from MutekH.
+////////////////////////////////////////////////////////////////////////////////////////
+inline void * memset(void *dst, int s, size_t count)
+{
+/*
+  int8_t s = _s;
+  const reg_t v = (uint8_t)s * (reg_t)0x0101010101010101LL;
+  int8_t *a = dst;
+  reg_t *r;
+
+  // align 
+  while ( ((uintptr_t *)a & reg_t_log2_m1) && count )
+    count--, *a++ = s;
+
+  size_t ucount = count & reg_t_log2_m1;
+  count &= ~reg_t_log2_m1;
+
+  for (r = (reg_t*)a; count; count -= sizeof(reg_t))
+      *r++ = v;
+
+  for (a = (int8_t*)r; ucount; ucount--)
+      *a++ = s;
+
+*/
+	char *a = (char *) dst;
+	while (count--){
+		*a++ = (char)s;
+	}
+
+	return dst;
+}
Index: soft/giet_vm/libs/libsrl/srl_private_types.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_private_types.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_private_types.h	(revision 160)
@@ -0,0 +1,101 @@
+#ifndef SRL_PRIVATE_TYPES_H
+#define SRL_PRIVATE_TYPES_H
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Abstract types definitions
+ */
+
+#include "stdio.h"
+#include "srl_barrier.h"
+#include "srl_public_types.h"
+
+#define TTY_INC 16
+
+/**
+   A numeric constant holder
+ */
+typedef unsigned int srl_const_t;
+#define SRL_CONST_INITIALIZER(x) x
+
+typedef void srl_task_func_t( void* );
+
+typedef struct srl_abstract_task_s {
+	srl_task_func_t *bootstrap;
+	srl_task_func_t *func;
+	void *args;
+	void *stack;
+	size_t stack_size;
+	const char *name;
+//	uint32_t context[CONTEXT_WSIZE];
+	sint32_t wait_val;
+	void *wait_addr;
+	size_t tty_addr;
+}srl_task_s;
+
+#define SRL_TASK_INITIALIZER(b, f, ss, s, a, n, ttyc, ttyn)	\
+	{														\
+		.bootstrap = (srl_task_func_t *)b,					\
+		.func = (srl_task_func_t *)f,						\
+		.args = (void*)a,									\
+		.stack = (void*)s,									\
+		.stack_size = ss,									\
+		.name = n,											\
+		.tty_addr = (size_t)ttyc + (ttyn * TTY_INC),		\
+	}
+
+
+typedef struct srl_abstract_cpudesc_s srl_cpudesc_s;
+struct srl_abstract_cpudesc_s {
+	const size_t ntasks;
+	const srl_task_s * const *task_list;
+	size_t tty_addr;
+};
+
+#define SRL_CPUDESC_INITIALIZER(nt, tl, ttyc, ttyn)	\
+	{												\
+		.ntasks = nt,								\
+		.task_list = tl,							\
+		.tty_addr = (size_t)ttyc + (ttyn * TTY_INC),\
+	}
+
+typedef struct srl_abstract_appdesc_s srl_appdesc_s;
+struct srl_abstract_appdesc_s {
+	const size_t ntasks;
+	srl_barrier_s *start;
+	const struct srl_mwmr_s * const *mwmr;
+	const srl_cpudesc_s * const *cpu;
+	const srl_task_s * const *task;
+	size_t tty_addr;
+};
+
+#define SRL_APPDESC_INITIALIZER(nt, cl, ml, tl, sb, ttyc, ttyn) \
+	{														   \
+		.ntasks = nt,										   \
+		.cpu = cl,										       \
+		.mwmr = ml,										       \
+		.task = tl,										       \
+		.start = sb,										   \
+		.tty_addr = (size_t)ttyc + (ttyn * TTY_INC),						\
+	}
+
+//needed by gcc
+void *memcpy(void *_dst, const void *_src, unsigned int size);
+void * memset(void *dst, int data, size_t size);
+
+
+/**
+ * All function needed by kmain has to be tagged with in_srl_main
+ * typically: srl_mwmw_sys
+ */
+#define in_srl_main __attribute__((section (".srl_main")))
+
+/**
+ * copy to the cache avoiding the optimisations done the compiler (volatile)
+ */
+#define cpu_mem_write_32(addr, data) *((volatile uint32_t*)(addr)) = data 
+
+#define uintptr_t unsigned int
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_public_types.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_public_types.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_public_types.h	(revision 160)
@@ -0,0 +1,42 @@
+#ifndef SRL_PUBLIC_TYPES_H
+#define SRL_PUBLIC_TYPES_H
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Abstract types definitions
+ */
+
+typedef unsigned long       uint_t;
+typedef signed long         sint_t;
+
+typedef unsigned char       uint8_t;
+typedef signed char         sint8_t;
+typedef signed short int    int8_t;
+
+typedef unsigned short int  uint16_t;
+typedef signed short int    sint16_t;
+typedef signed short int    int16_t;
+
+typedef unsigned int        uint32_t;
+typedef signed int          sint32_t;
+typedef signed int          int32_t;
+
+typedef sint32_t            error_t;
+typedef uint_t              bool_t;
+
+typedef void *srl_buffer_t;
+
+
+#ifndef NULL
+#define NULL                (void*)0
+#endif
+
+/** Get integer minimum value */
+#define __MIN(a, b) ({ const typeof(a) __a = (a); const typeof(b) __b = (b); __b < __a ? __b : __a; })
+    
+/** Get integer maximum value */
+#define __MAX(a, b) ({ const typeof(a) __a = (a); const typeof(b) __b = (b); __b > __a ? __b : __a; })
+
+
+#endif
Index: soft/giet_vm/libs/libsrl/srl_sched_wait.c
===================================================================
--- soft/giet_vm/libs/libsrl/srl_sched_wait.c	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_sched_wait.c	(revision 160)
@@ -0,0 +1,70 @@
+/*
+ * This file is part of MutekH.
+ * 
+ * MutekH is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 of the License.
+ * 
+ * MutekH is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with MutekH; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2008
+ */
+
+#include "srl_private_types.h"
+#include "srl_sched_wait.h"
+#include "srl_hw_helpers.h"
+#include "stdio.h"
+
+#define endian_cpu32(x) (x)
+
+#define DECLARE_WAIT(name, cmp)                                              \
+                                                                                         \
+    void srl_sched_wait_##name( void *addr, sint32_t val )				\
+    {			                                                                        \
+		dcache_flush(addr, sizeof(addr));												\
+        if ( ((sint32_t)*((unsigned int *)addr)) cmp val )			\
+        return;                                                                          \
+        do {                                                                             \
+            context_switch();															\
+			dcache_flush(addr, sizeof(addr));											\
+        } while (((sint32_t)*((unsigned int*)addr)) cmp val );		\
+    }
+
+
+
+DECLARE_WAIT(eq, ==)
+
+DECLARE_WAIT(ne, !=)
+
+DECLARE_WAIT(le, <=)
+
+DECLARE_WAIT(ge, >=)
+
+DECLARE_WAIT(lt, <)
+
+DECLARE_WAIT(gt, >)
+
+void srl_sched_wait_priv(uint32_t date )
+{
+	do{
+		context_switch();
+	}while (srl_cycle_count() > date);
+}
+
+void srl_sleep_cycles( uint32_t n )
+{
+	uint32_t next_run_to = srl_cycle_count()+n;
+
+	while(srl_cycle_count() < next_run_to)
+		srl_sched_wait_priv(next_run_to);
+}
+
Index: soft/giet_vm/libs/libsrl/srl_sched_wait.h
===================================================================
--- soft/giet_vm/libs/libsrl/srl_sched_wait.h	(revision 160)
+++ soft/giet_vm/libs/libsrl/srl_sched_wait.h	(revision 160)
@@ -0,0 +1,39 @@
+#ifndef SRL_SCHED_WAIT_H
+#define SRL_SCHED_WAIT_H
+
+#include "srl_public_types.h"
+
+/**
+ * @file
+ * @module{SRL}
+ * @short Smart waiting tools
+ */
+
+#define DECLARE_WAIT(name, cmp)                                       \
+/**                                                                           \
+   @this makes the current task sleep until the value pointed at @tt addr     \
+   asserts the following test:                                                \
+                                                                              \
+   @code                                                                      \
+   (*addr cmp val)                                                            \
+   @end code                                                                  \
+                                                                              \
+   @param addr The address to poll                                            \
+   @param val The value to compare to                                         \
+*/                                                                            \
+                                                                              \
+void srl_sched_wait_##name(void *addr, sint32_t val );
+
+DECLARE_WAIT(eq, ==)
+DECLARE_WAIT(ne, !=)
+DECLARE_WAIT(le, <=)
+DECLARE_WAIT(ge, >=)
+DECLARE_WAIT(lt, <)
+DECLARE_WAIT(gt, >)
+
+#undef DECLARE_WAIT
+
+
+void srl_sleep_cycles( unsigned int n );
+
+#endif
Index: soft/giet_vm/libs/mwmr.c
===================================================================
--- soft/giet_vm/libs/mwmr.c	(revision 160)
+++ soft/giet_vm/libs/mwmr.c	(revision 160)
@@ -0,0 +1,228 @@
+//////////////////////////////////////////////////////////////////////////////////
+// File     : mwmr.c         
+// Date     : 01/04/2012
+// Author   : alain greiner
+// Copyright (c) UPMC-LIP6
+///////////////////////////////////////////////////////////////////////////////////
+// The mwmr.c and mwmr.h files are part of the GIET nano-kernel.
+// This  middlewre implements a user level Multi-Writers / Multi-Readers
+// communication channel, that can be sued by parallel multi-tasks applications
+// respecting the TCG (Tasks and Communications Graph) formalism.
+// 
+// The mwmr_read() and mwmr_write() functions do not require a system call,
+//
+// The mwmr_get_base() returns the virtual base address of the MWMR channel. 
+// As this function requires a system call, it is defined in the stdio.c and
+// stdio.h files.
+//
+// ALL MWMR channels must be defined in the mapping_info data structure, 
+// to be initialised by the GIET in the boot phase.
+// The max number of words that can be stored in a MWMR channel is defined by the
+// depth parameter, but all MWMR channels are implemented as fixed size buffers,
+// and the size is defined by the GIET_MWMR_SIZE_MAX configuration parameter.
+// An MWMR transaction is an integer number of unsigned int (32 bits mwords).
+// Both the mwmr_read() and mwmr_write() functions are blocking functions. 
+// A private lock provides exclusive access to the MWMR channel, that can have
+// a variable number of producers and a variable number of consumers.
+///////////////////////////////////////////////////////////////////////////////////
+
+#include <mwmr.h>
+#include <stdio.h>
+
+#define MWMR_PART
+//#define MWMR_DEBUG_READ
+//#define MWMR_DEBUG_WRITE
+
+///////////////////////////////////////////////////////////////////////////////////
+//	mwmr_lock_acquire()
+// We use a fixed delay befor retry, in order to avoid the system call
+// associated to the rand() function.
+// This is probably a weakness, that can be improved...
+///////////////////////////////////////////////////////////////////////////////////
+inline void mwmr_lock_acquire(unsigned int* lock)
+{
+    asm volatile (
+            "lock_try:              \n"
+            "ll   $2,    0(%0)      \n" /* $2 <= lock current value */
+            "bnez $2,    lock_delay \n" /* retry if lock already taken */
+            "li   $3,    1          \n" /* $3 <= argument for sc */
+            "sc   $3,    0(%0)      \n" /* try to get lock */
+            "bnez $3,    lock_ok    \n" /* exit if atomic */
+            "lock_delay:            \n"
+            "li   $4,    100        \n" /* $4 <= delay */
+            "lock_loop:             \n"
+            "addi $4,    $4,  -1    \n" /* $4 <= $4 - 1 */
+            "beqz $4,    lock_loop  \n" /* test end delay */
+            "nop                    \n"
+            "j           lock_try   \n" /* retry if not atomic */
+            "nop                    \n"
+            "lock_ok:               \n"
+            :
+            :"r"(lock)
+            :"$2", "$3", "$4");
+} 
+
+inline void print_state( mwmr_channel_t* mwmr)
+{
+
+    tty_printf("PTR %d", mwmr->ptr);
+    tty_printf("/PTW %d", mwmr->ptw);
+    tty_printf("/STS %d", mwmr->sts);
+    tty_printf("/DEPTH %d", mwmr->depth);
+    tty_printf("/LOCK %d\n", mwmr->lock);
+
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//	mwmr_write()
+// This blocking function returns only when the transfer is completed.
+// It takes the lock for exclusive access before testing the channel state.
+// If there is not enough space in mwmr channel to write nwords words,
+// it writes as many words as possible, release the lock, and retry after 
+// a random delay.
+//////////////////////////////////////////////////////////////////////////////
+void mwmr_write( mwmr_channel_t*   	mwmr, 
+                 unsigned int*		buffer,
+                 unsigned int 		nwords )
+{
+    unsigned int	x;
+    unsigned int	spaces;
+
+    while(1)
+    {
+        // get the lock
+        mwmr_lock_acquire((unsigned int*)&mwmr->lock);
+#ifdef MWMR_DEBUG_WRITE
+tty_printf("write: lock done\n");
+print_state(mwmr);
+#endif
+
+        // compute number of empty slots
+        spaces = mwmr->depth - mwmr->sts;
+
+        if( spaces >= nwords ) 	// write nwords, release lock and return
+        {
+            for ( x = 0 ; x < nwords ; x++ )  
+            {
+                mwmr->data[mwmr->ptw] = buffer[x];
+                mwmr->ptw  = (mwmr->ptw + 1) % mwmr->depth;
+#ifdef MWMR_DEBUG_WRITE
+tty_printf("/PTW %d\n", mwmr->ptw);
+#endif
+            }
+            mwmr->sts  = mwmr->sts + nwords;
+#ifdef MWMR_DEBUG_WRITE
+tty_printf("write done\n");
+print_state(mwmr);
+#endif
+            mwmr->lock = 0;
+            return;
+        }
+        else if ( spaces == 0 )	// release lock and retry after delay
+        {
+            mwmr->lock = 0;
+            for ( x = rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );
+        }
+        else		// write spaces, release lock and retry after delay
+        {
+#ifdef MWMR_PART
+            for ( x = 0 ; x < spaces ; x++ )  
+            {
+                mwmr->data[mwmr->ptw] = buffer[x];
+                mwmr->ptw  = (mwmr->ptw + 1) % mwmr->depth;
+            }
+            mwmr->sts  = mwmr->depth;
+            nwords     = nwords - spaces;
+            buffer     = buffer + spaces;
+#ifdef MWMR_DEBUG_WRITE
+tty_printf("write part done\n");
+print_state(mwmr);
+#endif
+#endif
+            mwmr->lock = 0;
+        }
+
+        // random delay before retry
+        for ( x = rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );
+    }
+} 
+
+
+//////////////////////////////////////////////////////////////////////////////
+//	mwmr_read()
+// This blocking function returns only when the transfer is completed.
+// It takes the lock for exclusive access before testing the channel state.
+// If there is not enough data in mwmr channel to read nwords words,
+// it reads as many words as possible, release the lock, and retry after 
+// a random delay.
+//////////////////////////////////////////////////////////////////////////////
+void mwmr_read( mwmr_channel_t*    	mwmr, 
+                unsigned int*		buffer,
+                unsigned int 		nwords )
+{
+    unsigned int	x;
+    unsigned int	dispos;
+
+    while(1)
+    {
+        // get the lock
+        mwmr_lock_acquire((unsigned int*)&mwmr->lock);
+
+#ifdef MWMR_DEBUG_READ
+tty_printf("lock done\n");
+print_state(mwmr);
+#endif
+
+        // compute number of available words
+        dispos = mwmr->sts;
+
+        if( dispos >= nwords ) 	// read nwords, release lock and return
+        {
+            for ( x = 0 ; x < nwords ; x++ )  
+            {
+                buffer[x] = mwmr->data[mwmr->ptr];
+                mwmr->ptr  = (mwmr->ptr + 1) % mwmr->depth;
+#ifdef MWMR_DEBUG_WRITE
+tty_printf("PTR %d\n", mwmr->ptr);
+#endif
+            }
+            mwmr->sts  = mwmr->sts - nwords;
+#ifdef MWMR_DEBUG_READ
+tty_printf("read done\n");
+print_state(mwmr);
+#endif
+            mwmr->lock = 0;
+            return;
+        }
+        else if ( dispos == 0 )	// release lock and retry after delay
+        {
+            mwmr->lock = 0;
+            for ( x = rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );
+        }
+        else		// read dispos, release lock and retry after delay
+        {
+#ifdef MWMR_PART
+            for ( x = 0 ; x < dispos ; x++ )  
+            {
+                buffer[x] = mwmr->data[mwmr->ptr];
+                mwmr->ptr  = (mwmr->ptr + 1) % mwmr->depth;
+            }
+            mwmr->sts  = 0;
+            nwords     = nwords - dispos;
+            buffer     = buffer + dispos;
+
+#ifdef MWMR_DEBUG_READ
+tty_printf("read part done\n");
+print_state(mwmr);
+#endif
+
+#endif
+            mwmr->lock = 0;
+        }
+
+        // random delay before retry
+        for ( x = rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );
+    }
+} 
+
Index: soft/giet_vm/libs/mwmr.h
===================================================================
--- soft/giet_vm/libs/mwmr.h	(revision 160)
+++ soft/giet_vm/libs/mwmr.h	(revision 160)
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////////////
+// File     : mwmr.h         
+// Date     : 01/04/2012
+// Author   : alain greiner
+// Copyright (c) UPMC-LIP6
+///////////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MWMR_H_
+#define _MWMR_H_
+
+///////////////////////////////////////////////////////////////////////////////////
+//  MWMR channel structure
+// The data array size is defined to obtain sizeof(mwmr_channel_t) = 4096 bytes.
+// The actual size can be redefined in the mapping info data structure.
+///////////////////////////////////////////////////////////////////////////////////
+
+typedef struct mwmr_channel_s {
+    unsigned int	ptr;		// index of the first valid data 
+    unsigned int	ptw;		// index of the first empty slot 
+    unsigned int	sts;		// number of words available
+    unsigned int 	depth;		// max number of words		
+    unsigned int	lock;		// exclusive access lock
+    unsigned int	data[1019];	// circular buffer
+} mwmr_channel_t;
+
+
+//////////////////////////////////////////////////////////////////////////////
+//  MWMR access functions
+//////////////////////////////////////////////////////////////////////////////
+
+void mwmr_write( mwmr_channel_t*	mwmr, 
+                 unsigned int*		buffer,
+                 unsigned int 		nwords );
+
+void mwmr_read( mwmr_channel_t*   	mwmr, 
+                unsigned int*		buffer,
+                unsigned int 		nwords );
+#endif
+
Index: soft/giet_vm/libs/srl.h
===================================================================
--- soft/giet_vm/libs/srl.h	(revision 160)
+++ soft/giet_vm/libs/srl.h	(revision 160)
@@ -0,0 +1,40 @@
+#ifndef SRL_H_
+#define SRL_H_
+
+/**
+   @file
+   @module{SRL}
+   @short SRL Api main header
+ */
+
+#include "libsrl/srl_public_types.h"
+//#include "libsrl/srl_private_types.h"
+
+#include "libsrl/srl_lock.h"
+#include "libsrl/srl_mwmr.h"
+#include "libsrl/srl_log.h"
+#include "libsrl/srl_barrier.h"
+#include "libsrl/srl_memspace.h"
+
+#include "libsrl/srl_hw_helpers.h"
+
+//kernel use!
+//#include "libsrl/srl_mwmr_sys.h"
+
+/* port, APP_NAME, TASK */
+# define GET_MWMR(port)                                                                       \
+({                                                                                            \
+    srl_mwmr_t	_mwmr;                                                                      \
+    if( vobj_get_vbase( APP_NAME , #port, MWMR, (unsigned int*)&_mwmr ) )                   \
+    {                                                                                         \
+        srl_log_printf( NONE, "\n[ERROR] in "TASK" task :\n");                              \
+        srl_log_printf( NONE, "          undefined <"#port"> channel: %d\n", _mwmr);           \
+        srl_log_printf( TRACE, "*** &"#port" = %x\n\n", (unsigned int)_mwmr );                 \
+        exit();/*srl?*/                                                                     \
+    }else                                                                                         \
+        srl_log_printf( TRACE, "%s:%d: arg of %s for %s,from %s; &"#port" = %x\n\n", __FILE__, __LINE__, APP_NAME, TASK,#port, (unsigned int)_mwmr ); \
+    _mwmr;\
+})
+
+#endif
+
Index: soft/giet_vm/libs/stdio.c
===================================================================
--- soft/giet_vm/libs/stdio.c	(revision 159)
+++ soft/giet_vm/libs/stdio.c	(revision 160)
@@ -34,5 +34,5 @@
 #define SYSCALL_IOC_READ        0x16
 #define SYSCALL_IOC_COMPLETED   0x17
-#define SYSCALL_MWMR_BASE	0x1A
+#define SYSCALL_VOBJ_GET_VBASE	0x1A
 
 //////////////////////////////////////////////////////////////////////////////////
@@ -720,4 +720,5 @@
 //////////////////////////////////////////////////////////////////////////////////
 // 	mwmr_base()
+// 	TODO!
 // This function returns in argument buffer the virtual base address 
 // of a MWMR communication channel, identified by the two arguments
@@ -726,15 +727,14 @@
 // must be declared in the mapping_info data structure to be initialised
 // in the boot phase.
-// - Returns 0 if success, > 0 if error ( channel not defined )
-//////////////////////////////////////////////////////////////////////////////////
-unsigned int mwmr_base( char* 		vspace_name,
-                        char*		mwmr_name,
-                        void*		buffer )
-{
-    return sys_call(SYSCALL_MWMR_BASE, 
+// - Returns the address if success,  0 if error ( channel not defined )
+//////////////////////////////////////////////////////////////////////////////////
+unsigned int vobj_get_vbase( char* vspace_name, char* vobj_name,
+                        unsigned int vobj_type, unsigned int* vobj_buffer)
+{
+    return sys_call(SYSCALL_VOBJ_GET_VBASE, 
                     (unsigned int)vspace_name,
-                    (unsigned int)mwmr_name,
-                    (unsigned int)buffer,
-                    0);
+                    (unsigned int)vobj_name,
+                    (unsigned int)vobj_type,
+                    (unsigned int)vobj_buffer);
 }
 ////////////////////////////////////////////////////////////////////////////////////
Index: soft/giet_vm/libs/stdio.h
===================================================================
--- soft/giet_vm/libs/stdio.h	(revision 159)
+++ soft/giet_vm/libs/stdio.h	(revision 160)
@@ -8,4 +8,6 @@
 #ifndef _STDIO_H
 #define _STDIO_H
+
+#include <mapping_info.h>
 
 /* MIPS32 related functions */
@@ -57,5 +59,6 @@
 unsigned int rand();
 unsigned int ctx_switch();
-unsigned int mwmr_base(char* vspace_name, char* mwmr_name, void* buffer);
+unsigned int vobj_get_vbase( char* vspace_name, char* vobj_name,
+                        unsigned int vobj_type, unsigned int* vobj_buffer);
 
 /*
