你好,游客 登录 注册 搜索
背景:
阅读新闻

深入分析S3C2440启动代码中大小端问题

[日期:2012-02-18] 来源:Linux社区  作者:ce123 [字体:大 中 小]

二、S3C2440启动代码中与大小管相关的代码

Option.inc中相关代码
[plain]
  1. GBLL ENDIAN_CHANGE  
  2. ENDIAN_CHANGE<span style="white-space:pre">   </span>SETL<span style="white-space:pre">   </span>{TRUE}  
  3.   
  4.   
  5. GBLA ENTRY_BUS_WIDTH  
  6. ENTRY_BUS_WIDTH SETA 16  
2440init.s中相关代码
[plain]
  1.     AREA    Init,CODE,READONLY  
  2.   
  3.     ENTRY  
  4.       
  5.     EXPORT  __ENTRY  
  6. __ENTRY  
  7. ResetEntry  
  8.     ;1)The code, which converts to Big-endian, should be in little endian code.  
  9.     ;2)The following little endian code will be compiled in Big-Endian mode.  
  10.     ;  The code byte order should be changed as the memory bus width.  
  11.     ;3)The pseudo instruction,DCD can not be used here because the linker generates error.  
  12.     ASSERT  :DEF:ENDIAN_CHANGE  
  13.     [ ENDIAN_CHANGE  
  14.         ASSERT  :DEF:ENTRY_BUS_WIDTH  
  15.         [ ENTRY_BUS_WIDTH=32  
  16.             b   ChangeBigEndian     ;DCD 0xea000007  
  17.         ]  
  18.   
  19.         [ ENTRY_BUS_WIDTH=16  
  20.             andeq   r14,r7,r0,lsl #20   ;DCD 0x0007ea00  
  21.         ]  
  22.   
  23.         [ ENTRY_BUS_WIDTH=8  
  24.             streq   r0,[r0,-r10,ror #1] ;DCD 0x070000ea  
  25.         ]  
  26.         |  
  27.         b   ResetHandler  
  28.     ]  
  29.     b   HandlerUndef    ;handler for Undefined mode  
  30.     b   HandlerSWI  ;handler for SWI interrupt  
  31.     b   HandlerPabort   ;handler for PAbort  
  32.     b   HandlerDabort   ;handler for DAbort  
  33.     b   .       ;reserved  
  34.     b   HandlerIRQ  ;handler for IRQ interrupt  
  35.     b   HandlerFIQ  ;handler for FIQ interrupt  
  36.   
  37. ;@0x20  
  38.     b   EnterPWDN   ; Must be @0x20.  
  39. ChangeBigEndian  
  40. ;@0x24  
  41.     [ ENTRY_BUS_WIDTH=32  
  42.         DCD 0xee110f10  ;0xee110f10 => mrc p15,0,r0,c1,c0,0  
  43.         DCD 0xe3800080  ;0xe3800080 => orr r0,r0,#0x80;  //Big-endian  
  44.         DCD 0xee010f10  ;0xee010f10 => mcr p15,0,r0,c1,c0,0  
  45.     ]  
  46.     [ ENTRY_BUS_WIDTH=16  
  47.         DCD 0x0f10ee11  
  48.         DCD 0x0080e380  
  49.         DCD 0x0f10ee01  
  50.     ]  
  51.     [ ENTRY_BUS_WIDTH=8  
  52.         DCD 0x100f11ee  
  53.         DCD 0x800080e3  
  54.         DCD 0x100f01ee  
  55.     ]  
  56.     DCD 0xffffffff  ;swinv 0xffffff is similar with NOP and run well in both endian mode.  
  57.     DCD 0xffffffff  
  58.     DCD 0xffffffff  
  59.     DCD 0xffffffff  
  60.     DCD 0xffffffff  
  61.     b ResetHandler  
我们可以看到,在Option.inc将ENDIAN_CHANGE设置FALSE,程序将直接运行b ResetHandler,S3C2440默认是处于小端模式,ADS1.2中的设置默认也是小段模式,一切风平浪静。
linux
相关资讯       S3C2440 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款