📄 startup.s
字号:
;/****************************************Copyright (c)**************************************************
;** zhuhai creawor Development Co.,LTD.
;** graduate school
;** http://www.creawor.com
;**
;**-------------------------------------------File Info-----------------------------------------
;** File name: Startup.s
;** Last modified Date: 2004-09-17
;** Last Version: 1.0
;** Descriptions: The start up codes for LPC2200, 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
;**------------------------------------------------------------------------------------------------------
;** 31 30 29 28 7 6 5 4 3 2 1 0
;**+---+---+---+---+--ss--+---+---+---+---+---+---+---+---+
;**| N | Z | C | V | | I | F | T |M4 |M3 |M2 |M1 |M0 |
;**+---+---+---+---+--ss--+---+---+---+---+---+---+---+---+
;** 如 I = 0,允许IRQ中断;“1”禁止中断
;********************************************************************************************************/
;/********************************************************************************************************
;** define the stack size 定义堆栈的大小
;********************************************************************************************************/
SVC_STACK_LEGTH EQU 0
FIQ_STACK_LEGTH EQU 0 ;// 快速中断堆栈设置为零
IRQ_STACK_LEGTH EQU 9*8 ;// every layer need 9 bytes stack , permit 8 layer .
;// 每层嵌套需要9个字堆栈,允许8层嵌套
ABT_STACK_LEGTH EQU 0 ;// 取数据中止堆栈设置为“0”
UND_STACK_LEGTH EQU 0 ;// 未定义堆栈设置为“0”
;/*******************************************************************************************************
;** define the mode 定义各种模式及存储器组
;*******************************************************************************************************/
NoInt EQU 0x80 ;// 定义关闭所有中断
USR32Mode EQU 0x10 ;// 用户模式 b'0001_0000
SVC32Mode EQU 0x13 ;// 管理模式 b'0001_0011
SYS32Mode EQU 0x1f ;// 系统模式 b'0001_1111
IRQ32Mode EQU 0x12 ;// 中断模式 b'0001_0010
FIQ32Mode EQU 0x11 ;// 快速中断 b'0001_0001
IRQ_FIQ_EN EQU 0XCF
PINSEL2 EQU 0xE002C014 ;// 定义管脚功能寄存器
BCFG0 EQU 0xFFE00000 ;// 定义存储器组0 配置寄存器
BCFG1 EQU 0xFFE00004 ;// 定义存储器组1 配置寄存器
BCFG2 EQU 0xFFE00008 ;// 定义存储器组2 配置寄存器
BCFG3 EQU 0xFFE0000C ;// 定义存储器组3 配置寄存器
;/*******************************************************************************************************
;** The imported labels 引入的外部标号在这声明
;*******************************************************************************************************/
IMPORT __use_no_semihosting_swi ;// 引入外部标号在这声明(外部函数)
IMPORT __use_two_region_memory
IMPORT FIQ_Exception ;// Fast interrupt exceptions handler 快速中断异常处理程序入口
IMPORT __main ;// The entry point to the main function C语言主程序入口
IMPORT TargetResetInit ;// initialize the target board 目标板基本初始化
;//IMPORT SoftwareInterrupt ;// Software interrupt exceptions handler 软件中断异常处理程序入
;/*******************************************************************************************************
;** The emported labels 给外部使用的标号在这里声明
;*******************************************************************************************************/
EXPORT bottom_of_heap
EXPORT bottom_of_Stacks
EXPORT top_of_heap
EXPORT StackUsr
EXPORT Reset
EXPORT __user_initial_stackheap
;/*******************************************************************************************************
;** interrupt vectors 中断向量表
;*******************************************************************************************************/
AREA vectors,CODE,READONLY ;// 异常向量处理程序
ENTRY
CODE32
Reset
LDR PC, ResetAddr ;// 指令机器码 0XE59FF018
LDR PC, UndefinedAddr ;// 指令机器码 0XE59FF018
;LDR PC, SWI_Addr ;// 指令机器码 0XE59FF018
LDR PC, PrefetchAddr ;// 指令机器码 0XE59FF018
LDR PC, DataAbortAddr ;// 指令机器码 0XE59FF018
DCD 0xb9205f80 ;// 其指令机器码值是向量表所有的指令机器码相加取反后所得:0XB9205F80
LDR PC, [PC, #-0xff0] ;// 指令机器码 0XE51FFFF0
LDR PC, FIQ_Addr ;// 指令机器码 0XE59FF018
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
; BL ResetInit
B Undefined
;/*******************************************************************************************************
;** 取指令中止
;*******************************************************************************************************/
PrefetchAbort
; BL ResetInit
B PrefetchAbort
;/*******************************************************************************************************
;** 取数据中止
;*******************************************************************************************************/
DataAbort
; BL ResetInit
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 作 者:
;** Created Date 日 期:
;********************************************************************************************************/
InitStack ;// 初始化堆栈
MOV R0, LR
;//Build the SVC stack 设置管理模式堆栈
MSR CPSR_c, #0xd3
LDR SP, = StackSvc
;// Build the Irq stack 设置中断模式堆栈
MSR CPSR_c, #0xd2 ;// 装入中断模式值,先关中断
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -