Ignore:
Timestamp:
Mar 27, 2015, 11:43:48 AM (10 years ago)
Author:
alain
Message:

1) Introducing support for external IRQs dynamic routing.
2) Simplifying the _v2p_translate() function.
3) Removing the generic IOC driver (integrated in the FAT library).

File:
1 edited

Legend:

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

    r519 r528  
    6161#endif
    6262
    63 
    6463////////////////////////////////////////////////////////////////////////////
    65 //     Coprocessors loks and synchronisation variables
     64//        Extern variables
    6665////////////////////////////////////////////////////////////////////////////
    6766
    68 __attribute__((section(".kdata")))
    69 simple_lock_t  _coproc_lock[X_SIZE*Y_SIZE];
    70 
    71 __attribute__((section(".kdata")))
    72 unsigned int   _coproc_done[X_SIZE*Y_SIZE];
     67// allocated in tty0.c file.
     68extern sqt_lock_t _tty0_sqt_lock;
     69
     70// allocated in mwr_driver.c file.
     71extern simple_lock_t  _coproc_lock[X_SIZE*Y_SIZE];
     72extern unsigned int   _coproc_done[X_SIZE*Y_SIZE];
     73
     74// allocated in tty_driver.c file.
     75extern unsigned int _tty_rx_full[NB_TTY_CHANNELS];
     76extern unsigned int _tty_rx_buf[NB_TTY_CHANNELS];
    7377
    7478////////////////////////////////////////////////////////////////////////////
     
    9195__attribute__((section(".kdata")))
    9296unsigned int _nic_tx_channel_allocator = 0;
    93 
    94 ////////////////////////////////////////////////////////////////////////////
    95 // These global variables are allocated in tty0.c and tty_driver.c files.
    96 ////////////////////////////////////////////////////////////////////////////
    97 
    98 extern sqt_lock_t _tty0_sqt_lock;
    99 
    100 extern unsigned int _tty_rx_full[NB_TTY_CHANNELS];
    101 
    102 extern unsigned int _tty_rx_buf[NB_TTY_CHANNELS];
    10397
    10498////////////////////////////////////////////////////////////////////////////
     
    157151    &_sys_ukn,                  /* 0x17 */
    158152    &_sys_ukn,                  /* 0x18 */   
    159     &_context_switch,           /* 0x19 */
     153    &_sys_context_switch,       /* 0x19 */
    160154    &_sys_vseg_get_vbase,       /* 0x1A */
    161155    &_sys_vseg_get_length,      /* 0x1B */
     
    355349    unsigned int size = desc->buffer_size;
    356350 
    357     // these variables are used for the v2p translations
    358     unsigned int       ptab  = _get_context_slot(CTX_PTAB_ID);
    359     unsigned int       ppn;
    360     unsigned int       flags;
     351    // physical addresses
    361352    unsigned long long buffer_paddr;
    362353    unsigned int       buffer_lsb;
     
    369360    unsigned int       lock_msb;
    370361
     362    unsigned int       flags;     // unused
     363
    371364    // compute memory buffer physical address
    372     _v2p_translate( (page_table_t*)ptab,
    373                     desc->buffer_vaddr>>12,
    374                     &ppn,
    375                     &flags );
    376     buffer_paddr = (((unsigned long long)ppn) << 12) |
    377                    (desc->buffer_vaddr & 0x00000FFF);
    378     buffer_lsb = (unsigned int)buffer_paddr;
    379     buffer_msb = (unsigned int)(buffer_paddr>>32);
     365    buffer_paddr = _v2p_translate( desc->buffer_vaddr , &flags );
     366    buffer_lsb   = (unsigned int)buffer_paddr;
     367    buffer_msb   = (unsigned int)(buffer_paddr>>32);
    380368
    381369    // call MWMR_DMA driver
     
    385373    _mwr_set_channel_register( cluster_xy, channel, CHANNEL_BUFFER_MSB, buffer_msb );
    386374                       
    387     // compute MWMR descriptor and lock physical addresses (if required)
    388375    if ( mode == MODE_MWMR )
    389376    {
    390         _v2p_translate( (page_table_t*)ptab,
    391                         desc->mwmr_vaddr>>12,
    392                         &ppn,
    393                         &flags );
    394         mwmr_paddr = (((unsigned long long)ppn) << 12) |
    395                      (desc->mwmr_vaddr & 0x00000FFF);
     377        // compute MWMR descriptor physical address
     378        mwmr_paddr = _v2p_translate( desc->mwmr_vaddr , &flags );
    396379        mwmr_lsb = (unsigned int)mwmr_paddr;
    397380        mwmr_msb = (unsigned int)(mwmr_paddr>>32);
    398 
    399         _v2p_translate( (page_table_t*)ptab,
    400                         desc->lock_vaddr>>12,
    401                         &ppn,
    402                         &flags );
    403         lock_paddr = (((unsigned long long)ppn) << 12) |
    404                      (desc->lock_vaddr & 0x00000FFF);
    405         lock_lsb = (unsigned int)lock_paddr;
    406         lock_msb = (unsigned int)(lock_paddr>>32);
    407381
    408382        // call MWMR_DMA driver
    409383        _mwr_set_channel_register( cluster_xy, channel, CHANNEL_MWMR_LSB, mwmr_lsb );
    410384        _mwr_set_channel_register( cluster_xy, channel, CHANNEL_MWMR_MSB, mwmr_msb );
     385
     386        // compute lock physical address
     387        lock_paddr = _v2p_translate( desc->lock_vaddr , &flags );
     388        lock_lsb = (unsigned int)lock_paddr;
     389        lock_msb = (unsigned int)(lock_paddr>>32);
     390
     391        // call MWMR_DMA driver
    411392        _mwr_set_channel_register( cluster_xy, channel, CHANNEL_LOCK_LSB, lock_lsb );
    412393        _mwr_set_channel_register( cluster_xy, channel, CHANNEL_LOCK_MSB, lock_msb );
     
    740721    unsigned long long ker_chbuf_pbase;     // kernel chbuf physical address
    741722
    742     // These variables are used for the various V2P translation
    743     unsigned int       ptab  = _get_context_slot(CTX_PTAB_ID);
    744     unsigned int       ppn;
    745     unsigned int       flags;
    746     unsigned int       vaddr;
    747 
    748723    // allocate one kernel container per cluster in the (xmax / ymax) mesh
    749     unsigned int        cx;              // cluster X coordinate
    750     unsigned int        cy;              // cluster Y coordinate
    751     unsigned int        index;           // container index in chbuf
    752     unsigned long long  cont_paddr;      // container physical address
     724    unsigned int        cx;                 // cluster X coordinate
     725    unsigned int        cy;                 // cluster Y coordinate
     726    unsigned int        index;              // container index in chbuf
     727    unsigned int        vaddr;              // virtual address
     728    unsigned long long  cont_paddr;         // container physical address
     729
     730    unsigned int        flags;              // for _v2p_translate()
    753731
    754732    for ( cx = 0 ; cx < xmax ; cx++ )
     
    770748
    771749            // compute container physical address
    772             _v2p_translate( (page_table_t*)ptab,
    773                             vaddr>>12,
    774                             &ppn,
    775                             &flags );
    776             cont_paddr = (((unsigned long long)ppn) << 12) | (vaddr & 0x00000FFF);
     750            cont_paddr = _v2p_translate( vaddr , &flags );
    777751
    778752            // initialize chbuf entry
     
    816790    if ( is_rx ) vaddr = (unsigned int)( &_nic_rx_chbuf[nic_channel] );
    817791    else         vaddr = (unsigned int)( &_nic_tx_chbuf[nic_channel] );
    818     _v2p_translate( (page_table_t*)ptab,
    819                      vaddr>>12,
    820                      &ppn,
    821                      &flags );
    822     ker_chbuf_pbase = (((unsigned long long)ppn) << 12) | (vaddr & 0x00000FFF);
     792
     793    ker_chbuf_pbase = _v2p_translate( vaddr , &flags );
    823794
    824795#if GIET_DEBUG_NIC
     
    965936    unsigned long long kernel_buffer_paddr;  // kernel buffer physical address
    966937    unsigned long long kernel_chbuf_paddr;   // kernel chbuf physical address
    967     unsigned long long buffer_desc;          // kernel buffer descriptor
    968     unsigned long long buffer_desc_paddr;    // kernel buffer descriptor physical address
     938    unsigned long long buffer_descriptor;    // kernel buffer descriptor
     939    unsigned long long buffer_desc_paddr;    // kernel buffer descriptor paddr
    969940    unsigned int       index;                // kernel buffer index in chbuf
    970 
    971     // The following variables are used for V2P translation
    972     unsigned int ptab = _get_context_slot( CTX_PTAB_ID );
    973     unsigned int ppn;
    974     unsigned int flags;
    975     unsigned int vaddr;
     941    unsigned int       flags;                // for _v2P_translate
    976942
    977943    // Compute user buffer physical address and check access rights
    978     vaddr = (unsigned int)buffer;
    979     _v2p_translate( (page_table_t*)ptab,
    980                      vaddr>>12,
    981                      &ppn,
    982                      &flags );
     944    user_buffer_paddr = _v2p_translate( (unsigned int)buffer , &flags );
    983945
    984946    if ( (flags & PTE_U) == 0 )
     
    987949        return -1;
    988950    }
    989     user_buffer_paddr = ((unsigned long long)ppn << 12) | (vaddr & 0x00000FFF);
    990951
    991952#if GIET_DEBUG_NIC
     
    995956
    996957    // compute kernel chbuf physical address (required for sync)
    997     vaddr = (unsigned int)chbuf;
    998     _v2p_translate( (page_table_t*)ptab,
    999                      vaddr>>12,
    1000                      &ppn,
    1001                      &flags );
    1002     kernel_chbuf_paddr = ((unsigned long long)ppn << 12) | (vaddr & 0x00000FFF);
     958    kernel_chbuf_paddr = _v2p_translate( (unsigned int)chbuf , &flags );
    1003959
    1004960    // poll local kernel container status until success
     
    1011967        // inval buffer descriptor in L2 before read in L2
    1012968        _mmc_inval( buffer_desc_paddr , 8 );
    1013         buffer_desc = chbuf->buffer[index].desc;
     969        buffer_descriptor = chbuf->buffer[index].desc;
    1014970
    1015971#if GIET_DEBUG_NIC
    1016972_printf("\n[GIET DEBUG NIC] Task %d in _sys_nic_move() read buffer descriptor %d\n"
    1017973        " at cycle = %d / paddr = %l / buffer descriptor = %l\n",
    1018         thread, index, _get_proctime(), buffer_desc_paddr, buffer_desc );
     974        thread, index, _get_proctime(), buffer_desc_paddr, buffer_descriptor );
    1019975#endif
    1020976
    1021977        // test buffer status and break if found
    1022         if ( ( is_rx != 0 ) && (buffer_desc >> 63) == 1 )  break;
    1023         if ( ( is_rx == 0 ) && (buffer_desc >> 63) == 0 )  break;
     978        if ( ( is_rx != 0 ) && (buffer_descriptor >> 63) == 1 )  break;
     979        if ( ( is_rx == 0 ) && (buffer_descriptor >> 63) == 0 )  break;
    1024980    }
    1025981
    1026982    // compute kernel buffer physical address
    1027     kernel_buffer_paddr = buffer_desc & 0x0000FFFFFFFFFFFFULL;
     983    kernel_buffer_paddr = buffer_descriptor & 0x0000FFFFFFFFFFFFULL;
    1028984   
    1029985    // move one container
     
    12811237#if NB_CMA_CHANNELS > 0
    12821238
    1283     unsigned int       ptab;            // page table virtual address
    12841239    unsigned int       vaddr;           // virtual address
    1285     unsigned int       flags;           // protection flags
    1286     unsigned int       ppn;             // physical page number
     1240    unsigned int       flags;           // for _v2p_translate()
    12871241
    12881242    // get channel index
     
    13081262
    13091263    // checking user buffers virtual addresses and length alignment
    1310     if ( ((unsigned int)vbase0 & 0x3) || ((unsigned int)vbase1 & 0x3) || (length & 0x3) )
    1311     {
    1312         _printf("\n[GIET ERROR] in _fbf_cma_start() : user buffer not word aligned\n");
    1313         return -1;
    1314     }
    1315 
    1316     // get page table virtual address
    1317     ptab = _get_context_slot(CTX_PTAB_ID);
     1264    if ( ((unsigned int)vbase0 & 0x3) ||
     1265         ((unsigned int)vbase1 & 0x3) ||
     1266         (length & 0x3) )
     1267    {
     1268        _printf("\n[GIET ERROR] in _fbf_cma_start() : user buffer not aligned\n");
     1269        return -1;
     1270    }
    13181271
    13191272    // compute frame buffer physical address and initialize _fbf_chbuf[channel]
    1320     vaddr = ((unsigned int)SEG_FBF_BASE);
    1321     _v2p_translate( (page_table_t*) ptab,
    1322                     (vaddr >> 12),
    1323                     &ppn,
    1324                     &flags );
    1325 
    1326     _fbf_chbuf[channel].fbf.desc = ((paddr_t)ppn << 12) | (vaddr & 0x00000FFF);
     1273    vaddr = (unsigned int)SEG_FBF_BASE;
     1274    _fbf_chbuf[channel].fbf.desc = _v2p_translate( vaddr , &flags );
    13271275
    13281276    // Compute user buffer 0 physical addresses and intialize _fbf_chbuf[channel]
    1329     vaddr = (unsigned int)vbase0;
    1330     _v2p_translate( (page_table_t*) ptab,
    1331                     (vaddr >> 12),
    1332                     &ppn,
    1333                     &flags );
     1277    vaddr = (unsigned int)vbase0;
     1278    _fbf_chbuf[channel].buf0.desc = _v2p_translate( vaddr , &flags );
     1279
    13341280    if ((flags & PTE_U) == 0)
    13351281    {
    1336         _printf("\n[GIET ERROR] in _fbf_cma_start() : user buffer 0 not in user space\n");
    1337         return -1;
    1338     }
    1339 
    1340     _fbf_chbuf[channel].buf0.desc = ((paddr_t)ppn << 12) | (vaddr & 0x00000FFF);
     1282        _printf("\n[GIET ERROR] in _fbf_cma_start() : buf0 not in user space\n");
     1283        return -1;
     1284    }
    13411285
    13421286    // Compute user buffer 1 physical addresses and intialize _fbf_chbuf[channel]
    1343     vaddr = (unsigned int)vbase1;
    1344     _v2p_translate( (page_table_t*) ptab,
    1345                     (vaddr >> 12),
    1346                     &ppn,
    1347                     &flags );
     1287    vaddr = (unsigned int)vbase1;
     1288    _fbf_chbuf[channel].buf1.desc = _v2p_translate( vaddr , &flags );
     1289
    13481290    if ((flags & PTE_U) == 0)
    13491291    {
    1350         _printf("\n[GIET ERROR] in _fbf_cma_start() : user buffer 1 not in user space\n");
    1351         return -1;
    1352     }
    1353 
    1354     _fbf_chbuf[channel].buf1.desc = ((paddr_t)ppn << 12) | (vaddr & 0x00000FFF);
     1292        _printf("\n[GIET ERROR] in _fbf_cma_start() : buf1 not in user space\n");
     1293        return -1;
     1294    }
    13551295
    13561296    // initializes buffer length
     
    13581298
    13591299    // Compute and register physical adress of the fbf_chbuf descriptor
    1360     vaddr = (unsigned int)(&_fbf_chbuf[channel]);
    1361     _v2p_translate( (page_table_t*) ptab,
    1362                     (vaddr >> 12),
    1363                     &ppn,
    1364                     &flags );
     1300    vaddr = (unsigned int)&_fbf_chbuf[channel];
     1301    _fbf_chbuf_paddr[channel] = _v2p_translate( vaddr , &flags );
    13651302 
    1366     _fbf_chbuf_paddr[channel] = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
    1367 
    13681303    if ( USE_IOB )
    13691304    {
     
    15941529
    15951530    // deschedule
    1596     _context_switch();
     1531    _sys_context_switch();
    15971532
    15981533    return 0;
    15991534}
    16001535
    1601 //////////////////////
    1602 int _context_switch()
     1536/////////////////////////
     1537int _sys_context_switch()
    16031538{
    16041539    unsigned int save_sr;
     
    17551690                      unsigned int* y )
    17561691{
    1757     unsigned int ppn;
    17581692    unsigned int flags;
    1759     unsigned int vpn  = (((unsigned int)ptr)>>12);
     1693    unsigned long long paddr = _v2p_translate( (unsigned int)ptr , &flags );
    17601694   
    1761     // get the page table pointer
    1762     page_table_t* pt = (page_table_t*)_get_context_slot( CTX_PTAB_ID );
    1763 
    1764     // compute the physical address
    1765     _v2p_translate( pt, vpn, &ppn, &flags );
    1766 
    1767     *x = (ppn>>24) & 0xF;
    1768     *y = (ppn>>20) & 0xF;
     1695    *x = (paddr>>36) & 0xF;
     1696    *y = (paddr>>32) & 0xF;
     1697
    17691698    return 0;
    17701699}
Note: See TracChangeset for help on using the changeset viewer.