xref: /titanic_50/usr/src/uts/common/sys/kdi.h (revision 01f19855c272b5ab349dd1175fe302692565c657)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*01f19855Scth  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _KDI_H
287c478bd9Sstevel@tonic-gate #define	_KDI_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * The Kernel/Debugger interface.
347c478bd9Sstevel@tonic-gate  *
357c478bd9Sstevel@tonic-gate  * The Debugger -> Kernel portion of the interface is handled by the kdi_t,
367c478bd9Sstevel@tonic-gate  * which is defined in the archkdi.h files.  These functions are intended to
377c478bd9Sstevel@tonic-gate  * be called only when the system is stopped and the debugger is in control.
387c478bd9Sstevel@tonic-gate  *
397c478bd9Sstevel@tonic-gate  * The Kernel -> Debugger portion is handled by the debugvec_t, which is
407c478bd9Sstevel@tonic-gate  * defined here.  These functions are used by the kernel to inform the debugger
417c478bd9Sstevel@tonic-gate  * of various state changes.
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef __cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /* The VA range reserved for the debugger. */
497c478bd9Sstevel@tonic-gate #if defined(__sparc)
507c478bd9Sstevel@tonic-gate #define	SEGDEBUGBASE	0xedd00000
517c478bd9Sstevel@tonic-gate #define	SEGDEBUGSIZE	(0xf0000000 - SEGDEBUGBASE)
527c478bd9Sstevel@tonic-gate #elif defined(__amd64)
537c478bd9Sstevel@tonic-gate #define	SEGDEBUGBASE	0xffffffffff800000
547c478bd9Sstevel@tonic-gate #define	SEGDEBUGSIZE	0x400000
557c478bd9Sstevel@tonic-gate #else
567c478bd9Sstevel@tonic-gate #define	SEGDEBUGBASE	0xff800000
577c478bd9Sstevel@tonic-gate #define	SEGDEBUGSIZE	0x400000
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate struct cpu;
617c478bd9Sstevel@tonic-gate struct modctl;
627c478bd9Sstevel@tonic-gate struct gate_desc;
637c478bd9Sstevel@tonic-gate struct user_desc;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate typedef struct kdi_debugvec kdi_debugvec_t;
667c478bd9Sstevel@tonic-gate typedef struct kdi kdi_t;
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate extern kdi_debugvec_t	*kdi_dvec;
69*01f19855Scth extern struct modctl	*kdi_dmods;
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	KDI_VERSION		6
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate extern void kdi_dvec_enter(void);
747c478bd9Sstevel@tonic-gate extern void kdi_dvec_cpu_init(struct cpu *);
757c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
767c478bd9Sstevel@tonic-gate extern void kdi_dvec_idt_sync(struct gate_desc *);
777c478bd9Sstevel@tonic-gate #endif	/* __i386 || __amd64 */
787c478bd9Sstevel@tonic-gate extern void kdi_dvec_vmready(void);
797c478bd9Sstevel@tonic-gate extern void kdi_dvec_memavail(void);
807c478bd9Sstevel@tonic-gate #if defined(__sparc)
817c478bd9Sstevel@tonic-gate extern void kdi_dvec_cpr_restart(void);
827c478bd9Sstevel@tonic-gate #endif
837c478bd9Sstevel@tonic-gate extern void kdi_dvec_modavail(void);
847c478bd9Sstevel@tonic-gate extern void kdi_dvec_thravail(void);
857c478bd9Sstevel@tonic-gate extern void kdi_dvec_mod_loaded(struct modctl *);
867c478bd9Sstevel@tonic-gate extern void kdi_dvec_mod_unloading(struct modctl *);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * The state machine described below is used to coordinate the efforts of
907c478bd9Sstevel@tonic-gate  * kmdb and dtrace.  As both use breakpoints, only one may be currently be
917c478bd9Sstevel@tonic-gate  * active at a given time.  Transitions are possible between the idle state
927c478bd9Sstevel@tonic-gate  * and either of the active states, but not directly between the two active
937c478bd9Sstevel@tonic-gate  * states.
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate typedef enum kdi_dtrace_set {
967c478bd9Sstevel@tonic-gate 	KDI_DTSET_DTRACE_ACTIVATE,
977c478bd9Sstevel@tonic-gate 	KDI_DTSET_DTRACE_DEACTIVATE,
987c478bd9Sstevel@tonic-gate 	KDI_DTSET_KMDB_BPT_ACTIVATE,
997c478bd9Sstevel@tonic-gate 	KDI_DTSET_KMDB_BPT_DEACTIVATE
1007c478bd9Sstevel@tonic-gate } kdi_dtrace_set_t;
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate typedef enum {
1037c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_DTRACE_ACTIVE,
1047c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_IDLE,
1057c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_KMDB_BPT_ACTIVE
1067c478bd9Sstevel@tonic-gate } kdi_dtrace_state_t;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate extern int kdi_dtrace_set(kdi_dtrace_set_t);
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1117c478bd9Sstevel@tonic-gate }
1127c478bd9Sstevel@tonic-gate #endif
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #endif /* _KDI_H */
115