程序代码.docx
- 文档编号:25462031
- 上传时间:2023-06-09
- 格式:DOCX
- 页数:150
- 大小:56.65KB
程序代码.docx
《程序代码.docx》由会员分享,可在线阅读,更多相关《程序代码.docx(150页珍藏版)》请在冰豆网上搜索。
程序代码
;/*
;************************************************************************************************************
;*北京精仪达盛科技有限公司
;*研发部
;*
;*
;*
;*---------------------------------------------文件信息----------------------------------------------------
;*
;*文件名称:
2410INIT.S
;*文件功能:
S3C2410启动代码,配置存储器,ISR,堆栈,初始化C向量地址
;*补充说明:
;*--------------------------------------------最新版本信息-------------------------------------------------
;*修改作者:
ARM开发小组
;*修改日期:
2004/00/00
;*版本声明:
V0.1
;*--------------------------------------------历史版本信息-------------------------------------------------
;*文件作者:
kwtark(samsung)
;*创建日期:
2002/02/25
;*版本声明:
ver0.0
;2002/03/20:
purnnamu:
AddsomefunctionsfortestingSTOP,POWER_OFFmode
;2002/04/10:
SJS:
subinterruptdisable0x3ff->0x7ff
;*-----------------------------------------------------------------------------------------------------------
;*************************************************************************************************************
;*/
GET2410addr.s
GETmemcfg.s
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~
;//Checkiftasm.exe(armasm-16...@ADS1.0)isused.
GBLLTHUMBCODE
[{CONFIG}=16
THUMBCODESETL{TRUE}
CODE32
|
THUMBCODESETL{FALSE}
]
MACRO
MOV_PC_LR
[THUMBCODE
bxlr
|
movpc,lr
]
MEND
MACRO
MOVEQ_PC_LR
[THUMBCODE
bxeqlr
|
moveqpc,lr
]
MEND
MACRO
$HandlerLabelHANDLER$HandleLabel
$HandlerLabel
subsp,sp,#4;//decrementsp(tostorejumpaddress)
stmfdsp!
{r0};//PUSHtheworkregistertostack(lrdoes'tpushbecauseitreturntooriginaladdress)
ldrr0,=$HandleLabel;//loadtheaddressofHandleXXXtor0
ldrr0,[r0];//loadthecontents(serviceroutinestartaddress)ofHandleXXX
strr0,[sp,#4];//storethecontents(ISR)ofHandleXXXtostack
ldmfdsp!
{r0,pc};//POPtheworkregisterandpc(jumptoISR)
MEND
IMPORT|Image$$RO$$Limit|;//EndofROMcode(=startofROMdata)
IMPORT|Image$$RW$$Base|;//BaseofRAMtoinitialise
IMPORT|Image$$ZI$$Base|;//Baseandlimitofarea
IMPORT|Image$$ZI$$Limit|;//tozeroinitialise
IMPORTMain;//Themainentryofmonprogram
AREAInit,CODE,READONLY
ENTRY
;//1)Thecode,whichconvertstoBig-endian,shouldbeinlittleendiancode.
;//2)ThefollowinglittleendiancodewillbecompiledinBig-Endianmode.
;//Thecodebyteordershouldbechangedasthememorybuswidth.
;//3)Thepseudoinstruction,DCDcan'tbeusedherebecausethelinkergenerateserror.
ASSERT:
DEF:
ENDIAN_CHANGE
[ENDIAN_CHANGE
ASSERT:
DEF:
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
ChangeBigEndian
;//@0x24
[ENTRY_BUS_WIDTH=32
DCD0xee110f10;0xee110f10=>mrcp15,0,r0,c1,c0,0
DCD0xe3800080;0xe3800080=>orrr0,r0,#0x80;//Big-endian
DCD0xee010f10;0xee010f10=>mcrp15,0,r0,c1,c0,0
]
[ENTRY_BUS_WIDTH=16
DCD0x0f10ee11
DCD0x0080e380
DCD0x0f10ee01
]
[ENTRY_BUS_WIDTH=8
DCD0x100f11ee
DCD0x800080e3
DCD0x100f01ee
]
DCD0xffffffff;//swinv0xffffffissimilarwithNOPandrunwellinbothendianmode.
DCD0xffffffff
DCD0xffffffff
DCD0xffffffff
DCD0xffffffff
bResetHandler
;//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;//POWER_OFFmode?
bneENTER_POWER_OFF
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;//1)waituntiltheSTOPmodeisineffect.
bne%B0;//2)OrwaithereuntiltheCPU&Peripheralswillbeturned-off
;//EnteringPOWER_OFFmode,onlytheresetbywake-upisavailable.
ldrr0,=REFRESH;//exitfromSDRAMselfrefreshmode.
strr3,[r0]
MOV_PC_LR
ENTER_POWER_OFF
;//NOTE.
;//1)rGSTATUS3shouldhavethereturnaddressafterwake-upfromPOWER_OFFmode.
ldrr0,=REFRESH
ldrr1,[r0];//r1=rREFRESH
orrr1,r1,#BIT_SELFREFRESH
strr1,[r0];//EnableSDRAMself-refresh
movr1,#16;//Waituntilself-refreshisissued,whichmaynotbeneeded.
0subsr1,r1,#1
bne%B0
ldrr1,=MISCCR
ldrr0,[r1]
orrr0,r0,#(7<<17);//MakesurethatSCLK0:
SCLK->0,SCLK1:
SCLK->0,SCKE=Lduringboot-up
strr0,[r1]
ldrr0,=CLKCON
strr2,[r0]
b.;//CPUwilldiehere.
WAKEUP_POWER_OFF
;//ReleaseSCLKnafterwake-upfromthePOWER_OFFmode.
ldrr1,=MISCCR
ldrr0,[r1]
bicr0,r0,#(7<<17);//SCLK0:
0->SCLK,SCLK1:
0->SCLK,SCKE:
L->H
strr0,[r1]
;//Setmemorycontrolregisters
ldrr0,=SMRDATA
ldrr1,=BWSCON;//BWSCONAddress
addr2,r0,#52;//EndaddressofSMRDATA
0
ldrr3,[r0],#4
strr3,[r1],#4
cmpr2,r0
bne%B0
movr1,#256
0subsr1,r1,#1;//1)waituntiltheSelfRefreshisreleased.
bne%B0
ldrr1,=GSTATUS3;//GSTATUS3hasthestartaddressjustafterPOWER_OFFwake-up
ldrr0,[r1]
movpc,r0
LTORG
HandlerFIQHANDLERHandleFIQ
HandlerIRQHANDLERHandleIRQ
HandlerUndefHANDLERHandleUndef
HandlerSWIHANDLERHandleSWI
HandlerDabortHANDLERHandleDabort
HandlerPabortHANDLERHandlePabort
IsrIRQ
subsp,sp,#4;//reservedforPC
stmfdsp!
{r8-r9}
ldrr9,=INTOFFSET
ldrr9,[r9]
ldrr8,=HandleEINT0
addr8,r8,r9,lsl#2
ldrr8,[r8]
strr8,[sp,#8]
ldmfdsp!
{r8-r9,pc}
;//================================================================================================
;//ENTRY
;//=================================================================================================
ResetHandler
ldrr0,=WTCON;//watchdogdisable
ldrr1,=0x0
strr1,[r0]
ldrr0,=INTMSK
ldrr1,=0xffffffff;//allinterruptdisable
strr1,[r0]
ldrr0,=INTSUBMSK
ldrr1,=0x7ff;//allsubinterruptdisable,2002/04/10
strr1,[r0]
[{FALSE}
;//rGPFDAT=(rGPFDAT&~(0xf<<4))|((~data&0xf)<<4);
;//Led_Display
ldrr0,=GPFCON
ldrr1,=0x5500
strr1,[r0]
ldrr0,=GPFDAT
ldrr1,=0x10
strr1,[r0]
]
;//ToreducePLLlocktime,adjusttheLOCKTIMEregister.
ldrr0,=LOCKTIME
ldrr1,=0xffffff
strr1,[r0]
[PLL_ON_START
;//ConfigureMPLL
ldrr0,=MPLLCON
ldrr1,=((M_MDIV<<12)+(M_PDIV<<4)+M_SDIV);//Fin=12MHz,Fout=50MHz
strr1,[r0]
]
;//Checkifthebootiscausedbythewake-upfromPOWER_OFFmode.
ldrr1,=GSTATUS2
ldrr0,[r1]
tstr0,#0x2
;//Incaseofthewake-upfromPOWER_OFFmode,gotoPOWER_OFF_WAKEUPhandler.
bneWAKEUP_POWER_OFF
EXPORTStartPointAfterPowerOffWakeUp
StartPointAfterPowerOffWakeUp
;//Setmemorycontrolregisters
ldrr0,=SMRDATA
ldrr1,=BWSCON;//BWSCONAddress
addr2,r0,#52;//EndaddressofSMRDATA
0
ldrr3,[r0],#4
strr3,[r1],#4
cmpr2,r0
bne%B0
;//Initializestacks
blInitStacks
;//SetupIRQhandler
ldrr0,=HandleIRQ;//Thisroutineisneeded
ldrr1,=IsrIRQ;//ifthereisn't'subspc,lr,#4'at0x18,0x1c
strr1,[r0]
;//CopyandpasteRWdata/zeroinitializeddata
ldrr0,=|Image$$RO$$Limit|;//GetpointertoROMdata
ldrr1,=|Image$$RW$$Base|;//andRAMcopy
ldrr3,=|Image$$ZI$$Base|
;//Zeroinitbase=>topofinitialiseddata
cmpr0,r1;//Checkthattheyaredifferent
beq%F2
1
cmpr1,r3;//Copyinitdata
ldrccr2,[r0],#4;//-->LDRCCr2,[r0]+ADDr0,r0,#4
strccr2,[r1],#4;//-->STRCCr2,[r1]+ADDr1,r1,#4
bcc%B1
2
ldrr1,=|Image$$ZI$$Limit|;//Topofzeroinitsegment
movr2,#0
3
cmpr3,r1;Zeroinit
strccr2,[r3],#4
bcc%B3
[:
LNOT:
THUMBCODE
blMain;//Don'tusemain()because......
b.
]
[THUMBCODE;//forstart-upcodeforThumbmode
orrlr,pc,#1
bxlr
CODE16
blMain;//Don'tusemain()because......
b.
CODE32
]
;//functioninitializingstacks
InitStacks
;//Don'tuseDRAM,suchasstmfd,ldmfd......
;//SVCstackisinitializedbefore
;//Undertoolkitver2.5,'msrcpsr,r1'canbeusedinsteadof'msrcpsr_cxsf,r1'
mrsr0,cpsr
bicr0,r0,#MODEMASK
orrr1,r0,#UNDEFMODE|NOINT
msrcpsr_cxsf,r1;//UndefMode
ldrsp,=UndefStack
orrr1,r0,#ABORTMODE|NOINT
msrcpsr_cxsf,r1;//AbortMode
ldrsp,=AbortStack
orrr1,r0,#IRQMODE|NOINT
msr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 程序代码