📄 startup.s
字号:
;
; Copyright (c) Microsoft Corporation. All rights reserved.
;
;
; Use of this sample source code is subject to the terms of the Microsoft
; license agreement under which you licensed this sample source code. If
; you did not accept the terms of the license agreement, you are not
; authorized to use this sample source code. For the terms of the license,
; please see the license agreement between you and Microsoft or, if applicable,
; see the LICENSE.RTF on your install media or the root of your tools installation.
; THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
;
;++
;
; Module Name:
;
; startup.s
;
; Abstract:
;
; This module implements Bulverde initialization code. It's responsible
; for setting up the Bulverde core. Board-level initialization is done
; in OEM-specific code.
;
; Environment:
;
; Revision History:
;
; Notes:
;
; Register Useage: r10 is used to hold the contents of the RCSR throughout
; this module. The rest of the registers are fair game.
;
;--
;
;-------------------------------------------------------------------------------
; Copyright 2000-2003 Intel Corporation All Rights Reserved.
;
; Portions of the source code contained or described herein and all documents
; related to such source code (Material) are owned by Intel Corporation
; or its suppliers or licensors and is licensed by Microsoft Corporation for distribution.
; Title to the Material remains with Intel Corporation or its suppliers and licensors.
; Use of the Materials is subject to the terms of the Microsoft license agreement which accompanied the Materials.
; No other license under any patent, copyright, trade secret or other intellectual
; property right is granted to or conferred upon you by disclosure or
; delivery of the Materials, either expressly, by implication, inducement,
; estoppel or otherwise
; Some portion of the Materials may be copyrighted by Microsoft Corporation.
;
;-------------------------------------------------------------------------------
;
; Disable listing
OPT 2
INCLUDE kxarm.h
INCLUDE bulverde.inc
INCLUDE bulverde_macros.inc
INCLUDE xlli_bulverde_defs.inc
; Re-enable listing
OPT 1
; PQOAL BSP imports
IMPORT OALStartUp
; XLLI/XLLP imports
IMPORT xlli_GPIO_init
IMPORT xlli_setClocks
IMPORT xlli_freq_change
IMPORT xlli_intr_init
IMPORT xlli_mem_restart
IMPORT xlli_ost_init
IMPORT xlli_pwrmgr_init
IMPORT xlli_IMpwr_init
IMPORT XllpPmValidateResumeFromSleep
IMPORT XllpPmGoToContextRestoration
XLLP_CKEN_MEMC EQU xlli_BIT_22
XLLP_CKEN_OST EQU xlli_BIT_9
STARTUPTEXT
;*******************************************************************************
;
; StartUp() is the entry point on Reset (Hard Reset or Sleep Exit Reset)
;
; Desription: The MDOCIPL code that gets executed on reset will jump
; to this location after initializing the GPIO controller and memory
; controller. If it is a hard reset, it will load this code (bootloader)
; from flash into RAM before jumping here.
;
;*******************************************************************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Note: - The MMU assumed to be inactive at this time so physical addresses
; should be used.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LEAF_ENTRY StartUp
; Perform pre-initialization and determine the reason for the reset.
bl PreInit
; r10 now contains the contents of the power manager registers RCSR in the
; lower half and PSSR in the upper half. If we're in this routine because
; of a hardware/power-on reset, then we need to continue in this routine and
; initialize all hardware. Otherwise, we'll assume the hardware's already
; been initialized and we can skip.
;
;jump directly to OALstartup if this was not a reset
;
tst r10, #(RCSR_HARD_RESET :OR: RCSR_WDOG_RESET :OR: RCSR_SLEEP_RESET :OR: RCSR_GPIO_RESET)
beq OALStartUp
; If we're here because of a GPIO reset, skip the memory controller
; initialization because all memory registers (except for configuration
; registers are maintained across the reboot).
;
tst r10, #RCSR_GPIO_RESET
bne Continue_StartUp
; init GPIO subsystem with the correct values for Platforom
; (though this was temporarily done in MDOCIPL as well)
;
bl xlli_GPIO_init
; This is where you would initialize the Bulverde memory controller.
; However, this step was already done in the MDOCIPL.
; We *CANNOT* do this here because we are currently running in RAM
;
;bl xlli_mem_init
; If we're here because of a hardware reset then skip sleep reset check
;
tst r10, #RCSR_HARD_RESET
bne Continue_StartUp
; We may be here because of a sleep reset. Try to resume from the sleep
; state. At this point, it may be a watchdog reset or a sleep/software reset.
;
ldr r0, =xlli_PMRCREGS_PHYSICAL_BASE ; read the PSPR register
ldr r0, [r0, #xlli_PSPR_offset] ;
mov r1, r10 ; packed RCSR+PSSR required in r1
bl XllpPmValidateResumeFromSleep ; r0-r6 are lost
cmp r0, #0 ; zero return: OK to restore
bne Continue_StartUp ; treat as a full-init reset
; At this point, the reset could have been caused by a resume from sleep
; or by a software reset. For now, assume it was a sleep-based reset.
;
b Sleep_Reset_Not_SoftReset
Continue_StartUp
; Initialize the interrupt controller.
; All interrupts are masked.
;
bl xlli_intr_init
; Enable sub-systems clocks
; on HARD reset all clocks are turned on by default.
; keep MEM controller & OST timer clock turned on, turn OFF rest of the clocks
;
ldr r1, =xlli_CLKREGS_PHYSICAL_BASE
ldr r2, =(XLLP_CKEN_MEMC :OR: XLLP_CKEN_OST)
str r2, [r1, #xlli_CKEN_offset]
; set core frequency registers
;
bl xlli_setClocks
;initiate the frequency change as xlli_setClocks changed core frequency
;
bl xlli_freq_change
; restart the memory controller
;
bl xlli_mem_restart
; Some GPIO configurations cannot be applied until the memory controller
; is re-started. Set them now. If done earlier, it would cause a hang
; Specifically, on Plato, this has to do with GPIO pin to be used as the PCMCIA PSKTSEL pin
;
bl GPIO_reconfig
; Initialize the OS timers.
;
bl xlli_ost_init
; Initialize the power manager.
;
bl xlli_pwrmgr_init
; Jump to OAL startup code.
;
b OALStartUp
Sleep_Reset_Not_SoftReset
; Sleep Exit reset will not clear the CCCR register. So we don't have to call
; xlli_setClocks here. However, if the core was in Turbo or Half turbo mode
; before the sleep, we need to explicity set the core to that mode by
; initiating a frequency change.
;
bl xlli_freq_change
; Some GPIO configurations cannot be applied until the memory controller
; is re-started. Set them now. If done earlier, it would cause a hang
; Specifically, on Plato, this has to do with GPIO pin to be used as the PCMCIA PSKTSEL pin
;
bl GPIO_reconfig
ldr r0, =xlli_PMRCREGS_PHYSICAL_BASE ; Get the Power Manager base address
ldr r0, [r0, #xlli_PSPR_offset] ; Phys. addr of save data
mov r1, r10 ; Packed RCSR+PSSR
b XllpPmGoToContextRestoration ; Never returns.
; if it returns jump to Failed Reset
b Continue_StartUp
ENTRY_END
;-------------------------------------------------------------------------------
LTORG ; insert a literal pool here.
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
;
; PreInit: Perform pre-initialization (enter supervisor mode, disable MMU and caches,
; and determine the reason for the reset).
;
; Inputs: r10 contains an optional flag - TBD
;
; On return: r10 has RCSR in lower half and PSSR in upper half
;
; Register used: r0-r2, r10, r12
;
;-------------------------------------------------------------------------------
;
ALIGN
PreInit
; Put the CPU in Supervisor mode (SVC) and disable IRQ and FIQ interrupts.
;
ldr r0, =(Mode_SVC :OR: NoIntsMask)
msr cpsr_c, r0
; Disable the MMU, caches, and write-buffer and flush.
;
ldr r0, =0x2043 ; enable access to all coprocessors
mcr p15, 0, r0, c15, c1, 0 ;
CPWAIT r0 ;
ldr r0, =0x00000078 ; get a zero to turn things off (must write bits[6:3] as 1s)
mcr p15, 0, r0, c1, c0, 0 ; turn off MMU, I&D caches, and write buffer
CPWAIT r0 ;
mvn r0, #0 ; grant manager access to all domains
mcr p15, 0, r0, c3, c0, 0 ;
; Read the reset cause bits in RCSR.
;
ldr r0, =BULVERDE_BASE_REG_PA_PWR
ldr r10, [r0, #RCSR_OFFSET]
; Extract the reset cause bits.
;
mov r2, #RCSR_ALL ; Mask RCSR
and r10, r10, r2 ; r10 now holds the conditioned Reset Reason
; Clear the reset cause bits (they're sticky).
;
str r2, [r0, #RCSR_OFFSET]
; Read and store PSSR in the upper half of r10.
;
ldr r12, [r0, #PSSR_OFFSET]
mov r2, #PSSR_VALID_MASK ; mask PSSR (all in lower byte)
and r12, r12, r2 ; r12 now holds the conditioned PSSR
mov r12, r12, lsl #16 ; move to upper half of register
orr r10, r10, r12 ; r10 now has RCSR in lower half and PSSR in upper
; Enable data aborts for VDD and BATT faults (alternative is to use interrupt)
;
mov r1, #(PMCR_BIDAE:OR:PMCR_VIDAE) ; Enable imprecise data aborts on VDD and BATT faults.
str r1, [r0, #PMCR_OFFSET]
mov pc, lr ; return to caller.
;-------------------------------------------------------------------------------
LTORG ; insert a literal pool here.
;******************************************************************************
;
; FUNCTION: GPIO_reconfig
;
; Initialize PCMCIA GPIOs
;
;******************************************************************************
ALIGN
GPIO_reconfig
; Get GPIO registers base address and configure all GPIO lines.
;
ldr r0, =xlli_GPIOREGS_PHYSICAL_BASE ; Load the GPIO register block base address
ldr r1, [r0, #xlli_GPDR2_offset] ; Get current pin direction values for GPDR2
orr r1, r1, #xlli_BIT_15
str r1, [r0, #xlli_GPDR2_offset] ; Write the R2 values
ldr r1, [r0, #xlli_GAFR2_L_offset] ; Get current pin alt function values for GAFR2_L
orr r1, r1, #xlli_BIT_30
str r1, [r0, #xlli_GAFR2_L_offset] ; Write the R2_L values
mov r1, #0x600
reconfig_g subs r1, r1, #1
bne reconfig_g
mov pc, lr ; Return to calling program
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -