9
0
Fork 0

ARM lowlevel: Use get_runtime_offset

The current approach to get the offset between link and runtime address
is fragile. It requires a big fat comment to put no code above it and it
requires an extra linker section. Instead use a small assembler function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2012-09-06 22:32:10 +02:00
parent cc27564e4c
commit 2e368eec07
5 changed files with 6 additions and 23 deletions

View File

@ -152,23 +152,17 @@ static void barebox_uncompress(void *compressed_start, unsigned int len)
* Board code can jump here by either returning from board_init_lowlevel
* or by calling this function directly.
*/
void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
void __naked board_init_lowlevel_return(void)
{
uint32_t r, addr, offset;
uint32_t r, offset;
uint32_t pg_start, pg_end, pg_len;
/*
* Get runtime address of this function. Do not
* put any code above this.
*/
__asm__ __volatile__("1: adr %0, 1b":"=r"(addr));
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__("mov sp, %0" : : "r"(r));
/* Get offset between linked address and runtime address */
offset = (uint32_t)__ll_return - addr;
offset = get_runtime_offset();
pg_start = (uint32_t)&input_data - offset;
pg_end = (uint32_t)&input_data_end - offset;

View File

@ -59,22 +59,16 @@ void __naked __section(.text_entry) start(void)
* Board code can jump here by either returning from board_init_lowlevel
* or by calling this function directly.
*/
void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
void __naked board_init_lowlevel_return(void)
{
uint32_t r, addr, offset;
/*
* Get runtime address of this function. Do not
* put any code above this.
*/
__asm__ __volatile__("1: adr %0, 1b":"=r"(addr));
uint32_t r, offset;
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__("mov sp, %0" : : "r"(r));
/* Get offset between linked address and runtime address */
offset = (uint32_t)__ll_return - addr;
offset = get_runtime_offset();
/* relocate to link address if necessary */
if (offset)

View File

@ -37,7 +37,6 @@ int board_init(void);
int dram_init (void);
extern char __exceptions_start[], __exceptions_stop[];
extern char __ll_return[];
void board_init_lowlevel(void);
void board_init_lowlevel_return(void);

View File

@ -40,8 +40,6 @@ SECTIONS
_stext = .;
_text = .;
*(.text_entry*)
__ll_return = .;
*(.text_ll_return*)
__bare_init_start = .;
*(.text_bare_init*)
__bare_init_end = .;

View File

@ -39,8 +39,6 @@ SECTIONS
_stext = .;
_text = .;
*(.text_head_entry*)
__ll_return = .;
*(.text_ll_return*)
__bare_init_start = .;
*(.text_bare_init*)
__bare_init_end = .;