?? 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 管理模式堆??臻g
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 快速中斷模式堆??臻g
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 + -