xref: /illumos-gate/usr/src/cmd/mdb/common/kmdb/kmdb_dpi.h (revision 2a8bcb4e)
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 _KMDB_DPI_H
28 #define	_KMDB_DPI_H
29 
30 /*
31  * Retargetable Kmdb/PROM interface
32  */
33 
34 #include <sys/types.h>
35 #include <setjmp.h>
36 #ifdef	__sparc
37 #include <sys/regset.h>
38 #endif	/* __sparc */
39 
40 #include <mdb/mdb_kreg.h>
41 #include <mdb/mdb_target.h>
42 #include <kmdb/kmdb_auxv.h>
43 #include <kmdb/kmdb_dpi_isadep.h>
44 #include <kmdb/kmdb_kctl.h>
45 
46 /*
47  * The following directive tells the mapfile generator that only those
48  * prototypes and declarations ending with a "Driver OK" comment should be
49  * included in the mapfile.
50  *
51  * MAPFILE: export "Driver OK"
52  */
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #define	DPI_MASTER_CPUID	(-1)	/* matches CPU ID for master */
59 
60 #define	DPI_ALLOW_FAULTS	NULL
61 
62 #define	DPI_STATE_INIT		1	/* debugger initializing */
63 #define	DPI_STATE_STOPPED	2	/* User-requested stop (debug_enter) */
64 #define	DPI_STATE_FAULTED	3	/* Breakpoint, watchpoint, etc. */
65 #define	DPI_STATE_LOST		4	/* debugger fault */
66 
67 #define	DPI_STATE_WHY_BKPT	1
68 #define	DPI_STATE_WHY_V_WAPT	2
69 #define	DPI_STATE_WHY_P_WAPT	3
70 #define	DPI_STATE_WHY_TRAP	4
71 
72 #define	DPI_WAPT_TYPE_PHYS	0x1	/* Physical address (SPARC only) */
73 #define	DPI_WAPT_TYPE_VIRT	0x2	/* Virtual address */
74 #define	DPI_WAPT_TYPE_IO	0x4	/* I/O space (Intel only) */
75 
76 #define	DPI_CPU_STATE_NONE	0
77 #define	DPI_CPU_STATE_MASTER	1
78 #define	DPI_CPU_STATE_SLAVE	2
79 
80 typedef struct dpi_ops dpi_ops_t;
81 
82 typedef struct kmdb_wapt {
83 	uintptr_t wp_addr;		/* Watchpoint base address */
84 	size_t wp_size;			/* Size of watched area, in bytes */
85 	int wp_type;			/* DPI_WAPT_TYPE_* */
86 	uint_t wp_wflags;		/* access modes */
87 	void *wp_priv;			/* DPI-private data */
88 } kmdb_wapt_t;
89 
90 extern int kmdb_dpi_init(kmdb_auxv_t *);
91 
92 extern void kmdb_dpi_enter_mon(void);
93 
94 extern void kmdb_dpi_modchg_register(void (*)(struct modctl *, int));
95 extern void kmdb_dpi_modchg_cancel(void);
96 
97 extern int kmdb_dpi_get_cpu_state(int);
98 extern int kmdb_dpi_get_master_cpuid(void);
99 
100 extern const mdb_tgt_gregset_t *kmdb_dpi_get_gregs(int);
101 
102 extern int kmdb_dpi_get_register(const char *, kreg_t *);
103 extern int kmdb_dpi_set_register(const char *, kreg_t);
104 
105 extern jmp_buf *kmdb_dpi_set_fault_hdlr(jmp_buf *);
106 extern void kmdb_dpi_restore_fault_hdlr(jmp_buf *);
107 
108 extern int kmdb_dpi_brkpt_arm(uintptr_t, mdb_instr_t *);
109 extern int kmdb_dpi_brkpt_disarm(uintptr_t, mdb_instr_t);
110 
111 extern int kmdb_dpi_wapt_validate(kmdb_wapt_t *);
112 extern int kmdb_dpi_wapt_reserve(kmdb_wapt_t *);
113 extern void kmdb_dpi_wapt_release(kmdb_wapt_t *);
114 extern void kmdb_dpi_wapt_arm(kmdb_wapt_t *);
115 extern void kmdb_dpi_wapt_disarm(kmdb_wapt_t *);
116 extern int kmdb_dpi_wapt_match(kmdb_wapt_t *);
117 
118 extern void kmdb_dpi_set_state(int, int);
119 extern int kmdb_dpi_get_state(int *);
120 
121 extern int kmdb_dpi_step(void);
122 
123 extern uintptr_t kmdb_dpi_call(uintptr_t, uint_t, const uintptr_t *);
124 
125 extern void kmdb_dpi_process_work_queue(void);
126 extern int kmdb_dpi_work_required(void);			/* Driver OK */
127 
128 extern void kmdb_dpi_flush_slave_caches(void);
129 
130 extern void kmdb_dpi_dump_crumbs(uintptr_t, int);
131 
132 /*
133  * Debugger/Kernel suspend
134  */
135 
136 extern jmp_buf kmdb_dpi_entry_pcb;
137 extern uint_t kmdb_dpi_resume_requested;			/* Driver OK */
138 extern uint_t kmdb_dpi_switch_target;				/* Driver OK */
139 extern jmp_buf kmdb_dpi_resume_pcb;
140 
141 extern int kmdb_dpi_reenter(void);
142 extern void kmdb_dpi_resume(void);
143 extern void kmdb_dpi_resume_unload(void);
144 extern int kmdb_dpi_switch_master(int);
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* _KMDB_DPI_H */
151