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 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/mdb_modapi.h>
30 #include <sys/dditypes.h>
31 #include <sys/sysinfo.h>
32 #include <sys/1394/s1394.h>
34 static int print_node_info(s1394_hal_t
*hal
);
38 * is used to print node information (speed map, node number, GUID, etc.)
39 * about the 1394 devices currently attached to the 1394 bus.
42 speedmap(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
47 if (flags
& DCMD_ADDRSPEC
) {
48 if (mdb_vread(&hal
, sizeof (s1394_hal_t
), addr
) == -1) {
49 mdb_warn("failed to read the HAL structure");
53 ret
= print_node_info(&hal
);
57 (void) mdb_walk_dcmd("speedmap", "speedmap", argc
, argv
);
64 speedmap_walk_init(mdb_walk_state_t
*wsp
)
66 s1394_state_t
*statep
;
69 if (wsp
->walk_addr
== NULL
) {
70 if (mdb_readvar(&statep
, "s1394_statep") == -1) {
71 mdb_warn("failed to find the s1394_statep pointer");
74 if (mdb_vread(&state
, sizeof (s1394_state_t
),
75 (uintptr_t)statep
) == -1) {
76 mdb_warn("failed to read the s1394_statep structure");
79 wsp
->walk_addr
= (uintptr_t)state
.hal_head
;
86 speedmap_walk_step(mdb_walk_state_t
*wsp
)
89 uintptr_t addr
= wsp
->walk_addr
;
94 if (mdb_vread(&hal
, sizeof (s1394_hal_t
), addr
) == -1) {
95 mdb_warn("failed to read the HAL structure");
99 wsp
->walk_addr
= (uintptr_t)hal
.hal_next
;
100 return (wsp
->walk_callback(addr
, &hal
, wsp
->walk_cbdata
));
105 speedmap_walk_fini(mdb_walk_state_t
*wsp
)
107 /* Nothing to do here */
110 static const mdb_dcmd_t dcmds
[] = {
111 { "speedmap", NULL
, "print 1394 bus information", speedmap
},
115 static const mdb_walker_t walkers
[] = {
116 { "speedmap", "iterate over HAL structures", speedmap_walk_init
,
117 speedmap_walk_step
, speedmap_walk_fini
},
121 static const mdb_modinfo_t modinfo
= {
122 MDB_API_VERSION
, dcmds
, walkers
125 const mdb_modinfo_t
*
133 * is used to do the actual printing, given a HAL pointer.
136 print_node_info(s1394_hal_t
*hal
)
138 s1394_node_t node
[IEEE1394_MAX_NODES
];
139 uint32_t cfgrom
[IEEE1394_CONFIG_ROM_QUAD_SZ
];
140 char str
[512], tmp
[512];
141 uint_t hal_node_num
, num_nodes
;
144 num_nodes
= hal
->number_of_nodes
;
145 if (mdb_vread(node
, (num_nodes
* sizeof (s1394_node_t
)),
146 (uintptr_t)hal
->topology_tree
) == -1) {
147 mdb_warn("failed to read the node structures");
151 hal_node_num
= IEEE1394_NODE_NUM(hal
->node_id
);
153 mdb_printf("Speed Map:\n");
155 (void) strcpy(str
, " |");
156 for (i
= 0; i
< num_nodes
; i
++) {
157 (void) mdb_snprintf(tmp
, sizeof (tmp
), " %2d ", i
);
158 (void) strcat(str
, tmp
);
160 (void) strcat(str
, " | GUID\n");
161 mdb_printf("%s", str
);
163 (void) strcpy(str
, "----|");
164 for (i
= 0; i
< hal
->number_of_nodes
; i
++) {
165 (void) mdb_snprintf(tmp
, sizeof (tmp
), "----");
166 (void) strcat(str
, tmp
);
168 (void) strcat(str
, "--|------------------\n");
169 mdb_printf("%s", str
);
171 for (i
= 0; i
< num_nodes
; i
++) {
172 if (node
[i
].cfgrom
!= NULL
) {
173 if (mdb_vread(&cfgrom
, IEEE1394_CONFIG_ROM_SZ
,
174 (uintptr_t)node
[i
].cfgrom
) == -1) {
175 mdb_warn("failed to read Config ROM");
180 (void) mdb_snprintf(str
, sizeof (str
), " %2d |", i
);
182 for (j
= 0; j
< num_nodes
; j
++) {
183 (void) mdb_snprintf(tmp
, sizeof (tmp
), " %3d",
184 hal
->speed_map
[i
][j
]);
185 (void) strcat(str
, tmp
);
188 if (i
== hal_node_num
) {
189 (void) strcat(str
, " | Local OHCI Card\n");
191 } else if (node
[i
].link_active
== 0) {
192 (void) strcat(str
, " | Link off\n");
194 } else if (CFGROM_BIB_READ(&node
[i
])) {
195 (void) mdb_snprintf(tmp
, sizeof (tmp
),
196 " | %08x%08x\n", cfgrom
[3], cfgrom
[4]);
197 (void) strcat(str
, tmp
);
200 (void) strcat(str
, " | ????????????????\n");
202 mdb_printf("%s", str
);