zoukankan      html  css  js  c++  java
  • Nios II 中的缓存和内存数据的读写

    nios 使用地址中31bit来表示访问是否bypass cache。
    如果bit 31=0 表示不bypass cache,即使用cache里的数据;如果bit 31=1表示bypass cache,即直接使用mem中的数据。
    如alt_remap_uncached函数

     1 #ifdef NIOS2_MMU_PRESENT
     2 /* Convert KERNEL region address to IO region address */
     3 #define BYPASS_DCACHE_MASK   (0x1 << 29)
     4 #else
     5 /* Set bit 31 of address to bypass D-cache */
     6 #define BYPASS_DCACHE_MASK   (0x1 << 31)
     7 #endif
     8 
     9 /*
    10  * Convert a pointer to a block of cached memory, into a block of
    11  * uncached memory.
    12  */
    13 
    14 volatile void* alt_remap_uncached (void* ptr, alt_u32 len)
    15 {
    16   alt_dcache_flush (ptr, len);
    17   return (volatile void*) (((alt_u32) ptr) | BYPASS_DCACHE_MASK);
    18 }

     其中

     1 #ifdef NIOS2_FLUSHDA_SUPPORTED
     2 #define ALT_FLUSH_DATA(i) __asm__ volatile ("flushda (%0)" :: "r" (i));
     3 #else
     4 #define ALT_FLUSH_DATA(i) __asm__ volatile ("flushd (%0)" :: "r" (i));
     5 #endif /* NIOS2_FLUSHDA_SUPPORTED */
     6 
     7 /*
     8  * alt_dcache_flush() is called to flush the data cache for a memory
     9  * region of length "len" bytes, starting at address "start".
    10  *
    11  * Any dirty lines in the data cache are written back to memory.
    12  */
    13 
    14 void alt_dcache_flush (void* start, alt_u32 len)
    15 {
    16 #if NIOS2_DCACHE_SIZE > 0
    17 
    18   char* i;
    19   char* end; 
    20 
    21   /*
    22    * This is the most we would ever need to flush.
    23    *
    24    * SPR 196942, 2006.01.13: The cache flush loop below will use the
    25    * 'flushda' instruction if its available; in that case each line
    26    * must be flushed individually, and thus 'len' cannot be trimmed.
    27    */
    28   #ifndef NIOS2_FLUSHDA_SUPPORTED
    29   if (len > NIOS2_DCACHE_SIZE)
    30   {
    31     len = NIOS2_DCACHE_SIZE;
    32   }
    33   #endif
    34 
    35   end = ((char*) start) + len; 
    36 
    37   for (i = start; i < end; i+= NIOS2_DCACHE_LINE_SIZE)
    38   { 
    39     ALT_FLUSH_DATA(i); 
    40   }
    41 
    42   /* 
    43    * For an unaligned flush request, we've got one more line left.
    44    * Note that this is dependent on NIOS2_DCACHE_LINE_SIZE to be a 
    45    * multiple of 2 (which it always is).
    46    */
    47 
    48   if (((alt_u32) start) & (NIOS2_DCACHE_LINE_SIZE - 1))
    49   {
    50     ALT_FLUSH_DATA(i);
    51   }
    52 
    53 #endif /* NIOS2_DCACHE_SIZE > 0 */
    54 }
  • 相关阅读:
    pyqt5 动画在QThread线程中无法运行问题
    几种编码格式
    Android精品课程—PullToRefresh 下拉刷新
    【张泽华】android视频教程下载地址及上课源代码
    Android中常用适配器及定义自己的适配器
    VirtualBOX 虚拟机安装 OS X 10.9 Mavericks 及 Xcode 5,本人X220亲测
    google maps api申请的问题
    如何在Android应用程序中使用传感器(OpenIntents开源组织SensorSimulator项目)
    cvsnt 设置用户、修改密码
    Windows下用Git下载android源码 转载
  • 原文地址:https://www.cnblogs.com/zhongzhe/p/3936024.html
Copyright © 2011-2022 走看看