Improved conversion of old-style USB device options to new format.
This commit is contained in:
parent
50bac3b15c
commit
d9dd62e42f
@ -2251,9 +2251,9 @@ int bx_parse_usb_port_params(const char *context, const char *param,
|
||||
{
|
||||
bool devopt = 0;
|
||||
int idx, plen;
|
||||
char tmpname[20], optstr[BX_PATHNAME_LEN];
|
||||
char tmpname[20], newopts[BX_PATHNAME_LEN];
|
||||
char *devstr, *arg;
|
||||
const char *opt = NULL;
|
||||
const char *opt = NULL, *origopts;
|
||||
|
||||
if (!strncmp(param, "port", 4)) {
|
||||
devopt = 1;
|
||||
@ -2290,11 +2290,15 @@ int bx_parse_usb_port_params(const char *context, const char *param,
|
||||
opt = "file";
|
||||
}
|
||||
if (opt != NULL) {
|
||||
sprintf(optstr, "%s:%s", opt, arg);
|
||||
sprintf(tmpname, "port%d", idx);
|
||||
base = (bx_list_c*)SIM->get_param(tmpname, base);
|
||||
new bx_param_string_c(base,
|
||||
"options2", "Options 2", "", optstr, BX_PATHNAME_LEN);
|
||||
origopts = SIM->get_param_string("options", base)->getptr();
|
||||
if (strlen(origopts) > 0) {
|
||||
sprintf(newopts, "%s:%s, %s", opt, arg, origopts);
|
||||
} else {
|
||||
sprintf(newopts, "%s:%s", opt, arg);
|
||||
}
|
||||
SIM->get_param_string("options", base)->set(newopts);
|
||||
}
|
||||
}
|
||||
free(devstr);
|
||||
|
@ -129,26 +129,10 @@ bool bx_usbdev_ctl_c::init_device(bx_list_c *portconf, logfunctions *hub, void *
|
||||
{
|
||||
Bit8u devtype, modtype;
|
||||
usb_device_c **device = (usb_device_c**)dev;
|
||||
const char *options, *options2;
|
||||
char new_options[BX_PATHNAME_LEN];
|
||||
bx_param_string_c *opts2;
|
||||
|
||||
devtype = (Bit8u)((bx_param_enum_c*)portconf->get_by_name("device"))->get();
|
||||
if (devtype == 0) return 0;
|
||||
modtype = usb_module_id[devtype];
|
||||
options = ((bx_param_string_c*)portconf->get_by_name("options"))->getptr();
|
||||
opts2 = (bx_param_string_c*)portconf->get_by_name("options2");
|
||||
if (opts2 != NULL) {
|
||||
// backward compatibility code
|
||||
options2 = opts2->getptr();
|
||||
if (strlen(options) > 0) {
|
||||
sprintf(new_options, "%s, %s", options2, options);
|
||||
} else {
|
||||
sprintf(new_options, "%s", options2);
|
||||
}
|
||||
((bx_param_string_c*)portconf->get_by_name("options"))->set(new_options);
|
||||
portconf->remove("options2");
|
||||
}
|
||||
if (!usbdev_locator_c::module_present(usb_module_names[modtype])) {
|
||||
#if BX_PLUGINS
|
||||
PLUG_load_plugin_var(usb_module_names[modtype], PLUGTYPE_USB);
|
||||
|
Loading…
x
Reference in New Issue
Block a user