Skip to content

Commit

Permalink
Some USB debugger config parameter changes.
Browse files Browse the repository at this point in the history
- Changed USB debug type defines to enum.
- Trigger options depend on the debug type parameter.
- Minor related changes.
  • Loading branch information
vruppert committed Jun 16, 2024
1 parent 3118f0d commit 533e2f7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
19 changes: 10 additions & 9 deletions bochs/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ void bx_init_usb_options(const char *usb_name, const char *pname, int maxports,
#if BX_USE_WIN32USBDEBUG
static const char *usb_debug_type[] = { "none", "uhci", "ohci", "ehci", "xhci", NULL };
bx_list_c *usb_debug = new bx_list_c(ports, "usb_debug", "USB Debug Options");
new bx_param_enum_c(usb_debug,
bx_param_enum_c *type = new bx_param_enum_c(usb_debug,
"type", "HC type",
"Select Host Controller type",
usb_debug_type, 0, 0);
usb_debug_type, USB_DEBUG_NONE, USB_DEBUG_NONE);
new bx_param_bool_c(usb_debug,
"reset", "Trigger on reset",
"Trigger on Reset",
Expand Down Expand Up @@ -269,6 +269,8 @@ void bx_init_usb_options(const char *usb_name, const char *pname, int maxports,
"Trigger on write to non-existant port",
0
);
type->set_dependent_list(usb_debug->clone(), 1);
type->set_dependent_bitmap(USB_DEBUG_NONE, 0);
#endif
// prepare runtime options
bx_list_c *rtmenu = (bx_list_c*)SIM->get_param("menu.runtime");
Expand Down Expand Up @@ -307,7 +309,7 @@ void bx_init_usb_options(const char *usb_name, const char *pname, int maxports,
-1, 10,
-1, 0 // -1 as a default so that we can tell if this parameter was given
);

deplist = new bx_list_c(NULL);
for (Bit8u i = 0; i < maxports; i++) {
sprintf(name, "port%u", i+1);
Expand Down Expand Up @@ -3404,20 +3406,19 @@ static int parse_line_formatted(const char *context, int num_params, char *param
}
// check that we haven't already defined the type
// we can only debug one controller at a time
Bit32s type = SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get();
if (type > 0) {
bx_param_enum_c *type = SIM->get_param_enum(BXPN_USB_DEBUG_TYPE);
if (type->get() != USB_DEBUG_NONE) {
PARSE_ERR(("%s: usb_debug: type='%s' previously defined.", context,
SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get_choice(type)));
type->get_selected()));
}
if (parse_usb_debug_options(context, num_params, params) < 0) {
return -1;
}
// we currently only support the xHCI controller type, so give
// an error if it is something else.
type = SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get();
if ((type == USB_DEBUG_OHCI) || (type == USB_DEBUG_EHCI)) {
if ((type->get() == USB_DEBUG_OHCI) || (type->get() == USB_DEBUG_EHCI)) {
PARSE_ERR(("%s: usb_debug: type='%s' not supported yet.", context,
SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get_choice(type)));
type->get_selected()));
}
#endif
} else if (!strcmp(params[0], "load32bitOSImage")) {
Expand Down
9 changes: 5 additions & 4 deletions bochs/gui/win32usb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,18 @@ int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam)
int ret;

// get the (host controller) type we are to debug
Bit32s type = SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get();
bx_param_enum_c *debug_type = SIM->get_param_enum(BXPN_USB_DEBUG_TYPE);
Bit32s type = debug_type->get();
if ((type < USB_DEBUG_UHCI) || (type > USB_DEBUG_XHCI)) {
sprintf(str, "Unknown host controller type given: %d", type);
MessageBox(hwnd, str, NULL, MB_ICONINFORMATION);
return 0;
}

// check to make sure the specified HC was enabled and in use
// check to make sure the specified HC is enabled
host_param = SIM->get_param(hc_param_str[type]);
if ((host_param == NULL) || !host_param->get_enabled()) {
sprintf(str, "Parameter not found or enabled: %s", hc_param_str[type]);
if ((host_param == NULL) || !SIM->get_param_bool("enabled", host_param)->get()) {
sprintf(str, "Selected USB HC not enabled: %s", debug_type->get_choice(type));
MessageBox(hwnd, str, NULL, MB_ICONINFORMATION);
return 0;
}
Expand Down
12 changes: 7 additions & 5 deletions bochs/gui/win32usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

#define COMMON_STR_SIZE 128

#define USB_DEBUG_NONE 0
#define USB_DEBUG_UHCI 1
#define USB_DEBUG_OHCI 2
#define USB_DEBUG_EHCI 3
#define USB_DEBUG_XHCI 4
enum {
USB_DEBUG_NONE,
USB_DEBUG_UHCI,
USB_DEBUG_OHCI,
USB_DEBUG_EHCI,
USB_DEBUG_XHCI
};

BOCHSAPI_MSVCONLY int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam);

Expand Down

0 comments on commit 533e2f7

Please sign in to comment.