Skip to content

Commit

Permalink
Some works on USB debugger option handling.
Browse files Browse the repository at this point in the history
- Now using parameter format "property=value" like most of the Bochs options.
- Save USB debugger options if present.
  • Loading branch information
vruppert committed Jun 20, 2024
1 parent ccdfbc6 commit 1d556fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
37 changes: 7 additions & 30 deletions bochs/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2279,34 +2279,6 @@ int get_floppy_type_from_image(const char *filename)
}
}

#if BX_USE_WIN32USBDEBUG
static Bit32s parse_usb_debug_options(const char *context, int num_params, char *params[])
{
for (int i=1; i<num_params; i++) {
if (!strncmp(params[i], "type=", 5)) {
SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->set_by_name(&params[i][5]);
} else if (!strcmp(params[i], "reset")) {
SIM->get_param_bool(BXPN_USB_DEBUG_RESET)->set(1);
} else if (!strcmp(params[i], "enable")) {
SIM->get_param_bool(BXPN_USB_DEBUG_ENABLE)->set(1);
} else if (!strcmp(params[i], "start_frame")) {
SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->set(BX_USB_DEBUG_SOF_SET);
} else if (!strcmp(params[i], "doorbell")) {
SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL)->set(1);
} else if (!strcmp(params[i], "event")) {
SIM->get_param_bool(BXPN_USB_DEBUG_EVENT)->set(1);
} else if (!strcmp(params[i], "non_exist")) {
SIM->get_param_bool(BXPN_USB_DEBUG_NON_EXIST)->set(1);
} else {
PARSE_ERR(("%s: %s directive malformed.", context, params[i]));
return -1;
}
}

return 0;
}
#endif

static Bit32s parse_log_options(const char *context, int num_params, char *params[])
{
int level, action, i;
Expand Down Expand Up @@ -3411,8 +3383,10 @@ static int parse_line_formatted(const char *context, int num_params, char *param
PARSE_ERR(("%s: usb_debug: type='%s' previously defined.", context,
type->get_selected()));
}
if (parse_usb_debug_options(context, num_params, params) < 0) {
return -1;
for (i=1; i<num_params; i++) {
if (bx_parse_param_from_list(context, params[i], (bx_list_c*) SIM->get_param(BXPN_USB_DEBUG)) < 0) {
PARSE_ERR(("%s: usb_debug directive malformed.", context));
}
}
// we currently only support the xHCI controller type, so give
// an error if it is something else.
Expand Down Expand Up @@ -3797,6 +3771,9 @@ int bx_write_configuration(const char *rc, int overwrite)
bx_write_param_list(fp, (bx_list_c*) SIM->get_param(BXPN_KEYBOARD), NULL, 0);
bx_write_param_list(fp, (bx_list_c*) SIM->get_param(BXPN_MOUSE), NULL, 0);
bx_write_param_list(fp, (bx_list_c*) SIM->get_param(BXPN_SOUNDLOW),"sound", 0);
#if BX_USE_WIN32USBDEBUG
bx_write_param_list(fp, (bx_list_c*) SIM->get_param(BXPN_USB_DEBUG), "usb_debug", 0);
#endif
SIM->save_addon_options(fp);
fclose(fp);
return 0;
Expand Down
3 changes: 2 additions & 1 deletion bochs/param_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009-2023 The Bochs Project
// Copyright (C) 2009-2024 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -164,6 +164,7 @@
#define BXPN_XHCI_ENABLED "ports.usb.xhci.enabled"
#define BXPN_XHCI_MODEL "ports.usb.xhci.model"
#define BXPN_XHCI_N_PORTS "ports.usb.xhci.n_ports"
#define BXPN_USB_DEBUG "ports.usb_debug"
#define BXPN_USB_DEBUG_TYPE "ports.usb_debug.type"
#define BXPN_USB_DEBUG_RESET "ports.usb_debug.reset"
#define BXPN_USB_DEBUG_ENABLE "ports.usb_debug.enable"
Expand Down

0 comments on commit 1d556fd

Please sign in to comment.