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 2000-2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Routines extracted from usr/src/uts/common/io/usb/usba/usba.c.
33 #include <sys/mdb_modapi.h>
34 #include <sys/usb/usba.h>
35 #include <sys/usb/usba/usba_types.h>
36 #include <sys/usb/usba/usba_impl.h>
37 #include <sys/usb/usba/hcdi_impl.h>
39 #include <sys/sunndi.h>
43 * check whether this dip is the root hub.
44 * dip_addr is address of the devinfo struct in the core image (not local space)
47 mdb_usba_is_root_hub(struct dev_info
*dip
)
49 uintptr_t p
= (uintptr_t)dip
->devi_hw_prop_ptr
;
55 if (mdb_vread(&prop
, sizeof (prop
), p
) == -1) {
56 mdb_warn("failed to read property");
59 if (mdb_readstr(prop_name
, sizeof (prop_name
),
60 (uintptr_t)prop
.prop_name
) == -1) {
61 mdb_warn("failed to read property name");
64 if (strcmp(prop_name
, "root-hub") == 0) {
69 p
= (uintptr_t)prop
.prop_next
;
77 * retrieve hcdi structure from the dip
79 * dip_addr is address of the devinfo struct in the core image (not local space)
82 mdb_usba_hcdi_get_hcdi(struct dev_info
*dip
)
84 return ((uintptr_t)dip
->devi_driver_data
);
89 * get usba_device pointer in the devi
91 * dip_addr is address of the devinfo struct in the core image (not local space)
94 mdb_usba_get_usba_device(uintptr_t dip_addr
)
96 struct dev_info devinfo
;
98 if (mdb_vread(&devinfo
, sizeof (struct dev_info
), dip_addr
) == -1) {
99 mdb_warn("failed to read dev_info at %p", dip_addr
);
105 * we cannot use parent_data in the usb node because its
106 * bus parent (eg. PCI nexus driver) uses this data
108 * we cannot use driver data in the other usb nodes since
109 * usb drivers may need to use this
111 if (mdb_usba_is_root_hub(&devinfo
)) {
112 usba_hcdi_t hcdi_struct
;
113 uintptr_t hcdi_addr
= mdb_usba_hcdi_get_hcdi(&devinfo
);
120 /* Read hcdi struct into local address space. */
121 if (mdb_vread(&hcdi_struct
, sizeof (usba_hcdi_t
),
123 mdb_warn("failed to read hcdi struct");
128 return ((uintptr_t)hcdi_struct
.hcdi_usba_device
);
131 struct dev_info devinfo
;
133 if (mdb_vread(&devinfo
, sizeof (struct dev_info
),
135 mdb_warn("failed to read dev_info at %p", dip_addr
);
140 /* casts needed to keep lint happy */
141 return ((uintptr_t)devinfo
.devi_parent_data
);