Ignore:
Timestamp:
Jul 24, 2014, 3:19:18 PM (10 years ago)
Author:
cfuguet
Message:

tsar_boot: improving configuration infrastructure

  • Using hard_config.h which respects the same sintax that the hard_config.h file of all TSAR platforms. This file can be then generated by the GIET-VM genmap tool or written manually.
  • All peripheral drivers have been moved to a drivers directory and they are compiled as a static library. This allows GCC to only include in the final .ELF the object files of used peripherals and not all of them.
  • Example hard_config.h and ldscripts have been introduced in the conf directory.
  • Improving comments in all files
File:
1 edited

Legend:

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

    r703 r758  
    88
    99#include <reset_utils.h>
    10 
    11 /*
    12  * pread(size_t file_offset, void* buf, size_t nbyte, size_t offset)
    13  *
    14  * read from disk into buffer "nbyte" bytes from (file_offset + offset)
    15  *
     10#include <reset_tty.h>
     11#include <reset_ioc.h>
     12#include <io.h>
     13
     14/**
    1615 * \param file_offset: Disk relative offset of file
    1716 * \param buf: Destination buffer
    1817 * \param nbyte: Number of bytes to read
    1918 * \param offset: File relative offset
     19 *
     20 * \brief read from disk into buffer "nbyte" bytes from (file_offset + offset)
    2021 *
    2122 * \note Absolute disk offset (in bytes) is (file_offset + offset)
     
    5758        if (offset_blk != blk_buf_idx) {
    5859            if (reset_ioc_read(offset_blk, (void*)&blk_buf, 1)) {
    59                 return -1; 
     60                return -1;
    6061            }
    6162        }
    6263        blk_buf_idx = offset_blk;
    63         read_nbyte = (nbyte > unaligned_nbyte) ? unaligned_nbyte : nbyte; 
     64        read_nbyte = (nbyte > unaligned_nbyte) ? unaligned_nbyte : nbyte;
    6465        memcpy((void*)dst, (void*)&blk_buf.b[offset], read_nbyte);
    6566        nbyte -= read_nbyte;
     
    7071     * Read aligned bytes directly to buffer
    7172     */
    72     size_t nblk = nbyte / BLOCK_SIZE; 
     73    size_t nblk = nbyte / BLOCK_SIZE;
    7374    if (nblk) {
    7475        if (reset_ioc_read(offset_blk, (void*)&dst[read_nbyte], nblk)) {
     
    9192        read_nbyte += nbyte;
    9293    }
    93     return read_nbyte;
    94 }
    95 
    96 /********************************************************************
    97  * proctime()
    98  *
    99  * Returns processor local time.
    100  ********************************************************************/
    101 inline unsigned int proctime()
    102 {
    103     unsigned int ret;
    104     asm volatile ("mfc0   %0,        $9":"=r" (ret));
    105     return ret;
    106 }
    107 
    108 /********************************************************************
    109  * memcpy( _dst, _src, size )
    110  *
    111  * Transfer data between two memory buffers.
    112  *
    113  * \param _dst   : Destination buffer base address
     94    return read_nbyte;
     95}
     96
     97/**
     98 * \param _dst   : Destination buffer base address
    11499 * \param _src   : Source buffer base address
    115  * \param size   : Number of bytes to transfer
    116  *
    117  ********************************************************************/
     100 * \param size   : Number of bytes to transfer
     101 *
     102 * \brief Transfer data between two memory buffers.
     103 */
    118104void* memcpy(void *_dst, const void *_src, size_t n)
    119105{
     
    135121}
    136122
    137 /********************************************************************
    138  * memset( _dst, value, size )
    139  *
    140  * Initialize memory buffers with predefined value.
    141  *
    142  * \param _dst   : Destination buffer base address
    143  * \param value  : Initialization value
     123/**
     124 * \param _dst   : Destination buffer base address
     125 * \param value  : Initialization value
    144126 * \param size   : Number of bytes to initialize
    145127 *
    146  ********************************************************************/
     128 * \brief Initialize memory buffers with predefined value.
     129 */
    147130void* memset(void *_dst, int c, size_t len)
    148131{
     
    179162}
    180163
    181 /********************************************************************
    182  * check_elf_header(Elf32_Ehdr*)
    183  *
    184  * Verify that ELF file is valid and that the number of program
    185  * headers does not exceed the defined maximum
    186  *
     164/**
    187165 * \param ehdr : ELF header pointer
    188166 *
    189  ********************************************************************/
     167 * \brief Verify that ELF file is valid and that the number of program headers
     168 *        does not exceed the defined maximum
     169 */
    190170void check_elf_header(Elf32_Ehdr *ehdr)
    191171{
     
    205185     * Verification of Program Headers table size. It must be
    206186     * smaller than the work size allocated for the
    207      * elf_pht[PHDR_ARRAY_SIZE] array
    208      */
    209     if (ehdr->e_phnum > PHDR_ARRAY_SIZE)
     187     * elf_pht[RESET_PHDR_ARRAY_SIZE] array
     188     */
     189    if (ehdr->e_phnum > RESET_PHDR_ARRAY_SIZE)
    210190    {
    211191        reset_puts("[RESET ERROR] ELF PHDR table size too large\n");
     
    214194}
    215195
    216 /********************************************************************
    217  * reset_print_elf_phdr( elf_phdr_ptr )
    218  *
    219  * Print some fields of a ELF program header
    220  *
     196/**
    221197 * \param elf_phdr_ptr : Pointer to the ELF program header to print
    222198 *
    223  ********************************************************************/
     199 * \brief Print some fields of a ELF program header
     200 */
    224201void reset_print_elf_phdr(Elf32_Phdr * elf_phdr_ptr)
    225202{
     
    243220}
    244221
    245 
    246 /********************************************************************
    247  * reset_mcc_inval()
    248  *
    249  * Invalidate all data cache lines corresponding to a memory buffer
    250  * (identified by an address and a size) in L2 cache.
    251  ********************************************************************/
    252 #if USE_IOB
    253 void reset_mcc_invalidate (const void * buffer, size_t size)
    254 {
    255     addr_t *mcc_address = (addr_t*)MCC_PADDR_BASE;
    256 
    257     // get the hard lock assuring exclusive access to MEMC
    258     while (ioread32(&mcc_address[MCC_LOCK]));
    259 
    260     // write invalidate paremeters on the memory cache this preloader
    261     // use only the cluster 0 and then the HI bits are not used
    262    
    263     iowrite32(&mcc_address[MCC_ADDR_LO], (unsigned int) buffer);
    264     iowrite32(&mcc_address[MCC_ADDR_HI], (unsigned int) 0);
    265     iowrite32(&mcc_address[MCC_LENGTH] , (unsigned int) size);
    266     iowrite32(&mcc_address[MCC_CMD]    , (unsigned int) MCC_CMD_INVAL);
    267 
    268     // release the lock protecting MEMC
    269     iowrite32(&mcc_address[MCC_LOCK], (unsigned int) 0);
    270 }
    271 #endif
    272 
    273 /********************************************************************
    274  * reset_dcache_buf_invalidate()
    275  *
    276  * Invalidate all data cache lines corresponding to a memory buffer
    277  * (identified by an address and a size) in L1 cache and L2 cache.
    278  ********************************************************************/
    279 #if (CACHE_COHERENCE == 0) || USE_IOB
    280 void reset_buf_invalidate (const void * buffer, size_t line_size, size_t size)
    281 {
    282     unsigned int i;
    283 
    284     // iterate on cache lines
    285     for (i = 0; i <= size; i += line_size)
    286     {
    287         asm volatile(
    288             " cache %0, %1"
    289             :// no outputs
    290             :"i" (0x11), "R" (*((unsigned char *) buffer + i))
    291             );
    292     }
    293 
    294 #if USE_IOB
    295     reset_mcc_invalidate(buffer, size);
    296 #endif
    297 }
    298 #endif
    299 
    300 // vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
     222/*
     223 * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
     224 */
Note: See TracChangeset for help on using the changeset viewer.