Last active
June 13, 2016 08:39
-
-
Save coypoop/fb8fcbdb58f1b3693d4cd2954726f2d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
End result will be: | |
/* CPU dependent mtc0 hazard hook */ | |
#if (MIPS32R2 + MIPS64R2) > 0 | |
# define COP0_SYNC .set push; .set mips32r2; ehb; .set pop | |
# define JR_HB_RA .set push; .set mips32r2; jr.hb ra; nop; .set pop | |
#else | |
# define COP0_SYNC sll $0,$0,1; sll $0,$0,1; sll $0,$0,1 | |
# define JR_HB_RA sll $0,$0,1; sll $0,$0,1; jr ra; sll $0,$0,1 | |
#endif | |
#define COP0_HAZARD_FPUENABLE nop; nop; nop; nop; | |
Make sure we use sll rather than nop, which is used | |
out of paranoia that .set reorder will get rid of | |
the nops (as it likely doesn't know about COP0 hazards). | |
MIPSnnR2 or newer has ehb/jr.hb to take care of all | |
our worries about cop0 hazards. | |
It's completely safe but potentially wasteful - unclear | |
why we have a case of less padding for very old archs | |
(MIPS1-2? when the macros are defined is vague.) | |
diff --git a/sys/arch/mips/include/cpuregs.h b/sys/arch/mips/include/cpuregs.h | |
index 38905ee..99b4f4d 100644 | |
--- a/sys/arch/mips/include/cpuregs.h | |
+++ b/sys/arch/mips/include/cpuregs.h | |
@@ -152,22 +152,11 @@ | |
/* CPU dependent mtc0 hazard hook */ | |
#if (MIPS32R2 + MIPS64R2) > 0 | |
-# if (MIPS1 + MIPS3 + MIPS32 + MIPS64) == 0 | |
-# define COP0_SYNC sll $0,$0,3 /* EHB */ | |
-# define JR_HB_RA .set push; .set mips32r2; jr.hb ra; nop; .set pop | |
-# else | |
-# define COP0_SYNC sll $0,$0,1; sll $0,$0,1; sll $0,$0,3 | |
-# define JR_HB_RA sll $0,$0,1; sll $0,$0,1; jr ra; sll $0,$0,3 | |
-# endif | |
-#elif (MIPS32 + MIPS64) > 0 | |
-# define COP0_SYNC sll $0,$0,1; sll $0,$0,1; sll $0,$0,1 | |
-# define JR_HB_RA sll $0,$0,1; sll $0,$0,1; jr ra; sll $0,$0,1 | |
-#elif MIPS3 > 0 | |
-# define COP0_SYNC nop; nop; nop | |
-# define JR_HB_RA nop; nop; jr ra; nop | |
+# define COP0_SYNC .set push; .set mips32r2; ehb; .set pop | |
+# define JR_HB_RA .set push; .set mips32r2; jr.hb ra; nop; .set pop | |
#else | |
-# define COP0_SYNC nop | |
-# define JR_HB_RA jr ra; nop | |
+# define COP0_SYNC sll $0,$0,1; sll $0,$0,1; sll $0,$0,1 | |
+# define JR_HB_RA sll $0,$0,1; sll $0,$0,1; jr ra; sll $0,$0,1 | |
#endif | |
#define COP0_HAZARD_FPUENABLE nop; nop; nop; nop; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment