4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <kmdb/kmdb_auxv.h>
32 #include <kmdb/kmdb_wr.h>
35 #include <sys/sunddi.h>
37 #include <sys/modctl.h>
38 #include <sys/ksynch.h>
45 KCTL_ST_INACTIVE
= 0, /* kmdb is inactive */
46 KCTL_ST_DSEG_ALLOCED
, /* kmdb segment has been allocated */
47 KCTL_ST_INITIALIZED
, /* kmdb_init has been called */
48 KCTL_ST_KCTL_PREACTIVATED
, /* kctl preactivation completed */
49 KCTL_ST_MOD_NOTIFIERS
, /* krtld module notifiers registered */
50 KCTL_ST_THREAD_STARTED
, /* WR queue thread started */
51 KCTL_ST_DBG_ACTIVATED
, /* kmdb activated */
52 KCTL_ST_ACTIVE
, /* kernel is aware of kmdb activation */
53 KCTL_ST_DEACTIVATING
/* debugger is being deactivated */
57 KCTL_WR_ST_RUN
, /* WR queue thread is running */
58 KCTL_WR_ST_STOP
, /* WR queue thread is stopping */
59 KCTL_WR_ST_STOPPED
/* WR queue thread has stopped */
63 dev_info_t
*kctl_drv_dip
; /* Driver's device info structure */
64 size_t kctl_memgoalsz
; /* Desired size of debugger memory */
65 caddr_t kctl_dseg
; /* Debugger segment (Oz) address */
66 size_t kctl_dseg_size
; /* Debugger segment (Oz) size */
67 caddr_t kctl_mrbase
; /* Add'l Oz memory range base address */
68 size_t kctl_mrsize
; /* Add'l Oz memory range size */
69 vnode_t kctl_vp
; /* vnode used to allocate dbgr seg */
70 kctl_state_t kctl_state
; /* State of debugger */
71 uint_t kctl_boot_loaded
; /* Set if debugger loaded at boot */
72 struct bootops
*kctl_boot_ops
; /* Boot operations (during init only) */
73 const char *kctl_execname
; /* Path of this module */
74 uint_t kctl_wr_avail
; /* Work available on the WR queue */
75 ksema_t kctl_wr_avail_sem
; /* For WR thr: Work avail on WR queue */
76 kthread_t
*kctl_wr_thr
; /* Thread that processes WR queue */
77 kctl_wr_state_t kctl_wr_state
; /* State of WR queue thread */
78 kmutex_t kctl_lock
; /* serializes (de)activation */
79 kcondvar_t kctl_wr_cv
; /* WR queue thread completion */
80 kmutex_t kctl_wr_lock
; /* WR queue thread completion */
81 uint_t kctl_flags
; /* KMDB_F_* from kmdb.h */
83 caddr_t kctl_tba
; /* kmdb's native trap table */
91 extern void kctl_dprintf(const char *, ...);
92 extern void kctl_warn(const char *, ...);
94 extern int kctl_preactivate_isadep(void);
95 extern void kctl_activate_isadep(kdi_debugvec_t
*);
96 extern void kctl_depreactivate_isadep(void);
97 extern void kctl_cleanup(void);
99 extern void *kctl_boot_tmpinit(void);
100 extern void kctl_boot_tmpfini(void *);
102 extern void kctl_auxv_init(kmdb_auxv_t
*, const char *, const char **, void *);
103 extern void kctl_auxv_init_isadep(kmdb_auxv_t
*, void *);
104 extern void kctl_auxv_fini(kmdb_auxv_t
*);
105 extern void kctl_auxv_fini_isadep(kmdb_auxv_t
*);
107 extern void kctl_auxv_set_promif(kmdb_auxv_t
*);
108 extern void kctl_switch_promif(void);
111 extern void kctl_wrintr(void);
112 extern void kctl_wrintr_fire(void);
113 extern void kctl_wr_thr_start(void);
114 extern void kctl_wr_thr_stop(void);
115 extern void kctl_wr_thr_join(void);
117 extern int kctl_mod_decompress(struct modctl
*);
118 extern void kctl_mod_loaded(struct modctl
*);
119 extern void kctl_mod_changed(uint_t
, struct modctl
*);
120 extern void kctl_mod_notify_reg(void);
121 extern void kctl_mod_notify_unreg(void);
123 extern void kctl_dmod_init(void);
124 extern void kctl_dmod_fini(void);
125 extern void kctl_dmod_sync(void);
126 extern void kctl_dmod_autoload(const char *);
127 extern void kctl_dmod_unload_all(void);
128 extern void kctl_dmod_path_reset(void);
130 extern int kctl_wr_process(void);
131 extern void kctl_wr_unload(void);
133 extern char *kctl_basename(char *);
134 extern char *kctl_strdup(const char *);
135 extern void kctl_strfree(char *);
138 extern kthread_t
*kctl_curthread_set(kthread_t
*);