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

📄 startup.s

📁 CIRRUS 93XX系列windows mobile 6.0 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                       
;                                                                      
;**********************************************************************
EBOOT_RUN_FLAG			EQU			 0x00001234
REG_SCRATCH_REG0        EQU          0x80930040

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


                IMPORT          SysconSetup
                IMPORT          EbootMain
                IMPORT          SdramCfg
                IMPORT          PageTableSetup 
;                IMPORT          MMUSetup
                

;**********************************************************************
;  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, =REG_SCRATCH_REG0
                ldr    	    r1, =EBOOT_RUN_FLAG
                str             r1, [r0]

;
; When Programming SDRAM clear clkset1 so the delay loop have proper
; delays.
;
                ldr             r0, =0x80930020
                ldr             r1, =0x0
                str             r1, [r0]

;
; Configure SDRAM
;
                bl              SdramCfg



;
; Copy the image to RAM
;
                ldr             r0,  =EP93XX_FLASH_PHY_ADDR
                
                ldr             r2,  =EP93XX_SDRAM_PHY_ADDR
                
                ldr             r3, =0x00040000
                orr             r1, r2,r3
                
                ldr             r3, =0x00060000
                orr             r11,r2,r3
                
EbootCopyLoop   ldmia           r0!, {r2-r9}
                stmia           r1!, {r2-r9}
                cmp             r1, r11
                bne             EbootCopyLoop
                
                ldr             r0, =ExecuteFromRam
                orr             r0, r0, #EP93XX_SDRAM_PHY_ADDR
                mov           pc, r0
;
; create a temporary stack below kernel memory from config.bib
;
ExecuteFromRam              

                ldr             sp, =EbootStack
                sub            sp, sp, #0x4 
                orr             sp, sp, #EP93XX_SDRAM_PHY_ADDR
                bl              SysconSetup
;
; Initializes the vector table.  Incase of spurious vectors.
;
                ldr                r0, =VectorTable
                orr               r0, r0, #EP93XX_SDRAM_PHY_ADDR
                ldr               r1, =EP93XX_SDRAM_PHY_ADDR
                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.

;1.get the 16K aligned pagetable address
        ldr     r5, =PageTable
        mov     r7, r5
        ldr     r2, =0xFFFFC000
        and     r5, r5, r2
        cmp  r7, r5
        beq   dontadd
        orr     r5, r5, #0x4000
        
dontadd  
        orr     r5, r5, #EP93XX_SDRAM_PHY_ADDR
        
        str    r5, [sp]
        ;sub  sp, sp, #0x4
        ;mov   r10, r5   ;save page table address to r10

;2. call PageTableSetup to produce the MMU page table. page table address is store in r0 to let  PageTableSetup know.
        mov   r0, r5
        bl          PageTableSetup

; Set up the MMU.  Start by flushing the cache and TLB.       
        ldr     r0, =0x00000000
        mcr     p15, 0, r0, c7, c7, 0
        mcr     p15, 0, r0, c8, c7, 0

        ; Set user mode access for all 16 domains.

        ldr     r0, =0x55555555
        mcr     p15, 0, r0, c3, c0, 0
        ;
        ; Tell the MMU where to find the page table.
        ;
        ;add sp, sp, #0x4
        ldr  r10, [sp]
        mcr     p15, 0, r10, c2, c0, 0
        ;
        ; Enable the MMU.
        ;
        ldr     r0, =0xc000107d
        mcr     p15, 0, r0, c1, c0, 0
        ;
        ; There should always be two NOP instructions following the enable or
        ; disable of the MMU.
        ;
        nop
        nop
        ;;

        ldr       r0, =0x0FFFFFFF
        ldr       lr, =govirtual

        and    sp, sp, r0
        and     lr, lr, r0
        mov     pc, lr

;
; Branch to eboot main C routine.
;
govirtual                 

                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 %       0x4000
EbootStack


PageTable     
PTs     %       0x8000

                END

⌨️ 快捷键说明

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