Add "usbconfig dump_all_desc", a subcommand to dump all device and config

descriptors.

Reviewed by:	hselasky@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Edward Tomasz Napierala 2018-03-13 19:49:06 +00:00
parent 2f5a9b7661
commit cd1fd29c26
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=330875
2 changed files with 18 additions and 1 deletions

View File

@ -97,6 +97,8 @@ Remove a quirk.
Add quirk for the currently selected USB device.
.It Cm remove_quirk Ar quirk_name
Remove a quirk for the currently selected USB device.
.It Cm dump_all_desc
Display the device and configuration descriptors.
.It Cm dump_quirk_names
Display the list of supported quirk names.
.It Cm dump_device_quirks

View File

@ -77,6 +77,7 @@ struct options {
uint8_t got_power_on:1;
uint8_t got_dump_device_quirks:1;
uint8_t got_dump_quirk_names:1;
uint8_t got_dump_all_desc:1;
uint8_t got_dump_device_desc:1;
uint8_t got_dump_curr_config:1;
uint8_t got_dump_all_config:1;
@ -112,6 +113,7 @@ enum {
T_SHOW_IFACE_DRIVER,
T_DUMP_QUIRK_NAMES,
T_DUMP_DEVICE_QUIRKS,
T_DUMP_ALL_DESC,
T_DUMP_DEVICE_DESC,
T_DUMP_CURR_CONFIG_DESC,
T_DUMP_ALL_CONFIG_DESC,
@ -144,6 +146,7 @@ static const struct token token[] = {
{"remove_quirk", T_REMOVE_QUIRK, 1},
{"dump_quirk_names", T_DUMP_QUIRK_NAMES, 0},
{"dump_device_quirks", T_DUMP_DEVICE_QUIRKS, 0},
{"dump_all_desc", T_DUMP_ALL_DESC, 0},
{"dump_device_desc", T_DUMP_DEVICE_DESC, 0},
{"dump_curr_config_desc", T_DUMP_CURR_CONFIG_DESC, 0},
{"dump_all_config_desc", T_DUMP_ALL_CONFIG_DESC, 0},
@ -283,6 +286,7 @@ usage(void)
" remove_quirk <quirk>" "\n"
" dump_quirk_names" "\n"
" dump_device_quirks" "\n"
" dump_all_desc" "\n"
" dump_device_desc" "\n"
" dump_curr_config_desc" "\n"
" dump_all_config_desc" "\n"
@ -489,7 +493,8 @@ flush_command(struct libusb20_backend *pbe, struct options *opt)
}
}
dump_any =
(opt->got_dump_device_desc ||
(opt->got_dump_all_desc ||
opt->got_dump_device_desc ||
opt->got_dump_curr_config ||
opt->got_dump_all_config ||
opt->got_dump_info);
@ -508,6 +513,10 @@ flush_command(struct libusb20_backend *pbe, struct options *opt)
} else if (opt->got_dump_curr_config) {
printf("\n");
dump_config(pdev, 0);
} else if (opt->got_dump_all_desc) {
printf("\n");
dump_device_desc(pdev);
dump_config(pdev, 1);
}
if (dump_any) {
printf("\n");
@ -696,6 +705,12 @@ main(int argc, char **argv)
opt->got_get_template = 1;
opt->got_any++;
break;
case T_DUMP_ALL_DESC:
if (opt->got_dump_all_desc)
duplicate_option(argv[n]);
opt->got_dump_all_desc = 1;
opt->got_any++;
break;
case T_DUMP_DEVICE_DESC:
if (opt->got_dump_device_desc)
duplicate_option(argv[n]);