Changeset 207 for soft/giet_vm/sys


Ignore:
Timestamp:
Aug 16, 2012, 6:36:16 PM (12 years ago)
Author:
alain
Message:

Several bugs have been fixed to support TSAR multi-cluster architecture
such as the "tsarv4-generic_mmu" platform.

Location:
soft/giet_vm/sys
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/sys/common.c

    r199 r207  
    1313#include <ctx_handler.h>
    1414#include <drivers.h>
     15#include <hwr_mapping.h>
    1516#include <stdarg.h>
    1617
     
    153154////////////////////////////////////////////////////////////////////////////
    154155//    _puts()
    155 // display a string on TTY0 / used for system code debugand log
    156 ////////////////////////////////////////////////////////////////////////////
    157 void _puts(char *buffer)
    158 {
    159     unsigned int* tty_address = (unsigned int*)&seg_tty_base;
     156// display a string on TTY0 / used for system code debug and log
     157////////////////////////////////////////////////////////////////////////////
     158void _puts(char* buffer)
     159{
     160    unsigned int* tty_address = (unsigned int*)( (char*)&seg_tty_base +
     161                                (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) );
    160162    unsigned int n;
    161163
     
    163165    {
    164166        if (buffer[n] == 0) break;
    165         tty_address[0] = (unsigned int)buffer[n];
     167        tty_address[TTY_WRITE] = (unsigned int)buffer[n];
    166168    }
    167169}
    168170////////////////////////////////////////////////////////////////////////////
    169 //    _putw()
     171//    _putx()
    170172// display an int (hexa) on TTY0 / used for system code debug and log
    171173////////////////////////////////////////////////////////////////////////////
    172 void _putw(unsigned int val)
     174void _putx(unsigned int val)
    173175{
    174176    static const char   HexaTab[] = "0123456789ABCDEF";
  • soft/giet_vm/sys/common.h

    r203 r207  
    3333
    3434void                            _puts(char *string);
    35 void                            _putw(unsigned int val);
     35void                            _putx(unsigned int val);
    3636void                            _putd(unsigned int val);
    3737
  • soft/giet_vm/sys/drivers.c

    r205 r207  
    231231    _get_lock(&_tty_put_lock);
    232232    _puts("\n[GIET ERROR] TTY index too large for task ");
    233     _putw( task_id );
     233    _putd( task_id );
    234234    _puts(" on processor ");
    235     _putw( proc_id );
     235    _putd( proc_id );
    236236    _puts("\n");
    237237    _release_lock(&_tty_put_lock);
     
    316316////////////////////////////////////////////////////////////////////////////////
    317317unsigned int _tty_get_char( unsigned int        tty_id,
    318                             char*           buffer )
     318                            unsigned char*  buffer )
    319319{
    320320    // checking argument
     
    731731//////////////////////////////////////////////////////////////////////////////////
    732732unsigned int _dma_reset_irq( unsigned int       cluster_id,
    733                              unsigned int       local_id )
     733                             unsigned int       channel_id )
    734734{
    735735    // parameters checking
    736736    if ( cluster_id >= NB_CLUSTERS ) return 1;
    737     if ( local_id >= NB_DMAS_MAX )  return 1;
     737    if ( channel_id >= NB_DMAS_MAX ) return 1;
    738738
    739739    // compute DMA base address
     
    741741                                  (cluster_id * (unsigned)CLUSTER_SIZE) );
    742742
    743     dma_address[local_id*DMA_SPAN + DMA_RESET] = 0;                     
     743    dma_address[channel_id*DMA_SPAN + DMA_RESET] = 0;                   
    744744    return 0;
    745745}
     
    748748//////////////////////////////////////////////////////////////////////////////////
    749749unsigned int _dma_get_status( unsigned int      cluster_id,
    750                               unsigned int      local_id,
     750                              unsigned int      channel_id,
    751751                              unsigned int* status )
    752752{
    753753    // parameters checking
    754754    if ( cluster_id >= NB_CLUSTERS ) return 1;
    755     if ( local_id >= NB_DMAS_MAX )  return 1;
     755    if ( channel_id >= NB_DMAS_MAX ) return 1;
    756756
    757757    // compute DMA base address
    758758    unsigned int*       dma_address = (unsigned int*)( (char*)&seg_dma_base +
    759759                                  (cluster_id * (unsigned)CLUSTER_SIZE) );
    760    
    761     *status = dma_address[local_id*DMA_SPAN + DMA_LEN];
     760
     761    *status = dma_address[channel_id*DMA_SPAN + DMA_LEN];
    762762    return 0;
    763763}
     
    839839// - user_vaddr : virtual base address of the memory buffer.
    840840// - length     : number of bytes to be transfered.
    841 // The memory buffer must be mapped in user address space and word-aligned.
     841// The user buffer must be mapped in user address space and word-aligned.
    842842// The user buffer length must be multiple of 4 bytes.
    843843// Me must compute the physical base addresses for both the frame buffer
    844844// and the user buffer before programming the DMA transfer.
    845 // The GIET being fully static, we don't need to split the transfer in 4Kbytes
     845// The GIET being fully static, we don't need to split the transfer in 4 Kbytes
    846846// pages, because the user buffer is contiguous in physical space.
    847847// Returns 0 if success, > 0 if error.
     
    871871    {
    872872        _get_lock(&_tty_put_lock);
    873         _puts("[GIET ERROR] in _fbdma_access() : user buffer not word aligned\n");
     873        _puts("\n[GIET ERROR] in _fbdma_access() : user buffer not word aligned\n");
    874874        _release_lock(&_tty_put_lock);
    875875        return 1;
     
    880880
    881881    // compute frame buffer pbase address
    882     unsigned int fb_vaddr = (unsigned int)&seg_fbf_base + offset;
     882    unsigned int fb_vaddr = (unsigned int)&seg_fbf_base +
     883                            (CLUSTER_IO_ID * (unsigned int)CLUSTER_SIZE) + offset;
    883884
    884885    ko = _v2p_translate( (page_table_t*)user_ptab,
     
    891892    {
    892893        _get_lock(&_tty_put_lock);
    893         _puts("[GIET ERROR] in _fbdma_access() : frame buffer unmapped\n");
     894        _puts("\n[GIET ERROR] in _fbdma_access() : frame buffer unmapped\n");
    894895        _release_lock(&_tty_put_lock);
    895896        return 2;
     
    906907    {
    907908        _get_lock(&_tty_put_lock);
    908         _puts("[GIET ERROR] in _fbdma_access() : user buffer unmapped\n");
     909        _puts("\n[GIET ERROR] in _fbdma_access() : user buffer unmapped\n");
    909910        _release_lock(&_tty_put_lock);
    910911        return 3;
     
    920921    {
    921922        _get_lock(&_tty_put_lock);
    922         _puts("[GIET ERROR] in _fbdma_access() : user buffer not writable\n");
     923        _puts("\n[GIET ERROR] in _fbdma_access() : user buffer not writable\n");
    923924        _release_lock(&_tty_put_lock);
    924925        return 5;
  • soft/giet_vm/sys/drivers.h

    r204 r207  
    4141
    4242unsigned int _tty_get_char( unsigned int        tty_id,
    43                             char*                       buffer);
     43                            unsigned char*      buffer);
    4444
    4545///////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/sys/exc_handler.c

    r199 r207  
    7777    _puts( (char*)exc_type[type] );
    7878    _puts("\n - EPC       : ");
    79     _putw( _get_epc() );
     79    _putx( _get_epc() );
    8080    _puts("\n - BVAR      : ");
    81     _putw( _get_bvar() );
     81    _putx( _get_bvar() );
    8282    _puts("\n");
    8383
  • soft/giet_vm/sys/irq_handler.c

    r204 r207  
    8282// This ISR handles all IRQs generated by the multi-channels DMA controlers.
    8383// The multi_dma components can be distributed in the clusters.
    84 // The channel_id argument is the global DMA channel index.
    85 //     channel_id = cluster_id*NB_DMAS_MAX + loc_id
    86 // - The ISR saves the transfert status in _dma_status[channel_id].
     84// The channel_id argument is the local DMA channel index.
     85//     dma_global_id = cluster_id*NB_DMAS_MAX + channel_id
     86// - The ISR saves the transfert status in _dma_status[dma_global_id].
    8787// - It acknowledges the interrupt to reinitialize the DMA controler.
    88 // - it resets the synchronisation variable _dma_busy[channel_id].
     88// - it resets the synchronisation variable _dma_busy[dma_global_id].
    8989///////////////////////////////////////////////////////////////////////////////////
    9090void _isr_dma( unsigned int channel_id )
    9191{
    92     // compute cluster_id and loc_id
    93     unsigned int cluster_id = channel_id / NB_DMAS_MAX;
    94     unsigned int local_id   = channel_id % NB_DMAS_MAX;
     92    // compute cluster_id
     93    unsigned int cluster_id = _procid()/NB_PROCS_MAX;
     94
     95    // compute dma_global_id
     96    unsigned int dma_global_id = cluster_id*NB_DMAS_MAX + channel_id;
    9597
    9698    // save DMA channel status 
    97     if ( _dma_get_status(cluster_id, local_id, &_dma_status[channel_id]) )
     99    if ( _dma_get_status(cluster_id,
     100                         channel_id,
     101                         (unsigned int*)&_dma_status[dma_global_id] ) )
    98102    {
    99103        _get_lock(&_tty_put_lock);
     
    104108
    105109    // reset DMA channel irq
    106     if ( _dma_reset_irq(cluster_id, local_id) )
     110    if ( _dma_reset_irq( cluster_id,
     111                         channel_id) )
    107112    {
    108113        _get_lock(&_tty_put_lock);
     
    113118
    114119    // release DMA channel
    115     _dma_done[channel_id] = 1; 
     120    _dma_done[dma_global_id] = 1; 
    116121}
    117122
     
    125130{
    126131     // save status & reset IRQ
    127     if ( _ioc_get_status( &_ioc_status ) )
     132    if ( _ioc_get_status( (unsigned int*)&_ioc_status ) )
    128133    {
    129134        _get_lock(&_tty_put_lock);
     
    143148// These timers are distributed in all clusters, and can be implemented
    144149// in a vci_multi_timer component, or in a vci_xicu component.
    145 // The timer_id argument is a global index:
    146 //     timer_id = cluster_id*(NB_TIMERS_MAX+NB_PROCS_MAX) + local_id
    147 // The user timer local index is (loc_id - NB_PROCS_MAX).
    148 //
     150// The timer_id argument is the user timer local index.
     151//     timer_globa_id = cluster_id*(NB_TIMERS_MAX) + timer_id
    149152// The ISR acknowledges the IRQ and registers the event in the proper entry
    150153// of the _timer_event[] array, and a log message is displayed on kernel terminal.
     
    152155void _isr_timer(unsigned int timer_id)
    153156{
    154 
    155     unsigned int cluster_id = timer_id / (NB_TIMERS_MAX + NB_PROCS_MAX);
    156     unsigned int local_id   = timer_id % (NB_TIMERS_MAX + NB_PROCS_MAX);
    157 
    158     // checking timer type
    159     if (local_id < NB_PROCS_MAX )
    160     {
    161         _get_lock(&_tty_put_lock);
    162         _puts("[GIET ERROR] Strange... User timer ISR for a system timer\n");
    163         _release_lock(&_tty_put_lock);
    164         return;
    165     }
     157    // compute cluster_id
     158    unsigned int cluster_id = _procid()/NB_PROCS_MAX;
    166159
    167160    // aknowledge IRQ
    168     if ( _timer_reset_irq( cluster_id, local_id ) )
     161    if ( _timer_reset_irq( cluster_id,
     162                           NB_PROCS_MAX + timer_id ) )
    169163    {
    170164        _get_lock(&_tty_put_lock);
     
    176170#if NB_TIMERS_MAX
    177171    // register the event
    178     _timer_event[(cluster_id*NB_TIMERS_MAX) + (loc_id - NB_PROCS_MAX)] = 1;
     172    unsigned int timer_global_id = cluster_id*NB_TIMERS_MAX + timer_id;
     173    _user_timer_event[timer_global_id] = 1;
    179174#endif
    180175
    181176    // display a message on TTY 0
    182177    _get_lock(&_tty_put_lock);
    183     _puts("[GIET] User Timer IRQ at cycle ");
     178    _puts("\n[GIET] User Timer IRQ at cycle ");
    184179    _putd( _proctime() );
    185     _puts(" / index = ");
    186     _putd(timer_id);
     180    _puts("\n - cluster_id = ");
     181    _putd( cluster_id );
     182    _puts("\n - timer_id   = ");
     183    _putd( timer_id );
    187184    _puts("\n");
    188185    _release_lock(&_tty_put_lock);
     
    194191// signaling that a character is available.
    195192// There is one single multi_tty component controling all TTYs,
    196 // and the tty_id // argument is the global TTY index.
     193// and the tty_id argument is the global TTY index.
    197194// There is one communication buffer _tty_buf[tty_id] per terminal.
    198195// The sychronisation variable _tty_full[tty_id], is set by the ISR,
     
    203200{
    204201    // save character and reset IRQ
    205     if ( _tty_get_char( tty_id, &_tty_get_buf[tty_id] ) )
     202    if ( _tty_get_char( tty_id,
     203                        (unsigned char*)&_tty_get_buf[tty_id] ) )
    206204    {
    207205        _get_lock(&_tty_put_lock);
  • soft/giet_vm/sys/kernel_init.c

    r203 r207  
    5454{
    5555    // compute cluster and local processor index
    56     unsigned int        proc_id    = _procid();
    57     unsigned int    cluster_id = proc_id / NB_PROCS_MAX;
    58     unsigned int    lpid       = proc_id % NB_PROCS_MAX;
     56    unsigned int        global_pid = _procid();
     57    unsigned int    cluster_id = global_pid / NB_PROCS_MAX;
     58    unsigned int    proc_id    = global_pid % NB_PROCS_MAX;
     59
     60    // Step 0 : Compute number of tasks allocated to proc
     61
     62    unsigned int tasks = _get_tasks_number();
     63
     64#if GIET_DEBUG_INIT
     65_get_lock(&_tty_put_lock);
     66_puts("\n[GIET DEBUG] step 0 for processor ");
     67_putd( global_pid );
     68_puts(" : tasks = ");
     69_putd( tasks );
     70_puts("\n");
     71_release_lock(&_tty_put_lock);
     72#endif
    5973
    6074    // step 1 : Initialise scheduler physical addresses array
    61 
    62     // get scheduler physical address from register
     75    //          get scheduler physical address (from CP0 register)
     76
    6377    static_scheduler_t*         psched = (static_scheduler_t*)_get_sched();
    64     _schedulers_paddr[proc_id]     = psched;
     78    _schedulers_paddr[global_pid]  = psched;
    6579
    6680#if GIET_DEBUG_INIT
    6781_get_lock(&_tty_put_lock);
    6882_puts("\n[GIET DEBUG] step 1 for processor ");
    69 _putd( proc_id );
     83_putd( global_pid );
    7084_puts(" / scheduler pbase = ");
    71 _putw( (unsigned int)psched );
    72 _puts("\n");
    73 _release_lock(&_tty_put_lock);
    74 #endif
    75 
     85_putx( (unsigned int)psched );
     86_puts("\n");
     87_release_lock(&_tty_put_lock);
     88#endif
    7689
    7790    // step 2 : initialise page table addresse arrays
     
    8093
    8194    unsigned int ltid;
    82     unsigned int tasks = _get_tasks_number();
    8395
    8496    for ( ltid = 0 ; ltid < tasks ; ltid++ )
     
    94106_get_lock(&_tty_put_lock);
    95107_puts("\n[GIET DEBUG] step 2 for processor ");
    96 _putd( proc_id );
     108_putd( global_pid );
    97109_puts(" / vspace ");
    98110_putd( vspace_id );
    99111_puts("\n- ptab vbase = ");
    100 _putw( ptab_vaddr );
     112_putx( ptab_vaddr );
    101113_puts("\n- ptab pbase = ");
    102 _putw( ptab_paddr );
     114_putx( ptab_paddr );
    103115_puts("\n");
    104116_release_lock(&_tty_put_lock);
     
    129141        }
    130142    }
    131     _icu_set_mask( cluster_id, lpid, hwi_mask, 0 ); // set HWI_MASK
    132     _icu_set_mask( cluster_id, lpid, pti_mask, 1 );     // set PTI_MASK
     143    _icu_set_mask( cluster_id, proc_id, hwi_mask, 0 ); // set HWI_MASK
     144    _icu_set_mask( cluster_id, proc_id, pti_mask, 1 );  // set PTI_MASK
    133145   
    134146#if GIET_DEBUG_INIT
    135147_get_lock(&_tty_put_lock);
    136148_puts("\n[GIET DEBUG] step 3 for processor ");
    137 _putd( proc_id );
     149_putd( global_pid );
    138150_puts("\n - ICU HWI_MASK = ");
    139 _putw( hwi_mask );
     151_putx( hwi_mask );
    140152_puts("\n - ICU PTI_MASK = ");
    141 _putw( pti_mask );
    142 _puts("\n");
    143 _release_lock(&_tty_put_lock);
    144 #endif
    145 
     153_putx( pti_mask );
     154_puts("\n");
     155_release_lock(&_tty_put_lock);
     156#endif
    146157
    147158    // step 4 : start TICK timer if more than one task
     
    155166_get_lock(&_tty_put_lock);
    156167_puts("\n[GIET DEBUG] Step 4 for processor ");
    157 _putd( proc_id );
     168_putd( global_pid );
    158169_puts(" / context switch activated\n");
    159170_release_lock(&_tty_put_lock);
     
    169180    _set_context_slot( IDLE_TASK_INDEX, CTX_RUN_ID,  1 );
    170181    _set_context_slot( IDLE_TASK_INDEX, CTX_SR_ID,   0xFF03 );
    171     _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID,   (unsigned int)&_idle_stack[proc_id] + 64 );
     182    _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID,   (unsigned int)&_idle_stack[global_pid] + 64 );
    172183    _set_context_slot( IDLE_TASK_INDEX, CTX_RA_ID,   (unsigned int)&_ctx_eret );
    173184    _set_context_slot( IDLE_TASK_INDEX, CTX_EPC_ID,  (unsigned int)&_ctx_idle );
     
    178189_get_lock(&_tty_put_lock);
    179190_puts("\n[GIET DEBUG] Step 5 for processor ");
    180 _putd( proc_id );
     191_putd( global_pid );
    181192_puts(" / idle task context set\n");
    182193_release_lock(&_tty_put_lock);
     
    195206        _get_lock( &_tty_put_lock );
    196207        _puts("\n [GIET WARNING] No task allocated to processor ");
    197         _putw( proc_id );
     208        _putd( global_pid );
    198209        _puts(" => idle\n");
    199210        _release_lock ( &_tty_put_lock );
     
    212223_get_lock(&_tty_put_lock);
    213224_puts("\n[GIET DEBUG] step 6 for processor ");
    214 _putd( proc_id );
     225_putd( global_pid );
    215226_puts(" / registers initialised \n");
    216227_puts("- sp   = ");
    217 _putw( sp_value );
     228_putx( sp_value );
    218229_puts("\n");
    219230_puts("- sr   = ");
    220 _putw( sr_value );
     231_putx( sr_value );
    221232_puts("\n");
    222233_puts("- ptpr = ");
    223 _putw( ptpr_value<<13 );
     234_putx( ptpr_value<<13 );
    224235_puts("\n");
    225236_puts("- epc  = ");
    226 _putw( epc_value );
     237_putx( epc_value );
    227238_puts("\n");
    228239_release_lock(&_tty_put_lock);
  • soft/giet_vm/sys/sys_handler.c

    r204 r207  
    6666    _puts("\n\n!!! Undefined System Call !!!\n");
    6767    _puts("\nEPC = ");
    68     _putw( epc );
     68    _putx( epc );
    6969    _exit();
    7070}
  • soft/giet_vm/sys/vm_handler.c

    r189 r207  
    4545        _puts("\n[GIET ERROR] in iommu_add_pte2 function\n");
    4646        _puts("the IOMMU PT1 entry is not mapped / ix1 = ");
    47         _putw( ix1 );
     47        _putx( ix1 );
    4848        _puts("\n");
    4949        _exit();
     
    7676        _puts("\n[GIET ERROR] in iommu_inval_pte2 function\n");
    7777        _puts("the IOMMU PT1 entry is not mapped / ix1 = ");
    78         _putw( ix1 );
     78        _putx( ix1 );
    7979        _puts("\n");
    8080        _exit();
     
    105105    unsigned int    ix1 = vpn >> 9;
    106106    unsigned int    ix2 = vpn & 0x1FF;
    107 
     107/*
     108_puts("\n\n********************** entering v2p_translate");
     109_puts("\n - pt    = ");
     110_putx( (unsigned int)pt );
     111_puts("\n - vpn   = ");
     112_putx( vpn << 12 );
     113_puts("\n - ptba  = ");
     114_putx( pt->pt1[ix1] << 12 ) ;
     115_puts("\n - &pte2 = ");
     116_putx( (pt->pt1[ix1] << 12) + 8*ix2 );
     117_puts("\n - flags = ");
     118_putx( *(unsigned int*)((pt->pt1[ix1] << 12) + 8*ix2) );
     119_puts("\n");
     120*/
    108121    // check PTE1 mapping
    109122    if ( (pt->pt1[ix1] & PTE_V) == 0 )
Note: See TracChangeset for help on using the changeset viewer.