Changeset 547 for soft


Ignore:
Timestamp:
Apr 5, 2015, 12:09:09 AM (9 years ago)
Author:
alain
Message:

Move the peripheral initialisation from the boot.c to the kernel_init.c

Location:
soft/giet_vm/giet_kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_kernel/exc_handler.c

    r528 r547  
    3232// Initialize the exception vector indexed by the CR XCODE field
    3333///////////////////////////////////////////////////////////////////////////////////
     34
     35__attribute__((section(".kdata")))
    3436const _exc_func_t _cause_vector[16] =
    3537{
     
    5254};
    5355
    54 static const char * exc_type[] =
    55 {
    56     "strange unknown cause",
    57     "illegal read address",
    58     "illegal write address",
    59     "inst bus error",
    60     "data bus error",
    61     "breakpoint",
    62     "reserved instruction",
    63     "illegal coproc access",
    64     "arithmetic overflow",
    65 };
    66 
    6756///////////////////////////////////////////////
    6857static void _display_cause( unsigned int type )
     
    7766
    7867
     68    const char * mips32_exc_str[] = { "strange unknown cause  ",
     69                                      "illegal read address   ",
     70                                      "illegal write address  ",
     71                                      "inst bus error         ",
     72                                      "data bus error         ",
     73                                      "breakpoint             ",
     74                                      "reserved instruction   ",
     75                                      "illegal coproc access  ",
     76                                      "arithmetic overflow    "};
     77
    7978    _printf("\n[GIET] Exception for task %d on processor[%d,%d,%d] at cycle %d\n"
    8079            " - type      : %s\n"
     
    8382            "...Task desactivated\n",
    8483            task, x, y, lpid, _get_proctime(),
    85             exc_type[type], _get_epc(), _get_bvar() );
     84            mips32_exc_str[type], _get_epc(), _get_bvar() );
    8685
    8786    // goes to sleeping state
  • soft/giet_vm/giet_kernel/irq_handler.c

    r528 r547  
    1818#include <mmc_driver.h>
    1919#include <bdv_driver.h>
     20#include <hba_driver.h>
    2021#include <dma_driver.h>
    21 #include <spi_driver.h>
     22#include <sdc_driver.h>
    2223#include <mwr_driver.h>
    2324#include <mapping_info.h>
     
    5152// irq_handler.h / mapping.py / xml_driver.c
    5253/////////////////////////////////////////////////////////////////////////
    53 __attribute__((section(".kdata")))
    54 char* _isr_type_name[] = { "DEFAULT",
    55                            "TICK"   ,
    56                            "TTY_RX" ,
    57                            "TTY_TX" ,
    58                            "BDV"    ,
    59                            "TIMER"  ,
    60                            "WAKUP"  ,
    61                            "NIC_RX" ,
    62                            "NIC_TX" ,
    63                            "CMA"    ,
    64                            "MMC"    ,
    65                            "DMA"    ,
    66                            "SPI"    ,
    67                            "MWR"    ,
    68                            "HBA"    };
     54
     55__attribute__((section(".kdata")))
     56char* _isr_type_str[] = { "DEFAULT",
     57                          "TICK"   ,
     58                          "TTY_RX" ,
     59                          "TTY_TX" ,
     60                          "BDV"    ,
     61                          "TIMER"  ,
     62                          "WAKUP"  ,
     63                          "NIC_RX" ,
     64                          "NIC_TX" ,
     65                          "CMA"    ,
     66                          "MMC"    ,
     67                          "DMA"    ,
     68                          "SPI"    ,
     69                          "MWR"    ,
     70                          "HBA"    };
     71
     72__attribute__((section(".kdata")))
     73char* _irq_type_str[] = { "HWI",
     74                          "WTI",
     75                          "PTI" };
    6976
    7077////////////////////
     
    8491    mapping_periph_t*    pic        = NULL;
    8592
    86     // scan external peripherals to find XCU
     93    // scan external peripherals to find PIC
    8794    unsigned int min = cluster[cluster_io].periph_offset ;
    8895    unsigned int max = min + cluster[cluster_io].periphs ;
     
    184191    _pic_init( irq_id , wti_addr, cluster_xy );
    185192   
    186     // initializes the WTI interrupt vector entry for XCU
    187     _schedulers[x][y][p]->wti_vector[wti_id] = isr_channel<<16 | isr_type;
     193    // initializes the WTI interrupt vector entry for target XCU
     194    static_scheduler_t*  psched = (static_scheduler_t*)_get_sched();
     195    psched->wti_vector[wti_id] = isr_channel<<16 | isr_type;
     196
     197#if GIET_DEBUG_IRQS
     198_printf("\n[DEBUG IRQS] _ext_irq_alloc() for P[%d,%d,%d] at cycle %d\n"
     199        "  wti_id = %d / isr_type = %s / channel = %d / pic_input = %d\n",
     200        x , y , p , _get_proctime() ,
     201        wti_id , _isr_type_str[isr_type] , isr_channel , irq_id );
     202#endif
    188203
    189204}  // end ext_irq_alloc()
     
    265280        channel    = (entry>>16) & 0x00007FFF;
    266281
    267 #if GIET_DEBUG_IRQS // we don't take the TTY lock to avoid deadlocks
    268 char* irq_type_str[] = { "HWI", "WTI", "PTI" };
    269 _puts("\n[IRQS DEBUG] Processor[");
    270 _putd(x);
    271 _puts(",");
    272 _putd(y);
    273 _puts(",");
    274 _putd(lpid);
    275 _puts("] enters _irq_demux() at cycle ");
    276 _putd(_get_proctime() );
    277 _puts("\n  ");
    278 _puts(irq_type_str[irq_type] );
    279 _puts(" : irq_id = ");
    280 _putd(irq_id);
    281 _puts(" / isr_type = ");
    282 _putd(isr_type);
    283 _puts(" / channel = ");
    284 _putd(channel);
    285 _puts("\n");
     282#if GIET_DEBUG_IRQS    // we don't take the TTY lock to avoid deadlocks
     283_nolock_printf("\n[DEBUG IRQS] _irq_demux() Processor[%d,%d,%d] enters at cycle %d\n"
     284               " irq_type = %s / irq_id = %d / isr_type = %s / channel = %d\n",
     285               x , y , lpid , _get_proctime() ,
     286               _irq_type_str[irq_type] , irq_id , _isr_type_str[isr_type] , channel );   
    286287#endif
    287288
    288289        // ISR call
    289290        if      ( isr_type == ISR_TICK   ) _isr_tick   ( irq_type, irq_id, channel );
    290         else if ( isr_type == ISR_WAKUP  ) _isr_wakup  ( irq_type, irq_id, channel );
    291         else if ( isr_type == ISR_BDV    ) _bdv_isr    ( irq_type, irq_id, channel );
    292         else if ( isr_type == ISR_CMA    ) _cma_isr    ( irq_type, irq_id, channel );
    293291        else if ( isr_type == ISR_TTY_RX ) _tty_rx_isr ( irq_type, irq_id, channel );
    294292        else if ( isr_type == ISR_TTY_TX ) _tty_tx_isr ( irq_type, irq_id, channel );
     293        else if ( isr_type == ISR_BDV    ) _bdv_isr    ( irq_type, irq_id, channel );
     294        else if ( isr_type == ISR_TIMER  ) _timer_isr  ( irq_type, irq_id, channel );
     295        else if ( isr_type == ISR_WAKUP  ) _isr_wakup  ( irq_type, irq_id, channel );
    295296        else if ( isr_type == ISR_NIC_RX ) _nic_rx_isr ( irq_type, irq_id, channel );
    296297        else if ( isr_type == ISR_NIC_TX ) _nic_tx_isr ( irq_type, irq_id, channel );
    297         else if ( isr_type == ISR_TIMER  ) _timer_isr  ( irq_type, irq_id, channel );
     298        else if ( isr_type == ISR_CMA    ) _cma_isr    ( irq_type, irq_id, channel );
    298299        else if ( isr_type == ISR_MMC    ) _mmc_isr    ( irq_type, irq_id, channel );
    299300        else if ( isr_type == ISR_DMA    ) _dma_isr    ( irq_type, irq_id, channel );
    300         else if ( isr_type == ISR_SPI    ) _spi_isr    ( irq_type, irq_id, channel );
     301        else if ( isr_type == ISR_SDC    ) _sdc_isr    ( irq_type, irq_id, channel );
    301302        else if ( isr_type == ISR_MWR    ) _mwr_isr    ( irq_type, irq_id, channel );
     303        else if ( isr_type == ISR_HBA    ) _hba_isr    ( irq_type, irq_id, channel );
    302304        else
    303305        {
    304306            _printf("\n[GIET ERROR] in _irq_demux() :"
    305307                    " illegal ISR type on processor[%d,%d,%d] at cycle %d\n"
    306                     " - irq_type = %d\n"
     308                    " - irq_type = %s\n"
    307309                    " - irq_id   = %d\n"
    308                     " - isr_type = %x\n",
    309                     x, y, lpid, _get_proctime(), irq_type, irq_id, isr_type );
     310                    " - isr_type = %s\n",
     311                    x, y, lpid, _get_proctime(),
     312                    _irq_type_str[irq_type] , irq_id , _isr_type_str[isr_type] );   
     313            _exit();
    310314        }
    311315    }
  • soft/giet_vm/giet_kernel/irq_handler.h

    r528 r547  
    3131    ISR_MMC     = 10,
    3232    ISR_DMA     = 11,
    33     ISR_SPI     = 12,
     33    ISR_SDC     = 12,
    3434    ISR_MWR     = 13,
    3535    ISR_HBA     = 14,
     
    4747extern unsigned char _wti_alloc_two[X_SIZE][Y_SIZE][NB_PROCS_MAX];
    4848extern unsigned char _wti_alloc_ter[X_SIZE][Y_SIZE][NB_PROCS_MAX];
     49
     50// ISR type names
     51extern char* _isr_type_str[GIET_ISR_TYPE_MAX];
     52
     53// IRQ type names
     54extern char* _irq_type_str[3];
    4955
    5056///////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_kernel/kernel_init.c

    r536 r547  
    1818#include <fat32.h>
    1919#include <xcu_driver.h>
     20#include <nic_driver.h>
     21#include <hba_driver.h>
    2022#include <mmc_driver.h>
    2123#include <ctx_handler.h>
     
    144146    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    145147    unsigned int p          = gpid & ((1<<P_WIDTH)-1);
    146 
    147     ////////////////////////////////////////////////////////////////////////////
    148     // Step 0 : P[0,0,0] initialises various global vaiables
    149     ////////////////////////////////////////////////////////////////////////////
     148    unsigned int unused;
     149   
     150    ////////////////////////////////////////////////////////////////////////////
     151    // Step 0 : P[0,0,0] initialises global variables and peripherals
     152   ////////////////////////////////////////////////////////////////////////////
    150153
    151154    if ( gpid == 0 )
    152155    {
    153         // distributed kernel heap initialisation
     156        ////// distributed kernel heap initialisation
    154157        _heap_init();
    155158       
    156159#if GIET_DEBUG_INIT
    157 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes kernel HEAP init\n",
    158                x, y, p );
    159 #endif
    160         // distributed lock for TTY0
     160_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes kernel heap init\n", x, y, p );
     161#endif
     162        //////  distributed lock for TTY0
    161163        _sqt_lock_init( &_tty0_sqt_lock );
    162164
    163165#if GIET_DEBUG_INIT
    164 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes TTY0 lock init\n",
    165                x , y , p );
    166 #endif
    167         // distributed kernel barrier between all processors
     166_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes TTY0 lock init\n", x , y , p );
     167#endif
     168        //////  distributed kernel barrier between all processors
    168169        _sqt_barrier_init( &_all_procs_barrier );
    169170
    170171#if GIET_DEBUG_INIT
    171 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes barrier init\n",
    172                x , y , p );
    173 #endif
    174 
    175 #if USE_PIC
    176 
    177         // _ext_irq_index[isr][channel] initialisation
    178         _ext_irq_init();
    179 
    180         // routing HBA IRQ to proc[0,0,0] EXT_IRQ_ONE
    181         unsigned int unused = 0;
    182         if ( USE_IOC_HBA ) _ext_irq_alloc( ISR_HBA , 0 , &unused );
    183 
    184 #if GIET_DEBUG_INIT
    185 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes ext_irq init\n",
    186                x , y , p );
    187 #endif
    188 
    189 #endif // USE_PIC
    190 
    191         // release other processors
     172_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes barrier init\n", x , y , p );
     173#endif
     174
     175        ////// _ext_irq_index[isr][channel] initialisation
     176        if ( USE_PIC ) _ext_irq_init();
     177
     178#if GIET_DEBUG_INIT
     179_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes ext_irq init\n", x , y , p );
     180#endif
     181
     182        //////  NIC peripheral initialization
     183        if ( USE_NIC ) _nic_global_init( 1,      // broadcast accepted
     184                                         1,      // bypass activated
     185                                         0,      // tdm non activated
     186                                         0 );    // tdm period
     187#if GIET_DEBUG_INIT
     188_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes NIC init\n", x , y , p );
     189#endif
     190
     191        //////  HBA peripheral initialisation
     192        if ( USE_IOC_HBA )
     193        {
     194            _hba_init();
     195
     196            // routing HBA IRQ to proc[0,0,0]
     197            _ext_irq_alloc( ISR_HBA , 0 , &unused );
     198        }
     199
     200#if GIET_DEBUG_INIT
     201_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes HBA init\n", x , y , p );
     202#endif
     203
     204        //////  release other processors
    192205        _kernel_init_done = 1;
    193206    }
     
    209222
    210223#if GIET_DEBUG_INIT
    211 _printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] initialises SCHED array\n"
     224_printf("\n[DEBUG KINIT] P[%d,%d,%d] initialises SCHED array\n"
    212225        " - scheduler vbase = %x\n"
    213226        " - tasks           = %d\n",
     
    255268
    256269#if GIET_DEBUG_INIT
    257 _printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] initialises PTABS arrays"
     270_printf("\n[DEBUG KINIT] P[%d,%d,%d] initialises PTABS arrays"
    258271        " and context for task %d \n"
    259272        " - ptabs_vaddr[%d][%d][%d] = %x\n"
     
    297310
    298311#if GIET_DEBUG_INIT
    299 _printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] initializes idle_task and starts TICK\n", 
     312_printf("\n[DEBUG KINIT] P[%d,%d,%d] initializes idle_task and starts TICK\n", 
    300313        x, y, p );
    301314#endif
     
    306319
    307320#if GIET_DEBUG_INIT
    308 _printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes kernel FAT init\n",
     321_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes kernel FAT init\n",
    309322        x, y, p );
    310323#endif
     
    334347
    335348#if GIET_DEBUG_INIT
    336 _printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] jumps to user code at cycle %d\n"
     349_printf("\n[DEBUG KINIT] P[%d,%d,%d] jumps to user code at cycle %d\n"
    337350        " ltid = %d / sp = %x / sr = %x / ptpr = %x / epc = %x\n",
    338351        x , y , p , _get_proctime() ,
  • soft/giet_vm/giet_kernel/sys_handler.c

    r536 r547  
    2222#include <giet_config.h>
    2323#include <mapping_info.h>
     24#include <irq_handler.h>
    2425#include <io.h>
    2526
     
    517518    else
    518519    {
    519         _set_context_slot( CTX_TTY_ID, channel );
    520         return 0;
    521     }
     520    }
     521
     522    // allocate a WTI mailbox to the calling proc if external IRQ
     523    unsigned int unused;
     524    if ( USE_PIC ) _ext_irq_alloc( ISR_TTY_RX , channel , &unused );
     525   
     526    // update calling task index
     527    _set_context_slot( CTX_TTY_ID, channel );
     528
     529    return 0;
    522530}
    523531
     
    700708unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
    701709_printf("\n[GIET DEBUG NIC] Task %d enters sys_nic_alloc() at cycle %d\n"
    702         " nic_channel = %d / cma_channel = %d\n"
     710        "  nic_channel = %d / cma_channel = %d\n",
    703711        thread , _get_proctime() , nic_channel , cma_channel );
    704712#endif
     
    754762
    755763#if GIET_DEBUG_NIC
    756 _printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_start()"
    757         " allocates container in cluster[%d,%d] : vaddr = %x / paddr = %l\n",
     764_printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_alloc()"
     765        " allocates container in cluster[%d,%d]\n"
     766        "  vaddr = %x / paddr = %l\n",
    758767        thread , cx , cy , vaddr , cont_paddr );
    759768#endif
     
    781790
    782791#if GIET_DEBUG_NIC
    783 _printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_start()"
    784         " get NIC chbuf : paddr = %l\n",
     792_printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_alloc() get NIC chbuf : paddr = %l\n",
    785793        thread , nic_chbuf_pbase );
    786794#endif
     
    793801
    794802#if GIET_DEBUG_NIC
    795 _printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_start()"
    796         " get kernel chbuf : vaddr = %x / paddr = %l\n",
     803_printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_alloc() get kernel chbuf\n"
     804        " vaddr = %x / paddr = %l\n",
    797805        thread , vaddr , ker_chbuf_pbase );
    798806#endif
     
    851859#if GIET_DEBUG_NIC
    852860unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
    853 _printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_start() at cycle %d"
    854         " get NIC channel = %d / CMA channel = %d\n",
     861_printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_start() at cycle %d\n"
     862        "  get NIC channel = %d / CMA channel = %d\n",
    855863        thread, _get_proctime(), nic_channel, cma_channel );
    856864#endif
     
    969977
    970978#if GIET_DEBUG_NIC
    971 _printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_move() read buffer descriptor %d\n"
    972         " at cycle = %d / paddr = %l / buffer descriptor = %l\n",
     979_printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_move() read buf_desc %d at cycle %d\n"
     980        " paddr = %l / buffer descriptor = %l\n",
    973981        thread, index, _get_proctime(), buffer_desc_paddr, buffer_descriptor );
    974982#endif
     
    9931001                          NIC_CONTAINER_SIZE );
    9941002#if GIET_DEBUG_NIC
    995 _printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_move() transfer "
    996         "kernel buffer %l to user buffer %l at cycle %d\n",
     1003_printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_move() transfer kernel buffer %l\n"
     1004        " to user buffer %l at cycle %d\n",
    9971005        thread , kernel_buffer_paddr , user_buffer_paddr , _get_proctime() );
    9981006#endif
Note: See TracChangeset for help on using the changeset viewer.