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 _KDI_IMPL_H 27 #define _KDI_IMPL_H 28 29 #include <sys/kdi.h> 30 #include <sys/kdi_machimpl.h> 31 #include <sys/privregs.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 struct module; 38 struct gdscr; 39 40 /* 41 * The debugvec is used by the kernel to interact with the debugger. 42 */ 43 struct kdi_debugvec { 44 void (*dv_kctl_vmready)(void); 45 void (*dv_kctl_memavail)(void); 46 void (*dv_kctl_modavail)(void); 47 void (*dv_kctl_thravail)(void); 48 49 void (*dv_vmready)(void); 50 void (*dv_memavail)(caddr_t, size_t); 51 void (*dv_mod_loaded)(struct modctl *); 52 void (*dv_mod_unloading)(struct modctl *); 53 54 #if defined(__i386) || defined(__amd64) 55 void (*dv_handle_fault)(greg_t, greg_t, greg_t, int); 56 #endif 57 #if defined(__sparc) 58 void (*dv_kctl_cpu_init)(void); 59 void (*dv_cpu_init)(struct cpu *); 60 void (*dv_cpr_restart)(void); 61 #endif 62 }; 63 64 typedef struct kdi_plat { 65 void (*pkdi_system_claim)(void); 66 void (*pkdi_system_release)(void); 67 void (*pkdi_console_claim)(void); 68 void (*pkdi_console_release)(void); 69 } kdi_plat_t; 70 71 #define pkdi_system_claim kdi_plat.pkdi_system_claim 72 #define pkdi_system_release kdi_plat.pkdi_system_release 73 #define pkdi_console_claim kdi_plat.pkdi_console_claim 74 #define pkdi_console_release kdi_plat.pkdi_console_release 75 76 /* 77 * The KDI, or Kernel/Debugger Interface, consists of an ops vector describing 78 * kernel services that may be directly invoked by the debugger. Unless 79 * otherwise specified, the functions implementing this ops vector are designed 80 * to function when the debugger has control of the system - when all other CPUs 81 * have been stopped. In such an environment, blocking services such as memory 82 * allocation or synchronization primitives are not available. 83 */ 84 85 struct kdi { 86 int kdi_version; 87 88 /* 89 * Determines whether significant changes (loads or unloads) have 90 * been made to the modules since the last time this op was invoked. 91 */ 92 int (*kdi_mods_changed)(void); 93 94 /* 95 * Iterates through the current set of modctls, and invokes the 96 * caller-provided callback on each one. 97 */ 98 int (*kdi_mod_iter)(int (*)(struct modctl *, void *), void *); 99 100 /* 101 * Determines whether or not a given module is loaded. 102 */ 103 int (*kdi_mod_isloaded)(struct modctl *); 104 105 /* 106 * Has anything changed between two versions of the same modctl? 107 */ 108 int (*kdi_mod_haschanged)(struct modctl *, struct module *, 109 struct modctl *, struct module *); 110 111 /* 112 * Invoked by the debugger when it assumes control of the machine. 113 */ 114 void (*kdi_system_claim)(void); 115 116 /* 117 * Invoked by the debugger when it relinquishes control of the machine. 118 */ 119 void (*kdi_system_release)(void); 120 121 int (*kdi_pread)(caddr_t, size_t, uint64_t, size_t *); 122 int (*kdi_pwrite)(caddr_t, size_t, uint64_t, size_t *); 123 void (*kdi_flush_caches)(void); 124 125 size_t (*kdi_range_is_nontoxic)(uintptr_t, size_t, int); 126 127 struct cons_polledio *(*kdi_get_polled_io)(void); 128 129 int (*kdi_vtop)(uintptr_t, uint64_t *); 130 131 kdi_dtrace_state_t (*kdi_dtrace_get_state)(void); 132 int (*kdi_dtrace_set)(kdi_dtrace_set_t); 133 134 void (*kdi_plat_call)(void (*)(void)); 135 136 void (*kdi_kmdb_enter)(void); 137 138 kdi_mach_t kdi_mach; 139 kdi_plat_t kdi_plat; 140 }; 141 142 extern void kdi_softcall(void (*)(void)); 143 extern void kdi_setsoftint(uint64_t); 144 extern int kdi_pread(caddr_t, size_t, uint64_t, size_t *); 145 extern int kdi_pwrite(caddr_t, size_t, uint64_t, size_t *); 146 extern size_t kdi_range_is_nontoxic(uintptr_t, size_t, int); 147 extern void kdi_flush_caches(void); 148 extern kdi_dtrace_state_t kdi_dtrace_get_state(void); 149 extern int kdi_vtop(uintptr_t, uint64_t *); 150 151 extern void cpu_kdi_init(kdi_t *); 152 extern void mach_kdi_init(kdi_t *); 153 extern void plat_kdi_init(kdi_t *); 154 155 extern void *boot_kdi_tmpinit(void); 156 extern void boot_kdi_tmpfini(void *); 157 158 #ifdef __cplusplus 159 } 160 #endif 161 162 #endif /* _KDI_IMPL_H */ 163