This is because some loaders expect to be able to resume execution at an alternative location by altering %pc from within Forth.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- arch/sparc64/call-client.S | 19 +++++++++++++------ arch/sparc64/cpustate.h | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/arch/sparc64/call-client.S b/arch/sparc64/call-client.S index a4f8104..9489aa6 100644 --- a/arch/sparc64/call-client.S +++ b/arch/sparc64/call-client.S @@ -75,6 +75,11 @@ sparc64_of_client_interface: ldx [%sp + 2047 - 248 + 240], %g7 stx %g7, [%g1 + 0x60] + /* Save %pc */ + mov %o7, %g7 + add %g7, 8, %g7 + stx %g7, [%g1 + 0x4d0] + SAVE_CPU_WINDOW_STATE(cif)
/* Move to OpenBIOS context stack */ @@ -116,15 +121,17 @@ sparc64_of_client_interface: setx client_tba, %g6, %g7 ldx [%g7], %g6 wrpr %g6, %tba - + + /* Restore %pc */ + ldx [%g1 + 0x4d0], %o7 + /* Restore globals */ ldx [%g1 + 0x38], %g2 ldx [%g1 + 0x40], %g3 ldx [%g1 + 0x48], %g4 ldx [%g1 + 0x50], %g5 ldx [%g1 + 0x58], %g6 - ldx [%g1 + 0x60], %g7 - ldx [%g1 + 0x30], %g1 - - jmp %o7+8 - nop + ldx [%g1 + 0x60], %g7 + + jmp %o7 + ldx [%g1 + 0x30], %g1 diff --git a/arch/sparc64/cpustate.h b/arch/sparc64/cpustate.h index 8ea45c4..a0e838a 100644 --- a/arch/sparc64/cpustate.h +++ b/arch/sparc64/cpustate.h @@ -131,7 +131,7 @@ save_cpu_window_##type: \ #define SAVE_CPU_TRAP_STATE(type) \ /* Save trap state into context at %g1 */ \ - add %g1, 0x4d0, %g5; \ + add %g1, 0x4e0, %g5; \ mov 4, %g6; \ \ save_trap_state_##type: \ @@ -232,7 +232,7 @@ restore_cpu_window_##type: \
#define RESTORE_CPU_TRAP_STATE(type) \ /* Restore trap state from context at %g1 */ \ - add %g1, 0x4d0, %g5; \ + add %g1, 0x4e0, %g5; \ mov 4, %g6; \ \ restore_trap_state_##type: \