Ignore:
Timestamp:
Apr 1, 2013, 8:57:02 PM (11 years ago)
Author:
cfuguet
Message:

Introducing dcache line invalidation mechanism in the boot_ioc_read
function, when using platform without cache coherency.

Introducing two parameters in the defs_platform.h file:

CACHE_COHERENCE

Equals to 0 when no cache coherency

CACHE_LINE_SIZE

Number of bytes in a cache line

  • TODO: Use the config register of the cache models to get

this size

Adding new platform configuration file for the

caba_vgsb_xicu_mmu SOCLIB platform.


File:
1 edited

Legend:

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

    r302 r347  
    11#include <boot_ioc.h>
    2 #include <defs.h>
    32
    43#ifndef SOCLIB_IOC
     
    1615int boot_ioc_init()
    1716{
    18 #ifndef SOCLIB_IOC
     17#ifdef SOCLIB_IOC
     18    return 0;
     19#else
    1920    unsigned char sdcard_rsp;
    2021
     
    5556
    5657    boot_puts("Finish block device initialization\n\r");
    57 #endif
    5858
    5959    return 0;
     60#endif
    6061}
    6162
     
    101102 *       has finished
    102103 */
     104
     105#ifdef SOCLIB_IOC
     106///////////////////////////////////////////////////////////////////////////////
     107// SOCLIB version of the boot_ioc_read function
     108
    103109int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count)
    104110{
    105 #ifdef SOCLIB_IOC
    106111
    107112    unsigned int * ioc_address  = (unsigned int*)VCIBD_BASE;
     
    125130    _boot_ioc_completed();
    126131
     132#if (CACHE_COHERENCE == 0)
     133    boot_dbuf_invalidate(buffer, CACHE_LINE_SIZE, count * 512);
     134#endif
     135    return 0;
     136}
     137
    127138#else
     139///////////////////////////////////////////////////////////////////////////////
     140// FPGA version of the boot_ioc_read function
     141
     142int boot_ioc_read(unsigned int lba, void* buffer, unsigned int count)
     143{
    128144    unsigned int sdcard_rsp;
    129145
     
    147163        }   
    148164    }
    149    
    150 #endif
    151165
    152166    return 0;
    153167}
    154 
    155 /**
    156  * boot_ioc_write()
    157  *
    158  * Transfer data from a memory buffer to a file on the block_device.
    159  *
    160  * \param lba    : first block index on the disk
    161  * \param buffer : base address of the memory buffer
    162  * \param count  : number of blocks to be transfered
    163  *
    164  * \note The source buffer must be in user address space.
    165  *
    166  *in_reset int _ioc_write(unsigned int lba, void* buffer, unsigned int count)
    167  *{
    168  *#ifdef SOCLIB_IOC
    169  *
    170  *    unsigned int * ioc_address = ( unsigned int * )VCIBD_BASE;
    171  *
    172  *    // block_device configuration
    173  *    iowrite32( &ioc_address[BLOCK_DEVICE_BUFFER],
    174  *            ( unsigned int ) buffer );
    175  *
    176  *    iowrite32( &ioc_address[BLOCK_DEVICE_COUNT],
    177  *            ( unsigned int ) count );
    178  *
    179  *    iowrite32( &ioc_address[BLOCK_DEVICE_LBA],
    180  *            ( unsigned int ) lba );
    181  *
    182  *    iowrite32( &ioc_address[BLOCK_DEVICE_IRQ_ENABLE],
    183  *            ( unsigned int ) 0 );
    184  *
    185  *    iowrite32( &ioc_address[BLOCK_DEVICE_OP],
    186  *            ( unsigned int ) BLOCK_DEVICE_WRITE);
    187  *
    188  *    _boot_ioc_completed();
    189  *
    190  *#else   
    191  *       
    192  *    sdcard_dev_lseek(&_sdcard_device, lba);
    193  *    sdcard_dev_write(&_sdcard_device, buffer, count*512);
    194  *
    195  *#endif
    196  *
    197  *    return 0;
    198  *}
    199  */
     168#endif
    200169
    201170/**
    202171 * _dcache_buf_invalidate()
    203172 *
    204  * Invalidate all cache lines corresponding to a memory buffer.
    205  * This is used by the block_device driver.
    206  *
    207  *in_reset static void _dcache_buf_invalidate(const void * buffer, unsigned int size)
    208  *{
    209  *    unsigned int i;
    210  *    unsigned int dcache_line_size;
    211  *
    212  *    // retrieve dcache line size from config register (bits 12:10)
    213  *    asm volatile("mfc0 %0, $16, 1" : "=r" (dcache_line_size));
    214  *
    215  *    dcache_line_size = 2 << ((dcache_line_size>>10) & 0x7);
    216  *
    217  *    // iterate on lines to invalidate each one of them
    218  *    for ( i=0; i<size; i+=dcache_line_size )
    219  *        asm volatile
    220  *            (" mtc2 %0,     $7\n"
    221  *             :
    222  *             : "r" (*((char*)buffer+i))
    223  *             );
    224  *}
     173 * Invalidate all data cache lines corresponding to a memory
     174 * buffer (identified by an address and a size).
    225175 */
     176#if (CACHE_COHERENCE == 0)
     177void boot_dbuf_invalidate (
     178        const void * buffer,
     179        unsigned int line_size,
     180        unsigned int size)
     181{
     182    unsigned int i;
     183
     184    // iterate on cache lines
     185    for (i = 0; i < size; i += line_size) {
     186        asm volatile(
     187            " cache %0, %1"
     188            :// no outputs
     189            :"i" (0x11), "R" (*((unsigned char *) buffer + i))
     190            );
     191    }
     192}
     193#endif
    226194
    227195/*
Note: See TracChangeset for help on using the changeset viewer.