📄 rominit.s
字号:
/* * armboot - Startup Code for ARM920 CPU-core * * Copyright (c) 2001 Marius Gr鰃er <mag@sysgo.de> * Copyright (c) 2002 Alex Z黳ke <azu@sysgo.de> * Copyright (c) 2002 Gary Jennejohn <gj@denx.de> * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */#define _ASMLANGUAGE#include "vxWorks.h"#include "sysLib.h"#include "asm.h"#include "regs.h" #include "config.h"#include "arch/arm/mmuArmLib.h" .data .globl VAR(copyright_wind_river) .long VAR(copyright_wind_river)#define TEXT_BASE 0x10000000/* internals */ .globl FUNC(romInit) /* start of system code */ .globl VAR(sdata) /* start of data */ .globl _sdata .globl VAR(integratorMemSize) /* actual memory size *//* externals */ .extern FUNC(romStart) /* system initialization routine */_sdata:VAR_LABEL(sdata) .asciz "start of data" .balign 4/* variables */ .dataVAR_LABEL(integratorMemSize) .long 0 .text .balign 4/* ************************************************************************* * * Jump vector table as in table 3.1 in [1] * ************************************************************************* *//* flash */#define MC_PUIA 0xFFFFFF10#define MC_PUP 0xFFFFFF50#define MC_PUER 0xFFFFFF54#define MC_ASR 0xFFFFFF04#define MC_AASR 0xFFFFFF08#define EBI_CFGR 0xFFFFFF64#define SMC2_CSR 0xFFFFFF70/* clocks */#define PLLAR 0xFFFFFC28#define PLLBR 0xFFFFFC2C#define MCKR 0xFFFFFC30#define AT91C_BASE_CKGR 0xFFFFFC20#define CKGR_MOR 0/* sdram */#define PIOC_ASR 0xFFFFF870#define PIOC_BSR 0xFFFFF874#define PIOC_PDR 0xFFFFF804#define EBI_CSA 0xFFFFFF60#define SDRC_CR 0xFFFFFF98#define SDRC_MR 0xFFFFFF90#define SDRC_TR 0xFFFFFF94.globl _start_ARM_FUNCTION(romInit)_romInit:_start: b reset B . B . B . B . B . B . B . /*.balignl 16,0xdeadbeef*/ /* copyright notice appears at beginning of ROM (in TEXT segment) */ .ascii "Copyright 1999-2001 ARM Limited" .ascii "\nCopyright 1999-2001 Wind River Systems, Inc." .balign 4/* ************************************************************************* * * Startup Code (reset vector) * * do important init only if we don't start from memory! * relocate armboot to ram * setup stack * jump to second stage * ************************************************************************* */_MTEXT_BASE: .word TEXT_BASE.globl _armboot_start_armboot_start: .word _start/* * the actual reset code */reset: /* * set the cpu to SVC32 mode */ mrs r0,cpsr bic r0,r0,#0x1f orr r0,r0,#0xd3 msr cpsr,r0 /* * we do sys-critical inits only at reboot, * not when booting from ram! */#ifndef CONFIG_SKIP_LOWLEVEL_INIT bl cpu_init_crit#endif ldr r0, __boot_stack sub sp, r0, #12 /* leave 3 words for abort-stack */ MOV r0, #BOOT_COLD ldr pc, _start_armboot/*_start_armboot: .word start_armboot*/_start_armboot: .word romStart__boot_stack: .word 0x20000f00/* ************************************************************************* * * CPU_init_critical registers * * setup important registers * setup memory timing * ************************************************************************* */cpu_init_crit: /* * flush v4 I/D caches */ mov r0, #0 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ /* * disable MMU stuff and caches */ mrc p15, 0, r0, c1, c0, 0 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) orr r0, r0, #0x00000002 @ set bit 2 (A) Align orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache mcr p15, 0, r0, c1, c0, 0 /* * before relocating, we have to setup RAM timing * because memory timing is board-dependend, you will * find a lowlevel_init.S in your board directory. */ mov ip, lr bl lowlevel_init mov lr, ip mov pc, lr.globl lowlevel_initlowlevel_init: /* Get the CKGR Base Address */ ldr r1, =AT91C_BASE_CKGR /* Main oscillator Enable register */#ifdef CFG_USE_MAIN_OSCILLATOR ldr r0, =0x0000FF01 /* Enable main oscillator, OSCOUNT = 0xFF */#else ldr r0, =0x0000FF00 /* Disable main oscillator, OSCOUNT = 0xFF */#endif str r0, [r1, #CKGR_MOR] /* Add loop to compensate Main Oscillator startup time */ ldr r0, =0x00000010LoopOsc: subs r0, r0, #1 bhi LoopOsc /* memory control configuration */ /* this isn't very elegant, but what the heck */ ldr r0, =SMRDATA ldr r1, _MTEXT_BASE sub r0, r0, r1 add r2, r0, #800: /* the address */ ldr r1, [r0], #4 /* the value */ ldr r3, [r0], #4 str r3, [r1] cmp r2, r0 bne 0b /* delay - this is all done by guess */ ldr r0, =0x000100001: subs r0, r0, #1 bhi 1b ldr r0, =SMRDATA1 ldr r1, _MTEXT_BASE sub r0, r0, r1 add r2, r0, #1762: /* the address */ ldr r1, [r0], #4 /* the value */ ldr r3, [r0], #4 str r3, [r1] cmp r2, r0 bne 2b /* everything is fine now */ mov pc, lr .ltorgSMRDATA: .word MC_PUIA .word MC_PUIA_VAL .word MC_PUP .word MC_PUP_VAL .word MC_PUER .word MC_PUER_VAL .word MC_ASR .word MC_ASR_VAL .word MC_AASR .word MC_AASR_VAL .word EBI_CFGR .word EBI_CFGR_VAL .word SMC2_CSR .word SMC2_CSR_VAL .word PLLAR .word PLLAR_VAL .word PLLBR .word PLLBR_VAL .word MCKR .word MCKR_VAL /* SMRDATA is 80 bytes long */ /* here there's a delay of 100 */SMRDATA1: .word PIOC_ASR .word PIOC_ASR_VAL .word PIOC_BSR .word PIOC_BSR_VAL .word PIOC_PDR .word PIOC_PDR_VAL .word EBI_CSA .word EBI_CSA_VAL .word SDRC_CR .word SDRC_CR_VAL .word SDRC_MR .word SDRC_MR_VAL .word SDRAM .word SDRAM_VAL .word SDRC_MR .word SDRC_MR_VAL1 .word SDRAM .word SDRAM_VAL .word SDRAM .word SDRAM_VAL .word SDRAM .word SDRAM_VAL .word SDRAM .word SDRAM_VAL .word SDRAM .word SDRAM_VAL .word SDRAM .word SDRAM_VAL .word SDRAM .word SDRAM_VAL .word SDRAM .word SDRAM_VAL .word SDRC_MR .word SDRC_MR_VAL2 .word SDRAM1 .word SDRAM_VAL .word SDRC_TR .word SDRC_TR_VAL .word SDRAM .word SDRAM_VAL .word SDRC_MR .word SDRC_MR_VAL3 .word SDRAM .word SDRAM_VAL /* SMRDATA1 is 176 bytes long */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -