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 26 #ifndef _KMDB_DPI_IMPL_H 27 #define _KMDB_DPI_IMPL_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 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 #if defined(__i386) || defined(__amd64) 90 void (*dpo_step_branch)(void); 91 #endif 92 93 uintptr_t (*dpo_call)(uintptr_t, uint_t, const uintptr_t *); 94 95 void (*dpo_dump_crumbs)(uintptr_t, int); 96 97 #if defined(__i386) || defined(__amd64) 98 void (*dpo_msr_add)(const kdi_msr_t *); 99 uint64_t (*dpo_msr_get)(int, uint_t); 100 #endif 101 102 #ifdef __sparc 103 void (*dpo_kernpanic)(int); 104 #endif 105 }; 106 107 extern void (*kmdb_dpi_wrintr_fire)(void); 108 109 extern dpi_ops_t kmdb_dpi_ops; 110 111 extern void kmdb_dpi_resume_common(int); 112 extern void kmdb_dpi_resume_master(void); 113 114 /* Used by the debugger to tell the driver how to resume */ 115 #define KMDB_DPI_CMD_RESUME_ALL 1 /* Resume all CPUs */ 116 #define KMDB_DPI_CMD_RESUME_MASTER 2 /* Resume only master CPU */ 117 #define KMDB_DPI_CMD_RESUME_UNLOAD 3 /* Resume for debugger unload */ 118 #define KMDB_DPI_CMD_SWITCH_CPU 4 /* Switch to another CPU */ 119 #define KMDB_DPI_CMD_FLUSH_CACHES 5 /* Flush slave caches */ 120 #define KMDB_DPI_CMD_REBOOT 6 /* Reboot the machine */ 121 122 #ifdef __cplusplus 123 } 124 #endif 125 126 #endif /* _KMDB_DPI_IMPL_H */ 127