xref: /illumos-gate/usr/src/cmd/mdb/common/kmdb/kmdb_dpi.h (revision 2a8bcb4e)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _KMDB_DPI_H
28*7c478bd9Sstevel@tonic-gate #define	_KMDB_DPI_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Retargetable Kmdb/PROM interface
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
35*7c478bd9Sstevel@tonic-gate #include <setjmp.h>
36*7c478bd9Sstevel@tonic-gate #ifdef	__sparc
37*7c478bd9Sstevel@tonic-gate #include <sys/regset.h>
38*7c478bd9Sstevel@tonic-gate #endif	/* __sparc */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #include <mdb/mdb_kreg.h>
41*7c478bd9Sstevel@tonic-gate #include <mdb/mdb_target.h>
42*7c478bd9Sstevel@tonic-gate #include <kmdb/kmdb_auxv.h>
43*7c478bd9Sstevel@tonic-gate #include <kmdb/kmdb_dpi_isadep.h>
44*7c478bd9Sstevel@tonic-gate #include <kmdb/kmdb_kctl.h>
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /*
47*7c478bd9Sstevel@tonic-gate  * The following directive tells the mapfile generator that only those
48*7c478bd9Sstevel@tonic-gate  * prototypes and declarations ending with a "Driver OK" comment should be
49*7c478bd9Sstevel@tonic-gate  * included in the mapfile.
50*7c478bd9Sstevel@tonic-gate  *
51*7c478bd9Sstevel@tonic-gate  * MAPFILE: export "Driver OK"
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
55*7c478bd9Sstevel@tonic-gate extern "C" {
56*7c478bd9Sstevel@tonic-gate #endif
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #define	DPI_MASTER_CPUID	(-1)	/* matches CPU ID for master */
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate #define	DPI_ALLOW_FAULTS	NULL
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_INIT		1	/* debugger initializing */
63*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_STOPPED	2	/* User-requested stop (debug_enter) */
64*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_FAULTED	3	/* Breakpoint, watchpoint, etc. */
65*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_LOST		4	/* debugger fault */
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_WHY_BKPT	1
68*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_WHY_V_WAPT	2
69*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_WHY_P_WAPT	3
70*7c478bd9Sstevel@tonic-gate #define	DPI_STATE_WHY_TRAP	4
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate #define	DPI_WAPT_TYPE_PHYS	0x1	/* Physical address (SPARC only) */
73*7c478bd9Sstevel@tonic-gate #define	DPI_WAPT_TYPE_VIRT	0x2	/* Virtual address */
74*7c478bd9Sstevel@tonic-gate #define	DPI_WAPT_TYPE_IO	0x4	/* I/O space (Intel only) */
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate #define	DPI_CPU_STATE_NONE	0
77*7c478bd9Sstevel@tonic-gate #define	DPI_CPU_STATE_MASTER	1
78*7c478bd9Sstevel@tonic-gate #define	DPI_CPU_STATE_SLAVE	2
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate typedef struct dpi_ops dpi_ops_t;
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate typedef struct kmdb_wapt {
83*7c478bd9Sstevel@tonic-gate 	uintptr_t wp_addr;		/* Watchpoint base address */
84*7c478bd9Sstevel@tonic-gate 	size_t wp_size;			/* Size of watched area, in bytes */
85*7c478bd9Sstevel@tonic-gate 	int wp_type;			/* DPI_WAPT_TYPE_* */
86*7c478bd9Sstevel@tonic-gate 	uint_t wp_wflags;		/* access modes */
87*7c478bd9Sstevel@tonic-gate 	void *wp_priv;			/* DPI-private data */
88*7c478bd9Sstevel@tonic-gate } kmdb_wapt_t;
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_init(kmdb_auxv_t *);
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_enter_mon(void);
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_modchg_register(void (*)(struct modctl *, int));
95*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_modchg_cancel(void);
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_get_cpu_state(int);
98*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_get_master_cpuid(void);
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate extern const mdb_tgt_gregset_t *kmdb_dpi_get_gregs(int);
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_get_register(const char *, kreg_t *);
103*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_set_register(const char *, kreg_t);
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate extern jmp_buf *kmdb_dpi_set_fault_hdlr(jmp_buf *);
106*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_restore_fault_hdlr(jmp_buf *);
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_brkpt_arm(uintptr_t, mdb_instr_t *);
109*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_brkpt_disarm(uintptr_t, mdb_instr_t);
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_wapt_validate(kmdb_wapt_t *);
112*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_wapt_reserve(kmdb_wapt_t *);
113*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_wapt_release(kmdb_wapt_t *);
114*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_wapt_arm(kmdb_wapt_t *);
115*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_wapt_disarm(kmdb_wapt_t *);
116*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_wapt_match(kmdb_wapt_t *);
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_set_state(int, int);
119*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_get_state(int *);
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_step(void);
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate extern uintptr_t kmdb_dpi_call(uintptr_t, uint_t, const uintptr_t *);
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_process_work_queue(void);
126*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_work_required(void);			/* Driver OK */
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_flush_slave_caches(void);
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_dump_crumbs(uintptr_t, int);
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /*
133*7c478bd9Sstevel@tonic-gate  * Debugger/Kernel suspend
134*7c478bd9Sstevel@tonic-gate  */
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate extern jmp_buf kmdb_dpi_entry_pcb;
137*7c478bd9Sstevel@tonic-gate extern uint_t kmdb_dpi_resume_requested;			/* Driver OK */
138*7c478bd9Sstevel@tonic-gate extern uint_t kmdb_dpi_switch_target;				/* Driver OK */
139*7c478bd9Sstevel@tonic-gate extern jmp_buf kmdb_dpi_resume_pcb;
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_reenter(void);
142*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_resume(void);
143*7c478bd9Sstevel@tonic-gate extern void kmdb_dpi_resume_unload(void);
144*7c478bd9Sstevel@tonic-gate extern int kmdb_dpi_switch_master(int);
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
147*7c478bd9Sstevel@tonic-gate }
148*7c478bd9Sstevel@tonic-gate #endif
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate #endif /* _KMDB_DPI_H */
151