xref: /illumos-gate/usr/src/cmd/mdb/common/kmdb/kmdb_dpi_impl.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _KMDB_DPI_IMPL_H
28 #define	_KMDB_DPI_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <setjmp.h>
33 #ifdef	__sparc
34 #include <sys/regset.h>
35 #endif	/* __sparc */
36 #include <sys/types.h>
37 
38 #include <kmdb/kmdb_auxv.h>
39 #include <kmdb/kmdb_dpi.h>
40 #include <mdb/mdb_kreg.h>
41 #include <mdb/mdb_target.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 extern jmp_buf *kmdb_dpi_fault_pcb;
48 
49 /*
50  * The routines used by the kmdb side of the DPI to access the saved state
51  * of the current kernel instance, and to control that instance.  A populated
52  * version of this vector is provided by the DPI backend used to control the
53  * machine.  General use of the kmdb DPI is not via direct invocation of the
54  * functions in this ops vector, but rather flows through the convenience
55  * wrappers in kmdb_dpi.c.
56  */
57 struct dpi_ops {
58 	int (*dpo_init)(kmdb_auxv_t *);
59 
60 	void (*dpo_debugger_activate)(kdi_debugvec_t **, uint_t);
61 	void (*dpo_debugger_deactivate)(void);
62 
63 	void (*dpo_enter_mon)(void);
64 
65 	void (*dpo_modchg_register)(void (*)(struct modctl *, int));
66 	void (*dpo_modchg_cancel)(void);
67 
68 	int (*dpo_get_cpu_state)(int);
69 	int (*dpo_get_master_cpuid)(void);
70 
71 	const mdb_tgt_gregset_t *(*dpo_get_gregs)(int);
72 #ifdef __sparc
73 	int (*dpo_get_cpu_register)(int, int, const char *, kreg_t *);
74 	int (*dpo_set_cpu_register)(int, int, const char *, kreg_t);
75 	int (*dpo_get_rwin)(int, int, struct rwindow *);
76 	int (*dpo_get_nwin)(int);
77 #else
78 	int (*dpo_get_cpu_register)(int, const char *, kreg_t *);
79 	int (*dpo_set_cpu_register)(int, const char *, kreg_t);
80 #endif
81 
82 	int (*dpo_brkpt_arm)(uintptr_t, mdb_instr_t *);
83 	int (*dpo_brkpt_disarm)(uintptr_t, mdb_instr_t);
84 
85 	int (*dpo_wapt_validate)(kmdb_wapt_t *);
86 	int (*dpo_wapt_reserve)(kmdb_wapt_t *);
87 	void (*dpo_wapt_release)(kmdb_wapt_t *);
88 	void (*dpo_wapt_arm)(kmdb_wapt_t *);
89 	void (*dpo_wapt_disarm)(kmdb_wapt_t *);
90 	int (*dpo_wapt_match)(kmdb_wapt_t *);
91 
92 	int (*dpo_step)(void);
93 #if defined(__i386) || defined(__amd64)
94 	void (*dpo_step_branch)(void);
95 #endif
96 
97 	uintptr_t (*dpo_call)(uintptr_t, uint_t, const uintptr_t *);
98 
99 	void (*dpo_dump_crumbs)(uintptr_t, int);
100 
101 	int (*dpo_memrange_add)(caddr_t, size_t);
102 
103 #if defined(__i386) || defined(__amd64)
104 	void (*dpo_msr_add)(const kmdb_msr_t *);
105 	uint64_t (*dpo_msr_get)(int, uint_t);
106 #endif
107 
108 #ifdef __sparc
109 	void (*dpo_kernpanic)(int);
110 #endif
111 };
112 
113 extern void (*kmdb_dpi_wrintr_fire)(void);
114 
115 extern dpi_ops_t kmdb_dpi_ops;
116 
117 extern void kmdb_dpi_resume_common(int);
118 extern void kmdb_dpi_resume_master(void);
119 
120 /* Used by the debugger to tell the driver how to resume */
121 #define	KMDB_DPI_CMD_RESUME_ALL		1	/* Resume all CPUs */
122 #define	KMDB_DPI_CMD_RESUME_MASTER	2	/* Resume only master CPU */
123 #define	KMDB_DPI_CMD_RESUME_UNLOAD	3	/* Resume for debugger unload */
124 #define	KMDB_DPI_CMD_SWITCH_CPU		4	/* Switch to another CPU */
125 #define	KMDB_DPI_CMD_FLUSH_CACHES	5	/* Flush slave caches */
126 #define	KMDB_DPI_CMD_REBOOT		6	/* Reboot the machine */
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif /* _KMDB_DPI_IMPL_H */
133