xref: /titanic_41/usr/src/uts/common/sys/kdi.h (revision 936b7af69172dce89b577831f79c0e18d15e854b)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _KDI_H
27 #define	_KDI_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 
33 /*
34  * The Kernel/Debugger interface.
35  *
36  * The Debugger -> Kernel portion of the interface is handled by the kdi_t,
37  * which is defined in the archkdi.h files.  These functions are intended to
38  * be called only when the system is stopped and the debugger is in control.
39  *
40  * The Kernel -> Debugger portion is handled by the debugvec_t, which is
41  * defined here.  These functions are used by the kernel to inform the debugger
42  * of various state changes.
43  */
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * The VA range reserved for the debugger; used by kmdb.
51  */
52 extern const caddr_t kdi_segdebugbase;
53 extern const size_t kdi_segdebugsize;
54 
55 struct cpu;
56 struct modctl;
57 struct gate_desc;
58 struct user_desc;
59 
60 typedef struct kdi_debugvec kdi_debugvec_t;
61 typedef struct kdi kdi_t;
62 
63 extern kdi_debugvec_t	*kdi_dvec;
64 extern struct modctl	*kdi_dmods;
65 
66 #define	KDI_VERSION		7
67 
68 extern void kdi_dvec_vmready(void);
69 extern void kdi_dvec_memavail(void);
70 #if defined(__sparc)
71 extern void kdi_dvec_cpu_init(struct cpu *);
72 extern void kdi_dvec_cpr_restart(void);
73 #endif
74 extern void kdi_dvec_modavail(void);
75 extern void kdi_dvec_thravail(void);
76 extern void kdi_dvec_mod_loaded(struct modctl *);
77 extern void kdi_dvec_mod_unloading(struct modctl *);
78 
79 /*
80  * The state machine described below is used to coordinate the efforts of
81  * kmdb and dtrace.  As both use breakpoints, only one may be currently be
82  * active at a given time.  Transitions are possible between the idle state
83  * and either of the active states, but not directly between the two active
84  * states.
85  */
86 typedef enum kdi_dtrace_set {
87 	KDI_DTSET_DTRACE_ACTIVATE,
88 	KDI_DTSET_DTRACE_DEACTIVATE,
89 	KDI_DTSET_KMDB_BPT_ACTIVATE,
90 	KDI_DTSET_KMDB_BPT_DEACTIVATE
91 } kdi_dtrace_set_t;
92 
93 typedef enum {
94 	KDI_DTSTATE_DTRACE_ACTIVE,
95 	KDI_DTSTATE_IDLE,
96 	KDI_DTSTATE_KMDB_BPT_ACTIVE
97 } kdi_dtrace_state_t;
98 
99 extern int kdi_dtrace_set(kdi_dtrace_set_t);
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* _KDI_H */
106