PERFORCE change 93141 for review
Kip Macy
kmacy at FreeBSD.org
Sat Mar 11 10:10:16 GMT 2006
http://perforce.freebsd.org/chv.cgi?CH=93141
Change 93141 by kmacy at kmacy_storage:sun4v_work on 2006/03/11 10:09:12
implement user trap handling
Affected files ...
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#26 edit
Differences ...
==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#26 (text+ko) ====
@@ -905,13 +905,29 @@
ENTRY(utl0)
+ GET_PCPU_SCRATCH
SAVE_GLOBALS(%l7)
SAVE_OUTS(%l7)
wrpr %g0, PSTATE_KERNEL, %pstate ! enable ints
+
+ brnz %o1, common_utrap
+ nop
+ call critical_enter
+ nop
jmpl %l3, %o7 ! call trap handler
mov %l7, %o0
+ call critical_exit
+ nop
+ b user_rtt
+ nop
+common_utrap:
+ stx %o1, [%l7 + TF_TYPE] ! save trap type
+ stx %o2, [%l7 + TF_TAR] ! save mem info
+ jmpl %l3, %o7 ! call trap handler
+ mov %l7, %o0
ENTRY(user_rtt)
+ GET_PCB(%g6)
add %sp, CCFSZ + SPOFF, %l7
! pil handling needs to be re-visited
wrpr %g0, PIL_TICK, %pil
@@ -972,18 +988,51 @@
wrpr %g1, %tpc
wrpr %g2, %tnpc
-#if 0
!
! switch "other" windows back to "normal" windows and
! restore to window we originally trapped in
!
rdpr %otherwin, %g1
wrpr %g0, 0, %otherwin
- wrpr %g0, %g1, %canrestore
-#endif
add %l3, WSTATE_CLEAN_OFFSET, %l3 ! convert to "clean" wstate
wrpr %g0, %l3, %wstate
+ wrpr %g0, %g1, %canrestore
+#ifdef notyet
+ !
+ ! First attempt to restore from the watchpoint saved register window
+ tst %g1
+ bne,a 1f
+ clrn [%g6 + STACK_BIAS + MPCB_RSP0]
+ tst %fp
+ be,a 1f
+ clrn [%g6 + STACK_BIAS + MPCB_RSP0]
+ ! test for user return window in pcb
+ ldn [%g6 + STACK_BIAS + MPCB_RSP0], %g1
+ cmp %fp, %g1
+ bne 1f
+ clrn [%g6 + STACK_BIAS + MPCB_RSP0]
+ restored
+ restore
+ ! restore from user return window
+ RESTORE_V9WINDOW(%g6 + STACK_BIAS + MPCB_RWIN0)
+ !
+ ! Attempt to restore from the scond watchpoint saved register window
+ tst %fp
+ be,a 2f
+ clrn [%g6 + STACK_BIAS + MPCB_RSP1]
+ ldn [%g6 + STACK_BIAS + MPCB_RSP1], %g1
+ cmp %fp, %g1
+ bne 2f
+ clrn [%g6 + STACK_BIAS + MPCB_RSP1]
+ restored
+ restore
+ RESTORE_V9WINDOW(%g6 + STACK_BIAS + MPCB_RWIN1)
+ save
+ b,a 2f
+1:
+
+#endif
rdpr %canrestore, %g1
brnz %g1, 3f
@@ -1037,8 +1086,8 @@
call critical_exit
nop
b common_rtt
+ nop
common_ktrap:
- nop
stx %o1, [%l7 + TF_TYPE] ! save trap type
stx %o2, [%l7 + TF_TAR] ! save mem info
jmpl %l3, %o7 ! call trap handler
@@ -1108,10 +1157,7 @@
set ktl0, %g6
save %sp, -(CCFSZ + TF_SIZEOF), %sp
-
- mov %g1, %l3 ! set trap/interrupt for tl0
- or %g2, T_KERNEL, %o1 ! trap type
- mov %g3, %o2 ! fault info if set
+ or %g2, T_KERNEL, %g2
! if the kwbuf is full we need to save to the stack now
ld [PCPU_REG + PC_KWBUF_FULL], %o0
@@ -1157,11 +1203,42 @@
bnz,pn %xcc, tl0_ktrap
wrpr %g0, %g6, %cwp
ENTRY(tl0_utrap)
- MAGIC_TRAP_ON;MAGIC_TRAP_ON;MAGIC_EXIT
+#ifdef notyet
+ /* we need to determine from the hardware the number of register windows */
+ sethi %hi(nwin_minus_one), %g5
+ ld [%g5 + %lo(nwin_minus_one)], %g5
+#else
+ mov nwin_minus_one, %g5
+#endif
+ MAGIC_TRAP_ON
+ GET_PCB(%g6)
+ wrpr %g0, %g5, %cleanwin
+ sub %g6, SPOFF + CCFSZ + TF_SIZEOF, %g6
+ save %g6, 0, %sp
+ rdpr %canrestore, %l0
+ rdpr %wstate, %l1
+ wrpr %g0, 0, %canrestore
+ sllx %l1, WSTATE_SHIFT, %l1
+ wrpr %l1, WSTATE_K64, %wstate
+ wrpr %g0, %l0, %otherwin
+ !
+ ! set pcontext to run kernel
+ !
+ mov KCONTEXT, %l0
+ mov MMU_CID_P, %l1
+ sethi %hi(FLUSH_ADDR), %l2
+ SET_MMU_CONTEXT(%l1, %l0)
+ flush %l2 ! flush / membar required by immu for
+ ! consistency guarantee
+ set utl0, %g6
win_saved:
+ mov %g1, %l3 ! set trap/interrupt for tl0
+ mov %g2, %o1 ! trap type
+ mov %g3, %o2 ! fault info if set
+ mov %g5, %l6 ! %pil if priv trap
!
- ! save trap state on stack
+ ! save state in trapframe
!
add %sp, REGOFF + SPOFF, %l7
rdpr %tpc, %l0
@@ -1266,7 +1343,7 @@
! %g4 <- tag %g5 <- data
! %g6 == search tag %g7 == fault addr
tsb_miss_lookup_0:
- ldda [%g2 + %g0]ASI_LDTD_N, %g4
+ ldda [%g2]ASI_LDTD_N, %g4
cmp %g4, %g0 ! entry tag == 0 ?
be,pn %xcc, 4f
nop
More information about the p4-projects
mailing list