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