/*
* 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)
*/
/*
* mod by lhh
*
* Our U-Boot Memory Map with static mmu_table
* (offset)
* --------------------------
* | Stack (512KB) |
* --------------------------
* | Heap (1MB+envsize) |
* --------------------------
* | IRQ Stack (KB) | <------------------------ if exists
* --------------------------
* | FIQ Stack (KB) | <------------------------ if exists
* --------------------------
* | GBL (B) |
* -------------------------- 0x03exxxxx
* | BSS and Reserved |
* -------------------------- 0x03e60000
* | U-Boot (512KB) |
* -------------------------- 0x03e00000
*/
#include #include #if defined(CONFIG_ENABLE_MMU) #include #endif #include #ifndef CONFIG_ENABLE_MMU #ifndef CFG_PHY_UBOOT_BASE #define CFG_PHY_UBOOT_BASE CFG_UBOOT_BASE #endif /* CFG_PHY_UBOOT_BASE */ #endif /* CONFIG_ENABLE_MMU */ /* ************************************************************************* * * Jump vector table as in table 3.1 in [1] * ************************************************************************* */ #if defined(CONFIG_EVT1) && !defined(CONFIG_FUSED) .word 0x2000 .word 0x0 .word 0x0 .word 0x0 #endif /****************************************************************************** * .global关键字,相当于C语言extern,全局变量,外部可访问 * _start程序入口,即uboot代码的开始。_start后面“:”标号,类似C中goto后面标号 * _start的值就是代码的最起始,相对0的位置;跳转到reset这个标号执行,即复位向量 * ARM上电复位后,从0x00000000执行,跳转到reset,不会执行异常向量表这部分。 * * 异常向量表:未定义指令异常、软中断异常、预处理指令异常、未使用、数据异常、 * 中断异常、快速中断异常;每条占一字节,地址范围为0x0000 0000~0x0000 0020 * 设置异常向量表的作用是识别bootloader。以后系统每当有异常出现, * 则CPU会根据异常号,从内存的0x00000000处开始查表做相应的处理 *******************************************************************************/ .globl _start _start: b reset @相对跳转,不能用绝对跳转,因为启动代码有可能还运行在IRAM(s5pv210内部的SRAM) 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 @ .word伪操作,为分配一段字(4字节)内存单元 @ 用C表示:pc = *(_x) = x x=异常向量 _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: @ 这填写的只是一个初始值,填充4字节 .word 0x12345678 /* now 16*4=64 */ .global _end_vect @ 异常向量结束标号 _end_vect: @ 表示接下来的代码使用16字节对齐,不足的使用0xdeadbeef填充(坏牛肉) @ 类似的还有一个0xbadc0de 坏代码(哈哈),十六进制没有o,是数字0 .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 * ************************************************************************* */ @ 代码段基地址,boardsamsungTQ210config.mk中定义,TEXT_BASE=0x23e00000 _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 @ *(_armboot_start) = _start .globl _armboot_start _armboot_start: .word _start /* * These are defined in the board-specific linker script. */ @ 栈头和栈尾定义在链接脚本里:boardsamsungTQ210u-boot.lds .globl _bss_start _bss_start: .word __bss_start .globl _bss_end _bss_end: .word _end @ 中断的堆栈设置,在cpu_init中用到 #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 /* CONFIG_USE_IRQ */ /* * the actual reset code */ @ ARM复位执行就是这里的程序,上面那部分异常只有在异常发生才会执行 reset: /* * set the cpu to SVC32 mode and IRQ & FIQ disable */ @;mrs r0,cpsr @;bic r0,r0,#0x1f @;orr r0,r0,#0xd3 @;msr cpsr,r0 @ 置cpu到svc32模式,关闭中断;msr将0xd3写到cpsr_c 31 30 29 28 --- 7 6 - 4 3 2 1 0 说明 N Z C V I F M4 M3 M2 M1 M0 0 0 0 0 0 User模式 0 0 0 0 1 FIQ模式 0 0 0 1 0 IRQ模式 0 0 0 1 1 SVC模式 1 0 0 0 0 User模式 1 0 0 0 1 FIQ模式 1 0 0 1 0 IRQ模式 1 0 0 1 1 SVC模式 1 0 1 1 1 ABT模式 1 1 0 1 1 UND模式 msr cpsr_c, #0xd3 @ I & F disable, Mode: 0x13 - SVC 1101 0011 /* ************************************************************************* * * CPU_init_critical registers * * setup important registers * setup memory timing * ************************************************************************* */ /* * we do sys-critical inits only at reboot, * not when booting from ram! */ @ cpu初始化 cpu_init_crit: @ CONFIG_EVT1定义了,这段不执行 #ifndef CONFIG_EVT1 #if 0 bl v7_flush_dcache_all #else bl disable_l2cache mov r0, #0x0 @ mov r1, #0x0 @ i mov r3, #0x0 mov r4, #0x0 lp1: mov r2, #0x0 @ j lp2: mov r3, r1, LSL #29 @ r3 = r1(i) <<29 mov r4, r2, LSL #6 @ r4 = r2(j) <<6 orr r4, r4, #0x2 @ r3 = (i<<29)|(j<<6)|(1<<1) orr r3, r3, r4 mov r0, r3 @ r0 = r3 bl CoInvalidateDCacheIndex add r2, #0x1 @ r2(j)++ cmp r2, #1024 @ r2 < 1024 bne lp2 @ jump to lp2 add r1, #0x1 @ r1(i)++ cmp r1, #8 @ r1(i) < 8 bne lp1 @ jump to lp1 bl set_l2cache_auxctrl bl enable_l2cache #endif #endif bl disable_l2cache @ 关闭I/D-cache bl set_l2cache_auxctrl_cycle bl enable_l2cache @ 使能I/D-cache /* * Invalidate L1 I/D */ @ ARM Architecture Reference Manual.pdf的745页有例子,可以搜索CP15 @ CP15 —系统控制协处理器 (the system control coprocessor) @ 通过协处理器指令MCR和MRC提供具体的寄存器来配置和控制caches、MMU、保护系统、配置时钟模式(在bootloader时钟初始化用到) @ Register 7 - Cache control Register 8 - TLB operations mov r0, #0 @ set up for MCR mcr p15, 0, r0, c8, c7, 0 @ invalidate TLBs 关闭TLB 缓冲页表(虚拟机地址转物理地址的表)的cache mcr p15, 0, r0, c7, c5, 0 @ invalidate icache icache 缓冲指令的I-cache /* * disable MMU stuff and caches */ @ 关闭MMU和cache --- 分析cp15的寄存器1 mrc p15, 0, r0, c1, c0, 0
上一篇:TQ210 —— s5pv210 lowlevel_init.S分析(uboot第一阶段)
下一篇:TQ210 —— S5PV210 gboot设计
设计资源 培训 开发板 精华推荐
- CGD和Qorvo将共同革新电机控制解决方案
- 是德科技 FieldFox 手持式分析仪配合 VDI 扩频模块,实现毫米波分析功能
- 贸泽开售可精确测量CO2水平的 英飞凌PASCO2V15 XENSIV PAS CO2 5V传感器
- 玩法进阶,浩亭让您的PCB板端连接达到新高度!
- 长城汽车研发新篇章:固态电池技术引领未来
- 纳芯微提供全场景GaN驱动IC解决方案
- 解读华为固态电池新专利,2030 叫板宁德时代?
- 让纯电/插混车抓狂?中企推全球首款-40℃可放电增混电池,不怕冷
- 智驾域控知多少:中低端车型加速上车,行泊一体方案占主体
- Foresight推出六款先进立体传感器套件 彻底改变工业和汽车3D感知