/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/mdb_modapi.h>
/* ****************************************************************** */
/* extenal definition */
typedef struct mdb_ctf_id {
} mdb_ctf_id_t;
extern int mdb_ctf_lookup_by_name(const char *, mdb_ctf_id_t *);
/* ****************************************************************** */
/* internal definition */
typedef struct usb_descr_item {
/* define the known descriptor items */
{1, "bLength"},
{1, "bDescriptorType"},
{2, "wTotalLength"},
{1, "bNumInterfaces"},
{1, "bConfigurationValue"},
{1, "iConfiguration"},
{1, "bmAttributes"},
{1, "bMaxPower"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bFirstInterface"},
{1, "bInterfaceCount"},
{1, "bFunctionClass"},
{1, "bFunctionSubClass"},
{1, "bFunctionProtocol"},
{1, "iFunction"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bInterfaceNumber"},
{1, "bAlternateSetting"},
{1, "bNumEndpoints"},
{1, "bInterfaceClass"},
{1, "bInterfaceSubClass"},
{1, "bInterfaceProtocol"},
{1, "iInterface"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bEndpointAddress"},
{1, "bmAttributes"},
{2, "wMaxPacketSize"},
{1, "bInterval"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{2, "bcdUSB"},
{1, "bDeviceClass"},
{1, "bDeviceSubClass"},
{1, "bDeviceProtocol"},
{1, "bMaxPacketSize0"},
{1, "bNumConfigurations"},
{1, "bReserved"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bString"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{2, "bcdWAVersion"},
{1, "bNumPorts"},
{1, "bmAttributes"},
{2, "wNumRPipes"},
{2, "wRPipeMaxBlock"},
{1, "bRPipeBlockSize"},
{1, "bPwrOn2PwrGood"},
{1, "bNumMMCIEs"},
{1, "DeviceRemovable"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{2, "bcdHID"},
{1, "bCountryCode"},
{1, "bNumDescriptors"},
{1, "bReportDescriptorType"},
{2, "wReportDescriptorLength"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{2, "bcdADC"},
{2, "wTotalLength"},
{1, "blnCollection"},
{1, "baInterfaceNr"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bTerminalID"},
{2, "wTerminalType"},
{1, "bAssocTerminal"},
{1, "bNrChannels"},
{2, "wChannelConfig"},
{1, "iChannelNames"},
{1, "iTerminal"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bTerminalID"},
{2, "wTerminalType"},
{1, "bAssocTerminal"},
{1, "bSourceID"},
{1, "iTerminal"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bUnitID"},
{1, "bNrInPins"},
{1, "baSourceID"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bUnitID"},
{1, "bNrInPins"},
{1, "baSourceID"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bUnitID"},
{1, "bSourceID"},
{1, "bControlSize"},
{1, "bmaControls"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bUnitID"},
{1, "wProcessType"},
{1, "bNrInPins"},
{1, "baSourceID"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "wExtensionCode"},
{1, "bUnitID"},
{1, "bNrInPins"},
{1, "baSourceID"},
};
{1, "blength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bmAttributes"},
{1, "bLockDelayUnits"},
{2, "wLockDelay"},
};
{1, "blength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bTerminalLink"},
{1, "bDelay"},
{2, "wFormatTag"},
};
{1, "blength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bFormatType"},
{1, "bNrChannels"},
{1, "bSubFrameSize"},
{1, "bBitResolution"},
{1, "bSamFreqType"},
{1, "bSamFreqs"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubtype"},
{2, "bcdUVC"},
{2, "wTotalLength"},
{4, "dwClockFrequency"},
{1, "bInCollection"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bTerminalID"},
{2, "wTerminalType"},
{1, "AssocTerminal"},
{1, "iTerminal"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bTerminalID"},
{2, "wTerminalType"},
{1, "AssocTerminal"},
{1, "bSourceID"},
{1, "iTerminal"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bUnitID"},
{1, "bSourceID"},
{2, "wMaxMultiplier"},
{1, "bControlSize"},
{1, "bmControls"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bUnitID"},
{1, "bNrInPins"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bUnitID"},
{1, "bNumControls"},
{1, "bNrInPins"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bNumFormats"},
{2, "wTotalLength"},
{1, "bEndpointAddress"},
{1, "bmInfo"},
{1, "bTerminalLink"},
{1, "bStillCaptureMethod"},
{1, "bTriggerSupport"},
{1, "bTriggerUsage"},
{1, "bControlSize"},
{1, "bmaControls"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bNumFormats"},
{2, "wTotalLength"},
{1, "bEndpointAddress"},
{1, "bTerminalLink"},
{1, "bControlSize"},
{1, "bmaControls"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bEndpointAddress"},
{1, "bNumImageSizePatterns"},
{2, "wWidth"},
{2, "wHeight"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubtype"},
{1, "bColorPrimaries"},
{1, "bTransferCharacteristics"},
{1, "bMatrixCoefficients"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bFrameIndex"},
{1, "bmCapabilities"},
{2, "wWidth"},
{2, "wHeight"},
{4, "dwMinBitRate"},
{4, "dwMaxBitRate"},
{4, "dwMaxVideoFrameBufferSize"},
{4, "dwDefaultFrameInterval"},
{1, "bFrameIntervalType"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bFormatIndex"},
{1, "bNumFrameDescriptors"},
{1, "bmFlags"},
{1, "bDefaultFrameIndex"},
{1, "bAspectRatioX"},
{1, "bAspectRatioY"},
{1, "bmInterlaceFlags"},
{1, "bCopyProtect"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bFormatIndex"},
{1, "bNumFrameDescriptors"},
{1, "bBitsPerPixel"},
{1, "bDefaultFrameIndex"},
{1, "bAspectRatioX"},
{1, "bAspectRatioY"},
{1, "bmInterlaceFlags"},
{1, "bCopyProtect"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bFormatIndex"},
{1, "bDataOffset"},
{1, "bPacketLength"},
{1, "bStrideLength"},
};
{1, "bLength"},
{1, "bDescriptorType"},
{1, "bDescriptorSubType"},
{1, "bFormatIndex"},
{4, "dwMaxVideoFrameBufferSize"},
{1, "bFormatType"},
};
/* ****************************************************************** */
typedef struct hci_state {
void *hci_dip;
void *hci_hcdi_ops;
} hci_state_t;
/* ****************************************************************** */
/* exported functions */
void prt_usb_usage(void);
/* ****************************************************************** */
/* help of prtusb */
void
prt_usb_usage(void)
{
}
/* the entry of ::prtusb */
int
{
/* print all usba devices if no address assigned */
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("failed to walk usba_device");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/* for the first device, print head */
if (DCMD_HDRSPEC(flags)) {
count = 1;
mdb_printf("%<u>%-8s%-12s%-6s%-16s%-12s%-20s%</u>\n",
"INDEX", "DRIVER", "INST", "NODE", "VID.PID", "PRODUCT");
}
return (DCMD_USAGE);
}
mdb_warn("Failed to read usba_device!\n");
return (DCMD_ERR);
}
mdb_warn("Failed to read dev_info!\n");
return (DCMD_ERR);
}
/* process the "-i" */
count++;
return (DCMD_OK);
}
/* index number of device node */
/* driver and instance */
/* node name */
} else {
}
/* vid.pid */
mdb_printf("%04x.%04x ",
}
/* product string */
} else {
}
/* tree, print usb device tree info */
mdb_printf("mfg_prod_sn: ");
} else {
mdb_printf("NULL - ");
}
} else {
mdb_printf("NULL -");
}
} else {
mdb_printf("NULL");
}
mdb_printf("\n\n");
}
/* verbose, print all descriptors */
int i;
mdb_printf("\n");
/* device descriptor */
/* config cloud descriptors */
mdb_inc_indent(4);
mdb_printf("-- Active Config Index 0\n");
mdb_dec_indent(4);
} else {
/* multiple configs */
for (i = 0; i < usb_dev.usb_n_cfgs; i++) {
!= -1) &&
!= -1)) {
mdb_inc_indent(4);
if (cfg_buf ==
mdb_printf("-- Active Config"
" Index %x\n", i);
} else {
mdb_printf("-- Inactive Config"
" Index %x\n", i);
}
mdb_dec_indent(4);
}
}
}
}
if (usb_flag) {
}
return (DCMD_OK);
}
/* print the info required by "-t" */
static int
{
mdb_warn("prt_usb_tree: Failed to read dev_info!\n");
return (DCMD_ERR);
}
if (usb_dip.devi_child) {
mdb_printf("{\n");
mdb_inc_indent(4);
mdb_dec_indent(4);
mdb_printf("}\n\n");
}
/* print the sibling if flag == 1 */
}
return (DCMD_OK);
}
static int
{
mdb_warn("prt_usb_tree_node: Failed to read dev_info!\n");
return (DCMD_ERR);
}
/* node name */
} else {
}
/* instance */
/* driver name */
} else {
mdb_printf("(driver not attached)\n");
}
/* device path */
/* dip addr */
/* softe_sate */
}
/* error level */
}
{MDB_TYPE_STRING, {"ehci_state_t"}},
{MDB_TYPE_STRING, {"ehci_root_hub.rh_descr"}}
};
}
{MDB_TYPE_STRING, {"ohci_state_t"}},
{MDB_TYPE_STRING, {"ohci_root_hub.rh_descr"}}
};
}
{MDB_TYPE_STRING, {"uhci_state_t"}},
{MDB_TYPE_STRING, {"uhci_root_hub.rh_descr"}}
};
}
{MDB_TYPE_STRING, {"hubd_t"}},
{MDB_TYPE_STRING, {"h_hub_descr"}}
};
}
mdb_inc_indent(2);
mdb_printf("\n");
mdb_dec_indent(2);
}
}
}
mdb_printf("\n");
return (DCMD_OK);
}
/* print hid report descriptor */
static void
{
mdb_inc_indent(4);
mdb_dec_indent(4);
}
if (item.entity_item_right_sibling) {
}
}
}
static void
{
switch (item->entity_item_type) {
case 0x80:
mdb_printf("INPUT ");
break;
case 0x90:
mdb_printf("OUTPUT ");
break;
case 0xA0:
mdb_printf("COLLECTION ");
break;
case 0xB0:
mdb_printf("FEATURE ");
break;
case 0xC0:
mdb_printf("END_COLLECTION ");
break;
default:
mdb_printf("MAIN_ITEM ");
break;
}
mdb_printf("\n");
}
static void
{
mdb_printf("\n");
if (attr.entity_attribute_next) {
}
}
}
static void
{
int i;
if (len > 4) {
return;
}
mdb_printf("( ");
for (i = 0; i < len; i++) {
}
mdb_printf(")");
}
}
static void
{
switch (tag) {
case 0x04:
mdb_printf("usage page ");
break;
case 0x14:
mdb_printf("logical minimum ");
break;
case 0x24:
mdb_printf("logical maximum ");
break;
case 0x34:
mdb_printf("physical minimum ");
break;
case 0x44:
mdb_printf("physical maximum ");
break;
case 0x54:
mdb_printf("exponent ");
break;
case 0x64:
mdb_printf("unit ");
break;
case 0x74:
mdb_printf("report size ");
break;
case 0x84:
mdb_printf("report id ");
break;
case 0x94:
mdb_printf("report count ");
break;
case 0x08:
mdb_printf("usage ");
break;
case 0x18:
mdb_printf("usage min ");
break;
case 0x28:
mdb_printf("usage max ");
break;
default:
mdb_printf("tag ");
}
}
/* print the info required by "-v" */
static int
{
return (DCMD_ERR);
}
return (DCMD_ERR);
}
switch (desc_type) {
case USB_DESCR_TYPE_DEV:
mdb_printf("Device Descriptor\n");
break;
case USB_DESCR_TYPE_CFG:
indent = 4;
mdb_printf("Configuration Descriptor\n");
break;
case USB_DESCR_TYPE_STRING:
mdb_printf("String Descriptor\n");
break;
case USB_DESCR_TYPE_IF:
indent = 8;
mdb_printf("Interface Descriptor\n");
break;
case USB_DESCR_TYPE_EP:
indent = 8;
mdb_printf("Endpoint Descriptor\n");
break;
case USB_DESCR_TYPE_DEV_QLF:
mdb_printf("Device_Qualifier Descriptor\n");
break;
indent = 4;
mdb_printf("Other_Speed_Configuration Descriptor\n");
break;
case USB_DESCR_TYPE_IA:
indent = 6;
mdb_printf("Interface_Association Descriptor\n");
break;
case 0x21: /* hid descriptor */
indent = 12;
mdb_printf("WA Descriptor\n");
} else {
mdb_printf("HID Descriptor\n");
}
break;
case 0x24: /* class specific interfce descriptor */
indent = 12;
mdb_printf("AudioControl_Interface: ");
mdb_printf("AudioStream_Interface: ");
mdb_printf("VideoControl_Interface: ");
mdb_printf("VideoStream_Interface: ");
} else {
mdb_printf("Unknown_Interface:"
"0x%x\n", desc_type);
}
break;
case 0x25: /* class specific endpoint descriptor */
indent = 12;
mdb_printf("AudioEndpoint:\n");
mdb_printf("VideoEndpoint:\n");
} else {
mdb_printf("Unknown_Endpoint:"
"0x%x\n", desc_type);
}
break;
default:
break;
}
return (DCMD_ERR);
}
};
return (DCMD_OK);
}
/* print audio class specific control descriptor */
static int
{
return (DCMD_ERR);
}
switch (sub_type) {
case 0x01:
mdb_printf("header Descriptor\n");
break;
case 0x02:
mdb_printf("input_terminal Descriptor\n");
break;
case 0x03:
mdb_printf("output_terminal Descriptor\n");
break;
case 0x04:
mdb_printf("mixer_unit Descriptor\n");
break;
case 0x05:
mdb_printf("selector_unit Descriptor\n");
break;
case 0x06:
mdb_printf("feature_unit Descriptor\n");
break;
case 0x07:
mdb_printf("processing_unit Descriptor\n");
break;
case 0x08:
mdb_printf("extension_unit Descriptor\n");
break;
default:
break;
}
return (DCMD_OK);
}
/* print audio class specific stream descriptor */
static int
{
return (DCMD_ERR);
}
switch (sub_type) {
case 0x01:
mdb_printf("general_interface Descriptor\n");
break;
case 0x02:
mdb_printf("format_type Descriptor\n");
break;
default:
break;
}
return (DCMD_OK);
}
/* print video class specific control descriptor */
static int
{
return (DCMD_ERR);
}
switch (sub_type) {
case 0x01:
mdb_printf("header Descriptor\n");
break;
case 0x02:
mdb_printf("input_terminal Descriptor\n");
break;
case 0x03:
mdb_printf("output_terminal Descriptor\n");
break;
case 0x04:
mdb_printf("selector_unit Descriptor\n");
break;
case 0x05:
mdb_printf("processing_unit Descriptor\n");
break;
case 0x06:
mdb_printf("extension_unit Descriptor\n");
break;
default:
break;
}
return (DCMD_OK);
}
/* print video class specific stream descriptor */
static int
{
return (DCMD_ERR);
}
switch (sub_type) {
case 0x01:
mdb_printf("input_header Descriptor\n");
break;
case 0x02:
mdb_printf("output_header Descriptor\n");
break;
case 0x03:
mdb_printf("still_image_frame Descriptor\n");
break;
case 0x04:
mdb_printf("format_uncompressed Descriptor\n");
break;
case 0x05:
mdb_printf("frame_uncompressed Descriptor\n");
break;
case 0x06:
mdb_printf("format_mjpeg Descriptor\n");
break;
case 0x07:
mdb_printf("frame_mjpeg Descriptor\n");
break;
case 0x0A:
mdb_printf("format_mpeg2ts Descriptor\n");
break;
case 0x0C:
mdb_printf("format_dv Descriptor\n");
break;
case 0x0D:
mdb_printf("color_matching Descriptor\n");
break;
default:
break;
}
return (DCMD_OK);
}
/* parse and print the descriptor items */
static int
{
int i, j;
usb_descr_item_t *p = item;
mdb_printf("{");
switch (p->nlen) {
case 1: /* uint8_t */
return (DCMD_ERR);
}
break;
case 2: /* uint16_t */
return (DCMD_ERR);
}
break;
case 4: /* uint32_t */
return (DCMD_ERR);
}
break;
case 8: /* uint64_t */
return (DCMD_ERR);
}
(value << 32);
break;
default: /* byte array */
value = 0;
/* print an array instead of a value */
for (j = 0; j < p->nlen - BYTE_OFFSET; j++) {
break;
}
}
break;
}
if (p->nlen > BYTE_OFFSET) {
} else {
}
p++;
}
/* print the unresolved bytes */
mdb_printf("\n ... =");
}
break;
}
}
mdb_printf("\n}\n");
return (DCMD_OK);
}
/* print the buffer as a struct */
static int
{
} else {
}
return (DCMD_OK);
}
/* print the buffer as a byte array */
static int
{
int i;
mdb_printf("{\n");
for (i = 0; i < nlen; i++) {
break;
}
}
if (nlen) {
mdb_printf("\n");
}
mdb_printf("}\n");
return (DCMD_OK);
}