⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 startup.s

📁 CIRRUS 公司EP93XX系列CPU的WINCE下的BSP
💻 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                       
;                                                                      
;**********************************************************************

    OPT 2   ; disable listing
    INCLUDE kxarm.h
    OPT 1   ; reenable listing
    OPT 128 ; disable listing of macro expansions


;
; ASync bus mode, little endian, MMU disabled
;
;CP15R1Init              EQU         0xC0000078           
CP15R1Init              EQU         0xC0001078           
CLKSET1DEFAULT          EQU         0x000398e7


;
; Static memory settings.
;
SMCBCR_IDCY_MASK        EQU         0x0000000F
SMCBCR_IDCY_SHIFT       EQU         0
SMCBCR_WST1_MASK        EQU         0x000003E0
SMCBCR_WST1_SHIFT       EQU         5
SMCBCR_RBLE             EQU         0x00000400
SMCBCR_WST2_MASK        EQU         0x0000F800
SMCBCR_WST2_SHIFT       EQU         11
SMCBCR_WPERR            EQU         0x02000000
SMCBCR_WP               EQU         0x04000000
SMCBCR_PME              EQU         0x08000000
SMCBCR_MASK             EQU         0x30000000
SMCBCR_MW_8BIT          EQU         0x00000000
SMCBCR_MW_16BIT         EQU         0x10000000
SMCBCR_MW_32BIT         EQU         0x20000000
SMCBCR_EBIBRKDIS        EQU         0x40000000

ROMHDR_dllfirst         EQU         0x8
ROMHDR_dlllast          EQU         0xC
ROMHDR_physfirst        EQU         0x10
ROMHDR_physlast         EQU         0x14


                IMPORT          KernelStart
                IMPORT          OEMAddressTable
                IMPORT          SysconSetup
                IMPORT          SdramCfg
                IMPORT          pTOC


;**********************************************************************
;  StartUp routine to initialize the processor.
;**********************************************************************
                STARTUPTEXT
                DCB             "CRUS", 0 

                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

;
; Check to see if we are executing in flash, if so we may need to
; setup SDRAM.
;
                cmp             pc, #0x60000000
                bls             DontConfigureSDRAM

;
; If we loaded through eboot, SDRAM is already configured. 
; Check the CLKSET1 register to see if it has been modified.
;
                ldr             r0, =0x80930020 
                ldr             r1, [r0]
                ldr             r0, =CLKSET1DEFAULT
                cmp             r0, r1
                bne             DontConfigureSDRAM

;                
;
; Configure SDRAM
;
                bl              SdramCfg

DontConfigureSDRAM

;
; Turn off the MMU
;
                ldr             r0, =0xC0001078           
                mcr             p15, 0, r0, c1, c0, 0

;
; Configure the flash chips
;
                ldr             r0, =((4:SHL:SMCBCR_WST2_SHIFT)  :or: \
                                      (15:SHL:SMCBCR_WST1_SHIFT) :or: \
                                      (1 :and:SMCBCR_IDCY_MASK)  :or: \
                                      SMCBCR_MW_32BIT            :or: \
                                      SMCBCR_WP                  :or: \
                                      SMCBCR_PME                 :or: \
                                      SMCBCR_RBLE)

                ldr             r1, =0x80080018
                str             r0, [r1]
                nop             


;
; If we want an image that copies from flash to ram use the following.
;

                IF              COPY_FLASH_TO_RAM

;
; Get the address of the table of contents and adjust for the flash address.
;
                ldr             r0, =pTOC 
                ldr             r3, =0xDFD40000
                add             r0, r0, r3
                ldr             r4, [r0]
                add             r4, r4, r3

;
; Get the dll first and dll last address.  
; r1  = Destiniation = dllfirst 
; r11 = length       = dlllast - dllfirst 
;
                ldr             r1, [r4, #ROMHDR_dllfirst]
                ldr             r11, [r4, #ROMHDR_dlllast]

;
; Make sure that r1 and r11 are on a 0x20 boundary.
;
                ldr             r2, =0x07FFFFE0
                and             r1, r1, r2

                and             r11, r11, r2  
                add             r11, r11, #0x20

;*************************************************************************
; Copy routine.
; 
; r0  = Source
; r1  = Destination
; r11 = End Address Address of Destination
; r12 = LED counter
; r13 = LED address.
;
;*************************************************************************

                ldr             r13, =0x80840020
                ldr             r2,  [r13]
                and             r2, r2, #0xFFFFFFFC
                orr             r2, r2, #1
                str             r2,  [r13]

                ldr             r0,  =0x60000000
                ldr             r12, =0x3FFFF

NKCopyLoop      ldmia           r0!, {r2-r9}
                stmia           r1!, {r2-r9}
                ands            r2, r0, r12
                beq             ToggleLED

NKCopyTest      cmp             r1, r11
                bne             NKCopyLoop
                
                ldr             r2, =ExecuteFromRam
                and             r2, r2, #0x00FFFFFF
                mov             pc, r2
                

ToggleLED       ldr             r2, [r13]
                eor             r2, r2, #3
                str             r2, [r13]
                b               NKCopyTest                    
                ENDIF

;
; create a temporary stack below kernel memory from config.bib
;
ExecuteFromRam
                mov             sp, #0x40000
                bl              SysconSetup

;
; clear out magic words for memory and heap
; (r0) = physical address of OEMAddressTable
;
;
; Calculate the physical address of the table.
;
; r0 - Virtual address of OEMAddressTable
; r1 - Physical Address of Startup
; r2 - Virtual Address of Startup
;
; r0 = r0 - r2 + r1 = Physical address of OEMAddressTable 
;            
                ldr             r0,=OEMAddressTable
                adr             r1,StartUp
                ldr             r2,=StartUp        
                add             r0, r0, r1
                sub             r0, r0, r2
                bl              KernelStart
;
; KernelStart should never return:
;
    
spin            b               spin



;****************************************************************************
; Include the appropriate memory map.
;****************************************************************************
;                INCLUDE         mmumap.inc

; End of initialization code & data
                TEXTAREA

                END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -