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