Reset
??????? LDR???? PC, ResetAddr
??????? LDR???? PC, UndefinedAddr
??????? LDR???? PC, SWI_Addr
??????? LDR???? PC, PrefetchAddr
??????? LDR???? PC, DataAbortAddr
??????? DCD???? 0xb9205f80
??????? LDR???? PC, [PC, #-0xff0]
??????? LDR???? PC, FIQ_Addr
ResetAddr?????????? DCD???? ResetInit
UndefinedAddr?????? DCD???? Undefined
SWI_Addr??????????? DCD???? SoftwareInterrupt
PrefetchAddr??????? DCD???? PrefetchAbort
DataAbortAddr?????? DCD???? DataAbort
Nouse?????????????? DCD???? 0
IRQ_Addr??????????? DCD???? 0
FIQ_Addr??????????? DCD???? FIQ_Handler
;未定義指令
Undefined
??????? B?????? Undefined
;軟中斷
SoftwareInterrupt???
??????? B?????? SoftwareInterrupt?
;取指令中止
PrefetchAbort
??????? B?????? PrefetchAbort
;取數據中止
DataAbort
??????? B?????? DataAbort
;快速中斷
FIQ_Handler
??????? STMFD?? SP!, {R0-R3, LR}
??????? BL????? FIQ_Exception
??????? LDMFD?? SP!, {R0-R3, LR}
??????? SUBS??? PC,? LR,? #4
8: InitStack????
??????? MOV???? R0, LR
;Build the SVC stack
;設置管理模式堆棧
??????? MSR???? CPSR_c, #0xd3??
??????? LDR???? SP, StackSvc?
;Build the IRQ stack?
;設置中斷模式堆棧
??????? MSR???? CPSR_c, #0xd2
??????? LDR???? SP, StackIrq
;Build the FIQ stack
;設置快速中斷模式堆棧
??????? MSR???? CPSR_c, #0xd1
??????? LDR???? SP, StackFiq
;Build the DATAABORT stack
;設置中止模式堆棧
??????? MSR???? CPSR_c, #0xd7
??????? LDR???? SP, StackAbt
;Build the UDF stack
;設置未定義模式堆棧
??????? MSR???? CPSR_c, #0xdb
??????? LDR???? SP, StackUnd
;Build the SYS stack
;設置系統模式堆棧
??????? MSR???? CPSR_c, #0x5f????????????????? ;#0xdf
??????? LDR???? SP, =StackUsr
??????? MOV???? PC, R0
9:? BL? InitStack?????????????? ;初始化堆棧 Initialize the stack
??? BL? TargetResetIni;目標板基本初始化??????????????????????????????????????? ;跳轉到c語言入口 Jump to the entry point of C program
B?????? __main
周立功啟動代碼:
;/****************************************Copyright (c)**************************************************
;**?????????????????????????????? Guangzou ZLG-MCU Development Co.,LTD.
;**????????????????????????????????????? graduate school
;**???????????????????????????????? http://www.zlgmcu.com
;**
;**--------------File Info-------------------------------------------------------------------------------
;** File name: ???Startup.s
;** Last modified Date:? 2004-09-17
;** Last Version: ??1.0
;** Descriptions: ??The start up codes for LPC2100, including the initializing codes for the entry point of exceptions and the stacks of user tasks.
;**????Every project should have a independent copy of this file for related modifications
;**------------------------------------------------------------------------------------------------------
;** Created by: ???Chenmingji
;** Created date:?? ??2004-02-02
;** Version:????1.0
;** Descriptions: ??The original version//原著
;**
;**------------------------------------------------------------------------------------------------------
;** Modified by: ??Chenmingji
;** Modified date:??2004-09-17
;** Version:????1.01
;** Descriptions: ??Modified the bus setting to adapt for many common situations?
;**???????????????????????????? //改進了總線,可以根據這里的更改來控制總線的速率
;**------------------------------------------------------------------------------------------------------
;** Modified by: ??Chenmingji
;** Modified date:??2004-09-17
;** Version:????1.02
;** Descriptions: ??Added codes to support the enciphering of the chip
;**???????????????????????????? //增加了芯片加密
;**------------------------------------------------------------------------------------------------------
;** Modified by: ??Chenmingji
;** Modified date:??2004-09-17
;** Version:????1.04
;** Descriptions: ??Renewed the template, added codes to support more compilers?
;**???????????????????????????? //重建模板,加入更多代碼來支持更多的編譯
;**------------------------------------------------------------------------------------------------------
;** Modified by: ??
;** Modified date:
;** Version:?
;** Descriptions:?
;**
;********************************************************************************************************/
;define the stack size
;定義堆棧的大小
SVC_STACK_LEGTH???????? EQU???????? 0
FIQ_STACK_LEGTH???????? EQU???????? 0
IRQ_STACK_LEGTH???????? EQU???????? 256
ABT_STACK_LEGTH???????? EQU???????? 0
UND_STACK_LEGTH???????? EQU???????? 0
NoInt?????? EQU 0x80
;定義處理器模式,用戶/管理/系統/中斷
USR32Mode?? EQU 0x10
SVC32Mode?? EQU 0x13
SYS32Mode?? EQU 0x1f
IRQ32Mode?? EQU 0x12
FIQ32Mode?? EQU 0x11
PINSEL2???? EQU 0xE002C014//定義PINSEL2地址,這個地址的值一般用戶不需要改變,和芯片的加密有關
??????????????????????????? //更改后有可能使得JTAG調試失效,進入芯片加密狀態.
BCFG0?????? EQU 0xFFE00000
BCFG1?????? EQU 0xFFE00004
BCFG2?????? EQU 0xFFE00008
BCFG3?????? EQU 0xFFE0000C//定義存儲器組配置寄存器
BCFG_16DEF?EQU???? 0x10000400????? ;// 16Bit Bus
BCFG_CS3??? EQU??(BCFG_16DEF | (0x01<<00) | (0x07<<05) | (0x07<<11))?? ;// 分別是IDCY/WST1/WST2對應讀寫速率等
????????????????????????????????? ;//從第0位開始對其寫入0001,
?????????????????????????????????????????????? ;//從第5位開始寫入0111
???????????????????????????????????????????????????????????? ;//從11位開始寫入0111(0x07)/11111(0x1f)?
??? IMPORT __use_no_semihosting_swi
;The imported labels
;引入的外部標號在這聲明
??? IMPORT? FIQ_Exception?????????????????? ;Fast interrupt exceptions handler 快速中斷異常處理程序
??? IMPORT? __main????????????????????????? ;The entry point to the main function C語言主程序入口?
??? IMPORT? TargetResetInit???????????????? ;initialize the target board 目標板基本初始化
;The emported labels
;給外部使用的標號在這聲明
??? EXPORT? bottom_of_heap
??? EXPORT? StackUsr
????
??? EXPORT? Reset
??? EXPORT __user_initial_stackheap
??? CODE32
??? AREA??? vectors,CODE,READONLY
??????? ENTRY
;interrupt vectors
;中斷向量表
Reset
??????? LDR???? PC, ResetAddr
??????? LDR???? PC, UndefinedAddr
??????? LDR???? PC, SWI_Addr
??????? LDR???? PC, PrefetchAddr
??????? LDR???? PC, DataAbortAddr
??????? DCD???? 0xb9205f80
??????? LDR???? PC, [PC, #-0xff0]
??????? LDR???? PC, FIQ_Addr
ResetAddr?????????? DCD???? ResetInit
UndefinedAddr?????? DCD???? Undefined
SWI_Addr??????????? DCD???? SoftwareInterrupt
PrefetchAddr??????? DCD???? PrefetchAbort
DataAbortAddr?????? DCD???? DataAbort
Nouse?????????????? DCD???? 0
IRQ_Addr??????????? DCD???? 0
FIQ_Addr??????????? DCD???? FIQ_Handler
;未定義指令
Undefined
??????? B?????? Undefined
;軟中斷
SoftwareInterrupt???
??????? B?????? SoftwareInterrupt?
;取指令中止
PrefetchAbort
??????? B?????? PrefetchAbort
;取數據中止
DataAbort
??????? B?????? DataAbort
;快速中斷
FIQ_Handler
??????? STMFD?? SP!, {R0-R3, LR}
??????? BL????? FIQ_Exception
??????? LDMFD?? SP!, {R0-R3, LR}
??????? SUBS??? PC,? LR,? #4
????????
;/*********************************************************************************************************
;** unction name ?函數名稱: ?InitStack
;** Descriptions ?功能描述: ?Initialize the stacks? 初始化堆棧
;** input parameters ?輸 入:?? ?None 無
;** Returned value?? ?輸 出 :? ?None 無
;** Used global variables 全局變量: ?None 無
;** Calling modules ?調用模塊: ?None 無
;**?
;** Created by ??作 者: ?Chenmingji 陳明計
;** Created Date ?日 期: ?2004/02/02 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by ?修 改:?
;** Modified date ?日 期:?
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
InitStack????
??????? MOV???? R0, LR
;Build the SVC stack
;設置管理模式堆棧
??????? MSR???? CPSR_c, #0xd3??
??????? LDR???? SP, StackSvc?
;Build the IRQ stack?
;設置中斷模式堆棧
??????? MSR???? CPSR_c, #0xd2
??????? LDR???? SP, StackIrq
;Build the FIQ stack
;設置快速中斷模式堆棧
??????? MSR???? CPSR_c, #0xd1
??????? LDR???? SP, StackFiq
;Build the DATAABORT stack
;設置中止模式堆棧
??????? MSR???? CPSR_c, #0xd7
??????? LDR???? SP, StackAbt
;Build the UDF stack
;設置未定義模式堆棧
??????? MSR???? CPSR_c, #0xdb
??????? LDR???? SP, StackUnd
;Build the SYS stack
;設置系統模式堆棧
??????? MSR???? CPSR_c, #0x5f????????????????? ;#0xdf
??????? LDR???? SP, =StackUsr
??????? MOV???? PC, R0
;/*********************************************************************************************************
;** unction name ?函數名稱: ?ResetInit
;** Descriptions ?功能描述: ?RESET? 復位入口
;** input parameters ?輸 入:?? ?None 無
;** Returned value?? ?輸 出 :? ?None 無
;** Used global variables 全局變量: ?None 無
;** Calling modules ?調用模塊: ?None 無
;**?
;** Created by ??作 者: ?Chenmingji 陳明計
;** Created Date ?日 期: ?2004/02/02 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by ?修 改: Chenmingji 陳明計
;** Modified date ?日 期: 2004/02/02 2004年3月3日
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
ResetInit
;初始化外部總線控制器,根據目標板決定配置
;
;?????????? LDR???? R0, =PINSEL2
;?? IF :DEF: EN_CRP
;??????? LDR???? R1, =0x0f814910
;??? ELSE
;??????? LDR???? R1, =0x0f814914
;??? ENDIF
;??????? STR???? R1, [R0]
??????? LDR???? R0, =BCFG0
??????? LDR???? R1, =0x1000ffef?????????? ;0x00001046
??????? STR???? R1, [R0]
??????? LDR???? R0, =BCFG1
??????? LDR???? R1, =BCFG_CS3?????????????? ;0x1000ffef????????? ;0x1000ffef;;
??????? STR???? R1, [R0]
??????? LDR???? R0, =BCFG2
??????? LDR???? R1, =0x2000ffef
??????? STR???? R1, [R0]
;??????? LDR???? R0, =BCFG3
;??????? LDR???? R1, =0x00000CA0?????????? ;0x2000ffef
;??????? STR???? R1, [R0]
???????????????
??????? BL????? InitStack?????????????? ;初始化堆棧 Initialize the stack
??????? BL????? TargetResetInit???????? ;目標板基本初始化 Initialize the target board
??????????????????????????????????????? ;跳轉到c語言入口 Jump to the entry point of C program
??????
??????? B?????? __main
;/*********************************************************************************************************
;** unction name ?函數名稱: ?__user_initial_stackheap
;** Descriptions ?功能描述: ?Initial the function library stacks and heaps, can not deleted!?? 庫函數初始化堆和棧,不能刪除
;** input parameters ?輸 入:?? ?reference by function library 參考庫函數手冊
;** Returned value?? ?輸 出 :? ?reference by function library 參考庫函數手冊
;** Used global variables 全局變量: ?None 無
;** Calling modules ?調用模塊: ?None 無
;**?
;** Created by ??作 者: ?Chenmingji 陳明計
;** Created Date ?日 期: ?2004/02/02 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by ?
;** Modified date ?
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
__user_initial_stackheap????
??? LDR?? r0,=bottom_of_heap
;??? LDR?? r1,=StackUsr
??? MOV?? pc,lr
StackSvc?????????? DCD???? SvcStackSpace + (SVC_STACK_LEGTH - 1)* 4
StackIrq?????????? DCD???? IrqStackSpace + (IRQ_STACK_LEGTH - 1)* 4
StackFiq?????????? DCD???? FiqStackSpace + (FIQ_STACK_LEGTH - 1)* 4
StackAbt?????????? DCD???? AbtStackSpace + (ABT_STACK_LEGTH - 1)* 4
StackUnd?????????? DCD???? UndtStackSpace + (UND_STACK_LEGTH - 1)* 4
;/*********************************************************************************************************
;** unction name ?函數名稱: ?CrpData
;** Descriptions ?功能描述: ?encrypt the chip
;** input parameters ?輸 入:?? ?None 無
;** Returned value?? ?輸 出 :? ?None 無
;** Used global variables 全局變量: ?None 無
;** Calling modules ?調用模塊: ?None 無
;**?
;** Created by ??作 者: ?Chenmingji 陳明計
;** Created Date ?日 期: ?2004/03/27 2004年3月27日
;**-------------------------------------------------------------------------------------------------------
;** Modified by ?修 改:?
;** Modified date ?日 期:?
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
??? IF :DEF: EN_CRP
??????? IF? . >= 0x1fc
??????? INFO??? 1," The data at 0x000001fc must be 0x87654321. Please delete some source before this line."
??????? ENDIF
CrpData
??? WHILE . < 0x1fc
??? NOP
??? WEND
CrpData1
??? DCD???? 0x87654321????????? ;/*When the Data is 為0x87654321,user code be protected. 當此數為0x87654321時,用戶程序被保護 */
??? ENDIF
????
;/* 分配堆棧空間 */
??????? AREA??? MyStacks, DATA, NOINIT, ALIGN=2
SvcStackSpace????? SPACE?? SVC_STACK_LEGTH * 4? ;Stack spaces for Administration Mode 管理模式堆棧空間
IrqStackSpace????? SPACE?? IRQ_STACK_LEGTH * 4? ;Stack spaces for Interrupt ReQuest Mode 中斷模式堆棧空間
FiqStackSpace????? SPACE?? FIQ_STACK_LEGTH * 4? ;Stack spaces for Fast Interrupt reQuest Mode 快速中斷模式堆棧空間
AbtStackSpace????? SPACE?? ABT_STACK_LEGTH * 4? ;Stack spaces for Suspend Mode 中止義模式堆棧空間
UndtStackSpace???? SPACE?? UND_STACK_LEGTH * 4? ;Stack spaces for Undefined Mode 未定義模式堆棧
??????? AREA??? Heap, DATA, NOINIT
bottom_of_heap??? SPACE?? 1
??????? AREA??? Stacks, DATA, NOINIT
StackUsr
??? END
;/*********************************************************************************************************
;**??????????????????????????? End Of File
;***************************************************************************************************
評論
查看更多