汇编语言:是声明全局变量
.globl _end_ofs
_end_ofs:
.word _end - _start
c语言:声明这个变量,然后再调用这个变量
void board_init_r(gd_t *id, ulong dest_addr)
{
...............
monitor_flash_len = _end_ofs;//_end_ofs在别的头文件里声明了,所以这个函数就不用再声明
....................
}
-----------------------------------------------------------------------------------------
汇编:
.globl base_sp //定义并声明base_sp,并初始化为0
base_sp:
.long 0
.........
ldr sp ,base_sp //重新设置栈
......
c语言:
void board_init_f(ulong bootflag)
{
extern ulong base_sp; //在c语言里使用汇编申请的全局变量之前要声明
.........
#else
addr_sp += 128; /* leave 32 words for abort-stack */
gd->irq_sp = addr_sp;
#endif
debug("New Stack Pointer is: %08lx ", addr_sp);//addr_sp这是board_init_f函数的最后的栈值
#ifdef CONFIG_POST
post_bootmode_init();
post_run(NULL, POST_ROM | post_bootmode_get(0));
#endif
gd->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 ", gd->reloc_off);
memcpy(id, (void *)gd, sizeof(gd_t));
base_sp = addr_sp; //把board_init_f函数的最后的栈值,传递给汇编
}