Rewrite of the USB debugger code for wxWidgets support.
MSVC plugins version now also compiles with USB debugger enabled. TODO: MSVC builds still fail to show USB debugger dialog.
This commit is contained in:
parent
67e4e12de1
commit
e83d8bd5e3
@ -721,7 +721,7 @@ void bx_gui_c::usb_handler(void)
|
||||
if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_USB) {
|
||||
// Once we set the trigger, don't allow the user to press the button again
|
||||
if (SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->get() < BX_USB_DEBUG_SOF_TRIGGER)
|
||||
SIM->usb_config_interface(USB_DEBUG_FRAME, 0, 0);
|
||||
SIM->usb_debug_interface(USB_DEBUG_FRAME, 0, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -74,7 +74,6 @@ class bx_real_sim_c : public bx_simulator_interface_c {
|
||||
void *ci_callback_data;
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
int usb_debug_type;
|
||||
usb_interface_callback_t usbi_callback;
|
||||
#endif
|
||||
rt_conf_entry_t *rt_conf_entries;
|
||||
addon_option_t *addon_options;
|
||||
@ -186,8 +185,7 @@ public:
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
virtual void register_usb_debug_type(int type);
|
||||
virtual void usb_debug_trigger(int type, int trigger, int wParam, int lParam);
|
||||
virtual void register_usb_interface(usb_interface_callback_t callback, void *data);
|
||||
virtual int usb_config_interface(int type, int wParam, int lParam);
|
||||
virtual int usb_debug_interface(int type, int wParam, int lParam);
|
||||
#endif
|
||||
virtual int begin_simulation(int argc, char *argv[]);
|
||||
virtual int register_runtime_config_handler(void *dev, rt_conf_handler_t handler);
|
||||
@ -397,7 +395,6 @@ bx_real_sim_c::bx_real_sim_c()
|
||||
ci_callback_data = NULL;
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
usb_debug_type = 0;
|
||||
usbi_callback = NULL;
|
||||
#endif
|
||||
is_sim_thread_func = NULL;
|
||||
bx_debug_gui = 0;
|
||||
@ -963,7 +960,7 @@ void bx_real_sim_c::register_usb_debug_type(int type)
|
||||
|
||||
void bx_real_sim_c::usb_debug_trigger(int type, int trigger, int wParam, int lParam)
|
||||
{
|
||||
if (type != USB_DEBUG_NONE) {
|
||||
if (usb_debug_type != USB_DEBUG_NONE) {
|
||||
if (type == usb_debug_type) {
|
||||
win32_usb_trigger(type, trigger, wParam, lParam);
|
||||
} else {
|
||||
@ -972,22 +969,15 @@ void bx_real_sim_c::usb_debug_trigger(int type, int trigger, int wParam, int lPa
|
||||
}
|
||||
}
|
||||
|
||||
void bx_real_sim_c::register_usb_interface(usb_interface_callback_t callback, void *data)
|
||||
int bx_real_sim_c::usb_debug_interface(int type, int wParam, int lParam)
|
||||
{
|
||||
usbi_callback = callback;
|
||||
}
|
||||
int retval = -1;
|
||||
|
||||
int bx_real_sim_c::usb_config_interface(int type, int wParam, int lParam)
|
||||
{
|
||||
if (!usbi_callback) {
|
||||
BX_PANIC(("no usb interface was loaded"));
|
||||
return -1;
|
||||
if (type != USB_DEBUG_NONE) {
|
||||
set_display_mode(DISP_MODE_CONFIG);
|
||||
retval = win32_usb_interface(type, wParam, lParam);
|
||||
set_display_mode(DISP_MODE_SIM);
|
||||
}
|
||||
|
||||
set_display_mode(DISP_MODE_CONFIG);
|
||||
int retval = (*usbi_callback)(type, wParam, lParam);
|
||||
set_display_mode(DISP_MODE_SIM);
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
@ -571,9 +571,6 @@ enum ci_return_t {
|
||||
CI_ERR_NO_TEXT_CONSOLE // err: can't work because there's no text console
|
||||
};
|
||||
typedef int (*config_interface_callback_t)(void *userdata, ci_command_t command);
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
typedef int (*usb_interface_callback_t)(int type, int wParam, int lParam);
|
||||
#endif
|
||||
typedef BxEvent* (*bxevent_handler)(void *theclass, BxEvent *event);
|
||||
typedef void (*rt_conf_handler_t)(void *this_ptr);
|
||||
typedef Bit32s (*addon_option_parser_t)(const char *context, int num_params, char *params[]);
|
||||
@ -717,8 +714,7 @@ public:
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
virtual void register_usb_debug_type(int type) {}
|
||||
virtual void usb_debug_trigger(int type, int trigger, int wParam, int lParam) {}
|
||||
virtual void register_usb_interface(usb_interface_callback_t callback, void *data) {}
|
||||
virtual int usb_config_interface(int type, int wParam, int lParam) { return -1; }
|
||||
virtual int usb_debug_interface(int type, int wParam, int lParam) { return -1; }
|
||||
#endif
|
||||
virtual int begin_simulation(int argc, char *argv[]) {return -1;}
|
||||
virtual int register_runtime_config_handler(void *dev, rt_conf_handler_t handler) {return 0;}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2003-2023 The Bochs Project
|
||||
// Copyright (C) 2003-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
|
||||
@ -31,10 +31,6 @@
|
||||
#include "win32res.h"
|
||||
#include "win32paramdlg.h"
|
||||
#include "plugin.h"
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
#include "win32usb.h"
|
||||
static int win32_usbi_callback(int type, int wParam, int lParam);
|
||||
#endif
|
||||
|
||||
#if BX_USE_WIN32CONFIG
|
||||
|
||||
@ -45,9 +41,6 @@ PLUGIN_ENTRY_FOR_MODULE(win32config)
|
||||
{
|
||||
if (mode == PLUGIN_INIT) {
|
||||
SIM->register_configuration_interface("win32config", win32_ci_callback, NULL);
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
SIM->register_usb_interface(win32_usbi_callback, NULL);
|
||||
#endif
|
||||
SIM->set_notify_callback(win32_notify_callback, NULL);
|
||||
} else if (mode == PLUGIN_PROBE) {
|
||||
return (int)PLUGTYPE_CI;
|
||||
@ -805,34 +798,4 @@ static int win32_ci_callback(void *userdata, ci_command_t command)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
static int win32_usbi_callback(int type, int wParam, int lParam) {
|
||||
if (!bx_gui->has_gui_console()) {
|
||||
if (SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get() > 0) {
|
||||
// if "start_frame" is 0, do the debug_window
|
||||
// if "start_frame" is 1, wait for the trigger from the HC
|
||||
// (set the value to 2, then return, allowing the trigger to envoke it)
|
||||
// if "start_frame" is 2, the HC triggered the debug
|
||||
if (SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->get() == BX_USB_DEBUG_SOF_SET) {
|
||||
SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->set(BX_USB_DEBUG_SOF_TRIGGER);
|
||||
bx_gui->replace_bitmap(bx_gui->usb_hbar_id, bx_gui->usb_trigger_bmap_id);
|
||||
} else {
|
||||
bx_gui->replace_bitmap(bx_gui->usb_hbar_id, bx_gui->usb_bmap_id);
|
||||
if (win32_usb_start(GetBochsWindow(), type, wParam, lParam) < 0) {
|
||||
bx_user_quit = 1;
|
||||
#if !BX_DEBUGGER
|
||||
bx_atexit();
|
||||
SIM->quit_sim(1);
|
||||
#else
|
||||
bx_dbg_exit(1);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BX_USE_WIN32CONFIG
|
||||
|
@ -65,6 +65,35 @@ struct CALLBACK_PARAMS g_params;
|
||||
|
||||
HFONT hTreeViewFont;
|
||||
|
||||
int win32_usb_interface(int type, int wParam, int lParam)
|
||||
{
|
||||
if (!bx_gui->has_gui_console()) {
|
||||
if (SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get() > 0) {
|
||||
// if "start_frame" is 0, do the debug_window
|
||||
// if "start_frame" is 1, wait for the trigger from the HC
|
||||
// (set the value to 2, then return, allowing the trigger to envoke it)
|
||||
// if "start_frame" is 2, the HC triggered the debug
|
||||
if (SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->get() == BX_USB_DEBUG_SOF_SET) {
|
||||
SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->set(BX_USB_DEBUG_SOF_TRIGGER);
|
||||
bx_gui->replace_bitmap(bx_gui->usb_hbar_id, bx_gui->usb_trigger_bmap_id);
|
||||
} else {
|
||||
bx_gui->replace_bitmap(bx_gui->usb_hbar_id, bx_gui->usb_bmap_id);
|
||||
if (win32_usb_start(GetForegroundWindow(), type, wParam, lParam) < 0) {
|
||||
bx_user_quit = 1;
|
||||
#if !BX_DEBUGGER
|
||||
bx_atexit();
|
||||
SIM->quit_sim(1);
|
||||
#else
|
||||
bx_dbg_exit(1);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Common to all HC types
|
||||
//
|
||||
@ -150,7 +179,7 @@ void win32_usb_trigger(int type, int trigger, int wParam, int lParam)
|
||||
case USB_DEBUG_FRAME:
|
||||
num_trigger = SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME);
|
||||
if (num_trigger && (num_trigger->get() == BX_USB_DEBUG_SOF_TRIGGER)) {
|
||||
SIM->usb_config_interface(USB_DEBUG_FRAME, wParam, lParam);
|
||||
SIM->usb_debug_interface(USB_DEBUG_FRAME, wParam, lParam);
|
||||
num_trigger->set(BX_USB_DEBUG_SOF_SET);
|
||||
}
|
||||
break;
|
||||
@ -158,31 +187,31 @@ void win32_usb_trigger(int type, int trigger, int wParam, int lParam)
|
||||
case USB_DEBUG_COMMAND:
|
||||
bool_trigger = SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL);
|
||||
if (bool_trigger && bool_trigger->get())
|
||||
SIM->usb_config_interface(USB_DEBUG_COMMAND, wParam, lParam);
|
||||
SIM->usb_debug_interface(USB_DEBUG_COMMAND, wParam, lParam);
|
||||
break;
|
||||
|
||||
case USB_DEBUG_EVENT:
|
||||
bool_trigger = SIM->get_param_bool(BXPN_USB_DEBUG_EVENT);
|
||||
if (bool_trigger && bool_trigger->get())
|
||||
SIM->usb_config_interface(USB_DEBUG_EVENT, wParam, lParam);
|
||||
SIM->usb_debug_interface(USB_DEBUG_EVENT, wParam, lParam);
|
||||
break;
|
||||
|
||||
case USB_DEBUG_NONEXIST:
|
||||
bool_trigger = SIM->get_param_bool(BXPN_USB_DEBUG_NON_EXIST);
|
||||
if (bool_trigger && bool_trigger->get())
|
||||
SIM->usb_config_interface(USB_DEBUG_NONEXIST, wParam, lParam);
|
||||
SIM->usb_debug_interface(USB_DEBUG_NONEXIST, wParam, lParam);
|
||||
break;
|
||||
|
||||
case USB_DEBUG_RESET:
|
||||
bool_trigger = SIM->get_param_bool(BXPN_USB_DEBUG_RESET);
|
||||
if (bool_trigger && bool_trigger->get())
|
||||
SIM->usb_config_interface(USB_DEBUG_RESET, wParam, lParam);
|
||||
SIM->usb_debug_interface(USB_DEBUG_RESET, wParam, lParam);
|
||||
break;
|
||||
|
||||
case USB_DEBUG_ENABLE:
|
||||
bool_trigger = SIM->get_param_bool(BXPN_USB_DEBUG_ENABLE);
|
||||
if (bool_trigger && bool_trigger->get())
|
||||
SIM->usb_config_interface(USB_DEBUG_ENABLE, wParam, lParam);
|
||||
SIM->usb_debug_interface(USB_DEBUG_ENABLE, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ enum {
|
||||
USB_DEBUG_XHCI
|
||||
};
|
||||
|
||||
BOCHSAPI_MSVCONLY int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam);
|
||||
int win32_usb_interface(int type, int wParam, int lParam);
|
||||
|
||||
int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam);
|
||||
|
||||
// USB debug break_type
|
||||
#define USB_DEBUG_FRAME 1
|
||||
|
@ -4,6 +4,9 @@ icon_bochs ICON build/win32/nsis/bochs.ico
|
||||
#if BX_WITH_WIN32
|
||||
#include "win32res.rc"
|
||||
#else
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
#include "win32usbres.rc"
|
||||
#endif
|
||||
#if BX_DEBUGGER_GUI
|
||||
#include "win32_enh_dbg.rc"
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user