xref: /onnv-gate/usr/src/uts/common/sys/kdi_impl.h (revision 4652:017019fc1cf1)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53446Smrj  * Common Development and Distribution License (the "License").
63446Smrj  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
223446Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _KDI_IMPL_H
270Sstevel@tonic-gate #define	_KDI_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/kdi.h>
320Sstevel@tonic-gate #include <sys/kdi_machimpl.h>
333446Smrj #include <sys/privregs.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef __cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate struct module;
400Sstevel@tonic-gate struct gdscr;
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * The debugvec is used by the kernel to interact with the debugger.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate struct kdi_debugvec {
463446Smrj 	void	(*dv_kctl_vmready)(void);
473446Smrj 	void	(*dv_kctl_memavail)(void);
483446Smrj 	void	(*dv_kctl_modavail)(void);
493446Smrj 	void	(*dv_kctl_thravail)(void);
500Sstevel@tonic-gate 
510Sstevel@tonic-gate 	void	(*dv_vmready)(void);
523446Smrj 	void	(*dv_memavail)(caddr_t, size_t);
533446Smrj 	void	(*dv_mod_loaded)(struct modctl *);
543446Smrj 	void	(*dv_mod_unloading)(struct modctl *);
550Sstevel@tonic-gate 
563446Smrj #if defined(__i386) || defined(__amd64)
573446Smrj 	void	(*dv_handle_fault)(greg_t, greg_t, greg_t, int);
583446Smrj #endif
590Sstevel@tonic-gate #if defined(__sparc)
603446Smrj 	void	(*dv_kctl_cpu_init)(void);
613446Smrj 	void	(*dv_cpu_init)(struct cpu *);
620Sstevel@tonic-gate 	void	(*dv_cpr_restart)(void);
630Sstevel@tonic-gate #endif
640Sstevel@tonic-gate };
650Sstevel@tonic-gate 
660Sstevel@tonic-gate typedef struct kdi_plat {
670Sstevel@tonic-gate 	void (*pkdi_system_claim)(void);
680Sstevel@tonic-gate 	void (*pkdi_system_release)(void);
690Sstevel@tonic-gate 	void (*pkdi_console_claim)(void);
700Sstevel@tonic-gate 	void (*pkdi_console_release)(void);
710Sstevel@tonic-gate } kdi_plat_t;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #define	pkdi_system_claim	kdi_plat.pkdi_system_claim
740Sstevel@tonic-gate #define	pkdi_system_release	kdi_plat.pkdi_system_release
750Sstevel@tonic-gate #define	pkdi_console_claim	kdi_plat.pkdi_console_claim
760Sstevel@tonic-gate #define	pkdi_console_release	kdi_plat.pkdi_console_release
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /*
790Sstevel@tonic-gate  * The KDI, or Kernel/Debugger Interface, consists of an ops vector describing
800Sstevel@tonic-gate  * kernel services that may be directly invoked by the debugger.  Unless
810Sstevel@tonic-gate  * otherwise specified, the functions implementing this ops vector are designed
820Sstevel@tonic-gate  * to function when the debugger has control of the system - when all other CPUs
830Sstevel@tonic-gate  * have been stopped.  In such an environment, blocking services such as memory
840Sstevel@tonic-gate  * allocation or synchronization primitives are not available.
850Sstevel@tonic-gate  */
863446Smrj 
870Sstevel@tonic-gate struct kdi {
880Sstevel@tonic-gate 	int kdi_version;
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 	/*
910Sstevel@tonic-gate 	 * Determines whether significant changes (loads or unloads) have
920Sstevel@tonic-gate 	 * been made to the modules since the last time this op was invoked.
930Sstevel@tonic-gate 	 */
940Sstevel@tonic-gate 	int (*kdi_mods_changed)(void);
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 	/*
970Sstevel@tonic-gate 	 * Iterates through the current set of modctls, and invokes the
980Sstevel@tonic-gate 	 * caller-provided callback on each one.
990Sstevel@tonic-gate 	 */
1000Sstevel@tonic-gate 	int (*kdi_mod_iter)(int (*)(struct modctl *, void *), void *);
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	/*
1030Sstevel@tonic-gate 	 * Determines whether or not a given module is loaded.
1040Sstevel@tonic-gate 	 */
1050Sstevel@tonic-gate 	int (*kdi_mod_isloaded)(struct modctl *);
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 	/*
1080Sstevel@tonic-gate 	 * Has anything changed between two versions of the same modctl?
1090Sstevel@tonic-gate 	 */
1100Sstevel@tonic-gate 	int (*kdi_mod_haschanged)(struct modctl *, struct module *,
1110Sstevel@tonic-gate 	    struct modctl *, struct module *);
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate 	/*
1140Sstevel@tonic-gate 	 * Invoked by the debugger when it assumes control of the machine.
1150Sstevel@tonic-gate 	 */
1160Sstevel@tonic-gate 	void (*kdi_system_claim)(void);
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate 	/*
1190Sstevel@tonic-gate 	 * Invoked by the debugger when it relinquishes control of the machine.
1200Sstevel@tonic-gate 	 */
1210Sstevel@tonic-gate 	void (*kdi_system_release)(void);
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate 	int (*kdi_pread)(caddr_t, size_t, uint64_t, size_t *);
1240Sstevel@tonic-gate 	int (*kdi_pwrite)(caddr_t, size_t, uint64_t, size_t *);
1250Sstevel@tonic-gate 	void (*kdi_flush_caches)(void);
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 	size_t (*kdi_range_is_nontoxic)(uintptr_t, size_t, int);
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate 	struct cons_polledio *(*kdi_get_polled_io)(void);
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate 	int (*kdi_vtop)(uintptr_t, uint64_t *);
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate 	kdi_dtrace_state_t (*kdi_dtrace_get_state)(void);
1340Sstevel@tonic-gate 	int (*kdi_dtrace_set)(kdi_dtrace_set_t);
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate 	void (*kdi_plat_call)(void (*)(void));
1370Sstevel@tonic-gate 
1383446Smrj 	void (*kdi_kmdb_enter)(void);
1393446Smrj 
1400Sstevel@tonic-gate 	kdi_mach_t kdi_mach;
1410Sstevel@tonic-gate 	kdi_plat_t kdi_plat;
1420Sstevel@tonic-gate };
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate extern void kdi_softcall(void (*)(void));
145*4652Scwb extern void kdi_setsoftint(uint64_t);
1460Sstevel@tonic-gate extern int kdi_pread(caddr_t, size_t, uint64_t, size_t *);
1470Sstevel@tonic-gate extern int kdi_pwrite(caddr_t, size_t, uint64_t, size_t *);
1480Sstevel@tonic-gate extern size_t kdi_range_is_nontoxic(uintptr_t, size_t, int);
1490Sstevel@tonic-gate extern void kdi_flush_caches(void);
1500Sstevel@tonic-gate extern kdi_dtrace_state_t kdi_dtrace_get_state(void);
1510Sstevel@tonic-gate extern int kdi_vtop(uintptr_t, uint64_t *);
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate extern void cpu_kdi_init(kdi_t *);
1540Sstevel@tonic-gate extern void mach_kdi_init(kdi_t *);
1550Sstevel@tonic-gate extern void plat_kdi_init(kdi_t *);
1560Sstevel@tonic-gate 
1573446Smrj extern void *boot_kdi_tmpinit(void);
1583446Smrj extern void boot_kdi_tmpfini(void *);
1593446Smrj 
1600Sstevel@tonic-gate #ifdef __cplusplus
1610Sstevel@tonic-gate }
1620Sstevel@tonic-gate #endif
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate #endif /* _KDI_IMPL_H */
165