USB debugger: Moved platform independant stuff to separate files.
This commit is contained in:
parent
d8a955b035
commit
2717e90d58
@ -221,6 +221,7 @@
|
||||
<ClCompile Include="..\gui\paramtree.cc" />
|
||||
<ClCompile Include="..\gui\siminterface.cc" />
|
||||
<ClCompile Include="..\gui\textconfig.cc" />
|
||||
<ClCompile Include="..\gui\usb_debug.cc" />
|
||||
<ClCompile Include="..\gui\win32_enh_dbg_osdep.cc" />
|
||||
<ClCompile Include="..\gui\win32usb.cc" />
|
||||
</ItemGroup>
|
||||
@ -230,6 +231,7 @@
|
||||
<ClInclude Include="..\gui\keymap.h" />
|
||||
<ClInclude Include="..\gui\paramtree.h" />
|
||||
<ClInclude Include="..\gui\siminterface.h" />
|
||||
<ClInclude Include="..\gui\usb_debug.h" />
|
||||
<ClInclude Include="..\gui\wenhdbg_res.h" />
|
||||
<ClInclude Include="..\gui\win32dialog.h" />
|
||||
<ClInclude Include="..\gui\win32res.h" />
|
||||
|
@ -224,6 +224,7 @@
|
||||
<ClCompile Include="..\gui\scrollwin.cc" />
|
||||
<ClCompile Include="..\gui\siminterface.cc" />
|
||||
<ClCompile Include="..\gui\textconfig.cc" />
|
||||
<ClCompile Include="..\gui\usb_debug.cc" />
|
||||
<ClCompile Include="..\gui\win32.cc" />
|
||||
<ClCompile Include="..\gui\win32_enh_dbg_osdep.cc" />
|
||||
<ClCompile Include="..\gui\win32config.cc" />
|
||||
@ -240,6 +241,7 @@
|
||||
<ClInclude Include="..\gui\scrollwin.h" />
|
||||
<ClInclude Include="..\gui\sdl.h" />
|
||||
<ClInclude Include="..\gui\siminterface.h" />
|
||||
<ClInclude Include="..\gui\usb_debug.h" />
|
||||
<ClInclude Include="..\gui\wenhdbg_res.h" />
|
||||
<ClInclude Include="..\gui\win32dialog.h" />
|
||||
<ClInclude Include="..\gui\win32paramdlg.h" />
|
||||
|
2
bochs/configure
vendored
2
bochs/configure
vendored
@ -26660,7 +26660,7 @@ fi
|
||||
USB_DBG_OBJS=""
|
||||
if test "$usb_debugger" = 1; then
|
||||
if test "$DEFAULT_GUI" = win32 -o "$with_win32" = yes; then
|
||||
USB_DBG_OBJS="win32usb.o"
|
||||
USB_DBG_OBJS="usb_debug.o win32usb.o"
|
||||
printf "%s\n" "#define BX_USE_WIN32USBDEBUG 1" >>confdefs.h
|
||||
|
||||
else
|
||||
|
@ -3020,7 +3020,7 @@ AC_SUBST(ENH_DBG_OBJS)
|
||||
USB_DBG_OBJS=""
|
||||
if test "$usb_debugger" = 1; then
|
||||
if test "$DEFAULT_GUI" = win32 -o "$with_win32" = yes; then
|
||||
USB_DBG_OBJS="win32usb.o"
|
||||
USB_DBG_OBJS="usb_debug.o win32usb.o"
|
||||
AC_DEFINE(BX_USE_WIN32USBDEBUG, 1)
|
||||
else
|
||||
AC_MSG_WARN([The USB debugger supported only for Win32 cannot be compiled here, disabling it])
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "bx_debug/debug.h"
|
||||
#include "virt_timer.h"
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
#include "gui/win32usb.h"
|
||||
#include "gui/usb_debug.h"
|
||||
#endif
|
||||
|
||||
bx_simulator_interface_c *SIM = NULL;
|
||||
@ -72,9 +72,6 @@ class bx_real_sim_c : public bx_simulator_interface_c {
|
||||
const char *registered_ci_name;
|
||||
config_interface_callback_t ci_callback;
|
||||
void *ci_callback_data;
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
int usb_debug_type;
|
||||
#endif
|
||||
rt_conf_entry_t *rt_conf_entries;
|
||||
addon_option_t *addon_options;
|
||||
bool init_done;
|
||||
@ -393,9 +390,6 @@ bx_real_sim_c::bx_real_sim_c()
|
||||
bxevent_callback_data = NULL;
|
||||
ci_callback = NULL;
|
||||
ci_callback_data = NULL;
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
usb_debug_type = 0;
|
||||
#endif
|
||||
is_sim_thread_func = NULL;
|
||||
bx_debug_gui = 0;
|
||||
bx_log_viewer = 0;
|
||||
@ -949,21 +943,12 @@ int bx_real_sim_c::configuration_interface(const char *ignore, ci_command_t comm
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
void bx_real_sim_c::register_usb_debug_type(int type)
|
||||
{
|
||||
if (type != USB_DEBUG_NONE) {
|
||||
if ((type != USB_DEBUG_UHCI) && (type != USB_DEBUG_XHCI)) {
|
||||
BX_PANIC(("USB debugger does not yet support type %d", type));
|
||||
} else {
|
||||
usb_debug_type = type;
|
||||
bx_gui->set_usbdbg_bitmap(0);
|
||||
}
|
||||
}
|
||||
usb_dbg_register_type(type);
|
||||
}
|
||||
|
||||
void bx_real_sim_c::usb_debug_trigger(int type, int trigger, int wParam, int lParam)
|
||||
{
|
||||
if ((usb_debug_type != USB_DEBUG_NONE) && (type == usb_debug_type)) {
|
||||
win32_usb_trigger(type, trigger, wParam, lParam);
|
||||
}
|
||||
usb_dbg_trigger(type, trigger, wParam, lParam);
|
||||
}
|
||||
|
||||
int bx_real_sim_c::usb_debug_interface(int type, int wParam, int lParam)
|
||||
@ -972,7 +957,7 @@ int bx_real_sim_c::usb_debug_interface(int type, int wParam, int lParam)
|
||||
|
||||
if (type != USB_DEBUG_NONE) {
|
||||
set_display_mode(DISP_MODE_CONFIG);
|
||||
retval = win32_usb_interface(type, wParam, lParam);
|
||||
retval = usb_dbg_interface(type, wParam, lParam);
|
||||
set_display_mode(DISP_MODE_SIM);
|
||||
}
|
||||
return retval;
|
||||
|
125
bochs/gui/usb_debug.cc
Normal file
125
bochs/gui/usb_debug.cc
Normal file
@ -0,0 +1,125 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023 Benjamin David Lunt
|
||||
// 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "bochs.h"
|
||||
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
|
||||
#include "usb_debug.h"
|
||||
#include "siminterface.h"
|
||||
#include "gui.h"
|
||||
#include "param_names.h"
|
||||
|
||||
#define LOG_THIS genlog->
|
||||
|
||||
int usb_debug_type = USB_DEBUG_NONE;
|
||||
|
||||
void usb_dbg_register_type(int type)
|
||||
{
|
||||
if (type != USB_DEBUG_NONE) {
|
||||
if ((type != USB_DEBUG_UHCI) && (type != USB_DEBUG_XHCI)) {
|
||||
BX_PANIC(("USB debugger does not yet support type %d", type));
|
||||
} else {
|
||||
usb_debug_type = type;
|
||||
bx_gui->set_usbdbg_bitmap(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int usb_dbg_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->set_usbdbg_bitmap(1);
|
||||
} else {
|
||||
bx_gui->set_usbdbg_bitmap(0);
|
||||
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;
|
||||
}
|
||||
|
||||
// one of the controllers has triggered a debug item.
|
||||
void usb_dbg_trigger(int type, int trigger, int wParam, int lParam)
|
||||
{
|
||||
if ((usb_debug_type == USB_DEBUG_NONE) || (type != usb_debug_type))
|
||||
return;
|
||||
|
||||
bx_param_bool_c *bool_trigger;
|
||||
bx_param_num_c *num_trigger;
|
||||
switch (trigger) {
|
||||
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_debug_interface(USB_DEBUG_FRAME, wParam, lParam);
|
||||
num_trigger->set(BX_USB_DEBUG_SOF_SET);
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_DEBUG_COMMAND:
|
||||
bool_trigger = SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL);
|
||||
if (bool_trigger && bool_trigger->get())
|
||||
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_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_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_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_debug_interface(USB_DEBUG_ENABLE, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
38
bochs/gui/usb_debug.h
Normal file
38
bochs/gui/usb_debug.h
Normal file
@ -0,0 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023 Benjamin David Lunt
|
||||
// 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef BX_USB_DEBUG_H
|
||||
#define BX_USB_DEBUG_H
|
||||
|
||||
#if BX_USE_WIN32USBDEBUG
|
||||
|
||||
extern int usb_debug_type;
|
||||
|
||||
void usb_dbg_register_type(int type);
|
||||
|
||||
int usb_dbg_interface(int type, int wParam, int lParam);
|
||||
|
||||
void usb_dbg_trigger(int type, int trigger, int wParam, int lParam);
|
||||
|
||||
int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam);
|
||||
|
||||
#endif // BX_USE_WIN32USBDEBUG
|
||||
#endif // BX_USB_DEBUG_H
|
@ -30,6 +30,7 @@
|
||||
#include "iodev.h"
|
||||
#include "param_names.h"
|
||||
|
||||
#include "usb_debug.h"
|
||||
#include "win32usbres.h"
|
||||
#include "win32usb.h"
|
||||
|
||||
@ -65,35 +66,6 @@ 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->set_usbdbg_bitmap(1);
|
||||
} else {
|
||||
bx_gui->set_usbdbg_bitmap(0);
|
||||
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
|
||||
//
|
||||
@ -107,17 +79,11 @@ int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam)
|
||||
|
||||
// get the (host controller) type we are to debug
|
||||
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 is enabled
|
||||
host_param = SIM->get_param(hc_param_str[type]);
|
||||
host_param = SIM->get_param(hc_param_str[usb_debug_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));
|
||||
sprintf(str, "Selected USB HC not enabled: %s", debug_type->get_choice(usb_debug_type));
|
||||
MessageBox(hwnd, str, NULL, MB_ICONINFORMATION);
|
||||
return 0;
|
||||
}
|
||||
@ -148,12 +114,12 @@ int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam)
|
||||
}
|
||||
|
||||
// create the dialog and wait for it to return
|
||||
g_params.type = type;
|
||||
g_params.type = usb_debug_type;
|
||||
g_params.break_type = break_type;
|
||||
g_params.wParam = wParam;
|
||||
g_params.lParam = lParam;
|
||||
ret = (int) DialogBoxParam(NULL, MAKEINTRESOURCE(dlg_resource[type]), hwnd,
|
||||
usb_debug_callbacks[type], (LPARAM) 0);
|
||||
ret = (int) DialogBoxParam(NULL, MAKEINTRESOURCE(dlg_resource[usb_debug_type]), hwnd,
|
||||
usb_debug_callbacks[usb_debug_type], (LPARAM) 0);
|
||||
// destroy the font
|
||||
DeleteObject(hTreeViewFont);
|
||||
|
||||
@ -165,57 +131,6 @@ int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// one of the controllers has triggered a debug item.
|
||||
void win32_usb_trigger(int type, int trigger, int wParam, int lParam)
|
||||
{
|
||||
// check that we are the correct controller type
|
||||
bx_param_enum_c *cntlr_type = SIM->get_param_enum(BXPN_USB_DEBUG_TYPE);
|
||||
if ((cntlr_type == NULL) || (cntlr_type->get() != type))
|
||||
return;
|
||||
|
||||
bx_param_bool_c *bool_trigger;
|
||||
bx_param_num_c *num_trigger;
|
||||
switch (trigger) {
|
||||
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_debug_interface(USB_DEBUG_FRAME, wParam, lParam);
|
||||
num_trigger->set(BX_USB_DEBUG_SOF_SET);
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_DEBUG_COMMAND:
|
||||
bool_trigger = SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL);
|
||||
if (bool_trigger && bool_trigger->get())
|
||||
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_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_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_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_debug_interface(USB_DEBUG_ENABLE, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HWND TreeView = NULL;
|
||||
int tree_items = 0;
|
||||
HTREEITEM TreeViewInsert(HWND TreeView, HTREEITEM Parent, HTREEITEM After, char *str, LPARAM lParam, Bit32u state) {
|
||||
|
@ -26,12 +26,6 @@
|
||||
|
||||
#define COMMON_STR_SIZE 128
|
||||
|
||||
int win32_usb_interface(int type, int wParam, int lParam);
|
||||
|
||||
int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam);
|
||||
|
||||
void win32_usb_trigger(int type, int trigger, int wParam, int lParam);
|
||||
|
||||
struct CALLBACK_PARAMS {
|
||||
int type;
|
||||
int break_type;
|
||||
|
Loading…
Reference in New Issue
Block a user