arm9 中断向量 重定位_arm9_u-boot-2012.4.1分析

void board_init_f(ulongbootflag)

{

bd_t*bd;

init_fnc_t**init_fnc_ptr;

gd_t*id;ulongaddr, addr_sp;

#ifdef CONFIG_PRAMulongreg;#endifbootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F,"board_init_f");/*Pointer is writable since we allocated a register for it*/gd= (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);/*compiler optimization barrier needed for GCC >= 3.4*/__asm__ __volatile__("": : :"memory");

memset((void *)gd, 0, sizeof(gd_t));

gd->mon_len =_bss_end_ofs;

#ifdef CONFIG_OF_EMBED/*Get a pointer to the FDT*/gd->fdt_blob =_binary_dt_dtb_start;#elif defined CONFIG_OF_SEPARATE

/*FDT is at end of image*/gd->fdt_blob = (void *)(_end_ofs +_TEXT_BASE);#endif

/*Allow the early environment to override the fdt address*/gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,

(uintptr_t)gd->fdt_blob);for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {if ((*init_fnc_ptr)() != 0) {

hang ();

}

}

#ifdef CONFIG_OF_CONTROL/*For now, put this check after the console is ready*/

if(fdtdec_prepare_fdt()) {

panic("** CONFIG_OF_CONTROL defined but no FDT - please see"

"doc/README.fdt-control");

}#endifdebug("monitor len: %08lX\n", gd->mon_len);/** Ram is setup, size stored in gd !!*/debug("ramsize: %08lX\n", gd->ram_size);#if defined(CONFIG_SYS_MEM_TOP_HIDE)

/** Subtract specified amount of memory to hide so that it won't

* get "touched" at all by U-Boot. By fixing up gd->ram_size

* the Linux kernel should now get passed the now "corrected"

* memory size and won't touch it either. This should work

* for arch/ppc and arch/powerpc. Only Linux board ports in

* arch/powerpc with bootwrapper support, that recalculate the

* memory size from the SDRAM controller setup will have to

* get fixed.*/gd->ram_size -=CONFIG_SYS_MEM_TOP_HIDE;#endifaddr= CONFIG_SYS_SDRAM_BASE + gd->ram_size;

#ifdef CONFIG_LOGBUFFER

#ifndef CONFIG_ALT_LB_ADDR/*reserve kernel log buffer*/addr-=(LOGBUFF_RESERVE);

debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,

addr);#endif

#endif#ifdef CONFIG_PRAM/** reserve protected RAM*/reg= getenv_ulong("pram", 10, CONFIG_PRAM);

addr-= (reg << 10); /*size is in kB*/debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr);#endif /* CONFIG_PRAM */

#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))

/*reserve TLB table*/addr-= (4096 * 4);/*round down to next 64 kB limit*/addr&= ~(0x10000 - 1);

gd->tlb_addr =addr;

debug("TLB table at: %08lx\n", addr);#endif

/*round down to next 4 kB limit*/addr&= ~(4096 - 1);

debug("Top of RAM usable for U-Boot at: %08lx\n", addr);

#ifdef CONFIG_LCD

#ifdef CONFIG_FB_ADDR

gd->fb_base =CONFIG_FB_ADDR;#else

/*reserve memory for LCD display (always full pages)*/addr=lcd_setmem(addr);

gd->fb_base =addr;#endif /* CONFIG_FB_ADDR */

#endif /* CONFIG_LCD */

/** reserve memory for U-Boot code, data & bss

* round down to next 4 kB limit*/addr-= gd->mon_len;

addr&= ~(4096 - 1);

debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);

#ifndef CONFIG_SPL_BUILD/** reserve memory for malloc() arena*/addr_sp= addr -TOTAL_MALLOC_LEN;

debug("Reserving %dk for malloc() at: %08lx\n",

TOTAL_MALLOC_LEN>> 10, addr_sp);/** (permanently) allocate a Board Info struct

* and a permanent copy of the "global" data*/addr_sp-= sizeof(bd_t);

bd= (bd_t *) addr_sp;

gd->bd =bd;

debug("Reserving %zu Bytes for Board Info at: %08lx\n",sizeof(bd_t), addr_sp);

#ifdef CONFIG_MACH_TYPE

gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /*board id for Linux*/

#endifaddr_sp-= sizeof(gd_t);

id= (gd_t *) addr_sp;

debug("Reserving %zu Bytes for Global Data at: %08lx\n",sizeof(gd_t), addr_sp);/*setup stackpointer for exeptions*/gd->irq_sp =addr_sp;

#ifdef CONFIG_USE_IRQ

addr_sp-= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);

debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",

CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);#endif

/*leave 3 words for abort-stack*/addr_sp-= 12;/*8-byte alignment for ABI compliance*/addr_sp&= ~0x07;#elseaddr_sp+= 128; /*leave 32 words for abort-stack*/gd->irq_sp =addr_sp;#endifdebug("New Stack Pointer is: %08lx\n", addr_sp);

#ifdef CONFIG_POST

post_bootmode_init();

post_run(NULL, POST_ROM| post_bootmode_get(0));#endifgd->bd->bi_baudrate = gd->baudrate;/*Ram ist board specific, so move it to board code ...*/dram_init_banksize();

display_dram_config();/*and display it*/gd->relocaddr =addr;

gd->start_addr_sp =addr_sp;

gd->reloc_off = addr -_TEXT_BASE;

debug("relocation Offset is: %08lx\n", gd->reloc_off);

memcpy(id, (void *)gd, sizeof(gd_t));

relocate_code(addr_sp, id, addr);/*NOTREACHED - relocate_code() does not return*/}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值