Changeset 178 for soft/giet_vm
- Timestamp:
- Jul 22, 2012, 12:06:11 PM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 1 added
- 3 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r177 r178 43 43 mwmr_channel.o \ 44 44 barrier.o \ 45 spin_lock.o \ 46 common.o 45 spin_lock.o 47 46 48 47 LIB_OBJS = $(patsubst %,$(LIB_DIR)/%,$(LIB_OBJS_LIST)) -
soft/giet_vm/apps/compile.mk
r177 r178 10 10 11 11 %.o: %.c 12 $(CC) $(APP_INCLUDE) $(CFLAGS)-c -o $@ $<13 $(DU) -D $@> $@.txt12 $(CC) $(APP_INCLUDE) $(CFLAGS) -I. -c -o $@ $< 13 $(DU) -D $@ > $@.txt 14 14 15 15 clean: -
soft/giet_vm/libs/common.h
r176 r178 1 1 ////////////////////////////////////////////////////////////////////////////////// 2 // File : common.h3 // Date : 20/07/20124 // Author: mohamed karaoui2 // File : common.h 3 // Date : 20/07/2012 4 // Maintener : mohamed karaoui 5 5 // Copyright (c) UPMC-LIP6 6 6 /////////////////////////////////////////////////////////////////////////////////// … … 8 8 #ifndef _COMMON_H_ 9 9 #define _COMMON_H_ 10 11 /* 12 * memcpy, memset function 13 * This function is required because it can be gnerated by GCC 14 * during compilation so we must provide it. 15 * Code taken from MutekH. 16 */ 17 ////////////////////////////////////////////////////////////////////////// 18 static inline void *memcpy(void *_dst, const void *_src, unsigned int size) 19 { 20 unsigned int *dst = _dst; 21 const unsigned int *src = _src; 22 23 /* if source and destination buffer are word-aligned, 24 * then copy word-by-word */ 25 if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) 26 while (size > 3) { 27 *dst++ = *src++; 28 size -= 4; 29 } 30 31 unsigned char *cdst = (unsigned char*)dst; 32 unsigned char *csrc = (unsigned char*)src; 33 34 /* byte-by-byte copy */ 35 while (size--) { 36 *cdst++ = *csrc++; 37 } 38 return _dst; 39 } 40 41 ////////////////////////////////////////////////////////// 42 static inline void * memset(void *dst, int s, unsigned int count) 43 { 44 char *a = (char *) dst; 45 while (count--) 46 *a++ = (char)s; 47 return dst; 48 } 10 49 11 50 /** … … 26 65 Taken from Mutekh(SRL API) 27 66 */ 28 29 67 static inline void __abort() 30 68 { … … 33 71 } 34 72 35 ////////////////////////////////////////////////////////////////////////////////////////36 // mempcy()37 // GCC may requires this function. Taken from MutekH.38 ////////////////////////////////////////////////////////////////////////////////////////39 void *memcpy(void *_dst, const void *_src, unsigned int size);40 41 ////////////////////////////////////////////////////////////////////////////////////////42 // memset()43 // GCC may requires this function. Taken from MutekH.44 ////////////////////////////////////////////////////////////////////////////////////////45 inline void * memset(void *dst, int s, unsigned int count);46 47 73 #endif /* _COMMON_H_ */ -
soft/giet_vm/libs/libsrl/srl_barrier.h
r160 r178 6 6 * License. 7 7 * 8 * Copyright (c) 2006, Nicolas Pouillon, <nipo@ssji.net>9 8 * Laboratoire d'informatique de Paris 6 / ASIM, France 10 9 * … … 21 20 */ 22 21 23 #include "stdio.h" 24 #include "srl_log.h" 25 #include "srl_sched_wait.h" 22 #include "barrier.h" 26 23 27 24 28 typedef struct srl_abstract_barrier_s 29 { 30 unsigned int init_val; 31 unsigned int count; 32 33 } srl_barrier_s; 25 typedef giet_barrier_t *srl_barrier_t; 34 26 35 # define SRL_BARRIER_INITIALIZER(n){ .init_val=(n) , .count =(n)} 36 37 typedef srl_barrier_s *srl_barrier_t; 38 39 void srl_barrier_wait( srl_barrier_t barrier ); 40 27 #define srl_barrier_wait(bar) barrier_wait(bar) 41 28 42 29 #endif -
soft/giet_vm/libs/libsrl/srl_hw_helpers.h
r175 r178 9 9 10 10 #include "stdio.h" 11 12 typedef struct __ldscript_symbol_s __ldscript_symbol_t;13 14 #define BASE_ADDR_OF(id) \15 ({ \16 extern __ldscript_symbol_t _dsx_##id##_region_begin; \17 (void*)&_dsx_##id##_region_begin; \18 })19 11 20 12 … … 62 54 @return Cycles from the initialization of the system 63 55 */ 64 65 //static: to avoid multiple definition error66 56 static inline unsigned int srl_cycle_count() 67 57 { -
soft/giet_vm/libs/libsrl/srl_lock.h
r160 r178 21 21 */ 22 22 23 #include "srl_public_types.h" 24 #include "stdio.h" 23 #include "spin_lock.h" 25 24 26 typedef struct { 27 unsigned int lock; 28 }srl_lock_t; 29 30 #define SRL_LOCK_INITIALIZER { 0 } 25 typedef giet_lock_t* srl_lock_t; 31 26 32 27 /** … … 35 30 @param lock The lock object 36 31 */ 37 int srl_lock_lock( srl_lock_t lock);32 #define srl_lock_lock(lock) lock_acquire(lock); 38 33 39 34 /** 40 @this releases a l -ock.35 @this releases a lock. 41 36 42 37 @param lock The lock object 43 38 */ 44 void srl_lock_unlock( srl_lock_t lock);39 #define srl_lock_unlock( lock ) lock_release(lock); 45 40 46 41 /** … … 51 46 @return 0 if the lock was taken successfully 52 47 */ 53 int srl_lock_try_lock( srl_lock_tlock );48 #define srl_lock_try_lock( lock ) lock_try_acquire( lock ); 54 49 55 50 #endif -
soft/giet_vm/libs/libsrl/srl_memspace.h
r160 r178 8 8 */ 9 9 10 /**11 @internal12 */13 typedef struct srl_memspace_s {14 void *buffer;15 uint32_t size;16 } srl_memspace_s;17 10 18 11 /** 19 12 The memspace abstract type. 20 13 */ 21 typedef struct srl_memspace_s *srl_memspace_t; 22 23 #define SRL_MEMSPACE_INITIALIZER( b, s ) \ 24 {\ 25 .buffer = b,\ 26 .size = s,\ 27 } 28 29 /** 30 @this retrieves the base address of a memspace 31 32 @param memsp The memspace 33 @return the base address of the memspace 34 */ 35 #define SRL_MEMSPACE_ADDR(memsp) ((memsp)->buffer) 14 typedef void* srl_memspace_t; 36 15 37 16 /** -
soft/giet_vm/libs/libsrl/srl_mwmr.h
r175 r178 6 6 typedef mwmr_channel_t* srl_mwmr_t; 7 7 8 #define srl_mwmr_write mwmr_write 9 #define srl_mwmr_read mwmr_read 10 11 12 13 14 15 16 17 18 19 8 #define srl_mwmr_write(a, b, c) mwmr_write(a, b, c) 9 #define srl_mwmr_read(a, b, c) mwmr_read(a, b, c) 20 10 21 11 -
soft/giet_vm/libs/libsrl/srl_private_types.h
r160 r178 8 8 */ 9 9 10 #include "stdio.h"11 #include "srl_barrier.h"12 #include "srl_public_types.h"13 10 14 #define TTY_INC 1615 16 /**17 A numeric constant holder18 */19 typedef unsigned int srl_const_t;20 #define SRL_CONST_INITIALIZER(x) x21 22 typedef void srl_task_func_t( void* );23 24 typedef struct srl_abstract_task_s {25 srl_task_func_t *bootstrap;26 srl_task_func_t *func;27 void *args;28 void *stack;29 size_t stack_size;30 const char *name;31 // uint32_t context[CONTEXT_WSIZE];32 sint32_t wait_val;33 void *wait_addr;34 size_t tty_addr;35 }srl_task_s;36 37 #define SRL_TASK_INITIALIZER(b, f, ss, s, a, n, ttyc, ttyn) \38 { \39 .bootstrap = (srl_task_func_t *)b, \40 .func = (srl_task_func_t *)f, \41 .args = (void*)a, \42 .stack = (void*)s, \43 .stack_size = ss, \44 .name = n, \45 .tty_addr = (size_t)ttyc + (ttyn * TTY_INC), \46 }47 48 49 typedef struct srl_abstract_cpudesc_s srl_cpudesc_s;50 struct srl_abstract_cpudesc_s {51 const size_t ntasks;52 const srl_task_s * const *task_list;53 size_t tty_addr;54 };55 56 #define SRL_CPUDESC_INITIALIZER(nt, tl, ttyc, ttyn) \57 { \58 .ntasks = nt, \59 .task_list = tl, \60 .tty_addr = (size_t)ttyc + (ttyn * TTY_INC),\61 }62 63 typedef struct srl_abstract_appdesc_s srl_appdesc_s;64 struct srl_abstract_appdesc_s {65 const size_t ntasks;66 srl_barrier_s *start;67 const struct srl_mwmr_s * const *mwmr;68 const srl_cpudesc_s * const *cpu;69 const srl_task_s * const *task;70 size_t tty_addr;71 };72 73 #define SRL_APPDESC_INITIALIZER(nt, cl, ml, tl, sb, ttyc, ttyn) \74 { \75 .ntasks = nt, \76 .cpu = cl, \77 .mwmr = ml, \78 .task = tl, \79 .start = sb, \80 .tty_addr = (size_t)ttyc + (ttyn * TTY_INC), \81 }82 83 //needed by gcc84 void *memcpy(void *_dst, const void *_src, unsigned int size);85 void * memset(void *dst, int data, size_t size);86 87 88 /**89 * All function needed by kmain has to be tagged with in_srl_main90 * typically: srl_mwmw_sys91 */92 #define in_srl_main __attribute__((section (".srl_main")))93 11 94 12 /** … … 97 15 #define cpu_mem_write_32(addr, data) *((volatile uint32_t*)(addr)) = data 98 16 99 #define uintptr_t unsigned int100 101 17 #endif -
soft/giet_vm/libs/libsrl/srl_sched_wait.c
r160 r178 17 17 * 18 18 * Copyright (c) UPMC, Lip6, SoC 19 * Nicolas Pouillon <nipo@ssji.net>, 200820 19 */ 21 20 … … 27 26 #define endian_cpu32(x) (x) 28 27 29 #define DECLARE_WAIT(name, cmp) 30 31 void srl_sched_wait_##name( void *addr, sint32_t val ) 32 { 33 dcache_flush(addr, sizeof(addr));\34 if ( ((sint32_t)*((unsigned int *)addr)) cmp val ) 35 return; 36 do { 37 context_switch();\38 dcache_flush(addr, sizeof(addr));\39 } while (((sint32_t)*((unsigned int*)addr)) cmp val ); 28 #define DECLARE_WAIT(name, cmp) \ 29 \ 30 void srl_sched_wait_##name( void *addr, sint32_t val ) \ 31 { \ 32 srl_dcache_flush_addr(addr); \ 33 if ( ((sint32_t)*((unsigned int *)addr)) cmp val ) \ 34 return; \ 35 do { \ 36 srl_sched_wait_priv(100);?? \ 37 srl_dcache_flush_addr(addr); \ 38 } while (((sint32_t)*((unsigned int*)addr)) cmp val ); \ 40 39 } 41 40 … … 54 53 DECLARE_WAIT(gt, >) 55 54 55 //TODO 56 56 void srl_sched_wait_priv(uint32_t date ) 57 57 { -
soft/giet_vm/libs/mwmr_channel.c
r175 r178 74 74 // after a random delay. 75 75 ////////////////////////////////////////////////////////////////////////////// 76 void mwmr_write( mwmr_channel_t* mwmr,77 unsigned int*buffer,78 unsigned int nitems )76 void mwmr_write( mwmr_channel_t* mwmr, 77 const unsigned int* buffer, 78 unsigned int nitems ) 79 79 { 80 80 unsigned int x; -
soft/giet_vm/libs/mwmr_channel.h
r159 r178 29 29 ////////////////////////////////////////////////////////////////////////////// 30 30 31 void mwmr_write( mwmr_channel_t* mwmr,32 unsigned int*buffer,33 unsigned int nitems );31 void mwmr_write( mwmr_channel_t* mwmr, 32 const unsigned int* buffer, 33 unsigned int nitems ); 34 34 35 35 void mwmr_read( mwmr_channel_t* mwmr, -
soft/giet_vm/libs/spin_lock.c
r165 r178 10 10 // It is a simple binary lock, without waiting queue. 11 11 // 12 // The lock_acquire() and lock_release() functions do not require a system call. 13 // The barrier itself must have been allocated in a non cacheable segment, 14 // if the platform does not provide hardwate cache coherence. 12 // The lock_acquire(), lock_try_acquire() and lock_release() functions do 13 // not require a system call. 15 14 // 16 15 // ALL locks must be defined in the mapping_info data structure, 17 16 // to be initialised by the GIET in the boot phase. 18 17 // The vobj_get_vbase() system call (defined in stdio.c and stdio.h files) 19 // can be used to get the virtual base address of the lock fro it's name.18 // can be used to get the virtual base address of the lock from it's name. 20 19 /////////////////////////////////////////////////////////////////////////////////// 21 20 … … 65 64 } 66 65 66 ////////////////////////////////////////////////////////////////////////////// 67 // lock_try_acquire() 68 ////////////////////////////////////////////////////////////////////////////// 69 int lock_try_acquire( giet_lock_t* lock ) 70 { 71 register int ret = 0; 72 register unsigned int* plock = &lock->value; 73 74 asm volatile ("ll $2, 0(%1) \n" // $2 <= _locks_lock 75 "bnez $2, _lock_done \n" // exitif busy 76 "li $3, 1 \n" // prepare argument for sc 77 "sc $3, 0(%1) \n" // try to set _locks_busy 78 "xori %0, $3, 1 \n" // ret = !$3 79 "_lock_done: \n" 80 :"=r"(ret) 81 :"r"(plock) 82 :"$2","$3"); 83 return ret; 84 } -
soft/giet_vm/libs/spin_lock.h
r165 r178 27 27 void lock_release( giet_lock_t* lock ); 28 28 29 // return 0 if success 30 int lock_try_acquire( giet_lock_t* lock ); 31 29 32 #endif 30 33 -
soft/giet_vm/libs/srl.h
r175 r178 19 19 #include "libsrl/srl_hw_helpers.h" 20 20 21 #include "libsrl/srl_args.h" 22 21 23 //kernel use! 22 24 //#include "libsrl/srl_mwmr_sys.h" 23 24 #define GET_MWMR(port) GET_ARG(port, VOBJ_TYPE_MWMR)25 /* port, APP_NAME, TASK, #task_name, alias */26 # define SRL_GET_ARG(task_name, port, type) \27 ({ \28 srl_mwmr_t _mwmr; \29 if( giet_vobj_get_vbase( APP_NAME , alias_##task_name.port, type, (unsigned int*)&_mwmr ) ) \30 { \31 srl_log_printf( NONE, "\n[ERROR] in "#task_name" task :\n"); \32 srl_log_printf( NONE, " undefined port <"#port"> for channel(%s): %d\n", alias_##task_name.port,_mwmr); \33 srl_log_printf( TRACE, "*** &"#port" = %x\n\n", (unsigned int)_mwmr ); \34 srl_exit(); \35 }else \36 srl_log_printf( TRACE, "%s:%d: arg of %s for %s,from %s; &"#port" = %x\n\n", __FILE__, __LINE__, APP_NAME, #task_name,#port, (unsigned int)_mwmr ); \37 _mwmr;\38 })39 40 41 25 42 26 -
soft/giet_vm/libs/stdio.h
r165 r178 10 10 11 11 #include <mapping_info.h> 12 #include <common.h> 12 13 13 14 /* MIPS32 related functions */ … … 66 67 unsigned int giet_procnumber(); 67 68 68 /*69 * memcpy function70 * This function is required because it can be gnerated by GCC71 * during compilation so we must provide it.72 * Code taken from MutekH.73 */74 static inline void *memcpy(void *_dst, const void *_src, unsigned int size)75 {76 unsigned int *dst = _dst;77 const unsigned int *src = _src;78 79 /* if source and destination buffer are word-aligned,80 * then copy word-by-word */81 if (!((unsigned int)dst & 3) && !((unsigned int)src & 3))82 while (size > 3) {83 *dst++ = *src++;84 size -= 4;85 }86 87 unsigned char *cdst = (unsigned char*)dst;88 unsigned char *csrc = (unsigned char*)src;89 90 /* byte-by-byte copy */91 while (size--) {92 *cdst++ = *csrc++;93 }94 return _dst;95 }96 69 97 70 #endif 98
Note: See TracChangeset
for help on using the changeset viewer.