xref: /illumos-gate/usr/src/uts/common/sys/kdi.h (revision 2d6eb4a5)
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
5*ae115bc7Smrj  * Common Development and Distribution License (the "License").
6*ae115bc7Smrj  * 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 /*
22*ae115bc7Smrj  * 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_H
277c478bd9Sstevel@tonic-gate #define	_KDI_H
287c478bd9Sstevel@tonic-gate 
29*ae115bc7Smrj #include <sys/types.h>
30*ae115bc7Smrj 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * The Kernel/Debugger interface.
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * The Debugger -> Kernel portion of the interface is handled by the kdi_t,
357c478bd9Sstevel@tonic-gate  * which is defined in the archkdi.h files.  These functions are intended to
367c478bd9Sstevel@tonic-gate  * be called only when the system is stopped and the debugger is in control.
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * The Kernel -> Debugger portion is handled by the debugvec_t, which is
397c478bd9Sstevel@tonic-gate  * defined here.  These functions are used by the kernel to inform the debugger
407c478bd9Sstevel@tonic-gate  * of various state changes.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifdef __cplusplus
447c478bd9Sstevel@tonic-gate extern "C" {
457c478bd9Sstevel@tonic-gate #endif
467c478bd9Sstevel@tonic-gate 
47*ae115bc7Smrj /*
48*ae115bc7Smrj  * The VA range reserved for the debugger; used by kmdb.
49*ae115bc7Smrj  */
50*ae115bc7Smrj extern const caddr_t kdi_segdebugbase;
51*ae115bc7Smrj extern const size_t kdi_segdebugsize;
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate struct cpu;
547c478bd9Sstevel@tonic-gate struct modctl;
557c478bd9Sstevel@tonic-gate struct gate_desc;
567c478bd9Sstevel@tonic-gate struct user_desc;
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate typedef struct kdi_debugvec kdi_debugvec_t;
597c478bd9Sstevel@tonic-gate typedef struct kdi kdi_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate extern kdi_debugvec_t	*kdi_dvec;
6201f19855Scth extern struct modctl	*kdi_dmods;
637c478bd9Sstevel@tonic-gate 
64*ae115bc7Smrj #define	KDI_VERSION		7
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate extern void kdi_dvec_vmready(void);
677c478bd9Sstevel@tonic-gate extern void kdi_dvec_memavail(void);
687c478bd9Sstevel@tonic-gate #if defined(__sparc)
69*ae115bc7Smrj extern void kdi_dvec_cpu_init(struct cpu *);
707c478bd9Sstevel@tonic-gate extern void kdi_dvec_cpr_restart(void);
717c478bd9Sstevel@tonic-gate #endif
727c478bd9Sstevel@tonic-gate extern void kdi_dvec_modavail(void);
737c478bd9Sstevel@tonic-gate extern void kdi_dvec_thravail(void);
747c478bd9Sstevel@tonic-gate extern void kdi_dvec_mod_loaded(struct modctl *);
757c478bd9Sstevel@tonic-gate extern void kdi_dvec_mod_unloading(struct modctl *);
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * The state machine described below is used to coordinate the efforts of
797c478bd9Sstevel@tonic-gate  * kmdb and dtrace.  As both use breakpoints, only one may be currently be
807c478bd9Sstevel@tonic-gate  * active at a given time.  Transitions are possible between the idle state
817c478bd9Sstevel@tonic-gate  * and either of the active states, but not directly between the two active
827c478bd9Sstevel@tonic-gate  * states.
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate typedef enum kdi_dtrace_set {
857c478bd9Sstevel@tonic-gate 	KDI_DTSET_DTRACE_ACTIVATE,
867c478bd9Sstevel@tonic-gate 	KDI_DTSET_DTRACE_DEACTIVATE,
877c478bd9Sstevel@tonic-gate 	KDI_DTSET_KMDB_BPT_ACTIVATE,
887c478bd9Sstevel@tonic-gate 	KDI_DTSET_KMDB_BPT_DEACTIVATE
897c478bd9Sstevel@tonic-gate } kdi_dtrace_set_t;
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate typedef enum {
927c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_DTRACE_ACTIVE,
937c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_IDLE,
947c478bd9Sstevel@tonic-gate 	KDI_DTSTATE_KMDB_BPT_ACTIVE
957c478bd9Sstevel@tonic-gate } kdi_dtrace_state_t;
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate extern int kdi_dtrace_set(kdi_dtrace_set_t);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1007c478bd9Sstevel@tonic-gate }
1017c478bd9Sstevel@tonic-gate #endif
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #endif /* _KDI_H */
104