[OpenBIOS] [PATCH 6/7] SPARC64: split off general CPU registers into *_GENERAL_STATE macros

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Sun Aug 21 17:32:41 CEST 2016


A few of the CPU registers were included in the *_WINDOW_STATE macros.
Split them out so that they can be used on their own without altering the
window state.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 arch/sparc64/cpustate.h |   42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/arch/sparc64/cpustate.h b/arch/sparc64/cpustate.h
index a0e838a..87c4af8 100644
--- a/arch/sparc64/cpustate.h
+++ b/arch/sparc64/cpustate.h
@@ -43,6 +43,18 @@
  * invoke the miss handler.
  */
 
+#define SAVE_CPU_GENERAL_STATE(type) \
+	/* Save generate state into context at %g1 */ \
+	rdpr	%pstate, %g7; \
+	stx	%g7, [%g1 + 0xb0]; \
+	rd	%y, %g7; \
+	stx	%g7, [%g1 + 0xb8]; \
+	rd	%fprs, %g7; \
+	stx	%g7, [%g1 + 0xc0]; \
+	rdpr    %tl, %g7; \
+	stx     %g7, [%g1 + 0xc8];
+
+
 #define SAVE_CPU_WINDOW_STATE(type) \
 	/* Save window state into context at %g1 */ \
 	rdpr	%cwp, %g7; \
@@ -69,15 +81,6 @@
 	stx	%o6, [%g1 + 0xa0]; \
 	stx	%o7, [%g1 + 0xa8]; \
 	\
-	rdpr	%pstate, %g7; \
-	stx	%g7, [%g1 + 0xb0]; \
-	rd	%y, %g7; \
-	stx	%g7, [%g1 + 0xb8]; \
-	rd	%fprs, %g7; \
-	stx	%g7, [%g1 + 0xc0]; \
-	rdpr    %tl, %g7; \
-	stx     %g7, [%g1 + 0xc8]; \
-	\
 	/* Now iterate through all of the windows saving all l and i registers */ \
 	add	%g1, 0xd0, %g5; \
 	\
@@ -153,10 +156,21 @@ save_trap_state_##type: \
 
 /* Save all state into context at %g1 */
 #define SAVE_CPU_STATE(type) \
+	SAVE_CPU_GENERAL_STATE(type); \
 	SAVE_CPU_WINDOW_STATE(type); \
 	SAVE_CPU_TRAP_STATE(type);
 
 
+#define RESTORE_CPU_GENERAL_STATE(type) \
+	/* Restore general state from context at %g1 */ \
+	ldx	[%g1 + 0xb0], %g7; \
+	wrpr	%g7, %pstate; \
+	ldx	[%g1 + 0xb8], %g7; \
+	wr	%g7, 0, %y; \
+	ldx	[%g1 + 0xc0], %g7; \
+	wr	%g7, 0, %fprs;
+	
+	
 #define RESTORE_CPU_WINDOW_STATE(type) \
 	/* Restore window state from context at %g1 */ \
 	\
@@ -220,14 +234,7 @@ restore_cpu_window_##type: \
 	ldx	[%g1 + 0x90], %o4; \
 	ldx	[%g1 + 0x98], %o5; \
 	ldx	[%g1 + 0xa0], %o6; \
-	ldx	[%g1 + 0xa8], %o7; \
-	\
-	ldx	[%g1 + 0xb0], %g7; \
-	wrpr	%g7, %pstate; \
-	ldx	[%g1 + 0xb8], %g7; \
-	wr	%g7, 0, %y; \
-	ldx	[%g1 + 0xc0], %g7; \
-	wr	%g7, 0, %fprs; \
+	ldx	[%g1 + 0xa8], %o7;
 
 
 #define RESTORE_CPU_TRAP_STATE(type) \
@@ -254,5 +261,6 @@ restore_trap_state_##type: \
 
 /* Restore all state from context at %g1 */
 #define RESTORE_CPU_STATE(type) \
+	RESTORE_CPU_GENERAL_STATE(type); \
 	RESTORE_CPU_WINDOW_STATE(type); \
 	RESTORE_CPU_TRAP_STATE(type);
-- 
1.7.10.4




More information about the OpenBIOS mailing list