当前位置: 代码迷 >> 汇编语言 >> 一段arm的编译语言,几天了也不懂
  详细解决方案

一段arm的编译语言,几天了也不懂

热度:10162   发布时间:2013-02-26 00:00:00.0
一段arm的汇编语言,几天了也不懂
void cp15_force_cache_coherence(UNS_32 *start_adr,
  UNS_32 *end_adr)
{
  register UNS_32 * addr;

  /*******************************************************************
  * Cache lines are 32-bytes (8 words); clean and invalidate each
  * line of D-cache and invalidate each line of I-cache within the
  * address range. Make sure addresses are 32-bit aligned.
  ******************************************************************/
  for (addr = (UNS_32 *)((UNS_32)start_adr & 0xFFFFFFE0);
  addr < end_adr;
  addr += 8)
  {
  /* p15 is MMU coprocessor, Cache OPS is c7, TLB OPS is c8 */
#ifdef __GNUC__
asm("MOV r0, %0" : : "r"(addr));
  /* Clean and Invalidate D-Cache single entry using MVA format */
  asm("MCR p15, 0, r0, c7, c14, 1");
  /* Invalidate I-Cache single entry using MVA format */
  asm("MCR p15, 0, r0, c7, c5, 1");
#endif
#ifdef __ghs__
  invalcache(addr);
#endif
#ifdef __arm
  UNS_32 trx;
  __asm
  {
  MOV trx, addr
  /* Clean and Invalidate D-Cache single entry using MVA
  format */
  MCR p15, 0, trx, c7, c14, 1
  /* Invalidate I-Cache single entry using MVA format */
  MCR p15, 0, trx, c7, c5, 1
  }
#endif
#ifdef __ICCARM__

  /* Use IAR intrinsic functions */
  __MCR(15, 0, (UNS_32)addr, 7, 14, 1);
  __MCR(15, 0, (UNS_32)addr, 7, 5, 1);
#endif

  }
  /*******************************************************************
  * Invalidate the I-TLB within the the address range. The I-TLB has
  * 256 word granularity. Make sure addresses are '256 word' aligned.
  ******************************************************************/
  for (addr = (UNS_32 *)((UNS_32)start_adr & 0xFFFFFC00);
  addr < end_adr;
  addr += 256)
  {
#ifdef __GNUC__
asm("MOV r0, %0" : : "r"(addr));
  /* Invalidate I-TLB using MVA format */
  asm("MCR p15, 0, r0, c8, c5, 1");
  asm("NOP");
  asm("NOP");
#endif
#ifdef __ghs__
  invaltlb(addr);
#endif
#ifdef __arm
  UNS_32 trx;
  __asm
  {
  MOV trx, addr
  /* Invalidate I-TLB using MVA format */
  MCR p15, 0, trx, c8, c5, 1
  NOP
  NOP
  }
#endif
#ifdef __ICCARM__

  /* Invalidate I-TLB using MVA format */
  /* Use IAR intrinsic functions */
  __MCR(15, 0, (UNS_32)addr, 8, 5, 1);
  __no_operation();
  __no_operation();
#endif
  }
}

哪位大侠能帮忙分析一下这段程序,实在是不懂啊!

------解决方案--------------------------------------------------------
去嵌入式里面再问问吧
  相关解决方案