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