forked from Mirrors/opensbi
firmware: fw_base.S: Simplify address get
Simplify address get and remove _link_start _link_end _load_start. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -63,17 +63,11 @@ _try_lottery:
|
|||||||
amoadd.w a6, a7, (a6)
|
amoadd.w a6, a7, (a6)
|
||||||
bnez a6, _wait_relocate_copy_done
|
bnez a6, _wait_relocate_copy_done
|
||||||
|
|
||||||
/* Save load address */
|
|
||||||
lla t0, _load_start
|
|
||||||
lla t1, _fw_start
|
|
||||||
REG_S t1, 0(t0)
|
|
||||||
|
|
||||||
#ifdef FW_PIC
|
#ifdef FW_PIC
|
||||||
/* relocate the global table content */
|
/* relocate the global table content */
|
||||||
lla t0, _link_start
|
li t0, FW_TEXT_START /* link start */
|
||||||
REG_L t0, 0(t0)
|
lla t1, _fw_start /* load start */
|
||||||
/* t1 shall has the address of _fw_start */
|
sub t2, t1, t0 /* load offset */
|
||||||
sub t2, t1, t0
|
|
||||||
lla t0, __rel_dyn_start
|
lla t0, __rel_dyn_start
|
||||||
lla t1, __rel_dyn_end
|
lla t1, __rel_dyn_end
|
||||||
beq t0, t1, _relocate_done
|
beq t0, t1, _relocate_done
|
||||||
@@ -96,18 +90,14 @@ _wait_relocate_copy_done:
|
|||||||
#else
|
#else
|
||||||
/* Relocate if load address != link address */
|
/* Relocate if load address != link address */
|
||||||
_relocate:
|
_relocate:
|
||||||
lla t0, _link_start
|
li t0, FW_TEXT_START /* link start */
|
||||||
REG_L t0, 0(t0)
|
lla t2, _fw_start /* load start */
|
||||||
lla t1, _link_end
|
lla t3, _fw_reloc_end /* load end */
|
||||||
REG_L t1, 0(t1)
|
sub t6, t2, t0 /* load offset */
|
||||||
lla t2, _load_start
|
sub t1, t3, t6 /* link end */
|
||||||
REG_L t2, 0(t2)
|
|
||||||
beq t0, t2, _relocate_done
|
beq t0, t2, _relocate_done
|
||||||
sub t3, t1, t0
|
|
||||||
add t3, t3, t2
|
|
||||||
lla t4, _relocate_done
|
lla t4, _relocate_done
|
||||||
sub t4, t4, t2
|
sub t4, t4, t6
|
||||||
add t4, t4, t0
|
|
||||||
blt t2, t0, _relocate_copy_to_upper
|
blt t2, t0, _relocate_copy_to_upper
|
||||||
_relocate_copy_to_lower:
|
_relocate_copy_to_lower:
|
||||||
ble t1, t2, _relocate_copy_to_lower_loop
|
ble t1, t2, _relocate_copy_to_lower_loop
|
||||||
@@ -147,8 +137,7 @@ _relocate_copy_to_upper_loop:
|
|||||||
jr t4
|
jr t4
|
||||||
_wait_relocate_copy_done:
|
_wait_relocate_copy_done:
|
||||||
lla t0, _fw_start
|
lla t0, _fw_start
|
||||||
lla t1, _link_start
|
li t1, FW_TEXT_START
|
||||||
REG_L t1, 0(t1)
|
|
||||||
beq t0, t1, _wait_for_boot_hart
|
beq t0, t1, _wait_for_boot_hart
|
||||||
lla t2, _boot_status
|
lla t2, _boot_status
|
||||||
lla t3, _wait_for_boot_hart
|
lla t3, _wait_for_boot_hart
|
||||||
@@ -173,12 +162,7 @@ _relocate_done:
|
|||||||
*/
|
*/
|
||||||
lla t0, _boot_status
|
lla t0, _boot_status
|
||||||
#ifndef FW_PIC
|
#ifndef FW_PIC
|
||||||
lla t1, _link_start
|
add t0, t0, t6
|
||||||
REG_L t1, 0(t1)
|
|
||||||
lla t2, _load_start
|
|
||||||
REG_L t2, 0(t2)
|
|
||||||
sub t0, t0, t1
|
|
||||||
add t0, t0, t2
|
|
||||||
#endif
|
#endif
|
||||||
li t1, BOOT_STATUS_RELOCATE_DONE
|
li t1, BOOT_STATUS_RELOCATE_DONE
|
||||||
REG_S t1, 0(t0)
|
REG_S t1, 0(t0)
|
||||||
@@ -502,12 +486,6 @@ _relocate_lottery:
|
|||||||
RISCV_PTR 0
|
RISCV_PTR 0
|
||||||
_boot_status:
|
_boot_status:
|
||||||
RISCV_PTR 0
|
RISCV_PTR 0
|
||||||
_load_start:
|
|
||||||
RISCV_PTR _fw_start
|
|
||||||
_link_start:
|
|
||||||
RISCV_PTR FW_TEXT_START
|
|
||||||
_link_end:
|
|
||||||
RISCV_PTR _fw_reloc_end
|
|
||||||
|
|
||||||
.section .entry, "ax", %progbits
|
.section .entry, "ax", %progbits
|
||||||
.align 3
|
.align 3
|
||||||
|
Reference in New Issue
Block a user