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.
26 #include <sys/cpuvar.h>
27 #include <sys/kdi_impl.h>
28 #include <sys/reboot.h>
29 #include <sys/errno.h>
30 #include <sys/atomic.h>
33 kdi_debugvec_t
*kdi_dvec
;
34 struct modctl
*kdi_dmods
;
36 static kdi_dtrace_state_t kdi_dtrace_state
= KDI_DTSTATE_IDLE
;
39 kdi_dvec_vmready(void)
41 kdi_dvec
->dv_kctl_vmready();
42 kdi_dvec
->dv_vmready();
46 kdi_dvec_memavail(void)
49 * The driver will allocate more memory (if requested), and will call
52 kdi_dvec
->dv_kctl_memavail();
57 kdi_dvec_handle_fault(greg_t trapno
, greg_t pc
, greg_t sp
, int cpuid
)
59 kdi_dvec
->dv_handle_fault(trapno
, pc
, sp
, cpuid
);
65 kdi_dvec_modavail(void)
67 kdi_dvec
->dv_kctl_modavail();
71 kdi_dvec_thravail(void)
73 kdi_dvec
->dv_kctl_thravail();
77 kdi_dvec_mod_loaded(struct modctl
*modp
)
79 kdi_dvec
->dv_mod_loaded(modp
);
83 kdi_dvec_mod_unloading(struct modctl
*modp
)
85 kdi_dvec
->dv_mod_unloading(modp
);
89 kdi_dtrace_get_state(void)
91 return (kdi_dtrace_state
);
95 kdi_dtrace_set(kdi_dtrace_set_t transition
)
97 kdi_dtrace_state_t
new, cur
;
100 cur
= kdi_dtrace_state
;
102 switch (transition
) {
103 case KDI_DTSET_DTRACE_ACTIVATE
:
104 if (cur
== KDI_DTSTATE_KMDB_BPT_ACTIVE
)
106 if (cur
== KDI_DTSTATE_DTRACE_ACTIVE
)
108 new = KDI_DTSTATE_DTRACE_ACTIVE
;
110 case KDI_DTSET_DTRACE_DEACTIVATE
:
111 if (cur
== KDI_DTSTATE_KMDB_BPT_ACTIVE
)
113 if (cur
== KDI_DTSTATE_IDLE
)
115 new = KDI_DTSTATE_IDLE
;
117 case KDI_DTSET_KMDB_BPT_ACTIVATE
:
118 if (cur
== KDI_DTSTATE_DTRACE_ACTIVE
)
120 if (cur
== KDI_DTSTATE_KMDB_BPT_ACTIVE
)
122 new = KDI_DTSTATE_KMDB_BPT_ACTIVE
;
124 case KDI_DTSET_KMDB_BPT_DEACTIVATE
:
125 if (cur
== KDI_DTSTATE_DTRACE_ACTIVE
)
127 if (cur
== KDI_DTSTATE_IDLE
)
129 new = KDI_DTSTATE_IDLE
;
134 } while (atomic_cas_32((uint_t
*)&kdi_dtrace_state
, cur
, new) != cur
);