xref: /onnv-gate/usr/src/uts/sun4u/os/mach_trap.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include <sys/trap.h>
30*0Sstevel@tonic-gate #include <sys/machtrap.h>
31*0Sstevel@tonic-gate #include <sys/machsystm.h>
32*0Sstevel@tonic-gate #include <sys/cpu_module.h>
33*0Sstevel@tonic-gate #include <sys/panic.h>
34*0Sstevel@tonic-gate #include <sys/uadmin.h>
35*0Sstevel@tonic-gate #include <sys/kobj.h>
36*0Sstevel@tonic-gate #include <sys/contract/process_impl.h>
37*0Sstevel@tonic-gate #include <vm/hat_sfmmu.h>
38*0Sstevel@tonic-gate #include <sys/reboot.h>
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #ifdef  TRAPTRACE
41*0Sstevel@tonic-gate #include <sys/traptrace.h>
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate void showregs(unsigned, struct regs *, caddr_t, uint_t);
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate extern int tudebug;
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate void
49*0Sstevel@tonic-gate mmu_print_sfsr(uint_t sfsr)
50*0Sstevel@tonic-gate {
51*0Sstevel@tonic-gate 	printf("MMU sfsr=%x:", sfsr);
52*0Sstevel@tonic-gate 	switch (X_FAULT_TYPE(sfsr)) {
53*0Sstevel@tonic-gate 	case FT_NONE:
54*0Sstevel@tonic-gate 		printf(" No error");
55*0Sstevel@tonic-gate 		break;
56*0Sstevel@tonic-gate 	case FT_PRIV:
57*0Sstevel@tonic-gate 		printf(" Privilege violation");
58*0Sstevel@tonic-gate 		break;
59*0Sstevel@tonic-gate 	case FT_SPEC_LD:
60*0Sstevel@tonic-gate 		printf(" Speculative load on E-bit page");
61*0Sstevel@tonic-gate 		break;
62*0Sstevel@tonic-gate 	case FT_ATOMIC_NC:
63*0Sstevel@tonic-gate 		printf(" Atomic to uncacheable page");
64*0Sstevel@tonic-gate 		break;
65*0Sstevel@tonic-gate 	case FT_ILL_ALT:
66*0Sstevel@tonic-gate 		printf(" Illegal lda or sta");
67*0Sstevel@tonic-gate 		break;
68*0Sstevel@tonic-gate 	case FT_NFO:
69*0Sstevel@tonic-gate 		printf(" Normal access to NFO page");
70*0Sstevel@tonic-gate 		break;
71*0Sstevel@tonic-gate 	case FT_RANGE:
72*0Sstevel@tonic-gate 		printf(" Data or instruction address out of range");
73*0Sstevel@tonic-gate 		break;
74*0Sstevel@tonic-gate 	case FT_RANGE_REG:
75*0Sstevel@tonic-gate 		printf(" Jump to register out of range");
76*0Sstevel@tonic-gate 		break;
77*0Sstevel@tonic-gate 	default:
78*0Sstevel@tonic-gate 		printf(" Unknown error");
79*0Sstevel@tonic-gate 		break;
80*0Sstevel@tonic-gate 	}
81*0Sstevel@tonic-gate 	if (sfsr) {
82*0Sstevel@tonic-gate 		printf(" on ASI 0x%x E %d CID %d PRIV %d W %d OW %d FV %d",
83*0Sstevel@tonic-gate 			(sfsr & SFSR_ASI) >> SFSR_ASI_SHIFT,
84*0Sstevel@tonic-gate 			(sfsr & SFSR_E) != 0,
85*0Sstevel@tonic-gate 			(sfsr & SFSR_CTX) >> SFSR_CT_SHIFT,
86*0Sstevel@tonic-gate 			(sfsr & SFSR_PR) != 0,
87*0Sstevel@tonic-gate 			(sfsr & SFSR_W) != 0,
88*0Sstevel@tonic-gate 			(sfsr & SFSR_OW) != 0,
89*0Sstevel@tonic-gate 			(sfsr & SFSR_FV) != 0);
90*0Sstevel@tonic-gate 	}
91*0Sstevel@tonic-gate 	printf("\n");
92*0Sstevel@tonic-gate }
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate /*
96*0Sstevel@tonic-gate  * Handle an asynchronous hardware error, i.e. an E-$ parity error.
97*0Sstevel@tonic-gate  * The policy is currently to send a hardware error contract event to
98*0Sstevel@tonic-gate  * the process's process contract and to kill the process.  Eventually
99*0Sstevel@tonic-gate  * we may want to instead send a special signal whose default
100*0Sstevel@tonic-gate  * disposition is to generate the contract event.
101*0Sstevel@tonic-gate  */
102*0Sstevel@tonic-gate void
103*0Sstevel@tonic-gate trap_async_hwerr(void)
104*0Sstevel@tonic-gate {
105*0Sstevel@tonic-gate 	k_siginfo_t si;
106*0Sstevel@tonic-gate 	proc_t *p = ttoproc(curthread);
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate 	errorq_drain(ue_queue); /* flush pending async error messages */
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate 	contract_process_hwerr(p->p_ct_process, p);
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate 	bzero(&si, sizeof (k_siginfo_t));
113*0Sstevel@tonic-gate 	si.si_signo = SIGKILL;
114*0Sstevel@tonic-gate 	si.si_code = SI_NOINFO;
115*0Sstevel@tonic-gate 	trapsig(&si, 1);
116*0Sstevel@tonic-gate }
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate /*
119*0Sstevel@tonic-gate  * Handle bus error and bus timeout for a user process by sending SIGBUS
120*0Sstevel@tonic-gate  * The type is either ASYNC_BERR or ASYNC_BTO.
121*0Sstevel@tonic-gate  */
122*0Sstevel@tonic-gate void
123*0Sstevel@tonic-gate trap_async_berr_bto(int type, struct regs *rp)
124*0Sstevel@tonic-gate {
125*0Sstevel@tonic-gate 	k_siginfo_t si;
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate 	errorq_drain(ue_queue); /* flush pending async error messages */
128*0Sstevel@tonic-gate 	bzero(&si, sizeof (k_siginfo_t));
129*0Sstevel@tonic-gate 
130*0Sstevel@tonic-gate 	si.si_signo = SIGBUS;
131*0Sstevel@tonic-gate 	si.si_code = (type == ASYNC_BERR ? BUS_OBJERR : BUS_ADRERR);
132*0Sstevel@tonic-gate 	si.si_addr = (caddr_t)rp->r_pc; /* AFAR unavailable - future RFE */
133*0Sstevel@tonic-gate 	si.si_errno = ENXIO;
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate 	trapsig(&si, 1);
136*0Sstevel@tonic-gate }
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate #ifdef TRAPWINDOW
139*0Sstevel@tonic-gate long trap_window[25];
140*0Sstevel@tonic-gate #endif /* TRAPWINDOW */
141*0Sstevel@tonic-gate 
142*0Sstevel@tonic-gate /*
143*0Sstevel@tonic-gate  * Print out debugging info.
144*0Sstevel@tonic-gate  */
145*0Sstevel@tonic-gate /*ARGSUSED*/
146*0Sstevel@tonic-gate void
147*0Sstevel@tonic-gate showregs(uint_t type, struct regs *rp, caddr_t addr, uint_t mmu_fsr)
148*0Sstevel@tonic-gate {
149*0Sstevel@tonic-gate 	int s;
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate 	s = spl7();
152*0Sstevel@tonic-gate 	type &= ~T_USER;
153*0Sstevel@tonic-gate 	printf("%s: ", u.u_comm);
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate 	switch (type) {
156*0Sstevel@tonic-gate 	case T_SYS_RTT_ALIGN:
157*0Sstevel@tonic-gate 	case T_ALIGNMENT:
158*0Sstevel@tonic-gate 		printf("alignment error:\n");
159*0Sstevel@tonic-gate 		break;
160*0Sstevel@tonic-gate 	case T_INSTR_EXCEPTION:
161*0Sstevel@tonic-gate 		printf("text access exception:\n");
162*0Sstevel@tonic-gate 		break;
163*0Sstevel@tonic-gate 	case T_DATA_EXCEPTION:
164*0Sstevel@tonic-gate 		printf("data access exception:\n");
165*0Sstevel@tonic-gate 		break;
166*0Sstevel@tonic-gate 	case T_PRIV_INSTR:
167*0Sstevel@tonic-gate 		printf("privileged instruction fault:\n");
168*0Sstevel@tonic-gate 		break;
169*0Sstevel@tonic-gate 	case T_UNIMP_INSTR:
170*0Sstevel@tonic-gate 		printf("illegal instruction fault:\n");
171*0Sstevel@tonic-gate 		break;
172*0Sstevel@tonic-gate 	case T_IDIV0:
173*0Sstevel@tonic-gate 		printf("integer divide zero trap:\n");
174*0Sstevel@tonic-gate 		break;
175*0Sstevel@tonic-gate 	case T_DIV0:
176*0Sstevel@tonic-gate 		printf("zero divide trap:\n");
177*0Sstevel@tonic-gate 		break;
178*0Sstevel@tonic-gate 	case T_INT_OVERFLOW:
179*0Sstevel@tonic-gate 		printf("integer overflow:\n");
180*0Sstevel@tonic-gate 		break;
181*0Sstevel@tonic-gate 	case T_BREAKPOINT:
182*0Sstevel@tonic-gate 		printf("breakpoint trap:\n");
183*0Sstevel@tonic-gate 		break;
184*0Sstevel@tonic-gate 	case T_TAG_OVERFLOW:
185*0Sstevel@tonic-gate 		printf("tag overflow:\n");
186*0Sstevel@tonic-gate 		break;
187*0Sstevel@tonic-gate 	default:
188*0Sstevel@tonic-gate 		if (type >= T_SOFTWARE_TRAP && type <= T_ESOFTWARE_TRAP)
189*0Sstevel@tonic-gate 			printf("software trap 0x%x\n", type - T_SOFTWARE_TRAP);
190*0Sstevel@tonic-gate 		else
191*0Sstevel@tonic-gate 			printf("trap type = 0x%x\n", type);
192*0Sstevel@tonic-gate 		break;
193*0Sstevel@tonic-gate 	}
194*0Sstevel@tonic-gate 	if (type == T_DATA_EXCEPTION || type == T_INSTR_EXCEPTION) {
195*0Sstevel@tonic-gate 		mmu_print_sfsr(mmu_fsr);
196*0Sstevel@tonic-gate 	} else if (addr) {
197*0Sstevel@tonic-gate 		printf("addr=0x%p\n", (void *)addr);
198*0Sstevel@tonic-gate 	}
199*0Sstevel@tonic-gate 
200*0Sstevel@tonic-gate 	printf("pid=%d, pc=0x%lx, sp=0x%llx, tstate=0x%llx, context=0x%x\n",
201*0Sstevel@tonic-gate 	    (ttoproc(curthread) && ttoproc(curthread)->p_pidp) ?
202*0Sstevel@tonic-gate 	    (ttoproc(curthread)->p_pid) : 0, rp->r_pc, rp->r_sp,
203*0Sstevel@tonic-gate 	    rp->r_tstate, sfmmu_getctx_sec());
204*0Sstevel@tonic-gate 	if (USERMODE(rp->r_tstate)) {
205*0Sstevel@tonic-gate 		printf("o0-o7: %llx, %llx, %llx, %llx, %llx, %llx, "
206*0Sstevel@tonic-gate 		    "%llx, %llx\n", rp->r_o0, rp->r_o1, rp->r_o2, rp->r_o3,
207*0Sstevel@tonic-gate 		    rp->r_o4, rp->r_o5, rp->r_o6, rp->r_o7);
208*0Sstevel@tonic-gate 	}
209*0Sstevel@tonic-gate 	printf("g1-g7: %llx, %llx, %llx, %llx, %llx, %llx, %llx\n",
210*0Sstevel@tonic-gate 	    rp->r_g1, rp->r_g2, rp->r_g3,
211*0Sstevel@tonic-gate 	    rp->r_g4, rp->r_g5, rp->r_g6, rp->r_g7);
212*0Sstevel@tonic-gate 
213*0Sstevel@tonic-gate #ifdef TRAPWINDOW
214*0Sstevel@tonic-gate 	printf("trap_window: wim=%x\n", trap_window[24]);
215*0Sstevel@tonic-gate 	printf("o0-o7: %x, %x, %x, %x, %x, %x, %x, %x\n",
216*0Sstevel@tonic-gate 	    trap_window[0], trap_window[1], trap_window[2], trap_window[3],
217*0Sstevel@tonic-gate 	    trap_window[4], trap_window[5], trap_window[6], trap_window[7]);
218*0Sstevel@tonic-gate 	printf("l0-l7: %x, %x, %x, %x, %x, %x, %x, %x\n",
219*0Sstevel@tonic-gate 	    trap_window[8], trap_window[9], trap_window[10], trap_window[11],
220*0Sstevel@tonic-gate 	    trap_window[12], trap_window[13], trap_window[14], trap_window[15]);
221*0Sstevel@tonic-gate 	printf("i0-i7: %x, %x, %x, %x, %x, %x, %x, %x\n",
222*0Sstevel@tonic-gate 	    trap_window[16], trap_window[17], trap_window[18], trap_window[19],
223*0Sstevel@tonic-gate 	    trap_window[20], trap_window[21], trap_window[22], trap_window[23]);
224*0Sstevel@tonic-gate #endif /* TRAPWINDOW */
225*0Sstevel@tonic-gate 	if (tudebug > 1 && (boothowto & RB_DEBUG)) {
226*0Sstevel@tonic-gate 		debug_enter((char *)NULL);
227*0Sstevel@tonic-gate 	}
228*0Sstevel@tonic-gate 	splx(s);
229*0Sstevel@tonic-gate }
230*0Sstevel@tonic-gate 
231*0Sstevel@tonic-gate static void
232*0Sstevel@tonic-gate ptl1_showtrap(ptl1_state_t *pstate)
233*0Sstevel@tonic-gate {
234*0Sstevel@tonic-gate 	ptl1_regs_t *rp = &pstate->ptl1_regs;
235*0Sstevel@tonic-gate 	short i, j, maxtl = rp->ptl1_trap_regs[0].ptl1_tl;
236*0Sstevel@tonic-gate 
237*0Sstevel@tonic-gate 	printf("%%tl %%tpc              %%tnpc             %%tstate"
238*0Sstevel@tonic-gate 	    "           %%tt\n");
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate 	for (i = maxtl - 1; i >= 0; i--) {
241*0Sstevel@tonic-gate 		ptl1_trapregs_t *ptp = &rp->ptl1_trap_regs[i];
242*0Sstevel@tonic-gate 		uint64_t tstate = ptp->ptl1_tstate;
243*0Sstevel@tonic-gate 		uint32_t ccr, asi, cwp, pstate;
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate 		cwp = (tstate >> TSTATE_CWP_SHIFT) & TSTATE_CWP_MASK;
246*0Sstevel@tonic-gate 		pstate = (tstate >> TSTATE_PSTATE_SHIFT) & TSTATE_PSTATE_MASK;
247*0Sstevel@tonic-gate 		asi = (tstate >> TSTATE_ASI_SHIFT) & TSTATE_ASI_MASK;
248*0Sstevel@tonic-gate 		ccr = (tstate >> TSTATE_CCR_SHIFT) & TSTATE_CCR_MASK;
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate 		printf(" %d  %016" PRIx64 "  %016" PRIx64 "  %010" PRIx64
251*0Sstevel@tonic-gate 		    "        %03x\n", ptp->ptl1_tl, ptp->ptl1_tpc,
252*0Sstevel@tonic-gate 		    ptp->ptl1_tnpc, tstate, ptp->ptl1_tt);
253*0Sstevel@tonic-gate 		printf("    %%ccr: %02x  %%asi: %02x  %%cwp: %x  "
254*0Sstevel@tonic-gate 		    "%%pstate: %b\n", ccr, asi, cwp, pstate, PSTATE_BITS);
255*0Sstevel@tonic-gate 	}
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate 	printf("%%g0-3: %016x %016" PRIx64 " %016" PRIx64 " %016"
258*0Sstevel@tonic-gate 	    PRIx64 "\n", 0, rp->ptl1_g1, rp->ptl1_g2, rp->ptl1_g3);
259*0Sstevel@tonic-gate 	printf("%%g4-7: %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016"
260*0Sstevel@tonic-gate 	    PRIx64 "\n", rp->ptl1_g4, rp->ptl1_g5, rp->ptl1_g6, rp->ptl1_g7);
261*0Sstevel@tonic-gate 
262*0Sstevel@tonic-gate 	i = rp->ptl1_cwp;
263*0Sstevel@tonic-gate 	j = rp->ptl1_canrestore;
264*0Sstevel@tonic-gate 	for (; j >= 0; i--, j--) {
265*0Sstevel@tonic-gate 		struct rwindow *wp;
266*0Sstevel@tonic-gate 		ulong_t off;
267*0Sstevel@tonic-gate 		char *sym;
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate 		if (i < 0)
270*0Sstevel@tonic-gate 			i += MAXWIN;
271*0Sstevel@tonic-gate 
272*0Sstevel@tonic-gate 		wp = &rp->ptl1_rwindow[i];
273*0Sstevel@tonic-gate 
274*0Sstevel@tonic-gate 		if ((sym = kobj_getsymname(wp->rw_in[7], &off)) != NULL) {
275*0Sstevel@tonic-gate 			printf("Register window %d, caller %s+%lx\n",
276*0Sstevel@tonic-gate 			    i, sym, off);
277*0Sstevel@tonic-gate 		} else {
278*0Sstevel@tonic-gate 			printf("Register window %d, caller %lx\n",
279*0Sstevel@tonic-gate 			    i, wp->rw_in[7]);
280*0Sstevel@tonic-gate 		}
281*0Sstevel@tonic-gate 
282*0Sstevel@tonic-gate 		if (i == rp->ptl1_cwp) {
283*0Sstevel@tonic-gate 			struct rwindow *nwp;
284*0Sstevel@tonic-gate 
285*0Sstevel@tonic-gate 			if (i == MAXWIN - 1)
286*0Sstevel@tonic-gate 				nwp = &rp->ptl1_rwindow[0];
287*0Sstevel@tonic-gate 			else
288*0Sstevel@tonic-gate 				nwp = &rp->ptl1_rwindow[i+1];
289*0Sstevel@tonic-gate 			printf("%%o0-3: %016lx %016lx %016lx %016lx\n"
290*0Sstevel@tonic-gate 			    "%%o4-7: %016lx %016lx %016lx %016lx\n",
291*0Sstevel@tonic-gate 			    nwp->rw_in[0], nwp->rw_in[1], nwp->rw_in[2],
292*0Sstevel@tonic-gate 			    nwp->rw_in[3], nwp->rw_in[4], nwp->rw_in[5],
293*0Sstevel@tonic-gate 			    nwp->rw_in[6], nwp->rw_in[7]);
294*0Sstevel@tonic-gate 		}
295*0Sstevel@tonic-gate 		printf("%%l0-3: %016lx %016lx %016lx %016lx\n"
296*0Sstevel@tonic-gate 		    "%%l4-7: %016lx %016lx %016lx %016lx\n",
297*0Sstevel@tonic-gate 		    wp->rw_local[0], wp->rw_local[1], wp->rw_local[2],
298*0Sstevel@tonic-gate 		    wp->rw_local[3], wp->rw_local[4], wp->rw_local[5],
299*0Sstevel@tonic-gate 		    wp->rw_local[6], wp->rw_local[7]);
300*0Sstevel@tonic-gate 
301*0Sstevel@tonic-gate 		printf("%%i0-3: %016lx %016lx %016lx %016lx\n"
302*0Sstevel@tonic-gate 		    "%%i4-7: %016lx %016lx %016lx %016lx\n",
303*0Sstevel@tonic-gate 		    wp->rw_in[0], wp->rw_in[1], wp->rw_in[2], wp->rw_in[3],
304*0Sstevel@tonic-gate 		    wp->rw_in[4], wp->rw_in[5], wp->rw_in[6], wp->rw_in[7]);
305*0Sstevel@tonic-gate 	}
306*0Sstevel@tonic-gate }
307*0Sstevel@tonic-gate 
308*0Sstevel@tonic-gate void
309*0Sstevel@tonic-gate panic_showtrap(struct trap_info *tip)
310*0Sstevel@tonic-gate {
311*0Sstevel@tonic-gate 	ptl1_state_t *pstate = &CPU->cpu_m.ptl1_state;
312*0Sstevel@tonic-gate 	/*
313*0Sstevel@tonic-gate 	 * If ptl1_panic() was called, print out the information
314*0Sstevel@tonic-gate 	 * saved in the ptl1_state struture.
315*0Sstevel@tonic-gate 	 */
316*0Sstevel@tonic-gate 	if (pstate->ptl1_entry_count) {
317*0Sstevel@tonic-gate 		ptl1_showtrap(pstate);
318*0Sstevel@tonic-gate 		return;
319*0Sstevel@tonic-gate 	}
320*0Sstevel@tonic-gate 
321*0Sstevel@tonic-gate 	showregs(tip->trap_type, tip->trap_regs, tip->trap_addr,
322*0Sstevel@tonic-gate 	    tip->trap_mmu_fsr);
323*0Sstevel@tonic-gate }
324*0Sstevel@tonic-gate 
325*0Sstevel@tonic-gate static void
326*0Sstevel@tonic-gate ptl1_savetrap(panic_data_t *pdp, ptl1_state_t *pstate)
327*0Sstevel@tonic-gate {
328*0Sstevel@tonic-gate 	ptl1_regs_t *rp = &pstate->ptl1_regs;
329*0Sstevel@tonic-gate 	short i, maxtl = rp->ptl1_trap_regs[0].ptl1_tl;
330*0Sstevel@tonic-gate 	panic_nv_t *pnv = PANICNVGET(pdp);
331*0Sstevel@tonic-gate 	char name[PANICNVNAMELEN];
332*0Sstevel@tonic-gate 
333*0Sstevel@tonic-gate 	for (i = maxtl - 1; i >= 0; i--) {
334*0Sstevel@tonic-gate 		ptl1_trapregs_t *ptp = &rp->ptl1_trap_regs[i];
335*0Sstevel@tonic-gate 
336*0Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tl[%d]", i);
337*0Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tl);
338*0Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tt[%d]", i);
339*0Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tt);
340*0Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tpc[%d]", i);
341*0Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tpc);
342*0Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tnpc[%d]", i);
343*0Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tnpc);
344*0Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tstate[%d]", i);
345*0Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tstate);
346*0Sstevel@tonic-gate 	}
347*0Sstevel@tonic-gate 
348*0Sstevel@tonic-gate 	PANICNVSET(pdp, pnv);
349*0Sstevel@tonic-gate }
350*0Sstevel@tonic-gate 
351*0Sstevel@tonic-gate void
352*0Sstevel@tonic-gate panic_savetrap(panic_data_t *pdp, struct trap_info *tip)
353*0Sstevel@tonic-gate {
354*0Sstevel@tonic-gate 	panic_nv_t *pnv;
355*0Sstevel@tonic-gate 	ptl1_state_t *pstate = &CPU->cpu_m.ptl1_state;
356*0Sstevel@tonic-gate 	/*
357*0Sstevel@tonic-gate 	 * If ptl1_panic() was called, save the trap registers
358*0Sstevel@tonic-gate 	 * stored in the ptl1_state struture.
359*0Sstevel@tonic-gate 	 */
360*0Sstevel@tonic-gate 	if (pstate->ptl1_entry_count) {
361*0Sstevel@tonic-gate 		ptl1_savetrap(pdp, pstate);
362*0Sstevel@tonic-gate 		return;
363*0Sstevel@tonic-gate 	}
364*0Sstevel@tonic-gate 
365*0Sstevel@tonic-gate 	panic_saveregs(pdp, tip->trap_regs);
366*0Sstevel@tonic-gate 	pnv = PANICNVGET(pdp);
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate 	PANICNVADD(pnv, "sfsr", tip->trap_mmu_fsr);
369*0Sstevel@tonic-gate 	PANICNVADD(pnv, "sfar", tip->trap_addr);
370*0Sstevel@tonic-gate 	PANICNVADD(pnv, "tt", tip->trap_type);
371*0Sstevel@tonic-gate 
372*0Sstevel@tonic-gate 	PANICNVSET(pdp, pnv);
373*0Sstevel@tonic-gate }
374