How to invoke variables in the assembly in C language.
Assembly language: Declaring a global variable
. Globl _end_ofs
_end_ofs:
. Word _end-_start
C language: Declare the variable, and then call the variable
void Board_init_r (gd_t *id, ulong dest_addr)
{
...............
Monitor_flash_len = _end_ofs;//_end_ofs is declared in another header file, so this function does not have to be declared
....................
}
-----------------------------------------------------------------------------------------
Usage:The stack address in C language is passed to the Assembly (when porting uboot, it may be used)
Assembly:
. Globl base_sp//define and declare base_sp and initialize to 0
BASE_SP:
. Long 0
.........
Ldr SP, BASE_SP//Reset Stack
......
C Language:
void Board_init_f (ULONG bootflag)
{
extern ulong base_sp; To declare a global variable that uses a compilation request in C language
.........
#else
ADDR_SP + 128; /* Leave words for abort-stack * *
GD->IRQ_SP = addr_sp;
#endif
Debug ("New stack pointer is:%08lx\n", addr_sp)//addr_sp This is the last stack value of the Board_init_f function
#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\n", Gd->reloc_off);
memcpy (ID, (void *) GD, sizeof (gd_t));
base_sp = addr_sp; Pass the last stack value of the Board_init_f function to the Assembly
}