summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2008-04-14 21:04:57 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2008-04-14 21:04:57 +0000
commitdb4c8e0d63dc4976dba3e7e05324a7e1c4c9e8d2 (patch)
tree5406b68fdd745b41f6fd700c907bc6e9fff1084d /sys/arch
parentfe4a063c62965b992bbec37f13b16e9353f8732e (diff)
Introduce macros to switch to normal and alternate globals and switch to
use the .section based mechanism to patch them up for sun4v.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/sparc64/autoconf.c13
-rw-r--r--sys/arch/sparc64/sparc64/locore.s62
2 files changed, 31 insertions, 44 deletions
diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c
index 9940affda32..8e8a065ed4d 100644
--- a/sys/arch/sparc64/sparc64/autoconf.c
+++ b/sys/arch/sparc64/sparc64/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.86 2008/04/12 14:59:30 kettenis Exp $ */
+/* $OpenBSD: autoconf.c,v 1.87 2008/04/14 21:04:56 kettenis Exp $ */
/* $NetBSD: autoconf.c,v 1.51 2001/07/24 19:32:11 eeh Exp $ */
/*
@@ -289,7 +289,6 @@ bootstrap(nctx)
#ifdef SUN4V
if (CPU_ISSUN4V) {
extern vaddr_t dlflush_start;
- extern vaddr_t gl0_start, gl1_start;
vaddr_t *pva;
u_int32_t insn;
int32_t disp;
@@ -299,16 +298,6 @@ bootstrap(nctx)
flush((void *)(*pva));
}
- for (pva = &gl0_start; *pva; pva++) {
- *(u_int32_t *)(*pva) = 0xa1902000; /* wr %g0, 0, %gl */
- flush((void *)(*pva));
- }
-
- for (pva = &gl1_start; *pva; pva++) {
- *(u_int32_t *)(*pva) = 0xa1902001; /* wr %g0, 1, %gl */
- flush((void *)(*pva));
- }
-
disp = (vaddr_t)hv_mmu_demap_page - (vaddr_t)sp_tlb_flush_pte;
insn = 0x10800000 | disp >> 2; /* ba hv_mmu_demap_page */
((u_int32_t *)sp_tlb_flush_pte)[0] = insn;
diff --git a/sys/arch/sparc64/sparc64/locore.s b/sys/arch/sparc64/sparc64/locore.s
index d1f0ea3d659..fd2ee1fdca1 100644
--- a/sys/arch/sparc64/sparc64/locore.s
+++ b/sys/arch/sparc64/sparc64/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.132 2008/04/13 16:32:55 kettenis Exp $ */
+/* $OpenBSD: locore.s,v 1.133 2008/04/14 21:04:56 kettenis Exp $ */
/* $NetBSD: locore.s,v 1.137 2001/08/13 06:10:10 jdolecek Exp $ */
/*
@@ -150,6 +150,20 @@ _C_LABEL(sun4v_mp_patch):
stxa ctxid, [ctx] ASI_MMU_CONTEXTID ;\
.previous
+#define NORMAL_GLOBALS() \
+999: wrpr %g0, PSTATE_KERN, %pstate ;\
+ .section .sun4v_patch, "ax" ;\
+ .word 999b ;\
+ wrpr %g0, 0, %gl ;\
+ .previous
+
+#define ALTERNATE_GLOBALS() \
+999: wrpr %g0, PSTATE_KERN|PSTATE_AG, %pstate ;\
+ .section .sun4v_patch, "ax" ;\
+ .word 999b ;\
+ wrpr %g0, 1, %gl ;\
+ .previous
+
/*
* This macro will clear out a cache line before an explicit
@@ -3562,8 +3576,7 @@ Lslowtrap_reenter:
mov %g2, %o2 ! (pc)
sth %o1, [%sp + CC64FSZ + BIAS + TF_TT]! debug
- wrpr %g0, PSTATE_KERN, %pstate ! Get back to normal globals
-gl0_1: nop
+ NORMAL_GLOBALS()
stx %g1, [%sp + CC64FSZ + BIAS + TF_G + (1*8)]
stx %g2, [%sp + CC64FSZ + BIAS + TF_G + (2*8)]
@@ -3725,8 +3738,7 @@ syscall_setup:
sth %o1, [%sp + CC64FSZ + BIAS + TF_TT]! debug
#endif /* DEBUG */
- wrpr %g0, PSTATE_KERN, %pstate ! Get back to normal globals
-gl0_2: nop
+ NORMAL_GLOBALS()
stx %g1, [%sp + CC64FSZ + BIAS + TF_G + ( 1*8)]
mov %g1, %o1 ! code
@@ -4237,10 +4249,10 @@ _C_LABEL(sparc_interrupt):
ldx [%g3 + 8], %g5 ! intrlev[1] is reserved for %tick intr.
0:
INTR_SETUP -CC64FSZ-TF_SIZE-8
- ! Switch to normal globals so we can save them
- wrpr %g0, PSTATE_KERN, %pstate
-gl0_3: nop
+ NORMAL_GLOBALS()
+
+ /* Save normal globals */
stx %g1, [%sp + CC64FSZ + BIAS + TF_G + ( 1*8)]
stx %g2, [%sp + CC64FSZ + BIAS + TF_G + ( 2*8)]
stx %g3, [%sp + CC64FSZ + BIAS + TF_G + ( 3*8)]
@@ -4249,8 +4261,11 @@ gl0_3: nop
stx %g6, [%sp + CC64FSZ + BIAS + TF_G + ( 6*8)]
stx %g7, [%sp + CC64FSZ + BIAS + TF_G + ( 7*8)]
-gl0_x:
- flushw ! Do not remove this instruction -- causes interrupt loss
+999: flushw ! Do not remove this instruction -- causes interrupt loss
+ .section .sun4v_patch, "ax"
+ .word 999b
+ nop
+ .previous
GET_CPUINFO_VA(%g7)
#ifdef SUN4V
@@ -4473,8 +4488,7 @@ return_from_trap:
wrpr %g0, PSTATE_INTR, %pstate
wrpr %g0, %g0, %pil ! Lower IPL
1:
- wrpr %g0, PSTATE_KERN, %pstate ! Make sure we have normal globals & no IRQs
-gl0_4: nop
+ wrpr %g0, PSTATE_KERN, %pstate ! Disable IRQs
/* Restore normal globals */
ldx [%sp + CC64FSZ + BIAS + TF_G + (1*8)], %g1
@@ -4483,13 +4497,13 @@ gl0_4: nop
ldx [%sp + CC64FSZ + BIAS + TF_G + (4*8)], %g4
ldx [%sp + CC64FSZ + BIAS + TF_G + (5*8)], %g5
ldx [%sp + CC64FSZ + BIAS + TF_G + (6*8)], %g6
- bnz %icc, 2f
+ bnz,pn %icc, 2f
nop
ldx [%sp + CC64FSZ + BIAS + TF_G + (7*8)], %g7
2:
- /* Switch to alternate globals and load outs */
-gl1_1:
- wrpr %g0, PSTATE_KERN|PSTATE_AG, %pstate
+ ALTERNATE_GLOBALS()
+
+ /* Restore outs */
ldx [%sp + CC64FSZ + BIAS + TF_O + (0*8)], %i0
ldx [%sp + CC64FSZ + BIAS + TF_O + (1*8)], %i1
ldx [%sp + CC64FSZ + BIAS + TF_O + (2*8)], %i2
@@ -9117,22 +9131,6 @@ _C_LABEL(dlflush_start):
.xword dlflush5
.xword 0
-#ifdef SUN4V
- .globl _C_LABEL(gl0_start)
-_C_LABEL(gl0_start):
- .xword gl0_1
- .xword gl0_2
- .xword gl0_3
- .xword gl0_4
- .xword gl0_x
- .xword 0
-
- .globl _C_LABEL(gl1_start)
-_C_LABEL(gl1_start):
- .xword gl1_1
- .xword 0
-#endif
-
.section .sun4v_patch, "ax"
.globl _C_LABEL(sun4v_patch_end)
_C_LABEL(sun4v_patch_end):