网站公告列表

  没有公告

加入收藏
设为首页
联系本站
您现在的位置: AnalogCN安诺电子 >> 文章 >> 技术交流 >> 文章正文
  U-boot-1.1.6-2008R1到vdsp5(bf561)的移植记录(10):__xchg           ★★★ 【字体:
U-boot-1.1.6-2008R1到vdsp5(bf561)的移植记录(10):__xchg
作者:快乐虾    文章来源:http://blog.csdn.net/lights_joy    点击数:    更新时间:2008-4-21    
在u-boot-1.1.6-2008R1\include\asm\system.h中有这样一个函数:
static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
                      int size)
{
     unsigned long tmp = 0;
     unsigned long flags = 0;
 
     local_irq_save(flags);
 
     switch (size) {
     case 1:
         __asm__ __volatile__
              ("%0 = b%2 (z);\n\t"
               "b%2 = %1;\n\t"
               : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
         break;
     case 2:
         __asm__ __volatile__
              ("%0 = w%2 (z);\n\t"
               "w%2 = %1;\n\t"
               : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
         break;
     case 4:
         __asm__ __volatile__
              ("%0 = %2;\n\t"
               "%2 = %1;\n\t"
               : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
         break;
     }
     local_irq_restore(flags);
     return tmp;
}
这个函数使用了内嵌汇编,移植时有几个问题:
1、%0=b%2(z),类似这样的语句,在VDSP下一解释就变成了
r0 = bp0(r0和p0的使用可能与实际值不同)
当然是明显的语法错误,所以应该修改为
%0 = b[%2] (z)
2、”m”,在VDSP中不支持”m”,由于此处需要使用P指针,所以相应地改为”a”或者”p”。
3、(*__xg(ptr))直接用(ptr)就OK了。
这样,经过修改后的函数就成了:
static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
                      int size)
{
     unsigned long tmp = 0;
     unsigned long flags = 0;
 
     local_irq_save(flags);
 
     switch (size) {
     case 1:
         __asm__ __volatile__
              ("%0 = b[%2] (z);\n\t"
               "b[%2] = %1;\n\t"
               : "=&d" (tmp) : "d" (x), "a" (ptr) : "memory");
         break;
     case 2:
         __asm__ __volatile__
              ("%0 = w[%2] (z);\n\t"
              "w[%2] = %1;\n\t"
               : "=&d" (tmp) : "d" (x), "a" (ptr) : "memory");
         break;
     case 4:
         __asm__ __volatile__
              ("%0 = %2;\n\t"
               "%2 = %1;\n\t"
               : "=&d" (tmp) : "d" (x), "a" (ptr) : "memory");
         break;
     }
     local_irq_restore(flags);
     return tmp;
}
不过经过这样修改之后,VDSP会给出一个警告:
[Warning ea5506] "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\acc0ab0f1fc000\acc0ab0f1fc001.s":124 Memory load instruction use may trigger hardware anomaly 05-00-0227. See appropriate Blackfin anomaly lists for more information.
查了一下anomaly 05-00-0227,是这样解释的
Enables workaround for anomaly 05-00-0257: “An interrupt or exception during short hardware loops may cause the instruction fetch unit to malfunction.” When enabled, the compiler saves and restores LC0 and LC1 in interrupt handlers.
The compiler defines the macro __WORKAROUND_SHORT_LOOP_EXCEPTIONS_257 at the compile, assembly, and link build stages when this workaround is enabled.
暂时还不太明白这其中的意思,不过比较了一下gcc生成的代码和VDSP生成的代码,两者是一样的,所以暂时搁置一下这个问题。
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    前置放大器在移动医疗服务系
    便携式多通道大容量生理信号
    防腐监测仪的设计与应用
    基于AD1674的酶标仪的设计
    基于C/S模式的JRTPLIB库的测
    ffmpeg与jrtplib相结合应用
    blackfin模拟摄像头驱动中的
    可编程逻辑在数字信号处理系
    发现VDSP4.5一个BUG:单步调
    VDSP5.0双核工程下sml3中的变
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    版权所有:AnalogCN安诺电子 湘ICP备06016315号