📄 startup.s
字号:
;/****************************************Copyright (c)**************************************************
;** Guangzou ZLG-MCU Development Co.,LTD.
;** graduate school
;** http://www.zlgmcu.com
;**
;**--------------File Info-------------------------------------------------------------------------------
;** File name: Startup.s
;** Last modified Date: 2005-11-14
;** 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
;**------------------------------------------------------------------------------------------------------
;** Created by: Chenmingji
;** Created date: 2005-11-14
;** Version: 1.0
;** Descriptions: The original version
;**
;** Modified by:
;** Modified date:
;** Version:
;** Descriptions:
;**
;********************************************************************************************************/
;define the stack size
;定义堆栈的大小
SVC_STACK_LEGTH EQU 0
FIQ_STACK_LEGTH EQU 0
IRQ_STACK_LEGTH EQU 9*8
NoInt EQU 0x80
;// Add by Ganda
NoFIQ EQU 0x40
;// 2005/06/15
USR32Mode EQU 0x10
SVC32Mode EQU 0x13
SYS32Mode EQU 0x1f
IRQ32Mode EQU 0x12
FIQ32Mode EQU 0x11
PINSEL2 EQU 0xE002C014
;/* Define the Bus Speed */
BCFG0 EQU 0xFFE00000 ;// Control Word of BANK0 / CS0
BCFG1 EQU 0xFFE00004 ;// Control Word of BANK1 / CS1
BCFG2 EQU 0xFFE00008 ;// Control Word of BANK2 / CS2
BCFG3 EQU 0xFFE0000C ;// Control Word of BANK3 / CS3
BCFG_08DEF EQU 0x00000000 ;// 8Bit Bus
BCFG_16DEF EQU 0x10000400 ;// 16Bit Bus
BCFG_32DEF EQU 0x20000400 ;// 32Bit Bus
;// | IDCY | WST1 | WST2
;// | Idle width | Read width | Write width
;// | 0x00 ~ 0x0f| 0x00 ~ 0x1f| 0x00~0x1f
BCFG_FLASH EQU (BCFG_16DEF | (0x00<<00) | (0x03<<05) | (0x02<<11)) ;// For 90ns Flash
BCFG_PSRAM EQU (BCFG_16DEF | (0x00<<00) | (0x03<<05) | (0x02<<11)) ;// For 70ns PSRAM
BCFG_CS2 EQU (BCFG_16DEF | (0x0f<<00) | (0x1f<<05) | (0x1f<<11)) ;// Blank
BCFG_CS3 EQU (BCFG_16DEF | (0x0f<<00) | (0x1f<<05) | (0x1f<<11)) ;// For Peripheral Equipment
IMPORT __use_no_semihosting_swi
IMPORT __use_two_region_memory
;The imported labels
;引入的外部标号在这声明
IMPORT __main ;The entry point to the main function C语言主程序入口
;The exported labels
;给外部使用的标号在这声明
EXPORT bottom_of_heap
EXPORT bottom_of_Stacks
EXPORT top_of_heap
EXPORT StackUsr
EXPORT Reset
EXPORT __user_initial_stackheap
CODE32
AREA vectors,CODE,READONLY
ENTRY
;interrupt vectors
;中断向量表
Reset
B ResetInit
IMPORT OSIntNesting
IMPORT OsEnterSum
IMPORT OSTCBCur
IMPORT OSTCBHighRdy
;IMPORT StackUsr
IMPORT LowPRI
IMPORT OSIntCtxSw
IMPORT SoftwareInterrupt
IMPORT OSIntExit
IMPORT OSInit
IMPORT OSStart
IMPORT OSTaskCreate
IMPORT OSTimeTick
IMPORT OSTimeDly
IMPORT OSQCreate
IMPORT OSQPend
IMPORT OSQPost
IMPORT OSSemCreate
IMPORT OSSemPend
IMPORT OSSemPost
IMPORT OSSemAccept
IMPORT OSMboxCreate
IMPORT OSMboxDel
IMPORT OSMboxPend
IMPORT OSMboxPost
IMPORT malloc
IMPORT free
IMPORT memset
IMPORT memcpy
DCD OSIntNesting
DCD OsEnterSum
DCD OSTCBCur
DCD OSTCBHighRdy
DCD StackUsr
DCD LowPRI
DCD OSIntCtxSw
B SoftwareInterrupt
IMPORT RunFirst
B RunFirst
code16
PUSH {LR}
BL OSIntExit
POP {PC}
PUSH {LR}
BL OSInit
POP {PC}
PUSH {LR}
BL OSStart
POP {PC}
PUSH {LR}
BL OSTaskCreate
POP {PC}
PUSH {LR}
BL OSTimeTick
POP {PC}
PUSH {LR}
BL OSTimeDly
POP {PC}
PUSH {LR}
BL OSQCreate
POP {PC}
PUSH {LR}
BL OSQPend
POP {PC}
PUSH {LR}
BL OSQPost
POP {PC}
PUSH {LR}
BL OSSemCreate
POP {PC}
PUSH {LR}
BL OSSemPend
POP {PC}
PUSH {LR}
BL OSSemPost
POP {PC}
PUSH {LR}
BL OSMboxCreate
POP {PC}
PUSH {LR}
BL OSMboxDel
POP {PC}
PUSH {LR}
BL OSMboxPend
POP {PC}
PUSH {LR}
BL OSMboxPost
POP {PC}
PUSH {LR}
BL malloc
POP {PC}
PUSH {LR}
BL free
POP {PC}
PUSH {LR}
BL memset
POP {PC}
PUSH {LR}
BL memcpy
POP {PC}
code32
;/*********************************************************************************************************
;** unction name 函数名称: ResetInit
;** Descriptions 功能描述: RESET 复位入口
;** input parameters 输 入: None 无
;** Returned value 输 出 : None 无
;** Used global variables 全局变量: None 无
;** Calling modules 调用模块: None 无
;**
;** Created by 作 者: Chenmingji 陈明计
;** Created Date 日 期: 2005/11/14 2004年2月2日
;**-------------------------------------------------------------------------------------------------------
;** Modified by 修 改:
;** Modified date 日 期:
;**-------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
ResetInit
;Initial extenal bus controller.
;初始化外部总线控制器,根据目标板决定配置
LDR R0, =PINSEL2
LDR R1, =0x0f814914
STR R1, [R0]
LDR R0, =BCFG0
LDR R1, =BCFG_FLASH
STR R1, [R0]
LDR R0, =BCFG1
LDR R1, =BCFG_PSRAM
STR R1, [R0]
LDR R0, =BCFG2
LDR R1, =BCFG_CS2
STR R1, [R0]
LDR R0, =BCFG3
LDR R1, =BCFG_CS3
STR R1, [R0]
;Build the SVC stack
;设置管理模式堆栈
MSR CPSR_c, #(SVC32Mode | NoInt | NoFIQ)
LDR SP, StackSvc
;Build the IRQ stack
;设置中断模式堆栈
MSR CPSR_c, #(IRQ32Mode | NoInt | NoFIQ)
LDR SP, StackIrq
;Build the FIQ stack
;设置快速中断模式堆栈
MSR CPSR_c, #(FIQ32Mode | NoInt | NoFIQ)
LDR SP, StackFiq
;Build the SYS stack
;设置系统模式堆栈
MSR CPSR_c, #(SYS32Mode | NoInt | NoFIQ)
LDR SP, =StackUsr
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
LDR R2, =top_of_heap
LDR R3, =bottom_of_Stacks
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
EXPORT _sys_exit
_sys_exit
B .
EXPORT __rt_div0
EXPORT fputc
EXPORT fgetc
EXPORT _sys_close
EXPORT _sys_write
EXPORT _sys_read
; EXPORT _ttywrch
EXPORT _sys_istty
EXPORT _sys_seek
EXPORT _sys_ensure
EXPORT _sys_flen
EXPORT _sys_tmpnam
EXPORT _sys_command_string
__rt_div0
fputc
fgetc
_sys_close
_sys_write
_sys_read
;_ttywrch
_sys_istty
_sys_seek
_sys_ensure
_sys_flen
_sys_tmpnam
_sys_command_string
MOV R0, #0
MOV PC, LR
EXPORT SvcStackSpace
EXPORT IrqStackSpace
EXPORT FiqStackSpace
;/* 分配堆栈空间 */
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 快速中断模式堆栈空间
AREA Heap, DATA, NOINIT
bottom_of_heap SPACE 1
AREA StackBottom, DATA, NOINIT
bottom_of_Stacks SPACE 1
AREA HeapTop, DATA, NOINIT
top_of_heap
AREA Stacks, DATA, NOINIT
StackUsr
END
;/*********************************************************************************************************
;** End Of File
;********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -