xref: /titanic_41/usr/src/uts/common/sys/kdi.h (revision d58fda4376e4bf67072ce2e69f6f47036f9dbb68)
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 2004 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 
70 #define	KDI_VERSION		6
71 
72 extern void kdi_dvec_enter(void);
73 extern void kdi_dvec_cpu_init(struct cpu *);
74 #if defined(__i386) || defined(__amd64)
75 extern void kdi_dvec_idt_sync(struct gate_desc *);
76 #endif	/* __i386 || __amd64 */
77 extern void kdi_dvec_vmready(void);
78 extern void kdi_dvec_memavail(void);
79 #if defined(__sparc)
80 extern void kdi_dvec_cpr_restart(void);
81 #endif
82 extern void kdi_dvec_modavail(void);
83 extern void kdi_dvec_thravail(void);
84 extern void kdi_dvec_mod_loaded(struct modctl *);
85 extern void kdi_dvec_mod_unloading(struct modctl *);
86 
87 /*
88  * The state machine described below is used to coordinate the efforts of
89  * kmdb and dtrace.  As both use breakpoints, only one may be currently be
90  * active at a given time.  Transitions are possible between the idle state
91  * and either of the active states, but not directly between the two active
92  * states.
93  */
94 typedef enum kdi_dtrace_set {
95 	KDI_DTSET_DTRACE_ACTIVATE,
96 	KDI_DTSET_DTRACE_DEACTIVATE,
97 	KDI_DTSET_KMDB_BPT_ACTIVATE,
98 	KDI_DTSET_KMDB_BPT_DEACTIVATE
99 } kdi_dtrace_set_t;
100 
101 typedef enum {
102 	KDI_DTSTATE_DTRACE_ACTIVE,
103 	KDI_DTSTATE_IDLE,
104 	KDI_DTSTATE_KMDB_BPT_ACTIVE
105 } kdi_dtrace_state_t;
106 
107 extern int kdi_dtrace_set(kdi_dtrace_set_t);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _KDI_H */
114