bootloader代码分析报告

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Bootloader代码分析报告徐凯2007-8-3Bootloader代码分析报告.............................................................................................................11.启动代码分析...................................................................................................................11.1.vector.s代码分析..................................................................................................11.1.1.宏定义...............................................................................................................51.1.3.判断是否是thumb指令...................................................................................61.1.4.定义新程序、引入新符号...............................................................................61.1.5.定义新程序、引入新符号...............................................................................71.1.6.定义系统异常向量表.......................................................................................71.1.7.程序跳转宏定义...............................................................................................71.1.8.异常处理程序定义...........................................................................................71.1.9.声明C主函数程序入口.................................................................................101.1.10.定义vector.s中需要用到的连接器变量.................................................101.1.11.定义从FLASH启动程序的函数...................................................................111.2.sysinit.s代码分析..............................................................................................111.2.1.引入S3C4510相关系统配置寄存器的地址.................................................181.2.2.定义用于配置ROM和RAM的宏.....................................................................181.2.3.定义用于配置SYSCFG的宏...........................................................................181.2.4.定义用于初始化内存的函数InitMemory....................................................181.2.5.定义用于初始化内存的函数InitMemory....................................................201.2.6.定义内存重设置函数ResetMemSet..............................................................211.2.7.初始化21种中断源响应函数InitInterrupt............................................211.2.8.初始化18个外部I/O端口函数InitPort..................................................211.2.9.初始化2个计时器的函数InitTimer..........................................................221.2.10.初始化2个串口函数InitUart..................................................................221.2.11.初始化栈函数InitStack............................................................................231.2.12.系统初始化函数InitSystem......................................................................2411.启动代码分析1.1.vector.s代码分析由于连接器参数中有-firstvector.o,所以先从这个文件开始分析。首先,列出源代码:1ModeMaskEQU0x1F2SVC32ModeEQU0x133IRQ32ModeEQU0x124FIQ32ModeEQU0x115User32ModeEQU0x106Abort32ModeEQU0x177Undef32ModeEQU0x1B8IRQ_BITEQU0x809FIQ_BITEQU0x4010;RomBaseAddrEQU011RamBaseAddrEQU&10012;RamEndAddrEQU&20013GBLSMainEntry14MainEntrySETSmain15IMPORT$MainEntry16;**********************************************************17;シ・鯡ヌキケモテtasm.exeスミア默・18GBLLTHUMBCODE19[{CONFIG}=1620THUMBCODESETL{TRUE}21CODE3222|23THUMBCODESETL{FALSE}24]2526[THUMBCODE27CODE32;forstart-upcodeforThumbmode28]2930;******************************************************31AREASelfBoot,CODE,READONLY3233IMPORTUDF_INS_VECTOR34IMPORTSWI_SVC_VECTOR35IMPORTINS_ABT_VECTOR36IMPORTDAT_ABT_VECTOR237IMPORTIRQ_SVC_VECTOR38IMPORTFIQ_SVC_VECTOR3940ENTRY41IF:DEF:|ads$version|42ELSE43EXPORT__main44__main45ENDIF46ResetEntry47bSYS_RST_HANDLER48bUDF_INS_HANDLER49bSWI_SVC_HANDLER50bINS_ABT_HANDLER51bDAT_ABT_HANDLER52b.53bIRQ_SVC_HANDLER54bFIQ_SVC_HANDLER5556;******************************************************57MACRO58$LabelHANDLER$Vector59$Label60sublr,lr,#461stmfdsp!,{r0-r3,lr}62ldrr0,=$Vector63ldrpc,[r0]64ldmfdsp!,{r0-r3,pc}^65MEND6667UDF_INS_HANDLER68stmfdsp!,{r0-r3,lr}69ldrr0,=UDF_INS_VECTOR70movlr,pc71ldrpc,[r0]72ldmfdsp!,{r0-r3,pc}^73SWI_SVC_HANDLER74stmfdsp!,{r0-r3,lr}75ldrr0,=SWI_SVC_VECTOR76movlr,pc77ldrpc,[r0]78ldmfdsp!,{r0-r3,pc}^79INS_ABT_HANDLER80sublr,lr,#4381stmfdsp!,{r0-r3,lr}82ldrr0,=INS_ABT_VECTOR83movlr,pc84ldrpc,[r0]85ldmfdsp!,{r0-r3,pc}^86DAT_ABT_HANDLER87sublr,lr,#488stmfdsp!,{r0-r3,lr}89ldrr0,=DAT_ABT_VECTOR90movlr,pc91ldrpc,[r0]92ldmfdsp!,{r0-r3,pc}^93IRQ_SVC_HANDLER94sublr,lr,#495stmfdsp!,{r0-r12,lr}96mrsr0,spsr97stmfdsp!,{r0}98ldrr0,=IRQ_SVC_VECTOR99ldrpc,[r0]100FIQ_SVC_HANDLER101sublr,lr,#4102stmfdsp!,{r0-r12,lr}103mrsr0,spsr104stmfdsp!,{r0}105ldrr0,=IRQ_SVC_VECTOR106ldrpc,[r0]107108;*******************************************************109SYS_RST_HANDLER110mrsr0,cpsr;entersvcmodeanddisableirq,fiq111bicr0,r0,#ModeMask112orrr0,r0,#(SVC32Mode:OR:IRQ_BIT:OR:FIQ_BIT)113msrcpsr_c,r0114115IMPORTInitSystem116blInitSystem117118adrr0,ResetEntry119movr3,#(RamBaseAddr16)120ldrr1,BaseOfROM121ldrr2,TopOfROM122addr1,r1,r3123addr2,r2,r312404125ldmiar0!,{r4-r11}126stmiar1!,{r4-r11}127cmpr1,r2128bcc%B0129130subr1,r1,r2131subr0,r0,r1132ldrr1,BaseOfBSS133ldrr2,BaseOfZero134addr1,r1,r3135addr2,r2,r31361137cmpr1,r2138ldrccr4,[r0],#4139strccr4,[r1],#4140bcc%B114114

1 / 25
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功