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