This means we can remove the client_tba hack in the CIF prologue and also use the full SAVE_CPU_STATE() macro for entry.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- arch/sparc64/call-client.S | 12 ------------ arch/sparc64/context.h | 4 +++- arch/sparc64/cpu.fs | 4 +++- arch/sparc64/cpustate.h | 13 +++++++++---- arch/sparc64/entry.S | 3 +-- arch/sparc64/openbios.c | 9 +++++---- 6 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/arch/sparc64/call-client.S b/arch/sparc64/call-client.S index ebab6b9..4129505 100644 --- a/arch/sparc64/call-client.S +++ b/arch/sparc64/call-client.S @@ -18,8 +18,6 @@ client_context: .xword 0 client_stack: .xword 0 -client_tba: - .xword 0 client_window: .skip 2048
@@ -46,11 +44,6 @@ sparc64_of_client_interface: stx %g6, [%sp + 2047 - 248 + 232] stx %g7, [%sp + 2047 - 248 + 240]
- /* Save client trap table */ - setx client_tba, %g6, %g7 - rdpr %tba, %g6 - stx %g6, [%g7] - /* Save existing stack */ setx client_stack, %g6, %g7 stx %sp, [%g7] @@ -133,11 +126,6 @@ sparc64_of_client_interface: /* Restore stack */ setx client_stack, %g6, %g7 ldx [%g7], %sp - - /* Restore client trap table */ - setx client_tba, %g6, %g7 - ldx [%g7], %g6 - wrpr %g6, %tba /* Restore %pc */ ldx [%g1 + 0x4d0], %o7 diff --git a/arch/sparc64/context.h b/arch/sparc64/context.h index a047b9c..eb189fb 100644 --- a/arch/sparc64/context.h +++ b/arch/sparc64/context.h @@ -11,7 +11,9 @@ struct context { #define REG_O0 14 #define REG_SP 20 #define SP_LOC(ctx) (&(ctx)->regs[REG_SP]) - uint64_t tregs[20]; + uint64_t tba; + uint64_t _pad; + uint64_t tregs[16]; /* Flags */ /* Optional stack contents */ uint64_t return_addr; diff --git a/arch/sparc64/cpu.fs b/arch/sparc64/cpu.fs index b0aa611..5a8f8d6 100644 --- a/arch/sparc64/cpu.fs +++ b/arch/sparc64/cpu.fs @@ -3,9 +3,10 @@ include config.fs \ SPARC64 trap registers
: %tl-c saved-context h# c8 + @ ; +: %tba saved-context h# 4e0 + @ ;
: tl-offset ( level -- offset ) - h# 20 * h# 4e0 h# 60 + swap - ; + h# 20 * h# 4f0 h# 60 + swap - ; ;
: %tpc ( level -- n ) tl-offset saved-context + @ ; @@ -15,6 +16,7 @@ include config.fs
: .trap-registers cr + s" %tba: " type %tba u. cr s" %tl-c: " type %tl-c u. cr s" %tpc: " type %tl-c %tpc u. cr s" %tnpc: " type %tl-c %tnpc u. cr diff --git a/arch/sparc64/cpustate.h b/arch/sparc64/cpustate.h index cff7733..b4695ad 100644 --- a/arch/sparc64/cpustate.h +++ b/arch/sparc64/cpustate.h @@ -12,7 +12,7 @@ #include "autoconf.h"
/* State size for context (see below) */ -#define CONTEXT_STATE_SIZE 0x560 +#define CONTEXT_STATE_SIZE 0x570
/* Stack size for context (allocated inline of the context stack) */ #define CONTEXT_STACK_SIZE 0x2000 @@ -135,7 +135,9 @@ save_cpu_window_##type: \
#define SAVE_CPU_TRAP_STATE(type) \ /* Save trap state into context at %g1 */ \ - add %g1, 0x4e0, %g5; \ + rdpr %tba, %g5; \ + stx %g5, [%g1 + 0x4e0]; \ + add %g1, 0x4f0, %g5; \ mov 4, %g6; \ \ /* Save current trap level */ \ @@ -246,7 +248,7 @@ restore_cpu_window_##type: \
#define RESTORE_CPU_TRAP_STATE(type) \ /* Restore trap state from context at %g1 */ \ - add %g1, 0x4e0, %g5; \ + add %g1, 0x4f0, %g5; \ mov 4, %g6; \ \ restore_trap_state_##type: \ @@ -264,7 +266,10 @@ restore_trap_state_##type: \ add %g5, 0x20, %g5; \ \ ldx [%g1 + 0xc8], %g7; \ - wrpr %g7, %tl + wrpr %g7, %tl; \ + ldx [%g1 + 0x4e0], %g7; \ + wrpr %g7, %tba +
/* Restore all state from context at %g1 */ #define RESTORE_CPU_STATE(type) \ diff --git a/arch/sparc64/entry.S b/arch/sparc64/entry.S index 3a46d89..47d1139 100644 --- a/arch/sparc64/entry.S +++ b/arch/sparc64/entry.S @@ -269,8 +269,7 @@ lowmem: setx __context, %g2, %g1 ldx [%g1], %g1
- SAVE_CPU_GENERAL_STATE(entry) - SAVE_CPU_WINDOW_STATE(entry) + SAVE_CPU_STATE(entry)
/* Set up local stack pointer */ setx _estack - 2047, %o2, %sp diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index 9a1d56c..3b7bc46 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -10,6 +10,8 @@ #include "libopenbios/openbios.h" #include "libopenbios/bindings.h" #include "libopenbios/console.h" +#include "context.h" +#include "libopenbios/initprogram.h" #include "drivers/drivers.h" #include "dict.h" #include "arch/common/nvram.h" @@ -89,17 +91,16 @@ struct cpudef { ( addr -- ? ) */
-extern volatile uint64_t client_tba; - static void set_trap_table(void) { unsigned long addr; + volatile struct context *ctx = __context;
addr = POP();
- /* Update client_tba to be updated on CIF exit */ - client_tba = addr; + /* Update %tba to be updated on exit */ + ctx->tba = (uint64_t)addr; }
/* Reset control register is defined in 17.2.7.3 of US IIi User Manual */