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

1) Removing the IOC driver (integrated in the FAT library).
2) Simplifying the BDV, HBA, SDC, RDK drivers: they support
only two modes (synchronous => polling / descheduling => IRQ),
and only one access function (for both read/write).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_drivers/dma_driver.c

    r496 r529  
    8888
    8989////////////////////////////////////////////////
    90 unsigned int _dma_init( unsigned int cluster_xy,
    91                         unsigned int channel_id )
    92 {
    93 #if NB_DMA_CHANNELS > 0
    94 
    95     // parameters checking
     90void _dma_disable_irq( unsigned int cluster_xy,
     91                       unsigned int channel_id )
     92{
     93#if NB_DMA_CHANNELS > 0
     94
     95    // check DMA channel parameters
    9696    unsigned int x = cluster_xy >> Y_WIDTH;
    9797    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    98     if (x >= X_SIZE)                    return 1;
    99     if (y >= Y_SIZE)                    return 1;
    100     if (channel_id >= NB_DMA_CHANNELS)  return 1;
     98    if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
     99    {
     100        _puts("\n[DMA ERROR] in _dma_disable_irq() : illegal DMA channel ");
     101        _exit();
     102    }
    101103
    102104    // disable interrupt for selected channel
    103105    _dma_set_register(cluster_xy, channel_id, DMA_IRQ_DISABLE, 1);
    104     return 0;
    105 #else
    106     return 1;
    107 #endif
    108 }
    109 
    110 //////////////////////////////////////////////////
    111 unsigned int _dma_reset( unsigned int cluster_xy,
     106
     107#endif
     108}
     109
     110/////////////////////////////////////////////////
     111void _dma_reset_channel( unsigned int cluster_xy,
    112112                         unsigned int channel_id )
    113113{
    114114#if NB_DMA_CHANNELS > 0
    115115
    116     // parameters checking
     116    // check DMA channel parameters
    117117    unsigned int x = cluster_xy >> Y_WIDTH;
    118118    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    119     if (x >= X_SIZE)                    return 1;
    120     if (y >= Y_SIZE)                    return 1;
    121     if (channel_id >= NB_DMA_CHANNELS)  return 1;
     119    if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
     120    {
     121        _puts("\n[DMA ERROR] in _dma_reset_channel() : illegal DMA channel ");
     122        _exit();
     123    }
    122124
    123125    // reset selected channel
    124126    _dma_set_register(cluster_xy, channel_id, DMA_RESET, 0);
    125     return 0;
    126 #else
    127     return 1;
    128 #endif
    129 }
    130 
    131 //////////////////////////////////////////////////////
    132 unsigned int _dma_get_status( unsigned int cluster_xy,
    133                               unsigned int channel_id )
    134 {
    135 #if NB_DMA_CHANNELS > 0
    136 
    137     // parameters checking
     127
     128#endif
     129}
     130
     131///////////////////////////////////////////////////////
     132void _dma_get_status( unsigned int  cluster_xy,
     133                      unsigned int  channel_id,
     134                      unsigned int* status )
     135{
     136#if NB_DMA_CHANNELS > 0
     137
     138    // check DMA channel parameters
    138139    unsigned int x = cluster_xy >> Y_WIDTH;
    139140    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    140     if (x >= X_SIZE)                    return 1;
    141     if (y >= Y_SIZE)                    return 1;
    142     if (channel_id >= NB_DMA_CHANNELS)  return 1;
    143 
    144     // get selected channel status
    145     return _dma_get_register(cluster_xy, channel_id, DMA_LEN);
    146 #else
    147     return DMA_IDLE;
     141    if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
     142    {
     143        _puts("\n[DMA ERROR] in _dma_get_status() : illegal DMA channel ");
     144        _exit();
     145    }
     146
     147    // returns selected channel status
     148    *status = _dma_get_register(cluster_xy, channel_id, DMA_LEN);
     149
    148150#endif
    149151}
     
    157159{
    158160#if NB_DMA_CHANNELS > 0
     161
     162    // check DMA channel parameters
     163    unsigned int x = cluster_xy >> Y_WIDTH;
     164    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     165    if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
     166    {
     167        _puts("\n[DMA ERROR] in _dma_start_transfer() : illegal DMA channel ");
     168        _exit();
     169    }
    159170
    160171    // selected channel configuration and lauching
     
    169180    _dma_set_register(cluster_xy, channel_id, DMA_LEN,
    170181            (unsigned int)size);
    171 
    172182#endif
    173183}
     
    176186void _dma_physical_copy( unsigned int       cluster_xy,  // DMA cluster
    177187                         unsigned int       channel_id,  // DMA channel
    178                          unsigned long long dst_paddr,   // destination physical address
    179                          unsigned long long src_paddr,   // source physical address
     188                         unsigned long long dst_paddr,   // dest physical address
     189                         unsigned long long src_paddr,   // src physical address
    180190                         unsigned int       size )       // bytes
    181191{
    182192#if NB_DMA_CHANNELS > 0
    183 
    184     // check DMA channel parameters
    185     unsigned int x = cluster_xy >> Y_WIDTH;
    186     unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    187     if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
    188     {
    189         _puts("\n[DMA ERROR] in _dma_physical_copy() : illegal DMA channel ");
    190         _exit();
    191     }
    192193
    193194    // check buffers alignment constraints
     
    199200
    200201#if GIET_DEBUG_DMA_DRIVER
     202unsigned int x = cluster_xy >> Y_WIDTH;
     203unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    201204_puts("\n[DMA DEBUG] enter _dma_physical_copy() for channel[");
    202205_putd( x );
     
    212215_putl( dst_paddr );
    213216_puts("\n - bytes       = ");
    214 _putd( size );
    215 _puts("\n");
    216 #endif
    217 
    218     // dma channel configuration & lauching
     217_putx( size );
     218_puts("\n");
     219#endif
     220
     221    // dma channel configuration
     222    _dma_disable_irq( cluster_xy, channel_id );
     223
     224    // dma transfer lauching
    219225    _dma_start_transfer( cluster_xy, channel_id, dst_paddr, src_paddr, size );
    220226
    221227    // scan dma channel status
    222     unsigned int status = _dma_get_status( cluster_xy, channel_id );
     228    unsigned int status;
     229    do
     230    {
     231        _dma_get_status( cluster_xy, channel_id , &status );
     232
     233#if GIET_DEBUG_DMA_DRIVER
     234_puts("\n[DMA DEBUG] _dma_physical_copy() : ... waiting on DMA_STATUS\n");
     235#endif
     236
     237    }
    223238    while( (status != DMA_SUCCESS) &&
    224239           (status != DMA_READ_ERROR) &&
    225            (status != DMA_WRITE_ERROR) )
    226     {
    227         status = _dma_get_status( cluster_xy, channel_id );
    228 
    229 #if GIET_DEBUG_DMA_DRIVER
    230 _puts("\n[DMA DEBUG] _dma_physical_copy() : ... waiting on DMA_STATUS register\n");
    231 #endif
    232 
    233     }
     240           (status != DMA_WRITE_ERROR) );
    234241   
    235242    // analyse status
    236243    if( status != DMA_SUCCESS )
    237244    {
    238         _puts("\n[DMA ERROR] in _dma_physical_copy() : bad DMA_STATUS");
     245        _puts("\n[DMA ERROR] in _dma_physical_copy() : ERROR_STATUS");
    239246        _exit();
    240247    }
    241248
    242249    // reset dma channel
    243     _dma_reset( cluster_xy, channel_id );
     250    _dma_reset_channel( cluster_xy , channel_id );
    244251
    245252#if GIET_DEBUG_DMA_DRIVER
     
    261268void  _dma_copy( unsigned int cluster_xy,    // DMA cluster
    262269                 unsigned int channel_id,    // DMA channel
    263                  unsigned int vspace_id,     // vspace index for v2p translation
    264270                 unsigned int dst_vaddr,     // dst_vaddr buffer vbase
    265271                 unsigned int src_vaddr,     // src_vaddr buffer vbase
     
    268274#if NB_DMA_CHANNELS > 0
    269275
    270     // check DMA channel parameters
    271     unsigned int x = cluster_xy >> Y_WIDTH;
    272     unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    273     if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
    274     {
    275         _puts("\n[DMA ERROR] in _dma_copy() : illegal DMA channel ");
    276         _exit();
    277     }
    278 
    279276    // check buffers alignment constraints
    280277    if ( (dst_vaddr & 0x3)   || (src_vaddr & 0x3) || (size & 0x3) )
     
    284281    }
    285282
    286     unsigned int ppn;
     283    unsigned long long src_paddr;
     284    unsigned long long dst_paddr;
    287285    unsigned int flags;
    288286
    289287#if GIET_DEBUG_DMA_DRIVER
     288unsigned int x = cluster_xy >> Y_WIDTH;
     289unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    290290_puts("\n[DMA DEBUG] enter _dma_copy() for channel[");
    291291_putd( x );
     
    305305#endif
    306306
    307     // checking alignment constraints
    308     if ( (((unsigned int)dst_vaddr) & 0x3) ||
    309          (((unsigned int)src_vaddr) & 0x3) ||
    310          (size & 0x3) )
    311     {
    312         _puts("\n[DMA ERROR] in _dma_copy() : buffer unaligned\n");
    313         _exit();
    314     }
    315 
    316     // get vspace page table pointer
    317     unsigned int pt = _ptabs_vaddr[vspace_id];
    318 
    319307    // get src_paddr buffer physical addresse
    320     _v2p_translate( (page_table_t*)pt,              // page table pointer
    321                      src_vaddr>>12,                  // vpn
    322                      &ppn,                           // ppn
    323                      &flags );                       // flags
    324     unsigned long long src_paddr = (((unsigned long long)ppn) << 12) |
    325                                    (unsigned long long)(src_vaddr & 0x00000FFF);
     308    src_paddr = _v2p_translate( src_vaddr , &flags );
    326309
    327310    // get dst_paddr buffer physical addresse
    328     _v2p_translate( (page_table_t*)pt,              // page table pointer
    329                      dst_vaddr>>12,                  // vpn
    330                      &ppn,                           // ppn
    331                      &flags );                       // flags
    332     unsigned long long dst_paddr = (((unsigned long long)ppn) << 12) |
    333                                    (unsigned long long)(dst_vaddr & 0x00000FFF);
     311    dst_paddr = _v2p_translate( dst_vaddr , &flags );
    334312
    335313#if GIET_DEBUG_DMA_DRIVER
     
    345323
    346324    // scan dma channel status
    347     unsigned int status = _dma_get_status( cluster_xy, channel_id );
     325    unsigned int status;
     326    do
     327    {
     328        _dma_get_status( cluster_xy, channel_id , &status );
     329
     330#if GIET_DEBUG_DMA_DRIVER
     331_puts("\n[DMA DEBUG] _dma_physical_copy() : ... waiting on DMA_STATUS\n");
     332#endif
     333
     334    }
    348335    while( (status != DMA_SUCCESS) &&
    349336           (status != DMA_READ_ERROR) &&
    350            (status != DMA_WRITE_ERROR) )
    351     {
    352         status = _dma_get_status( cluster_xy, channel_id );
    353 
    354 #if GIET_DEBUG_DMA_DRIVER
    355 _puts("\n[DMA DEBUG] _dma_copy() : ... waiting on DMA_STATUS register\n");
    356 #endif
    357 
    358     }
     337           (status != DMA_WRITE_ERROR) );
    359338   
    360339    // analyse status
     
    365344    }
    366345    // reset dma channel
    367     _dma_reset( cluster_xy, channel_id );
     346    _dma_reset_channel( cluster_xy, channel_id );
    368347
    369348#if GIET_DEBUG_DMA_DRIVER
     
    380359#endif
    381360} // end _dma_copy
     361
    382362
    383363/////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.