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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2005 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/mutex.h>
30 #include <sys/mdb_modapi.h>
31 #include <sys/sgsbbc_priv.h>
32
33 /*
34 * Given the address of a soft state pointer for the SGSBBC driver,
35 * this function displays the values of selected fields.
36 *
37 * You have to specify the address of the soft state structure you
38 * want to decode. This dcmd does not automatically work that out
39 * for you. The contents of <sbbcp> points to the variable pointing
40 * to the soft state pointers.
41 *
42 * (ie. typing "**sbbcp/10J" at the mdb prompt will list the addresses
43 * of the first 10 soft state structures (if they exist).
44 *
45 * It can also be obtained using mdb's softstate dcmd.
46 * "*sbbcp::softstate 0 | ::sgsbbc_softstate"
47 */
48 /* ARGSUSED */
49 int
display_sbbc_softstate_t(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)50 display_sbbc_softstate_t(uintptr_t addr, uint_t flags, int argc,
51 const mdb_arg_t *argv)
52 {
53 sbbc_softstate_t softp;
54
55 uint_t offset = 0; /* offset into soft state structure */
56 int rv; /* return value from mdb function */
57
58 /*
59 * You have to specify the address of the soft state structure you
60 * want to decode. This dcmd does not automatically work that out.
61 */
62 if ((flags & DCMD_ADDRSPEC) == 0)
63 return (DCMD_ERR);
64
65 rv = mdb_vread(&softp, sizeof (sbbc_softstate_t), addr);
66 if (rv != sizeof (sbbc_softstate_t)) {
67 mdb_warn("sgsbbc soft_state: Failed read on %ll#r", addr);
68 return (DCMD_ERR);
69 }
70
71 mdb_printf("---------- sbbc_softstate_t @ %#lr ----------\n", addr);
72
73 offset = (int)(uintptr_t)&softp.dip - (int)(uintptr_t)&softp;
74 mdb_printf("%p: dip: %31ll#r\n", addr + offset, softp.dip);
75
76 offset = (int)(uintptr_t)&softp.sram - (int)(uintptr_t)&softp;
77 mdb_printf("%p: sram: %30ll#r\n", addr + offset, softp.sram);
78
79 offset = (int)(uintptr_t)&softp.sbbc_regs - (int)(uintptr_t)&softp;
80 mdb_printf("%p: sbbc_regs: %25ll#r\n", addr + offset, softp.sbbc_regs);
81
82 offset = (int)(uintptr_t)&softp.port_int_regs - (int)(uintptr_t)&softp;
83 mdb_printf("%p: port_int_regs: %21ll#r\n", addr + offset,
84 softp.port_int_regs);
85
86 offset = (int)(uintptr_t)&softp.epld_regs - (int)(uintptr_t)&softp;
87 mdb_printf("%p: epld_regs: %25p\n", addr + offset, softp.epld_regs);
88
89 offset = (int)(uintptr_t)&softp.sram_toc - (int)(uintptr_t)&softp;
90 mdb_printf("%p: sram_toc: %26d\n", addr + offset, softp.sram_toc);
91
92 offset = (int)(uintptr_t)&softp.sbbc_reg_handle1 -
93 (int)(uintptr_t)&softp;
94 mdb_printf("%p: sbbc_reg_handle1: %18ll#r\n", addr + offset,
95 softp.sbbc_reg_handle1);
96
97 offset = (int)(uintptr_t)&softp.sbbc_reg_handle2 -
98 (int)(uintptr_t)&softp;
99 mdb_printf("%p: sbbc_reg_handle2: %18ll#r\n", addr + offset,
100 softp.sbbc_reg_handle2);
101
102 offset = (int)(uintptr_t)&softp.inumber - (int)(uintptr_t)&softp;
103 mdb_printf("%p: inumber: %27ll#r\n", addr + offset, softp.inumber);
104
105 offset = (int)(uintptr_t)&softp.intr_hdlrs - (int)(uintptr_t)&softp;
106 mdb_printf("%p: intr_hdlrs: %24ll#r\n", addr + offset,
107 softp.intr_hdlrs);
108
109 offset = (int)(uintptr_t)&softp.suspended - (int)(uintptr_t)&softp;
110 mdb_printf("%p: suspended: %25ll#r\n", addr + offset, softp.suspended);
111
112 offset = (int)(uintptr_t)&softp.chosen - (int)(uintptr_t)&softp;
113 mdb_printf("%p: chosen: %28ll#r\n", addr + offset, softp.chosen);
114
115 return (DCMD_OK);
116 }
117
118 /*
119 * MDB module linkage information:
120 */
121
122 static const mdb_dcmd_t dcmds[] = {{
123 "sgsbbc_softstate",
124 NULL,
125 "print SGSBBC mailbox driver softstate fields",
126 display_sbbc_softstate_t
127 }, { NULL }
128 };
129
130 static const mdb_modinfo_t modinfo = {
131 MDB_API_VERSION, dcmds, NULL
132 };
133
134 const mdb_modinfo_t *
_mdb_init(void)135 _mdb_init(void)
136 {
137 return (&modinfo);
138 }
139