xref: /titanic_52/usr/src/uts/intel/sys/kdi_regs.h (revision 843e19887f64dde75055cf8842fc4db2171eff45)
1*ae115bc7Smrj /*
2*ae115bc7Smrj  * CDDL HEADER START
3*ae115bc7Smrj  *
4*ae115bc7Smrj  * The contents of this file are subject to the terms of the
5*ae115bc7Smrj  * Common Development and Distribution License (the "License").
6*ae115bc7Smrj  * You may not use this file except in compliance with the License.
7*ae115bc7Smrj  *
8*ae115bc7Smrj  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*ae115bc7Smrj  * or http://www.opensolaris.org/os/licensing.
10*ae115bc7Smrj  * See the License for the specific language governing permissions
11*ae115bc7Smrj  * and limitations under the License.
12*ae115bc7Smrj  *
13*ae115bc7Smrj  * When distributing Covered Code, include this CDDL HEADER in each
14*ae115bc7Smrj  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*ae115bc7Smrj  * If applicable, add the following below this CDDL HEADER, with the
16*ae115bc7Smrj  * fields enclosed by brackets "[]" replaced with your own identifying
17*ae115bc7Smrj  * information: Portions Copyright [yyyy] [name of copyright owner]
18*ae115bc7Smrj  *
19*ae115bc7Smrj  * CDDL HEADER END
20*ae115bc7Smrj  */
21*ae115bc7Smrj /*
22*ae115bc7Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*ae115bc7Smrj  * Use is subject to license terms.
24*ae115bc7Smrj  */
25*ae115bc7Smrj 
26*ae115bc7Smrj #ifndef _SYS_KDI_REGS_H
27*ae115bc7Smrj #define	_SYS_KDI_REGS_H
28*ae115bc7Smrj 
29*ae115bc7Smrj #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*ae115bc7Smrj 
31*ae115bc7Smrj #ifndef _ASM
32*ae115bc7Smrj #include <sys/types.h>
33*ae115bc7Smrj #include <sys/segments.h>
34*ae115bc7Smrj #include <sys/regset.h>
35*ae115bc7Smrj #include <sys/privregs.h>
36*ae115bc7Smrj #endif
37*ae115bc7Smrj 
38*ae115bc7Smrj #if defined(__amd64)
39*ae115bc7Smrj #include <amd64/sys/kdi_regs.h>
40*ae115bc7Smrj #elif defined(__i386)
41*ae115bc7Smrj #include <ia32/sys/kdi_regs.h>
42*ae115bc7Smrj #endif
43*ae115bc7Smrj 
44*ae115bc7Smrj #ifdef __cplusplus
45*ae115bc7Smrj extern "C" {
46*ae115bc7Smrj #endif
47*ae115bc7Smrj 
48*ae115bc7Smrj #define	KDI_NCRUMBS	5
49*ae115bc7Smrj 
50*ae115bc7Smrj #define	KDI_CPU_STATE_NONE		0
51*ae115bc7Smrj #define	KDI_CPU_STATE_MASTER		1
52*ae115bc7Smrj #define	KDI_CPU_STATE_SLAVE		2
53*ae115bc7Smrj 
54*ae115bc7Smrj #define	KDIREG_DRCTL_WPALLEN_MASK	0x000000ff
55*ae115bc7Smrj #define	KDIREG_DRSTAT_RESERVED		0xffff0ff0
56*ae115bc7Smrj #define	KDIREG_DRCTL_RESERVED		0x00000700
57*ae115bc7Smrj 
58*ae115bc7Smrj #define	KDI_MSR_READ		0x1	/* read during entry (unlimited) */
59*ae115bc7Smrj #define	KDI_MSR_WRITE		0x2	/* write during exit (unlimited) */
60*ae115bc7Smrj #define	KDI_MSR_WRITEDELAY	0x4	/* write after last branch (<= 1) */
61*ae115bc7Smrj #define	KDI_MSR_CLEARENTRY	0x3	/* clear before 1st branch (<= 1) */
62*ae115bc7Smrj 
63*ae115bc7Smrj #ifndef _ASM
64*ae115bc7Smrj 
65*ae115bc7Smrj /*
66*ae115bc7Smrj  * We maintain a ring buffer of bread crumbs for debugging purposes.  The
67*ae115bc7Smrj  * current buffer pointer is advanced along the ring with each intercepted
68*ae115bc7Smrj  * trap (debugger entry, invalid memory access, fault during step, etc).
69*ae115bc7Smrj  */
70*ae115bc7Smrj typedef struct kdi_crumb {
71*ae115bc7Smrj 	greg_t krm_cpu_state;	/* This CPU's state at last entry */
72*ae115bc7Smrj 	greg_t krm_pc;		/* Instruction pointer at trap */
73*ae115bc7Smrj 	greg_t krm_sp;		/* Stack pointer at trap */
74*ae115bc7Smrj 	greg_t krm_trapno;	/* The last trap number */
75*ae115bc7Smrj 	greg_t krm_flag;	/* KAIF_CRUMB_F_* */
76*ae115bc7Smrj } kdi_crumb_t;
77*ae115bc7Smrj 
78*ae115bc7Smrj #define	KDI_MAXWPIDX	3
79*ae115bc7Smrj 
80*ae115bc7Smrj /*
81*ae115bc7Smrj  * Storage for %dr0-3, %dr6, and %dr7.
82*ae115bc7Smrj  */
83*ae115bc7Smrj typedef struct kdi_drreg {
84*ae115bc7Smrj 	greg_t			dr_ctl;
85*ae115bc7Smrj 	greg_t			dr_stat;
86*ae115bc7Smrj 	greg_t			dr_addr[KDI_MAXWPIDX + 1];
87*ae115bc7Smrj } kdi_drreg_t;
88*ae115bc7Smrj 
89*ae115bc7Smrj typedef struct kdi_msr {
90*ae115bc7Smrj 	uint_t		msr_num;
91*ae115bc7Smrj 	uint_t		msr_type;
92*ae115bc7Smrj 	union {
93*ae115bc7Smrj 		uint64_t *_msr_valp;
94*ae115bc7Smrj 		uint64_t _msr_val;
95*ae115bc7Smrj 	} _u;
96*ae115bc7Smrj } kdi_msr_t;
97*ae115bc7Smrj 
98*ae115bc7Smrj #define	kdi_msr_val	_u._msr_val
99*ae115bc7Smrj #define	kdi_msr_valp	_u._msr_valp
100*ae115bc7Smrj 
101*ae115bc7Smrj /*
102*ae115bc7Smrj  * Data structure used to hold all of the state for a given CPU.
103*ae115bc7Smrj  */
104*ae115bc7Smrj typedef struct kdi_cpusave {
105*ae115bc7Smrj 	greg_t			*krs_gregs;	/* saved registers */
106*ae115bc7Smrj 
107*ae115bc7Smrj 	kdi_drreg_t		krs_dr;		/* saved debug registers */
108*ae115bc7Smrj 
109*ae115bc7Smrj 	user_desc_t		*krs_gdt;	/* GDT address */
110*ae115bc7Smrj 	gate_desc_t		*krs_idt;	/* IDT address */
111*ae115bc7Smrj 
112*ae115bc7Smrj 	greg_t			krs_cr0;	/* saved %cr0 */
113*ae115bc7Smrj 
114*ae115bc7Smrj 	kdi_msr_t		*krs_msr;	/* ptr to MSR save area */
115*ae115bc7Smrj 
116*ae115bc7Smrj 	uint_t			krs_cpu_state;	/* KDI_CPU_STATE_* mstr/slv */
117*ae115bc7Smrj 	uint_t			krs_cpu_flushed; /* Have caches been flushed? */
118*ae115bc7Smrj 	uint_t			krs_cpu_id;	/* this CPU's ID */
119*ae115bc7Smrj 
120*ae115bc7Smrj 	/* Bread crumb ring buffer */
121*ae115bc7Smrj 	ulong_t			krs_curcrumbidx; /* Current krs_crumbs idx */
122*ae115bc7Smrj 	kdi_crumb_t		*krs_curcrumb;	/* Pointer to current crumb */
123*ae115bc7Smrj 	kdi_crumb_t		krs_crumbs[KDI_NCRUMBS]; /* Crumbs */
124*ae115bc7Smrj } kdi_cpusave_t;
125*ae115bc7Smrj 
126*ae115bc7Smrj #endif /* !_ASM */
127*ae115bc7Smrj 
128*ae115bc7Smrj #ifdef __cplusplus
129*ae115bc7Smrj }
130*ae115bc7Smrj #endif
131*ae115bc7Smrj 
132*ae115bc7Smrj #endif /* _SYS_KDI_REGS_H */
133