1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/types.h>
30 #include <sys/kdi_impl.h>
31 #include <sys/segments.h>
32 #include <sys/cpuvar.h>
33 
34 #include <mdb/mdb_debug.h>
35 #include <mdb/mdb_err.h>
36 #include <mdb/mdb_umem.h>
37 #include <kmdb/kmdb_dpi.h>
38 #include <kmdb/kmdb_kdi_impl.h>
39 #include <mdb/mdb.h>
40 
41 void (**kmdb_kdi_shutdownp)(int, int);
42 
43 int
44 kmdb_kdi_xc_initialized(void)
45 {
46 	return (mdb.m_kdi->mkdi_xc_initialized());
47 }
48 
49 /*ARGSUSED*/
50 void
51 kmdb_kdi_stop_other_cpus(int my_cpuid, void (*slave_saver)(void))
52 {
53 	/* Stop other CPUs if there are CPUs to stop */
54 	if (mdb.m_kdi->mkdi_xc_initialized())
55 		mdb.m_kdi->mkdi_xc_others(my_cpuid, slave_saver);
56 }
57 
58 void
59 kmdb_kdi_cpu_iter(void (*iter)(struct cpu *, uint_t), uint_t arg)
60 {
61 	mdb.m_kdi->mkdi_cpu_iter(iter, arg);
62 }
63 
64 uintptr_t
65 kmdb_kdi_get_userlimit(void)
66 {
67 	return (mdb.m_kdi->mkdi_get_userlimit());
68 }
69 
70 void
71 kmdb_kdi_idt_init_gate(gate_desc_t *gate, void (*hdlr)(void), uint_t dpl,
72     int useboot)
73 {
74 	mdb.m_kdi->mkdi_idt_init_gate(gate, hdlr, dpl, useboot);
75 }
76 
77 void
78 kmdb_kdi_idt_read(gate_desc_t *idt, gate_desc_t *gatep, uint_t vec)
79 {
80 	mdb.m_kdi->mkdi_idt_read(idt, gatep, vec);
81 }
82 
83 void
84 kmdb_kdi_idt_write(gate_desc_t *idt, gate_desc_t *gate, uint_t vec)
85 {
86 	mdb.m_kdi->mkdi_idt_write(idt, gate, vec);
87 }
88 
89 gate_desc_t *
90 kmdb_kdi_cpu2idt(cpu_t *cp)
91 {
92 	return (mdb.m_kdi->mkdi_cpu2idt(cp));
93 }
94 
95 int
96 kmdb_kdi_get_cpuinfo(uint_t *vendorp, uint_t *familyp, uint_t *modelp)
97 {
98 	int err;
99 
100 	if ((err = mdb.m_kdi->mkdi_get_cpuinfo(vendorp, familyp, modelp)) != 0)
101 		return (set_errno(err));
102 
103 	return (0);
104 }
105 
106 /*ARGSUSED*/
107 void
108 kdi_cpu_init(void)
109 {
110 }
111 
112 /*ARGSUSED1*/
113 void
114 kmdb_kdi_init_isadep(kdi_t *kdi, kmdb_auxv_t *kav)
115 {
116 	kmdb_kdi_shutdownp = kdi->mkdi_shutdownp;
117 }
118