Ignore:
Timestamp:
Nov 3, 2014, 10:53:00 AM (10 years ago)
Author:
alain
Message:

Introducing dynamic allocation of peripheral channel(TTY, NIC, TIM, CMA)
Removint the ICU driver : ICU component not supported anymore.
Removing the FBF driver.

File:
1 edited

Legend:

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

    r345 r437  
    55// Copyright (c) UPMC-LIP6
    66///////////////////////////////////////////////////////////////////////////////////
    7 // The dma_driver.c and dma_driver.h files are part ot the GIET-VM nano-kernel.
    8 // This driver supports the SoCLib vci_multi_dma component.
    9 //
    10 // It can exist several DMA controlers in the architecture (one per cluster),
    11 // and each controller can contain several channels.
    12 //
    13 // There is  (NB_CLUSTERS * NB_DMA_CHANNELS) channels, indexed by a global index:
    14 //        dma_id = cluster_xy * NB_DMA_CHANNELS + loc_id
    15 //
    16 // A DMA channel is a private ressource allocated to a given processor.
    17 // It is exclusively used by the kernet to speedup data transfers, and
    18 // there is no lock protecting exclusive access to the channel.
    19 // As the kernel uses a polling policy on the DMA_STATUS register to detect
    20 // transfer completion, the DMA IRQ is not used.
    21 //
    22 // The virtual base address of the segment associated to a channel is:
    23 //    SEG_DMA_BASE + cluster_xy * PERI_CLUSTER_INCREMENT + DMA_SPAN * channel_id
    24 //
    25 // The SEG_DMA_BASE virtual address mus be defined in the hard_config.h file.
    26 ////////////////////////////////////////////////////////////////////////////////////
    277
    288#include <giet_config.h>
     
    10181}
    10282
    103 //////////////////////////////////////////////////////////////////////////////////
    104 // AS the GIET-VM uses a polling policy to detect transfer completion,
    105 // The DMA component initialisation must disable interrupts.
    106 // This function disables interrupts for one DMA channel in one cluster.
    107 // Returns 0 if success, returns > 0 if error.
    108 //////////////////////////////////////////////////////////////////////////////////
     83////////////////////////////////////////////////
    10984unsigned int _dma_init( unsigned int cluster_xy,
    11085                        unsigned int channel_id )
     
    127102}
    128103
    129 //////////////////////////////////////////////////////////////////////////////////
    130 // This function re-initialises one DMA channel in one cluster after a transfer
    131 // completion. It actually forces the channel to return in iDLE state.
    132 //////////////////////////////////////////////////////////////////////////////////
     104//////////////////////////////////////////////////
    133105unsigned int _dma_reset( unsigned int cluster_xy,
    134106                         unsigned int channel_id )
     
    151123}
    152124
    153 //////////////////////////////////////////////////////////////////////////////////
    154 // This function returns the status of a DMA channel in a given cluster
    155 //////////////////////////////////////////////////////////////////////////////////
     125//////////////////////////////////////////////////////
    156126unsigned int _dma_get_status( unsigned int cluster_xy,
    157127                              unsigned int channel_id )
     
    173143}
    174144
    175 //////////////////////////////////////////////////////////////////////////////////
    176 // This function sets the physical address (including 64 bits extension)
    177 // for the source and destination buffers in a DMA channel in a given cluster
    178 // and sets the transfer size to lauch the transfer.
    179 //////////////////////////////////////////////////////////////////////////////////
     145////////////////////////////////////////////////////////
    180146void _dma_start_transfer( unsigned int       cluster_xy,  // DMA cluster
    181147                          unsigned int       channel_id,  // DMA channel
     
    201167}
    202168
    203 ///////////////////////////////////////////////////////////////////////////////////
    204 // This function copies a source memory buffer to a destination memory buffer,
    205 // using directly physical addresses.
    206 // This blocking function is supposed to be used by the kernel only,
    207 // and uses a polling policy on DMA_STATUS register to detect completion.
    208 // Therefore, the DMA_IRQ is NOT used.
    209 // The source and destination buffers base addresses must be word aligned,
    210 // and the buffer's size must be multiple of 4.
    211 // In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
    212 // message is displayed on TTY0, and the system crash.
    213 ///////////////////////////////////////////////////////////////////////////////////
     169///////////////////////////////////////////////////////
    214170void _dma_physical_copy( unsigned int       cluster_xy,  // DMA cluster
    215171                         unsigned int       channel_id,  // DMA channel
     
    225181    if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
    226182    {
    227         _printf("\n[GIET ERROR] in _dma_physical_copy() : illegal DMA channel ");
     183        _puts("\n[DMA ERROR] in _dma_physical_copy() : illegal DMA channel ");
    228184        _exit();
    229185    }
     
    232188    if ( (dst_paddr & 0x3)   || (src_paddr & 0x3) || (size & 0x3) )
    233189    {
    234         _printf("\n[GIET ERROR] in _dma_physical_copy() : buffer unaligned\n");
    235         _exit();
    236     }
    237 
    238 #if GIET_DEBUG_DMA_DRIVER
    239 _printf("\n[DMA DEBUG] Start a dma_physical_copy on channel[%d,%d,%d] at cycle %d\n"
    240         " - src_paddr   = %l\n"
    241         " - dst_paddr   = %l\n"
    242         " - bytes       = %x\n",
    243         x, y, channel_id, _get_proctime(), src_paddr, dst_paddr, size );
     190        _puts("\n[DMA ERROR] in _dma_physical_copy() : buffer unaligned\n");
     191        _exit();
     192    }
     193
     194#if GIET_DEBUG_DMA_DRIVER
     195_puts("\n[DMA DEBUG] enter _dma_physical_copy() for channel[");
     196_putd( x );
     197_puts(",");
     198_putd( y );
     199_puts(",");
     200_putd( channel_id );
     201_puts("] at cycle ");
     202_putd( _get_proctime() );
     203_puts("\n - src_paddr   = ");
     204_putl( src_paddr );
     205_puts("\n - dst_paddr   = ");
     206_putl( dst_paddr );
     207_puts("\n - bytes       = ");
     208_putd( size );
     209_puts("\n");
    244210#endif
    245211
     
    256222
    257223#if GIET_DEBUG_DMA_DRIVER
    258 _printf("\n[DMA DEBUG] _dma_physical_copy() : ... waiting on DMA_STATUS register\n");
     224_puts("\n[DMA DEBUG] _dma_physical_copy() : ... waiting on DMA_STATUS register\n");
    259225#endif
    260226
     
    264230    if( status != DMA_SUCCESS )
    265231    {
    266         _printf("\n[GIET ERROR] in _dma_physical_copy() : DMA_STATUS = %x\n", status );
    267         _exit();
    268     }
     232        _puts("\n[DMA ERROR] in _dma_physical_copy() : bad DMA_STATUS");
     233        _exit();
     234    }
     235
    269236    // reset dma channel
    270237    _dma_reset( cluster_xy, channel_id );
    271238
    272239#if GIET_DEBUG_DMA_DRIVER
    273 _printf("\n[DMA DEBUG] _dma_physical_copy() completed at cycle %d\n", _get_proctime() );
     240_puts("\n[DMA DEBUG] exit _dma_physical_copy() at cycle ");
     241_putd( _get_proctime() );
     242_puts("\n");
    274243#endif
    275244
    276245#else // NB_DMA_CHANNELS == 0
    277     _printf("\n[GIET ERROR] in _dma_physical_copy() : NB_DMA_CHANNELS == 0 / cycle %d\n",
    278             _get_proctime );
     246
     247    _puts("\n[DMA ERROR] in _dma_physical_copy() : NB_DMA_CHANNELS == 0\n");
    279248    _exit();
    280 #endif
    281 }
    282 
    283 ///////////////////////////////////////////////////////////////////////////////////
    284 // This function copies a source memory buffer to a destination memory buffer,
    285 // making virtual to physical address translation: the MMU should be activated.
    286 // This blocking function is supposed to be used by the kernel only,
    287 // and uses a polling policy on DMA_STATUS register to detect completion.
    288 // Therefore, the DMA_IRQ is NOT used.
    289 // The source and destination buffers base addresses must be word aligned,
    290 // and the buffer's size must be multiple of 4.
    291 // In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
    292 // message is displayed on TTY0, and the system crash.
    293 ///////////////////////////////////////////////////////////////////////////////////
     249
     250#endif
     251}
     252
     253
     254////////////////////////////////////////
    294255void  _dma_copy( unsigned int cluster_xy,    // DMA cluster
    295256                 unsigned int channel_id,    // DMA channel
     
    306267    if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
    307268    {
    308         _printf("\n[GIET ERROR] in _dma_copy() : illegal DMA channel ");
     269        _puts("\n[DMA ERROR] in _dma_copy() : illegal DMA channel ");
    309270        _exit();
    310271    }
     
    313274    if ( (dst_vaddr & 0x3)   || (src_vaddr & 0x3) || (size & 0x3) )
    314275    {
    315         _printf("\n[GIET ERROR] in _dma_copy() : buffer unaligned\n");
     276        _puts("\n[DMA ERROR] in _dma_copy() : buffer unaligned\n");
    316277        _exit();
    317278    }
     
    322283
    323284#if GIET_DEBUG_DMA_DRIVER
    324 _printf("\n[DMA DEBUG] Start a dma_copy on channel[%d,%d,%d] at cycle %d\n"
    325         " - src_vaddr   = %x\n"
    326         " - dst_vaddr   = %x\n"
    327         " - bytes       = %x\n",
    328         x, y, channel_id, _get_proctime(), src_vaddr, dst_vaddr, size );
     285_puts("\n[DMA DEBUG] enter _dma_copy() for channel[");
     286_putd( x );
     287_puts(",");
     288_putd( y );
     289_puts(",");
     290_putd( channel_id );
     291_puts("] at cycle ");
     292_putd( _get_proctime() );
     293_puts("\n - src_vaddr   = ");
     294_putx( src_vaddr );
     295_puts("\n - dst_vaddr   = ");
     296_putx( dst_vaddr );
     297_puts("\n - bytes       = ");
     298_putd( size );
     299_puts("\n");
    329300#endif
    330301
     
    334305         (size & 0x3) )
    335306    {
    336         _printf("\n[GIET ERROR] in _dma_copy() : buffer unaligned\n");
     307        _puts("\n[DMA ERROR] in _dma_copy() : buffer unaligned\n");
    337308        _exit();
    338309    }
     
    348319    if ( ko )
    349320    {
    350         _printf("\n[GIET ERROR] in _dma_copy() : source buffer unmapped\n");
     321        _puts("\n[DMA ERROR] in _dma_copy() : source buffer unmapped\n");
    351322        _exit();
    352323    }
     
    361332    if ( ko )
    362333    {
    363         _printf("\n[GIET ERROR] in _dma_copy() : dest buffer unmapped\n");
     334        _puts("\n[DMA ERROR] in _dma_copy() : dest buffer unmapped\n");
    364335        _exit();
    365336    }
     
    368339
    369340#if GIET_DEBUG_DMA_DRIVER
    370 _printf(" - src_paddr   = %l\n"
    371         " - dst_paddr   = %l\n",
    372         src_paddr, dst_paddr );
     341_puts("\n - src_paddr   = ");
     342_putl( src_paddr );
     343_puts("\n - dst_paddr   = ");
     344_putl( dst_paddr );
     345_puts("\n");
    373346#endif
    374347
     
    385358
    386359#if GIET_DEBUG_DMA_DRIVER
    387 _printf("\n[DMA DEBUG] _dma_copy() : ... waiting on DMA_STATUS register\n");
     360_puts("\n[DMA DEBUG] _dma_copy() : ... waiting on DMA_STATUS register\n");
    388361#endif
    389362
     
    393366    if( status != DMA_SUCCESS )
    394367    {
    395         _printf("\n[GIET ERROR] in _dma_copy() : DMA_STATUS = %x\n", status );
     368        _puts("\n[DMA ERROR] in _dma_copy() : bad DMA_STATUS\n");
    396369        _exit();
    397370    }
     
    400373
    401374#if GIET_DEBUG_DMA_DRIVER
    402 _printf("\n[DMA DEBUG] _dma_copy() completed at cycle %d\n", _get_proctime() );
     375_puts("\n[DMA DEBUG] exit _dma_copy() at cycle ");
     376_putd( _get_proctime() );
     377_puts("\n");
    403378#endif
    404379
    405380#else // NB_DMA_CHANNELS == 0
    406     _printf("\n[GIET ERROR] in _dma_copy() : NB_DMA_CHANNELS == 0 / cycle %d\n",
    407             _get_proctime );
     381
     382    _puts("\n[DMA ERROR] in _dma_copy() : NB_DMA_CHANNELS == 0\n");
    408383    _exit();
     384
    409385#endif
    410386} // end _dma_copy
    411387
    412 ///////////////////////////////////////////////////////////////////////////////
    413 // This ISR handles the IRQ generated by a DMA channel.
    414 ///////////////////////////////////////////////////////////////////////////////
     388/////////////////////////////////////
    415389void _dma_isr( unsigned int irq_type,
    416390               unsigned int irq_id,
    417391               unsigned int channel )
    418392{
    419     _printf("\n[GIET ERROR] _dma_isr() not implemented / cycle %d\n",
    420             _get_proctime() );
     393    _puts("\n[DMA ERROR] _dma_isr() not implemented\n");
    421394    _exit();
    422395}
Note: See TracChangeset for help on using the changeset viewer.