Changeset 744


Ignore:
Timestamp:
Jul 10, 2014, 11:23:57 AM (10 years ago)
Author:
cfuguet
Message:

giet_tsar: using CLUSTER_IO constant in stdio functions

  • Erasing also extra end-of-line spaces
Location:
trunk/softs
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/softs/giet_tsar/giet.S

    r743 r744  
    44*       Date : 15/01/2014
    55*********************************************************************************
    6 * This is a very simple Interrupts/Exception/Traps handler for a generic 
     6* This is a very simple Interrupts/Exception/Traps handler for a generic
    77* multi-clusters / multi-processors TSAR architecture (up to 256 clusters,
    8 * up to 4  processors per cluster). 
     8* up to 4  processors per cluster).
    99* The physical address is 40 bits, and the 8 MSB bits A[39:32] define the
    1010* cluster index.
     
    1515    .section .giet,"ax",@progbits
    1616    .align 2
    17     .global _interrupt_vector   
     17    .global _interrupt_vector
    1818
    1919    .extern seg_xcu_base
     
    7878*   System Call Handler
    7979*
    80 * As the GIET_TSAR does not support system calls, 
     80* As the GIET_TSAR does not support system calls,
    8181* an error message is displayed on TTY0, the program is killed.
    8282****************************************************************/
     
    9797
    9898    mfc0    $4,     $14             /* $4 <= EPC */
    99     la      $5,     _itoa_buffer    /* $5 <= buffer address */ 
     99    la      $5,     _itoa_buffer    /* $5 <= buffer address */
    100100    addiu   $5,     $5,     2       /* skip the 0x prefix */
    101101    jal     _itoa_hex               /* fill the buffer */
     
    108108    nop
    109109
    110     j       _exit                   /* end of program */ 
     110    j       _exit                   /* end of program */
    111111
    112112_itoa_buffer: .ascii "0x00000000"
     
    122122* It makes the assumption that there is only one interrupt per
    123123* entry in the interrupt vector (it can be PTI, HWI, or WTI).
    124 * In case of a multi-clusters architecture, it exist one XCU 
    125 * per cluster, and the base address of the ICU segment depends 
     124* In case of a multi-clusters architecture, it exist one XCU
     125* per cluster, and the base address of the ICU segment depends
    126126* on both the cluster_xy and the proc_id:
    127127* - base_address = seg_xcu_base + (32*local_id) + (4G*cluster_xy)
     
    164164    sw      $31,    4*21($29)       /* save $31 */
    165165    mfc0    $27,    $14
    166     sw      $27,    4*22($29)       /* save EPC */ 
     166    sw      $27,    4*22($29)       /* save EPC */
    167167
    168168    /* XICU PRIO register address computation         */
     
    170170    /* and we must use the physical address extension */
    171171    mfc0    $10,    $15,    1        /* $10 <= proc_id                                 */
    172     andi    $10,    $10,    0x3FF    /* at most 1024 processors                        */ 
     172    andi    $10,    $10,    0x3FF    /* at most 1024 processors                        */
    173173    li      $11,    NB_PROCS_MAX
    174174    divu    $10,    $11
     
    194194    andi    $27,    $15,    0x4      /* test bit W in PRIO register                    */
    195195    bne     $27,    $0,     _int_WTI /* branch to WTI handler                          */
    196    
     196
    197197    /* exit interrupt handler: restore registers */
    198198_int_restore:
     
    200200    lw      $1,     4*4($29)
    201201    .set at
    202     lw      $2,     4*5($29) 
    203     lw      $3,     4*6($29) 
     202    lw      $2,     4*5($29)
     203    lw      $3,     4*6($29)
    204204    lw      $4,     4*7($29)
    205     lw      $5,     4*8($29) 
     205    lw      $5,     4*8($29)
    206206    lw      $6,     4*9($29)
    207     lw      $7,     4*10($29) 
     207    lw      $7,     4*10($29)
    208208    lw      $8,     4*11($29)
    209209    lw      $9,     4*12($29)
     
    217217    lw      $25,    4*20($29)
    218218    lw      $31,    4*21($29)
    219     lw      $27,    4*22($29)        /* get EPC */ 
     219    lw      $27,    4*22($29)        /* get EPC */
    220220    addiu   $29,    $29,    23*4     /* restore SP */
    221221    mtc0    $27,    $14              /* restore EPC */
     
    233233    la      $27,    _interrupt_vector
    234234    addu    $26,    $26,    $27
    235     lw      $26,    ($26)            /* read ISR address             */ 
     235    lw      $26,    ($26)            /* read ISR address             */
    236236    jalr    $26                      /* call ISR                     */
    237237    nop
     
    246246    la      $27,    _interrupt_vector
    247247    addu    $26,    $26,    $27      /* $26 <= &ISR[HWI_INDEX        */
    248     lw      $26,    ($26)            /* read ISR address             */ 
     248    lw      $26,    ($26)            /* read ISR address             */
    249249    jalr    $26                      /* call ISR                     */
    250250    nop
     
    262262    la      $27,    _interrupt_vector
    263263    addu    $26,    $26,    $27      /* $26 <= &ISR[WTI_INDEX]       */
    264     lw      $26,    ($26)            /* read ISR address             */ 
     264    lw      $26,    ($26)            /* read ISR address             */
    265265    jalr    $26                      /* call ISR                     */
    266266    nop
    267267    j       _int_restore             /* return from INT handler */
    268268    nop
    269    
     269
    270270/* The default ISR is called when no specific ISR has been installed */
    271271/* in the interrupt vector. It simply displays a message on TTY0     */
     
    273273isr_default:
    274274    addiu   $29,    $29,    -20     /* get space in stack */
    275     sw      $31,    16($29)         /* to save the return address */ 
     275    sw      $31,    16($29)         /* to save the return address */
    276276    la      $4,     _msg_default    /* $4 <= string address */
    277277    addi    $5,     $0,     36      /* $5 <= string length */
    278278    li      $6,     0               /* $6 <= TTY0 */
    279     jal     _tty_write 
    280     lw      $31,    16($29)         /* restore return address */ 
     279    jal     _tty_write
     280    lw      $31,    16($29)         /* restore return address */
    281281    addiu   $29,    $29,    20      /* free space */
    282282    jr      $31                     /* returns to interrupt handler */
     
    284284/****************************************************************
    285285*  Interrupt Vector Table (indexed by interrupt index)
    286 *  32 words corresponding to 32 ISR addresses 
     286*  32 words corresponding to 32 ISR addresses
    287287****************************************************************/
    288288_interrupt_vector:
     
    355355    li      $5,     36              /* $5 <= message length */
    356356    li      $6,     0               /* $6 <= TTY0 */
    357     jal     _tty_write               
     357    jal     _tty_write
    358358    nop
    359359
     
    362362    li      $5,     8               /* $5 <= message length */
    363363    li      $6,     0               /* $6 <= TTY0 */
    364     jal     _tty_write           
    365     nop
    366    
     364    jal     _tty_write
     365    nop
     366
    367367    mfc0    $4,     $14             /* $4 <= EPC value */
    368368    la      $5,     _itoa_buffer    /* $5 <= buffer address */
     
    377377    nop
    378378
    379     /* display BAR value */ 
     379    /* display BAR value */
    380380    la      $4,     _msg_bar        /* $4 <= message address */
    381381    li      $5,     8               /* $5 <= message length */
     
    385385
    386386    mfc0    $4,     $8              /* $4 <= BAR value */
    387     la      $5,     _itoa_buffer    /* $5 <= buffer address */ 
    388     addiu   $5,     $5,     2       /* skip 0x prefix */ 
     387    la      $5,     _itoa_buffer    /* $5 <= buffer address */
     388    addiu   $5,     $5,     2       /* skip 0x prefix */
    389389    jal     _itoa_hex               /* fill buffer */
    390390    nop
     
    393393    li      $5,     10              /* $5 <= message length */
    394394    li      $6,     0               /* $6 <= TTY0 */
    395     jal     _tty_write 
    396     nop
    397 
    398    
     395    jal     _tty_write
     396    nop
     397
     398
    399399    /* release the lock on TTY0 */
    400400    li      $4,     0
  • trunk/softs/giet_tsar/mips32_registers.h

    r622 r744  
    5858/* CP2 registers */
    5959
    60 #define CP2_PTPR             $0 
     60#define CP2_PTPR             $0
    6161#define CP2_MODE             $1
    6262#define CP2_ICACHE_FLUSH     $2
    6363#define CP2_DCACHE_FLUSH     $3
    64 #define CP2_ITLB_INVAL       $4 
    65 #define CP2_DTLB_INVAL       $5 
    66 #define CP2_ICACHE_INVAL     $6 
     64#define CP2_ITLB_INVAL       $4
     65#define CP2_DTLB_INVAL       $5
     66#define CP2_ICACHE_INVAL     $6
    6767#define CP2_DCACHE_INVAL     $7
    68 #define CP2_ICACHE_PREFETCH  $8 
    69 #define CP2_DCACHE_PREFETCH  $9 
    70 #define CP2_SYNC             $10 
    71 #define CP2_IETR             $11 
    72 #define CP2_DETR             $12 
     68#define CP2_ICACHE_PREFETCH  $8
     69#define CP2_DCACHE_PREFETCH  $9
     70#define CP2_SYNC             $10
     71#define CP2_IETR             $11
     72#define CP2_DETR             $12
    7373#define CP2_IBVAR            $13
    7474#define CP2_DBVAR            $14
    75 #define CP2_PARAMS           $15 
    76 #define CP2_RELEASE          $16 
    77 #define CP2_DATA_LO          $17     
    78 #define CP2_DATA_HI          $18         
    79 #define CP2_ICACHE_INVAL_PA  $19         
    80 #define CP2_DCACHE_INVAL_PA  $20 
     75#define CP2_PARAMS           $15
     76#define CP2_RELEASE          $16
     77#define CP2_DATA_LO          $17
     78#define CP2_DATA_HI          $18
     79#define CP2_ICACHE_INVAL_PA  $19
     80#define CP2_DCACHE_INVAL_PA  $20
    8181#define CP2_PADDR_EXT        $24
    8282#endif
  • trunk/softs/giet_tsar/reset.S

    r743 r744  
    55*********************************************************************************
    66* This is a boot code for a generic multi-clusters / multi-processors
    7 * TSAR architecture (up to 256 clusters / up to 4  processors per cluster). 
     7* TSAR architecture (up to 256 clusters / up to 4  processors per cluster).
    88* The physical address is 40 bits, and the 8 MSB bits A[39:32] define the
    99* cluster index.
    1010*
    11 * As we don't want to use the virtual memory, the physical address is 
     11* As we don't want to use the virtual memory, the physical address is
    1212* equal to  the virtual address (identity mapping) and all processors stacks
    13 * and code segments are allocated in the physical memory bank in cluster 0. 
     13* and code segments are allocated in the physical memory bank in cluster 0.
    1414*
    1515* Both the reset base address and the kernel base address must be redefined
     
    2222* There is two sets of peripherals:
    2323*
    24 * 1) A block device and a single channel TTY controller are available 
     24* 1) A block device and a single channel TTY controller are available
    2525*    in cluster(0,0).
    2626*
    27 * 2) Other peripherals (including another Blockdevice, a multi-channels TTY 
     27* 2) Other peripherals (including another Blockdevice, a multi-channels TTY
    2828*    contrÃŽler, a Frame buffer) are located in cluster_io.
    2929*    For those externals peripherals, hardware interrupts (HWI) are translated
     
    3737*       - Only processor 0 initializes the IOPIC component.
    3838*   - Each processor initializes its private XCU mask.
    39 *   - Each processor initializes the Status Register (SR) 
     39*   - Each processor initializes the Status Register (SR)
    4040*   - Each processor jumps to the same main address in kernel mode...
    4141********************************************************************************/
     
    5656    .extern main
    5757
    58     .globl  reset               
     58    .globl  reset
    5959    .ent    reset
    6060    .align  2
     
    9595
    9696    la      $26,    _interrupt_vector   /* interrupt vector address                */
    97     la      $27,    _mmc_isr 
     97    la      $27,    _mmc_isr
    9898    sw      $27,    32($26)             /* interrupt_vector[8] <= _mmc_isr         */
    99     la      $27,    _ioc_isr 
     99    la      $27,    _ioc_isr
    100100    sw      $27,    36($26)             /* interrupt_vector[9] <= _ioc_isr         */
    101     la      $27,    _tty_isr 
     101    la      $27,    _tty_isr
    102102    sw      $27,    40($26)             /* interrupt_vector[10] <= _tty_isr        */
    103103
     
    129129
    130130#endif
    131    
     131
    132132reset_xcu:
    133133
     
    149149
    150150/* initializes SR register */
    151     li      $26,    0x0000FF01     
     151    li      $26,    0x0000FF01
    152152    mtc0    $26,    $12                 /* SR <= kernel mode / IRQ enable */
    153153
  • trunk/softs/giet_tsar/stdio.c

    r743 r744  
    11////////////////////////////////////////////////////////////////////////////////////////
    22// File : stdio.c
    3 // Written by Alain Greiner 
    4 // Date : janvier 2014 
     3// Written by Alain Greiner
     4// Date : janvier 2014
    55//
    66// This file defines various functions that can be used by applications to access
     
    112112// Memcopy taken from MutekH.
    113113////////////////////////////////////////////////////////////////////////////////////////
    114 in_drivers void* _memcpy( void*        _dst, 
    115                           const void*  _src, 
     114in_drivers void* _memcpy( void*        _dst,
     115                          const void*  _src,
    116116                          unsigned int size )
    117117{
     
    120120    if ( ! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3) )
    121121    {
    122         while (size > 3) 
     122        while (size > 3)
    123123        {
    124124            *dst++ = *src++;
     
    130130    unsigned char *csrc = (unsigned char*)src;
    131131
    132     while (size--) 
     132    while (size--)
    133133    {
    134134        *cdst++ = *csrc++;
     
    141141in_drivers void  _extended_memcpy( unsigned int dst_cluster,
    142142                                   unsigned int dst_address,
    143                                    unsigned int src_cluster,
    144143                                   unsigned int src_address,
    145144                                   unsigned int length )
     
    205204{
    206205    asm volatile(
    207             "mfc0   $8,     $12         \n" 
     206            "mfc0   $8,     $12         \n"
    208207            "ori    $8,     $8,     1   \n"
    209208            "mtc0   $8,     $12         \n"
     
    260259
    261260////////////////////////////////////////////////////////////////////////////
    262 // This function makes a physical read access to a 32 bits word in memory, 
     261// This function makes a physical read access to a 32 bits word in memory,
    263262// after a temporary paddr extension.
    264263////////////////////////////////////////////////////////////////////////////
     
    273272            "mtc0    $3,        $12           \n"     /* IRQ disabled     */
    274273
    275             "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */   
     274            "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */
    276275            "lw      %0,        0(%1)         \n"     /* value <= *paddr  */
    277276            "mtc2    $0,        $24           \n"     /* PADDR_EXT <= 0   */
     
    285284}
    286285////////////////////////////////////////////////////////////////////////////
    287 // This function makes a physical read access to a single byte in memory, 
     286// This function makes a physical read access to a single byte in memory,
    288287// after a temporary paddr extension.
    289288////////////////////////////////////////////////////////////////////////////
     
    298297            "mtc0    $3,        $12           \n"     /* IRQ disabled     */
    299298
    300             "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */   
     299            "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */
    301300            "lb      %0,        0(%1)         \n"     /* value <= *paddr  */
    302301            "mtc2    $0,        $24           \n"     /* PADDR_EXT <= 0   */
     
    310309}
    311310////////////////////////////////////////////////////////////////////////////
    312 // This function makes a physical write access to a 32 bits word in memory, 
     311// This function makes a physical write access to a 32 bits word in memory,
    313312// after a temporary DTLB address extension.
    314313////////////////////////////////////////////////////////////////////////////
    315 in_drivers void _word_extended_write( unsigned int  cluster, 
     314in_drivers void _word_extended_write( unsigned int  cluster,
    316315                                      unsigned int  address,
    317                                       unsigned int  word ) 
     316                                      unsigned int  word )
    318317{
    319318    int sr = _sr_read();
     
    323322            "mtc0    $3,        $12           \n"     /* IRQ disabled     */
    324323
    325             "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */   
     324            "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */
    326325            "sw      %0,        0(%1)         \n"     /* *paddr <= value  */
    327             "mtc2    $0,        $24           \n"     /* PADDR_EXT <= 0   */   
     326            "mtc2    $0,        $24           \n"     /* PADDR_EXT <= 0   */
    328327
    329328            "sync                             \n"
     
    335334}
    336335////////////////////////////////////////////////////////////////////////////
    337 // This function makes a physical write access to single byte in memory, 
     336// This function makes a physical write access to single byte in memory,
    338337// after a temporary DTLB de-activation and address extension.
    339338////////////////////////////////////////////////////////////////////////////
    340 in_drivers void _byte_extended_write( unsigned int  cluster, 
     339in_drivers void _byte_extended_write( unsigned int  cluster,
    341340                                      unsigned int  address,
    342                                       unsigned char byte ) 
     341                                      unsigned char byte )
    343342{
    344343    int sr = _sr_read();
     
    348347            "mtc0    $3,        $12           \n"     /* IRQ disabled     */
    349348
    350             "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */   
     349            "mtc2    %2,        $24           \n"     /* PADDR_EXT <= msb */
    351350            "sb      %0,        0(%1)         \n"     /* *paddr <= value  */
    352             "mtc2    $0,        $24           \n"     /* PADDR_EXT <= 0   */   
     351            "mtc2    $0,        $24           \n"     /* PADDR_EXT <= 0   */
    353352
    354353            "sync                             \n"
     
    361360
    362361///////////////////////////////////////////////////////////////////////////////////////
    363 // Exit (suicide) after printing message on TTY0 
     362// Exit (suicide) after printing message on TTY0
    364363///////////////////////////////////////////////////////////////////////////////////////
    365364in_drivers void _exit()
     
    418417//  - If there is only one terminal, it is supposed to be shared, and used by
    419418//    all processors: a lock must be taken before display.
    420 //  - If there is several terminals, and the number of processors is smaller 
    421 //    than the number of terminals, there is one terminal per processor, but 
     419//  - If there is several terminals, and the number of processors is smaller
     420//    than the number of terminals, there is one terminal per processor, but
    422421//    the TTY index is not equal to the proc_id, due to cluster indexing policy:
    423422//    proc_id = cluster_xy * NB_PROCS_MAX + local_id (with cluster_xy = x << Y_WIDTH + y)
     
    434433// returns  the number of characters that have been actually written.
    435434///////////////////////////////////////////////////////////////////////////////////////
    436 in_drivers int _tty_write( char*           buffer, 
    437                            unsigned int    length, 
     435in_drivers int _tty_write( char*           buffer,
     436                           unsigned int    length,
    438437                           unsigned int    channel )
    439438{
     
    464463// and returns 1 if the register is full.
    465464///////////////////////////////////////////////////////////////////////////////////////
    466 in_drivers int _tty_read( char*          buffer, 
     465in_drivers int _tty_read( char*          buffer,
    467466                          unsigned int   channel )
    468467{
     
    493492// This function displays a 32 bits unsigned int as an hexa string on TTY0.
    494493///////////////////////////////////////////////////////////////////////////////
    495 in_drivers void _tty_putx(unsigned int val) 
     494in_drivers void _tty_putx(unsigned int val)
    496495{
    497496    static const char HexaTab[] = "0123456789ABCDEF";
     
    503502    buf[10] = 0;
    504503
    505     for (c = 0; c < 8; c++) 
    506     { 
     504    for (c = 0; c < 8; c++)
     505    {
    507506        buf[9 - c] = HexaTab[val & 0xF];
    508507        val = val >> 4;
     
    514513// This function displays a 32 bits unsigned int as a decimal string on TTY0.
    515514///////////////////////////////////////////////////////////////////////////////
    516 in_drivers void _tty_putd( unsigned int val ) 
     515in_drivers void _tty_putd( unsigned int val )
    517516{
    518517    static const char DecTab[] = "0123456789";
     
    523522    buf[10] = 0;
    524523
    525     for (i = 0; i < 10; i++) 
    526     {
    527         if ((val != 0) || (i == 0)) 
     524    for (i = 0; i < 10; i++)
     525    {
     526        if ((val != 0) || (i == 0))
    528527        {
    529528            buf[9 - i] = DecTab[val % 10];
    530529            first = 9 - i;
    531530        }
    532         else 
     531        else
    533532        {
    534533            break;
     
    540539
    541540//////////////////////////////////////////////////////////////////////////////
    542 // This function try to take the hardwired lock protecting exclusive access 
     541// This function try to take the hardwired lock protecting exclusive access
    543542// to TTY terminal identified by the channel argument.
    544543// It returns only when the lock has been successfully taken.
     
    552551
    553552//////////////////////////////////////////////////////////////////////////////
    554 // This function releases the hardwired lock protecting exclusive access 
     553// This function releases the hardwired lock protecting exclusive access
    555554// to TTY terminal identified by the channel argument.
    556555//////////////////////////////////////////////////////////////////////////////
     
    577576    // check TTY channel
    578577    l           = (proc_id % NB_PROCS_MAX);
    579     x           = (proc_id / NB_PROCS_MAX) >> Y_WIDTH; 
     578    x           = (proc_id / NB_PROCS_MAX) >> Y_WIDTH;
    580579    y           = (proc_id / NB_PROCS_MAX) & ((1<<Y_WIDTH) - 1);
    581580    channel = (x * Y_SIZE + y) * NB_PROCS_MAX + l;
     
    600599//  The <DEL> character is interpreted, and previous characters can be
    601600//  cancelled. All others characters are ignored.
    602 //  When the <LF> or <CR> character is received, the string is converted 
     601//  When the <LF> or <CR> character is received, the string is converted
    603602//  to an unsigned int value. If the number of decimal digit is too large
    604603//  for the 32 bits range, the zero value is returned.
     
    624623    // check TTY channel
    625624    l           = (proc_id % NB_PROCS_MAX);
    626     x           = (proc_id / NB_PROCS_MAX) >> Y_WIDTH; 
     625    x           = (proc_id / NB_PROCS_MAX) >> Y_WIDTH;
    627626    y           = (proc_id / NB_PROCS_MAX) & ((1<<Y_WIDTH) - 1);
    628627    channel = (x * Y_SIZE + y) * NB_PROCS_MAX + l;
     
    702701
    703702    // compute TTY channel :
    704     // if the number of TTY channels is smaller 
     703    // if the number of TTY channels is smaller
    705704    // than the number of clusters, use TTY_0_0
    706705    // else, TTY channel <= cluster index
     
    711710    else
    712711    {
    713         x           = (proc_id / NB_PROCS_MAX) >> Y_WIDTH; 
     712        x           = (proc_id / NB_PROCS_MAX) >> Y_WIDTH;
    714713        y           = (proc_id / NB_PROCS_MAX) & ((1<<Y_WIDTH) - 1);
    715714        channel     = (x * Y_SIZE + y);
    716715    }
    717716
    718     // take the TTY lock 
     717    // take the TTY lock
    719718    _tty_get_lock( channel );
    720719
    721720printf_text:
    722721
    723     while (*format) 
     722    while (*format)
    724723    {
    725724        unsigned int i;
    726725        for (i = 0; format[i] && format[i] != '%'; i++)
    727726            ;
    728         if (i) 
     727        if (i)
    729728        {
    730729            _tty_write( format, i, channel );
    731730            format += i;
    732731        }
    733         if (*format == '%') 
     732        if (*format == '%')
    734733        {
    735734            format++;
     
    762761                break;
    763762            case ('d'):             // decimal signed integer
    764                 if (val < 0) 
     763                if (val < 0)
    765764                {
    766765                    val = -val;
     
    768767                }
    769768            case ('u'):             // decimal unsigned integer
    770                 for( i=0 ; i<10 ; i++) 
     769                for( i=0 ; i<10 ; i++)
    771770                {
    772771                    buf[9-i] = HexaTab[val % 10];
     
    778777            case ('x'):             // hexadecimal integer
    779778                _tty_write( "0x", 2, channel );
    780                 for( i=0 ; i<8 ; i++) 
     779                for( i=0 ; i<8 ; i++)
    781780                {
    782781                    buf[7-i] = HexaTab[val % 16U];
     
    858857//////////////////////////////////////////////////////////////////////////////////////////
    859858// The block size is 512 bytes.
    860 // The functions below use the three variables _ioc_lock _ioc_done, 
     859// The functions below use the three variables _ioc_lock _ioc_done,
    861860// and _ioc_status for synchronisation.
    862861// - As the IOC component can be used by several programs running in parallel,
    863862// the _ioc_lock variable guaranties exclusive access to the device.
    864863// The _ioc_read() and _ioc_write() functions use atomic LL/SC to get the lock.
    865 // and set _ioc_lock to a non zero value. 
     864// and set _ioc_lock to a non zero value.
    866865// The _ioc_write() and _ioc_read() functions are blocking, polling the _ioc_lock
    867866// variable until the device is available.
     
    873872// reset the _ioc_done variable to zero, and releases the _ioc_lock variable.
    874873///////////////////////////////////////////////////////////////////////////////////////
    875 //  If USE_RAMDISK is set, we access a "virtual" block device controler  implemented 
     874//  If USE_RAMDISK is set, we access a "virtual" block device controler  implemented
    876875//  as a memory-mapped segment in cluster [0,0] at address seg_ramdisk_base.
    877876//  The tranfer being fully synchronous, the IOC interrupt is not activated.
     
    879878
    880879///////////////////////////////////////////////////////////////////////////////////////
    881 // This blocking function is used by the _ioc_read() and _ioc_write() functions 
     880// This blocking function is used by the _ioc_read() and _ioc_write() functions
    882881// to get _ioc_lock using LL/SC.
    883882///////////////////////////////////////////////////////////////////////////////////////
    884883in_drivers void _ioc_get_lock()
    885884{
    886     register unsigned int*  plock = (unsigned int*)&_ioc_lock;         
     885    register unsigned int*  plock = (unsigned int*)&_ioc_lock;
    887886
    888887    asm volatile (
     
    890889            "ll     $2,     0(%0)       \n" // $2 <= _ioc_lock
    891890            "bnez   $2,     1b          \n" // retry  if busy
    892             "li     $3,     1           \n" // prepare argument for sc 
     891            "li     $3,     1           \n" // prepare argument for sc
    893892            "sc     $3,     0(%0)       \n" // try to set _ioc_busy
    894             "beqz   $3,     1b          \n" // retry if not atomic 
     893            "beqz   $3,     1b          \n" // retry if not atomic
    895894            ::"r"(plock) :"$2","$3");
    896895}
     
    903902// - ext    : cluster index for the memory buffer
    904903///////////////////////////////////////////////////////////////////////////////////////
    905 in_drivers void _ioc_write( size_t   lba, 
    906                             void*    buffer, 
     904in_drivers void _ioc_write( size_t   lba,
     905                            void*    buffer,
    907906                            size_t   count,
    908907                            size_t   ext )
     
    923922                          src_address,
    924923                          count*512 );
    925        
     924
    926925        _ioc_status = BLOCK_DEVICE_WRITE_SUCCESS;
    927926        _ioc_done   = 1;
     
    946945// - ext    : cluster index for the memory buffer
    947946///////////////////////////////////////////////////////////////////////////////////////
    948 in_drivers void _ioc_read( size_t   lba, 
    949                            void*    buffer, 
     947in_drivers void _ioc_read( size_t   lba,
     948                           void*    buffer,
    950949                           size_t   count,
    951950                           size_t   ext )
     
    995994{
    996995    // waiting for completion
    997     while (_ioc_done == 0)  asm volatile("nop"); 
    998    
     996    while (_ioc_done == 0)  asm volatile("nop");
     997
    999998    // reset synchronisation variables
    1000999    _ioc_done = 0;
     
    10281027//  FRAME_BUFFER
    10291028//////////////////////////////////////////////////////////////////////////////////////
    1030 // The _fb_sync_write & _fb_sync_read functions use a memcpy strategy to implement 
     1029// The _fb_sync_write & _fb_sync_read functions use a memcpy strategy to implement
    10311030// the transfer between a data buffer and the frame buffer.
    10321031// They are blocking until completion of the transfer.
     
    10411040// - ext    : cluster_xy for the user buffer
    10421041//////////////////////////////////////////////////////////////////////////////////////
    1043 in_drivers void _fb_sync_write( unsigned int  offset, 
    1044                                 unsigned int  buffer, 
     1042in_drivers void _fb_sync_write( unsigned int  offset,
     1043                                unsigned int  buffer,
    10451044                                unsigned int  length,
    10461045                                unsigned int  ext )
     
    10491048    unsigned int  src_cluster = ext;
    10501049    unsigned int  dst_address = (unsigned int)&seg_fbf_base + offset;
    1051     unsigned int  dst_cluster = (X_IO << Y_WIDTH) | Y_IO;  // cluster_xy for I/O
    1052 
    1053     _extended_memcpy( dst_cluster,
     1050
     1051    _extended_memcpy( CLUSTER_IO,
    10541052                      dst_address,
    10551053                      src_cluster,
     
    10661064// - ext    : cluster_xy for the user buffer
    10671065//////////////////////////////////////////////////////////////////////////////////////
    1068 in_drivers void  _fb_sync_read( unsigned int  offset, 
    1069                                 unsigned int  buffer, 
     1066in_drivers void  _fb_sync_read( unsigned int  offset,
     1067                                unsigned int  buffer,
    10701068                                unsigned int  length,
    10711069                                unsigned int  ext )
     
    10741072    unsigned int  dst_cluster = ext;
    10751073    unsigned int  src_address = (unsigned int)&seg_fbf_base + offset;
    1076     unsigned int  src_cluster = (X_IO << Y_WIDTH) | Y_IO;  // cluster_xy for I/O
    10771074
    10781075    _extended_memcpy( dst_cluster,
    10791076                      dst_address,
    1080                       src_cluster,
     1077                      CLUSTER_IO,
    10811078                      src_address,
    10821079                      length );
     
    10931090    //int*         mmc_address = (int*)&seg_mmc_base;
    10941091    unsigned int cluster_xy  = _procid() / NB_PROCS_MAX;
    1095    
     1092
    10961093    _tty_printf( "WRITE ERROR signaled by Memory Cache in cluster %x\n", cluster_xy );
    10971094}
    10981095
    10991096///////////////////////////////////////////////////////////////////////////////////////
    1100 // Release a software spin-lock 
     1097// Release a software spin-lock
    11011098///////////////////////////////////////////////////////////////////////////////////////
    11021099in_drivers void _release_lock(size_t index)
    11031100
    11041101{
    1105     if( index >= NB_LOCKS ) 
     1102    if( index >= NB_LOCKS )
    11061103    {
    11071104        _tty_get_lock( 0 );
     
    11101107        _exit();
    11111108    }
    1112    
     1109
    11131110    _spin_lock[index] = 0;
    11141111}
     
    11321129
    11331130    register int   delay = ((_proctime() +_procid()) & 0xF) << 4;
    1134     register int * plock = (int *) &_spin_lock[index];         
     1131    register int * plock = (int *) &_spin_lock[index];
    11351132
    11361133    asm volatile ("_locks_llsc:             \n"
    11371134                  "ll   $2,    0(%0)        \n"     // $2 <= _locks_lock
    11381135                  "bnez $2,    _locks_delay \n"     // random delay if busy
    1139                   "li   $3,    1            \n"     // prepare argument for sc 
     1136                  "li   $3,    1            \n"     // prepare argument for sc
    11401137                  "sc   $3,    0(%0)        \n"     // try to set _locks_busy
    1141                   "bnez $3,    _locks_ok    \n"     // exit if atomic 
     1138                  "bnez $3,    _locks_ok    \n"     // exit if atomic
    11421139                  "_locks_delay:            \n"
    11431140                  "move $4,    %1           \n"     // $4 <= delay
     
    11551152// - barrier_count[index] <= N
    11561153// - barrier_lock[index]  <= 0
    1157 // All tasks try to initialize the barrier, but the initialisation 
     1154// All tasks try to initialize the barrier, but the initialisation
    11581155// is done by only one task, using LL/SC instructions.
    1159 // This cooperative initialisation is questionnable, 
     1156// This cooperative initialisation is questionnable,
    11601157// because the barrier can ony be initialised once...
    11611158//////////////////////////////////////////////////////////////////////////////////////
     
    11761173    // parallel initialisation using atomic instructions LL/SC
    11771174    asm volatile ("_barrier_init_test:              \n"
    1178                   "ll   $2,     0(%0)               \n" // read barrier_value 
     1175                  "ll   $2,     0(%0)               \n" // read barrier_value
    11791176                  "bnez $2,     _barrier_init_done  \n"
    11801177                  "move $3,     %3                  \n"
    11811178                  "sc   $3,     0(%0)               \n" // try to write barrier_value
    11821179                  "beqz $3,     _barrier_init_test  \n"
    1183                   "move $3, %3                      \n" 
     1180                  "move $3, %3                      \n"
    11841181                  "sw   $3, 0(%1)                   \n" // barrier_count <= barrier_value
    1185                   "move $3, $0                      \n" // 
     1182                  "move $3, $0                      \n" //
    11861183                  "sw   $3, 0(%2)                   \n" // barrier_lock <= 0
    11871184                  "_barrier_init_done:          \n"
     
    11901187
    11911188//////////////////////////////////////////////////////////////////////////////////////
    1192 // This blocking function uses a busy_wait technics (on the barrier_lock value), 
    1193 // because the GIET does not support dynamic scheduling/descheduling of tasks. 
     1189// This blocking function uses a busy_wait technics (on the barrier_lock value),
     1190// because the GIET does not support dynamic scheduling/descheduling of tasks.
    11941191// The barrier state is actually defined by two variables:
    11951192// _barrier_count[index] define the number of particpants that are waiting
    1196 // _barrier_lock[index] define the bool variable whose value is polled 
     1193// _barrier_lock[index] define the bool variable whose value is polled
    11971194// The last participant change the value of _barrier_lock[index] to release the barrier...
    11981195// There is at most 16 independant barriers, and an error is returned
     
    12011198in_drivers void _barrier_wait(unsigned int index)
    12021199{
    1203     register int*   pcount      = (int*)&_barrier_count[index];     
     1200    register int*   pcount      = (int*)&_barrier_count[index];
    12041201    register int    count;
    1205     int             lock        = _barrier_lock[index];     
     1202    int             lock        = _barrier_lock[index];
    12061203
    12071204    if ( index >= NB_BARRIERS )
     
    12121209        _exit();
    12131210    }
    1214    
     1211
    12151212    // parallel decrement _barrier_count[index] using atomic instructions LL/SC
    12161213    // input : pointer on _barrier_count[index]
     
    12381235        while ( lock == _barrier_lock[index] );
    12391236    }
    1240 } 
     1237}
    12411238
    12421239
  • trunk/softs/giet_tsar/stdio.h

    r743 r744  
    11////////////////////////////////////////////////////////////////////////////////////////
    22// File : stdio.h
    3 // Written by Alain Greiner 
     3// Written by Alain Greiner
    44// Date : 17/01/2014
    55//
     
    9595void            _mmc_isr();
    9696
    97 void            _fb_sync_write( unsigned int offset, 
     97void            _fb_sync_write( unsigned int offset,
    9898                                unsigned int buffer,
    9999                                unsigned int length,
    100100                                unsigned int ext );
    101 void            _fb_sync_read(  unsigned int offset, 
     101void            _fb_sync_read(  unsigned int offset,
    102102                                unsigned int buffer,
    103103                                unsigned int length,
     
    110110void            _barrier_wait(size_t index);
    111111
    112 volatile unsigned char _byte_extended_read( unsigned int cluster, 
     112volatile unsigned char _byte_extended_read( unsigned int cluster,
    113113                                            unsigned int address );
    114 volatile unsigned int  _word_extended_read( unsigned int cluster, 
     114volatile unsigned int  _word_extended_read( unsigned int cluster,
    115115                                            unsigned int address );
    116116
    117 void            _word_extended_write( unsigned int   cluster, 
    118                                       unsigned int   address, 
     117void            _word_extended_write( unsigned int   cluster,
     118                                      unsigned int   address,
    119119                                      unsigned int   word );
    120 void            _byte_extended_write( unsigned int   cluster, 
    121                                       unsigned int   address, 
     120void            _byte_extended_write( unsigned int   cluster,
     121                                      unsigned int   address,
    122122                                      unsigned char  byte );
    123123#endif
  • trunk/softs/soft_sort_giet/Makefile

    r626 r744  
    44DU = mipsel-unknown-elf-objdump
    55
    6 OBJS =   reset.o \
    7          giet.o \
    8          stdio.o \
    9          main.o
     6OBJS = reset.o \
     7       giet.o \
     8       stdio.o \
     9       main.o
    1010
    11 CFLAGS = -Wall -mno-gpopt -ffreestanding -fomit-frame-pointer -mips32 -ggdb
     11CFLAGS = -Wall -mno-gpopt -ffreestanding -fomit-frame-pointer -mips32
    1212
    1313GIET =  ../giet_tsar
  • trunk/softs/soft_transpose_giet/Makefile

    r623 r744  
    44DU = mipsel-unknown-elf-objdump
    55
    6 OBJS =   reset.o \
    7          giet.o \
    8          stdio.o \
    9          main.o
     6OBJS = reset.o \
     7       giet.o \
     8       stdio.o \
     9       main.o
    1010
    11 CFLAGS = -Wall -mno-gpopt -ffreestanding -fomit-frame-pointer -mips32 -ggdb
     11CFLAGS = -Wall -mno-gpopt -ffreestanding -fomit-frame-pointer -mips32 \
     12         -msoft-float -O2 \
     13         # -ggdb -mlong-calls
    1214
    1315GIET =  ../giet_tsar
     
    1820
    1921reset.o: $(GIET)/reset.S hard_config.h
    20         $(CC) -I. $(CFLAGS) -c -o $@ $<
     22        $(CC) -I. -I$(GIET) $(CFLAGS) -c -o $@ $<
    2123        $(DU) -D $@ > $@.txt
    2224
  • trunk/softs/soft_transpose_giet/hard_config.h

    r632 r744  
    77#define _HARD_CONFIG_H
    88
    9 #define  X_SIZE              2
    10 #define  Y_SIZE              2
     9#define  X_SIZE              6
     10#define  Y_SIZE              6
    1111#define  X_WIDTH             4
    1212#define  Y_WIDTH             4
     13#define  X_IO                0//(X_SIZE - 1)
     14#define  Y_IO                0//(Y_SIZE - 1)
    1315
    14 #define  NB_PROCS_MAX        1
     16#define  NB_PROCS_MAX        4
    1517
    16 #define  USE_RAMDISK         1
    17 #define  USE_EXT_IO          0
     18#define  USE_RAMDISK         0
     19#define  USE_PIC             1
    1820
    1921#define  NB_DMA_CHANNELS     0
     
    2123#define  NB_NIC_CHANNELS     0
    2224#define  NB_CMA_CHANNELS     0
    23 
    2425#define  NB_TTY_CHANNELS     1
    2526
  • trunk/softs/soft_transpose_giet/ldscript

    r631 r744  
    1010peripherals are not present in the architecture */
    1111
    12 seg_reset_base   = 0x00000000;       /* boot code                   */
     12seg_reset_base   = 0xBFC00000;       /* boot code                   */
    1313
    1414seg_kcode_base   = 0x00010000;       /* kernel code                 */
     
    2020
    2121seg_heap_base    = 0x00100000;       /* heaps for applications      */
    22 seg_stack_base   = 0x00300000;       /* stacks ifor applications    */
     22seg_stack_base   = 0x00300000;       /* stacks for applications     */
    2323
    24 seg_ramdisk_base = 0x00800000;       /* virtual disk                */
     24seg_ramdisk_base = 0xFFFFFFFF;       /* virtual disk                */
    2525
    26 seg_xcu_base     = 0xF0000000;       /* controler XCU               */
    27 seg_tty_base     = 0xF4000000;       /* controler TTY               */
    28 seg_fbf_base     = 0xF3000000;       /* controler FBF               */
    29 seg_ioc_base     = 0xF2000000;       /* controler IOC               */
    30 seg_nic_base     = 0xF7000000;       /* controler NIC               */
    31 seg_cma_base     = 0xF8000000;       /* controler CMA               */
    32 seg_pic_base     = 0xF9000000;       /* controler PIC               */
    33 seg_mmc_base     = 0xE0000000;       /* config    MMC               */
     26seg_xcu_base     = 0xB0000000;       /* XCU controller              */
     27seg_dma_base     = 0xB1000000;       /* DMA controller              */
     28seg_mmc_base     = 0xB2000000;       /* config    MMC               */
     29seg_ioc_base     = 0xB3000000;       /* IOC controller              */
     30seg_tty_base     = 0xB4000000;       /* TTY controller              */
     31seg_nic_base     = 0xB5000000;       /* NIC controller              */
     32seg_cma_base     = 0xB6000000;       /* CMA controller              */
     33seg_fbf_base     = 0xB7000000;       /* FBF controller              */
     34seg_pic_base     = 0xB8000000;       /* PIC controller              */
    3435
     36ENTRY(reset)
    3537
    3638/* Grouping sections into segments */
     
    6062   seg_code : {
    6163      *(.text)
     64      *(.text.*)
    6265   }
    6366   . = seg_reset_base;
  • trunk/softs/soft_transpose_giet/main.c

    r631 r744  
    1212#define PRINTF(...)      ({ if (lpid == 0) { _tty_printf(__VA_ARGS__); } })
    1313
    14 #define DISPLAY_OK          1   // enable display on frame buffer when non zero
    15 #define CHECK_VERBOSE        // display a detailed check on TTY  when non zero
    16 #define INSTRUMENTATION_OK  0   // display statistcs on TTY when non zero
     14#define DISPLAY_OK          1           // enable display on frame buffer when non zero
     15#define CHECK_VERBOSE       !DISPLAY_OK // display a detailed check on TTY  when non zero
     16#define INSTRUMENTATION_OK  0           // display statistcs on TTY when non zero
    1717
    1818// tricks to read some addresses from ldscript
     
    4141    unsigned int l;                                             // line index for loops
    4242    unsigned int p;                                             // pixel index for loops
    43 
    44     unsigned int * ioc_address = (unsigned int *) &seg_ioc_base;
    45     unsigned int block_size    = ioc_address[BLOCK_DEVICE_BLOCK_SIZE];
    46 
     43    unsigned int block_size  = _ioc_get_blocksize();            // get IOC block size
    4744    unsigned int proc_id     = _procid();                       // processor id
    4845    unsigned int nclusters   = X_SIZE*Y_SIZE;                   // number of clusters
     
    128125      LOAD_END[cluster_id][lpid] = _proctime();
    129126
     127
     128      _tty_printf("*** Proc [%d,%d,%d] barrier wait (0)\n", x, y, lpid);
    130129      _barrier_wait(0);
    131130
Note: See TracChangeset for help on using the changeset viewer.