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