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
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.
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]
23 * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #include <sys/mdb_modapi.h>
28 #include <sys/dditypes.h>
29 #include <sys/sysinfo.h>
30 #include <sys/1394/s1394.h>
32 static int print_node_info(s1394_hal_t
*hal
);
36 * is used to print node information (speed map, node number, GUID, etc.)
37 * about the 1394 devices currently attached to the 1394 bus.
40 speedmap(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
45 if (flags
& DCMD_ADDRSPEC
) {
46 if (mdb_vread(&hal
, sizeof (s1394_hal_t
), addr
) == -1) {
47 mdb_warn("failed to read the HAL structure");
51 ret
= print_node_info(&hal
);
55 (void) mdb_walk_dcmd("speedmap", "speedmap", argc
, argv
);
62 speedmap_walk_init(mdb_walk_state_t
*wsp
)
64 s1394_state_t
*statep
;
67 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
68 if (mdb_readvar(&statep
, "s1394_statep") == -1) {
69 mdb_warn("failed to find the s1394_statep pointer");
72 if (mdb_vread(&state
, sizeof (s1394_state_t
),
73 (uintptr_t)statep
) == -1) {
74 mdb_warn("failed to read the s1394_statep structure");
77 wsp
->walk_addr
= (uintptr_t)state
.hal_head
;
84 speedmap_walk_step(mdb_walk_state_t
*wsp
)
87 uintptr_t addr
= wsp
->walk_addr
;
89 if (addr
== (uintptr_t)NULL
)
92 if (mdb_vread(&hal
, sizeof (s1394_hal_t
), addr
) == -1) {
93 mdb_warn("failed to read the HAL structure");
97 wsp
->walk_addr
= (uintptr_t)hal
.hal_next
;
98 return (wsp
->walk_callback(addr
, &hal
, wsp
->walk_cbdata
));
103 speedmap_walk_fini(mdb_walk_state_t
*wsp
)
105 /* Nothing to do here */
108 static const mdb_dcmd_t dcmds
[] = {
109 { "speedmap", NULL
, "print 1394 bus information", speedmap
},
113 static const mdb_walker_t walkers
[] = {
114 { "speedmap", "iterate over HAL structures", speedmap_walk_init
,
115 speedmap_walk_step
, speedmap_walk_fini
},
119 static const mdb_modinfo_t modinfo
= {
120 MDB_API_VERSION
, dcmds
, walkers
123 const mdb_modinfo_t
*
131 * is used to do the actual printing, given a HAL pointer.
134 print_node_info(s1394_hal_t
*hal
)
136 s1394_node_t node
[IEEE1394_MAX_NODES
];
137 uint32_t cfgrom
[IEEE1394_CONFIG_ROM_QUAD_SZ
];
138 char str
[512], tmp
[512];
139 uint_t hal_node_num
, num_nodes
;
142 num_nodes
= hal
->number_of_nodes
;
143 if (mdb_vread(node
, (num_nodes
* sizeof (s1394_node_t
)),
144 (uintptr_t)hal
->topology_tree
) == -1) {
145 mdb_warn("failed to read the node structures");
149 hal_node_num
= IEEE1394_NODE_NUM(hal
->node_id
);
151 mdb_printf("Speed Map:\n");
153 (void) strcpy(str
, " |");
154 for (i
= 0; i
< num_nodes
; i
++) {
155 (void) mdb_snprintf(tmp
, sizeof (tmp
), " %2d ", i
);
156 (void) strcat(str
, tmp
);
158 (void) strcat(str
, " | GUID\n");
159 mdb_printf("%s", str
);
161 (void) strcpy(str
, "----|");
162 for (i
= 0; i
< hal
->number_of_nodes
; i
++) {
163 (void) mdb_snprintf(tmp
, sizeof (tmp
), "----");
164 (void) strcat(str
, tmp
);
166 (void) strcat(str
, "--|------------------\n");
167 mdb_printf("%s", str
);
169 for (i
= 0; i
< num_nodes
; i
++) {
170 if (node
[i
].cfgrom
!= NULL
) {
171 if (mdb_vread(&cfgrom
, IEEE1394_CONFIG_ROM_SZ
,
172 (uintptr_t)node
[i
].cfgrom
) == -1) {
173 mdb_warn("failed to read Config ROM");
178 (void) mdb_snprintf(str
, sizeof (str
), " %2d |", i
);
180 for (j
= 0; j
< num_nodes
; j
++) {
181 (void) mdb_snprintf(tmp
, sizeof (tmp
), " %3d",
182 hal
->speed_map
[i
][j
]);
183 (void) strcat(str
, tmp
);
186 if (i
== hal_node_num
) {
187 (void) strcat(str
, " | Local OHCI Card\n");
189 } else if (node
[i
].link_active
== 0) {
190 (void) strcat(str
, " | Link off\n");
192 } else if (CFGROM_BIB_READ(&node
[i
])) {
193 (void) mdb_snprintf(tmp
, sizeof (tmp
),
194 " | %08x%08x\n", cfgrom
[3], cfgrom
[4]);
195 (void) strcat(str
, tmp
);
198 (void) strcat(str
, " | ????????????????\n");
200 mdb_printf("%s", str
);