ADSArm2440启动代码分析文档格式.docx
《ADSArm2440启动代码分析文档格式.docx》由会员分享,可在线阅读,更多相关《ADSArm2440启动代码分析文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
importheadfile
GEToption.inc
GETmemcfg.inc
GET2440addr.inc
BIT_SELFREFRESHEQU(1<
<
22
配置模式
Pre-definedconstants
USERMODEEQU0x10
FIQMODEEQU0x11
IRQMODEEQU0x12
系统监控模式
SVCMODEEQU0x13
ABORTMODEEQU0x17
UNDEFMODEEQU0x1b
模式屏蔽寄存器
MODEMASKEQU0x1f
NOINTEQU0xc0
堆栈的定义大小及地址
Thelocationofstacks
UserStackEQU(_STACK_BASEADDRESS-0x3800;
0x33ff4800~
SVCStackEQU(_STACK_BASEADDRESS-0x2800;
0x33ff5800~
UndefStackEQU(_STACK_BASEADDRESS-0x2400;
0x33ff5c00~
AbortStackEQU(_STACK_BASEADDRESS-0x2000;
0x33ff6000~
IRQStackEQU(_STACK_BASEADDRESS-0x1000;
0x33ff7000~
FIQStackEQU(_STACK_BASEADDRESS-0x0;
0x33ff8000~
检测是工作在thumb状态下还是arm状态下;
Checkiftasm.exe(armasm-16...@ADS1.0isused.
GBLLTHUMBCODE
[{CONFIG}=16
THUMBCODESETL{TRUE}
CODE32
|
THUMBCODESETL{FALSE}
]
MACRO
MOV_PC_LR
[THUMBCODE
bxlr
movpc,lr
MEND
MOVEQ_PC_LR
bxeqlr
moveqpc,lr
$HandlerLabelHANDLER$HandleLabel;
宏定义的调用方式
$HandlerLabel
subsp,sp,#4;
decrementsp(tostorejumpaddress
stmfdsp!
{r0};
PUSHtheworkregistertostack(lrdoes'
tpushbecauseitreturntooriginaladdress
ldrr0,=$HandleLabel;
loadtheaddressofHandleXXXtor0
ldrr0,[r0];
loadthecontents(serviceroutinestartaddressofHandleXXX
strr0,[sp,#4];
storethecontents(ISRofHandleXXXtostackldmfdsp!
{r0,pc};
POPtheworkregisterandpc(jumptoISR
MEND;
宏定义的结束
------------------------------------------------------------------;
外部定义的函数和变量的声明
IMPORT|Image$$RO$$Limit|;
EndofROMcode(=startofROMdataIMPORT|Image$$RW$$Base|;
BaseofRAMtoinitialise
IMPORT|Image$$ZI$$Base|;
Baseandlimitofarea
IMPORT|Image$$ZI$$Limit|;
tozeroinitialise
IMPORTMain
代码段的入口
AREAInit,CODE,READONLY
ENTRY
1Thecode,whichconvertstoBig-endian,shouldbeinlittleendiancode.;
2ThefollowinglittleendiancodewillbecompiledinBig-Endianmode.;
Thecodebyteordershouldbechangedasthememorybuswidth.
3Thepseudoinstruction,DCDcan'
tbeusedherebecausethelinkergenerateserror.
ASSERT:
DEF:
ENDIAN_CHANGE
[ENDIAN_CHANGE
ENTRY_BUS_WIDTH
[ENTRY_BUS_WIDTH=32
bChangeBigEndian;
DCD0xea000007
[ENTRY_BUS_WIDTH=16
andeqr14,r7,r0,lsl#20;
DCD0x0007ea00
[ENTRY_BUS_WIDTH=8
streqr0,[r0,-r10,ror#1];
DCD0x070000ea
bResetHandler
bHandlerUndef;
handlerforUndefinedmode
bHandlerSWI;
handlerforSWIinterrupt
bHandlerPabort;
handlerforPAbort
bHandlerDabort;
handlerforDAbort
b.;
reserved
bHandlerIRQ;
handlerforIRQinterrupt
bHandlerFIQ;
handlerforFIQinterrupt
@0x20
bEnterPWDN;
Mustbe@0x20.
ChangeBigEndian
@0x24
DCD0xee110f10;
0xee110f10=>
mrcp15,0,r0,c1,c0,0
DCD0xe3800080;
0xe3800080=>
orrr0,r0,#0x80;
//Big-endian
DCD0xee010f10;
0xee010f10=>
mcrp15,0,r0,c1,c0,0
DCD0x0f10ee11
DCD0x0080e380
DCD0x0f10ee01
DCD0x100f11ee
DCD0x800080e3
DCD0x100f01ee
DCD0xffffffff;
swinv0xffffffissimilarwithNOPandrunwellinbothendianmode.
DCD0xffffffff
Functionforenteringpowerdownmode
1.SDRAMshouldbeinself-refreshmode.
2.AllinterruptshouldbemakskedforSDRAM/DRAMself-refresh.;
3.LCDcontrollershouldbedisabledforSDRAM/DRAMself-refresh.;
4.TheI-cachemayhavetobeturnedon.
5.Thelocationofthefollowingcodemayhavenottobechanged.;
voidEnterPWDN(intCLKCON;
EnterPWDN
movr2,r0;
r2=rCLKCON
tstr0,#0x8;
SLEEPmode?
bneENTER_SLEEP
ENTER_STOP
ldrr0,=REFRESH
ldrr3,[r0];
r3=rREFRESH
movr1,r3
orrr1,r1,#BIT_SELFREFRESH
strr1,[r0];
EnableSDRAMself-refresh
movr1,#16;
waituntilself-refreshisissued.maynotbeneeded.0subsr1,r1,#1
bne%B0
ldrr0,=CLKCON;
enterSTOPmode.
strr2,[r0]
movr1,#32
0subsr1,r1,#1;
1waituntiltheSTOPmodeisineffect.
bne%B0;
2OrwaithereuntiltheCPU&
Peripheralswillbeturned-off;
EnteringSLEEPmode,onlytheresetbywake-upisavailable.ldrr0,=REFRESH;
exitfromSDRAMselfrefreshmode.
strr3,[r0]
ENTER_SLEEP
NOTE.
1rGSTATUS3shouldhavethereturnaddressafterwake-upfromSLEEPmode.
ldrr1,[r0];
r1=rREFRESH
Waituntilself-refreshisissued,whichmaynotbeneeded.0subsr1,r1,#1
ldrr1,=MISCCR
ldrr0,[r1]
orrr0,r0,#(7<
17;
SetSCLK0=0,SCLK1=0,SCKE=0.
strr0,[r1]
ldr