17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ae115bc7Smrj  * Common Development and Distribution License (the "License").
6ae115bc7Smrj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22ae115bc7Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
24*399ca3a7SJohn Levon  *
25*399ca3a7SJohn Levon  * Copyright 2018 Joyent, Inc.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef _KMDB_DPI_IMPL_H
297c478bd9Sstevel@tonic-gate #define	_KMDB_DPI_IMPL_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <setjmp.h>
327c478bd9Sstevel@tonic-gate #ifdef	__sparc
337c478bd9Sstevel@tonic-gate #include <sys/regset.h>
347c478bd9Sstevel@tonic-gate #endif	/* __sparc */
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <kmdb/kmdb_auxv.h>
387c478bd9Sstevel@tonic-gate #include <kmdb/kmdb_dpi.h>
397c478bd9Sstevel@tonic-gate #include <mdb/mdb_kreg.h>
407c478bd9Sstevel@tonic-gate #include <mdb/mdb_target.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef __cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate extern jmp_buf *kmdb_dpi_fault_pcb;
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * The routines used by the kmdb side of the DPI to access the saved state
507c478bd9Sstevel@tonic-gate  * of the current kernel instance, and to control that instance.  A populated
517c478bd9Sstevel@tonic-gate  * version of this vector is provided by the DPI backend used to control the
527c478bd9Sstevel@tonic-gate  * machine.  General use of the kmdb DPI is not via direct invocation of the
537c478bd9Sstevel@tonic-gate  * functions in this ops vector, but rather flows through the convenience
547c478bd9Sstevel@tonic-gate  * wrappers in kmdb_dpi.c.
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate struct dpi_ops {
577c478bd9Sstevel@tonic-gate 	int (*dpo_init)(kmdb_auxv_t *);
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate 	void (*dpo_debugger_activate)(kdi_debugvec_t **, uint_t);
607c478bd9Sstevel@tonic-gate 	void (*dpo_debugger_deactivate)(void);
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	void (*dpo_enter_mon)(void);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 	void (*dpo_modchg_register)(void (*)(struct modctl *, int));
657c478bd9Sstevel@tonic-gate 	void (*dpo_modchg_cancel)(void);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 	int (*dpo_get_cpu_state)(int);
687c478bd9Sstevel@tonic-gate 	int (*dpo_get_master_cpuid)(void);
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate 	const mdb_tgt_gregset_t *(*dpo_get_gregs)(int);
71acbc304dSjohnlev 	int (*dpo_get_register)(const char *, kreg_t *);
72acbc304dSjohnlev 	int (*dpo_set_register)(const char *, kreg_t);
737c478bd9Sstevel@tonic-gate #ifdef __sparc
747c478bd9Sstevel@tonic-gate 	int (*dpo_get_rwin)(int, int, struct rwindow *);
757c478bd9Sstevel@tonic-gate 	int (*dpo_get_nwin)(int);
767c478bd9Sstevel@tonic-gate #endif
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 	int (*dpo_brkpt_arm)(uintptr_t, mdb_instr_t *);
797c478bd9Sstevel@tonic-gate 	int (*dpo_brkpt_disarm)(uintptr_t, mdb_instr_t);
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	int (*dpo_wapt_validate)(kmdb_wapt_t *);
827c478bd9Sstevel@tonic-gate 	int (*dpo_wapt_reserve)(kmdb_wapt_t *);
837c478bd9Sstevel@tonic-gate 	void (*dpo_wapt_release)(kmdb_wapt_t *);
847c478bd9Sstevel@tonic-gate 	void (*dpo_wapt_arm)(kmdb_wapt_t *);
857c478bd9Sstevel@tonic-gate 	void (*dpo_wapt_disarm)(kmdb_wapt_t *);
867c478bd9Sstevel@tonic-gate 	int (*dpo_wapt_match)(kmdb_wapt_t *);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate 	int (*dpo_step)(void);
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	uintptr_t (*dpo_call)(uintptr_t, uint_t, const uintptr_t *);
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	void (*dpo_dump_crumbs)(uintptr_t, int);
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #ifdef __sparc
957c478bd9Sstevel@tonic-gate 	void (*dpo_kernpanic)(int);
967c478bd9Sstevel@tonic-gate #endif
977c478bd9Sstevel@tonic-gate };
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate extern void (*kmdb_dpi_wrintr_fire)(void);
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate extern dpi_ops_t kmdb_dpi_ops;
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate extern void kmdb_dpi_resume_common(int);
1047c478bd9Sstevel@tonic-gate extern void kmdb_dpi_resume_master(void);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /* Used by the debugger to tell the driver how to resume */
1077c478bd9Sstevel@tonic-gate #define	KMDB_DPI_CMD_RESUME_ALL		1	/* Resume all CPUs */
1087c478bd9Sstevel@tonic-gate #define	KMDB_DPI_CMD_RESUME_MASTER	2	/* Resume only master CPU */
1097c478bd9Sstevel@tonic-gate #define	KMDB_DPI_CMD_RESUME_UNLOAD	3	/* Resume for debugger unload */
1107c478bd9Sstevel@tonic-gate #define	KMDB_DPI_CMD_SWITCH_CPU		4	/* Switch to another CPU */
1117c478bd9Sstevel@tonic-gate #define	KMDB_DPI_CMD_FLUSH_CACHES	5	/* Flush slave caches */
1127c478bd9Sstevel@tonic-gate #define	KMDB_DPI_CMD_REBOOT		6	/* Reboot the machine */
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate #endif
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #endif /* _KMDB_DPI_IMPL_H */
119