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. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _KDI_IMPL_H 277c478bd9Sstevel@tonic-gate #define _KDI_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/kdi.h> 327c478bd9Sstevel@tonic-gate #include <sys/kdi_machimpl.h> 33ae115bc7Smrj #include <sys/privregs.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate struct module; 407c478bd9Sstevel@tonic-gate struct gdscr; 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * The debugvec is used by the kernel to interact with the debugger. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate struct kdi_debugvec { 467c478bd9Sstevel@tonic-gate void (*dv_kctl_vmready)(void); 477c478bd9Sstevel@tonic-gate void (*dv_kctl_memavail)(void); 487c478bd9Sstevel@tonic-gate void (*dv_kctl_modavail)(void); 497c478bd9Sstevel@tonic-gate void (*dv_kctl_thravail)(void); 50ae115bc7Smrj 51ae115bc7Smrj void (*dv_vmready)(void); 52ae115bc7Smrj void (*dv_memavail)(caddr_t, size_t); 537c478bd9Sstevel@tonic-gate void (*dv_mod_loaded)(struct modctl *); 547c478bd9Sstevel@tonic-gate void (*dv_mod_unloading)(struct modctl *); 55ae115bc7Smrj 56ae115bc7Smrj #if defined(__i386) || defined(__amd64) 57ae115bc7Smrj void (*dv_handle_fault)(greg_t, greg_t, greg_t, int); 58ae115bc7Smrj #endif 59ae115bc7Smrj #if defined(__sparc) 60ae115bc7Smrj void (*dv_kctl_cpu_init)(void); 61ae115bc7Smrj void (*dv_cpu_init)(struct cpu *); 62ae115bc7Smrj void (*dv_cpr_restart)(void); 63ae115bc7Smrj #endif 647c478bd9Sstevel@tonic-gate }; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate typedef struct kdi_plat { 677c478bd9Sstevel@tonic-gate void (*pkdi_system_claim)(void); 687c478bd9Sstevel@tonic-gate void (*pkdi_system_release)(void); 697c478bd9Sstevel@tonic-gate void (*pkdi_console_claim)(void); 707c478bd9Sstevel@tonic-gate void (*pkdi_console_release)(void); 717c478bd9Sstevel@tonic-gate } kdi_plat_t; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define pkdi_system_claim kdi_plat.pkdi_system_claim 747c478bd9Sstevel@tonic-gate #define pkdi_system_release kdi_plat.pkdi_system_release 757c478bd9Sstevel@tonic-gate #define pkdi_console_claim kdi_plat.pkdi_console_claim 767c478bd9Sstevel@tonic-gate #define pkdi_console_release kdi_plat.pkdi_console_release 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * The KDI, or Kernel/Debugger Interface, consists of an ops vector describing 807c478bd9Sstevel@tonic-gate * kernel services that may be directly invoked by the debugger. Unless 817c478bd9Sstevel@tonic-gate * otherwise specified, the functions implementing this ops vector are designed 827c478bd9Sstevel@tonic-gate * to function when the debugger has control of the system - when all other CPUs 837c478bd9Sstevel@tonic-gate * have been stopped. In such an environment, blocking services such as memory 847c478bd9Sstevel@tonic-gate * allocation or synchronization primitives are not available. 857c478bd9Sstevel@tonic-gate */ 86ae115bc7Smrj 877c478bd9Sstevel@tonic-gate struct kdi { 887c478bd9Sstevel@tonic-gate int kdi_version; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * Determines whether significant changes (loads or unloads) have 927c478bd9Sstevel@tonic-gate * been made to the modules since the last time this op was invoked. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate int (*kdi_mods_changed)(void); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Iterates through the current set of modctls, and invokes the 987c478bd9Sstevel@tonic-gate * caller-provided callback on each one. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate int (*kdi_mod_iter)(int (*)(struct modctl *, void *), void *); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * Determines whether or not a given module is loaded. 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate int (*kdi_mod_isloaded)(struct modctl *); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * Has anything changed between two versions of the same modctl? 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate int (*kdi_mod_haschanged)(struct modctl *, struct module *, 1117c478bd9Sstevel@tonic-gate struct modctl *, struct module *); 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* 1147c478bd9Sstevel@tonic-gate * Invoked by the debugger when it assumes control of the machine. 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate void (*kdi_system_claim)(void); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /* 1197c478bd9Sstevel@tonic-gate * Invoked by the debugger when it relinquishes control of the machine. 1207c478bd9Sstevel@tonic-gate */ 1217c478bd9Sstevel@tonic-gate void (*kdi_system_release)(void); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate int (*kdi_pread)(caddr_t, size_t, uint64_t, size_t *); 1247c478bd9Sstevel@tonic-gate int (*kdi_pwrite)(caddr_t, size_t, uint64_t, size_t *); 1257c478bd9Sstevel@tonic-gate void (*kdi_flush_caches)(void); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate size_t (*kdi_range_is_nontoxic)(uintptr_t, size_t, int); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate struct cons_polledio *(*kdi_get_polled_io)(void); 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate int (*kdi_vtop)(uintptr_t, uint64_t *); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate kdi_dtrace_state_t (*kdi_dtrace_get_state)(void); 1347c478bd9Sstevel@tonic-gate int (*kdi_dtrace_set)(kdi_dtrace_set_t); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate void (*kdi_plat_call)(void (*)(void)); 1377c478bd9Sstevel@tonic-gate 138ae115bc7Smrj void (*kdi_kmdb_enter)(void); 139ae115bc7Smrj 1407c478bd9Sstevel@tonic-gate kdi_mach_t kdi_mach; 1417c478bd9Sstevel@tonic-gate kdi_plat_t kdi_plat; 1427c478bd9Sstevel@tonic-gate }; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate extern void kdi_softcall(void (*)(void)); 145*a1af7ba0Scwb extern void kdi_setsoftint(uint64_t); 1467c478bd9Sstevel@tonic-gate extern int kdi_pread(caddr_t, size_t, uint64_t, size_t *); 1477c478bd9Sstevel@tonic-gate extern int kdi_pwrite(caddr_t, size_t, uint64_t, size_t *); 1487c478bd9Sstevel@tonic-gate extern size_t kdi_range_is_nontoxic(uintptr_t, size_t, int); 1497c478bd9Sstevel@tonic-gate extern void kdi_flush_caches(void); 1507c478bd9Sstevel@tonic-gate extern kdi_dtrace_state_t kdi_dtrace_get_state(void); 1517c478bd9Sstevel@tonic-gate extern int kdi_vtop(uintptr_t, uint64_t *); 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate extern void cpu_kdi_init(kdi_t *); 1547c478bd9Sstevel@tonic-gate extern void mach_kdi_init(kdi_t *); 1557c478bd9Sstevel@tonic-gate extern void plat_kdi_init(kdi_t *); 1567c478bd9Sstevel@tonic-gate 157ae115bc7Smrj extern void *boot_kdi_tmpinit(void); 158ae115bc7Smrj extern void boot_kdi_tmpfini(void *); 159ae115bc7Smrj 1607c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate #endif 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #endif /* _KDI_IMPL_H */ 165