mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-29 22:51:49 +01:00
sparc: Update startup code to take PIC mode into account
Signed-off-by: Francois Retief <fgretief@spaceteq.co.za>
This commit is contained in:
parent
b6b280ce07
commit
0070109f68
@ -57,6 +57,27 @@ MINFRAME = (WINDOWSIZE + ARGPUSHSIZE + 4)
|
|||||||
#error Must define number of SPARC register windows, default is 8
|
#error Must define number of SPARC register windows, default is 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Macros to load address into a register. Uses GOT table for PIC */
|
||||||
|
#ifdef __PIC__
|
||||||
|
|
||||||
|
#define SPARC_PIC_THUNK_CALL(reg) \
|
||||||
|
sethi %pc22(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
|
||||||
|
call __sparc_get_pc_thunk.reg; \
|
||||||
|
add %##reg, %pc10(_GLOBAL_OFFSET_TABLE_+4), %##reg;
|
||||||
|
|
||||||
|
#define SPARC_LOAD_ADDRESS(sym, got, reg) \
|
||||||
|
sethi %gdop_hix22(sym), %##reg; \
|
||||||
|
xor %##reg, %gdop_lox10(sym), %##reg; \
|
||||||
|
ld [%##got + %##reg], %##reg, %gdop(sym);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define SPARC_PIC_THUNK_CALL(reg)
|
||||||
|
#define SPARC_LOAD_ADDRESS(sym, got, tmp) \
|
||||||
|
set sym, %##reg;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STACK_ALIGN 8
|
#define STACK_ALIGN 8
|
||||||
#define SA(X) (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1))
|
#define SA(X) (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1))
|
||||||
|
|
||||||
@ -278,7 +299,7 @@ leon2_init_mctrl:
|
|||||||
srl %g2, 30, %g2
|
srl %g2, 30, %g2
|
||||||
andcc %g2, 3, %g6
|
andcc %g2, 3, %g6
|
||||||
bne,a leon2_init_wim
|
bne,a leon2_init_wim
|
||||||
mov %g0, %asr16 ! clear err_reg
|
mov %g0, %asr16 ! clear err_reg
|
||||||
|
|
||||||
leon2_init_wim:
|
leon2_init_wim:
|
||||||
set WIM_INIT, %g3
|
set WIM_INIT, %g3
|
||||||
@ -299,7 +320,7 @@ leon2_init_stackp:
|
|||||||
|
|
||||||
cpu_init_unreloc:
|
cpu_init_unreloc:
|
||||||
call cpu_init_f
|
call cpu_init_f
|
||||||
nop
|
nop
|
||||||
|
|
||||||
/* un relocated start address of monitor */
|
/* un relocated start address of monitor */
|
||||||
#define TEXT_START _text
|
#define TEXT_START _text
|
||||||
@ -307,9 +328,10 @@ cpu_init_unreloc:
|
|||||||
/* un relocated end address of monitor */
|
/* un relocated end address of monitor */
|
||||||
#define DATA_END __init_end
|
#define DATA_END __init_end
|
||||||
|
|
||||||
|
SPARC_PIC_THUNK_CALL(l7)
|
||||||
reloc:
|
reloc:
|
||||||
set TEXT_START,%g2
|
SPARC_LOAD_ADDRESS(TEXT_START, l7, g2)
|
||||||
set DATA_END,%g3
|
SPARC_LOAD_ADDRESS(DATA_END, l7, g3)
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%g4
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%g4
|
||||||
reloc_loop:
|
reloc_loop:
|
||||||
ldd [%g2],%l0
|
ldd [%g2],%l0
|
||||||
@ -319,7 +341,7 @@ reloc_loop:
|
|||||||
inc 16,%g2
|
inc 16,%g2
|
||||||
subcc %g3,%g2,%g0
|
subcc %g3,%g2,%g0
|
||||||
bne reloc_loop
|
bne reloc_loop
|
||||||
inc 16,%g4
|
inc 16,%g4
|
||||||
|
|
||||||
clr %l0
|
clr %l0
|
||||||
clr %l1
|
clr %l1
|
||||||
@ -336,8 +358,8 @@ reloc_loop:
|
|||||||
|
|
||||||
clr_bss:
|
clr_bss:
|
||||||
/* clear bss area (the relocated) */
|
/* clear bss area (the relocated) */
|
||||||
set __bss_start,%g2
|
SPARC_LOAD_ADDRESS(__bss_start, l7, g2)
|
||||||
set __bss_end,%g3
|
SPARC_LOAD_ADDRESS(__bss_end, l7, g3)
|
||||||
sub %g3,%g2,%g3
|
sub %g3,%g2,%g3
|
||||||
add %g3,%g4,%g3
|
add %g3,%g4,%g3
|
||||||
clr %g1 /* std %g0 uses g0 and g1 */
|
clr %g1 /* std %g0 uses g0 and g1 */
|
||||||
@ -348,19 +370,19 @@ clr_bss_16:
|
|||||||
inc 16,%g4
|
inc 16,%g4
|
||||||
cmp %g3,%g4
|
cmp %g3,%g4
|
||||||
bne clr_bss_16
|
bne clr_bss_16
|
||||||
nop
|
nop
|
||||||
|
|
||||||
/* add offsets to GOT table */
|
/* add offsets to GOT table */
|
||||||
fixup_got:
|
fixup_got:
|
||||||
set __got_start,%g4
|
SPARC_LOAD_ADDRESS(__got_start, l7, g4)
|
||||||
set __got_end,%g3
|
SPARC_LOAD_ADDRESS(__got_end, l7, g3)
|
||||||
/*
|
/*
|
||||||
* new got offset = (old GOT-PTR (read with ld) -
|
* new got offset = (old GOT-PTR (read with ld) -
|
||||||
* CONFIG_SYS_RELOC_MONITOR_BASE(from define) ) +
|
* CONFIG_SYS_RELOC_MONITOR_BASE(from define) ) +
|
||||||
* Destination Address (from define)
|
* Destination Address (from define)
|
||||||
*/
|
*/
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%g2
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%g2
|
||||||
set TEXT_START, %g1
|
SPARC_LOAD_ADDRESS(TEXT_START, l7, g1)
|
||||||
add %g4,%g2,%g4
|
add %g4,%g2,%g4
|
||||||
sub %g4,%g1,%g4
|
sub %g4,%g1,%g4
|
||||||
add %g3,%g2,%g3
|
add %g3,%g2,%g3
|
||||||
@ -375,11 +397,11 @@ got_loop:
|
|||||||
inc 4,%g4
|
inc 4,%g4
|
||||||
cmp %g3,%g4
|
cmp %g3,%g4
|
||||||
bne got_loop
|
bne got_loop
|
||||||
nop
|
nop
|
||||||
|
|
||||||
prom_relocate:
|
prom_relocate:
|
||||||
set __prom_start, %g2
|
SPARC_LOAD_ADDRESS(__prom_start, l7, g2)
|
||||||
set __prom_end, %g3
|
SPARC_LOAD_ADDRESS(__prom_end, l7, g3)
|
||||||
set CONFIG_SYS_PROM_OFFSET, %g4
|
set CONFIG_SYS_PROM_OFFSET, %g4
|
||||||
|
|
||||||
prom_relocate_loop:
|
prom_relocate_loop:
|
||||||
@ -390,7 +412,7 @@ prom_relocate_loop:
|
|||||||
inc 16,%g2
|
inc 16,%g2
|
||||||
subcc %g3,%g2,%g0
|
subcc %g3,%g2,%g0
|
||||||
bne prom_relocate_loop
|
bne prom_relocate_loop
|
||||||
inc 16,%g4
|
inc 16,%g4
|
||||||
|
|
||||||
/* Trap table has been moved, lets tell CPU about
|
/* Trap table has been moved, lets tell CPU about
|
||||||
* the new trap table address
|
* the new trap table address
|
||||||
@ -403,19 +425,19 @@ prom_relocate_loop:
|
|||||||
nop
|
nop
|
||||||
/* Call relocated init functions */
|
/* Call relocated init functions */
|
||||||
jump:
|
jump:
|
||||||
set cpu_init_f2,%o1
|
SPARC_LOAD_ADDRESS(cpu_init_f2, l7, o1)
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
||||||
add %o1,%o2,%o1
|
add %o1,%o2,%o1
|
||||||
sub %o1,%g1,%o1
|
sub %o1,%g1,%o1
|
||||||
call %o1
|
call %o1
|
||||||
clr %o0
|
clr %o0
|
||||||
|
|
||||||
set board_init_f,%o1
|
SPARC_LOAD_ADDRESS(board_init_f, l7, o1)
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
||||||
add %o1,%o2,%o1
|
add %o1,%o2,%o1
|
||||||
sub %o1,%g1,%o1
|
sub %o1,%g1,%o1
|
||||||
call %o1
|
call %o1
|
||||||
clr %o0
|
clr %o0
|
||||||
|
|
||||||
dead: ta 0 ! if call returns...
|
dead: ta 0 ! if call returns...
|
||||||
nop
|
nop
|
||||||
|
|||||||
@ -57,6 +57,27 @@ MINFRAME = (WINDOWSIZE + ARGPUSHSIZE + 4)
|
|||||||
#error Must define number of SPARC register windows, default is 8
|
#error Must define number of SPARC register windows, default is 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Macros to load address into a register. Uses GOT table for PIC */
|
||||||
|
#ifdef __PIC__
|
||||||
|
|
||||||
|
#define SPARC_PIC_THUNK_CALL(reg) \
|
||||||
|
sethi %pc22(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
|
||||||
|
call __sparc_get_pc_thunk.reg; \
|
||||||
|
add %##reg, %pc10(_GLOBAL_OFFSET_TABLE_+4), %##reg;
|
||||||
|
|
||||||
|
#define SPARC_LOAD_ADDRESS(sym, got, reg) \
|
||||||
|
sethi %gdop_hix22(sym), %##reg; \
|
||||||
|
xor %##reg, %gdop_lox10(sym), %##reg; \
|
||||||
|
ld [%##got + %##reg], %##reg, %gdop(sym);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define SPARC_PIC_THUNK_CALL(reg)
|
||||||
|
#define SPARC_LOAD_ADDRESS(sym, got, tmp) \
|
||||||
|
set sym, %##reg;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STACK_ALIGN 8
|
#define STACK_ALIGN 8
|
||||||
#define SA(X) (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1))
|
#define SA(X) (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1))
|
||||||
|
|
||||||
@ -229,7 +250,7 @@ clear_window:
|
|||||||
bge clear_window
|
bge clear_window
|
||||||
save
|
save
|
||||||
|
|
||||||
wininit:
|
wiminit:
|
||||||
set WIM_INIT, %g3
|
set WIM_INIT, %g3
|
||||||
mov %g3, %wim
|
mov %g3, %wim
|
||||||
|
|
||||||
@ -240,7 +261,7 @@ stackp:
|
|||||||
|
|
||||||
cpu_init_unreloc:
|
cpu_init_unreloc:
|
||||||
call cpu_init_f
|
call cpu_init_f
|
||||||
nop
|
nop
|
||||||
|
|
||||||
/* un relocated start address of monitor */
|
/* un relocated start address of monitor */
|
||||||
#define TEXT_START _text
|
#define TEXT_START _text
|
||||||
@ -248,9 +269,10 @@ cpu_init_unreloc:
|
|||||||
/* un relocated end address of monitor */
|
/* un relocated end address of monitor */
|
||||||
#define DATA_END __init_end
|
#define DATA_END __init_end
|
||||||
|
|
||||||
|
SPARC_PIC_THUNK_CALL(l7)
|
||||||
reloc:
|
reloc:
|
||||||
set TEXT_START,%g2
|
SPARC_LOAD_ADDRESS(TEXT_START, l7, g2)
|
||||||
set DATA_END,%g3
|
SPARC_LOAD_ADDRESS(DATA_END, l7, g3)
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%g4
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%g4
|
||||||
reloc_loop:
|
reloc_loop:
|
||||||
ldd [%g2],%l0
|
ldd [%g2],%l0
|
||||||
@ -260,7 +282,7 @@ reloc_loop:
|
|||||||
inc 16,%g2
|
inc 16,%g2
|
||||||
subcc %g3,%g2,%g0
|
subcc %g3,%g2,%g0
|
||||||
bne reloc_loop
|
bne reloc_loop
|
||||||
inc 16,%g4
|
inc 16,%g4
|
||||||
|
|
||||||
clr %l0
|
clr %l0
|
||||||
clr %l1
|
clr %l1
|
||||||
@ -277,8 +299,8 @@ reloc_loop:
|
|||||||
|
|
||||||
clr_bss:
|
clr_bss:
|
||||||
/* clear bss area (the relocated) */
|
/* clear bss area (the relocated) */
|
||||||
set __bss_start,%g2
|
SPARC_LOAD_ADDRESS(__bss_start, l7, g2)
|
||||||
set __bss_end,%g3
|
SPARC_LOAD_ADDRESS(__bss_end, l7, g3)
|
||||||
sub %g3,%g2,%g3
|
sub %g3,%g2,%g3
|
||||||
add %g3,%g4,%g3
|
add %g3,%g4,%g3
|
||||||
clr %g1 /* std %g0 uses g0 and g1 */
|
clr %g1 /* std %g0 uses g0 and g1 */
|
||||||
@ -289,19 +311,19 @@ clr_bss_16:
|
|||||||
inc 16,%g4
|
inc 16,%g4
|
||||||
cmp %g3,%g4
|
cmp %g3,%g4
|
||||||
bne clr_bss_16
|
bne clr_bss_16
|
||||||
nop
|
nop
|
||||||
|
|
||||||
/* add offsets to GOT table */
|
/* add offsets to GOT table */
|
||||||
fixup_got:
|
fixup_got:
|
||||||
set __got_start,%g4
|
SPARC_LOAD_ADDRESS(__got_start, l7, g4)
|
||||||
set __got_end,%g3
|
SPARC_LOAD_ADDRESS(__got_end, l7, g3)
|
||||||
/*
|
/*
|
||||||
* new got offset = (old GOT-PTR (read with ld) -
|
* new got offset = (old GOT-PTR (read with ld) -
|
||||||
* CONFIG_SYS_RELOC_MONITOR_BASE(from define) ) +
|
* CONFIG_SYS_RELOC_MONITOR_BASE(from define) ) +
|
||||||
* Destination Address (from define)
|
* Destination Address (from define)
|
||||||
*/
|
*/
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%g2
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%g2
|
||||||
set TEXT_START, %g1
|
SPARC_LOAD_ADDRESS(TEXT_START, l7, g1)
|
||||||
add %g4,%g2,%g4
|
add %g4,%g2,%g4
|
||||||
sub %g4,%g1,%g4
|
sub %g4,%g1,%g4
|
||||||
add %g3,%g2,%g3
|
add %g3,%g2,%g3
|
||||||
@ -316,11 +338,11 @@ got_loop:
|
|||||||
inc 4,%g4
|
inc 4,%g4
|
||||||
cmp %g3,%g4
|
cmp %g3,%g4
|
||||||
bne got_loop
|
bne got_loop
|
||||||
nop
|
nop
|
||||||
|
|
||||||
prom_relocate:
|
prom_relocate:
|
||||||
set __prom_start, %g2
|
SPARC_LOAD_ADDRESS(__prom_start, l7, g2)
|
||||||
set __prom_end, %g3
|
SPARC_LOAD_ADDRESS(__prom_end, l7, g3)
|
||||||
set CONFIG_SYS_PROM_OFFSET, %g4
|
set CONFIG_SYS_PROM_OFFSET, %g4
|
||||||
|
|
||||||
prom_relocate_loop:
|
prom_relocate_loop:
|
||||||
@ -331,7 +353,7 @@ prom_relocate_loop:
|
|||||||
inc 16,%g2
|
inc 16,%g2
|
||||||
subcc %g3,%g2,%g0
|
subcc %g3,%g2,%g0
|
||||||
bne prom_relocate_loop
|
bne prom_relocate_loop
|
||||||
inc 16,%g4
|
inc 16,%g4
|
||||||
|
|
||||||
/* Trap table has been moved, lets tell CPU about
|
/* Trap table has been moved, lets tell CPU about
|
||||||
* the new trap table address
|
* the new trap table address
|
||||||
@ -358,19 +380,19 @@ snoop_detect:
|
|||||||
nop
|
nop
|
||||||
/* Call relocated init functions */
|
/* Call relocated init functions */
|
||||||
jump:
|
jump:
|
||||||
set cpu_init_f2,%o1
|
SPARC_LOAD_ADDRESS(cpu_init_f2, l7, o1)
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
||||||
add %o1,%o2,%o1
|
add %o1,%o2,%o1
|
||||||
sub %o1,%g1,%o1
|
sub %o1,%g1,%o1
|
||||||
call %o1
|
call %o1
|
||||||
clr %o0
|
clr %o0
|
||||||
|
|
||||||
set board_init_f,%o1
|
SPARC_LOAD_ADDRESS(board_init_f, l7, o1)
|
||||||
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
set CONFIG_SYS_RELOC_MONITOR_BASE,%o2
|
||||||
add %o1,%o2,%o1
|
add %o1,%o2,%o1
|
||||||
sub %o1,%g1,%o1
|
sub %o1,%g1,%o1
|
||||||
call %o1
|
call %o1
|
||||||
clr %o0
|
clr %o0
|
||||||
|
|
||||||
dead: ta 0 ! if call returns...
|
dead: ta 0 ! if call returns...
|
||||||
nop
|
nop
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user