Skip to content

Commit

Permalink
Some work on the USB debugger code.
Browse files Browse the repository at this point in the history
- Moved USB debugger API defines to siminterface.h.
- EHCI companions now also can enable the USB debugger.
- Removed obsolete hack from ohci_core.h.
  • Loading branch information
vruppert committed Jul 4, 2024
1 parent 3dab500 commit b4d4b62
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 47 deletions.
7 changes: 0 additions & 7 deletions bochs/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@
#define BX_GUI_MT_F12 (BX_MT_KEY_F12)
#define BX_GUI_MT_CTRL_ALT (BX_MT_KEY_CTRL | BX_MT_KEY_ALT)

// usb_debug items
#if BX_USE_WIN32USBDEBUG
#define BX_USB_DEBUG_SOF_NONE 0
#define BX_USB_DEBUG_SOF_SET 1
#define BX_USB_DEBUG_SOF_TRIGGER 2
#endif

// display library option flags
#define BX_GUI_OPT_HIDE_IPS 0x01
#define BX_GUI_OPT_NOKEYREPEAT 0x02
Expand Down
29 changes: 29 additions & 0 deletions bochs/gui/siminterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,35 @@ BOCHSAPI extern int floppy_type_n_sectors[];
BOCHSAPI extern const char *media_status_names[];
BOCHSAPI extern const char *bochs_bootdisk_names[];

// usb_debug items
#if BX_USE_WIN32USBDEBUG

enum {
USB_DEBUG_NONE,
USB_DEBUG_UHCI,
USB_DEBUG_OHCI,
USB_DEBUG_EHCI,
USB_DEBUG_XHCI
};

// USB debug break_type
#define USB_DEBUG_FRAME 1
#define USB_DEBUG_COMMAND 2
#define USB_DEBUG_EVENT 3
#define USB_DEBUG_NONEXIST 4
#define USB_DEBUG_RESET 5
#define USB_DEBUG_ENABLE 6

#define BX_USB_DEBUG_SOF_NONE 0
#define BX_USB_DEBUG_SOF_SET 1
#define BX_USB_DEBUG_SOF_TRIGGER 2

// lParam flags
#define USB_LPARAM_FLAG_BEFORE 0x00000001
#define USB_LPARAM_FLAG_AFTER 0x00000002

#endif

////////////////////////////////////////////////////////////////////
// base class simulator interface, contains just virtual functions.
// I'm not longer sure that having a base class is going to be of any
Expand Down
20 changes: 0 additions & 20 deletions bochs/gui/win32usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,12 @@

#define COMMON_STR_SIZE 128

enum {
USB_DEBUG_NONE,
USB_DEBUG_UHCI,
USB_DEBUG_OHCI,
USB_DEBUG_EHCI,
USB_DEBUG_XHCI
};

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
#define USB_DEBUG_COMMAND 2
#define USB_DEBUG_EVENT 3
#define USB_DEBUG_NONEXIST 4
#define USB_DEBUG_RESET 5
#define USB_DEBUG_ENABLE 6

void win32_usb_trigger(int type, int trigger, int wParam, int lParam);

// lParam flags
#define USB_LPARAM_FLAG_BEFORE 0x00000001
#define USB_LPARAM_FLAG_AFTER 0x00000002

struct CALLBACK_PARAMS {
int type;
int break_type;
Expand Down
3 changes: 0 additions & 3 deletions bochs/iodev/usb/ohci_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
#include "pci.h"
#include "usb_common.h"
#include "ohci_core.h"
#if BX_USE_WIN32USBDEBUG
#include "gui/win32usb.h"
#endif

#define LOG_THIS

Expand Down
2 changes: 0 additions & 2 deletions bochs/iodev/usb/ohci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ class bx_ohci_core_c : public bx_pci_device_c {

int event_handler(int event, void *ptr, int port);

#if !BX_USE_WIN32USBDEBUG
protected:
#endif
bx_ohci_core_t hub;

USBAsync *packets;
Expand Down
3 changes: 0 additions & 3 deletions bochs/iodev/usb/uhci_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
#include "pci.h"
#include "usb_common.h"
#include "uhci_core.h"
#if BX_USE_WIN32USBDEBUG
#include "gui/win32usb.h"
#endif

#define LOG_THIS

Expand Down
13 changes: 10 additions & 3 deletions bochs/iodev/usb/usb_ehci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
#include "ohci_core.h"
#include "qemu-queue.h"
#include "usb_ehci.h"
#if BX_USE_WIN32USBDEBUG
#include "gui/win32usb.h"
#endif

#define LOG_THIS theUSB_EHCI->

Expand Down Expand Up @@ -288,6 +285,11 @@ void bx_usb_ehci_c::init(void)
BX_EHCI_THIS uhci[0]->init_uhci(devfunc | 0x00, 0x8086, 0x24c2, 0x01, 0x80, BX_PCI_INTA);
BX_EHCI_THIS uhci[1]->init_uhci(devfunc | 0x01, 0x8086, 0x24c4, 0x01, 0x00, BX_PCI_INTB);
BX_EHCI_THIS uhci[2]->init_uhci(devfunc | 0x02, 0x8086, 0x24c7, 0x01, 0x00, BX_PCI_INTC);
#if BX_USE_WIN32USBDEBUG
if (SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get() == USB_DEBUG_UHCI) {
SIM->register_usb_debug_type(USB_DEBUG_UHCI);
}
#endif
} else if (companion_type == EHCI_COMPANION_OHCI) {
// initialize readonly registers
// 0x8086 = vendor (Intel)
Expand All @@ -304,6 +306,11 @@ void bx_usb_ehci_c::init(void)
BX_EHCI_THIS ohci[0]->init_ohci(devfunc | 0x00, 0x8086, 0x880C, 0x00, 0x80, BX_PCI_INTA);
BX_EHCI_THIS ohci[1]->init_ohci(devfunc | 0x01, 0x8086, 0x880D, 0x00, 0x00, BX_PCI_INTB);
BX_EHCI_THIS ohci[2]->init_ohci(devfunc | 0x02, 0x8086, 0x880E, 0x00, 0x00, BX_PCI_INTC);
#if BX_USE_WIN32USBDEBUG
if (SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get() == USB_DEBUG_OHCI) {
SIM->register_usb_debug_type(USB_DEBUG_OHCI);
}
#endif
} else
BX_PANIC(("Unknown EHCI Companion Type found..."));

Expand Down
3 changes: 0 additions & 3 deletions bochs/iodev/usb/usb_ohci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
#include "usb_common.h"
#include "ohci_core.h"
#include "usb_ohci.h"
#if BX_USE_WIN32USBDEBUG
#include "gui/win32usb.h"
#endif

#define LOG_THIS theUSB_OHCI->

Expand Down
3 changes: 0 additions & 3 deletions bochs/iodev/usb/usb_uhci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
#include "usb_common.h"
#include "uhci_core.h"
#include "usb_uhci.h"
#if BX_USE_WIN32USBDEBUG
#include "gui/win32usb.h"
#endif

#define LOG_THIS theUSB_UHCI->

Expand Down
3 changes: 0 additions & 3 deletions bochs/iodev/usb/usb_xhci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@
#include "pci.h"
#include "usb_common.h"
#include "usb_xhci.h"
#if BX_USE_WIN32USBDEBUG
#include "gui/win32usb.h"
#endif

#define LOG_THIS theUSB_XHCI->

Expand Down

0 comments on commit b4d4b62

Please sign in to comment.