xref: /titanic_50/usr/src/uts/common/sys/kdi.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _KDI_H
28*7c478bd9Sstevel@tonic-gate #define	_KDI_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * The Kernel/Debugger interface.
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * The Debugger -> Kernel portion of the interface is handled by the kdi_t,
36*7c478bd9Sstevel@tonic-gate  * which is defined in the archkdi.h files.  These functions are intended to
37*7c478bd9Sstevel@tonic-gate  * be called only when the system is stopped and the debugger is in control.
38*7c478bd9Sstevel@tonic-gate  *
39*7c478bd9Sstevel@tonic-gate  * The Kernel -> Debugger portion is handled by the debugvec_t, which is
40*7c478bd9Sstevel@tonic-gate  * defined here.  These functions are used by the kernel to inform the debugger
41*7c478bd9Sstevel@tonic-gate  * of various state changes.
42*7c478bd9Sstevel@tonic-gate  */
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
45*7c478bd9Sstevel@tonic-gate extern "C" {
46*7c478bd9Sstevel@tonic-gate #endif
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /* The VA range reserved for the debugger. */
49*7c478bd9Sstevel@tonic-gate #if defined(__sparc)
50*7c478bd9Sstevel@tonic-gate #define	SEGDEBUGBASE	0xedd00000
51*7c478bd9Sstevel@tonic-gate #define	SEGDEBUGSIZE	(0xf0000000 - SEGDEBUGBASE)
52*7c478bd9Sstevel@tonic-gate #elif defined(__amd64)
53*7c478bd9Sstevel@tonic-gate #define	SEGDEBUGBASE	0xffffffffff800000
54*7c478bd9Sstevel@tonic-gate #define	SEGDEBUGSIZE	0x400000
55*7c478bd9Sstevel@tonic-gate #else
56*7c478bd9Sstevel@tonic-gate #define	SEGDEBUGBASE	0xff800000
57*7c478bd9Sstevel@tonic-gate #define	SEGDEBUGSIZE	0x400000
58*7c478bd9Sstevel@tonic-gate #endif
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate struct cpu;
61*7c478bd9Sstevel@tonic-gate struct modctl;
62*7c478bd9Sstevel@tonic-gate struct gate_desc;
63*7c478bd9Sstevel@tonic-gate struct user_desc;
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate typedef struct kdi_debugvec kdi_debugvec_t;
66*7c478bd9Sstevel@tonic-gate typedef struct kdi kdi_t;
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate extern kdi_debugvec_t *kdi_dvec;
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate #define	KDI_VERSION		6
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_enter(void);
73*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_cpu_init(struct cpu *);
74*7c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
75*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_idt_sync(struct gate_desc *);
76*7c478bd9Sstevel@tonic-gate #endif	/* __i386 || __amd64 */
77*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_vmready(void);
78*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_memavail(void);
79*7c478bd9Sstevel@tonic-gate #if defined(__sparc)
80*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_cpr_restart(void);
81*7c478bd9Sstevel@tonic-gate #endif
82*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_modavail(void);
83*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_thravail(void);
84*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_mod_loaded(struct modctl *);
85*7c478bd9Sstevel@tonic-gate extern void kdi_dvec_mod_unloading(struct modctl *);
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * The state machine described below is used to coordinate the efforts of
89*7c478bd9Sstevel@tonic-gate  * kmdb and dtrace.  As both use breakpoints, only one may be currently be
90*7c478bd9Sstevel@tonic-gate  * active at a given time.  Transitions are possible between the idle state
91*7c478bd9Sstevel@tonic-gate  * and either of the active states, but not directly between the two active
92*7c478bd9Sstevel@tonic-gate  * states.
93*7c478bd9Sstevel@tonic-gate  */
94*7c478bd9Sstevel@tonic-gate typedef enum kdi_dtrace_set {
95*7c478bd9Sstevel@tonic-gate 	KDI_DTSET_DTRACE_ACTIVATE,
96*7c478bd9Sstevel@tonic-gate 	KDI_DTSET_DTRACE_DEACTIVATE,
97*7c478bd9Sstevel@tonic-gate 	KDI_DTSET_KMDB_BPT_ACTIVATE,
98*7c478bd9Sstevel@tonic-gate 	KDI_DTSET_KMDB_BPT_DEACTIVATE
99*7c478bd9Sstevel@tonic-gate } kdi_dtrace_set_t;
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate typedef enum {
102*7c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_DTRACE_ACTIVE,
103*7c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_IDLE,
104*7c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_KMDB_BPT_ACTIVE
105*7c478bd9Sstevel@tonic-gate } kdi_dtrace_state_t;
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate extern int kdi_dtrace_set(kdi_dtrace_set_t);
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
110*7c478bd9Sstevel@tonic-gate }
111*7c478bd9Sstevel@tonic-gate #endif
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate #endif /* _KDI_H */
114