Ignore:
Timestamp:
Dec 4, 2013, 7:59:21 PM (11 years ago)
Author:
alain
Message:

Modify the name "boot" to "reset" to avoid confusion
between the pre-loader and the boot-loader...
Increase the size of the segment containing the stacks.

File:
1 moved

Legend:

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

    r570 r586  
    1 #include <boot_ioc.h>
     1#include <reset_ioc.h>
    22
    33#ifndef SOCLIB_IOC
    44
    5 static struct sdcard_dev  _sdcard_device;
     5static struct sdcard_dev        _sdcard_device;
    66static struct spi_dev   *const  _spi_device   = ( struct spi_dev * )IOC_BASE;
    77
    8 #endif // end ifndef SOCLIB_IOC
    9 
    10 #define SDCARD_RESET_ITER_MAX 4
    11 
    12 inline void boot_sleep(int cycles)
     8#endif
     9
     10#define SDCARD_RESET_ITER_MAX   4
     11
     12///////////////////////////////////
     13inline void reset_sleep(int cycles)
    1314{
    1415    int i;
     
    1617}
    1718
    18 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
    19 inline unsigned int boot_proctime()
     19#if RESET_DEBUG
     20////////////////////////////////////
     21inline unsigned int reset_proctime()
    2022{
    2123    unsigned int ret;
     
    2628
    2729#ifndef SOCLIB_IOC
    28 int boot_ioc_init()
     30/////////////////////////////////////////////////////////////////////////////////
     31//     reset_ioc_init
     32// This function initializes the SDCARD / required for FPGA.
     33/////////////////////////////////////////////////////////////////////////////////
     34int reset_ioc_init()
    2935{
    3036    unsigned char sdcard_rsp;
    3137
    32     boot_puts("Initializing block device\n\r");
     38    reset_puts("Initializing block device\n\r");
    3339
    3440    /**
     
    5056    while(1)
    5157    {
    52         boot_puts("Trying to initialize SD card... ");
     58        reset_puts("Trying to initialize SD card... ");
    5359
    5460        sdcard_rsp = sdcard_dev_open(&_sdcard_device, _spi_device, 0);
    5561        if (sdcard_rsp == 0)
    5662        {
    57             boot_puts("OK\n");
     63            reset_puts("OK\n");
    5864            break;
    5965        }
    6066
    61         boot_puts("KO\n");
    62         boot_sleep(1000);
     67        reset_puts("KO\n");
     68        reset_sleep(1000);
    6369        if (++iter >= SDCARD_RESET_ITER_MAX)
    6470        {
    65             boot_puts("\nERROR: During SD card reset to IDLE state\n"
     71            reset_puts("\nERROR: During SD card reset to IDLE state\n"
    6672                      "/ card response = ");
    67             boot_putx(sdcard_rsp);
    68             boot_puts("\n");
    69             boot_exit();
     73            reset_putx(sdcard_rsp);
     74            reset_puts("\n");
     75            reset_exit();
    7076        }
    7177    }
     
    7783    if (sdcard_rsp)
    7884    {
    79         boot_puts("ERROR: During SD card blocklen initialization\n");
    80         boot_exit();
     85        reset_puts("ERROR: During SD card blocklen initialization\n");
     86        reset_exit();
    8187    }
    8288
     
    9399    );
    94100
    95     boot_puts("Finish block device initialization\n\r");
     101    reset_puts("Finish block device initialization\n\r");
    96102
    97103    return 0;
    98 }
    99 #endif // end ifndef SOCLIB_IOC
    100 
    101 /**
    102  * _boot_ioc_completed()
    103  *
    104  * This blocking function checks completion of an I/O transfer and reports errors.
    105  *
    106  * \note It returns 0 if the transfer is successfully completed.
    107  *       It returns -1 if an error has been reported.
    108  */
     104} // end reset_ioc_init()
     105#endif
     106
    109107#ifdef SOCLIB_IOC
    110 static int _boot_ioc_completed()
     108/////////////////////////////////////////////////////////////////////////////////////
     109//      reset_ioc_completed()
     110// This blocking function checks completion of an I/O transfer and reports errors.
     111// It returns 0 if the transfer is successfully completed.
     112// It returns -1 if an error has been reported.
     113/////////////////////////////////////////////////////////////////////////////////////
     114int reset_ioc_completed()
    111115{
    112116    unsigned int status = 0;
    113117
    114 
    115     unsigned int * ioc_address = ( unsigned int * )IOC_BASE;
     118    unsigned int * ioc_address = ( unsigned int * )IOC_PADDR_BASE;
    116119
    117120    while ( 1 )
     
    125128
    126129    return status;
    127 }
    128 #endif
    129 
    130 /**
    131  * boot_ioc_read()
    132  *
    133  * Transfer data from a file on the block device to a memory buffer.
    134  *
    135  * \param lba    : first block index on the disk
    136  * \param buffer : base address of the memory buffer
    137  * \param count  : number of blocks to be transfered
    138  *
    139  * \note This is a blocking function. The function returns once the transfer
    140  *       has finished
    141  */
     130} // end reset_ioc_completed()
     131#endif
    142132
    143133#ifdef SOCLIB_IOC
    144 ///////////////////////////////////////////////////////////////////////////////
    145 // SOCLIB version of the boot_ioc_read function
    146 
    147 void boot_buf_invalidate (
    148         const void * buffer,
    149         unsigned int line_size,
    150         unsigned int size);
    151 
    152 void boot_mcc_invalidate (
    153         const void * buffer,
    154         unsigned int size);
    155 
    156 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count)
    157 {
    158 
    159     unsigned int * ioc_address  = (unsigned int*)IOC_BASE;
    160 
    161 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
     134/////////////////////////////////////////////////////////////////////////////////////
     135//      reset_ioc_read()
     136// Transfer data the block device to a memory buffer: SOCLIB version
     137// - param lba    : first block index on the disk
     138// - param buffer : base address of the memory buffer
     139// - param count  : number of blocks to be transfered
     140// This is a blocking function. The function returns once the transfer is completed.
     141/////////////////////////////////////////////////////////////////////////////////////
     142int reset_ioc_read( unsigned int lba,
     143                    void*        buffer,
     144                    unsigned int count )
     145{
     146
     147    unsigned int * ioc_address  = (unsigned int*)IOC_PADDR_BASE;
     148
     149#if RESET_DEBUG
    162150    unsigned int start_time;
    163151    unsigned int end_time;
    164     boot_puts("[ DEBUG ] Reading blocks ");
    165     boot_putd(lba);
    166     boot_puts(" to ");
    167     boot_putd(lba + count - 1);
    168 
    169     start_time = boot_proctime();
     152    reset_puts("[RESET DEBUG] Reading blocks ");
     153    reset_putd(lba);
     154    reset_puts(" to ");
     155    reset_putd(lba + count - 1);
     156
     157    start_time = reset_proctime();
    170158#endif
    171159
     
    186174            ( unsigned int ) BLOCK_DEVICE_READ );
    187175
    188     _boot_ioc_completed();
     176    reset_ioc_completed();
    189177
    190178#if (CACHE_COHERENCE == 0) || (USE_IOB == 1)
    191     boot_buf_invalidate(buffer, CACHE_LINE_SIZE, count * 512);
    192 #endif
    193 
    194 #if (USE_IOB == 1)
    195     boot_mcc_invalidate(buffer, count * 512);
    196 #endif
    197 
    198 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
    199     end_time = boot_proctime();
    200 
    201     boot_puts(" / cycles for transfert: ");
    202     boot_putd(end_time - start_time);
    203     boot_puts("\n");
     179    reset_buf_invalidate(buffer, CACHE_LINE_SIZE, count * 512);
     180#endif
     181
     182#if USE_IOB
     183    reset_mcc_invalidate(buffer, count * 512);
     184#endif
     185
     186#if RESET_DEBUG
     187    end_time = reset_proctime();
     188    reset_puts(" / cycles for transfert: ");
     189    reset_putd(end_time - start_time);
     190    reset_puts("\n");
    204191#endif
    205192
    206193    return 0;
    207 }
     194} // end reset_ioc_read()
    208195
    209196#else
    210197
    211 ///////////////////////////////////////////////////////////////////////////////
    212 // FPGA version of the boot_ioc_read function
    213 
    214 int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count)
     198/////////////////////////////////////////////////////////////////////////////////////
     199//      reset_ioc_read()
     200// Transfer data the block device to a memory buffer: FPGA version
     201// - param lba    : first block index on the disk
     202// - param buffer : base address of the memory buffer
     203// - param count  : number of blocks to be transfered
     204// This is a blocking function. The function returns once the transfer is completed.
     205/////////////////////////////////////////////////////////////////////////////////////
     206int reset_ioc_read( unsigned int lba,
     207                    void*        buffer,
     208                    unsigned int count )
    215209{
    216210    unsigned int sdcard_rsp;
     
    219213    sdcard_dev_lseek(&_sdcard_device, lba);
    220214
    221 #if (BOOT_DEBUG ==1 && BOOT_DEBUG_IOC == 1)
     215#if RESET_DEBUG
    222216    unsigned int start_time;
    223217    unsigned int end_time;
    224     boot_puts("[ DEBUG ] Reading blocks ");
    225     boot_putd(lba);
    226     boot_puts(" to ");
    227     boot_putd(lba + count - 1);
    228 
    229     start_time = boot_proctime();
     218    reset_puts("[RESET DEBUG] Reading blocks ");
     219    reset_putd(lba);
     220    reset_puts(" to ");
     221    reset_putd(lba + count - 1);
     222    start_time = reset_proctime();
    230223#endif
    231224
     
    239232            ))
    240233        {
    241             boot_puts("ERROR during read on the SDCARD device. Code: ");
    242             boot_putx(sdcard_rsp);
    243             boot_puts("\n\r");
     234            reset_puts("ERROR during read on the SDCARD device. Code: ");
     235            reset_putx(sdcard_rsp);
     236            reset_puts("\n\r");
    244237
    245238            return 1;
     
    247240    }
    248241
    249 #if (BOOT_DEBUG == 1 && BOOT_DEBUG_IOC == 1)
    250     end_time = boot_proctime();
    251 
    252     boot_puts(" / cycles for transfert: ");
    253     boot_putd(end_time - start_time);
    254     boot_puts("\n");
     242#if RESET_DEBUG
     243    end_time = reset_proctime();
     244    reset_puts(" / cycles for transfert: ");
     245    reset_putd(end_time - start_time);
     246    reset_puts("\n");
    255247#endif
    256248
    257249    return 0;
    258 }
    259 #endif
    260 
    261 /**
    262  * _dcache_buf_invalidate()
    263  *
    264  * Invalidate all data cache lines corresponding to a memory
    265  * buffer (identified by an address and a size).
    266  */
     250} // end reset_ioc_read()
     251#endif
     252
     253//////////////////////////////////////////////////////////////////////////////
     254// reset_dcache_buf_invalidate()
     255// Invalidate all data cache lines corresponding to a memory buffer
     256// (identified by an address and a size) in L1 cache.
     257/////////////////////////////////////////////////////////////////////////////
    267258#if (CACHE_COHERENCE == 0) || (USE_IOB == 1)
    268 void boot_buf_invalidate (
    269         const void * buffer,
    270         unsigned int line_size,
    271         unsigned int size)
     259void reset_buf_invalidate ( const void * buffer,
     260                            unsigned int line_size,
     261                            unsigned int size)
    272262{
    273263    unsigned int i;
    274264
    275265    // iterate on cache lines
    276     for (i = 0; i <= size; i += line_size) {
     266    for (i = 0; i <= size; i += line_size)
     267    {
    277268        asm volatile(
    278269            " cache %0, %1"
     
    284275#endif
    285276
    286 /**
    287  * boot_mcc_inval()
    288  *
    289  * Invalidate all data cache lines corresponding to a memory
    290  * buffer (identified by an address and a size).
    291  */
    292 #if (USE_IOB == 1)
    293 void boot_mcc_invalidate (
    294         const void * buffer,
    295         unsigned int size)
    296 {
    297     unsigned int * mcc_address = (unsigned int *)MCC_BASE;
     277//////////////////////////////////////////////////////////////////////////////
     278// reset_mcc_inval()
     279// Invalidate all data cache lines corresponding to a memory buffer
     280// (identified by an address and a size) in L2 cache.
     281/////////////////////////////////////////////////////////////////////////////
     282#if USE_IOB
     283void reset_mcc_invalidate ( const void * buffer,
     284                            unsigned int size)
     285{
     286    unsigned int * mcc_address = (unsigned int *)MCC_PADDR_BASE;
    298287
    299288    // get the hard lock assuring exclusive access to MEMC
Note: See TracChangeset for help on using the changeset viewer.