Ignore:
Timestamp:
Feb 12, 2013, 6:33:31 PM (12 years ago)
Author:
meunier
Message:

Added support for memspaces and const.
Added an interrupt masking to the "giet_context_switch" syscall
Corrected two bugs in boot/boot_init.c (one minor and one regarding barriers initialization)
Reformatted the code in all files.

Location:
soft/giet_vm/libs/libsrl
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/libs/libsrl/srl_args.h

    r215 r228  
    44
    55
    6 #define SRL_GET_MWMR(port)      (srl_mwmr_t) APP_GET_ARG(port, VOBJ_TYPE_MWMR)
    7 #define SRL_GET_BARRIER(port)   APP_GET_ARG(port, VOBJ_TYPE_BARRIER)
    8 #define SRL_GET_LOCK(port)      APP_GET_ARG(port, VOBJ_TYPE_LOCK)
    9 //#define SRL_GET_MEMSPACE(port)  APP_GET_ARG(port, VOBJ_TYPE_BUFFER) TODO
    10 #define SRL_GET_MEMSPACE        #error "SRL_GET_MEMSPACE is not implemented"//
     6#define SRL_GET_MWMR(port)      (srl_mwmr_t)     APP_GET_ARG(port, VOBJ_TYPE_MWMR)
     7#define SRL_GET_BARRIER(port)   (srl_barrier_t)  APP_GET_ARG(port, VOBJ_TYPE_BARRIER)
     8#define SRL_GET_LOCK(port)                       APP_GET_ARG(port, VOBJ_TYPE_LOCK)
     9#define SRL_GET_CONST(port)                      APP_GET_ARG(port, VOBJ_TYPE_CONST)
     10#define SRL_GET_MEMSPACE(port)  (srl_memspace_t) APP_GET_ARG(port, VOBJ_TYPE_MEMSPACE)
    1111
    1212
     
    1414({                                                                                                 \
    1515    unsigned int  vbase;                                                                           \
    16     if( giet_vobj_get_vbase( APP_NAME , alias_##task_name.port, type, &vbase ) )                   \
     16    if (giet_vobj_get_vbase(APP_NAME , alias_##task_name.port, type, &vbase))                      \
    1717    {                                                                                              \
    18         srl_log_printf( NONE, "\n[ERROR] in "#task_name" task :\n");                               \
    19         srl_log_printf( NONE, "          undefined port <"#port"> for channel(%s): %d\n",          \
    20                                                                 alias_##task_name.port,vbase);     \
    21         srl_log_printf( TRACE, "*** &"#port" = %x\n\n", vbase );                                   \
     18        srl_log_printf(NONE, "\n[ERROR] in "#task_name" task :\n");                                \
     19        srl_log_printf(NONE, "          undefined port <"#port"> for channel \"%s\": %x\n",        \
     20                                                                alias_##task_name.port, vbase);    \
     21        srl_log_printf(TRACE, "*** &"#port" = %x\n\n", vbase);                                     \
    2222        srl_exit();                                                                                \
    23     }else                                                                                          \
    24         srl_log_printf( TRACE, "%s:%d: arg of %s for %s,from %s; &"#port" = %x\n\n",               \
    25                             __FILE__, __LINE__, APP_NAME, #task_name,#port, vbase );               \
    26     vbase;\
     23    }                                                                                              \
     24    else                                                                                           \
     25        srl_log_printf(TRACE, "%s:%d: arg of %s for %s, from %s; &"#port" = %x\n\n",               \
     26                            __FILE__, __LINE__, APP_NAME, #task_name, #port, vbase);               \
     27    vbase;                                                                                         \
    2728})
    2829
  • soft/giet_vm/libs/libsrl/srl_barrier.h

    r178 r228  
    2323
    2424
    25 typedef giet_barrier_t *srl_barrier_t;
     25typedef giet_barrier_t * srl_barrier_t;
    2626
    2727#define srl_barrier_wait(bar) barrier_wait(bar)
    2828
    2929#endif
     30
     31
     32// Local Variables:
     33// tab-width: 4
     34// c-basic-offset: 4
     35// c-file-offsets:((innamespace . 0)(inline-open . 0))
     36// indent-tabs-mode: nil
     37// End:
     38// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     39
  • soft/giet_vm/libs/libsrl/srl_endianness.h

    r160 r228  
    55
    66/** @this reads a big endian 16 bits value */
    7 #  define endian_le16(x)        (x)
     7#  define endian_le16(x)    (x)
    88/** @this reads a big endian 32 bits value */
    9 #  define endian_le32(x)        (x)
     9#  define endian_le32(x)    (x)
    1010/** @this reads a big endian 64 bits value */
    11 //#  define endian_le64(x)      (x)
     11//#  define endian_le64(x)    (x)
    1212/** @this reads a little endian 16 bits value */
    13 #  define endian_be16(x)        endian_swap16(x)
     13#  define endian_be16(x)    endian_swap16(x)
    1414/** @this reads a little endian 32 bits value */
    15 #  define endian_be32(x)        endian_swap32(x)
     15#  define endian_be32(x)    endian_swap32(x)
    1616/** @this reads a little endian 64 bits value */
    17 //#  define endian_be64(x)      endian_swap64(x)
     17//#  define endian_be64(x)    endian_swap64(x)
    1818
    1919/** @internal */
    20 static inline uint16_t endian_swap16(uint16_t x)
    21 {
    22   return (x >> 8) | (x << 8);
     20static inline uint16_t endian_swap16(uint16_t x) {
     21    return (x >> 8) | (x << 8);
    2322}
    2423
     24
    2525/** @internal */
    26 static inline uint32_t endian_swap32(uint32_t x)
    27 {
    28   return (((x >> 24) & 0x000000ff) |
    29           ((x >> 8 ) & 0x0000ff00) |
    30           ((x << 8 ) & 0x00ff0000) |
    31           ((x << 24) & 0xff000000));
     26static inline uint32_t endian_swap32(uint32_t x) {
     27    return (((x >> 24) & 0x000000ff) |
     28            ((x >> 8 ) & 0x0000ff00) |
     29            ((x << 8 ) & 0x00ff0000) |
     30            ((x << 24) & 0xff000000));
    3231}
    3332
     33
    3434/** @internal *//*
    35 static inline uint64_t __endian_swap64(uint64_t x)
    36 {
    37   return (((uint64_t)endian_swap32(x      ) << 32) |
    38           ((uint64_t)endian_swap32(x >> 32)      ));
    39 }*/
     35                   static inline uint64_t __endian_swap64(uint64_t x)
     36                   {
     37                   return (((uint64_t)endian_swap32(x      ) << 32) |
     38                   ((uint64_t)endian_swap32(x >> 32)      ));
     39                   }*/
    4040
    41 static inline uint32_t srl_uint32_le_to_machine(uint32_t x)
    42 {
    43         return endian_le32(x);
     41static inline uint32_t srl_uint32_le_to_machine(uint32_t x) {
     42    return endian_le32(x);
    4443}
    4544
    46 static inline uint32_t srl_uint32_machine_to_le(uint32_t x)
    47 {
    48         return endian_le32(x);
     45
     46static inline uint32_t srl_uint32_machine_to_le(uint32_t x) {
     47    return endian_le32(x);
    4948}
    5049
    51 static inline uint32_t srl_uint32_be_to_machine(uint32_t x)
    52 {
    53         return endian_be32(x);
     50
     51static inline uint32_t srl_uint32_be_to_machine(uint32_t x) {
     52    return endian_be32(x);
    5453}
    5554
    56 static inline uint32_t srl_uint32_machine_to_be(uint32_t x)
    57 {
    58         return endian_be32(x);
     55
     56static inline uint32_t srl_uint32_machine_to_be(uint32_t x) {
     57    return endian_be32(x);
    5958}
    6059
    61 static inline uint16_t srl_uint16_le_to_machine(uint16_t x)
    62 {
    63         return endian_le16(x);
     60
     61static inline uint16_t srl_uint16_le_to_machine(uint16_t x) {
     62    return endian_le16(x);
    6463}
    6564
    66 static inline uint16_t srl_uint16_machine_to_le(uint16_t x)
    67 {
    68         return endian_le16(x);
     65
     66static inline uint16_t srl_uint16_machine_to_le(uint16_t x) {
     67    return endian_le16(x);
    6968}
    7069
    71 static inline uint16_t srl_uint16_be_to_machine(uint16_t x)
    72 {
    73         return endian_be16(x);
     70
     71static inline uint16_t srl_uint16_be_to_machine(uint16_t x) {
     72    return endian_be16(x);
    7473}
    7574
    76 static inline uint16_t srl_uint16_machine_to_be(uint16_t x)
    77 {
    78         return endian_be16(x);
     75
     76static inline uint16_t srl_uint16_machine_to_be(uint16_t x) {
     77    return endian_be16(x);
    7978}
    8079
    8180
    8281#endif
     82
     83
     84// Local Variables:
     85// tab-width: 4
     86// c-basic-offset: 4
     87// c-file-offsets:((innamespace . 0)(inline-open . 0))
     88// indent-tabs-mode: nil
     89// End:
     90// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     91
  • soft/giet_vm/libs/libsrl/srl_hw_helpers.h

    r178 r228  
    1212
    1313/**
    14    Standard API call, expands to nothing for this implementation.
    15  */
     14  Standard API call, expands to nothing for this implementation.
     15  */
    1616#define srl_busy_cycles(n) do{}while(0)
    1717
    1818//void useless(void *pointless,...){}
    1919/**
    20    @this flushes the cache line containing the address.
    21  */
     20  @this flushes the cache line containing the address.
     21  */
    2222//TODO
    2323#define srl_dcache_flush_addr 0
    2424
    2525/*
    26 static inline cpu_dcache_invld(void *ptr){
    27          asm volatile (                                                         
    28         " cache %0, %1"                                                 
    29         : : "i" (0x11) , "R" (*(uint8_t*)(ptr))
    30         : "memory"                                                             
    31         );                                                     
    32 }
    33 */
     26   static inline cpu_dcache_invld(void *ptr){
     27   asm volatile (                               
     28   " cache %0, %1"                           
     29   : : "i" (0x11) , "R" (*(uint8_t*)(ptr))   
     30   : "memory"                               
     31   );                           
     32   }
     33   */
    3434
    3535/**
    36    @this flushes a memory zone from cache.
    37  */
     36  @this flushes a memory zone from cache.
     37  */
    3838//TODO
    3939//void dcache_flush(const void * addr, size_t size)
     
    4141
    4242/**
    43    @this waits for at least the given time (in cycles). The actual
    44    time spent in this call is not predictable.
     43  @this waits for at least the given time (in cycles). The actual
     44  time spent in this call is not predictable.
    4545
    46    @param time Number of cycles to wait for
    47  */
    48 void srl_sleep_cycles( unsigned int time );
     46  @param time Number of cycles to wait for
     47  */
     48void srl_sleep_cycles(unsigned int time);
    4949
    5050/**
    51    @this returns the absolute timestamp counter from the
    52    initialization of the platform.
     51  @this returns the absolute timestamp counter from the
     52  initialization of the platform.
    5353
    54    @return Cycles from the initialization of the system
    55  */
    56 static inline unsigned int srl_cycle_count()
    57 {
    58         return giet_proctime();
     54  @return Cycles from the initialization of the system
     55  */
     56static inline unsigned int srl_cycle_count() {
     57    return giet_proctime();
    5958}
    6059
     60
    6161/**
    62    @this aborts the current execution. On most systems, @this will
    63    simply hang.
    64  */
    65 static inline void srl_abort()
    66 {
    67         asm volatile ("break 0");
    68         while(1);
     62  @this aborts the current execution. On most systems, @this will
     63  simply hang.
     64  */
     65static inline void srl_abort() {
     66    asm volatile ("break 0");
     67    while (1);
    6968}
     69
    7070
    7171/**
    7272 *
    7373 */
    74 static inline void srl_exit()
    75 {
     74static inline void srl_exit() {
    7675    giet_exit();
    7776}
    7877
    7978#endif
     79
     80// Local Variables:
     81// tab-width: 4
     82// c-basic-offset: 4
     83// c-file-offsets:((innamespace . 0)(inline-open . 0))
     84// indent-tabs-mode: nil
     85// End:
     86// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     87
  • soft/giet_vm/libs/libsrl/srl_lock.h

    r178 r228  
    2323#include "spin_lock.h"
    2424
    25 typedef giet_lock_t* srl_lock_t;
     25typedef giet_lock_t * srl_lock_t;
    2626
    2727/**
     
    4949
    5050#endif
     51
     52
     53// Local Variables:
     54// tab-width: 4
     55// c-basic-offset: 4
     56// c-file-offsets:((innamespace . 0)(inline-open . 0))
     57// indent-tabs-mode: nil
     58// End:
     59// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     60
  • soft/giet_vm/libs/libsrl/srl_memspace.h

    r178 r228  
    11#ifndef SRL_MEMSPACE_H
    22#define SRL_MEMSPACE_H
     3
     4#include "srl_public_types.h"
     5
     6#include <memspace.h>
    37
    48/**
     
    1216   The memspace abstract type.
    1317 */
    14 typedef void* srl_memspace_t;
     18
     19
     20typedef giet_memspace_t * srl_memspace_t;
    1521
    1622/**
     
    2127 */
    2228#define SRL_MEMSPACE_SIZE(memsp) ((memsp)->size)
     29#define SRL_MEMSPACE_ADDR(memsp) ((memsp)->buffer)
     30
    2331
    2432#endif
     33
     34// Local Variables:
     35// tab-width: 4
     36// c-basic-offset: 4
     37// c-file-offsets:((innamespace . 0)(inline-open . 0))
     38// indent-tabs-mode: nil
     39// End:
     40// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     41
  • soft/giet_vm/libs/libsrl/srl_mwmr.h

    r213 r228  
    44#include "mwmr_channel.h"
    55
    6 typedef  mwmr_channel_t* srl_mwmr_t;
     6typedef  mwmr_channel_t * srl_mwmr_t;
    77
    8 #define srl_mwmr_write(a, b, c) mwmr_write(a, (unsigned int*) b, (unsigned int)c)
    9 #define srl_mwmr_read(a, b, c) mwmr_read(a, (unsigned int*) b, (unsigned int)c) 
     8#define srl_mwmr_write(a, b, c) mwmr_write(a, (unsigned int *) b, (unsigned int) c)
     9#define srl_mwmr_read(a, b, c) mwmr_read(a, (unsigned int *) b, (unsigned int) c)
    1010
    1111
    1212#endif //fin de SRL_MWMR_H_
     13
     14// Local Variables:
     15// tab-width: 4
     16// c-basic-offset: 4
     17// c-file-offsets:((innamespace . 0)(inline-open . 0))
     18// indent-tabs-mode: nil
     19// End:
     20// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     21
  • soft/giet_vm/libs/libsrl/srl_private_types.c

    r160 r228  
     1
    12#include "srl_private_types.h"
    23
     
    67// GCC requires this function. Taken from MutekH.
    78////////////////////////////////////////////////////////////////////////////////////////
    8 void *memcpy(void *_dst, const void *_src, unsigned int size)
    9 {
    10     unsigned int *dst = _dst;
    11     const unsigned int *src = _src;
    12     if ( ! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3) )
     9void * memcpy(void *_dst, const void * _src, unsigned int size) {
     10    unsigned int * dst = _dst;
     11    const unsigned int * src = _src;
     12    if (!((unsigned int) dst & 3) && !((unsigned int) src & 3) )
    1313        while (size > 3) {
    1414            *dst++ = *src++;
     
    2525}
    2626
     27
    2728////////////////////////////////////////////////////////////////////////////////////////
    2829//  mempcy()
    2930// GCC requires this function. Taken from MutekH.
    3031////////////////////////////////////////////////////////////////////////////////////////
    31 inline void * memset(void *dst, int s, size_t count)
    32 {
    33 /*
    34   int8_t s = _s;
    35   const reg_t v = (uint8_t)s * (reg_t)0x0101010101010101LL;
    36   int8_t *a = dst;
    37   reg_t *r;
     32inline void * memset(void * dst, int s, size_t count) {
     33    char * a = (char *) dst;
     34    while (count--){
     35        *a++ = (char)s;
     36    }
     37    return dst;
     38}
    3839
    39   // align
    40   while ( ((uintptr_t *)a & reg_t_log2_m1) && count )
    41     count--, *a++ = s;
    4240
    43   size_t ucount = count & reg_t_log2_m1;
    44   count &= ~reg_t_log2_m1;
     41// Local Variables:
     42// tab-width: 4
     43// c-basic-offset: 4
     44// c-file-offsets:((innamespace . 0)(inline-open . 0))
     45// indent-tabs-mode: nil
     46// End:
     47// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
    4548
    46   for (r = (reg_t*)a; count; count -= sizeof(reg_t))
    47       *r++ = v;
    48 
    49   for (a = (int8_t*)r; ucount; ucount--)
    50       *a++ = s;
    51 
    52 */
    53         char *a = (char *) dst;
    54         while (count--){
    55                 *a++ = (char)s;
    56         }
    57 
    58         return dst;
    59 }
  • soft/giet_vm/libs/libsrl/srl_sched_wait.c

    r178 r228  
    2828#define DECLARE_WAIT(name, cmp)                                 \
    2929                                                                \
    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 );  \
    39     }
     30void srl_sched_wait_##name(void * addr, sint32_t val) {         \
     31    srl_dcache_flush_addr(addr);                                \
     32    if (((sint32_t) * ((unsigned int *) addr)) cmp val)         \
     33    return;                                                     \
     34    do {                                                        \
     35        srl_sched_wait_priv(100);??                             \
     36        srl_dcache_flush_addr(addr);                            \
     37    } while (((sint32_t) * ((unsigned int *) addr)) cmp val);   \
     38}
    4039
    4140
     
    5352DECLARE_WAIT(gt, >)
    5453
    55 //TODO
    56 void srl_sched_wait_priv(uint32_t date )
    57 {
    58         do{
    59                 context_switch();
    60         }while (srl_cycle_count() > date);
     54    //TODO
     55void srl_sched_wait_priv(uint32_t date) {
     56    do {
     57        context_switch();
     58    } while (srl_cycle_count() > date);
    6159}
    6260
    63 void srl_sleep_cycles( uint32_t n )
    64 {
    65         uint32_t next_run_to = srl_cycle_count()+n;
     61void srl_sleep_cycles(uint32_t n) {
     62    uint32_t next_run_to = srl_cycle_count() + n;
    6663
    67         while(srl_cycle_count() < next_run_to)
    68                 srl_sched_wait_priv(next_run_to);
     64    while (srl_cycle_count() < next_run_to) {
     65        srl_sched_wait_priv(next_run_to);
     66    }
    6967}
    7068
     69
     70// Local Variables:
     71// tab-width: 4
     72// c-basic-offset: 4
     73// c-file-offsets:((innamespace . 0)(inline-open . 0))
     74// indent-tabs-mode: nil
     75// End:
     76// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     77
  • soft/giet_vm/libs/libsrl/srl_sched_wait.h

    r160 r228  
    3535
    3636
    37 void srl_sleep_cycles( unsigned int n );
     37void srl_sleep_cycles(unsigned int n);
    3838
    3939#endif
     40
     41
     42// Local Variables:
     43// tab-width: 4
     44// c-basic-offset: 4
     45// c-file-offsets:((innamespace . 0)(inline-open . 0))
     46// indent-tabs-mode: nil
     47// End:
     48// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     49
Note: See TracChangeset for help on using the changeset viewer.