📄 startup.s
字号:
;**********************************************************************
;
; Filename: startup.s
;
; Description: Initialization before the MMU gets turned. This is
; the first code that gets executed.
;
; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
; ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
; PARTICULAR PURPOSE.
;
; Use of this source code is subject to the terms of the Cirrus end-user
; license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
; If you did not accept the terms of the EULA, you are not authorized to
; use this source code. For a copy of the EULA, please see the
; EULA.RTF on your install media.
;
; Copyright(c) Cirrus Logic Corporation 2002, All Rights Reserved
;
;**********************************************************************
EBOOT_RUN_FLAG EQU 0x00001234
OPT 2 ; disable listing
INCLUDE kxarm.h
OPT 1 ; reenable listing
OPT 128 ; disable listing of macro expansions
IMPORT SysconSetup
IMPORT EbootMain
IMPORT MMUSetup
IMPORT SdramCfg
;**********************************************************************
; StartUp routine to initialize the processor.
;**********************************************************************
STARTUPTEXT
DCB "CRUS"
LEAF_ENTRY StartUp
;
; Kill watch dog timer. Before any thing else.
;
ldr r0, =0x80940000
ldr r1, =0xAA55
str r1, [r0]
;
; ensure SVC32 mode with IRQ and FIQ disabled
;
mov r0, #0xd3
msr cpsr_c, r0
;set eboot run flag
ldr r0, =0x80930040
ldr r1, =EBOOT_RUN_FLAG
str r1, [r0]
;
; When Programming SDRAM clear clkset1 so the delay loop have proper
; delays.
;
str r1, [r0]
ldr r0, =0x80930020
ldr r1, =0x0
str r1, [r0]
;
; Configure SDRAM
;
bl SdramCfg
;
; Copy the image to RAM
;
ldr r0, =0x60000000
ldr r1, =0xc0040000
ldr r11, =0xc0060000
EbootCopyLoop ldmia r0!, {r2-r9}
stmia r1!, {r2-r9}
cmp r1, r11
bne EbootCopyLoop
ldr r0, =ExecuteFromRam
orr r0, r0, #0xc0000000
mov pc, r0
;
; create a temporary stack below kernel memory from config.bib
;
ExecuteFromRam
ldr sp, =EbootStack
orr sp, sp, #0xc0000000
bl SysconSetup
;
; Initializes the vector table. Incase of spurious vectors.
;
ldr r0, =VectorTable
orr r0, r0, #0xc0000000
ldr r1, =0xc0000000
ldmia r0!, {r2-r9}
stmia r1!, {r2-r9}
ldmia r0!, {r2-r9}
stmia r1!, {r2-r9}
;
; Lets setup the MMU Linear = Physical. This allows us to
; setup cachable and noncachable areas.
;
bl MMUSetup
;
; Branch to eboot main C routine.
;
ldr sp, =EbootStack
; orr sp, sp, #0xc0000000
bl EbootMain
;
; KernelStart should never return:
;
spin b spin
;*************************************************************************
; Default vectors
;
; We never should hit these vectors, but just in case lets do something
;
;*************************************************************************
ResetVector
ldr r0, =0x808C0000
ldr r1, ='R'
STR R1, [R0]
b .
UndefVector ldr r0, =0x808C0000
ldr r1, ='U'
STR R1, [R0]
b .
SWIVector ldr r0, =0x808C0000
ldr r1, ='S'
STR R1, [R0]
b .
PrefetchVector ldr r0, =0x808C0000
ldr r1, ='P'
STR R1, [R0]
b .
DataAbortVector ldr r0, =0x808C0000
ldr r1, ='D'
STR R1, [R0]
b .
FIQVector ldr r0, =0x808C0000
ldr r1, ='F'
STR R1, [R0]
b .
IRQVector ldr r0, =0x808C0000
ldr r1, ='I'
STR R1, [R0]
b .
VectorTable
;
; Load value of relative label into program counter, causing jump to
; the value stored at the label.
; At startup pc is zero 0, loading the value of this lable should
; place pc in the area of 0x80090000. LDR is PC Relative.
;
ldr PC, Reset_Addr
ldr PC, Undefined_Addr
ldr PC, SWI_Addr
ldr PC, Prefetch_Addr
ldr PC, Abort_Addr
nop ; Reserved vector
ldr PC, IRQ_Addr
ldr PC, FIQ_Addr
;; these DCDs (below) have to remain here for the LDRs above to be able to jump
;; with offset
ExceptionVectorTable
Reset_Addr DCD ResetVector
Undefined_Addr DCD UndefVector
SWI_Addr DCD SWIVector
Prefetch_Addr DCD PrefetchVector
Abort_Addr DCD DataAbortVector
DCD 0
IRQ_Addr DCD IRQVector
FIQ_Addr DCD FIQVector
VectorTableEnd
AREA |.KDATA|,DATA,NOINIT
;*****************************************************************************
;
; The MMU level one page table.
;
;*****************************************************************************
EbootStackStart % 0x8000
EbootStack
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -