Changeset 412


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

boot_tsar: bug fix and more debug

Location:
trunk/softs/tsar_boot
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/softs/tsar_boot/conf/platform_fpga_de2-115/defs_platform.h

    r399 r412  
    77#define CACHE_LINE_SIZE 64//bytes
    88
    9 #define INSTRUMENTATION 0
     9#define BOOT_DEBUG      0
     10#define BOOT_DEBUG_IOC  0
    1011
    1112#define IOC_BASE        0xFB000000
    12 #define VCIBD_BASE      0xFB000000
    1313#define TTY_BASE        0xFC000000
    1414#define ICU_BASE        0xFD000000
  • trunk/softs/tsar_boot/conf/platform_vgsb_xicu_mmu/defs_platform.h

    r347 r412  
    99#define ICU_BASE        0x00F00000
    1010#define IOC_BASE        0x00F10000
    11 #define VCIBD_BASE      IOC_BASE
    1211#define TTY_BASE        0x00F20000
  • trunk/softs/tsar_boot/include/boot_ioc.h

    r388 r412  
    1515/**
    1616 * boot_ioc_read()
    17  * 
     17 *
    1818 * Transfer data from a file on the block device to a memory buffer.
    1919 *
  • trunk/softs/tsar_boot/src/boot_elf_loader.c

    r388 r412  
    3737    unsigned int i;
    3838    unsigned int segment_req;
    39    
     39
    4040    /*
    4141     * Loader state machine definition
    42      */ 
     42     */
    4343    enum
    4444    {
     
    4848        ELF_SEGMENT_STATE,
    4949        ELF_END_STATE
    50     } init_state;
     50    } init_state
     51#if (BOOT_DEBUG ==1)
     52    , init_state_debug
     53#endif
     54        ;
     55
     56#if (BOOT_DEBUG == 1)
     57    char* init_state_str[] = {
     58        "ELF_HEADER_STATE",
     59        "ELF_PROGRAM_HEADER_STATE",
     60        "ELF_OFFSET_STATE",
     61        "ELF_SEGMENT_STATE",
     62        "ELF_END_STATE"
     63    };
     64#endif
     65
    5166
    5267    boot_puts("Starting boot_elf_loader function...\n\r");
     
    6378
    6479    init_state         = ELF_HEADER_STATE;
     80#if (BOOT_DEBUG == 1)
     81    init_state_debug   = ELF_END_STATE;
     82#endif
    6583
    6684    while(init_state != ELF_END_STATE)
     
    88106        offset  +=  nb_read;
    89107
     108#if (BOOT_DEBUG == 1)
     109        if (init_state != init_state_debug)
     110        {
     111            boot_puts("init_state = ");
     112            boot_puts(init_state_str[init_state]);
     113            boot_puts("\n");
     114            init_state_debug = init_state;
     115        }
     116#endif
     117
    90118        switch(init_state)
    91119        {
     
    113141                            "Input file does not use ELF format"
    114142                            "\n"
    115                         ); 
     143                        );
    116144
    117145                        boot_exit();
    118146                    }
    119147
    120                     /* 
     148                    /*
    121149                     * Verification of Program Headers table size. It must be
    122                      * smaller than the work size allocated for the 
     150                     * smaller than the work size allocated for the
    123151                     * elf_pht[PHDR_ARRAY_SIZE] array
    124152                     **/
     
    142170            /**
    143171             * Reading ELF program headers
    144              */ 
     172             */
    145173            case ELF_PROGRAM_HEADER_STATE:
    146174                boot_memcpy(elf_pht_ptr, buffer_ptr, nb_read);
     
    160188                        if(elf_pht_ptr[pseg].p_type == PT_LOAD)
    161189                        {
    162                             nb_rest = elf_pht_ptr[pseg].p_offset - offset;
     190#if (BOOT_DEBUG == 1)
     191                            boot_puts("found a loadable segment:\n");
     192                            boot_puts("- type   : "); boot_putx(elf_pht_ptr[pseg].p_type);    boot_puts("\n");
     193                            boot_puts("- offset : "); boot_putx(elf_pht_ptr[pseg].p_offset);  boot_puts("\n");
     194                            boot_puts("- vaddr  : "); boot_putx(elf_pht_ptr[pseg].p_vaddr);   boot_puts("\n");
     195                            boot_puts("- paddr  : "); boot_putx(elf_pht_ptr[pseg].p_paddr);   boot_puts("\n");
     196                            boot_puts("- filesz : "); boot_putx(elf_pht_ptr[pseg].p_filesz);  boot_puts("\n");
     197                            boot_puts("- memsz  : "); boot_putx(elf_pht_ptr[pseg].p_memsz);   boot_puts("\n");
     198                            boot_puts("- flags  : "); boot_putx(elf_pht_ptr[pseg].p_flags);   boot_puts("\n");
     199                            boot_puts("- align  : "); boot_putx(elf_pht_ptr[pseg].p_align);   boot_puts("\n");
     200#endif
     201                            if (elf_pht_ptr[pseg].p_offset < offset)
     202                            {
     203                                /* case where the segment to load includes the elf and program headers */
     204                                nb_rest = elf_pht_ptr[pseg].p_filesz - offset;
     205                                init_state = ELF_SEGMENT_STATE;
     206                            }
     207                            else
     208                            {
     209                                /* segment to load is further away in memory */
     210                                nb_rest = elf_pht_ptr[pseg].p_offset - offset;
     211                                init_state = ELF_OFFSET_STATE;
     212                            }
    163213                            break;
    164214                        }
    165215                    }
    166216
    167                     init_state = ELF_OFFSET_STATE;
     217                    if (pseg == elf_header_ptr->e_phnum)
     218                    {
     219                        boot_puts(
     220                            "ERROR: "
     221                            "No PT_LOAD found"
     222                            "\n"
     223                        );
     224                        boot_exit();
     225                    }
     226
    168227                }
    169228
     
    191250                 * Copying ELF segment data in memory segments using the virtual
    192251                 * address got from the ELF file
    193                  */ 
     252                 */
    194253                segment_req = ((elf_pht_ptr[pseg].p_vaddr & 0xBFC00000) != 0xBFC00000);
    195254
     
    201260                                nb_read);
    202261                }
    203    
     262
    204263                nb_rest -= nb_read;
    205264
     
    237296                    /*
    238297                     * Program loading finished
    239                      */ 
     298                     */
    240299                    if(pseg == elf_header_ptr->e_phnum)
    241300                    {
  • 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.