xref: /titanic_51/usr/src/cmd/mdb/sparc/v9/kmdb/kaif_regs.h (revision a35baf17811a8fa436d774a0c6c2a02e92548a0a)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _KAIF_REGS_H
27 #define	_KAIF_REGS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifndef _ASM
32 #include <sys/types.h>
33 #include <sys/regset.h>
34 #include <sys/stack.h>
35 #include <sys/kdi_impl.h>
36 
37 #include <mdb/mdb_kreg_impl.h>
38 #include <mdb/mdb_target.h>
39 #include <mdb/mdb.h>
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #define	KAIF_CPU_STKSZ	((MINFRAME64 * 20) + STACK_ALIGN64)
47 
48 #define	KAIF_NCRUMBS	5
49 
50 #define	KAIF_CRUMB_SRC_OBP	1
51 #define	KAIF_CRUMB_SRC_IVEC	2
52 #define	KAIF_CRUMB_SRC_MAIN	3
53 
54 #define	KAIF_CRUMB_F_MAIN_OBPWAPT	0x01
55 #define	KAIF_CRUMB_F_MAIN_OBPPENT	0x02
56 #define	KAIF_CRUMB_F_MAIN_NORMAL	0x04
57 
58 #define	KAIF_CRUMB_F_IVEC_REENTER	0x08
59 #define	KAIF_CRUMB_F_IVEC_INOBP		0x10
60 #define	KAIF_CRUMB_F_IVEC_NORMAL	0x20
61 
62 #define	KAIF_CRUMB_F_OBP_NORMAL		0x40
63 #define	KAIF_CRUMB_F_OBP_REVECT		0x80
64 
65 #ifndef _ASM
66 
67 /*
68  * We maintain a ring buffer of bread crumbs for debugging purposes.  The
69  * current buffer pointer is advanced along the ring with each intercepted
70  * trap (debugger entry, invalid memory access, etc).  The structure must have a
71  * size equal to a multiple of 8.
72  */
73 typedef struct kaif_crumb {
74 	uint64_t krm_src;
75 	uint64_t krm_pc;
76 	uint64_t krm_tt;
77 	uint32_t krm_flag;
78 	uint32_t krm_pad;
79 } kaif_crumb_t;
80 
81 /* Keep in sync with kaif_regs.in */
82 typedef struct kaif_cpusave {
83 	mdb_tgt_gregset_t	krs_gregs;	/* Saved registers */
84 	struct rwindow		*krs_rwins;	/* Saved register windows */
85 	kfpu_t			krs_fpregs;	/* Saved FP registers */
86 
87 	kreg_t			krs_tstate;	/* Saved %tstate */
88 	kreg_t			krs_mmu_pcontext; /* Context # at kmdb entry */
89 
90 	uint_t			krs_cpu_state;	/* KAIF_CPU_STATE_* */
91 	uint_t			krs_cpu_flushed; /* Have caches been flushed? */
92 	uint_t			krs_cpu_id;	/* this CPU's ID */
93 	uint_t			krs_cpu_acked;	/* for slave to ack master */
94 
95 	uint64_t		krs_lsucr_save;	/* LSUCR for wapt step */
96 	uint32_t		krs_instr_save;	/* OBP instr for wapt step */
97 
98 	/* Bread crumb ring buffer */
99 	uint_t			krs_curcrumbidx; /* Current krs_crumbs idx */
100 	kaif_crumb_t		*krs_curcrumb;	/* Current crumb */
101 	kaif_crumb_t		krs_crumbs[KAIF_NCRUMBS];  /* Crumbs */
102 
103 	char			krs_cpustack[KAIF_CPU_STKSZ];
104 } kaif_cpusave_t;
105 #endif
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* _KAIF_REGS_H */
112