|
发表于 2014-11-3 23:22:03
3872 浏览 2 回复
【uboot】启动第一阶段代码
uboot启动第一阶段代码是汇编代码,4412启动的汇编代码./cpu/arm_cortexa9/start.S
/*
* armboot - Startup Code for S5PC110/ARM-Cortex CPU-core
*
* Copyright (c) 2009 Samsung Electronics
*
*
* 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
*
* Base codes by scsuh (sc.suh)
*/
#include <config.h>
#include <version.h>
#if defined(CONFIG_ENABLE_MMU)
#include <asm/proc/domain.h>
#endif
#if defined(CONFIG_S5PV310)
#include <s5pv310.h>
#endif
#if defined(CONFIG_S5PC210)
#include <s5pc210.h>
#endif
#ifndef CONFIG_ENABLE_MMU
#ifndef CFG_PHY_UBOOT_BASE
#define CFG_PHY_UBOOT_BASE CFG_UBOOT_BASE
#endif
#endif
/*
*************************************************************************
*
* Jump vector table as in table 3.1 in [1]
*
*************************************************************************
*/
.word 0x2000
.word 0x0
.word 0x0
.word 0x0
.globl _start
_start: b reset //第一条汇编指令,掉转到reset标签
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
_undefined_instruction:
.word undefined_instruction
_software_interrupt:
.word software_interrupt
_prefetch_abort:
.word prefetch_abort
_data_abort:
.word data_abort
_not_used:
.word not_used
_irq:
.word irq
_fiq:
.word fiq
_pad:
.word 0x12345678 /* now 16*4=64 */
.global _end_vect
_end_vect:
.balignl 16,0xdeadbeef
/*
*************************************************************************
*
* Startup Code (reset vector)
*
* do important init only if we don't start from memory!
* setup Memory and board specific bits prior to relocation.
* relocate armboot to ram
* setup stack
*
*************************************************************************
*/
_TEXT_BASE:
.word TEXT_BASE
/*
* Below variable is very important because we use MMU in U-Boot.
* Without it, we cannot run code correctly before MMU is ON.
* by scsuh.
*/
_TEXT_PHY_BASE:
.word CFG_PHY_UBOOT_BASE
.globl _armboot_start
_armboot_start:
.word _start
/*
* These are defined in the board-specific linker script.
*/
.globl _bss_start
_bss_start:
.word __bss_start
.globl _bss_end
_bss_end:
.word _end
.macro cache_invalidate_dcache_v7
MRC p15, 1, r0, c0, c0, 1 @ read Cache Level ID register (clidr)
ANDS r3, r0, #0x7000000 @ extract level of coherency from clidr
MOV r3, r3, lsr #23 @ left align level of coherency bit field
BEQ finished_inval @ if loc is 0, then no need to clean
MOV r10, #0 @ start clean at cache level 0 (in r10)
loop_1:
ADD r2, r10, r10, lsr #1 @ work out 3x current cache level
MOV r1, r0, lsr r2 @ extract cache type bits from clidr
AND r1, r1, #7 @ mask of the bits for current cache only
CMP r1, #2 @ see what cache we have at this level
BLT skip_inval @ skip if no cache, or just i-cache
MCR p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
MOV r1, #0
MCR p15, 0, r1, c7, c5, 4 @ prefetchflush to synch the new cssr&csidr
MRC p15, 1, r1, c0, c0, 0 @ read the new csidr
AND r2, r1, #7 @ extract the length of the cache lines
ADD r2, r2, #4 @ add 4 (line length offset)
LDR r6, =0x3ff
ANDS r6, r6, r1, lsr #3 @ find maximum number on the way size
CLZ r5,r6 @ DCI 0xE16F5F16 , find bit position of way size increment
LDR r7, =0x7fff
ANDS r7, r7, r1, lsr #13 @ extract max number of the index size
loop_2:
MOV r8, r6 @ create working copy of max way size
loop_3:
ORR r11, r10, r8, lsl r5 @ factor way and cache number into r11
ORR r11, r11, r7, lsl r2 @ factor index number into r11
MCR p15, 0, r11, c7, c6, 2 @ invalidate by set/way
SUBS r8, r8, #1 @ decrement the way
BGE loop_3
SUBS r7, r7, #1 @ decrement the index
BGE loop_2
skip_inval:
ADD r10, r10, #2 @ increment cache number
CMP r3, r10
BGT loop_1
finished_inval:
.endm
#if defined(CONFIG_USE_IRQ)
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
IRQ_STACK_START:
.word 0x0badc0de
/* IRQ stack memory (calculated at run-time) */
.globl FIQ_STACK_START
FIQ_STACK_START:
.word 0x0badc0de
#endif
/*
* the actual reset code
*/
reset:
#if 0
/*
* set the cpu to SVC32 mode and IRQ & FIQ disable 设置CPU为SVC32模式和禁止中断
*/
mrs r0, cpsr //第二条指令,在实模式下执行
bic r0, r0, #0x3f
orr r0, r0, #0xd3
msr cpsr, r0
#else//*****ly
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr,r0
#endif
// cache_invalidate_dcache_v7 @ call cache macro
#if 1 //*****ly
cache_init:
mrc p15, 0, r0, c0, c0, 0 @ read main ID register
and r1, r0, #0x00f00000 @ variant
and r2, r0, #0x0000000f @ revision
orr r2, r2, r1, lsr #20-4 @ combine variant and revision
cmp r2, #0x30
mrceq p15, 0, r0, c1, c0, 1 @ read ACTLR
orreq r0, r0, #0x6 @ Enable DP1(2), DP2(1)
mcreq p15, 0, r0, c1, c0, 1 @ write ACTLR
/*
* Invalidate L1 I/D
*/
mov r0, #0 @ set up for MCR
mcr p15, 0, r0, c8, c7, 0 @ invalidate TLBs
mcr p15, 0, r0, c7, c5, 0 @ invalidate icache
/*
* disable MMU stuff and caches
*/
mrc p15, 0, r0, c1, c0, 0
bic r0, r0, #0x00002000 @ clear bits 13 (--V-)
bic r0, r0, #0x00000007 @ clear bits 2:0 (-CAM)
orr r0, r0, #0x00001000 @ set bit 12 (---I) Icache
orr r0, r0, #0x00000002 @ set bit 1 (--A-) Align
orr r0, r0, #0x00000800 @ set bit 11 (Z---) BTB
mcr p15, 0, r0, c1, c0, 0
#endif
|
|
|
|
|
|
|
|
楼主|
发表于 2014-11-3 23:29:29
设置CPU模式为SVC32实模式
#if 0
/*
* set the cpu to SVC32 mode and IRQ & FIQ disable
*/
mrs r0, cpsr
bic r0, r0, #0x3f
orr r0, r0, #0xd3
msr cpsr, r0
#else//*****ly
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr,r0
#endif |
|
|
|
|
|
|
|
楼主|
发表于 2014-11-3 23:37:27
/*
* These are defined in the board-specific linker script.
*/
.globl _bss_start
_bss_start:
.word __bss_start
.globl _bss_end
_bss_end:
.word _end
.macro cache_invalidate_dcache_v7
MRC p15, 1, r0, c0, c0, 1 @ read Cache Level ID register (clidr)
ANDS r3, r0, #0x7000000 @ extract level of coherency from clidr
MOV r3, r3, lsr #23 @ left align level of coherency bit field
BEQ finished_inval @ if loc is 0, then no need to clean
MOV r10, #0 @ start clean at cache level 0 (in r10)
loop_1:
ADD r2, r10, r10, lsr #1 @ work out 3x current cache level
MOV r1, r0, lsr r2 @ extract cache type bits from clidr
AND r1, r1, #7 @ mask of the bits for current cache only
CMP r1, #2 @ see what cache we have at this level
BLT skip_inval @ skip if no cache, or just i-cache
MCR p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
MOV r1, #0
MCR p15, 0, r1, c7, c5, 4 @ prefetchflush to synch the new cssr&csidr
MRC p15, 1, r1, c0, c0, 0 @ read the new csidr
AND r2, r1, #7 @ extract the length of the cache lines
ADD r2, r2, #4 @ add 4 (line length offset)
LDR r6, =0x3ff
ANDS r6, r6, r1, lsr #3 @ find maximum number on the way size
CLZ r5,r6 @ DCI 0xE16F5F16 , find bit position of way size increment
LDR r7, =0x7fff
ANDS r7, r7, r1, lsr #13 @ extract max number of the index size
loop_2:
MOV r8, r6 @ create working copy of max way size
loop_3:
ORR r11, r10, r8, lsl r5 @ factor way and cache number into r11
ORR r11, r11, r7, lsl r2 @ factor index number into r11
MCR p15, 0, r11, c7, c6, 2 @ invalidate by set/way
SUBS r8, r8, #1 @ decrement the way
BGE loop_3
SUBS r7, r7, #1 @ decrement the index
BGE loop_2
skip_inval:
ADD r10, r10, #2 @ increment cache number
CMP r3, r10
BGT loop_1
finished_inval:
.endm |
|
|
|
|
|
|
登录或注册
扫一扫关注迅为公众号
|