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 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _KMDB_DPI_IMPL_H 28 #define _KMDB_DPI_IMPL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <setjmp.h> 33 #ifdef __sparc 34 #include <sys/regset.h> 35 #endif /* __sparc */ 36 #include <sys/types.h> 37 38 #include <kmdb/kmdb_auxv.h> 39 #include <kmdb/kmdb_dpi.h> 40 #include <mdb/mdb_kreg.h> 41 #include <mdb/mdb_target.h> 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 extern jmp_buf *kmdb_dpi_fault_pcb; 48 49 /* 50 * The routines used by the kmdb side of the DPI to access the saved state 51 * of the current kernel instance, and to control that instance. A populated 52 * version of this vector is provided by the DPI backend used to control the 53 * machine. General use of the kmdb DPI is not via direct invocation of the 54 * functions in this ops vector, but rather flows through the convenience 55 * wrappers in kmdb_dpi.c. 56 */ 57 struct dpi_ops { 58 int (*dpo_init)(kmdb_auxv_t *); 59 60 void (*dpo_debugger_activate)(kdi_debugvec_t **, uint_t); 61 void (*dpo_debugger_deactivate)(void); 62 63 void (*dpo_enter_mon)(void); 64 65 void (*dpo_modchg_register)(void (*)(struct modctl *, int)); 66 void (*dpo_modchg_cancel)(void); 67 68 int (*dpo_get_cpu_state)(int); 69 int (*dpo_get_master_cpuid)(void); 70 71 const mdb_tgt_gregset_t *(*dpo_get_gregs)(int); 72 int (*dpo_get_register)(const char *, kreg_t *); 73 int (*dpo_set_register)(const char *, kreg_t); 74 #ifdef __sparc 75 int (*dpo_get_rwin)(int, int, struct rwindow *); 76 int (*dpo_get_nwin)(int); 77 #endif 78 79 int (*dpo_brkpt_arm)(uintptr_t, mdb_instr_t *); 80 int (*dpo_brkpt_disarm)(uintptr_t, mdb_instr_t); 81 82 int (*dpo_wapt_validate)(kmdb_wapt_t *); 83 int (*dpo_wapt_reserve)(kmdb_wapt_t *); 84 void (*dpo_wapt_release)(kmdb_wapt_t *); 85 void (*dpo_wapt_arm)(kmdb_wapt_t *); 86 void (*dpo_wapt_disarm)(kmdb_wapt_t *); 87 int (*dpo_wapt_match)(kmdb_wapt_t *); 88 89 int (*dpo_step)(void); 90 #if defined(__i386) || defined(__amd64) 91 void (*dpo_step_branch)(void); 92 #endif 93 94 uintptr_t (*dpo_call)(uintptr_t, uint_t, const uintptr_t *); 95 96 void (*dpo_dump_crumbs)(uintptr_t, int); 97 98 int (*dpo_memrange_add)(caddr_t, size_t); 99 100 #if defined(__i386) || defined(__amd64) 101 void (*dpo_msr_add)(const kmdb_msr_t *); 102 uint64_t (*dpo_msr_get)(int, uint_t); 103 #endif 104 105 #ifdef __sparc 106 void (*dpo_kernpanic)(int); 107 #endif 108 }; 109 110 extern void (*kmdb_dpi_wrintr_fire)(void); 111 112 extern dpi_ops_t kmdb_dpi_ops; 113 114 extern void kmdb_dpi_resume_common(int); 115 extern void kmdb_dpi_resume_master(void); 116 117 /* Used by the debugger to tell the driver how to resume */ 118 #define KMDB_DPI_CMD_RESUME_ALL 1 /* Resume all CPUs */ 119 #define KMDB_DPI_CMD_RESUME_MASTER 2 /* Resume only master CPU */ 120 #define KMDB_DPI_CMD_RESUME_UNLOAD 3 /* Resume for debugger unload */ 121 #define KMDB_DPI_CMD_SWITCH_CPU 4 /* Switch to another CPU */ 122 #define KMDB_DPI_CMD_FLUSH_CACHES 5 /* Flush slave caches */ 123 #define KMDB_DPI_CMD_REBOOT 6 /* Reboot the machine */ 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 #endif /* _KMDB_DPI_IMPL_H */ 130