📄 boot.s
字号:
;-/****************************************************************************
;-** Copyright (c) 2004, UTStarcom, Inc.
;-** All Rights Reserved.
;-**
;-** Subsystem : Boot Support
;-** File : boot.s
;-** Created By : Sean Yang
;-** Created On : 2005.01.21
;-**
;-** Purpose:
;-** Boot up the whole software system from Boot Flash, no ICE
;-**
;-** Note:
;-**
;-****************************************************************************/
;- Get the start Ram address
TOP_INTERNAL_MEMORY EQU 0x00700000
INTERNAL_SRAM_SIZE EQU 0x00001000
TOP_EXCEPTION_STACK EQU (TOP_INTERNAL_MEMORY+INTERNAL_SRAM_SIZE)
;- Remap information definition
REG_MEMORY_MAPPING EQU 0x007FF804
VAL_MEMORY_MAPPING EQU 0x31
;- Main function entry address
MAIN_ADDR EQU 0x00300000
;------------------------------------------------------------------------------
;- Area Definition
;------------------------------------------------------------------------------
AREA reset, CODE, READONLY
ENTRY
EXPORT entry
entry
;------------------------------------------------------------------------------
;- Exception vectors ( before Remap )
;------------------------------------
;- These vectors can be read at address 0 or at RAM address
;- They ABSOLUTELY requires to be in relative addressing mode in order to
;- guarantee a valid jump. For the moment, all are just looping.
;- If an exception occurs before remap, this would result in an infinite loop.
;- To ensure if a exception occurs before start application to infinite loop.
;------------------------------------------------------------------------------
B InitReset ; Reset handler
undefvec
B undefvec ; Undefined Instruction
swivec
B swivec ; Software Interrupt
pabtvec
B pabtvec ; Prefetch Abort
dabtvec
B dabtvec ; Data Abort
rsvdvec
B rsvdvec ; reserved
irqvec
B irqvec ; IRQ
fiqvec
B fiqvec ; FIQ
space 4096
;------------------------------------------------------------------------------
;- Exception vectors ( after cstartup execution )
;------------------------------------
;- These vectors are read at RAM address after the remap command is performed.
;- As they will be relocated at address 0x0 to be effective, a
;- RELATIVE addressing is FORBIDDEN. The only possibility to get an absolute
;- addressing for an ARM vector is to read a PC relative value at a defined
;- offset. It is easy to reserve the locations 0x20 to 0x3C (the 8 next
;- vectors) for storing the absolute exception handler address.
;- The provisory handler addresses are defined on infinite loop and can be
;- modified at any time.
;- Note also that the reset is only accessible by a jump from the application
;- to 0. It is an actual software reset.
;------------------------------------------------------------------------------
EXPORT VectorTable
VectorTable
ldr pc, [pc, #&18] ; SoftReset
ldr pc, [pc, #&18] ; UndefHandler
ldr pc, [pc, #&18] ; SWIHandler
ldr pc, [pc, #&18] ; PrefetchAbortHandler
ldr pc, [pc, #&18] ; DataAbortHandler
ldr pc, [pc, #&18] ; Reserved
ldr pc, [pc, #&18] ; IRQ
ldr pc, [pc, #&18] ; FIQ
;- There are only 8 offsets as the vectoring is used.
DCD SoftReset
DCD UndefHandler
DCD SWIHandler
DCD PrefetchAbortHandler
DCD DataAbortHandler
DCD RevHandler
DCD IrqHandler
DCD FiqHandler
;- Vectoring Execution function run at absolute address
SoftReset
b SoftReset
UndefHandler
b UndefHandler
SWIHandler
b SWIHandler
PrefetchAbortHandler
b PrefetchAbortHandler
DataAbortHandler
b DataAbortHandler
RevHandler
b RevHandler
IrqHandler
b IrqHandler
FiqHandler
b FiqHandler
;--------------------
;- The reset handler
;--------------------
InitReset
;------------------------------------------------------------------------------
;- Low level Init by C function LowLevelInit
;------------------------------------------------------------------------------
IMPORT lowlevel_init
;- minimum C initialization
ldr r13,=TOP_EXCEPTION_STACK ; temporary stack in internal Ram
ldr r1,=TOP_INTERNAL_MEMORY
add r0, pc,#-(8+.-VectorTable) ; @ where to read values (relative)
bl lowlevel_init
;--------------------------------------------
;- Remap Command and jump on ABSOLUTE address
;--------------------------------------------
ldr r12, PtInitRemap ; Get the real jump address ( after remap )
ldr r0,=REG_MEMORY_MAPPING ; Get the REMAP register
ldr r1,=VAL_MEMORY_MAPPING ; Get the REMAP value
strb r1, [r0] ; Store the complete image with the remap command
;- Jump to LINK address at its absolute address
mov pc, r12 ; Jump and break the pipeline
PtInitRemap
DCD InitRemap ; Address where to jump after REMAP
;------------------------------------------------------------------------------
;- The Reset Handler after Remap
;-------------------------------
;- From here, the code is executed from its link address, ie. 0x100 0000.
;------------------------------------------------------------------------------
InitRemap
;------------------------------------------------------------------------------
;- check version, and copy version from FLASH to SRAM
;------------------------------------------------------------------------------
IMPORT copy_bootld
ldr r13,=INTERNAL_SRAM_SIZE ; temporary stack in internal Ram
bl copy_bootld
;------------------------------------------------------------------------------
;- Jump to entry address in SRAM
;------------------------------------------------------------------------------
ldr r0, =MAIN_ADDR
mov lr, pc
bx r0
;------------------------------------------------------------------------------
;- Loop for ever
;---------------
;- End of application. Normally, never occur.
;- Could jump on Software Reset ( B 0x0 ).
;------------------------------------------------------------------------------
End
b End
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -