Ignore:
Timestamp:
Jun 17, 2013, 7:10:20 PM (11 years ago)
Author:
porquet
Message:

boot_tsar: bug fix and more debug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/softs/tsar_boot/src/boot_ioc.c

    r388 r412  
    2121}
    2222
    23 #if INSTRUMENTATION
     23#if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
    2424inline unsigned int boot_proctime()
    2525{
     
    2828    return ret;
    2929}
    30 #endif // end if INSTRUMENTATION
     30#endif
    3131
    3232#ifndef SOCLIB_IOC
     
    4747      SPI_TX_NEGEDGE,
    4848      SPI_RX_POSEDGE
    49     ); 
     49    );
    5050
    5151    /**
     
    5353     */
    5454    unsigned int iter = 0;
    55     while(1) 
     55    while(1)
    5656    {
    5757        boot_puts("Trying to initialize SD card... ");
     
    118118
    119119
    120     unsigned int * ioc_address = ( unsigned int * )VCIBD_BASE;
    121  
     120    unsigned int * ioc_address = ( unsigned int * )IOC_BASE;
     121
    122122    while ( 1 )
    123     { 
     123    {
    124124        status = ioread32(&ioc_address[BLOCK_DEVICE_STATUS]);
    125125
     
    128128        break;
    129129    }
    130    
     130
    131131    return status;
    132132}
     
    135135/**
    136136 * boot_ioc_read()
    137  * 
     137 *
    138138 * Transfer data from a file on the block device to a memory buffer.
    139139 *
     
    153153{
    154154
    155     unsigned int * ioc_address  = (unsigned int*)VCIBD_BASE;
    156 
    157     // block_device configuration
    158     iowrite32( &ioc_address[BLOCK_DEVICE_BUFFER],
    159             ( unsigned int ) buffer );
    160 
    161     iowrite32( &ioc_address[BLOCK_DEVICE_COUNT],
    162             ( unsigned int ) count );
    163 
    164     iowrite32( &ioc_address[BLOCK_DEVICE_LBA],
    165             ( unsigned int ) lba );
    166 
    167     iowrite32( &ioc_address[BLOCK_DEVICE_IRQ_ENABLE],
    168             ( unsigned int ) 0 );
    169 
    170     iowrite32( &ioc_address[BLOCK_DEVICE_OP],
    171             ( unsigned int ) BLOCK_DEVICE_READ );
    172 
    173     _boot_ioc_completed();
    174 
    175 #if (CACHE_COHERENCE == 0)
    176     boot_dbuf_invalidate(buffer, CACHE_LINE_SIZE, count * 512);
    177 #endif
    178     return 0;
    179 }
    180 
    181 #else
    182 
    183 ///////////////////////////////////////////////////////////////////////////////
    184 // FPGA version of the boot_ioc_read function
    185 
    186 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count)
    187 {
    188     unsigned int sdcard_rsp;
    189     unsigned int i;
    190 
    191     sdcard_dev_lseek(&_sdcard_device, lba);
    192 
    193 #if INSTRUMENTATION
     155    unsigned int * ioc_address  = (unsigned int*)IOC_BASE;
     156
     157#if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
    194158    unsigned int start_time;
    195159    unsigned int end_time;
     
    202166#endif
    203167
     168    // block_device configuration
     169    iowrite32( &ioc_address[BLOCK_DEVICE_BUFFER],
     170            ( unsigned int ) buffer );
     171
     172    iowrite32( &ioc_address[BLOCK_DEVICE_COUNT],
     173            ( unsigned int ) count );
     174
     175    iowrite32( &ioc_address[BLOCK_DEVICE_LBA],
     176            ( unsigned int ) lba );
     177
     178    iowrite32( &ioc_address[BLOCK_DEVICE_IRQ_ENABLE],
     179            ( unsigned int ) 0 );
     180
     181    iowrite32( &ioc_address[BLOCK_DEVICE_OP],
     182            ( unsigned int ) BLOCK_DEVICE_READ );
     183
     184    _boot_ioc_completed();
     185
     186#if (CACHE_COHERENCE == 0)
     187    boot_dbuf_invalidate(buffer, CACHE_LINE_SIZE, count * 512);
     188#endif
     189
     190#if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
     191    end_time = boot_proctime();
     192
     193    boot_puts(" / cycles for transfert: ");
     194    boot_putd(end_time - start_time);
     195    boot_puts("\n");
     196#endif
     197
     198    return 0;
     199}
     200
     201#else
     202
     203///////////////////////////////////////////////////////////////////////////////
     204// FPGA version of the boot_ioc_read function
     205
     206int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count)
     207{
     208    unsigned int sdcard_rsp;
     209    unsigned int i;
     210
     211    sdcard_dev_lseek(&_sdcard_device, lba);
     212
     213#if (BOOT_DEBUG ==1 && BOOT_DEBUG_IOC == 1)
     214    unsigned int start_time;
     215    unsigned int end_time;
     216    boot_puts("[ DEBUG ] Reading blocks ");
     217    boot_putd(lba);
     218    boot_puts(" to ");
     219    boot_putd(lba + count - 1);
     220
     221    start_time = boot_proctime();
     222#endif
     223
    204224    for(i = 0; i < count; i++)
    205225    {
     
    208228                        (unsigned char *) buffer + (512 * i),
    209229                        512
    210                         ) 
     230                        )
    211231            ))
    212232        {
    213             boot_puts("ERROR during read on the SDCARD device. Code: "); 
     233            boot_puts("ERROR during read on the SDCARD device. Code: ");
    214234            boot_putx(sdcard_rsp);
    215235            boot_puts("\n\r");
     
    219239    }
    220240
    221 #if INSTRUMENTATION
     241#if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
    222242    end_time = boot_proctime();
    223243
     
    234254 * _dcache_buf_invalidate()
    235255 *
    236  * Invalidate all data cache lines corresponding to a memory 
     256 * Invalidate all data cache lines corresponding to a memory
    237257 * buffer (identified by an address and a size).
    238258 */
     
    245265    unsigned int i;
    246266
    247     // iterate on cache lines 
     267    // iterate on cache lines
    248268    for (i = 0; i < size; i += line_size) {
    249269        asm volatile(
Note: See TracChangeset for help on using the changeset viewer.