Ignore:
Timestamp:
Jul 18, 2013, 6:33:38 PM (11 years ago)
Author:
alain
Message:

Various modifications to support IO Bridge,
and MEMC configuration interface.

File:
1 edited

Legend:

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

    r246 r249  
    4141// - seg_cma_base
    4242// - seg_iob_base
     43// - seg_mmc_base
    4344//
    4445///////////////////////////////////////////////////////////////////////////////////
     
    5758#endif
    5859
     60#if (NB_CLUSTERS > 256)
     61# error: NB_CLUSTERS cannot be larger than 256!
     62#endif
     63
    5964#if !defined(NB_PROCS_MAX)
    6065# error: You must define NB_PROCS_MAX in the hard_config.h file
     
    6974#endif
    7075
     76#if !defined(GIET_USE_IOMMU)
     77# error: You must define GIET_USE_IOMMU in the giet_config.h file
     78#endif
     79
    7180#if !defined(NB_TTY_CHANNELS)
    7281# error: You must define NB_TTY_CHANNELS in the hard_config.h file
     
    121130#endif
    122131
    123 #if !defined( IOMMU_ACTIVE )
    124 # error: You must define IOMMU_ACTIVE in the hard_config.h file
     132#if !defined( USE_IOB )
     133# error: You must define USE_IOB in the hard_config.h file
    125134#endif
    126135
     
    314323
    315324    _get_lock(&_tty_put_lock);
    316     if (tty_id == 0xFFFFFFFF) {
    317         _puts("\n[GIET ERROR] no TTY assigned to the task ");
    318     }
    319     else {
    320         _puts("\n[GIET ERROR] TTY index too large for task ");
    321     }
     325    if (tty_id == 0xFFFFFFFF) _puts("\n[GIET ERROR] no TTY assigned to the task ");
     326    else                      _puts("\n[GIET ERROR] TTY index too large for task ");
    322327    _putd(task_id);
    323328    _puts(" on processor ");
     
    671676        if (ix2 == 0) ppn_first = ppn;
    672677
    673         if (IOMMU_ACTIVE) // the user buffer must be remapped in the I/0 space
     678        if ( GIET_USE_IOMMU && USE_IOB ) // user buffer remapped in the I/0 space
    674679        {
    675680            // check buffer length < 2 Mbytes
     
    710715    _ioc_iommu_npages = (user_vpn_max - user_vpn_min) + 1;
    711716
    712     // invalidate data cache in case of memory write
     717    // invalidate local data cache in case of memory write
    713718    if (to_mem) _dcache_buf_invalidate((void *) user_vaddr, length);
    714719
     
    737742#endif
    738743
     744    // Invalidate L2 cache if IO Bridge is used
     745    if ( to_mem && USE_IOB ) _memc_inval( buf_paddr, length );
     746   
    739747    // get the lock on ioc device
    740748    _get_lock(&_ioc_lock);
    741749
    742750    // peripheral configuration 
    743     if ( IOMMU_ACTIVE )
     751    if ( GIET_USE_IOMMU && USE_IOB )
    744752    {
    745753        ioc_address[BLOCK_DEVICE_BUFFER] = buf_xaddr;
     
    791799
    792800    // unmap the buffer from IOMMU page table if IOMMU is activated
    793     if (IOMMU_ACTIVE)
     801    if ( GIET_USE_IOMMU && USE_IOB )
    794802    {
    795803        unsigned int * iob_address = (unsigned int *) &seg_iob_base;
     
    11071115    if ( ix2 == 0 ) ppn_first = ppn;
    11081116
    1109     if ( IOMMU_ACTIVE )    // the user buffer must be remapped in the I/0 space
     1117    if ( GIET_USE_IOMMU && USE_IOB )    // user buffer remapped in the I/0 space
    11101118    {
    11111119    // check buffer length < 2 Mbytes
     
    14441452}
    14451453
     1454//////////////////////////////////////////////////////////////////////////////////
     1455//     VciMemCache driver
     1456//////////////////////////////////////////////////////////////////////////////////
     1457// The VciMemCache device can be accessed through a configuration interface.
     1458// as a set of uncached, memory mapped registers.
     1459///////////////////////////////////////////////////////////////////////////////////
     1460
     1461///////////////////////////////////////////////////////////////////////////////////
     1462// _memc_inval()
     1463// This function invalidate all cache lines covering a memory buffer defined
     1464// by the physical base address, and the length.
     1465// The buffer address MSB are used to compute the cluster index.
     1466///////////////////////////////////////////////////////////////////////////////////
     1467void _memc_inval( paddr_t      buf_paddr,
     1468                  unsigned int buf_length )
     1469{
     1470    unsigned int cluster_id    = (unsigned int)((buf_paddr>>32)/(256/NB_CLUSTERS));
     1471
     1472    unsigned int * mmc_address = (unsigned int *) ((char *) &seg_mmc_base +
     1473                                                   (cluster_id * GIET_CLUSTER_INCREMENT));
     1474
     1475    // get the lock protecting exclusive access to MEMC
     1476    while ( mmc_address[MEMC_LOCK] ) { asm volatile("nop"); }
     1477
     1478    // write inval arguments
     1479    mmc_address[MEMC_ADDR_LO]    = (unsigned int)buf_paddr;
     1480    mmc_address[MEMC_ADDR_HI]    = (unsigned int)(buf_paddr>>32);
     1481    mmc_address[MEMC_BUF_LENGTH] = buf_length;
     1482    mmc_address[MEMC_CMD_TYPE]   = MEMC_CMD_INVAL;
     1483
     1484    // release the lock protecting MEMC
     1485    mmc_address[MEMC_LOCK] = 0;
     1486}
    14461487///////////////////////////////////////////////////////////////////////////////////
    14471488// _heap_info()
Note: See TracChangeset for help on using the changeset viewer.