init.S (board\samsung\smdk6410)(5)

 *************************************************************************
 
_TEXT_BASE:
.wordTEXT_BASE

这个会在board\samsung\smdk6410\config.mk文件中给出。如下所示:

ifndef TEXT_BASE
TEXT_BASE = 0xc7e00000
endif
--------------------------------------------------------------------------------------------------------------
/*
 * 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:
.wordCFG_PHY_UBOOT_BASE

这个在第一篇中有说:

所以上面的CFG_PHY_UBOOT_BASE为0x57e00000

          CFG_UBOOT_BASE为0xc7e00000

--------------------------------------------------------------------------

.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

这些在链接脚本中有定义,如下所示:

. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
_end = .;
}
----------------------------------------------------------------------------------------------------

#ifdef CONFIG_USE_IRQ  

这个我们上一篇也说过,我们没定义#undef CONFIG_USE_IRQ/* we don't need IRQ/FIQ stuff */
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
IRQ_STACK_START:
.word0x0badc0de


/* IRQ stack memory (calculated at run-time) */
.globl FIQ_STACK_START
FIQ_STACK_START:
.word 0x0badc0de
#endif
----------------------------------------------------------------------------------------------------------
/*
 * the actual reset code
 */

reset:
/*
* set the cpu to SVC32 mode
*/
mrsr0,cpsr
bicr0,r0,#0x1f
orrr0,r0,#0xd3
msrcpsr,r0

 *************************************************************************

/*
 *************************************************************************
 *
 * CPU_init_critical registers
 *
 * setup important registers
 * setup memory timing

 *
 *************************************************************************
 */
         /*
         * we do sys-critical inits only at reboot,
         * not when booting from ram!
         */
cpu_init_crit:
/*
* flush v4 I/D caches
*/
movr0, #0
mcrp15, 0, r0, c7, c7, 0/* flush v3/v4 cache */
mcrp15, 0, r0, c8, c7, 0/* flush v4 TLB */


/*
* disable MMU stuff and caches
*/
mrcp15, 0, r0, c1, c0, 0
bicr0, r0, #0x00002300@ clear bits 13, 9:8 (--V- --RS)
bicr0, r0, #0x00000087@ clear bits 7, 2:0 (B--- -CAM)
orrr0, r0, #0x00000002@ set bit 2 (A) Align
orrr0, r0, #0x00001000@ set bit 12 (I) I-Cache
mcrp15, 0, r0, c1, c0, 0

上面这些就不说了,很多文章都有说。
------------------------------------------------------------------------------------------------------------

/* Peri port setup */
ldrr0, =0x70000000
orrr0, r0, #0x13
    mcrp15,0,r0,c15,c2,4       @ 256M(0x70000000-0x7fffffff)

这个以前说过,我有一篇博客专门讲的是这个。

-------------------------------------------------------------------------------------------------------------

/*
* Go setup Memory and board specific bits prior to relocation.
*/
bllowlevel_init/* go setup pll,mux,memory */

这一部分,我在另外几篇博客中对这个文件进行了详细的说明,这里就不说了。

-------------------------------------------------------------------------------------------------------------------

/* when we already run in ram, we don't need to relocate U-Boot.
* and actually, memory controller must be configured before U-Boot
* is running in ram. 判断U-boot现在运行的地方,是ram吗?判断的方法就是把当前PC的地址和_TEXT_BASE的值做些处理之后,进行比较,是否相同。

*/
ldrr0, =0xff000fff
bicr1, pc, r0/* r0 <- current base addr of code */
ldrr2, _TEXT_BASE/* r1 <- original base addr in ram */
bicr2, r2, r0/* r0 <- current base addr of code */
cmp     r1, r2                  /* compare r0, r1                  */
beq     after_copy/* r0 == r1 then skip flash copy   */

---------------------------------------------------------------------------------------------------------------------

#ifdef CONFIG_BOOT_NAND
movr0, #0x1000
blcopy_from_nand
#endif

其中copy_from_nand的源码如下所示:

/*

 * copy U-Boot to SDRAM and jump to ram (from NAND or OneNAND)
 * r0: size to be compared
 * Load 1'st 2blocks to RAM because U-boot's size is larger than 1block(128k) size
 */
.globl copy_from_nand
copy_from_nand:
movr10, lr/*save return address*/

movr9, r0
/* get ready to call C functions */
ldrsp, _TEXT_PHY_BASE/* setup temp stack pointer */

其中有如下定义:

_TEXT_PHY_BASE:
.wordCFG_PHY_UBOOT_BASE


subsp, sp, #12
movfp, #0/* no previous frame, so fp=0 */   这里不太懂fp是什么
movr9, #0x1000
blcopy_uboot_to_ram

copy_uboot_to_ram是个C语言写的函数,在Nand_cp.c (cpu\s3c64xx)文件中,源码如下所示:

-------------------------------------------------------------------------------------------------------------------------------

copy_uboot_to_ram的源码:

int copy_uboot_to_ram (void)
{
int large_block = 0;
int i;
vu_char id;

        NAND_ENABLE_CE();  使能NAND

----------------------------------------------------------------------------------------------------------------------------

其中有:

#define NAND_ENABLE_CE()(NFCONT_REG &= ~(1 << 1))

#define NFCONT_REG__REG(ELFIN_NAND_BASE+NFCONT_OFFSET)

#define __REG(x)(*(vu_long *)(x))

#define ELFIN_NAND_BASE0x70200000

#define NFCONT_OFFSET           0x04


init.S (board\samsung\smdk6410)


----------------------------------------------------------------------------------------------------------------------------
        NFCMD_REG = NAND_CMD_READID;
        NFADDR_REG =  0x00;

-----------------------------------------------------------------------------

其中有:

#define NFCMD_REG__REG(ELFIN_NAND_BASE+NFCMMD_OFFSET)



#define NAND_CMD_READID0x90

90 ID : Access command = 90H(NAND手册)

init.S (board\samsung\smdk6410)



------------------------------------------------------------------------

#define NFADDR_REG           __REG(ELFIN_NAND_BASE+NFADDR_OFFSET)


----------------------------------------------------------------------------------------------------------------------------------
/* wait for a while */
        for (i=0; i<200; i++);

-------------------------------------------------------------------------------------------------------------------------------
id = NFDATA8_REG;
id = NFDATA8_REG;

-------------------------------------------------------
其中有:

#define NFDATA8_REG          __REGb(ELFIN_NAND_BASE+NFDATA_OFFSET)


init.S (board\samsung\smdk6410)



-------------------------------------------------------------------------------------------------------------------------------

if (id > 0x80)
large_block = 1;
if(id == 0xd5)
large_block = 2;   对读出了ID进行判断,得出page(页)大小
-------------------------------------------------------------------------------------------------------------------------------

/* read NAND Block.
* 128KB ->240KB because of U-Boot size increase. by scsuh
* So, read 0x3c000 bytes not 0x20000(128KB).
*/
return nandll_read_blocks(CFG_PHY_UBOOT_BASE, 0x3c000, large_block);
}
上面这个函数的内容,下篇博客在说。
--------------------------------------------------------------------------------------------------------------------
3:tst r0, #0x0
bnecopy_failed


ldrr0, =0x0c000000
ldrr1, _TEXT_PHY_BASE
1:ldrr3, [r0], #4
ldrr4, [r1], #4
teqr3, r4
bnecompare_failed/* not matched */
subsr9, r9, #4
bne1b


4:movlr, r10/* all is OK */
movpc, lr


copy_failed:
nop/* copy from nand failed */
bcopy_failed


compare_failed:
nop/* compare failed */
bcompare_failed

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/psfpz.html