diff --git a/bochs/.bochsrc b/bochs/.bochsrc index d18d406f1..225f7f99c 100644 --- a/bochs/.bochsrc +++ b/bochs/.bochsrc @@ -1281,6 +1281,23 @@ speaker: enabled=1, mode=sound, volume=15 #usb_xhci: port1=disk, options1="speed:super, path:hdd.img, proto:uasp" #usb_xhci: port3=disk, options3="speed:high, path:hdd.img, proto:uasp" +#======================================================================= +# USB Debugger: +# This is the experimental USB Debugger for the Windows Platform. +# Specify a type (none, uhci, ohci, ehci, xhci) and one or more triggers. +# (Currently, only xhci is supported, with some uhci in the process) +# Triggers: +# reset: will break and load the debugger on a port reset +# enable: will break and load the debugger on a port enable +# start_frame: will break and load the debugger on start of frame +# (this is different for each controller type) +# doorbell: will break and load the debugger a xHCI Command Ring addition +# event: will break and load the debugger on a xHCI Event Ring addition +# non_exist: will break and load the debugger on a non-existant port access +# (experimental and is under development) +#======================================================================= +#usb_debug: type=xhci, reset, enable, start_frame, doorbell, event, non_exist + #======================================================================= # PCIDEV: # PCI host device mapping diff --git a/bochs/.conf.win32-cygwin-debugger b/bochs/.conf.win32-cygwin-debugger new file mode 100644 index 000000000..b0c96dafd --- /dev/null +++ b/bochs/.conf.win32-cygwin-debugger @@ -0,0 +1,39 @@ +#!/bin/sh +# +# These are the steps I typically use to configure and compile Bochs +# on a Win32 system with Cygwin (v1.7.28) or MinGW/MSYS. +# + +CC="gcc" +CXX="g++" +#CFLAGS="-O3 -Wall -Wno-format -mno-cygwin" # for GCC versions < 4.7 +CFLAGS="-O3 -Wall -Wno-format -mno-ms-bitfields" +CXXFLAGS="$CFLAGS" + +export CC +export CXX +export CFLAGS +export CXXFLAGS + +./configure --enable-sb16 \ + --enable-ne2000 \ + --enable-all-optimizations \ + --enable-cpu-level=6 \ + --enable-x86-64 \ + --enable-vmx=2 \ + --enable-avx \ + --enable-pci \ + --enable-clgd54xx \ + --enable-voodoo \ + --enable-usb \ + --enable-usb-ohci \ + --enable-usb-ehci \ + --enable-usb-xhci \ + --enable-busmouse \ + --enable-es1370 \ + --enable-e1000 \ + --enable-show-ips \ + --with-win32 --with-rfb --with-nogui \ + --enable-debugger \ + --enable-debugger-gui \ + ${CONFIGURE_ARGS} diff --git a/bochs/CHANGES b/bochs/CHANGES index 2bac2fcac..9788e3008 100644 --- a/bochs/CHANGES +++ b/bochs/CHANGES @@ -26,6 +26,7 @@ Brief summary : - USB: xHCI: added the ability to have more than one model of xHCI hardware. Currently there are two. - USB: Added experimental MSD UASP emulation - USB: Added OHCI as an EHCI Companion option. Now allows UHCI or OHCI specified as a configuration parameter. + - USB: Added the USB Debugger support for xHCI and UHCI - Disk images: Allows large VHD image files - Fixed and enhanced the Floppy Disk emulation, VGA emulation fixes - Expand maximum resolution for Banshee and Voodoo 3 from 1600x1280 to 1920x1440 @@ -213,6 +214,7 @@ Detailed change log : - xHCI: added checks to the Evaluate Context and Address Device commands. - xHCI: fixed/updated the Port Status Change Event emulation. - xHCI: fixed/updated the port bandwidth emulation. + - Now includes the USB Debugger support for the xHCI and UHCI controllers. - Many documentation additions. - Networking diff --git a/bochs/PARAM_TREE.txt b/bochs/PARAM_TREE.txt index 15a639620..b0989e81b 100644 --- a/bochs/PARAM_TREE.txt +++ b/bochs/PARAM_TREE.txt @@ -234,6 +234,12 @@ ports (same options as ports.usb.uhci) model n_ports + usb_debug + type + reset + enable + start_frame + non_exist network ne2k diff --git a/bochs/config.cc b/bochs/config.cc index 96971fd1f..d859797f0 100644 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -31,6 +31,9 @@ #if BX_SUPPORT_PCIUSB #include "iodev/usb/usb_common.h" #endif +#if BX_USE_WIN32USBDEBUG +#include "gui/win32usb.h" +#endif #include "param_names.h" #include @@ -1664,6 +1667,47 @@ void bx_init_options() #endif // parallel / serial / USB options initialized in the device plugin code + // usb debugging +#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(root_param, "usb_debug", "USB Debug Options"); + new bx_param_enum_c(usb_debug, + "type", "HC type", + "Select Host Controller type", + usb_debug_type, 0, 0); + new bx_param_bool_c(usb_debug, + "reset", "trigger on reset", + "Trigger on Reset", + 0 + ); + new bx_param_bool_c(usb_debug, + "enable", "trigger on enable", + "Trigger on Enable", + 0 + ); + new bx_param_num_c(usb_debug, + "start_frame", "trigger on start of frame", + "Trigger on start of frame", + BX_USB_DEBUG_SOF_NONE, BX_USB_DEBUG_SOF_TRIGGER, + BX_USB_DEBUG_SOF_NONE + ); + new bx_param_bool_c(usb_debug, + "doorbell", "trigger on doorbell", + "Trigger on Doorbell", + 0 + ); + new bx_param_bool_c(usb_debug, + "event", "trigger on event", + "Trigger on Event", + 0 + ); + new bx_param_bool_c(usb_debug, + "non_exist", "trigger on non exist", + "Trigger on write to non-existant port", + 0 + ); +#endif + #if BX_NETWORKING // network subtree bx_list_c *network = new bx_list_c(root_param, "network", "Network Configuration"); @@ -2230,6 +2274,34 @@ 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; iget_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; @@ -3321,6 +3393,29 @@ static int parse_line_formatted(const char *context, int num_params, char *param } #else PARSE_WARN(("%s: Bochs is not compiled with iodebug support", context)); +#endif +#if BX_USE_WIN32USBDEBUG + } else if (!strcmp(params[0], "usb_debug")) { + if (num_params < 2) { + PARSE_ERR(("%s: usb_debug directive malformed.", context)); + } + // 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) { + PARSE_ERR(("%s: usb_debug: type='%s' previously defined.", context, + SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get_choice(type))); + } + 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)) { + PARSE_ERR(("%s: usb_debug: type='%s' not supported yet.", context, + SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get_choice(type))); + } #endif } else if (!strcmp(params[0], "load32bitOSImage")) { PARSE_ERR(("%s: load32bitOSImage: This legacy feature is no longer supported.", context)); diff --git a/bochs/config.h.in b/bochs/config.h.in index 3bd458bcc..853c4d275 100644 --- a/bochs/config.h.in +++ b/bochs/config.h.in @@ -812,6 +812,11 @@ typedef Bit32u bx_phy_address; #error To enable EHCI, you must also enable UHCI #endif +#ifdef WIN32 +// set to 1 to include the USB DEBUG CONFIG Interface +#define BX_USE_WIN32USBDEBUG 0 +#endif + // MS bus mouse support #define BX_SUPPORT_BUSMOUSE 0 diff --git a/bochs/configure b/bochs/configure index a4c45f9c8..9572d50dd 100755 --- a/bochs/configure +++ b/bochs/configure @@ -869,6 +869,7 @@ DLLTOOL EXPORT_DYNAMIC CI_SUPPORT_OBJS CI_PLUGIN_OBJS +USB_DBG_OBJS ENH_DBG_OBJS CXXFLAGS_CONSOLE BXHUB_LINK_OPTS @@ -1085,6 +1086,7 @@ enable_usb enable_usb_ohci enable_usb_ehci enable_usb_xhci +enable_win32usbdbg enable_ne2000 enable_pnic enable_e1000 @@ -1826,6 +1828,8 @@ Optional Features: --enable-usb-ohci enable USB OHCI support (no) --enable-usb-ehci enable USB EHCI support (no) --enable-usb-xhci enable USB xHCI support (no) + --enable-win32usbdbg compile in support for Bochs Win32 USB debugger + (yes, if debugger is on and USB is on) --enable-ne2000 enable NE2000 support (no) --enable-pnic enable PCI pseudo NIC support (no) --enable-e1000 enable Intel(R) Gigabit Ethernet support (no) @@ -6164,7 +6168,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6167 "configure"' > conftest.$ac_ext + echo '#line 6171 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7661,11 +7665,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7664: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7668: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7668: \$? = $ac_status" >&5 + echo "$as_me:7672: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7895,11 +7899,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7898: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7902: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7902: \$? = $ac_status" >&5 + echo "$as_me:7906: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7963,11 +7967,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7966: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7970: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7970: \$? = $ac_status" >&5 + echo "$as_me:7974: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9758,7 +9762,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:11978: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11978: \$? = $ac_status" >&5 + echo "$as_me:11982: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -12039,11 +12043,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12042: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12046: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12046: \$? = $ac_status" >&5 + echo "$as_me:12050: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -13062,7 +13066,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:13984: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13984: \$? = $ac_status" >&5 + echo "$as_me:13988: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14045,11 +14049,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14048: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14052: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14052: \$? = $ac_status" >&5 + echo "$as_me:14056: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16013,11 +16017,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16016: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16020: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16020: \$? = $ac_status" >&5 + echo "$as_me:16024: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16247,11 +16251,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16250: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16254: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16254: \$? = $ac_status" >&5 + echo "$as_me:16258: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16315,11 +16319,11 @@ else $as_nop -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16318: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16322: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16322: \$? = $ac_status" >&5 + echo "$as_me:16326: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18110,7 +18114,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&5 printf %s "checking enable Bochs internal debugger GUI... " >&6; } # Check whether --enable-debugger-gui was given. @@ -24703,6 +24708,40 @@ fi +usb_debugger=0 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking enable Bochs Win32 USB debugger" >&5 +printf %s "checking enable Bochs Win32 USB debugger... " >&6; } +# Check whether --enable-win32usbdbg was given. +if test ${enable_win32usbdbg+y} +then : + enableval=$enable_win32usbdbg; if test "$enableval" = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + usb_debugger=1 + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + printf "%s\n" "#define BX_USE_WIN32USBDEBUG 0" >>confdefs.h + + usb_debugger=0 + fi +else $as_nop + + if test "$bx_debugger" = 1 -a "$use_usb" = 1; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + usb_debugger=1 + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + printf "%s\n" "#define BX_USE_WIN32USBDEBUG 0" >>confdefs.h + + usb_debugger=0 + fi + + +fi + networking=no NETDEV_OBJS='' @@ -26519,6 +26558,21 @@ printf "%s\n" "$as_me: WARNING: The Bochs debugger gui cannot be compiled here, 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" + printf "%s\n" "#define BX_USE_WIN32USBDEBUG 1" >>confdefs.h + + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: The USB debugger supported only for Win32 cannot be compiled here, disabling it" >&5 +printf "%s\n" "$as_me: WARNING: The USB debugger supported only for Win32 cannot be compiled here, disabling it" >&2;} + printf "%s\n" "#define BX_USE_WIN32USBDEBUG 0" >>confdefs.h + + fi +fi + + CI_PLUGIN_OBJS="textconfig.o" EXPORT_DYNAMIC="-export-dynamic" case $target in diff --git a/bochs/configure.ac b/bochs/configure.ac index f7c0bc268..cbd17fbef 100644 --- a/bochs/configure.ac +++ b/bochs/configure.ac @@ -830,6 +830,7 @@ AC_ARG_ENABLE(debugger, ) AC_SUBST(DEBUGGER_VAR) +gui_debugger=0 AC_MSG_CHECKING(enable Bochs internal debugger GUI) AC_ARG_ENABLE(debugger-gui, AS_HELP_STRING([--enable-debugger-gui], [compile in support for Bochs internal debugger GUI (yes, if debugger is on)]), @@ -1649,6 +1650,29 @@ fi AC_SUBST(USBHC_OBJS) AC_SUBST(USBHC_DLL_TARGETS) +usb_debugger=0 +AC_MSG_CHECKING(enable Bochs Win32 USB debugger) +AC_ARG_ENABLE(win32usbdbg, + AS_HELP_STRING([--enable-win32usbdbg], [compile in support for Bochs Win32 USB debugger (yes, if debugger is on and USB is on)]), + [if test "$enableval" = yes; then + AC_MSG_RESULT(yes) + usb_debugger=1 + else + AC_MSG_RESULT(no) + AC_DEFINE(BX_USE_WIN32USBDEBUG, 0) + usb_debugger=0 + fi], + [ + if test "$bx_debugger" = 1 -a "$use_usb" = 1; then + AC_MSG_RESULT(yes) + usb_debugger=1 + else + AC_MSG_RESULT(no) + AC_DEFINE(BX_USE_WIN32USBDEBUG, 0) + usb_debugger=0 + fi + ] + ) networking=no NETDEV_OBJS='' @@ -2903,6 +2927,18 @@ if test "$gui_debugger" = 1; then fi 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" + AC_DEFINE(BX_USE_WIN32USBDEBUG, 1) + else + AC_MSG_WARN([The USB debugger supported only for Win32 cannot be compiled here, disabling it]) + AC_DEFINE(BX_USE_WIN32USBDEBUG, 0) + fi +fi +AC_SUBST(USB_DBG_OBJS) + CI_PLUGIN_OBJS="textconfig.o" EXPORT_DYNAMIC="-export-dynamic" case $target in diff --git a/bochs/doc/docbook/user/user.dbk b/bochs/doc/docbook/user/user.dbk index 751a658dc..eadb962ab 100644 --- a/bochs/doc/docbook/user/user.dbk +++ b/bochs/doc/docbook/user/user.dbk @@ -3815,7 +3815,7 @@ The start address is optional, since it can be calculated from image size. The Bochs BIOS currently supports only the option "fastboot" to skip the boot menu delay. -flash_dats +flash_data This parameter defines the file name for the flash BIOS config space loaded startup if existing and saved on exit if modified. The Bochs BIOS doesn't @@ -5025,8 +5025,8 @@ available in the runtime configuration. The device 'printer' emulates the HP Deskjet 920C printer. The PCL data is sent to a file specified in the 'file' option with the optionsX -parameter. The current code appends the PCL code to the file if the file already -existed. The output file can be changed at runtime. +parameter. Note that an existing file will be over-written when Bochs starts +again. The output file can be changed at runtime. The optionsX parameter can also be used to assign @@ -5098,6 +5098,8 @@ The optionsX parameter is also available on OHCI. Example: + usb_ehci: enabled=1, companion=uhci + usb_ehci: enabled=1, companion=ohci usb_ehci: enabled=1, port1=tablet, options1="speed:high" usb_ehci: enabled=1, port1=disk, options1="speed:high, path:hdd.img, proto:bbb" usb_ehci: enabled=1, port1=disk, options1="speed:high, path:hdd.img, proto:uasp" @@ -5105,9 +5107,17 @@ Example: usb_ehci: enabled=1, port1=cdrom, options1="speed:high, path:bootcd.iso, proto:uasp" This option controls the presence of the USB EHCI host controller with a -6-port hub. The portX parameter accepts the same device types with the same +6-port root hub. The portX parameter accepts the same device types with the same syntax as the UHCI controller (see the usb_uhci option). -The optionsX parameter is also available on EHCI. +The optionsX parameter is also available on EHCI. + + +The EHCI will default to three UHCI companion controllers, but you can specify either UHCI or OHCI. + + +Either companion with allocate there first two ports to the first companion, the second pair to the next +companion, and the last pair to the third companion. Currently, there is no way to change this. +
usb_xhci @@ -5115,7 +5125,9 @@ The optionsX parameter is also available on EHCI. usb_xhci: enabled=1, model="uPD720202", n_ports=4 - usb_xhci: enabled=1, port1="disk:usbdisk.img" # defaults to the BBB protocol + usb_xhci: port1="disk:usbdisk.img" # defaults to super-speed + usb_xhci: port3="disk:usbdisk.img" # defaults to high-speed + usb_xhci: port1="speed:super, disk:usbdisk.img" # defaults to the BBB protocol usb_xhci: port1=disk, options1="speed:super, path:usbdisk.img, proto:uasp" usb_xhci: port1=disk, options1="speed:super, path:usbdisk.img, proto:bbb" usb_xhci: port1=cdrom, options1="speed:super, path:bootcd.iso, proto:uasp" @@ -5149,6 +5161,79 @@ On an xHCI, the number of ports used is the number of port register sets, one se protocol and a paired set for the USB2 protocol. An 'n_ports=' specification of 4 defines two physical sockets. + +Since the register sets are paired on the xHCI, for example if you have 2 sockets (4 register sets), +Bochs has Port 1 and Port 3 paired. Port 1 is for Super-speed devices while Port 3 is for high-, +full-, and low-speed devices. With this in mind, if you have a device on Port 1, you must +not have a device on Port 3. If you have a (super-speed) device on Port 1 and a (non-super-speed) +device on Port 3, Bochs will Panic with a string similar to: + + >>PANIC<< Port #3: Paired port number #1 already in use. + + + +With an example of 4 register sets (ports), this means there are only 2 physical sockets. You may +only have two devices at a time. To remedy the above Panic, take the following in mind: + + +Valid Port definitions (4-port example) + + + + + + + + + + Scenario + Port 1 (Paired with Port 3) + Port 2 (Paired with Port 4) + Port 3 (Paired with Port 1) + Port 4 (Paired with Port 2) + + + + + 1 + Super + Super + none + none + + + 2 + Super + none + none + High/Full/Low + + + 3 + none + Super + High/Full/Low + none + + + 4 + none + none + High/Full/Low + High/Full/Low + + + + +
+ +
+
+ +
usb debug + +See for this item. +
pcidev @@ -6343,7 +6428,10 @@ byte 3: WWWWWWWW 8-bit Wheel displacement (-127 -> 127) Using the 'model:xxxx" parameter, you can set the mouse to report a different type packet. See below. -This device may be used on all Host Controller types using a speed of 'low', 'full', or 'high'. (see model 'm388phy') +This device may be used on all Host Controller types using a speed of 'low', 'full', or 'high' (see model 'm388phy'). + +Only one mouse/tablet device may be used at one time per emulation session. + usb_uhci: enabled=1, port1=mouse, options1="speed:low" # default report packet shown above usb_ohci: enabled=1, port1=mouse, options1="speed:full, model:m228" # 3-byte report packet, 2 button, 8-bits @@ -6428,11 +6516,11 @@ byte 6: WWWWWWWW 8-bit Wheel displacement (-128 -> 127) This report is deliberately irregular by design, so that a Guest can test its HID Report Descriptor Parser. - - the button fields are not consecutive and are at arbitrary positions in the report. - - the coords fields are not byte aligned or consecutively spaced. - - the coords fields are of an irregular size, each a different size. - - there are padding fields between entries that do not align the next field on a byte boundary. - - this also uses the push/pop mechanism to test the function of your parser. + the button fields are not consecutive and are at arbitrary positions in the report. + the coords fields are not byte aligned or consecutively spaced. + the coords fields are of an irregular size, each a different size. + there are padding fields between entries that do not align the next field on a byte boundary. + this also uses the push/pop mechanism to test the function of your parser. Again, this is deliberate. A correctly written parser will extract the neccessary fields no matter the irregularity. Returns the 5-byte packet shown below. @@ -6449,9 +6537,15 @@ Please note that this model is not for normal use. It is intentionally<
mouse: misc - -Please note that most physical USB mice will be 'low-speed' only. - + +Note that most physical USB mice will be 'low-speed' only. + + +Note that the mouse is known to not function correctly in a Windows 2000 Guest. Clearing HANDLE_TOGGLE_CONTROL to zero +in usb_common.h and rebuilding Bochs allows this guest to function more regularly, though there are still some issues. +Since the USB mouse and keyboard work in all other regulary tested Guests, it must be a quirk with Win2k that needs to +be investigated. +
@@ -6493,6 +6587,9 @@ byte 0: 00000LLL Lock States This device may be used on all Host Controller types using a speed of 'low', 'full', or 'high'. + +Only one keyboard/keypad device may be used at one time per emulation session. + usb_uhci: enabled=1, port1=keyboard, options1="speed:low" usb_ohci: enabled=1, port1=keyboard, options1="speed:full" @@ -6523,6 +6620,9 @@ Only the key range noted before will be sent via the USB emulation. This device may be used on all Host Controller types using a speed of 'low', 'full', or 'high'. + +Only one keyboard/keypad device may be used at one time per emulation session. + usb_uhci: enabled=1, port1=keypad, options1="speed:low" usb_ohci: enabled=1, port1=keypad, options1="speed:full" @@ -6555,6 +6655,9 @@ Please note that the X and Y Displacement values are absolute, not relative valu This device may be used on all Host Controller types using a speed of 'low', 'full', or 'high'. + +Only one mouse/tablet device may be used at one time per emulation session. + usb_uhci: enabled=1, port1=tablet, options1="speed:low" usb_ohci: enabled=1, port1=tablet, options1="speed:full" @@ -6577,6 +6680,10 @@ high- and super-speed devices, you can specify the "UASP" protocol, also known a This device may be used on all Host Controller types using a speed of 'full', 'high', or 'super'. + +Any number of disk/CD-ROM devices may be used as long as there is an available HC/Hub port, +and that each instance uses its own image file, i.e.: image files cannot be shared. + usb_uhci: enabled=1, port1=disk, options1="speed:full, path:hdd.img" # defaults to the BBB protocol usb_ohci: enabled=1, port1=disk, options1="speed:full, path:hdd.img" @@ -6602,7 +6709,7 @@ Specifying 'proto:uasp' does not guarantee that the Guest will use that protocol See a previous section for more information. -Please note that this device is not allowed as a low-speed only device. Low-speed should be specified. +Please note that this device is not allowed as a low-speed only device. Low-speed should not be specified. @@ -6610,11 +6717,15 @@ Please note that this device is not allowed as a low-speed only device. Low-spee
Floppy This emulates a media device in the form of an external Floppy drive. By default, -the emulation uses the "Control/Bulk/Interrupt" transport, aka "CBI". Bochs can be -re-compiled to use the "Control/Bulk" transport, aka "CB". +the emulation uses the "Control/Bulk/Interrupt" transport, aka "CBI". A compile-time option can be +given to use the "Control/Bulk" transport, aka "CB". This device may be used on all Host Controller types using a speed of 'full'. + +Any number of floppy devices may be used as long as there is an available HC/Hub +port, and that each instance uses its own image file, i.e.: image files cannot be shared. + usb_uhci: enabled=1, port1=floppy, options1="speed:full, path:floppy.img" usb_ohci: enabled=1, port1=floppy, options1="speed:full, path:floppy.img, model:teac" @@ -6629,19 +6740,36 @@ usb_uhci: enabled=1, port1=floppy, options1="speed:full, path:mode + +The 'nofail' option can be used to disable the INQUIRY quirk. This quirk is enabled by default. + +usb_uhci: enabled=1, port1=floppy, options1="speed:full, path:floppy.img, nofail" + +To be consistant with real hardware, we need to fail with a STALL twice for any command after the first +INQUIRY command except for the INQUIRY command itself and the REQUEST SENSE command. (I don't know why, +and will document further when I know more.) + + +Bochs allows more than one USB floppy devices to be used at one time, one on each available port. +Each will be displayed in the status bar, the first as USB-FD1, the second as USB-FD2, etc. + Please note that this device is a full-speed only device. No other speed should be specified. -
Printer -This emulates a simple USB printer. All data sent to the printer will be appended +This emulates a simple USB printer. All data sent to the printer will be written to a specified file on the Host. This device may be used on all Host Controller types using a speed of 'full'. + +Any number of printer devices may be used as long as there is an available HC/Hub port, +and that each instance uses its own target file, i.e.: target files cannot be shared. + usb_uhci: enabled=1, port1=printer, options1="speed:full, file:printdata.bin" usb_ohci: enabled=1, port1=printer, options1="speed:full, file:printdata.bin" @@ -6661,6 +6789,9 @@ changed, with a range of 2 to 8. This device may be used on all Host Controller types using a speed of 'full'. + +Any number of hub devices may be used as long as there is an available HC/Hub port. + usb_uhci: enabled=1, port1=hub, options1="speed:full" usb_ohci: enabled=1, port1=hub, options1="speed:full, ports:4" @@ -6727,10 +6858,183 @@ interface has problems when double-quotes are used. Therefore, don't use them in runtime configuration interface. + + +When adjusting an xHCI port within the runtime configuration, you must remove a device +from a companion port before adding to the other associated port. For example, if port +1 and port 3 are paired and you currently have something on port 3, you must remove it +from port 3, continue the emulation, then come back and add something to port 1. You cannot +remove something from port 3 and add something to port 1 at the same time. + + + + +The USB emulation has been tested on numerous Guests. You can find these results at +here. + +
+
USB Debugger + +This debugger implementation is experimental. Please take caution when using it. + + + + usb_debug: type=none|uhci|ohci|ehci|xhci, reset, enable, start_frame, doorbell, event, non_exist + + + +Currently only none, uhci, or xhci can be specified as the type. +Future additions will include the other two controller types. + + +Only one type may be specified. You can only debug one controller type at a time. + + + + triggers: (one or more must be specified) + 'reset' -- When the controller resets a port, the debugger will halt the emulation and display + the debugger. This does not include when the HC gets reset, which in turn would reset + the downstream ports. + The debugger is triggered at the write of the port before the port value is updated by the write. + 'enable' -- When the controller enables a port, the debugger will halt the emulation and display + the debugger. For an EHCI port, the controller automatically enables the port when + a high-speed device is detected. + The debugger is triggered at the write of the port before the port value is updated by the write. + 'start_frame' -- When the controller starts a new frame, the debugger will halt the emulation + and display the debugger. Please note that the implementation of this feature is/will + be different with each controller type. Also, if the frame is not active, this trigger will + never be called. i.e.: In the UHCI, if the schedule is not in the RUN state, this trigger will + not be active. + -- uhci: Load the next Frame Index and process the TD/Queue pointed by it. + -- ohci: ** TODO ** + -- ehci: ** TODO ** + -- xhci: Start/Continue to process Transfer Rings. + 'doorbell' -- When the xHCI controller receives a doorbell ring indicator (for the Command Ring), + the debugger will halt the emulation and display the debugger. + -- When the EHCI controller is to execute a single TD, the debugger will halt the + emulation and display the debugger. + -- When the OHCI controller is to execute a single TD, the debugger will halt the + emulation and display the debugger. + -- When the UHCI controller is to execute a single TD, the debugger will halt the + emulation and display the debugger. + 'event' -- When the xHCI controller posts an event on the event ring, the debugger will + halt the emulation and display the debugger. This is only used in the xHCI controller + type. Other types will ignore this trigger. + 'non_exist' -- When the guest writes to a non-existent port, the debugger will halt the emulation + and display the debugger. This is so you can trigger the debugger via software. + Write to the first non-existent port and the debugger will be triggered. + Reads have no affect. + + + +The USB Debugger also has a button-bar icon that when clicked will trigger the debugger. However, please +note that if the debugger is currently unavailable, due to the controller state for example, the icon +will change to squiggly lines and then at the next available controller state, the debugger will display. +If the icon has an 'X' through it, the debugger is unavailable. + + +If you modify any value within the debugger's display, any change that might trigger a change to +the controller's state will take place. For example, if you change the Current Connect Status +and the Current Enable Status, both will be triggered at the same time by +the controller. To keep this from happening, change one and hit the Apply Button. Then trigger +the debugger again and change another. + + +When the Debugger dialog is displayed, you can view/modify different aspects of the controller, the +controller root hub ports, as well as other items. For example, with the xHCI debugger, you can view +and modify TRBs on the Command Ring. Simply set the 'doorbell' trigger, and when a doorbell is written, +the emulation will stop and display the current Command Ring with any available TRBs. + + +You can turn off or on any trigger (listed above) while within the Debugger dialog. If all of them +are off, you can use the Ribbon Trigger button to display the Debugger, then set any triggers active. + + +The figure below is an example of an xHCI controller using the Doorbell trigger to stop when the +Controller receives a TRB in the Command Ring with the Command Ring Doorbell being triggered. +
USB Debugger Example0 + + + + + USB Debugger Example 0 + +
+The three register sets are displayed allowing you to modify their values. Please note that modifying +the Capability Register set will produce undefined results. It is recommended that you do not modify +this register set. +
+ +The Debug Flags box allows you to set or clear a trigger. If the checkbox is checked, the trigger is active. + + +The Port Register set displays the used registers allowing you to modify them as you see fit. Again, undefined +results may happen if you modify these registers. + + +The Tree List shows the current TRB list of the Command Ring. Notice that six TRBs have already been executed. +(You should have had the Debugger triggered six times already). The TRB listed in bold is the current TRB to +be executed. If you select that item and then click the "View TRB" button, you can modify the TRB before the +controller has a chance to execute it. Note that you cannot change the TRB's type, though you can modify its +attributes. + + +The "Continue" button will exit the debugger and continue the emulation. The "Quit" button will quit the entire +emulation. + + +
USB Debugger: xHCI + +Notes on the xHCI USB Debugger will go here. + +
+ +
USB Debugger: EHCI + +Notes on the EHCI USB Debugger will go here. + +
+ +
USB Debugger: OHCI + +Notes on the OHCI USB Debugger will go here. + +
+ +
USB Debugger: UHCI + +When the 'doorbell' trigger is used, the debugger will trigger before the controller processes the TD *and* again +after the controller processes the TD. This is so you can see the TD before it is processed, allowing you to make +changes, and then see the results. Please note that the *before* and *after* status only effects the currently +executing TD. All other TDs have either already been executed or have not yet been executed. + + +Changing the 'Active' bit before the controller processes the TD is not allowed since the controller has already +found the TD active and is processing it. Changing it after the controller has processed it is allowed, but why +would you? + + +Changing any items in a TD *after* the TD has been processed is not recommended and undefined results may occur. + + +You normally would not have both the 'start_frame' and 'doorbell' triggers active when using the UHCI. If they +are, the 'doorbell' trigger will trigger the first TD in the frame anyway. The 'start_frame' trigger is only used +when you want to see the frame's list once at start of frame. The 'doorbell' trigger is used on every active TD found. + + +If the TD is using BreadthFirst processing, the debugger will not display any TDs linked by the LINK PTR. This is +because some drivers point the LINK PTR to itself to make sure the TD is executed. If the TD is executed, the active +bit will be clear, so the next TD will be processed anyway. + + +
+ +
+ diff --git a/bochs/gui/Makefile.in b/bochs/gui/Makefile.in index 1800e289a..335553d9c 100644 --- a/bochs/gui/Makefile.in +++ b/bochs/gui/Makefile.in @@ -70,7 +70,7 @@ CI_OBJS_WIN32 = win32config.o CI_OBJS_WIN32_SUPPORT = win32paramdlg.o scrollwin.o GUI_DLL_TARGETS = @GUI_DLL_TARGETS@ -OBJS_THAT_CANNOT_BE_PLUGINS = keymap.o gui.o siminterface.o paramtree.o @ENH_DBG_OBJS@ +OBJS_THAT_CANNOT_BE_PLUGINS = keymap.o gui.o siminterface.o paramtree.o @ENH_DBG_OBJS@ @USB_DBG_OBJS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ @@ -318,6 +318,14 @@ win32paramdlg.o: win32paramdlg.@CPP_SUFFIX@ win32dialog.h ../config.h ../bochs.h ../config.h ../osdep.h ../gui/paramtree.h ../logio.h \ ../misc/bswap.h siminterface.h \ win32res.h +win32usb.o: win32usb.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ + ../gui/paramtree.h ../logio.h ../misc/bswap.h win32dialog.h ../config.h \ + ../iodev/iodev.h ../plugin.h ../extplugin.h ../param_names.h \ + ../pc_system.h ../bx_debug/debug.h ../osdep.h ../cpu/decoder/decoder.h \ + ../memory/memory-bochs.h ../gui/siminterface.h ../gui/gui.h \ + win32usbres.h win32usb.h ../iodev/usb/usb_common.h \ + ../iodev/usb/usb_pcap.h ../iodev/usb/uhci_core.h ../iodev/usb/usb_uhci.h \ + ../iodev/usb/usb_xhci.h wx.o: wx.@CPP_SUFFIX@ ../config.h ../bochs.h ../config.h ../osdep.h \ ../gui/paramtree.h ../logio.h \ ../misc/bswap.h ../param_names.h \ @@ -439,6 +447,14 @@ win32paramdlg.lo: win32paramdlg.@CPP_SUFFIX@ win32dialog.h ../config.h ../bochs. ../config.h ../osdep.h ../gui/paramtree.h ../logio.h \ ../misc/bswap.h siminterface.h \ win32res.h +win32usb.lo: win32usb.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ + ../gui/paramtree.h ../logio.h ../misc/bswap.h win32dialog.h ../config.h \ + ../iodev/iodev.h ../plugin.h ../extplugin.h ../param_names.h \ + ../pc_system.h ../bx_debug/debug.h ../osdep.h ../cpu/decoder/decoder.h \ + ../memory/memory-bochs.h ../gui/siminterface.h ../gui/gui.h \ + win32usbres.h win32usb.h ../iodev/usb/usb_common.h \ + ../iodev/usb/usb_pcap.h ../iodev/usb/uhci_core.h ../iodev/usb/usb_uhci.h \ + ../iodev/usb/usb_xhci.h wx.lo: wx.@CPP_SUFFIX@ ../config.h ../bochs.h ../config.h ../osdep.h \ ../gui/paramtree.h ../logio.h \ ../misc/bswap.h ../param_names.h \ diff --git a/bochs/gui/bitmaps/usb.h b/bochs/gui/bitmaps/usb.h new file mode 100644 index 000000000..5fb6538e2 --- /dev/null +++ b/bochs/gui/bitmaps/usb.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////// +// $Id:$ +///////////////////////////////////////////////////////////////////////// + +#define BX_USB_BMAP_X 32 +#define BX_USB_BMAP_Y 32 + +static const unsigned char bx_usb_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03, + 0xE0, 0xFF, 0xFF, 0x07, 0xF0, 0x01, 0x80, 0x0F, 0xF0, 0x00, 0x00, 0x0F, + 0xF0, 0x01, 0x80, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, + 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, + 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, + 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, + 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0x0F, + 0xF0, 0xFF, 0xFF, 0x0F, 0xE0, 0xFF, 0xFF, 0x07, 0xC0, 0x00, 0x00, 0x03, + 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x0C, 0x30, 0x03, 0xC0, 0x0C, 0x30, 0x03, + 0xC0, 0x0C, 0x30, 0x03, 0xC0, 0x0C, 0x30, 0x03, 0xC0, 0x00, 0x00, 0x03, + 0xC0, 0xFF, 0xFF, 0x03, 0x80, 0xFF, 0xFF, 0x01 +}; + +static const unsigned char bx_usb_eject_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = { + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x40, 0xC4, 0xFF, 0xFF, 0x23, + 0xE8, 0xFF, 0xFF, 0x17, 0xE0, 0x01, 0x80, 0x07, 0xD0, 0x00, 0x00, 0x0B, + 0xB0, 0x01, 0x80, 0x0D, 0x70, 0xFF, 0xFF, 0x0E, 0xF0, 0xFE, 0x7F, 0x0F, + 0xF0, 0xFD, 0xBF, 0x0F, 0xF0, 0xFB, 0xDF, 0x0F, 0xF0, 0xF7, 0xEF, 0x0F, + 0xF0, 0xEF, 0xF7, 0x0F, 0xF0, 0xDF, 0xFB, 0x0F, 0xF0, 0xBF, 0xFD, 0x0F, + 0xF0, 0x7F, 0xFE, 0x0F, 0xF0, 0x7F, 0xFE, 0x0F, 0xF0, 0xBF, 0xFD, 0x0F, + 0xF0, 0xDF, 0xFB, 0x0F, 0xF0, 0xEF, 0xF7, 0x0F, 0xF0, 0xF7, 0xEF, 0x0F, + 0xF0, 0xFB, 0xDF, 0x0F, 0xE0, 0xFD, 0xBF, 0x07, 0xC0, 0x01, 0x80, 0x03, + 0x40, 0x00, 0x00, 0x02, 0x80, 0x0C, 0x30, 0x01, 0xE0, 0x0C, 0x30, 0x07, + 0xD0, 0x0C, 0x30, 0x0B, 0xC8, 0x0C, 0x30, 0x13, 0xC4, 0x00, 0x00, 0x23, + 0xC2, 0xFF, 0xFF, 0x43, 0x80, 0xFF, 0xFF, 0x01 +}; + +static const unsigned char bx_usb_trigger_bmap[(BX_USB_BMAP_X * BX_USB_BMAP_Y)/8] = { + 0x08, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x40, 0xC2, 0xFF, 0xFF, 0x23, + 0xE4, 0xFF, 0xFF, 0x47, 0xF8, 0x01, 0x80, 0x8F, 0xF4, 0x00, 0x00, 0x4F, + 0xF2, 0x01, 0x80, 0x2F, 0xF4, 0xFF, 0xFF, 0x4F, 0xF8, 0xFF, 0xFF, 0x8F, + 0xF4, 0xFF, 0xFF, 0x4F, 0xF2, 0xFF, 0xFF, 0x2F, 0xF4, 0xFF, 0xFF, 0x4F, + 0xF8, 0xFF, 0xFF, 0x8F, 0xF4, 0xFF, 0xFF, 0x4F, 0xF2, 0xFF, 0xFF, 0x2F, + 0xF4, 0xFF, 0xFF, 0x4F, 0xF8, 0xFF, 0xFF, 0x8F, 0xF4, 0xFF, 0xFF, 0x4F, + 0xF2, 0xFF, 0xFF, 0x2F, 0xF4, 0xFF, 0xFF, 0x4F, 0xF8, 0xFF, 0xFF, 0x8F, + 0xF4, 0xFF, 0xFF, 0x4F, 0xE2, 0xFF, 0xFF, 0x27, 0xC4, 0x00, 0x00, 0x43, + 0xC8, 0x00, 0x00, 0x83, 0xC4, 0x0C, 0x30, 0x43, 0xC2, 0x0C, 0x30, 0x23, + 0xC4, 0x0C, 0x30, 0x43, 0xC8, 0x0C, 0x30, 0x83, 0xC4, 0x00, 0x00, 0x43, + 0xC2, 0xFF, 0xFF, 0x23, 0x84, 0xFF, 0xFF, 0x41 +}; diff --git a/bochs/gui/bitmaps/usb.xpm b/bochs/gui/bitmaps/usb.xpm new file mode 100644 index 000000000..247c6ffb6 --- /dev/null +++ b/bochs/gui/bitmaps/usb.xpm @@ -0,0 +1,41 @@ +/* XPM */ +static const char *usb_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 32 32 2 1", +/* colors */ +". c None", +"# c #000000", +/* pixels */ +"................................", +"................................", +"......####################......", +".....######################.....", +"....#####..............#####....", +"....####................####....", +"....#####..............#####....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +"....########################....", +".....######################.....", +"......##................##......", +"......##................##......", +"......##..##........##..##......", +"......##..##........##..##......", +"......##..##........##..##......", +"......##..##........##..##......", +"......##................##......", +"......####################......", +".......##################......." +}; diff --git a/bochs/gui/gui.cc b/bochs/gui/gui.cc index 387bcca08..eccb89a44 100644 --- a/bochs/gui/gui.cc +++ b/bochs/gui/gui.cc @@ -33,6 +33,9 @@ #include "gui/bitmaps/paste.h" #include "gui/bitmaps/configbutton.h" #include "gui/bitmaps/cdromd.h" +#if BX_USE_WIN32USBDEBUG + #include "gui/bitmaps/usb.h" +#endif #include "gui/bitmaps/userbutton.h" #include "gui/bitmaps/saverestore.h" @@ -232,6 +235,15 @@ void bx_gui_c::init(int argc, char **argv, unsigned max_xres, unsigned max_yres, BX_GUI_THIS save_restore_bmap_id = create_bitmap(bx_save_restore_bmap, BX_SAVE_RESTORE_BMAP_X, BX_SAVE_RESTORE_BMAP_Y); +#if BX_USE_WIN32USBDEBUG + BX_GUI_THIS usb_bmap_id = create_bitmap(bx_usb_bmap, + BX_USB_BMAP_X, BX_USB_BMAP_Y); + BX_GUI_THIS usb_eject_bmap_id = create_bitmap(bx_usb_eject_bmap, + BX_USB_BMAP_X, BX_USB_BMAP_Y); + BX_GUI_THIS usb_trigger_bmap_id = create_bitmap(bx_usb_trigger_bmap, + BX_USB_BMAP_X, BX_USB_BMAP_Y); +#endif + // Add the initial bitmaps to the headerbar, and enable callback routine, for use // when that bitmap is clicked on. The floppy and cdrom devices are not // initialized yet. so we just set the bitmaps to ejected for now. @@ -260,6 +272,25 @@ void bx_gui_c::init(int argc, char **argv, unsigned max_xres, unsigned max_yres, BX_GRAVITY_LEFT, toggle_mouse_enable); BX_GUI_THIS set_tooltip(BX_GUI_THIS mouse_hbar_id, "Enable mouse capture"); +#if BX_USE_WIN32USBDEBUG + // USB button + if (BX_GUI_THIS dialog_caps & BX_GUI_DLG_USB) { + if ((SIM->get_param_enum(BXPN_USB_DEBUG_TYPE)->get() > 0) && ( + SIM->get_param_bool(BXPN_UHCI_ENABLED)->get() || + SIM->get_param_bool(BXPN_OHCI_ENABLED)->get() || + SIM->get_param_bool(BXPN_EHCI_ENABLED)->get() || + SIM->get_param_bool(BXPN_XHCI_ENABLED)->get())) { + BX_GUI_THIS usb_hbar_id = headerbar_bitmap(BX_GUI_THIS usb_bmap_id, + BX_GRAVITY_LEFT, usb_handler); + BX_GUI_THIS set_tooltip(BX_GUI_THIS usb_hbar_id, "Trigger the USB Debugger"); + } else { + BX_GUI_THIS usb_hbar_id = headerbar_bitmap(BX_GUI_THIS usb_eject_bmap_id, + BX_GRAVITY_LEFT, usb_handler); + BX_GUI_THIS set_tooltip(BX_GUI_THIS usb_hbar_id, "USB support not enabled"); + } + } +#endif + // These are the buttons on the right side. They are created in order // of right to left. @@ -682,6 +713,18 @@ void bx_gui_c::config_handler(void) } } +#if BX_USE_WIN32USBDEBUG +#include "win32usb.h" +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); + } +} +#endif + void bx_gui_c::toggle_mouse_enable(void) { int old = SIM->get_param_bool(BXPN_MOUSE_ENABLED)->get(); diff --git a/bochs/gui/gui.h b/bochs/gui/gui.h index 595459562..3c6a85688 100644 --- a/bochs/gui/gui.h +++ b/bochs/gui/gui.h @@ -26,8 +26,13 @@ // header bar and status bar stuff #define BX_HEADER_BAR_Y 32 -#define BX_MAX_PIXMAPS 17 -#define BX_MAX_HEADERBAR_ENTRIES 12 +#if BX_USE_WIN32USBDEBUG + #define BX_MAX_PIXMAPS 19 + #define BX_MAX_HEADERBAR_ENTRIES 13 +#else + #define BX_MAX_PIXMAPS 17 + #define BX_MAX_HEADERBAR_ENTRIES 12 +#endif // align pixmaps towards left or right side of header bar #define BX_GRAVITY_LEFT 10 @@ -42,7 +47,12 @@ #define BX_GUI_DLG_RUNTIME 0x08 #define BX_GUI_DLG_USER 0x10 #define BX_GUI_DLG_SAVE_RESTORE 0x20 -#define BX_GUI_DLG_ALL 0x3F +#if BX_USE_WIN32USBDEBUG + #define BX_GUI_DLG_USB 0x40 + #define BX_GUI_DLG_ALL 0x7F +#else + #define BX_GUI_DLG_ALL 0x3F +#endif // text mode blink feature #define BX_TEXT_BLINK_MODE 0x01 @@ -70,6 +80,13 @@ #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 + typedef struct { Bit16u start_address; Bit8u cs_start; @@ -235,6 +252,9 @@ protected: static void paste_handler(void); static void snapshot_handler(void); static void config_handler(void); +#if BX_USE_WIN32USBDEBUG + static void usb_handler(void); +#endif static void userbutton_handler(void); static void save_restore_handler(void); // process clicks on the "classic" Bochs headerbar @@ -268,6 +288,12 @@ protected: unsigned mouse_bmap_id, nomouse_bmap_id, mouse_hbar_id; unsigned user_bmap_id, user_hbar_id; unsigned save_restore_bmap_id, save_restore_hbar_id; +#if BX_USE_WIN32USBDEBUG + // TODO: this is a lousy hack. we need to keep these protected.... +public: + unsigned usb_bmap_id, usb_eject_bmap_id, usb_trigger_bmap_id, usb_hbar_id; +protected: +#endif // the "classic" Bochs headerbar unsigned bx_headerbar_entries; struct { diff --git a/bochs/gui/siminterface.cc b/bochs/gui/siminterface.cc index 18aa0b011..8cb1551b4 100644 --- a/bochs/gui/siminterface.cc +++ b/bochs/gui/siminterface.cc @@ -69,6 +69,9 @@ 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 + usb_interface_callback_t usbi_callback; +#endif rt_conf_entry_t *rt_conf_entries; addon_option_t *addon_options; bool init_done; @@ -176,6 +179,10 @@ public: config_interface_callback_t callback, void *userdata); virtual int configuration_interface(const char* name, ci_command_t command); +#if BX_USE_WIN32USBDEBUG + virtual void register_usb_interface(usb_interface_callback_t callback, void *data); + virtual int usb_config_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); virtual void unregister_runtime_config_handler(int id); @@ -932,6 +939,27 @@ int bx_real_sim_c::configuration_interface(const char *ignore, ci_command_t comm return retval; } +#if BX_USE_WIN32USBDEBUG +void bx_real_sim_c::register_usb_interface(usb_interface_callback_t callback, void *data) +{ + usbi_callback = callback; +} + +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; + } + + set_display_mode(DISP_MODE_CONFIG); + int retval = (*usbi_callback)(type, wParam, lParam); + set_display_mode(DISP_MODE_SIM); + + return retval; +} +#endif + int bx_real_sim_c::begin_simulation(int argc, char *argv[]) { return bx_begin_simulation(argc, argv); diff --git a/bochs/gui/siminterface.h b/bochs/gui/siminterface.h index 505d67874..47c35f9d1 100644 --- a/bochs/gui/siminterface.h +++ b/bochs/gui/siminterface.h @@ -570,6 +570,9 @@ 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[]); @@ -710,6 +713,10 @@ public: config_interface_callback_t callback, void *userdata) {} virtual int configuration_interface(const char* name, ci_command_t command) {return -1; } +#if BX_USE_WIN32USBDEBUG + 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; } +#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;} virtual void unregister_runtime_config_handler(int id) {} diff --git a/bochs/gui/win32.cc b/bochs/gui/win32.cc index 04fbb8baf..38df0ddd5 100644 --- a/bochs/gui/win32.cc +++ b/bochs/gui/win32.cc @@ -159,7 +159,7 @@ static BOOL hideIPS = FALSE; static char ipsText[20]; #endif #define BX_SB_MAX_TEXT_ELEMENTS 2 -#define SIZE_OF_SB_ELEMENT 50 +#define SIZE_OF_SB_ELEMENT 60 #define SIZE_OF_SB_MOUSE_MESSAGE 170 #define SIZE_OF_SB_IPS_MESSAGE 90 Bit32u SB_Led_Colors[3] = {0x0000FF00, 0x000040FF, 0x0000FFFF}; @@ -1218,6 +1218,13 @@ void SetMouseCapture() SetMouseToggleInfo(); } +#if BX_USE_WIN32USBDEBUG +BOOL GetMouseCaptureMode() +{ + return mouseCaptureMode; +} +#endif + LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc, hdcMem; diff --git a/bochs/gui/win32config.cc b/bochs/gui/win32config.cc index 36d3dc935..428356b74 100644 --- a/bochs/gui/win32config.cc +++ b/bochs/gui/win32config.cc @@ -31,6 +31,10 @@ #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 @@ -41,6 +45,9 @@ 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; @@ -798,4 +805,34 @@ 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 diff --git a/bochs/gui/win32usb.cc b/bochs/gui/win32usb.cc new file mode 100644 index 000000000..879a5a3ef --- /dev/null +++ b/bochs/gui/win32usb.cc @@ -0,0 +1,3875 @@ +///////////////////////////////////////////////////////////////////////// +// $Id$ +///////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023 Benjamin David Lunt +// Copyright (C) 2003-2023 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 + +// Define BX_PLUGGABLE in files that can be compiled into plugins. For +// platforms that require a special tag on exported symbols, BX_PLUGGABLE +// is used to know when we are exporting symbols and when we are importing. +#define BX_PLUGGABLE + +#include "bochs.h" + +#if BX_USE_WIN32USBDEBUG + +#include "windowsx.h" + +#include "win32dialog.h" + +#include "iodev.h" +#include "param_names.h" + +#include "win32usbres.h" +#include "win32usb.h" + +#include "iodev/usb/usb_common.h" + +static const int dlg_resource[5] = { + 0, + USB_DEBUG_UHCI_DLG, + USB_DEBUG_OHCI_DLG, + USB_DEBUG_EHCI_DLG, + USB_DEBUG_XHCI_DLG +}; + +bx_param_c *host_param = NULL; +static const char *hc_param_str[5] = { + "", + BXPN_USB_UHCI, + BXPN_USB_OHCI, + BXPN_USB_EHCI, + BXPN_USB_XHCI +}; + +static const DLGPROC usb_debug_callbacks[5] = { + NULL, + hc_uhci_callback, + hc_ohci_callback, + hc_ehci_callback, + hc_xhci_callback +}; + +Bit32u pci_bar_address = 0; +struct CALLBACK_PARAMS g_params; + +HFONT hTreeViewFont; + +/////////////////////////////////////////////////////////////////////////////////////////////// +// Common to all HC types +// +void SetMouseCapture(); +BOOL GetMouseCaptureMode(); + +// return 0 to continue with emulation +// return -1 to quit emulation +int win32_usb_start(HWND hwnd, int break_type, int wParam, int lParam) +{ + char str[COMMON_STR_SIZE]; + int ret; + + // get the (host controller) type we are to debug + Bit32s type = SIM->get_param_enum(BXPN_USB_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 + 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]); + MessageBox(hwnd, str, NULL, MB_ICONINFORMATION); + return 0; + } + + // create a font for the TreeView + hTreeViewFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, + OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_DONTCARE, TEXT("Cascadia")); + if (hTreeViewFont == NULL) { + hTreeViewFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, + OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_DONTCARE, TEXT("Consolas")); + } + if (hTreeViewFont == NULL) { + hTreeViewFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, + OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_DONTCARE, TEXT("Courier New")); + } + if (hTreeViewFont == NULL) { + MessageBox(hwnd, "Could not create a font for the Tree View Control", NULL, MB_ICONINFORMATION); + return 0; + } + + // if the mouse is currently being captured, we need to pause capture mode + // (This is Win32 specific, though we are already Win32 specific, so it shouldn't matter) + BOOL capture = GetMouseCaptureMode(); + if (capture) { + bx_gui->mouse_enabled_changed_specific(0); + SetMouseCapture(); + } + + // create the dialog and wait for it to return + g_params.type = 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); + // destroy the font + DeleteObject(hTreeViewFont); + + // re-capture the mouse? + if (capture) { + bx_gui->mouse_enabled_changed_specific(1); + SetMouseCapture(); + } + + 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_config_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_config_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); + 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); + 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); + 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); + break; + } +} + +HWND TreeView = NULL; +int tree_items = 0; +HTREEITEM TreeViewInsert(HWND TreeView, HTREEITEM Parent, HTREEITEM After, char *str, LPARAM lParam, Bit32u state) { + TVINSERTSTRUCT tvis; + + // if Parent != NULL, change Parent to have children + if (Parent != NULL) { + tvis.item.mask = TVIF_HANDLE | TVIF_CHILDREN; + tvis.item.hItem = Parent; + tvis.item.cChildren = 1; + TreeView_SetItem(TreeView, &tvis.item); + } + tvis.hParent = Parent; + tvis.hInsertAfter = After; + tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; + tvis.item.pszText = str; + tvis.item.state = TVIS_EXPANDED | state; + tvis.item.stateMask = TVIS_EXPANDED | state; + tvis.item.lParam = lParam; + tree_items++; + return TreeView_InsertItem(TreeView, &tvis); +} + +struct DUMP_PARAMS g_dump_parms; +INT_PTR CALLBACK dump_dialog_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_INITDIALOG: + // make sure we don't over do it + if (g_dump_parms.size > 512) + g_dump_parms.size = 512; + if (g_dump_parms.size > 0) { + // 3 bytes per char printed, ~18 chars at the first of each line, 20 of chars, 2 chars at the end of each line, 2 at last line + int str_size = (g_dump_parms.size * 3) + ((18 + 2) * ((g_dump_parms.size + 15) / 16)) + 2; + // make sure we are at least COMMON_STR_SIZE so we can use it to set the title + if (str_size < COMMON_STR_SIZE) + str_size = COMMON_STR_SIZE; + char *str = new char[str_size]; + char temp_str[COMMON_STR_SIZE]; + if (g_dump_parms.big) + sprintf(str, "%s--Address: 0x" FMT_ADDRX64 ": size = %i", g_dump_parms.title, g_dump_parms.address, g_dump_parms.size); + else + sprintf(str, "%s--Address: 0x%08X: size = %i", g_dump_parms.title, (Bit32u) g_dump_parms.address, g_dump_parms.size); + SetWindowText(hDlg, str); + + // we need a fixed width font for the dump + HFONT hDumpFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, + OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_DONTCARE, TEXT("Courier New")); + SNDMSG(GetDlgItem(hDlg, IDC_DUMP), WM_SETFONT, (WPARAM) hDumpFont, FALSE); + + // read in the buffer + Bit8u *buffer = new Bit8u[g_dump_parms.size]; + DEV_MEM_READ_PHYSICAL(g_dump_parms.address, g_dump_parms.size, buffer); + + // dump it + int j = 0; + strcpy(str, ""); + for (int i = 0; i < g_dump_parms.size; i++) { + if (j == 0) { + if (g_dump_parms.big) + sprintf(temp_str, "0x" FMT_PHY_ADDRX64 ": ", g_dump_parms.address); + else + sprintf(temp_str, "0x%08X: ", (Bit32u) g_dump_parms.address); + strcat(str, temp_str); + g_dump_parms.address += 16; + } + + j++; + if ((j == 8) && ((i + 1) != g_dump_parms.size)) { + sprintf(temp_str, "%02X-", buffer[i]); + } else { + sprintf(temp_str, "%02X ", buffer[i]); + } + strcat(str, temp_str); + if (j == 16) { + strcat(str, "\r\n"); + j = 0; + } + } + strcat(str, "\r\n"); + SetDlgItemText(hDlg, IDC_DUMP, str); + + DeleteObject(hDumpFont); + delete [] buffer; + delete [] str; + + SetFocus(GetDlgItem(hDlg, IDCANCEL)); + } else + SetDlgItemText(hDlg, IDC_DUMP, "Nothing to do..."); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// UHCI +// +struct S_ATTRIBUTES attribs_u_command[] = { + // | 31 chars + null | <- max + { (1<<7), (1<<7), 7, "Max Packet" , {-1, } }, + { (1<<6), (1<<6), 6, "Configure Flag" , {-1, } }, + { (1<<5), (1<<5), 5, "Software Debug" , {-1, } }, + { (1<<4), (1<<4), 4, "Force Global Resume" , {-1, } }, + { (1<<3), (1<<3), 3, "Enter Global Suspend Mode" , {-1, } }, + { (1<<2), (1<<2), 2, "Global Reset" , {-1, } }, + { (1<<1), (1<<1), 1, "Host Controller Reset" , {-1, } }, + { (1<<0), (1<<0), 0, "Run/Stop" , {-1, } }, + { 0, (DWORD) -1, -1, "\0" , {-1, } } +}; + +struct S_ATTRIBUTES attribs_u_status[] = { + // | 31 chars + null | <- max + { (1<<5), (1<<5), 5, "HCHalted" , {-1, } }, + { (1<<4), (1<<4), 4, "Host Controller Process Error" , {-1, } }, + { (1<<3), (1<<3), 3, "Host System Error" , {-1, } }, + { (1<<2), (1<<2), 2, "Resume Detect" , {-1, } }, + { (1<<1), (1<<1), 1, "USB Error Interrupt" , {-1, } }, + { (1<<0), (1<<0), 0, "USB Interrupt" , {-1, } }, + { 0, (DWORD) -1, -1, "\0" , {-1, } } +}; + +struct S_ATTRIBUTES attribs_u_interrupt[] = { + // | 31 chars + null | <- max + { (1<<3), (1<<3), 3, "Short packet Interrupt Enable" , {-1, } }, + { (1<<2), (1<<2), 2, "Interrupt On Complete (IOC)" , {-1, } }, + { (1<<1), (1<<1), 1, "Resume Interrupt Enable" , {-1, } }, + { (1<<0), (1<<0), 0, "Timeout/CRC Interrupt Enable" , {-1, } }, + { 0, (DWORD) -1, -1, "\0" , {-1, } } +}; + +struct S_ATTRIBUTES attribs_u_ports[] = { + // | 31 chars + null | <- max + { (1<<15), (1<<15), 15, "Zero (bit 15)" , {-1, } }, + { (1<<14), (1<<14), 14, "Zero (bit 14)" , {-1, } }, + { (1<<13), (1<<13), 13, "Zero (bit 13)" , {-1, } }, + { (1<<12), (1<<12), 12, "Suspend" , {-1, } }, + { (1<<11), (1<<11), 11, "Over-current Changed" , {-1, } }, + { (1<<10), (1<<10), 10, "Over-current Status" , {-1, } }, + { (1<< 9), (1<< 9), 9, "Port Reset" , {-1, } }, + { (1<< 8), (1<< 8), 8, "Low Speed Device Attached" , {-1, } }, + { (1<< 7), (1<< 7), 7, "Reserved (must be 1)" , {-1, } }, + { (1<< 6), (1<< 6), 6, "Resume Detect" , {-1, } }, + { (1<< 5), (1<< 5), 5, "Line Status: D-" , {-1, } }, + { (1<< 4), (1<< 4), 4, "Line Status: D+" , {-1, } }, + { (1<< 3), (1<< 3), 3, "Port Enable/Disable Change" , {-1, } }, + { (1<< 2), (1<< 2), 2, "Port Enabled/Disabled" , {-1, } }, + { (1<< 1), (1<< 1), 1, "Current Status Change" , {-1, } }, + { (1<< 0), (1<< 0), 0, "Current Connect Status" , {-1, } }, + { 0, (DWORD) -1, -1, "\0" , {-1, } } +}; + +BOOL u_changed[IDC_U_EN_END - IDC_U_EN_START + 1]; + +// lParam: type is in low 8 bits, break_type in high 8-bits of low word +INT_PTR CALLBACK hc_uhci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + int ret; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "Bochs for Windows -- USB Debug: UHCI Host Controller"); + SetWindowText(hDlg, str); + + // call the initializer + TreeView = GetDlgItem(hDlg, IDC_STACK); + SNDMSG(TreeView, WM_SETFONT, (WPARAM) hTreeViewFont, FALSE); + ret = hc_uhci_init(hDlg); + if (ret < 0) { + MessageBox(hDlg, "Error initializing dialog", NULL, MB_ICONINFORMATION); + } + + memset(u_changed, 0, sizeof(u_changed)); + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); + + if (ret >= 0) { + SetFocus(GetDlgItem(hDlg, ret)); + return FALSE; + } else + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case ID_CONTINUE_EMU: + if (TreeView) + TreeView_DeleteAllItems(TreeView); + TreeView = NULL; + SIM->get_param_bool(BXPN_USB_DEBUG_RESET)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_RESET) == BST_CHECKED) ? true : false); + SIM->get_param_bool(BXPN_USB_DEBUG_ENABLE)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_ENABLE) == BST_CHECKED) ? true : false); + SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_DOORBELL) == BST_CHECKED) ? true : false); + SIM->get_param_bool(BXPN_USB_DEBUG_EVENT)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_EVENT) == BST_CHECKED) ? true : false); + SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_SOF) == BST_CHECKED) ? BX_USB_DEBUG_SOF_SET : BX_USB_DEBUG_SOF_NONE); + SIM->get_param_bool(BXPN_USB_DEBUG_NON_EXIST)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_NONEXIST) == BST_CHECKED) ? true : false); + EndDialog(hDlg, 1); + break; + case ID_QUIT_EMU: + if (TreeView) + TreeView_DeleteAllItems(TreeView); + TreeView = NULL; + EndDialog(hDlg, -1); // -1 to quit the SIM + break; + case ID_APPLY: + hc_uhci_save(hDlg); + break; + case IDC_U_REG_COMMAND_B: + do_attributes(hDlg, IDC_U_REG_COMMAND, 4, "Command Register", attribs_u_command); + break; + case IDC_U_REG_STATUS_B: + do_attributes(hDlg, IDC_U_REG_STATUS, 4, "Status Register", attribs_u_status); + break; + case IDC_U_REG_INTERRUPT_B: + do_attributes(hDlg, IDC_U_REG_INTERRUPT, 4, "Interrupt Register", attribs_u_interrupt); + break; + case IDC_U_REG_PORT0_B: + do_attributes(hDlg, IDC_U_REG_PORT0, 4, "Port0 Register", attribs_u_ports); + break; + case IDC_U_REG_PORT1_B: + do_attributes(hDlg, IDC_U_REG_PORT1, 4, "Port1 Register", attribs_u_ports); + break; + case IDC_VIEW_TD: + uhci_display_td(hDlg); + break; + } + break; + // one of the edit controls changed + case EN_CHANGE: + if ((LOWORD(wParam) >= IDC_U_EN_START) && (LOWORD(wParam) <= IDC_U_EN_END)) { + u_changed[LOWORD(wParam) - IDC_U_EN_START] = TRUE; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), TRUE); + } + break; + } + } + + return 0; +} + +#include "iodev/usb/uhci_core.h" +#include "iodev/usb/usb_uhci.h" + +extern bx_usb_uhci_c *theUSB_UHCI; + +// returns -1 if error, else returns ID to control to set the focus to +int hc_uhci_init(HWND hwnd) +{ + char str[COMMON_STR_SIZE]; + Bit32u frame_addr, frame_num; + int ret = IDOK; + + if (theUSB_UHCI == NULL) + return -1; + + // set the dialog title to the break type + switch (g_params.break_type) { + case USB_DEBUG_FRAME: + SetWindowText(hwnd, "UHCI Debug Dialog: Break Type: Start of Frame"); + break; + case USB_DEBUG_COMMAND: + SetWindowText(hwnd, "UHCI Debug Dialog: Break Type: Doorbell"); + break; + //case USB_DEBUG_EVENT: + // SetWindowText(hwnd, "UHCI Debug Dialog: Break Type: Event Ring"); + // break; + case USB_DEBUG_NONEXIST: + SetWindowText(hwnd, "UHCI Debug Dialog: Break Type: Non-existant Port Write"); + break; + case USB_DEBUG_RESET: + sprintf(str, "UHCI Debug Dialog: Break Type: Port %d Reset", g_params.wParam); + SetWindowText(hwnd, str); + break; + case USB_DEBUG_ENABLE: + sprintf(str, "UHCI Debug Dialog: Break Type: Port %d Enable", g_params.wParam); + SetWindowText(hwnd, str); + break; + } + + //bool sof = (SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->get() > 0); + CheckDlgButton(hwnd, IDC_DEBUG_RESET, SIM->get_param_bool(BXPN_USB_DEBUG_RESET)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_ENABLE, SIM->get_param_bool(BXPN_USB_DEBUG_ENABLE)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_DOORBELL, SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_EVENT, SIM->get_param_bool(BXPN_USB_DEBUG_EVENT)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_SOF, (SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->get() > BX_USB_DEBUG_SOF_NONE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_NONEXIST, SIM->get_param_bool(BXPN_USB_DEBUG_NON_EXIST)->get() ? BST_CHECKED : BST_UNCHECKED); + + pci_bar_address = theUSB_UHCI->get_bar_addr(4); + sprintf(str, "0x%04X", pci_bar_address); + SetDlgItemText(hwnd, IDC_PORT_ADDR, str); + + sprintf(str, "0x%04X", theUSB_UHCI->read(pci_bar_address + 0, 2)); + SetDlgItemText(hwnd, IDC_U_REG_COMMAND, str); + sprintf(str, "0x%04X", theUSB_UHCI->read(pci_bar_address + 2, 2)); + SetDlgItemText(hwnd, IDC_U_REG_STATUS, str); + sprintf(str, "0x%04X", theUSB_UHCI->read(pci_bar_address + 4, 2)); + SetDlgItemText(hwnd, IDC_U_REG_INTERRUPT, str); + sprintf(str, "0x%04X", frame_num = theUSB_UHCI->read(pci_bar_address + 6, 2)); + SetDlgItemText(hwnd, IDC_U_REG_FRAME_NUM, str); + sprintf(str, "0x%08X", frame_addr = theUSB_UHCI->read(pci_bar_address + 8, 4)); + SetDlgItemText(hwnd, IDC_U_REG_FRAME_ADDRESS, str); + sprintf(str, "0x%02X", theUSB_UHCI->read(pci_bar_address + 12, 1)); + SetDlgItemText(hwnd, IDC_U_REG_SOF, str); + + sprintf(str, "0x%04X", theUSB_UHCI->read(pci_bar_address + 16, 2)); + SetDlgItemText(hwnd, IDC_U_REG_PORT0, str); + sprintf(str, "0x%04X", theUSB_UHCI->read(pci_bar_address + 18, 2)); + SetDlgItemText(hwnd, IDC_U_REG_PORT1, str); + + // display the port types + SIM->get_param_enum("port1.device", host_param)->dump_param(str, COMMON_STR_SIZE, 1); + SetDlgItemText(hwnd, IDC_U_REG_PORT0_TYPE, str); + SIM->get_param_enum("port2.device", host_param)->dump_param(str, COMMON_STR_SIZE, 1); + SetDlgItemText(hwnd, IDC_U_REG_PORT1_TYPE, str); + + frame_addr += (frame_num * sizeof(Bit32u)); + sprintf(str, "0x%08X", frame_addr); + SetDlgItemText(hwnd, IDC_FRAME_ADDRESS, str); + + tree_items = 0; + TreeView_DeleteAllItems(TreeView); + + bool valid = 0; + switch (g_params.break_type) { + // The DoTransfer() function was called + case USB_DEBUG_COMMAND: + // The start of a frame timer was triggered + case USB_DEBUG_FRAME: + SetDlgItemText(hwnd, IDC_RING_TYPE, "SOF Frame Address:"); + if (frame_addr != 0x00000000) { + hc_uhci_do_item(frame_addr, frame_num); + EnableWindow(GetDlgItem(hwnd, IDC_VIEW_TD), TRUE); + ret = IDC_STACK; // set the focus to the TreeView + valid = 1; + } + break; + + // an event triggered. We ignore these in the uhci + //case USB_DEBUG_EVENT: + // break; + + // first byte (word, dword, qword) of first non-existant port was written to + case USB_DEBUG_NONEXIST: + // port reset (non-root reset) + case USB_DEBUG_RESET: + // enable changed + case USB_DEBUG_ENABLE: + SetDlgItemText(hwnd, IDC_RING_TYPE, "None"); + SetDlgItemText(hwnd, IDC_FRAME_ADDRESS, "None"); + EnableWindow(GetDlgItem(hwnd, IDC_VIEW_TD), FALSE); + break; + } + + if (!valid) { + TreeView_SetBkColor(TreeView, COLORREF(0x00A9A9A9)); + SetDlgItemText(hwnd, IDC_TREE_COMMENT, "This trigger does not populate the TreeView"); + } else + SetDlgItemText(hwnd, IDC_TREE_COMMENT, "TreeView populated"); + + return ret; +} + +int hc_uhci_save(HWND hwnd) +{ + char str[COMMON_STR_SIZE]; + + if (u_changed[IDC_U_REG_COMMAND - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_COMMAND, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 0, strtol(str, NULL, 0), 2); + } + if (u_changed[IDC_U_REG_STATUS - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_STATUS, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 2, strtol(str, NULL, 0), 2); + } + if (u_changed[IDC_U_REG_INTERRUPT - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_INTERRUPT, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 4, strtol(str, NULL, 0), 2); + } + if (u_changed[IDC_U_REG_FRAME_NUM - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_FRAME_NUM, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 6, strtol(str, NULL, 0), 2); + } + if (u_changed[IDC_U_REG_FRAME_ADDRESS - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_FRAME_ADDRESS, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 8, strtol(str, NULL, 0), 4); + } + if (u_changed[IDC_U_REG_SOF - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_SOF, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 12, strtol(str, NULL, 0), 1); + } + + if (u_changed[IDC_U_REG_PORT0 - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_PORT0, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 16, strtol(str, NULL, 0), 2); + } + if (u_changed[IDC_U_REG_PORT1 - IDC_U_EN_START]) { + GetDlgItemText(hwnd, IDC_U_REG_PORT1, str, COMMON_STR_SIZE); + theUSB_UHCI->write(pci_bar_address + 18, strtol(str, NULL, 0), 2); + } + + memset(u_changed, 0, sizeof(u_changed)); + EnableWindow(GetDlgItem(hwnd, ID_APPLY), 0); + + return 0; +} + +static bool uhci_add_queue(struct USB_UHCI_QUEUE_STACK *stack, const Bit32u addr) +{ + // check to see if this queue has been processed before + for (int i=0; iqueue_cnt; i++) { + if (stack->queue_stack[i] == addr) + return TRUE; + } + + // if the stack is full, we return TRUE anyway + if (stack->queue_cnt == USB_UHCI_QUEUE_STACK_SIZE) + return TRUE; + + // add the queue's address + stack->queue_stack[stack->queue_cnt] = addr; + stack->queue_cnt++; + + return FALSE; +} + +void hc_uhci_do_item(Bit32u FrameAddr, Bit32u FrameNum) +{ + struct USB_UHCI_QUEUE_STACK queue_stack; + Bit32u item, queue_addr = 0; + struct QUEUE queue; + struct TD td; + char str[COMMON_STR_SIZE]; + HTREEITEM hCur, Next; + Bit32u state; + + // get the frame pointer + DEV_MEM_READ_PHYSICAL(FrameAddr, sizeof(Bit32u), (Bit8u *) &item); + sprintf(str, "Frame Pointer(%i): 0x%08X", FrameNum, item); + Next = TreeViewInsert(TreeView, TVI_ROOT, TVI_FIRST, str, 0, 0); + + queue_stack.queue_cnt = 0; + + // A catch to make sure we don't do too many + while (tree_items < 50) { + if (!USB_UHCI_IS_LINK_VALID(item)) // the the T bit is set, we are done + break; + + // is it a queue? + if (USB_UHCI_IS_LINK_QUEUE(item)) { + // add it to our current list of queues + if (uhci_add_queue(&queue_stack, item & ~0xF)) { + // if this queue has been added before, stop. + break; + } + + // read in the queue + DEV_MEM_READ_PHYSICAL(item & ~0xF, sizeof(struct QUEUE), (Bit8u *) &queue); + sprintf(str, "0x%08X: Queue Head: (0x%08X 0x%08X)", item & ~0xF, queue.horz, queue.vert); + Next = TreeViewInsert(TreeView, Next, TVI_LAST, str, (LPARAM) ((item & ~0xF) | 1), 0); + + // if the vert pointer is valid, there are td's in it to process + // else only the head pointer may be valid + if (!USB_UHCI_IS_LINK_VALID(queue.vert)) { + // no vertical elements to process + // (clear queue_addr to indicate we are not processing + // elements of the vertical part of a queue) + queue_addr = 0; + item = queue.horz; + } else { + // there are vertical elements to process + // (save the address of the horz pointer in queue_addr + // so that we may update the queue's vertical pointer + // member with the successfully processed TD's link pointer) + queue_addr = item; + item = queue.vert; + } + continue; + } + + // we processed another td within this queue line + state = 0; // clear the state + DEV_MEM_READ_PHYSICAL(item & ~0xF, sizeof(struct TD), (Bit8u *) &td); + const bool depthbreadth = (td.dword0 & 0x0004) ? true : false; // 1 = depth first, 0 = breadth first + sprintf(str, "0x%08X: TD: (0x%08X)", item & ~0xF, td.dword0); + if ((item & ~0xF) == (Bit32u) g_params.wParam) + state |= TVIS_BOLD; + hCur = TreeViewInsert(TreeView, Next, TVI_LAST, str, (LPARAM) ((item & ~0xF) | 0), state); + if ((item & ~0xF) == (Bit32u) g_params.wParam) + TreeView_Select(TreeView, hCur, TVGN_CARET); + item = td.dword0; + if (queue_addr != 0) { + // if breadth first or last in the element list, move on to next queue item + if (!depthbreadth || !USB_UHCI_IS_LINK_VALID(item)) { + item = queue.horz; + queue_addr = 0; + } + } + } +} + +static struct TD g_td; +static struct QUEUE g_queue; +void uhci_display_td(HWND hwnd) { + TVITEM tvitem; + INT_PTR ret = -1; + Bit32u address = 0; + + HTREEITEM item = TreeView_GetSelection(TreeView); + if (item != NULL) { + tvitem.mask = TVIF_PARAM | TVIF_HANDLE; + tvitem.hItem = item; + TreeView_GetItem(TreeView, &tvitem); + if (tvitem.lParam > 0) { + address = tvitem.lParam & ~0xF; + if (tvitem.lParam & 1) { + // is a queue head + DEV_MEM_READ_PHYSICAL(address, sizeof(struct QUEUE), (Bit8u *) &g_queue); + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_UHCI_DLG_QUEUE), hwnd, hc_uhci_callback_queue, 0); + } else { + // is a TD + DEV_MEM_READ_PHYSICAL(address, sizeof(struct TD), (Bit8u *) &g_td); + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_UHCI_DLG_TD), hwnd, hc_uhci_callback_td, 0); + } + if (ret == 1) { + if (tvitem.lParam & 1) { + // write back the queue + DEV_MEM_WRITE_PHYSICAL(address, sizeof(struct QUEUE), (Bit8u *) &g_queue); + } else { + // write back the td + DEV_MEM_WRITE_PHYSICAL(address, sizeof(struct TD), (Bit8u *) &g_td); + } + } + } else + MessageBox(hwnd, "Item selected has no TD attached.", NULL, MB_ICONINFORMATION); + + } else + MessageBox(hwnd, "No TD selected", NULL, MB_ICONINFORMATION); +} + +INT_PTR CALLBACK hc_uhci_callback_queue(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x%08X", g_queue.horz & ~0xF); + SetDlgItemText(hDlg, IDC_HORZ_PTR, str); + + CheckDlgButton(hDlg, IDC_HORZ_Q, (g_queue.horz & 2) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_HORZ_T, (g_queue.horz & 1) ? BST_CHECKED : BST_UNCHECKED); + + sprintf(str, "0x%08X", g_queue.vert & ~0xF); + SetDlgItemText(hDlg, IDC_VERT_PTR, str); + + CheckDlgButton(hDlg, IDC_VERT_Q, (g_queue.vert & 2) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_VERT_T, (g_queue.vert & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_HORZ_PTR, str, COMMON_STR_SIZE); + g_queue.horz = strtol(str, NULL, 0); + + g_queue.horz |= (IsDlgButtonChecked(hDlg, IDC_HORZ_Q) == BST_CHECKED) ? 2 : 0; + g_queue.horz |= (IsDlgButtonChecked(hDlg, IDC_HORZ_T) == BST_CHECKED) ? 1 : 0; + + GetDlgItemText(hDlg, IDC_VERT_PTR, str, COMMON_STR_SIZE); + g_queue.vert = strtol(str, NULL, 0); + + g_queue.vert |= (IsDlgButtonChecked(hDlg, IDC_VERT_Q) == BST_CHECKED) ? 2 : 0; + g_queue.vert |= (IsDlgButtonChecked(hDlg, IDC_VERT_T) == BST_CHECKED) ? 1 : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +INT_PTR CALLBACK hc_uhci_callback_td(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + if (g_params.lParam & USB_LPARAM_FLAG_BEFORE) { + sprintf(str, "Transfer Descriptor: *Before*"); + SetWindowText(hDlg, str); + } else if (g_params.lParam & USB_LPARAM_FLAG_AFTER) { + sprintf(str, "Transfer Descriptor: *After*"); + SetWindowText(hDlg, str); + EnableWindow(GetDlgItem(hDlg, IDC_STATUS_ACTIVE), TRUE); + } // else just "Transfer Descriptor" + + sprintf(str, "0x%08X", g_td.dword0 & ~0xF); + SetDlgItemText(hDlg, IDC_LINK_PTR, str); + + CheckDlgButton(hDlg, IDC_VERT_VF, (g_td.dword0 & 4) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_VERT_Q, (g_td.dword0 & 2) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_VERT_T, (g_td.dword0 & 1) ? BST_CHECKED : BST_UNCHECKED); + + sprintf(str, "%i", g_td.dword1 & 0x3FF); + SetDlgItemText(hDlg, IDC_ACTUAL_LEN, str); + + CheckDlgButton(hDlg, IDC_STATUS_ACTIVE, (g_td.dword1 & (1<<23)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_STALLED, (g_td.dword1 & (1<<22)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_DATA_BUFF_ERR, (g_td.dword1 & (1<<21)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_BABBLE, (g_td.dword1 & (1<<20)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_NAK, (g_td.dword1 & (1<<19)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_CRC, (g_td.dword1 & (1<<18)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_BITSTUFF, (g_td.dword1 & (1<<17)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_RSVD, (g_td.dword1 & (1<<16)) ? BST_CHECKED : BST_UNCHECKED); + + CheckDlgButton(hDlg, IDC_STATUS_IOC, (g_td.dword1 & (1<<24)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_ISO, (g_td.dword1 & (1<<25)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_LS, (g_td.dword1 & (1<<26)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_STATUS_SPD, (g_td.dword1 & (1<<29)) ? BST_CHECKED : BST_UNCHECKED); + + sprintf(str, "%i", (g_td.dword1 >> 27) & 0x3); + SetDlgItemText(hDlg, IDC_STATUS_CERR, str); + + CheckDlgButton(hDlg, IDC_DEVICE_TOGGLE, (g_td.dword2 & (1<<19)) ? BST_CHECKED : BST_UNCHECKED); + + ComboBox_AddString(GetDlgItem(hDlg, IDC_COMBO_PID), "IN (0x69)"); + ComboBox_AddString(GetDlgItem(hDlg, IDC_COMBO_PID), "OUT (0xE1)"); + ComboBox_AddString(GetDlgItem(hDlg, IDC_COMBO_PID), "SETUP (0x2D)"); + ComboBox_AddString(GetDlgItem(hDlg, IDC_COMBO_PID), "ERROR"); + if ((g_td.dword2 & 0xFF) == 0x69) + ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_COMBO_PID), 0); + else if ((g_td.dword2 & 0xFF) == 0xE1) + ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_COMBO_PID), 1); + else if ((g_td.dword2 & 0xFF) == 0x2D) + ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_COMBO_PID), 2); + else + ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_COMBO_PID), 3); + + sprintf(str, "%i", (g_td.dword2 >> 8) & 0x7F); + SetDlgItemText(hDlg, IDC_DEVICE_ADDR, str); + sprintf(str, "%i", (g_td.dword2 >> 15) & 0x0F); + SetDlgItemText(hDlg, IDC_DEVICE_EP, str); + sprintf(str, "%i", (g_td.dword2 >> 21) & 0x7FF); + SetDlgItemText(hDlg, IDC_DEVICE_MAXLEN, str); + + sprintf(str, "0x%08X", g_td.dword3); + SetDlgItemText(hDlg, IDC_DEVICE_BUFFER, str); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDC_DUMP_BUFFER: + GetDlgItemText(hDlg, IDC_DEVICE_BUFFER, str, COMMON_STR_SIZE); + g_dump_parms.address = strtol(str, NULL, 0); + if (g_params.lParam & USB_LPARAM_FLAG_AFTER) + GetDlgItemText(hDlg, IDC_ACTUAL_LEN, str, COMMON_STR_SIZE); + else + GetDlgItemText(hDlg, IDC_DEVICE_MAXLEN, str, COMMON_STR_SIZE); + g_dump_parms.size = (strtol(str, NULL, 0) + 1) & 0x7FF; + strcpy(g_dump_parms.title, "UHCI: Transfer Descriptor Buffer"); + g_dump_parms.big = 0; + DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_DLG_DUMP), hDlg, dump_dialog_callback, 0); + break; + case IDC_LINK_VF: + if (IsDlgButtonChecked(hDlg, IDC_LINK_VF) == BST_CHECKED) + SetDlgItemText(hDlg, IDC_LINK_VF, "(Depth First) Vf:"); + else + SetDlgItemText(hDlg, IDC_LINK_VF, "(Breadth First) Vf:"); + break; + case IDOK: + GetDlgItemText(hDlg, IDC_LINK_PTR, str, COMMON_STR_SIZE); + g_td.dword0 = strtol(str, NULL, 0); + g_td.dword0 |= (IsDlgButtonChecked(hDlg, IDC_LINK_VF) == BST_CHECKED) ? 4 : 0; + g_td.dword0 |= (IsDlgButtonChecked(hDlg, IDC_LINK_Q) == BST_CHECKED) ? 2 : 0; + g_td.dword0 |= (IsDlgButtonChecked(hDlg, IDC_LINK_T) == BST_CHECKED) ? 1 : 0; + + GetDlgItemText(hDlg, IDC_ACTUAL_LEN, str, COMMON_STR_SIZE); + g_td.dword1 = strtol(str, NULL, 0) & 0x3FF; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_ACTIVE) == BST_CHECKED) ? (1<<23) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_STALLED) == BST_CHECKED) ? (1<<22) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_DATA_BUFF_ERR) == BST_CHECKED) ? (1<<21) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_BABBLE) == BST_CHECKED) ? (1<<20) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_NAK) == BST_CHECKED) ? (1<<19) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_CRC) == BST_CHECKED) ? (1<<18) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_BITSTUFF) == BST_CHECKED) ? (1<<17) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_RSVD) == BST_CHECKED) ? (1<<16) : 0; + + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_IOC) == BST_CHECKED) ? (1<<24) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_ISO) == BST_CHECKED) ? (1<<25) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_LS) == BST_CHECKED) ? (1<<26) : 0; + g_td.dword1 |= (IsDlgButtonChecked(hDlg, IDC_STATUS_SPD) == BST_CHECKED) ? (1<<29) : 0; + + GetDlgItemText(hDlg, IDC_STATUS_CERR, str, COMMON_STR_SIZE); + g_td.dword1 |= (strtol(str, NULL, 0) & 0x3) << 27; + + g_td.dword2 = (IsDlgButtonChecked(hDlg, IDC_DEVICE_TOGGLE) == BST_CHECKED) ? (1<<19) : 0; + switch (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_COMBO_PID))) { + case 0: + g_td.dword2 |= 0x69; + break; + case 1: + g_td.dword2 |= 0xE1; + break; + case 2: + g_td.dword2 |= 0x2D; + break; + default: + g_td.dword2 |= 0x00; + } + + GetDlgItemText(hDlg, IDC_DEVICE_ADDR, str, COMMON_STR_SIZE); + g_td.dword2 |= (strtol(str, NULL, 0) & 0x7F) << 8; + GetDlgItemText(hDlg, IDC_DEVICE_EP, str, COMMON_STR_SIZE); + g_td.dword2 |= (strtol(str, NULL, 0) & 0x0F) << 15; + GetDlgItemText(hDlg, IDC_DEVICE_MAXLEN, str, COMMON_STR_SIZE); + g_td.dword2 |= (strtol(str, NULL, 0) & 0x7FF) << 21; + + GetDlgItemText(hDlg, IDC_DEVICE_BUFFER, str, COMMON_STR_SIZE); + g_td.dword3 = strtol(str, NULL, 0); + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// OHCI +// + +// lParam: type is in low 8 bits, break_type in high 8-bits of low word +INT_PTR CALLBACK hc_ohci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + + return 0; +} + +int hc_ohci_init(HWND hwnd) { + + return 0; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// EHCI +// + +// lParam: type is in low 8 bits, break_type in high 8-bits of low word +INT_PTR CALLBACK hc_ehci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + + return 0; +} + +int hc_ehci_init(HWND hwnd) +{ + + return 0; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// XHCI +// + +struct S_ATTRIBUTES attribs_x_ports[] = { + // | 31 chars + null | <- max + { (1ULL<<31), (1ULL<<31), 31, "Warm Port Reset" , {-1, } }, + { (1<<30), (1<<30), 30, "Device Removable" , {-1, } }, + { (1<<29), (1<<29), 29, "Reserved (bit 29)" , {-1, } }, + { (1<<28), (1<<28), 28, "Reserved (bit 28)" , {-1, } }, + { (1<<27), (1<<27), 27, "Wake on Over-current Enable" , {-1, } }, + { (1<<26), (1<<26), 26, "Wake on Disconnect Enable" , {-1, } }, + { (1<<25), (1<<25), 25, "Wake on Connect Enable" , {-1, } }, + { (1<<24), (1<<24), 24, "Cold Attach Status" , {-1, } }, + { (1<<23), (1<<23), 23, "Port Config Error Change" , {-1, } }, + { (1<<22), (1<<22), 22, "Port Link State Change" , {-1, } }, + { (1<<21), (1<<21), 21, "Port Reset Change" , {-1, } }, + { (1<<20), (1<<20), 20, "Over-current Change" , {-1, } }, + { (1<<19), (1<<19), 19, "Warm Port Reset Change" , {-1, } }, + { (1<<18), (1<<18), 18, "Port Enable/Disable Change" , {-1, } }, + { (1<<17), (1<<17), 17, "Connect Status Change" , {-1, } }, + { (1<<16), (1<<16), 16, "Port Link State Write Strobe" , {-1, } }, + { (1<<15), (1<<15), 15, "Port Indicator (bit 1)" , {-1, } }, + { (1<<14), (1<<14), 14, "Port Indicator (bit 0)" , {-1, } }, + { (1<<13), (1<<13), 13, "Port Speed (bit 3)" , {-1, } }, + { (1<<12), (1<<12), 12, "Port Speed (bit 2)" , {-1, } }, + { (1<<11), (1<<11), 11, "Port Speed (bit 1)" , {-1, } }, + { (1<<10), (1<<10), 10, "Port Speed (bit 0)" , {-1, } }, + { (1<< 9), (1<< 9), 9, "Port Power" , {-1, } }, + { (1<< 8), (1<< 8), 8, "Port Link State (bit 3)" , {-1, } }, + { (1<< 7), (1<< 7), 7, "Port Link State (bit 2)" , {-1, } }, + { (1<< 6), (1<< 6), 6, "Port Link State (bit 1)" , {-1, } }, + { (1<< 5), (1<< 5), 5, "Port Link State (bit 0)" , {-1, } }, + { (1<< 4), (1<< 4), 4, "Port Reset" , {-1, } }, + { (1<< 3), (1<< 3), 3, "Over-current Status" , {-1, } }, + { (1<< 2), (1<< 2), 2, "Reserved" , {-1, } }, + { (1<< 1), (1<< 1), 1, "Port Enabled/Disabled" , {-1, } }, + { (1<< 0), (1<< 0), 0, "Current Connect Status" , {-1, } }, + { 0, (DWORD) -1, -1, "\0" , {-1, } } +}; + +static bool x_changed[IDC_X_EN_END - IDC_X_EN_START + 1]; + +// lParam: type is in low 8 bits, break_type in high 8-bits of low word +INT_PTR CALLBACK hc_xhci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + int ret; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "Bochs for Windows -- USB Debug: xHCI Host Controller"); + SetWindowText(hDlg, str); + + // call the initializer + TreeView = GetDlgItem(hDlg, IDC_STACK); + SNDMSG(TreeView, WM_SETFONT, (WPARAM) hTreeViewFont, FALSE); + ret = hc_xhci_init(hDlg); + if (ret < 0) { + MessageBox(hDlg, "Error initializing dialog", NULL, MB_ICONINFORMATION); + } + + memset(x_changed, 0, sizeof(x_changed)); + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); + + if (ret >= 0) { + SetFocus(GetDlgItem(hDlg, ret)); + return FALSE; + } else + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case ID_CONTINUE_EMU: + if (TreeView) + TreeView_DeleteAllItems(TreeView); + TreeView = NULL; + SIM->get_param_bool(BXPN_USB_DEBUG_RESET)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_RESET) == BST_CHECKED) ? true : false); + SIM->get_param_bool(BXPN_USB_DEBUG_ENABLE)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_ENABLE) == BST_CHECKED) ? true : false); + SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_DOORBELL) == BST_CHECKED) ? true : false); + SIM->get_param_bool(BXPN_USB_DEBUG_EVENT)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_EVENT) == BST_CHECKED) ? true : false); + SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_SOF) == BST_CHECKED) ? BX_USB_DEBUG_SOF_SET : BX_USB_DEBUG_SOF_NONE); + SIM->get_param_bool(BXPN_USB_DEBUG_NON_EXIST)->set((IsDlgButtonChecked(hDlg, IDC_DEBUG_NONEXIST) == BST_CHECKED) ? true : false); + EndDialog(hDlg, 1); + break; + case ID_QUIT_EMU: + if (TreeView) + TreeView_DeleteAllItems(TreeView); + TreeView = NULL; + EndDialog(hDlg, -1); // -1 to quit the SIM + break; + case ID_APPLY: + hc_xhci_save(hDlg); + break; + case IDC_X_REG_PORT0_B: + do_attributes(hDlg, IDC_X_REG_PORT0, 8, "Port0 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT1_B: + do_attributes(hDlg, IDC_X_REG_PORT1, 8, "Port1 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT2_B: + do_attributes(hDlg, IDC_X_REG_PORT2, 8, "Port2 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT3_B: + do_attributes(hDlg, IDC_X_REG_PORT3, 8, "Port3 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT4_B: + do_attributes(hDlg, IDC_X_REG_PORT4, 8, "Port4 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT5_B: + do_attributes(hDlg, IDC_X_REG_PORT5, 8, "Port5 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT6_B: + do_attributes(hDlg, IDC_X_REG_PORT6, 8, "Port6 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT7_B: + do_attributes(hDlg, IDC_X_REG_PORT7, 8, "Port7 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT8_B: + do_attributes(hDlg, IDC_X_REG_PORT8, 8, "Port8 Register", attribs_x_ports); + break; + case IDC_X_REG_PORT9_B: + do_attributes(hDlg, IDC_X_REG_PORT9, 8, "Port9 Register", attribs_x_ports); + break; + case IDC_VIEW_TRB: + switch (g_params.break_type) { + case USB_DEBUG_COMMAND: + xhci_display_trb(hDlg, VIEW_TRB_TYPE_COMMAND); + break; + case USB_DEBUG_EVENT: + xhci_display_trb(hDlg, VIEW_TRB_TYPE_EVENT); + break; + case USB_DEBUG_FRAME: + xhci_display_trb(hDlg, VIEW_TRB_TYPE_TRANSFER); + break; + } + break; + } + break; + // one of the edit controls changed + case EN_CHANGE: + if ((LOWORD(wParam) >= IDC_X_EN_START) && (LOWORD(wParam) <= IDC_X_EN_END)) { + u_changed[LOWORD(wParam) - IDC_X_EN_START] = 1; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 1); + } + break; + } + /* + * https://social.msdn.microsoft.com/Forums/en-US/60402c1d-d7a6-4406-9b83-67fa74c24104/select-an-item-in-a-treeview-with-a-right-click?forum=vcmfcatl + case WM_NOTIFY: + switch (((LPNMHDR) lParam)->code) { + case NM_RCLICK: + MessageBox(hDlg, "Right Click", NULL, MB_ICONINFORMATION); + break; + } + break; + */ + } + + return 0; +} + +#include "iodev/usb/usb_xhci.h" + +extern bx_usb_xhci_c *theUSB_XHCI; + +static Bit32u xhci_read_dword(const Bit32u address) +{ + Bit32u value; + + theUSB_XHCI->read_handler(address, 4, &value, NULL); + return value; +} + +// returns -1 if error, else returns ID to control to set the focus to +int hc_xhci_init(HWND hwnd) +{ + char str[COMMON_STR_SIZE]; + char str1[COMMON_STR_SIZE]; + Bit64u RingPtr = 0, qword; + Bit32u dword, offset; + unsigned i; + int ret = IDOK; + + if (theUSB_XHCI == NULL) + return -1; + + // set the dialog title to the break type + switch (g_params.break_type) { + case USB_DEBUG_COMMAND: + SetWindowText(hwnd, "xHCI Debug Dialog: Break Type: Command Ring"); + break; + case USB_DEBUG_EVENT: + SetWindowText(hwnd, "xHCI Debug Dialog: Break Type: Event Ring"); + break; + case USB_DEBUG_FRAME: + SetWindowText(hwnd, "xHCI Debug Dialog: Break Type: Frame"); + break; + } + + CheckDlgButton(hwnd, IDC_DEBUG_RESET, SIM->get_param_bool(BXPN_USB_DEBUG_RESET)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_ENABLE, SIM->get_param_bool(BXPN_USB_DEBUG_ENABLE)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_DOORBELL, SIM->get_param_bool(BXPN_USB_DEBUG_DOORBELL)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_EVENT, SIM->get_param_bool(BXPN_USB_DEBUG_EVENT)->get() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_SOF, (SIM->get_param_num(BXPN_USB_DEBUG_START_FRAME)->get() > BX_USB_DEBUG_SOF_NONE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_DEBUG_NONEXIST, SIM->get_param_bool(BXPN_USB_DEBUG_NON_EXIST)->get() ? BST_CHECKED : BST_UNCHECKED); + + pci_bar_address = theUSB_XHCI->get_bar_addr(0); + sprintf(str, "0x%08X", pci_bar_address); + SetDlgItemText(hwnd, IDC_PORT_ADDR, str); + + for (i=0; i<8; i++) { + dword = xhci_read_dword(pci_bar_address + (i * 4)); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_CAPLENGTH + i, str); + } + offset = xhci_read_dword(pci_bar_address + 0) & 0xFF; + + dword = xhci_read_dword(pci_bar_address + offset + 0x00); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_COMMAND, str); + dword = xhci_read_dword(pci_bar_address + offset + 0x04); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_STATUS, str); + dword = xhci_read_dword(pci_bar_address + offset + 0x08); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_PAGESIZE, str); + dword = xhci_read_dword(pci_bar_address + offset + 0x14); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_DEVICE_NOTE, str); + sprintf(str, "0x" FMT_ADDRX64, theUSB_XHCI->hub.op_regs.HcCrcr.actual); // we can't read this using read_handler() since the handler will return zero + SetDlgItemText(hwnd, IDC_X_REG_COMMAND_RING, str); + qword = xhci_read_dword(pci_bar_address + offset + 0x30) | + ((Bit64u) xhci_read_dword(pci_bar_address + offset + 0x34) << 32); + sprintf(str, "0x" FMT_ADDRX64, qword); + SetDlgItemText(hwnd, IDC_X_REG_DEV_CONTEXT_BASE, str); + dword = xhci_read_dword(pci_bar_address + offset + 0x38); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_CONFIGURE, str); + + offset = xhci_read_dword(pci_bar_address + 0x18); + dword = xhci_read_dword(pci_bar_address + offset + 0); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_MFINDEX, str); + + // show up to 10 port register sets + for (i=0; ihub.n_ports; i++) { + dword = xhci_read_dword(pci_bar_address + XHCI_PORT_SET_OFFSET + (i * 16)); + sprintf(str, "0x%08X", dword); + SetDlgItemText(hwnd, IDC_X_REG_PORT0 + i, str); + sprintf(str1, "port%d.device", i + 1); + SIM->get_param_enum(str1, host_param)->dump_param(str, COMMON_STR_SIZE, 1); + SetDlgItemText(hwnd, IDC_X_REG_PORT0_TYPE + i, str); + } + for (; ihub.op_regs.HcCrcr.crc; + sprintf(str, "0x" FMT_ADDRX64, RingPtr); + SetDlgItemText(hwnd, IDC_FRAME_ADDRESS, str); + if (RingPtr != 0) { + hc_xhci_do_ring("Command", RingPtr, theUSB_XHCI->hub.ring_members.command_ring.dq_pointer); + EnableWindow(GetDlgItem(hwnd, IDC_VIEW_TRB), 1); + valid = 1; + } + break; + + // an event TRB was placed on an event ring + case USB_DEBUG_EVENT: + SetDlgItemText(hwnd, IDC_RING_TYPE, "Event Ring:"); + sprintf(str, "Interrupter %i", (int) g_params.wParam); + SetDlgItemText(hwnd, IDC_FRAME_ADDRESS, str); + hc_xhci_do_event_ring("Event", (int) g_params.wParam); + EnableWindow(GetDlgItem(hwnd, IDC_VIEW_TRB), 1); + valid = 1; + break; + + case USB_DEBUG_FRAME: + + SetDlgItemText(hwnd, IDC_RING_TYPE, "SOF Ring Address:"); + + break; + + // first byte (word, dword, qword) of first non-existant port was written to + case USB_DEBUG_NONEXIST: + SetDlgItemText(hwnd, IDC_RING_TYPE, "None"); + SetDlgItemText(hwnd, IDC_FRAME_ADDRESS, "None"); + EnableWindow(GetDlgItem(hwnd, IDC_VIEW_TRB), 0); + valid = 0; + break; + + // port reset (non-root reset) + case USB_DEBUG_RESET: + SetDlgItemText(hwnd, IDC_RING_TYPE, "None"); + SetDlgItemText(hwnd, IDC_FRAME_ADDRESS, "None"); + EnableWindow(GetDlgItem(hwnd, IDC_VIEW_TRB), 0); + valid = 0; + break; + + // enable changed + case USB_DEBUG_ENABLE: + SetDlgItemText(hwnd, IDC_RING_TYPE, "None"); + SetDlgItemText(hwnd, IDC_FRAME_ADDRESS, "None"); + EnableWindow(GetDlgItem(hwnd, IDC_VIEW_TRB), 0); + valid = 0; + break; + } + + if (!valid) { + TreeView_SetBkColor(TreeView, COLORREF(0x00A9A9A9)); + SetDlgItemText(hwnd, IDC_TREE_COMMENT, "This trigger does not populate the TreeView"); + } else + SetDlgItemText(hwnd, IDC_TREE_COMMENT, "TreeView populated"); + + return ret; +} + +int hc_xhci_save(HWND hwnd) +{ + + MessageBox(hwnd, "xHCI: Save to controller is not yet implemented!", NULL, MB_ICONINFORMATION); + + return 0; +} + +static const struct VIEW_TRB_TYPE trb_types[] = { + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 0 + { VIEW_TRB_TYPE_TRANSFER, "Normal" }, // 1 + { VIEW_TRB_TYPE_TRANSFER, "Setup" }, // 2 + { VIEW_TRB_TYPE_TRANSFER, "Data" }, // 3 + { VIEW_TRB_TYPE_TRANSFER, "Status" }, // 4 + { VIEW_TRB_TYPE_TRANSFER, "ISO" }, // 5 + { VIEW_TRB_TYPE_TRANSFER | // 6 + VIEW_TRB_TYPE_COMMAND, "LINK" }, + { VIEW_TRB_TYPE_TRANSFER, "Event Data" }, // 7 + { VIEW_TRB_TYPE_TRANSFER, "No-Op Transfer" }, // 8 + { VIEW_TRB_TYPE_COMMAND, "Enable Slot" }, // 9 + { VIEW_TRB_TYPE_COMMAND, "Disable Slot" }, // 10 + { VIEW_TRB_TYPE_COMMAND, "Address Dev" }, // 11 + { VIEW_TRB_TYPE_COMMAND, "Config EP" }, // 12 + { VIEW_TRB_TYPE_COMMAND, "Eval Context" }, // 13 + { VIEW_TRB_TYPE_COMMAND, "Reset EP" }, // 14 + { VIEW_TRB_TYPE_COMMAND, "Stop EP" }, // 15 + { VIEW_TRB_TYPE_COMMAND, "Set TR Deque" }, // 16 + { VIEW_TRB_TYPE_COMMAND, "Reset Device" }, // 17 + { VIEW_TRB_TYPE_COMMAND, "Force Event" }, // 18 + { VIEW_TRB_TYPE_COMMAND, "Negotiate Bandwidth" }, // 19 + { VIEW_TRB_TYPE_COMMAND, "Set Latency Tolerance" }, // 20 + { VIEW_TRB_TYPE_COMMAND, "Get Port Bandwidth" }, // 21 + { VIEW_TRB_TYPE_COMMAND, "Force Header" }, // 22 + { VIEW_TRB_TYPE_COMMAND, "No-Op Command" }, // 23 + { VIEW_TRB_TYPE_COMMAND, "Get Extended Property" }, // 24 + { VIEW_TRB_TYPE_COMMAND, "Set Extended Property" }, // 25 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 26 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 27 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 28 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 29 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 30 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 31 + { VIEW_TRB_TYPE_EVENT, "Transfer Event" }, // 32 + { VIEW_TRB_TYPE_EVENT, "Command Completion" }, // 33 + { VIEW_TRB_TYPE_EVENT, "Port Status Change" }, // 34 + { VIEW_TRB_TYPE_EVENT, "Bandwidth Request" }, // 35 + { VIEW_TRB_TYPE_EVENT, "Doorbell Event" }, // 36 + { VIEW_TRB_TYPE_EVENT, "Host Controller Event" }, // 37 + { VIEW_TRB_TYPE_EVENT, "Device Notification" }, // 38 + { VIEW_TRB_TYPE_EVENT, "MFINDEX Wrap Event" }, // 39 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 40 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 41 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 42 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 43 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 44 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 45 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 46 + { VIEW_TRB_TYPE_NONE, "Reserved" }, // 47 + // remaining are vendor defined (allowed in any ring) +}; + +// these match the VIEW_TRB_TYPE_ masks +static const char *ring_type[] = { + "", // VIEW_TRB_TYPE_NONE + "Command", // VIEW_TRB_TYPE_COMMAND + "Event", // VIEW_TRB_TYPE_EVENT + "", // + "Transfer" // VIEW_TRB_TYPE_TRANSFER +}; + +void hc_xhci_do_ring(const char *ring_str, Bit64u RingPtr, Bit64u dequeue_ptr) +{ + char str[COMMON_STR_SIZE]; + int trb_count = 0; // count of TRB's processed + Bit64u address = RingPtr; + struct TRB trb; + HTREEITEM Parent; + Bit32u state = 0; + Bit8u type; + + sprintf(str, "%s Ring: 0x" FMT_ADDRX64, ring_str, address); + Parent = TreeViewInsert(TreeView, TVI_ROOT, TVI_FIRST, str, 0, 0); + + do { + state = 0; // clear the state + DEV_MEM_READ_PHYSICAL(address, sizeof(struct TRB), (Bit8u *) &trb); + type = TRB_GET_TYPE(trb.command); + if (type <= 47) + sprintf(str, "0x" FMT_ADDRX64 " %08X 0x%08X (%i) (%s)", trb.parameter, trb.status, trb.command, trb.command & 1, trb_types[type].name); + else + sprintf(str, "0x" FMT_ADDRX64 " %08X 0x%08X (%i) (Vendor Specific)", trb.parameter, trb.status, trb.command, trb.command & 1); + if (address == dequeue_ptr) { + strcat(str, " <--- dq_pointer"); + state |= TVIS_BOLD; + } + TreeViewInsert(TreeView, Parent, TVI_LAST, str, (LPARAM) address, state); + if (type == LINK) { + address = trb.parameter & (Bit64u) ~0xF; + } else + address += sizeof(struct TRB); + + if (++trb_count > MAX_TRBS_ALLOWED) // safety catch + break; + } while (address != RingPtr); +} + +void hc_xhci_do_event_ring(const char *ring_str, int interrupter) +{ + char str[COMMON_STR_SIZE]; + int trb_count = 0; // count of TRB's processed + Bit64u address; + struct TRB trb; + HTREEITEM Parent, Segment; + Bit32u state = 0; + Bit8u type; + + sprintf(str, "%s Ring: Interrupter: %i", ring_str, interrupter); + Parent = TreeViewInsert(TreeView, TVI_ROOT, TVI_FIRST, str, 0, 0); + + for (unsigned i=0; i<(1<hub.ring_members.event_rings[interrupter].entrys[i].addr; + sprintf(str, "Event Ring Segment %i (0x" FMT_ADDRX64 "), size %i", i, address, theUSB_XHCI->hub.ring_members.event_rings[interrupter].entrys[i].size); + Segment = TreeViewInsert(TreeView, Parent, TVI_LAST, str, 0, 0); + for (unsigned j=0; jhub.ring_members.event_rings[interrupter].entrys[i].size; j++) { + state = 0; // clear the state + DEV_MEM_READ_PHYSICAL(address, sizeof(struct TRB), (Bit8u *) &trb); + type = TRB_GET_TYPE(trb.command); + if (type <= 47) + sprintf(str, "0x" FMT_ADDRX64 " %08X 0x%08X (%i) (%s)", trb.parameter, trb.status, trb.command, trb.command & 1, trb_types[type].name); + else + sprintf(str, "0x" FMT_ADDRX64 " %08X 0x%08X (%i) (Vendor Specific)", trb.parameter, trb.status, trb.command, trb.command & 1); + if (address == theUSB_XHCI->hub.ring_members.event_rings[interrupter].cur_trb) { + strcat(str, " <--- eq_pointer"); + state |= TVIS_BOLD; + } + TreeViewInsert(TreeView, Segment, TVI_LAST, str, (LPARAM) address, state); + + if (++trb_count > MAX_TRBS_ALLOWED) // safety catch + break; + + address += sizeof(struct TRB); + } + if (trb_count > MAX_TRBS_ALLOWED) // safety catch + break; + } +} + +static struct TRB g_trb; +void xhci_display_trb(HWND hwnd, int type_mask) { + char str[COMMON_STR_SIZE]; + TVITEM tvitem; + INT_PTR ret = -1; + + HTREEITEM item = TreeView_GetSelection(TreeView); + if (item != NULL) { + tvitem.mask = TVIF_PARAM | TVIF_HANDLE; + tvitem.hItem = item; + TreeView_GetItem(TreeView, &tvitem); + if (tvitem.lParam > 0) { + DEV_MEM_READ_PHYSICAL(tvitem.lParam, sizeof(struct TRB), (Bit8u *) &g_trb); + const Bit8u type = TRB_GET_TYPE(g_trb.command); + + // check to see if this type of TRB is allowed in this type of ring + if ((type > 0) && (type <= 47) && ((trb_types[type].allowed_mask & type_mask) == 0)) { + sprintf(str, "TRB type %i not allowed in a %s ring!", type, ring_type[type_mask]); + MessageBox(hwnd, str, NULL, MB_ICONINFORMATION); + } + + // using the type of trb, display an associated dialog + switch (type) { + case NORMAL: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_NORM_TRB), hwnd, hc_xhci_callback_trb_normal, 0); + break; + case SETUP_STAGE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_SETUP_TRB), hwnd, hc_xhci_callback_trb_setup, 0); + break; + case DATA_STAGE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_DATA_TRB), hwnd, hc_xhci_callback_trb_data, 0); + break; + case STATUS_STAGE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_STATUS_TRB), hwnd, hc_xhci_callback_trb_status, 0); + break; + case LINK: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_LINK_TRB), hwnd, hc_xhci_callback_trb_link, 0); + break; + case EVENT_DATA: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_EVENT_TRB), hwnd, hc_xhci_callback_trb_event, 0); + break; + case NO_OP: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_NOOP_TRB), hwnd, hc_xhci_callback_trb_noop, 0); + break; + case ENABLE_SLOT: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_ENSLOT_TRB), hwnd, hc_xhci_callback_trb_enslot, 0); + break; + case DISABLE_SLOT: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_DISSLOT_TRB), hwnd, hc_xhci_callback_trb_disslot, 0); + break; + case ADDRESS_DEVICE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_ADDRESS_TRB), hwnd, hc_xhci_callback_trb_address, 0); + break; + case CONFIG_EP: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_CONFIGEP_TRB), hwnd, hc_xhci_callback_trb_configep, 0); + break; + case EVALUATE_CONTEXT: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_EVALUATE_TRB), hwnd, hc_xhci_callback_trb_evaluate, 0); + break; + case RESET_EP: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_RESETEP_TRB), hwnd, hc_xhci_callback_trb_resetep, 0); + break; + case STOP_EP: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_STOPEP_TRB), hwnd, hc_xhci_callback_trb_stopep, 0); + break; + case SET_TR_DEQUEUE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_SETTRPTR_TRB), hwnd, hc_xhci_callback_trb_settrptr, 0); + break; + case RESET_DEVICE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_RESETDEV_TRB), hwnd, hc_xhci_callback_trb_resetdev, 0); + break; + case FORCE_EVENT: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_FORCE_TRB), hwnd, hc_xhci_callback_trb_forceevent, 0); + break; + case DEG_BANDWIDTH: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_DISSLOT_TRB), hwnd, hc_xhci_callback_trb_disslot, 0); + break; + case SET_LAT_TOLERANCE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_SETLAT_TRB), hwnd, hc_xhci_callback_trb_setlat, 0); + break; + case GET_PORT_BAND: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_GETBAND_TRB), hwnd, hc_xhci_callback_trb_getband, 0); + break; + case FORCE_HEADER: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_FORCEHDR_TRB), hwnd, hc_xhci_callback_trb_forcehdr, 0); + break; + case NO_OP_CMD: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_RESETDEV_TRB), hwnd, hc_xhci_callback_trb_resetdev, 0); + break; + case TRANS_EVENT: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_TRANSEVENT_TRB), hwnd, hc_xhci_callback_trb_transevent, 0); + break; + case COMMAND_COMPLETION: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_CMNDCOMP_TRB), hwnd, hc_xhci_callback_trb_compcompletion, 0); + break; + case PORT_STATUS_CHANGE: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_PSCHANGE_TRB), hwnd, hc_xhci_callback_trb_pschange, 0); + break; + case BANDWIDTH_REQUEST: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_BANDREQU_TRB), hwnd, hc_xhci_callback_trb_bandrequ, 0); + break; + case DOORBELL_EVENT: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_DOORBELL_TRB), hwnd, hc_xhci_callback_trb_doorbell, 0); + break; + case HOST_CONTROLLER_EVENT: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_HOSTEVENT_TRB), hwnd, hc_xhci_callback_trb_hostevent, 0); + break; + case DEVICE_NOTIFICATION: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_DEVNOTEVENT_TRB), hwnd, hc_xhci_callback_trb_devnotevent, 0); + break; + case MFINDEX_WRAP: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_HOSTEVENT_TRB), hwnd, hc_xhci_callback_trb_hostevent, 0); + break; + case NEC_TRB_TYPE_CMD_COMP: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_NECFWEVENT_TRB), hwnd, hc_xhci_callback_trb_necfwevent, 0); + break; + case NEC_TRB_TYPE_GET_FW: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_NECFW_TRB), hwnd, hc_xhci_callback_trb_necfw, 0); + break; + case NEC_TRB_TYPE_GET_UN: + ret = DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_NECUN_TRB), hwnd, hc_xhci_callback_trb_necun, 0); + break; + case BX_TRB_TYPE_DUMP: + break; + default: + sprintf(str, "Unsupported or Reserved TRB type %i found!", type); + MessageBox(hwnd, str, NULL, MB_ICONINFORMATION); + } + + if (ret == 1) { + // make sure the type is still correct + g_trb.command &= ~(0x3F << 10); + g_trb.command |= TRB_SET_TYPE(type); + // write back the trb + DEV_MEM_WRITE_PHYSICAL(tvitem.lParam, sizeof(struct TRB), (Bit8u *) &g_trb); + } + } else + MessageBox(hwnd, "Item selected has no TRB attached.", NULL, MB_ICONINFORMATION); + + } else + MessageBox(hwnd, "No TRB selected", NULL, MB_ICONINFORMATION); +} + + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_normal(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + sprintf(str, "%i", TRB_GET_TX_LEN(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_TD_SIZE, str); + sprintf(str, "%i", TRB_GET_TX_LEN(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_TRANS_LEN, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_BEI, TRB_DC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_IDT, TRB_IS_IMMED_DATA(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_IOC, TRB_IOC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_CH, TRB_CHAIN(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_NS, (g_trb.command & 8) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_ISP, TRB_SPD(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_ENT, TRB_TOGGLE(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + GetDlgItemText(hDlg, IDC_TRB_TD_SIZE, str, COMMON_STR_SIZE); + g_trb.status |= TRB_SET_TDSIZE(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_TRANS_LEN, str, COMMON_STR_SIZE); + g_trb.status |= strtol(str, NULL, 0) & 0x1FFFF; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_BEI) == BST_CHECKED) ? (1<<9) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IDT) == BST_CHECKED) ? (1<<6) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IOC) == BST_CHECKED) ? (1<<5) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_CH) == BST_CHECKED) ? (1<<4) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_NS) == BST_CHECKED) ? (1<<3) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ISP) == BST_CHECKED) ? (1<<2) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ENT) == BST_CHECKED) ? (1<<1) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_setup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x%04X", (Bit16u) ((g_trb.parameter & BX_CONST64(0x00000000000000FF)) >> 0)); + SetDlgItemText(hDlg, IDC_TRB_BREQUESTTYPE, str); + sprintf(str, "0x%04X", (Bit16u) ((g_trb.parameter & BX_CONST64(0x000000000000FF00)) >> 8)); + SetDlgItemText(hDlg, IDC_TRB_BREQUEST, str); + sprintf(str, "0x%04X", (Bit16u) ((g_trb.parameter & BX_CONST64(0x00000000FFFF0000)) >> 16)); + SetDlgItemText(hDlg, IDC_TRB_WVALUE, str); + sprintf(str, "0x%04X", (Bit16u) ((g_trb.parameter & BX_CONST64(0x0000FFFF00000000)) >> 32)); + SetDlgItemText(hDlg, IDC_TRB_WINDEX, str); + sprintf(str, "0x%04X", (Bit16u) ((g_trb.parameter & BX_CONST64(0xFFFF000000000000)) >> 48)); + SetDlgItemText(hDlg, IDC_TRB_WLENGTH, str); + + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + sprintf(str, "%i", TRB_GET_TX_LEN(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_TRANS_LEN, str); + + sprintf(str, "%i", (g_trb.command & 0x00030000) >> 16); + SetDlgItemText(hDlg, IDC_TRB_TRT, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_IDT, TRB_IS_IMMED_DATA(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_IOC, TRB_IOC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_BREQUESTTYPE, str, COMMON_STR_SIZE); + g_trb.parameter = (((Bit64u) strtol(str, NULL, 0) << 0) & BX_CONST64(0x00000000000000FF)); + GetDlgItemText(hDlg, IDC_TRB_BREQUEST, str, COMMON_STR_SIZE); + g_trb.parameter |= (((Bit64u) strtol(str, NULL, 0) << 8) & BX_CONST64(0x000000000000FF00)); + GetDlgItemText(hDlg, IDC_TRB_WVALUE, str, COMMON_STR_SIZE); + g_trb.parameter |= (((Bit64u) strtol(str, NULL, 0) << 16) & BX_CONST64(0x00000000FFFF0000)); + GetDlgItemText(hDlg, IDC_TRB_WINDEX, str, COMMON_STR_SIZE); + g_trb.parameter |= (((Bit64u) strtol(str, NULL, 0) << 32) & BX_CONST64(0x0000FFFF00000000)); + GetDlgItemText(hDlg, IDC_TRB_WLENGTH, str, COMMON_STR_SIZE); + g_trb.parameter |= (((Bit64u) strtol(str, NULL, 0) << 48) & BX_CONST64(0xFFFF000000000000)); + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + GetDlgItemText(hDlg, IDC_TRB_TRANS_LEN, str, COMMON_STR_SIZE); + g_trb.status |= strtol(str, NULL, 0) & 0x1FFFF; + + GetDlgItemText(hDlg, IDC_TRB_TRT, str, COMMON_STR_SIZE); + g_trb.command = (strtol(str, NULL, 0) << 16) & 0x00030000; + + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IDT) == BST_CHECKED) ? (1<<6) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IOC) == BST_CHECKED) ? (1<<5) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_data(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + sprintf(str, "%i", TRB_GET_TX_LEN(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_TD_SIZE, str); + sprintf(str, "%i", TRB_GET_TX_LEN(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_TRANS_LEN, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_DIR, (g_trb.command & 0x10000) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_IDT, TRB_IS_IMMED_DATA(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_IOC, TRB_IOC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_CH, TRB_CHAIN(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_NS, (g_trb.command & 8) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_ISP, TRB_SPD(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_ENT, TRB_TOGGLE(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + GetDlgItemText(hDlg, IDC_TRB_TD_SIZE, str, COMMON_STR_SIZE); + g_trb.status |= TRB_SET_TDSIZE(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_TRANS_LEN, str, COMMON_STR_SIZE); + g_trb.status |= strtol(str, NULL, 0) & 0x1FFFF; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_DIR) == BST_CHECKED) ? (1<<16) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IDT) == BST_CHECKED) ? (1<<6) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IOC) == BST_CHECKED) ? (1<<5) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_CH) == BST_CHECKED) ? (1<<4) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_NS) == BST_CHECKED) ? (1<<3) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ISP) == BST_CHECKED) ? (1<<2) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ENT) == BST_CHECKED) ? (1<<1) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_status(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_DIR, (g_trb.command & 0x10000) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_IOC, TRB_IOC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_CH, TRB_CHAIN(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_ENT, TRB_TOGGLE(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_DIR) == BST_CHECKED) ? (1<<16) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IOC) == BST_CHECKED) ? (1<<5) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_CH) == BST_CHECKED) ? (1<<4) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ENT) == BST_CHECKED) ? (1<<1) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_link(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x0F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_IOC, TRB_IOC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_CH, TRB_CHAIN(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_TC, TRB_GET_TOGGLE(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_IOC) == BST_CHECKED) ? (1<<5) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_CH) == BST_CHECKED) ? (1<<4) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_TC) == BST_CHECKED) ? (1<<1) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_event(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_BEI, TRB_DC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_IOC, TRB_IOC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_CH, TRB_CHAIN(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_ENT, TRB_TOGGLE(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_BEI) == BST_CHECKED) ? (1<<9) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_IOC) == BST_CHECKED) ? (1<<5) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_CH) == BST_CHECKED) ? (1<<4) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ENT) == BST_CHECKED) ? (1<<1) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_noop(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_IOC, TRB_IOC(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_CH, TRB_CHAIN(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_ENT, TRB_TOGGLE(g_trb.command) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_IOC) == BST_CHECKED) ? (1<<5) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_CH) == BST_CHECKED) ? (1<<4) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ENT) == BST_CHECKED) ? (1<<1) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_enslot(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_STYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_TYPE, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_TYPE, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_STYPE(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_disslot(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + // if this is the Negotiate Bandwidth Command, we need to change the title + if (TRB_GET_TYPE(g_trb.command) == DEG_BANDWIDTH) + SetWindowText(hDlg, "Negotiate Bandwidth TRB"); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_address(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + Bit64u address; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x0F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_BSR, (g_trb.command & (1<<9)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDC_IN_CONTEXT: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + address = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_CONTEXT), hDlg, hc_xhci_callback_context, (LPARAM) address); + break; + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_BSR) == BST_CHECKED) ? (1<<9) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_configep(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + Bit64u address; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x0F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_DECONFIG, (g_trb.command & (1<<9)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDC_IN_CONTEXT: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + address = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_CONTEXT), hDlg, hc_xhci_callback_context, (LPARAM) address); + break; + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_DECONFIG) == BST_CHECKED) ? (1<<9) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_evaluate(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + Bit64u address; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x0F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_BSR, (g_trb.command & (1<<9)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDC_IN_CONTEXT: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + address = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_CONTEXT), hDlg, hc_xhci_callback_context, (LPARAM) address); + break; + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + //g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_BSR) == BST_CHECKED) ? (1<<9) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_resetep(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_EP(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_EP_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_TSP, (g_trb.command & (1<<9)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_EP_ID, str, COMMON_STR_SIZE); + g_trb.command |= TRB_SET_EP(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_TSP) == BST_CHECKED) ? (1<<9) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_stopep(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_EP(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_EP_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_SP, (g_trb.command & (1<<23)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_EP_ID, str, COMMON_STR_SIZE); + g_trb.command |= TRB_SET_EP(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_SP) == BST_CHECKED) ? (1<<23) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_settrptr(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x0F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_STREAM(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_STREAMID, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_EP(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_EP_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + + GetDlgItemText(hDlg, IDC_TRB_STREAMID, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0xFFFF) << 16; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_EP_ID, str, COMMON_STR_SIZE); + g_trb.command |= TRB_SET_EP(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_resetdev(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + // if this is the NoOp Command, we need to change the title + if (TRB_GET_TYPE(g_trb.command) == NO_OP_CMD) + SetWindowText(hDlg, "No Op Command TRB"); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_forceevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x0F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_TARGET(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str); + + sprintf(str, "%i", (g_trb.command & (0xFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_TRB_VF_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + + GetDlgItemText(hDlg, IDC_TRB_INT_TARGET, str, COMMON_STR_SIZE); + g_trb.status = (strtol(str, NULL, 0) & 0x3FF) << 22; + + GetDlgItemText(hDlg, IDC_TRB_VF_ID, str, COMMON_STR_SIZE); + g_trb.command = (strtol(str, NULL, 0) & 0xFF) << 16; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_setlat(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", (g_trb.command & (0xFFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_TRB_BELT, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_BELT, str, COMMON_STR_SIZE); + g_trb.command = (strtol(str, NULL, 0) & 0xFFF) << 16; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_getband(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x0F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", (g_trb.command & (0x0F << 16)) >> 16); + SetDlgItemText(hDlg, IDC_TRB_DEV_SPEED, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + + g_trb.status = 0; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_DEV_SPEED, str, COMMON_STR_SIZE); + g_trb.command |= (strtol(str, NULL, 0) & 0x0F) << 16; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_forcehdr(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & ~BX_CONST64(0x1F)); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "0x%08X", g_trb.status); + SetDlgItemText(hDlg, IDC_TRB_HDR_HI, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & ~BX_CONST64(0x1F); + + GetDlgItemText(hDlg, IDC_TRB_HDR_HI, str, COMMON_STR_SIZE); + g_trb.status = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_transevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_EP(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_EP_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_ED, (g_trb.command & 4) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_EP_ID, str, COMMON_STR_SIZE); + g_trb.command |= TRB_SET_EP(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_ED) == BST_CHECKED) ? (1<<2) : 0; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_compcompletion(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + sprintf(str, "%i", g_trb.status & 0x00FFFFFF); + SetDlgItemText(hDlg, IDC_TRB_COMP_LPARAM, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", (g_trb.command & (0xFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_TRB_VF_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_COMP_LPARAM, str, COMMON_STR_SIZE); + g_trb.status |= strtol(str, NULL, 0) & 0x00FFFFFF; + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_VF_ID, str, COMMON_STR_SIZE); + g_trb.command |= (strtol(str, NULL, 0) & 0xFF) << 16; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_pschange(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, (g_trb.parameter & BX_CONST64(0x00000000FF000000)) >> 24); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = (Bit64u) (strtol(str, NULL, 0) & 0xFF) << 24; + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_bandrequ(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_doorbell(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter & 0x1F); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", (g_trb.command & (0xFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_TRB_VF_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0) & 0x1F; + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_VF_ID, str, COMMON_STR_SIZE); + g_trb.command |= (strtol(str, NULL, 0) & 0xFF) << 16; + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_hostevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + // if this is the MFINDEX Wrap Event, we need to change the title + if (TRB_GET_TYPE(g_trb.command) == MFINDEX_WRAP) + SetWindowText(hDlg, "MFINDEX Wrap Event TRB"); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + g_trb.parameter = 0; + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_devnotevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter >> 8); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + sprintf(str, "%i", (Bit8u) (g_trb.parameter & 0xF0) >> 4); + SetDlgItemText(hDlg, IDC_TRB_NOT_TYPE, str); + + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = (Bit64u) strtol(str, NULL, 0) << 8; + GetDlgItemText(hDlg, IDC_TRB_NOT_TYPE, str, COMMON_STR_SIZE); + g_trb.parameter |= (strtol(str, NULL, 0) & 0xF) << 4; + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command = TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_necfw(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + + g_trb.parameter = 0; + g_trb.status = 0; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_necun(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0); + + g_trb.status = 0; + + g_trb.command = (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +// lParam = address to the TRB +INT_PTR CALLBACK hc_xhci_callback_trb_necfwevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + sprintf(str, "0x" FMT_ADDRX64, g_trb.parameter); + SetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str); + + sprintf(str, "%i", TRB_GET_COMP_CODE(g_trb.status)); + SetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str); + sprintf(str, "0x%04X", g_trb.status & 0x0000FFFF); + SetDlgItemText(hDlg, IDC_TRB_COMP_LPARAM, str); + + sprintf(str, "0x%04X", (g_trb.command & 0xFFFF0000) >> 16); + SetDlgItemText(hDlg, IDC_TRB_COMP_HPARAM, str); + sprintf(str, "%i", TRB_GET_SLOT(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str); + sprintf(str, "%i", TRB_GET_TYPE(g_trb.command)); + SetDlgItemText(hDlg, IDC_TRB_TYPE, str); + + CheckDlgButton(hDlg, IDC_TRB_C, (g_trb.command & 1) ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hDlg, IDOK)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText(hDlg, IDC_TRB_DATA_PTR, str, COMMON_STR_SIZE); + g_trb.parameter = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_TRB_COMP_CODE, str, COMMON_STR_SIZE); + g_trb.status = TRB_SET_COMP_CODE(strtol(str, NULL, 0)); + GetDlgItemText(hDlg, IDC_TRB_COMP_LPARAM, str, COMMON_STR_SIZE); + g_trb.status |= strtol(str, NULL, 0) & 0x0000FFFF; + + GetDlgItemText(hDlg, IDC_TRB_COMP_HPARAM, str, COMMON_STR_SIZE); + g_trb.command = (strtol(str, NULL, 0) & 0x0000FFFF) << 16; + GetDlgItemText(hDlg, IDC_TRB_SLOT_ID, str, COMMON_STR_SIZE); + g_trb.command |= TRB_SET_SLOT(strtol(str, NULL, 0)); + g_trb.command |= (IsDlgButtonChecked(hDlg, IDC_TRB_C) == BST_CHECKED) ? (1<<0) : 0; + + EndDialog(hDlg, 1); + break; + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + break; + } + } + + return 0; +} + +static Bit64u xhci_context_address = 0; +static Bit8u *xhci_context = NULL; +static int xhci_current_ep_context = 1; // 0 through 30 (slot, control_ep, ep1_out, ep1_in, ep2_out, ep2_in, etc) +static bool xhci_context_changed = 0; + +static Bit64u xhci_str_context_address = 0; +static Bit8u *xhci_str_context = NULL; +static int xhci_str_current_context = 0; +static bool xhci_str_context_changed = 0; +static int xhci_max_streams = 0; + +static const char *slot_speed_str[] = { + "Undefined", + "Full", + "Low", + "High", + "Super Gen1x1", + "Super Gen2x1", + "Super Gen1x2", + "Super Gen2x2", + "Undefined", + "Undefined", + "Undefined", + "Undefined", + "Undefined", + "Undefined", + "Undefined", + "Undefined", + "Not Valid" +}; + +static const char *slot_type_str[] = { + "Disabled/Enabled", + "Default", + "Addressed", + "Configured", + "Reserved" +}; + +static const char *ep_type_str[] = { + "n/a", + "ISO Out", + "Bulk Out", + "Int Out", + "Control", + "ISO In", + "Bulk In", + "Int In", + "Not Valid" +}; + +static const char *ep_state_str[] = { + "Disabled", + "Running", + "Halted", + "Stopped", + "Error", + "Reserved", + "Reserved", + "Reserved", + "Not Valid" +}; + +static const char *string_sct_str[] = { + "Secondary / Transfer Ring / N/A", + "Primary / Transfer Ring / N/A", + "Primary / SSA / 8", + "Primary / SSA / 16", + "Primary / SSA / 32", + "Primary / SSA / 64", + "Primary / SSA / 128", + "Primary / SSA / 256", + "Error" +}; + +// xHCI 1.2: 6.2.5.1, Page 461 +static void hc_xhci_callback_context_ep_get(HWND hDlg) +{ + char str[COMMON_STR_SIZE]; + Bit32u *p; + int i; + + // display the EP (with Drop and Add bits) + p = (Bit32u *) &xhci_context[0]; + if (xhci_current_ep_context == 1) { + strcpy(str, "Control EP "); + } else { + sprintf(str, "EP%i %s ", (xhci_current_ep_context >> 1), (xhci_current_ep_context & 1) ? "IN" : "OUT"); + } + if (p[0] & (1 << xhci_current_ep_context)) + strcat(str, "(D)"); + if (p[1] & (1 << xhci_current_ep_context)) + strcat(str, "(A)"); + SetDlgItemText(hDlg, IDC_CONTEXT_OF_STR, str); + + // EP Context + p = (Bit32u *) &xhci_context[CONTEXT_SIZE + (xhci_current_ep_context * CONTEXT_SIZE)]; + sprintf(str, "%i", (p[0] & (0xFF << 24)) >> 24); + SetDlgItemText(hDlg, IDC_CONTEXT_MAX_ESIT_HI, str); + sprintf(str, "%i", (p[0] & (0xFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_CONTEXT_INTERVAL, str); + CheckDlgButton(hDlg, IDC_CONTEXT_LSA, (p[0] & (1<<15)) ? BST_CHECKED : BST_UNCHECKED); + sprintf(str, "%i", (p[0] & (0x1F << 10)) >> 10); + SetDlgItemText(hDlg, IDC_CONTEXT_MAX_PSTREAMS, str); + sprintf(str, "%i", (p[0] & (0x3 << 8)) >> 8); + SetDlgItemText(hDlg, IDC_CONTEXT_MULT, str); + sprintf(str, "%i", (p[0] & (0x7 << 0)) >> 0); + SetDlgItemText(hDlg, IDC_CONTEXT_EP_STATE, str); + sprintf(str, "%i", (p[1] & (0xFFFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_CONTEXT_MAX_PACKET_SIZE, str); + sprintf(str, "%i", (p[1] & (0xFF << 8)) >> 8); + SetDlgItemText(hDlg, IDC_CONTEXT_MAX_BURST_SIZE, str); + CheckDlgButton(hDlg, IDC_CONTEXT_HID, (p[1] & (1<<7)) ? BST_CHECKED : BST_UNCHECKED); + sprintf(str, "%i", (p[1] & (0x7 << 3)) >> 3); + SetDlgItemText(hDlg, IDC_CONTEXT_EP_TYPE, str); + sprintf(str, "%i", (p[1] & (0x3 << 1)) >> 1); + SetDlgItemText(hDlg, IDC_CONTEXT_CERR, str); + sprintf(str, "0x" FMT_ADDRX64, ((Bit64u) p[3] << 32) | (p[2] & ~BX_CONST64(0xF))); + SetDlgItemText(hDlg, IDC_CONTEXT_TR_DEQUEUE_PTR, str); + CheckDlgButton(hDlg, IDC_CONTEXT_DCS, (p[2] & (1<<0)) ? BST_CHECKED : BST_UNCHECKED); + sprintf(str, "%i", (p[4] & (0xFFFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_CONTEXT_MAX_ESIT_LO, str); + sprintf(str, "%i", (p[4] & (0xFFFF << 0)) >> 0); + SetDlgItemText(hDlg, IDC_CONTEXT_AVERAGE_LEN, str); + + EnableWindow(GetDlgItem(hDlg, IDC_CONTEXT_STREAM_CONTEXT), (((p[0] & (0x1F << 10)) >> 10) > 0)); + + for (i=0; i<3; i++) { + sprintf(str, "0x%08X", p[5+i]); + SetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_EP_0 + i, str); + } +#if (CONTEXT_SIZE == 64) + for (i=3; i<11; i++) { + sprintf(str, "0x%08X", p[5+i]); + SetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_EP_0 + i, str); + EnableWindow(GetDlgItem(hDlg, IDC_CONTEXT_RSVDO_EP_0 + i), 1); + } +#endif + + xhci_context_changed = 0; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); +} + +static void hc_xhci_callback_context_ep_put(HWND hDlg) +{ + char str[COMMON_STR_SIZE]; + Bit32u *p; + int i; + + // EP Context + p = (Bit32u *) &xhci_context[CONTEXT_SIZE + (xhci_current_ep_context * CONTEXT_SIZE)]; + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_ESIT_HI, str, COMMON_STR_SIZE); + p[0] = (strtol(str, NULL, 0) & 0xFF) << 24; + GetDlgItemText(hDlg, IDC_CONTEXT_INTERVAL, str, COMMON_STR_SIZE); + p[0] |= (strtol(str, NULL, 0) & 0xFF) << 16; + p[0] |= (IsDlgButtonChecked(hDlg, IDC_CONTEXT_LSA) == BST_CHECKED) ? (1<<15) : 0; + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_PSTREAMS, str, COMMON_STR_SIZE); + p[0] |= (strtol(str, NULL, 0) & 0x1F) << 10; + GetDlgItemText(hDlg, IDC_CONTEXT_MULT, str, COMMON_STR_SIZE); + p[0] |= (strtol(str, NULL, 0) & 0x3) << 8; + GetDlgItemText(hDlg, IDC_CONTEXT_EP_STATE, str, COMMON_STR_SIZE); + p[0] |= (strtol(str, NULL, 0) & 0x7) << 0; + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_PACKET_SIZE, str, COMMON_STR_SIZE); + p[1] = (strtol(str, NULL, 0) & 0xFFFF) << 16; + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_BURST_SIZE, str, COMMON_STR_SIZE); + p[1] |= (strtol(str, NULL, 0) & 0xFF) << 8; + p[1] |= (IsDlgButtonChecked(hDlg, IDC_CONTEXT_HID) == BST_CHECKED) ? (1<<7) : 0; + GetDlgItemText(hDlg, IDC_CONTEXT_EP_TYPE, str, COMMON_STR_SIZE); + p[1] |= (strtol(str, NULL, 0) & 0x7) << 3; + GetDlgItemText(hDlg, IDC_CONTEXT_CERR, str, COMMON_STR_SIZE); + p[1] |= (strtol(str, NULL, 0) & 0x3) << 1; + GetDlgItemText(hDlg, IDC_CONTEXT_TR_DEQUEUE_PTR, str, COMMON_STR_SIZE); + p[2] = strtol(str, NULL, 0) & ~BX_CONST64(0xF); + p[3] = (Bit64u) strtol(str, NULL, 0) >> 32; + p[2] |= (IsDlgButtonChecked(hDlg, IDC_CONTEXT_DCS) == BST_CHECKED) ? (1<<0) : 0; + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_ESIT_LO, str, COMMON_STR_SIZE); + p[4] = (strtol(str, NULL, 0) & 0xFFFF) << 16; + GetDlgItemText(hDlg, IDC_CONTEXT_AVERAGE_LEN, str, COMMON_STR_SIZE); + p[4] |= (strtol(str, NULL, 0) & 0xFFFF) << 0; + + for (i=0; i<3; i++) { + GetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_EP_0 + i, str, COMMON_STR_SIZE); + p[5+i] = strtol(str, NULL, 0); + } +#if (CONTEXT_SIZE == 64) + for (i=3; i<11; i++) { + GetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_EP_0 + i, str, COMMON_STR_SIZE); + p[5+i] = strtol(str, NULL, 0); + } +#endif + + xhci_context_changed = 0; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); +} + +INT_PTR CALLBACK hc_xhci_callback_context(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + struct S_ATTRIBUTES *attribs; + Bit32u *p; + int i, j; + + switch (msg) { + case WM_INITDIALOG: + xhci_context_address = lParam; + xhci_current_ep_context = 1; + xhci_context = new Bit8u[CONTEXT_SIZE + (32 * CONTEXT_SIZE)]; + DEV_MEM_READ_PHYSICAL(xhci_context_address, CONTEXT_SIZE + (32 * CONTEXT_SIZE), xhci_context); + p = (Bit32u *) &xhci_context[0]; + + // Context structure + sprintf(str, "0x%08X", p[0]); + SetDlgItemText(hDlg, IDC_CONTEXT_DROP, str); + sprintf(str, "0x%08X", p[1]); + SetDlgItemText(hDlg, IDC_CONTEXT_ADD, str); + + sprintf(str, "%i", (p[7] & 0x00FF0000) >> 16); + SetDlgItemText(hDlg, IDC_CONTEXT_ALT_SETTING, str); + sprintf(str, "%i", (p[7] & 0x0000FF00) >> 8); + SetDlgItemText(hDlg, IDC_CONTEXT_INTFACE_NUM, str); + sprintf(str, "%i", (p[7] & 0x000000FF) >> 0); + SetDlgItemText(hDlg, IDC_CONTEXT_CONFIG_VALUE, str); + + // Slot Context + p = (Bit32u *) &xhci_context[CONTEXT_SIZE]; + sprintf(str, "%i", (p[0] & (0x1F << 27)) >> 27); + SetDlgItemText(hDlg, IDC_CONTEXT_ENTRIES, str); + CheckDlgButton(hDlg, IDC_CONTEXT_HUB, (p[0] & (1<<26)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlg, IDC_CONTEXT_MTT, (p[0] & (1<<25)) ? BST_CHECKED : BST_UNCHECKED); + sprintf(str, "%i", (p[0] & (0xF << 20)) >> 20); + SetDlgItemText(hDlg, IDC_CONTEXT_SPEED, str); + sprintf(str, "0x%05X", (p[0] & (0xFFFFF << 0)) >> 0); + SetDlgItemText(hDlg, IDC_CONTEXT_ROUTE_STRING, str); + sprintf(str, "%i", (p[1] & (0xFF << 24)) >> 24); + SetDlgItemText(hDlg, IDC_CONTEXT_NUM_PORTS, str); + sprintf(str, "%i", (p[1] & (0xFF << 16)) >> 16); + SetDlgItemText(hDlg, IDC_CONTEXT_RH_PORT_NUM, str); + sprintf(str, "%i", (p[1] & (0xFFFF << 0)) >> 0); + SetDlgItemText(hDlg, IDC_CONTEXT_MAX_EXIT_LAT, str); + sprintf(str, "%i", (p[2] & (0x3FF << 22)) >> 22); + SetDlgItemText(hDlg, IDC_CONTEXT_INT_TARGET, str); + sprintf(str, "%i", (p[2] & (0x3 << 16)) >> 16); + SetDlgItemText(hDlg, IDC_CONTEXT_TTT, str); + sprintf(str, "%i", (p[2] & (0xFF << 8)) >> 8); + SetDlgItemText(hDlg, IDC_CONTEXT_TT_PORT_NUM, str); + sprintf(str, "%i", (p[2] & (0xFF << 0)) >> 0); + SetDlgItemText(hDlg, IDC_CONTEXT_TT_HUB_SLOT_ID, str); + sprintf(str, "%i", (p[3] & (0x1F << 27)) >> 27); + SetDlgItemText(hDlg, IDC_CONTEXT_SLOT_STATE, str); + sprintf(str, "%i", (p[3] & (0xFF << 0)) >> 0); + SetDlgItemText(hDlg, IDC_CONTEXT_DEV_ADDRESS, str); + for (i=0; i<4; i++) { + sprintf(str, "0x%08X", p[4+i]); + SetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_SLOT_0 + i, str); + } +#if (CONTEXT_SIZE == 64) + for (i=4; i<12; i++) { + sprintf(str, "0x%08X", p[4+i]); + SetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_SLOT_0 + i, str); + EnableWindow(GetDlgItem(hDlg, IDC_CONTEXT_RSVDO_SLOT_0 + i), 1); + } +#endif + + // Endpoint Context + hc_xhci_callback_context_ep_get(hDlg); + + xhci_context_changed = 0; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); + SetFocus(GetDlgItem(hDlg, IDC_CONTEXT_DROP)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDC_CONTEXT_DROP_B: + // create an attributes structure + attribs = (struct S_ATTRIBUTES *) calloc(sizeof(struct S_ATTRIBUTES), 33); + for (i=0,j=31; i<32; i++,j--) { + attribs[i].attrb = (BX_CONST64(1)< 1) { + if (xhci_context_changed) { + int ret = MessageBox(hDlg, "EP has changed. Save?", NULL, MB_ICONQUESTION | MB_YESNOCANCEL); + if (ret == IDYES) + hc_xhci_callback_context_ep_put(hDlg); + else if (ret == IDCANCEL) + break; + } + xhci_current_ep_context--; + hc_xhci_callback_context_ep_get(hDlg); + } + break; + case IDC_CONTEXT_NEXT: + if (xhci_current_ep_context < 31) { + if (xhci_context_changed) { + int ret = MessageBox(hDlg, "EP has changed. Save?", NULL, MB_ICONQUESTION | MB_YESNOCANCEL); + if (ret == IDYES) + hc_xhci_callback_context_ep_put(hDlg); + else if (ret == IDCANCEL) + break; + } + xhci_current_ep_context++; + hc_xhci_callback_context_ep_get(hDlg); + } + break; + case IDC_CONTEXT_STREAM_CONTEXT: + GetDlgItemText(hDlg, IDC_CONTEXT_TR_DEQUEUE_PTR, str, COMMON_STR_SIZE); + xhci_str_context_address = strtol(str, NULL, 0) & ~BX_CONST64(0x0F); + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_PSTREAMS, str, COMMON_STR_SIZE); + xhci_max_streams = strtol(str, NULL, 0); + if (xhci_max_streams > MAX_PSA_SIZE) + xhci_max_streams = MAX_PSA_SIZE; + if (xhci_max_streams > 0) + xhci_max_streams = (1 << (xhci_max_streams + 1)); + DialogBoxParam(NULL, MAKEINTRESOURCE(USB_DEBUG_XHCI_DLG_STR_CONTEXT), hDlg, hc_xhci_callback_str_context, (LPARAM) 0); + break; + case IDOK: + if (xhci_context_changed) { + int ret = MessageBox(hDlg, "EP has changed. Save?", NULL, MB_ICONQUESTION | MB_YESNOCANCEL); + if (ret == IDYES) + hc_xhci_callback_context_ep_put(hDlg); + else if (ret == IDCANCEL) + break; + } + + // Context structure + p = (Bit32u *) &xhci_context[0]; + GetDlgItemText(hDlg, IDC_CONTEXT_DROP, str, COMMON_STR_SIZE); + p[0] = strtol(str, NULL, 0) & ~0x3; + GetDlgItemText(hDlg, IDC_CONTEXT_ADD, str, COMMON_STR_SIZE); + p[1] = strtol(str, NULL, 0); + + GetDlgItemText(hDlg, IDC_CONTEXT_ALT_SETTING, str, COMMON_STR_SIZE); + p[7] = (strtol(str, NULL, 0) & 0xFF) << 16; + GetDlgItemText(hDlg, IDC_CONTEXT_INTFACE_NUM, str, COMMON_STR_SIZE); + p[7] |= (strtol(str, NULL, 0) & 0xFF) << 8; + GetDlgItemText(hDlg, IDC_CONTEXT_CONFIG_VALUE, str, COMMON_STR_SIZE); + p[7] |= (strtol(str, NULL, 0) & 0xFF) << 0; + + // Slot Context + p = (Bit32u *) &xhci_context[CONTEXT_SIZE]; + GetDlgItemText(hDlg, IDC_CONTEXT_ENTRIES, str, COMMON_STR_SIZE); + p[0] = (strtol(str, NULL, 0) & 0x1F) << 27; + p[0] |= (IsDlgButtonChecked(hDlg, IDC_CONTEXT_HUB) == BST_CHECKED) ? (1<<26) : 0; + p[0] |= (IsDlgButtonChecked(hDlg, IDC_CONTEXT_MTT) == BST_CHECKED) ? (1<<25) : 0; + GetDlgItemText(hDlg, IDC_CONTEXT_SPEED, str, COMMON_STR_SIZE); + p[0] |= (strtol(str, NULL, 0) & 0xF) << 20; + GetDlgItemText(hDlg, IDC_CONTEXT_ROUTE_STRING, str, COMMON_STR_SIZE); + p[0] |= (strtol(str, NULL, 0) & 0xFFFFF) << 0; + GetDlgItemText(hDlg, IDC_CONTEXT_NUM_PORTS, str, COMMON_STR_SIZE); + p[1] = (strtol(str, NULL, 0) & 0xFF) << 24; + GetDlgItemText(hDlg, IDC_CONTEXT_RH_PORT_NUM, str, COMMON_STR_SIZE); + p[1] |= (strtol(str, NULL, 0) & 0xFF) << 16; + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_EXIT_LAT, str, COMMON_STR_SIZE); + p[1] |= (strtol(str, NULL, 0) & 0xFFFF) << 0; + GetDlgItemText(hDlg, IDC_CONTEXT_INT_TARGET, str, COMMON_STR_SIZE); + p[2] = (strtol(str, NULL, 0) & 0x3FF) << 22; + GetDlgItemText(hDlg, IDC_CONTEXT_TTT, str, COMMON_STR_SIZE); + p[2] |= (strtol(str, NULL, 0) & 0x3) << 16; + GetDlgItemText(hDlg, IDC_CONTEXT_TT_PORT_NUM, str, COMMON_STR_SIZE); + p[2] |= (strtol(str, NULL, 0) & 0xFF) << 8; + GetDlgItemText(hDlg, IDC_CONTEXT_TT_HUB_SLOT_ID, str, COMMON_STR_SIZE); + p[2] |= (strtol(str, NULL, 0) & 0xFF) << 0; + GetDlgItemText(hDlg, IDC_CONTEXT_SLOT_STATE, str, COMMON_STR_SIZE); + p[3] = (strtol(str, NULL, 0) & 0x1F) << 27; + GetDlgItemText(hDlg, IDC_CONTEXT_DEV_ADDRESS, str, COMMON_STR_SIZE); + p[3] |= (strtol(str, NULL, 0) & 0xFF) << 0; + for (i=0; i<4; i++) { + GetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_SLOT_0 + i, str, COMMON_STR_SIZE); + p[4+i] = strtol(str, NULL, 0); + } +#if (CONTEXT_SIZE == 64) + for (i=4; i<12; i++) { + GetDlgItemText(hDlg, IDC_CONTEXT_RSVDO_SLOT_0 + i, str, COMMON_STR_SIZE); + p[4+i] = strtol(str, NULL, 0); + } +#endif + DEV_MEM_WRITE_PHYSICAL(xhci_context_address, CONTEXT_SIZE + (32 * CONTEXT_SIZE), xhci_context); + + delete [] xhci_context; + EndDialog(hDlg, 1); + break; + case IDCANCEL: + delete [] xhci_context; + EndDialog(hDlg, 0); + break; + } + break; + case EN_CHANGE: + if ((LOWORD(wParam) >= IDC_CONTEXT_MAX_ESIT_HI) && (LOWORD(wParam) <= IDC_CONTEXT_RSVDO_EP_10)) { + xhci_context_changed = 1; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 1); + } + switch (LOWORD(wParam)) { + case IDC_CONTEXT_SPEED: + GetDlgItemText(hDlg, IDC_CONTEXT_SPEED, str, COMMON_STR_SIZE); + i = strtol(str, NULL, 0); + if (i > 15) i = 16; + SetDlgItemText(hDlg, IDC_CONTEXT_SPEED_STR, slot_speed_str[i]); + break; + case IDC_CONTEXT_SLOT_STATE: + GetDlgItemText(hDlg, IDC_CONTEXT_SLOT_STATE, str, COMMON_STR_SIZE); + i = strtol(str, NULL, 0); + if (i > 3) i = 4; + SetDlgItemText(hDlg, IDC_CONTEXT_SLOT_STATE_STR, slot_type_str[i]); + break; + case IDC_CONTEXT_EP_STATE: + GetDlgItemText(hDlg, IDC_CONTEXT_EP_STATE, str, COMMON_STR_SIZE); + i = strtol(str, NULL, 0); + if (i > 7) i = 7; + SetDlgItemText(hDlg, IDC_CONTEXT_EP_STATE_STR, ep_state_str[i]); + break; + case IDC_CONTEXT_EP_TYPE: + GetDlgItemText(hDlg, IDC_CONTEXT_EP_TYPE, str, COMMON_STR_SIZE); + i = strtol(str, NULL, 0); + if (i > 7) i = 7; + SetDlgItemText(hDlg, IDC_CONTEXT_EP_TYPE_STR, ep_type_str[i]); + break; + case IDC_CONTEXT_MAX_PSTREAMS: + GetDlgItemText(hDlg, IDC_CONTEXT_MAX_PSTREAMS, str, COMMON_STR_SIZE); + i = strtol(str, NULL, 0); + if (i == 0) + SetDlgItemText(hDlg, IDC_CONTEXT_MAXPS_STR, "None"); + else if (i <= 15) + SetDlgItemInt(hDlg, IDC_CONTEXT_MAXPS_STR, (1 << (i + 1)), 0); + else + SetDlgItemText(hDlg, IDC_CONTEXT_MAXPS_STR, "Error"); + EnableWindow(GetDlgItem(hDlg, IDC_CONTEXT_STREAM_CONTEXT), (i > 0) && (i <=15)); + break; + } + break; + } + } + + return 0; +} + +static void CALLBACK hc_xhci_callback_str_context_get(HWND hDlg) +{ + char str[COMMON_STR_SIZE]; + Bit32u *p; + + // display the EP (with Drop and Add bits) + sprintf(str, "Context %i of %i", xhci_str_current_context, xhci_max_streams - 1); + if (xhci_str_current_context == 0) + strcat(str, "(Reserved)"); + SetDlgItemText(hDlg, IDC_CONTEXT_OF_STR, str); + + // String Context + p = (Bit32u *) &xhci_str_context[xhci_str_current_context * 32]; + sprintf(str, "0x" FMT_ADDRX64, ((Bit64u) p[1] << 32) | (p[0] & ~BX_CONST64(0xF))); + SetDlgItemText(hDlg, IDC_STR_CONTEXT_DQPTR, str); + sprintf(str, "%i", (p[0] & (0x7 << 1)) >> 1); + SetDlgItemText(hDlg, IDC_STR_CONTEXT_SCT, str); + CheckDlgButton(hDlg, IDC_STR_CONTEXT_DCS, (p[0] & (1<<0)) ? BST_CHECKED : BST_UNCHECKED); + sprintf(str, "0x%08X", p[2] & 0x00FFFFFF); + SetDlgItemText(hDlg, IDC_STR_CONTEXT_STOPPED, str); + sprintf(str, "0x%04X", (p[2] & 0xFF000000) >> 24); + SetDlgItemText(hDlg, IDC_STR_CONTEXT_RSVDO_0, str); + sprintf(str, "0x%08X", p[3]); + SetDlgItemText(hDlg, IDC_STR_CONTEXT_RSVDO_1, str); + + xhci_str_context_changed = 0; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); +} + +static void CALLBACK hc_xhci_callback_str_context_put(HWND hDlg) +{ + char str[COMMON_STR_SIZE]; + Bit32u *p; + + // String Context + p = (Bit32u *) &xhci_str_context[xhci_str_current_context * 32]; + GetDlgItemText(hDlg, IDC_STR_CONTEXT_DQPTR, str, COMMON_STR_SIZE); + p[0] = strtol(str, NULL, 0) & ~BX_CONST64(0xF); + p[1] = (Bit64u) strtol(str, NULL, 0) >> 32; + GetDlgItemText(hDlg, IDC_STR_CONTEXT_SCT, str, COMMON_STR_SIZE); + p[0] |= (strtol(str, NULL, 0) & 0x7) << 1; + p[0] |= (IsDlgButtonChecked(hDlg, IDC_STR_CONTEXT_DCS) == BST_CHECKED) ? (1<<0) : 0; + GetDlgItemText(hDlg, IDC_STR_CONTEXT_STOPPED, str, COMMON_STR_SIZE); + p[1] = (strtol(str, NULL, 0) & 0x00FFFFFF) << 0; + GetDlgItemText(hDlg, IDC_STR_CONTEXT_RSVDO_0, str, COMMON_STR_SIZE); + p[1] |= (strtol(str, NULL, 0) & 0xFF) << 24; + GetDlgItemText(hDlg, IDC_STR_CONTEXT_RSVDO_1, str, COMMON_STR_SIZE); + p[2] = strtol(str, NULL, 0); + + xhci_str_context_changed = 0; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); +} + +// xHCI 1.2: 6.2.4.1, Page 458 +INT_PTR CALLBACK hc_xhci_callback_str_context(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char str[COMMON_STR_SIZE]; + int i; + + switch (msg) { + case WM_INITDIALOG: + xhci_str_current_context = 0; + xhci_str_context = new Bit8u[CONTEXT_SIZE + (32 * CONTEXT_SIZE)]; + DEV_MEM_READ_PHYSICAL(xhci_str_context_address, MAX_PSA_SIZE_NUM * 32, xhci_str_context); + + // String Context + hc_xhci_callback_str_context_get(hDlg); + + xhci_str_context_changed = 0; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 0); + SetFocus(GetDlgItem(hDlg, IDC_STR_CONTEXT_DQPTR)); + return TRUE; + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case ID_APPLY: + hc_xhci_callback_str_context_put(hDlg); + break; + case IDC_CONTEXT_PREV: + if (xhci_str_current_context > 0) { + if (xhci_str_context_changed) { + int ret = MessageBox(hDlg, "Context has changed. Save?", NULL, MB_ICONQUESTION | MB_YESNOCANCEL); + if (ret == IDYES) + hc_xhci_callback_str_context_put(hDlg); + else if (ret == IDCANCEL) + break; + } + xhci_str_current_context--; + hc_xhci_callback_str_context_get(hDlg); + } + break; + case IDC_CONTEXT_NEXT: + if (xhci_str_current_context < (xhci_max_streams - 1)) { + if (xhci_str_context_changed) { + int ret = MessageBox(hDlg, "Context has changed. Save?", NULL, MB_ICONQUESTION | MB_YESNOCANCEL); + if (ret == IDYES) + hc_xhci_callback_str_context_put(hDlg); + else if (ret == IDCANCEL) + break; + } + xhci_str_current_context++; + hc_xhci_callback_str_context_get(hDlg); + } + break; + case IDOK: + if (xhci_str_context_changed) { + int ret = MessageBox(hDlg, "Context has changed. Save?", NULL, MB_ICONQUESTION | MB_YESNOCANCEL); + if (ret == IDYES) + hc_xhci_callback_str_context_put(hDlg); + else if (ret == IDCANCEL) + break; + } + + DEV_MEM_WRITE_PHYSICAL(xhci_str_context_address, MAX_PSA_SIZE_NUM * 32, xhci_str_context); + + delete [] xhci_str_context; + EndDialog(hDlg, 1); + break; + case IDCANCEL: + delete [] xhci_str_context; + EndDialog(hDlg, 0); + break; + } + break; + case EN_CHANGE: + if ((LOWORD(wParam) >= IDC_STR_CONTEXT_DQPTR) && (LOWORD(wParam) <= IDC_STR_CONTEXT_RSVDO_1)) { + xhci_str_context_changed = 1; + EnableWindow(GetDlgItem(hDlg, ID_APPLY), 1); + } + switch (LOWORD(wParam)) { + case IDC_STR_CONTEXT_SCT: + GetDlgItemText(hDlg, IDC_STR_CONTEXT_SCT, str, COMMON_STR_SIZE); + i = strtol(str, NULL, 0); + if (i > 7) i = 8; + SetDlgItemText(hDlg, IDC_CONTEXT_SCT_STR, string_sct_str[i]); + break; + } + break; + } + } + + return 0; +} + + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// Attributes +char a_title[COMMON_STR_SIZE]; +BOOL a_single; +DWORD64 a_attrib; +const struct S_ATTRIBUTES *a_attributes; +HWND ListBox = NULL; + +#include + +static INT_PTR CALLBACK attribute_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + int bCaption = SW_HIDE; + int i = 0, j = 0; + RECT rect; + + switch (msg) { + case WM_INITDIALOG: + SetWindowText(hDlg, a_title); + // move the window to be "within" the parent window + GetWindowRect((HWND) lParam, &rect); + SetWindowPos(hDlg, HWND_TOP, rect.right, rect.top - 3, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); + // initialize the ListBox + ListBox = GetDlgItem(hDlg, IDC_LIST); + ListBox_ResetContent(ListBox); + while (a_attributes[i].index > -1) { + ListBox_AddString(ListBox, a_attributes[i].str); + if ((a_attrib & a_attributes[i].mask) == a_attributes[i].attrb) + ListBox_SetSel(ListBox, TRUE, i); + if (a_attributes[i].str[0] == '*') + bCaption = SW_SHOW; + i++; + } + + // no need to show the caption if no 'single-only' entries + ShowWindow(GetDlgItem(hDlg, IDC_CAPTION), bCaption); + break; + + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + switch (LOWORD(wParam)) { + case IDCANCEL: + EndDialog(hDlg, IDCANCEL); + break; + case IDOK: + a_attrib = 0; + while (a_attributes[i].index > -1) { + if (ListBox_GetSel(ListBox, i)) + a_attrib |= a_attributes[i].attrb; + i++; + } + EndDialog(hDlg, IDOK); + break; + } + break; + + case LBN_SELCHANGE: + i = ListBox_GetCaretIndex(ListBox); // index to just clicked item + if (ListBox_GetSel(ListBox, i)) { + if (a_single) { + for (j=0; j -1) { + ListBox_SetSel(ListBox, FALSE, a_attributes[i].groups[j]); + j++; + } + } + } + break; + } + } + + return 0; +} + +void do_attributes(HWND hwnd, DWORD id, const int size, const char *title, const struct S_ATTRIBUTES *attribs) +{ + char str[COMMON_STR_SIZE]; + char str1[COMMON_STR_SIZE]; + + GetDlgItemText(hwnd, id, str, COMMON_STR_SIZE); + strcpy(a_title, title); + a_single = FALSE; + a_attrib = strtoul(str, NULL, 0); + a_attributes = attribs; + + // create the dialog and wait for it to return + if (DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_ATTRIBUTE), hwnd, attribute_callback, (LPARAM) GetDlgItem(hwnd, id)) == IDOK) { + sprintf(str1, "0x%%0%iX", size); + sprintf(str, str1, (DWORD) a_attrib); + SetDlgItemText(hwnd, id, str); + } +} + +#endif diff --git a/bochs/gui/win32usb.h b/bochs/gui/win32usb.h new file mode 100644 index 000000000..bf29eac62 --- /dev/null +++ b/bochs/gui/win32usb.h @@ -0,0 +1,161 @@ +///////////////////////////////////////////////////////////////////////// +// $Id$ +///////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023 Benjamin David Lunt +// Copyright (C) 2003-2021 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_WIN32_USB_H +#define BX_WIN32_USB_H + +#if BX_USE_WIN32USBDEBUG + +#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 + +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; + int wParam; + int lParam; +}; + +struct DUMP_PARAMS { + char title[COMMON_STR_SIZE]; + bx_phy_address address; + int size; // amount to dump (no more than 512) + bool big; // use 64-bit addresses? +}; +INT_PTR CALLBACK dump_dialog_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +/////////////////////////////////////////////////////////////////////////////////////////////// +// UHCI +// +INT_PTR CALLBACK hc_uhci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void hc_uhci_do_item(Bit32u FrameAddr, Bit32u FrameNum); +int hc_uhci_init(HWND hwnd); +int hc_uhci_save(HWND hwnd); +void uhci_display_td(HWND hwnd); + +INT_PTR CALLBACK hc_uhci_callback_queue(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_uhci_callback_td(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +/////////////////////////////////////////////////////////////////////////////////////////////// +// OHCI +// +INT_PTR CALLBACK hc_ohci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +int hc_ohci_init(HWND hwnd); + +/////////////////////////////////////////////////////////////////////////////////////////////// +// EHCI +// +INT_PTR CALLBACK hc_ehci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +int hc_ehci_init(HWND hwnd); + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// XHCI +// +#define VIEW_TRB_TYPE_NONE 0 +#define VIEW_TRB_TYPE_COMMAND 1 +#define VIEW_TRB_TYPE_EVENT 2 +#define VIEW_TRB_TYPE_TRANSFER 4 + +struct VIEW_TRB_TYPE { + Bit8u allowed_mask; + char name[22]; +}; + +#define MAX_TRBS_ALLOWED 4096 + +INT_PTR CALLBACK hc_xhci_callback(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +int hc_xhci_init(HWND hwnd); +int hc_xhci_save(HWND hwnd); +void hc_xhci_do_ring(const char *ring_str, Bit64u RingPtr, Bit64u dequeue_ptr); +void hc_xhci_do_event_ring(const char *ring_str, int interrupter); +void xhci_display_trb(HWND hwnd, int type_mask); +INT_PTR CALLBACK hc_xhci_callback_trb_normal(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_setup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_data(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_status(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_link(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_event(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_noop(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_enslot(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_disslot(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_address(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_configep(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_evaluate(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_resetep(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_stopep(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_settrptr(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_resetdev(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_forceevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_setlat(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_getband(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_forcehdr(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_transevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_compcompletion(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_pschange(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_bandrequ(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_doorbell(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_hostevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_devnotevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +INT_PTR CALLBACK hc_xhci_callback_trb_necfw(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_necun(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_trb_necfwevent(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +INT_PTR CALLBACK hc_xhci_callback_context(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK hc_xhci_callback_str_context(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + + +/////////////////////////////////////////////////////////////////////////////////////////////// +// Attributes +struct S_ATTRIBUTES { + DWORD64 attrb; + DWORD64 mask; + int index; + char str[32]; + int groups[10]; // up to 10 items can be grouped. Increase if we need more. +}; +void do_attributes(HWND hwnd, DWORD id, const int size, const char *title, const struct S_ATTRIBUTES *attribs); + + +#endif // BX_USE_WIN32USBDEBUG +#endif // BX_WIN32_USB_H diff --git a/bochs/gui/win32usbres.h b/bochs/gui/win32usbres.h new file mode 100644 index 000000000..2c894a51d --- /dev/null +++ b/bochs/gui/win32usbres.h @@ -0,0 +1,345 @@ + + +#define USB_DEBUG_UHCI_DLG 3900 +#define USB_DEBUG_OHCI_DLG 3901 +#define USB_DEBUG_EHCI_DLG 3902 +#define USB_DEBUG_XHCI_DLG 3903 + +#define USB_DEBUG_UHCI_DLG_QUEUE 4000 +#define USB_DEBUG_UHCI_DLG_TD 4001 + +#define USB_DEBUG_DLG_DUMP 4010 + + +#define USB_DEBUG_XHCI_DLG_NORM_TRB 4104 +#define USB_DEBUG_XHCI_DLG_SETUP_TRB 4105 +#define USB_DEBUG_XHCI_DLG_DATA_TRB 4106 +#define USB_DEBUG_XHCI_DLG_STATUS_TRB 4107 +#define USB_DEBUG_XHCI_DLG_LINK_TRB 4108 +#define USB_DEBUG_XHCI_DLG_EVENT_TRB 4109 +#define USB_DEBUG_XHCI_DLG_NOOP_TRB 4110 +#define USB_DEBUG_XHCI_DLG_ENSLOT_TRB 4111 +#define USB_DEBUG_XHCI_DLG_DISSLOT_TRB 4112 +#define USB_DEBUG_XHCI_DLG_ADDRESS_TRB 4113 +#define USB_DEBUG_XHCI_DLG_CONFIGEP_TRB 4114 +#define USB_DEBUG_XHCI_DLG_EVALUATE_TRB 4115 +#define USB_DEBUG_XHCI_DLG_RESETEP_TRB 4116 +#define USB_DEBUG_XHCI_DLG_STOPEP_TRB 4117 +#define USB_DEBUG_XHCI_DLG_SETTRPTR_TRB 4118 +#define USB_DEBUG_XHCI_DLG_RESETDEV_TRB 4119 +#define USB_DEBUG_XHCI_DLG_FORCE_TRB 4120 +#define USB_DEBUG_XHCI_DLG_SETLAT_TRB 4121 +#define USB_DEBUG_XHCI_DLG_GETBAND_TRB 4122 +#define USB_DEBUG_XHCI_DLG_FORCEHDR_TRB 4123 +#define USB_DEBUG_XHCI_DLG_TRANSEVENT_TRB 4124 +#define USB_DEBUG_XHCI_DLG_CMNDCOMP_TRB 4125 +#define USB_DEBUG_XHCI_DLG_PSCHANGE_TRB 4126 +#define USB_DEBUG_XHCI_DLG_BANDREQU_TRB 4127 +#define USB_DEBUG_XHCI_DLG_DOORBELL_TRB 4128 +#define USB_DEBUG_XHCI_DLG_HOSTEVENT_TRB 4129 +#define USB_DEBUG_XHCI_DLG_DEVNOTEVENT_TRB 4130 + +#define USB_DEBUG_XHCI_DLG_NECFW_TRB 4140 +#define USB_DEBUG_XHCI_DLG_NECUN_TRB 4141 +#define USB_DEBUG_XHCI_DLG_NECFWEVENT_TRB 4142 + +#define IDD_ATTRIBUTE 4150 +#define USB_DEBUG_XHCI_DLG_CONTEXT 4151 +#define USB_DEBUG_XHCI_DLG_STR_CONTEXT 4152 + +#define IDC_LIST 4160 +#define IDC_CAPTION 4161 +#define IDC_DUMP 4162 + +// common to all for HCs +#define ID_QUIT_EMU 4200 +#define ID_CONTINUE_EMU 4201 +#define IDC_PORT_ADDR 4202 +#define IDC_FRAME_ADDRESS 4203 +#define ID_APPLY 4204 +#define IDC_STACK 4205 +#define IDC_TREE_COMMENT 4206 + +#define IDC_STATIC -1 + + +// UHCI items start with 5000 +// (items that we want to trigger an EN_CHANGE must start with 5000 +// and end in 5020) +#define IDC_U_EN_START 5000 +#define IDC_U_REG_COMMAND 5000 +#define IDC_U_REG_STATUS 5001 +#define IDC_U_REG_INTERRUPT 5002 +#define IDC_U_REG_FRAME_NUM 5003 +#define IDC_U_REG_FRAME_ADDRESS 5004 +#define IDC_U_REG_SOF 5005 +#define IDC_U_REG_PORT0 5006 +#define IDC_U_REG_PORT1 5007 +#define IDC_U_EN_END 5020 + +#define IDC_U_REG_COMMAND_B 5100 +#define IDC_U_REG_STATUS_B 5101 +#define IDC_U_REG_INTERRUPT_B 5102 +#define IDC_U_REG_PORT0_B 5103 +#define IDC_U_REG_PORT1_B 5104 + +#define IDC_U_REG_PORT0_TYPE 5140 +#define IDC_U_REG_PORT1_TYPE 5141 + +#define IDC_HORZ_PTR 5200 +#define IDC_HORZ_T 5201 +#define IDC_HORZ_Q 5202 +#define IDC_VERT_PTR 5203 +#define IDC_VERT_T 5204 +#define IDC_VERT_Q 5205 +#define IDC_VERT_VF 5206 + +#define IDC_LINK_PTR 5210 +#define IDC_LINK_T 5211 +#define IDC_LINK_Q 5212 +#define IDC_LINK_VF 5213 +#define IDC_STATUS_LS 5214 +#define IDC_ACTUAL_LEN 5215 +#define IDC_STATUS_NAK 5216 +#define IDC_STATUS_CRC 5217 +#define IDC_STATUS_BITSTUFF 5218 +#define IDC_STATUS_RSVD 5219 +#define IDC_STATUS_ACTIVE 5220 +#define IDC_STATUS_STALLED 5221 +#define IDC_STATUS_DATA_BUFF_ERR 5222 +#define IDC_STATUS_BABBLE 5223 +#define IDC_STATUS_SPD 5224 +#define IDC_STATUS_IOC 5225 +#define IDC_STATUS_ISO 5226 +#define IDC_STATUS_CERR 5227 +#define IDC_DEVICE_ADDR 5228 +#define IDC_DEVICE_EP 5229 +#define IDC_DEVICE_MAXLEN 5230 +#define IDC_DEVICE_TOGGLE 5231 +#define IDC_DEVICE_BUFFER 5232 +#define IDC_COMBO_PID 5233 +#define IDC_DUMP_BUFFER 5234 + + + +// OHCI items start with 6000 + + + +// EHCI items start with 7000 + + + +// xHCI items start with 8000 +// (items that we want to trigger an EN_CHANGE must start with 8000 +// and end in 8019) +#define IDC_X_EN_START 8000 +#define IDC_X_REG_CAPLENGTH 8000 +#define IDC_X_REG_HCSPARAMS1 8001 +#define IDC_X_REG_HCSPARAMS2 8002 +#define IDC_X_REG_HCSPARAMS3 8003 +#define IDC_X_REG_HCCPARAMS1 8004 +#define IDC_X_REG_DBOFF 8005 +#define IDC_X_REG_RTSOFF 8006 +#define IDC_X_REG_HCCPARAMS2 8007 +#define IDC_X_REG_COMMAND 8008 +#define IDC_X_REG_STATUS 8009 +#define IDC_X_REG_PAGESIZE 8010 +#define IDC_X_REG_DEVICE_NOTE 8011 +#define IDC_X_REG_COMMAND_RING 8012 +#define IDC_X_REG_DEV_CONTEXT_BASE 8013 +#define IDC_X_REG_CONFIGURE 8014 +#define IDC_X_REG_PORT0 8015 +#define IDC_X_REG_PORT1 8016 +#define IDC_X_REG_PORT2 8017 +#define IDC_X_REG_PORT3 8018 +#define IDC_X_REG_PORT4 8019 +#define IDC_X_REG_PORT5 8020 +#define IDC_X_REG_PORT6 8021 +#define IDC_X_REG_PORT7 8022 +#define IDC_X_REG_PORT8 8023 +#define IDC_X_REG_PORT9 8024 +#define IDC_X_REG_MFINDEX 8025 +#define IDC_X_EN_END 8025 + +#define IDC_X_REG_EPORT0 8040 +#define IDC_X_REG_EPORT1 8041 +#define IDC_X_REG_EPORT2 8042 +#define IDC_X_REG_EPORT3 8043 +#define IDC_X_REG_EPORT4 8044 +#define IDC_X_REG_EPORT5 8045 +#define IDC_X_REG_EPORT6 8046 +#define IDC_X_REG_EPORT7 8047 +#define IDC_X_REG_EPORT8 8048 +#define IDC_X_REG_EPORT9 8049 + +#define IDC_X_REG_PORT0_B 8050 +#define IDC_X_REG_PORT1_B 8051 +#define IDC_X_REG_PORT2_B 8052 +#define IDC_X_REG_PORT3_B 8053 +#define IDC_X_REG_PORT4_B 8054 +#define IDC_X_REG_PORT5_B 8055 +#define IDC_X_REG_PORT6_B 8056 +#define IDC_X_REG_PORT7_B 8057 +#define IDC_X_REG_PORT8_B 8058 +#define IDC_X_REG_PORT9_B 8059 + +#define IDC_X_REG_PORT0_TYPE 8060 +#define IDC_X_REG_PORT1_TYPE 8061 +#define IDC_X_REG_PORT2_TYPE 8062 +#define IDC_X_REG_PORT3_TYPE 8063 +#define IDC_X_REG_PORT4_TYPE 8064 +#define IDC_X_REG_PORT5_TYPE 8065 +#define IDC_X_REG_PORT6_TYPE 8066 +#define IDC_X_REG_PORT7_TYPE 8067 +#define IDC_X_REG_PORT8_TYPE 8068 +#define IDC_X_REG_PORT9_TYPE 8069 + +#define IDC_X_REG_PORT0_ETYPE 8070 +#define IDC_X_REG_PORT1_ETYPE 8071 +#define IDC_X_REG_PORT2_ETYPE 8072 +#define IDC_X_REG_PORT3_ETYPE 8073 +#define IDC_X_REG_PORT4_ETYPE 8074 +#define IDC_X_REG_PORT5_ETYPE 8075 +#define IDC_X_REG_PORT6_ETYPE 8076 +#define IDC_X_REG_PORT7_ETYPE 8077 +#define IDC_X_REG_PORT8_ETYPE 8078 +#define IDC_X_REG_PORT9_ETYPE 8079 + +#define IDC_VIEW_TRB 8080 +#define IDC_VIEW_TD 8080 + +#define IDC_DEBUG_RESET 8081 +#define IDC_DEBUG_ENABLE 8082 +#define IDC_DEBUG_DOORBELL 8083 +#define IDC_DEBUG_EVENT 8084 +#define IDC_DEBUG_SOF 8085 +#define IDC_DEBUG_NONEXIST 8086 + +#define IDC_TRB_DATA_PTR 8100 +#define IDC_TRB_INT_TARGET 8101 +#define IDC_TRB_TD_SIZE 8102 +#define IDC_TRB_TRANS_LEN 8103 +#define IDC_TRB_TYPE 8104 +#define IDC_TRB_BEI 8105 +#define IDC_TRB_IDT 8106 +#define IDC_TRB_IOC 8107 +#define IDC_TRB_CH 8108 +#define IDC_TRB_NS 8109 +#define IDC_TRB_ISP 8110 +#define IDC_TRB_ENT 8111 +#define IDC_TRB_C 8112 + +#define IDC_TRB_WVALUE 8120 +#define IDC_TRB_BREQUEST 8121 +#define IDC_TRB_BREQUESTTYPE 8122 +#define IDC_TRB_WLENGTH 8123 +#define IDC_TRB_WINDEX 8124 +#define IDC_TRB_TRT 8125 + +#define IDC_TRB_DIR 8126 +#define IDC_TRB_TC 8127 +#define IDC_TRB_SLOT_TYPE 8128 +#define IDC_TRB_SLOT_ID 8129 +#define IDC_TRB_BSR 8130 +#define IDC_TRB_DECONFIG 8131 +#define IDC_TRB_EP_ID 8132 +#define IDC_TRB_TSP 8133 +#define IDC_TRB_SP 8134 +#define IDC_TRB_STREAMID 8135 +#define IDC_TRB_VF_ID 8136 +#define IDC_TRB_BELT 8137 +#define IDC_TRB_DEV_SPEED 8138 +#define IDC_TRB_SCT 8139 +#define IDC_TRB_DCS 8140 +#define IDC_TRB_HDR_HI 8141 +#define IDC_TRB_FTYPE 8142 +#define IDC_TRB_COMP_CODE 8143 +#define IDC_TRB_ED 8144 +#define IDC_TRB_COMP_LPARAM 8145 +#define IDC_TRB_COMP_HPARAM 8146 +#define IDC_TRB_NOT_TYPE 8147 +#define IDC_RING_TYPE 8148 +#define IDC_IN_CONTEXT 8149 + +// context structure +#define IDC_CONTEXT_NEXT 8200 +#define IDC_CONTEXT_PREV 8201 +#define IDC_CONTEXT_DROP 8202 +#define IDC_CONTEXT_DROP_B 8203 +#define IDC_CONTEXT_ADD 8204 +#define IDC_CONTEXT_ADD_B 8205 +#define IDC_CONTEXT_ALT_SETTING 8206 +#define IDC_CONTEXT_INTFACE_NUM 8207 +#define IDC_CONTEXT_CONFIG_VALUE 8208 +#define IDC_CONTEXT_OF_STR 8209 +#define IDC_CONTEXT_STREAM_CONTEXT 8210 + +#define IDC_CONTEXT_ENTRIES 8220 +#define IDC_CONTEXT_HUB 8221 +#define IDC_CONTEXT_MTT 8222 +#define IDC_CONTEXT_SPEED 8223 +#define IDC_CONTEXT_ROUTE_STRING 8224 +#define IDC_CONTEXT_NUM_PORTS 8225 +#define IDC_CONTEXT_RH_PORT_NUM 8226 +#define IDC_CONTEXT_MAX_EXIT_LAT 8227 +#define IDC_CONTEXT_INT_TARGET 8228 +#define IDC_CONTEXT_TTT 8229 +#define IDC_CONTEXT_TT_PORT_NUM 8230 +#define IDC_CONTEXT_TT_HUB_SLOT_ID 8231 +#define IDC_CONTEXT_SLOT_STATE 8232 +#define IDC_CONTEXT_DEV_ADDRESS 8233 +#define IDC_CONTEXT_RSVDO_SLOT_0 8234 +#define IDC_CONTEXT_RSVDO_SLOT_1 8235 +#define IDC_CONTEXT_RSVDO_SLOT_2 8236 +#define IDC_CONTEXT_RSVDO_SLOT_3 8237 +#define IDC_CONTEXT_RSVDO_SLOT_4 8238 +#define IDC_CONTEXT_RSVDO_SLOT_5 8239 +#define IDC_CONTEXT_RSVDO_SLOT_6 8240 +#define IDC_CONTEXT_RSVDO_SLOT_7 8241 +#define IDC_CONTEXT_RSVDO_SLOT_8 8242 +#define IDC_CONTEXT_RSVDO_SLOT_9 8243 +#define IDC_CONTEXT_RSVDO_SLOT_10 8244 +#define IDC_CONTEXT_RSVDO_SLOT_11 8245 +#define IDC_CONTEXT_SPEED_STR 8246 +#define IDC_CONTEXT_SLOT_STATE_STR 8247 + +#define IDC_CONTEXT_MAX_ESIT_HI 8260 +#define IDC_CONTEXT_INTERVAL 8261 +#define IDC_CONTEXT_LSA 8262 +#define IDC_CONTEXT_MAX_PSTREAMS 8263 +#define IDC_CONTEXT_MULT 8264 +#define IDC_CONTEXT_EP_STATE 8265 +#define IDC_CONTEXT_MAX_PACKET_SIZE 8266 +#define IDC_CONTEXT_MAX_BURST_SIZE 8267 +#define IDC_CONTEXT_HID 8268 +#define IDC_CONTEXT_EP_TYPE 8269 +#define IDC_CONTEXT_CERR 8270 +#define IDC_CONTEXT_TR_DEQUEUE_PTR 8271 +#define IDC_CONTEXT_DCS 8272 +#define IDC_CONTEXT_MAX_ESIT_LO 8273 +#define IDC_CONTEXT_AVERAGE_LEN 8274 +#define IDC_CONTEXT_RSVDO_EP_0 8275 +#define IDC_CONTEXT_RSVDO_EP_1 8276 +#define IDC_CONTEXT_RSVDO_EP_2 8277 +#define IDC_CONTEXT_RSVDO_EP_3 8278 +#define IDC_CONTEXT_RSVDO_EP_4 8279 +#define IDC_CONTEXT_RSVDO_EP_5 8280 +#define IDC_CONTEXT_RSVDO_EP_6 8281 +#define IDC_CONTEXT_RSVDO_EP_7 8282 +#define IDC_CONTEXT_RSVDO_EP_8 8283 +#define IDC_CONTEXT_RSVDO_EP_9 8284 +#define IDC_CONTEXT_RSVDO_EP_10 8285 +#define IDC_CONTEXT_EP_STATE_STR 8286 +#define IDC_CONTEXT_EP_TYPE_STR 8287 +#define IDC_CONTEXT_MAXPS_STR 8288 + +// string context +#define IDC_STR_CONTEXT_DQPTR 8301 +#define IDC_STR_CONTEXT_SCT 8302 +#define IDC_STR_CONTEXT_DCS 8303 +#define IDC_STR_CONTEXT_STOPPED 8304 +#define IDC_STR_CONTEXT_RSVDO_0 8305 +#define IDC_STR_CONTEXT_RSVDO_1 8306 +#define IDC_CONTEXT_SCT_STR 8307 + diff --git a/bochs/iodev/iodev.h b/bochs/iodev/iodev.h index 4e3beaa23..321a896c9 100644 --- a/bochs/iodev/iodev.h +++ b/bochs/iodev/iodev.h @@ -173,6 +173,9 @@ public: void set_name(const char *name) {pci_name = name;} const char* get_name(void) {return pci_name;} +#if BX_USE_WIN32USBDEBUG + Bit32u get_bar_addr(int indx) const { return pci_bar[indx].addr; } +#endif protected: const char *pci_name; diff --git a/bochs/iodev/usb/ohci_core.cc b/bochs/iodev/usb/ohci_core.cc index 414c9387b..f37350096 100644 --- a/bochs/iodev/usb/ohci_core.cc +++ b/bochs/iodev/usb/ohci_core.cc @@ -36,6 +36,9 @@ #include "pci.h" #include "usb_common.h" #include "ohci_core.h" +#if BX_USE_WIN32USBDEBUG + #include "gui/win32usb.h" +#endif #define LOG_THIS @@ -796,14 +799,23 @@ bool bx_ohci_core_c::mem_write(bx_phy_address addr, unsigned len, void *data) case 0x60: // HcRhPortStatus[3] #if (USB_OHCI_PORTS < 4) + #if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_OHCI, USB_DEBUG_NONEXIST, 0, 0); + #endif break; #endif case 0x5C: // HcRhPortStatus[2] #if (USB_OHCI_PORTS < 3) + #if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_OHCI, USB_DEBUG_NONEXIST, 0, 0); + #endif break; #endif case 0x58: // HcRhPortStatus[1] #if (USB_OHCI_PORTS < 2) + #if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_OHCI, USB_DEBUG_NONEXIST, 0, 0); + #endif break; #endif case 0x54: { // HcRhPortStatus[0] @@ -816,6 +828,9 @@ bool bx_ohci_core_c::mem_write(bx_phy_address addr, unsigned len, void *data) if (hub.usb_port[p].HcRhPortStatus.ccs == 0) hub.usb_port[p].HcRhPortStatus.csc = 1; else { +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_OHCI, USB_DEBUG_ENABLE, 0, 0); +#endif hub.usb_port[p].HcRhPortStatus.pes = 1; } } @@ -832,6 +847,9 @@ bool bx_ohci_core_c::mem_write(bx_phy_address addr, unsigned len, void *data) if (hub.usb_port[p].HcRhPortStatus.ccs == 0) hub.usb_port[p].HcRhPortStatus.csc = 1; else { +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_OHCI, USB_DEBUG_RESET, 0, 0); +#endif reset_port(p); hub.usb_port[p].HcRhPortStatus.pps = 1; hub.usb_port[p].HcRhPortStatus.pes = 1; @@ -899,6 +917,9 @@ void bx_ohci_core_c::ohci_timer(void) Bit16u zero = 0; if (hub.op_regs.HcControl.hcfs == OHCI_USB_OPERATIONAL) { +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_OHCI, USB_DEBUG_FRAME, 0, 0); +#endif // set remaining to the interval amount. hub.op_regs.HcFmRemainingToggle = hub.op_regs.HcFmInterval.fit; hub.sof_time = bx_pc_system.time_usec(); @@ -1138,6 +1159,10 @@ int bx_ohci_core_c::process_td(struct OHCI_TD *td, struct OHCI_ED *ed, int toggl return 0; } +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_OHCI, USB_DEBUG_COMMAND, 0, 0); +#endif + // The td->cc field should be 111x if it hasn't been processed yet. if (TD_GET_CC(td) < NotAccessed) { BX_ERROR(("Found TD with CC value not 111x")); diff --git a/bochs/iodev/usb/uhci_core.cc b/bochs/iodev/usb/uhci_core.cc index f46142ef6..3a686270e 100644 --- a/bochs/iodev/usb/uhci_core.cc +++ b/bochs/iodev/usb/uhci_core.cc @@ -55,6 +55,9 @@ #include "pci.h" #include "usb_common.h" #include "uhci_core.h" +#if BX_USE_WIN32USBDEBUG + #include "gui/win32usb.h" +#endif #define LOG_THIS @@ -515,6 +518,10 @@ void bx_uhci_core_c::write(Bit32u address, Bit32u value, unsigned io_len) case 0x14: // port #3 non existent, but linux systems check it to see if there are more than 2 BX_ERROR(("write to non existent offset 0x14 (port #3)")); +#if BX_USE_WIN32USBDEBUG + // Non existant Register Port (the next one after the last) + win32_usb_trigger(USB_DEBUG_UHCI, USB_DEBUG_NONEXIST, 0, 0); +#endif break; case 0x10: // port #1 @@ -524,6 +531,10 @@ void bx_uhci_core_c::write(Bit32u address, Bit32u value, unsigned io_len) // If the ports reset bit is set, don't allow any writes unless the new write will clear the reset bit if (hub.usb_port[port].reset && ((value & (1 << 9)) != 0)) break; +#if BX_USE_WIN32USBDEBUG + if ((value & (1 << 9)) && !hub.usb_port[port].reset) + win32_usb_trigger(USB_DEBUG_UHCI, USB_DEBUG_RESET, port, 0); +#endif if (value & ((1<<5) | (1<<4) | (1<<0))) BX_DEBUG(("write to one or more read-only bits in port #%d register: 0x%04x", port+1, value)); if (!(value & (1<<7))) @@ -549,6 +560,9 @@ void bx_uhci_core_c::write(Bit32u address, Bit32u value, unsigned io_len) hub.usb_port[port].reset = (value & (1<<9)) ? 1 : 0; hub.usb_port[port].resume = (value & (1<<6)) ? 1 : 0; if (!hub.usb_port[port].enabled && (value & (1<<2))) { +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_UHCI, USB_DEBUG_ENABLE, port, 0); +#endif hub.usb_port[port].enable_changed = 0; } else if (value & (1<<3)) hub.usb_port[port].enable_changed = 0; @@ -630,6 +644,10 @@ bool bx_uhci_core_c::uhci_add_queue(struct USB_UHCI_QUEUE_STACK *stack, const Bi // Called once every 1ms void bx_uhci_core_c::uhci_timer(void) { +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_UHCI, USB_DEBUG_FRAME, 0, 0); +#endif + // If the "global reset" bit was set by software if (global_reset) { for (int i=0; idword0, td->dword1, td->dword2, td->dword3)); +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_UHCI, USB_DEBUG_COMMAND, address, USB_LPARAM_FLAG_BEFORE); +#endif + // check TD to make sure it is valid // A max length 0x500 to 0x77E is illegal if ((maxlen >= 0x500) && (maxlen != 0x7FF)) { - BX_ERROR(("invalid max. length value 0x%04x", maxlen )); + BX_ERROR(("invalid max. length value 0x%04x", maxlen)); return 0; // error = consistency check failure } diff --git a/bochs/iodev/usb/uhci_core.h b/bochs/iodev/usb/uhci_core.h index 62c39cc55..2a96c991a 100644 --- a/bochs/iodev/usb/uhci_core.h +++ b/bochs/iodev/usb/uhci_core.h @@ -200,7 +200,9 @@ public: int event_handler(int event, void *ptr, int port); +#if !BX_USE_WIN32USBDEBUG protected: +#endif bx_uhci_core_t hub; Bit8u global_reset; diff --git a/bochs/iodev/usb/usb_ehci.cc b/bochs/iodev/usb/usb_ehci.cc index 204227530..85d4d2b1a 100644 --- a/bochs/iodev/usb/usb_ehci.cc +++ b/bochs/iodev/usb/usb_ehci.cc @@ -48,6 +48,9 @@ #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-> @@ -1024,14 +1027,25 @@ bool bx_usb_ehci_c::write_handler(bx_phy_address addr, unsigned len, void *data, BX_EHCI_THIS hub.usb_port[port].device->usb_send_msg(USB_MSG_RESET); BX_EHCI_THIS hub.usb_port[port].portsc.csc = 0; if (BX_EHCI_THIS hub.usb_port[port].device->get_speed() == USB_SPEED_HIGH) { +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_EHCI, USB_DEBUG_ENABLE, 0, 0); +#endif BX_EHCI_THIS hub.usb_port[port].portsc.ped = 1; } } } +#if BX_USE_WIN32USBDEBUG + if (!oldpr && BX_EHCI_THIS hub.usb_port[port].portsc.pr) { + win32_usb_trigger(USB_DEBUG_EHCI, USB_DEBUG_RESET, 0, 0); + } +#endif if (oldfpr && !BX_EHCI_THIS hub.usb_port[port].portsc.fpr) { BX_EHCI_THIS hub.usb_port[port].portsc.sus = 0; } +#if BX_USE_WIN32USBDEBUG } else if (port == USB_EHCI_PORTS) { + win32_usb_trigger(USB_DEBUG_EHCI, USB_DEBUG_NONEXIST, 0, 0); +#endif } } } else { @@ -1895,6 +1909,10 @@ int bx_usb_ehci_c::state_fetchqtd(EHCIQueue *q) EHCIqtd qtd; int again = 0; +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_EHCI, USB_DEBUG_COMMAND, 0, 0); +#endif + get_dwords(NLPTR_GET(q->qtdaddr), (Bit32u*) &qtd, sizeof(EHCIqtd) >> 2); EHCIPacket *p = QTAILQ_FIRST(&q->packets); @@ -2350,6 +2368,10 @@ void bx_usb_ehci_c::ehci_frame_timer(void) usec_elapsed = t_now - BX_EHCI_THIS hub.last_run_usec; frames = (int)(usec_elapsed / FRAME_TIMER_USEC); +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_EHCI, USB_DEBUG_FRAME, 0, 0); +#endif + if (BX_EHCI_THIS periodic_enabled() || (BX_EHCI_THIS hub.pstate != EST_INACTIVE)) { need_timer++; BX_EHCI_THIS hub.async_stepdown = 0; diff --git a/bochs/iodev/usb/usb_xhci.cc b/bochs/iodev/usb/usb_xhci.cc index 6d116bbd0..54ef6f078 100644 --- a/bochs/iodev/usb/usb_xhci.cc +++ b/bochs/iodev/usb/usb_xhci.cc @@ -70,6 +70,9 @@ #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-> @@ -850,7 +853,7 @@ bool bx_usb_xhci_c::restore_hc_state(void) // get MAX_SCRATCH_PADS worth of pointers for (i=0; i= EXT_CAPS_OFFSET) && (offset < (EXT_CAPS_OFFSET + EXT_CAPS_SIZE))) { unsigned caps_offset = (offset - EXT_CAPS_OFFSET); @@ -2270,7 +2282,7 @@ Bit64u bx_usb_xhci_c::process_transfer_ring(int slot, int ep, Bit64u ring_addr, // is the data in trb.parameter? (Immediate data?) is_immed_data = TRB_IS_IMMED_DATA(trb.command); if (is_immed_data) - DEV_MEM_READ_PHYSICAL_DMA((bx_phy_address) org_addr, 8, immed_data); // No byte-swapping here + DEV_MEM_READ_PHYSICAL((bx_phy_address) org_addr, 8, immed_data); // No byte-swapping here else address = trb.parameter; @@ -2515,6 +2527,10 @@ void bx_usb_xhci_c::process_command_ring(void) Bit8u buffer[CONTEXT_SIZE + (32 * CONTEXT_SIZE)]; struct SLOT_CONTEXT slot_context; struct EP_CONTEXT ep_context; + +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_XHCI, USB_DEBUG_COMMAND, 0, 0); +#endif if (!BX_XHCI_THIS hub.op_regs.HcCrcr.crr) return; @@ -2922,7 +2938,7 @@ void bx_usb_xhci_c::process_command_ring(void) unsigned offset = band_speed * (((1 + BX_XHCI_THIS hub.n_ports) + 7) & ~7); if (hub_id == 0) { // root hub if (band_speed < 4) { - DEV_MEM_WRITE_PHYSICAL_DMA((bx_phy_address) trb.parameter, 1 + BX_XHCI_THIS hub.n_ports, &BX_XHCI_THIS hub.port_band_width[offset]); + DEV_MEM_WRITE_PHYSICAL((bx_phy_address) trb.parameter, 1 + BX_XHCI_THIS hub.n_ports, &BX_XHCI_THIS hub.port_band_width[offset]); comp_code = TRB_SUCCESS; } else { comp_code = TRB_ERROR; @@ -3028,6 +3044,10 @@ void bx_usb_xhci_c::write_event_TRB(unsigned interrupter, Bit64u parameter, Bit3 // write the TRB write_TRB((bx_phy_address) BX_XHCI_THIS hub.ring_members.event_rings[interrupter].cur_trb, parameter, status, command | (Bit32u) BX_XHCI_THIS hub.ring_members.event_rings[interrupter].rcs); // set the cycle bit + +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_XHCI, USB_DEBUG_EVENT, interrupter, 0); +#endif BX_DEBUG(("Write Event TRB: table index: %d, trb index: %d", BX_XHCI_THIS hub.ring_members.event_rings[interrupter].count, @@ -3189,8 +3209,8 @@ void bx_usb_xhci_c::dump_stream_context(const Bit32u *context) { BX_INFO((" -=-=-=-=-=-=-=- Stream Context -=-=-=-=-=-=-")); BX_INFO((" TR Dequeue Ptr: " FMT_ADDRX64 "", (* (Bit64u *) &context[0] & (Bit64u) ~0x0F))); - BX_INFO((" Content Type: %01x", (context[0] & (0x07 << 1)) >> 1)); - BX_INFO((" DCS: %d", (context[0] & (1 << 0)) >> 0)); + BX_INFO((" Content Type: %01x", (context[0] & (0x07 << 1)) >> 1)); + BX_INFO((" DCS: %d", (context[0] & (1 << 0)) >> 0)); } void bx_usb_xhci_c::copy_slot_from_buffer(struct SLOT_CONTEXT *slot_context, const Bit8u *buffer) @@ -3588,13 +3608,16 @@ void bx_usb_xhci_c::xhci_timer(void) if (BX_XHCI_THIS hub.op_regs.HcStatus.hch) return; +#if BX_USE_WIN32USBDEBUG + win32_usb_trigger(USB_DEBUG_XHCI, USB_DEBUG_FRAME, 0, 0); +#endif + /* Per section 4.19.3 of the xHCI 1.0 specs, we need to present * a "Port Status Change Event". * Also, we should only present this event once if any other bits * change, only presenting it again when all change bits are written * back to zero, and a change bit goes from 0 to 1. */ - for (unsigned port=0; port",IDC_U_REG_COMMAND_B,134,41,18,12 + EDITTEXT IDC_U_REG_STATUS,72,56,58,12,ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_U_REG_STATUS_B,134,56,18,12 + EDITTEXT IDC_U_REG_INTERRUPT,72,70,58,12,ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_U_REG_INTERRUPT_B,134,70,18,12 + EDITTEXT IDC_U_REG_FRAME_NUM,72,84,58,12,ES_AUTOHSCROLL + EDITTEXT IDC_U_REG_FRAME_ADDRESS,71,98,58,12,ES_AUTOHSCROLL + EDITTEXT IDC_U_REG_SOF,72,112,58,12,ES_AUTOHSCROLL + EDITTEXT IDC_U_REG_PORT0,72,143,58,12,ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_U_REG_PORT0_B,134,143,18,12 + EDITTEXT IDC_U_REG_PORT0_TYPE,72,157,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_U_REG_PORT1,72,171,58,12,ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_U_REG_PORT1_B,134,172,18,12 + EDITTEXT IDC_U_REG_PORT1_TYPE,72,185,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + PUSHBUTTON "&Apply",ID_APPLY,106,212,50,14,WS_DISABLED + EDITTEXT IDC_FRAME_ADDRESS,231,163,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + CONTROL "Reset",IDC_DEBUG_RESET,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,43,96,10 + CONTROL "Enable",IDC_DEBUG_ENABLE,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,53,96,10 + CONTROL "Doorbell",IDC_DEBUG_DOORBELL,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,63,96,10 + CONTROL "Event",IDC_DEBUG_EVENT,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,73,96,10 + CONTROL "Start of Frame",IDC_DEBUG_SOF,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,83,96,10 + CONTROL "Non-exist",IDC_DEBUG_NONEXIST,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,93,96,10 + CONTROL "Tree1",IDC_STACK,"SysTreeView32",TVS_HASBUTTONS | + TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | + WS_BORDER | WS_TABSTOP,168,180,411,304 + RTEXT "Command",IDC_STATIC,15,43,50,8,WS_TABSTOP + GROUPBOX "Operational Registers",IDC_STATIC,7,30,149,98 + RTEXT "Status",IDC_STATIC,15,58,50,8,WS_TABSTOP + RTEXT "Interrupt Enable",IDC_STATIC,15,72,50,8,WS_TABSTOP + RTEXT "Frame Number",IDC_STATIC,15,87,50,8,WS_TABSTOP + RTEXT "Start of Frame",IDC_STATIC,15,115,50,8,WS_TABSTOP + GROUPBOX "Port Registers",IDC_STATIC,7,132,149,76 + RTEXT "Port 0",IDC_STATIC,15,145,50,8,WS_TABSTOP + RTEXT "Port 1",IDC_STATIC,15,173,50,8,WS_TABSTOP + RTEXT "Emulation Type",IDC_STATIC,15,159,50,8,WS_TABSTOP + RTEXT "Emulation Type",IDC_STATIC,16,187,50,8,WS_TABSTOP + RTEXT "UHCI at Port IO Address",IDC_STATIC,17,15,80,8, + WS_TABSTOP + EDITTEXT IDC_PORT_ADDR,102,13,58,12,ES_AUTOHSCROLL | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + RTEXT "Frame at Address",IDC_RING_TYPE,168,166,57,8,WS_TABSTOP + RTEXT "Frame Address",IDC_STATIC,15,101,50,8,WS_TABSTOP + EDITTEXT IDC_TREE_COMMENT,168,486,411,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + PUSHBUTTON "View Item",IDC_VIEW_TD,295,162,50,14,WS_DISABLED + GROUPBOX "Debug Flags",IDC_STATIC,477,30,116,126 +END + +USB_DEBUG_UHCI_DLG_QUEUE DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Queue" +FONT 8, "Helv" +BEGIN + RTEXT "Pointer:",IDC_STATIC,50,17,46,8 + EDITTEXT IDC_HORZ_PTR,100,16,82,12,ES_RIGHT | ES_AUTOHSCROLL + CONTROL "Terminate:",IDC_HORZ_T,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,81,40,101,12 + CONTROL "Queue:",IDC_HORZ_Q,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,81,30,101,12 + RTEXT "Pointer:",IDC_STATIC,50,70,46,8 + EDITTEXT IDC_VERT_PTR,100,69,82,12,ES_RIGHT | ES_AUTOHSCROLL + GROUPBOX " Horizontal Pointer ",IDC_STATIC,13,6,175,50 + GROUPBOX " Vertical Pointer ",IDC_STATIC,13,60,175,50 + CONTROL "Terminate:",IDC_VERT_T,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,81,95,101,12 + CONTROL "Queue:",IDC_VERT_Q,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,81,85,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_UHCI_DLG_TD DIALOG DISCARDABLE 0, 0, 203, 319 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Transfer Descriptor" +FONT 8, "Helv" +BEGIN + EDITTEXT IDC_LINK_PTR,100,15,82,12,ES_RIGHT | ES_AUTOHSCROLL + CONTROL "(Breadth First) Vf:",IDC_LINK_VF,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,81,29,101,12 + CONTROL "Queue:",IDC_LINK_Q,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,81,40,101,12 + CONTROL "Terminate:",IDC_LINK_T,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,81,51,101,12 + EDITTEXT IDC_ACTUAL_LEN,100,76,82,12,ES_RIGHT | ES_AUTOHSCROLL + CONTROL "Active:",IDC_STATUS_ACTIVE,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_DISABLED | WS_TABSTOP,27,98,65,12 + CONTROL "Stalled:",IDC_STATUS_STALLED,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,27,110,65,12 + CONTROL "Data Buffer Error:",IDC_STATUS_DATA_BUFF_ERR,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,23, + 122,69,12 + CONTROL "Babble Detect:",IDC_STATUS_BABBLE,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,27, + 133,65,12 + CONTROL "NAK Received:",IDC_STATUS_NAK,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,103,97,65,12 + CONTROL "CRC/Timeout:",IDC_STATUS_CRC,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,103,109,65,12 + CONTROL "Bitstuff Error:",IDC_STATUS_BITSTUFF,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP, + 103,121,65,12 + CONTROL "Reserved:",IDC_STATUS_RSVD,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,103,133,65,12 + CONTROL "Interrupt On Comp:",IDC_STATUS_IOC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,16, + 154,76,12 + CONTROL "Isochronous:",IDC_STATUS_ISO,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,27,165,65,12 + CONTROL "Low Speed:",IDC_STATUS_LS,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,103,154,65,12 + CONTROL "Short Packet:",IDC_STATUS_SPD,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,103,165,65,12 + RTEXT "C_ERR:",IDC_STATIC,52,181,46,8 + CONTROL "Toggle Bit:",IDC_DEVICE_TOGGLE,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,27,243,65,12 + COMBOBOX IDC_COMBO_PID,112,210,70,60,CBS_DROPDOWN | + WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_DEVICE_ADDR,147,227,35,12,ES_RIGHT | ES_AUTOHSCROLL + EDITTEXT IDC_DEVICE_EP,147,242,35,12,ES_RIGHT | ES_AUTOHSCROLL + EDITTEXT IDC_DEVICE_MAXLEN,147,256,35,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_DEVICE_BUFFER,83,278,82,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON ">",IDC_DUMP_BUFFER,170,279,18,12 + PUSHBUTTON "Cancel",IDCANCEL,31,296,50,14 + DEFPUSHBUTTON "Save",IDOK,121,296,50,14 + RTEXT "Link Pointer:",IDC_STATIC,50,16,46,8 + GROUPBOX " Link Pointer ",IDC_STATIC,11,7,177,58 + GROUPBOX " Status ",IDC_STATIC,11,67,177,129 + RTEXT "Actual Len:",IDC_STATIC,50,78,46,8 + GROUPBOX " Status ",IDC_STATIC,21,90,153,59 + EDITTEXT IDC_STATUS_CERR,102,179,22,12,ES_RIGHT | ES_AUTOHSCROLL + GROUPBOX " Packet Header ",IDC_STATIC,11,198,177,74 + RTEXT "PID:",IDC_STATIC,79,212,29,8 + RTEXT "Device Address:",IDC_STATIC,62,229,81,8 + RTEXT "End Point:",IDC_STATIC,101,244,41,8 + RTEXT "Max Length:",IDC_STATIC,61,259,81,8 + RTEXT "Buffer:",IDC_STATIC,33,280,46,8 +END + +USB_DEBUG_OHCI_DLG DIALOG DISCARDABLE 0, 0, DLG_WIDTH, DLG_HEIGHT +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "OHCI" +FONT 8, "Helv" +BEGIN + DEFPUSHBUTTON "&Continue", ID_CONTINUE_EMU, 15, 10, 50, 14 + PUSHBUTTON "&Quit", ID_QUIT_EMU, 75, 10, 50, 14 +// CONTROL "Check1",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | +// WS_TABSTOP,140,20,50,10 +END + +USB_DEBUG_EHCI_DLG DIALOG DISCARDABLE 0, 0, DLG_WIDTH, DLG_HEIGHT +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "EHCI" +FONT 8, "Helv" +BEGIN + DEFPUSHBUTTON "&Continue", ID_CONTINUE_EMU, 15, 10, 50, 14 + PUSHBUTTON "&Quit", ID_QUIT_EMU, 75, 10, 50, 14 +// CONTROL "Radio1",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | +// WS_GROUP,75,50,50,10 +END + +USB_DEBUG_XHCI_DLG DIALOGEX 0, 0, 600, 500 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "XHCI" +FONT 8, "Helv" +BEGIN + DEFPUSHBUTTON "&Continue",ID_CONTINUE_EMU,487,7,50,14 + PUSHBUTTON "&Quit",ID_QUIT_EMU,543,7,50,14 + EDITTEXT IDC_X_REG_CAPLENGTH,72,41,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_HCSPARAMS1,72,56,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_HCSPARAMS2,72,70,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_HCSPARAMS3,72,84,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_HCCPARAMS1,71,98,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_DBOFF,72,112,58,12,ES_RIGHT | ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_RTSOFF,72,126,58,12,ES_RIGHT | ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_HCCPARAMS2,72,140,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_COMMAND,222,41,58,12,ES_RIGHT | ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_STATUS,222,56,58,12,ES_RIGHT | ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_PAGESIZE,222,70,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_DEVICE_NOTE,222,84,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_COMMAND_RING,222,97,90,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_DEV_CONTEXT_BASE,222,112,90,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_CONFIGURE,222,126,58,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_X_REG_PORT0,72,171,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT0_B,134,171,18,12 + EDITTEXT IDC_X_REG_PORT0_TYPE,72,185,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT1,72,199,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT1_B,134,200,18,12 + EDITTEXT IDC_X_REG_PORT1_TYPE,72,213,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT2,72,227,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT2_B,134,228,18,12 + EDITTEXT IDC_X_REG_PORT2_TYPE,72,241,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT3,72,255,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT3_B,134,256,18,12 + EDITTEXT IDC_X_REG_PORT3_TYPE,72,269,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT4,72,283,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT4_B,134,284,18,12 + EDITTEXT IDC_X_REG_PORT4_TYPE,72,297,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT5,72,311,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT5_B,134,312,18,12 + EDITTEXT IDC_X_REG_PORT5_TYPE,72,325,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT6,72,339,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT6_B,134,340,18,12 + EDITTEXT IDC_X_REG_PORT6_TYPE,72,353,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT7,72,367,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT7_B,134,368,18,12 + EDITTEXT IDC_X_REG_PORT7_TYPE,72,381,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT8,72,395,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT8_B,134,396,18,12 + EDITTEXT IDC_X_REG_PORT8_TYPE,72,409,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_PORT9,72,423,58,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_X_REG_PORT9_B,134,424,18,12 + EDITTEXT IDC_X_REG_PORT9_TYPE,72,437,58,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + PUSHBUTTON "&Apply",ID_APPLY,106,458,50,14,WS_DISABLED + RTEXT "Ring Address:",IDC_RING_TYPE,166,166,97,8 + EDITTEXT IDC_FRAME_ADDRESS,270,163,90,12,ES_RIGHT | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT + WS_TABSTOP,WS_EX_STATICEDGE + EDITTEXT IDC_X_REG_MFINDEX,403,41,58,12,ES_RIGHT | ES_AUTOHSCROLL + CONTROL "&Reset",IDC_DEBUG_RESET,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,43,96,10 + CONTROL "&Enable",IDC_DEBUG_ENABLE,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,53,96,10 + CONTROL "&Doorbell",IDC_DEBUG_DOORBELL,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,63,96,10 + CONTROL "E&vent",IDC_DEBUG_EVENT,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,73,96,10 + CONTROL "&Start of Frame",IDC_DEBUG_SOF,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,83,96,10 + CONTROL "&Non-exist",IDC_DEBUG_NONEXIST,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,491,93,96,10 + CONTROL "Tree1",IDC_STACK,"SysTreeView32",TVS_HASBUTTONS | + TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | + WS_BORDER | WS_TABSTOP,168,180,411,304 + GROUPBOX "Port Registers",IDC_STATIC,7,160,149,294 + RTEXT "Port 0",IDC_X_REG_EPORT0,15,173,50,8,WS_TABSTOP + RTEXT "Port 1",IDC_X_REG_EPORT1,15,201,50,8,WS_TABSTOP + RTEXT "Port 2",IDC_X_REG_EPORT2,15,229,50,8,WS_TABSTOP + RTEXT "Port 3",IDC_X_REG_EPORT3,15,257,50,8,WS_TABSTOP + RTEXT "Port 4",IDC_X_REG_EPORT4,15,285,50,8,WS_TABSTOP + RTEXT "Port 5",IDC_X_REG_EPORT5,15,313,50,8,WS_TABSTOP + RTEXT "Port 6",IDC_X_REG_EPORT6,15,341,50,8,WS_TABSTOP + RTEXT "Port 7",IDC_X_REG_EPORT7,15,369,50,8,WS_TABSTOP + RTEXT "Port 8",IDC_X_REG_EPORT8,15,397,50,8,WS_TABSTOP + RTEXT "Port 9",IDC_X_REG_EPORT9,15,425,50,8,WS_TABSTOP + RTEXT "Emulation Type",IDC_X_REG_PORT0_ETYPE,15,187,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT1_ETYPE,16,215,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT2_ETYPE,16,243,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT3_ETYPE,16,271,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT4_ETYPE,16,299,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT5_ETYPE,16,327,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT6_ETYPE,16,355,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT7_ETYPE,16,383,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT8_ETYPE,16,411,50,8 + RTEXT "Emulation Type",IDC_X_REG_PORT9_ETYPE,16,439,50,8 + RTEXT "xHCI at Mem-mapped Address",IDC_STATIC,17,15,80,8, + WS_TABSTOP + EDITTEXT IDC_PORT_ADDR,102,13,58,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP, + WS_EX_STATICEDGE + EDITTEXT IDC_TREE_COMMENT,168,486,411,12,ES_RIGHT | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT + WS_TABSTOP + GROUPBOX "Capability Registers",IDC_STATIC,7,30,129,126 + RTEXT "Cap Length",IDC_STATIC,15,43,50,8,WS_TABSTOP + RTEXT "HCSParams1",IDC_STATIC,15,58,50,8,WS_TABSTOP + RTEXT "HCSParams2",IDC_STATIC,15,72,50,8,WS_TABSTOP + RTEXT "HCSParams3",IDC_STATIC,15,87,50,8,WS_TABSTOP + RTEXT "HCCParams1",IDC_STATIC,15,101,50,8,WS_TABSTOP + RTEXT "DB Offset",IDC_STATIC,15,115,50,8,WS_TABSTOP + RTEXT "RTS Offset",IDC_STATIC,15,128,50,8,WS_TABSTOP + RTEXT "HCCParams2",IDC_STATIC,15,142,50,8,WS_TABSTOP + GROUPBOX "Operational Registers",IDC_STATIC,141,30,177,126 + RTEXT "Command",IDC_STATIC,149,43,70,8,WS_TABSTOP + RTEXT "Status",IDC_STATIC,149,57,70,8,WS_TABSTOP + RTEXT "Page Size",IDC_STATIC,149,72,70,8,WS_TABSTOP + RTEXT "Device Notification",IDC_STATIC,149,86,70,8,WS_TABSTOP + RTEXT "Device Context Base",IDC_STATIC,149,115,70,8,WS_TABSTOP + RTEXT "Command Ring",IDC_STATIC,149,101,70,8,WS_TABSTOP + RTEXT "Configure",IDC_STATIC,149,128,70,8,WS_TABSTOP + GROUPBOX "Runtime Registers",IDC_STATIC,323,30,143,126 + RTEXT "Microframe Index",IDC_STATIC,330,43,70,8,WS_TABSTOP + PUSHBUTTON "View TRB",IDC_VIEW_TRB,363,162,50,14,WS_DISABLED + GROUPBOX "Debug Flags",IDC_STATIC,477,30,116,126 +END + +USB_DEBUG_XHCI_DLG_NORM_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Normal TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Data Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Interrupter Target:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_INT_TARGET,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TD Size:",IDC_STATIC,11,36,85,8 + EDITTEXT IDC_TRB_TD_SIZE,100,36,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Transfer Length:",IDC_STATIC,11,50,85,8 + EDITTEXT IDC_TRB_TRANS_LEN,100,50,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Block Event Interrupt:",IDC_TRB_BEI,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 77,101,12 + CONTROL "Immediate Data:",IDC_TRB_IDT,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,88,101,12 + CONTROL "Interrupt on Complete:",IDC_TRB_IOC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 99,101,12 + CONTROL "Chain Bit:",IDC_TRB_CH,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,110,101,12 + CONTROL "No Snoop:",IDC_TRB_NS,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,121,101,12 + CONTROL "Interrupt on Short Packet:",IDC_TRB_ISP,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 132,101,12 + CONTROL "Evaluate Next TRB:",IDC_TRB_ENT,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 143,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_SETUP_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Setup TRB" +FONT 8, "Helv" +BEGIN + RTEXT "wValue",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_WVALUE,100,8,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "bRequest",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_BREQUEST,100,23,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "bRequestType",IDC_STATIC,11,38,85,8 + EDITTEXT IDC_TRB_BREQUESTTYPE,100,37,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "wLength",IDC_STATIC,11,52,85,8 + EDITTEXT IDC_TRB_WLENGTH,100,51,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "wIndex",IDC_STATIC,11,66,85,8 + EDITTEXT IDC_TRB_WINDEX,100,65,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Interrupter Target:",IDC_STATIC,11,80,85,8 + EDITTEXT IDC_TRB_INT_TARGET,100,79,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Transfer Length:",IDC_STATIC,11,93,85,8 + EDITTEXT IDC_TRB_TRANS_LEN,100,93,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Transfer Type:",IDC_STATIC,11,107,85,8 + EDITTEXT IDC_TRB_TRT,100,107,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,121,85,8 + EDITTEXT IDC_TRB_TYPE,100,121,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Immediate Data:",IDC_TRB_IDT,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,135,101,12 + CONTROL "Interrupt on Complete:",IDC_TRB_IOC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 146,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,158,101,12 + DEFPUSHBUTTON "OK",IDOK,146,139,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,156,50,14 +END + +USB_DEBUG_XHCI_DLG_DATA_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Data TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Data Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Interrupter Target:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_INT_TARGET,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TD Size:",IDC_STATIC,11,36,85,8 + EDITTEXT IDC_TRB_TD_SIZE,100,36,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Transfer Length:",IDC_STATIC,11,50,85,8 + EDITTEXT IDC_TRB_TRANS_LEN,100,50,48,12,ES_RIGHT | ES_AUTOHSCROLL + CONTROL "Direction:",IDC_TRB_DIR,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 63,101,12 + RTEXT "TRB Type:",IDC_STATIC,11,77,85,8 + EDITTEXT IDC_TRB_TYPE,100,75,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Immediate Data:",IDC_TRB_IDT,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,88,101,12 + CONTROL "Interrupt on Complete:",IDC_TRB_IOC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 99,101,12 + CONTROL "Chain Bit:",IDC_TRB_CH,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,110,101,12 + CONTROL "No Snoop:",IDC_TRB_NS,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,121,101,12 + CONTROL "Interrupt on Short Packet:",IDC_TRB_ISP,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 132,101,12 + CONTROL "Evaluate Next TRB:",IDC_TRB_ENT,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 143,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_STATUS_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Status TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Interrupter Target:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_INT_TARGET,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + CONTROL "Direction:",IDC_TRB_DIR,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 63,101,12 + RTEXT "TRB Type:",IDC_STATIC,11,77,85,8 + EDITTEXT IDC_TRB_TYPE,100,75,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Interrupt on Complete:",IDC_TRB_IOC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 99,101,12 + CONTROL "Chain Bit:",IDC_TRB_CH,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,110,101,12 + CONTROL "Evaluate Next TRB:",IDC_TRB_ENT,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 143,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_LINK_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Link TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Ring Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Interrupter Target:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_INT_TARGET,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Interrupt on Complete:",IDC_TRB_IOC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 99,101,12 + CONTROL "Chain Bit:",IDC_TRB_CH,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,110,101,12 + CONTROL "Toggle Cycle:",IDC_TRB_TC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 143,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_NOOP_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "No-Op TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Interrupter Target:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_INT_TARGET,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Interrupt on Complete:",IDC_TRB_IOC,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 99,101,12 + CONTROL "Chain Bit:",IDC_TRB_CH,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,110,101,12 + CONTROL "Evaluate Next TRB:",IDC_TRB_ENT,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 143,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_ENSLOT_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Enable Slot TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Slot Type:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_SLOT_TYPE,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_DISSLOT_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Disable Slot TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Slot ID:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_ADDRESS_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Address Device TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Input Context Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,82,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON ">",IDC_IN_CONTEXT,185,8,13,12 + RTEXT "Slot ID:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Block Set Address:",IDC_TRB_BSR,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,128,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_CONFIGEP_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Configure EP TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Input Context Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,82,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON ">",IDC_IN_CONTEXT,185,8,13,12 + RTEXT "Slot ID:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Deconfigure:",IDC_TRB_DECONFIG,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,128,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_EVALUATE_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Evaluate Context TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Input Context Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,82,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON ">",IDC_IN_CONTEXT,185,8,13,12 + RTEXT "Slot ID:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Block Set Address:",IDC_TRB_BSR,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP | WS_DISABLED,7,128,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_RESETEP_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Reset EP TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Slot ID:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Endpoint ID:",IDC_STATIC,11,51,85,8 + EDITTEXT IDC_TRB_EP_ID,100,50,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Transfer State Preserve:",IDC_TRB_TSP,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP | WS_DISABLED,7,128,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_STOPEP_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Stop EP TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Slot ID:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,23,48,12,ES_RIGHT | + ES_AUTOHSCROLL + CONTROL "Suspend:",IDC_TRB_SP,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,37,101,12 + RTEXT "Endpoint ID:",IDC_STATIC,11,51,85,8 + EDITTEXT IDC_TRB_EP_ID,100,50,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_SETTRPTR_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Set TR Dequeue Pointer TRB" +FONT 8, "Helv" +BEGIN + RTEXT "New TR Dequeue Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Stream Context Type:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_SCT,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + CONTROL "Dequeue Cycle Bit:",IDC_TRB_DCS,"Button", + BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7, + 35,101,12 + RTEXT "Stream ID:",IDC_STATIC,11,55,85,8 + EDITTEXT IDC_TRB_STREAMID,100,50,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Slot ID:",IDC_STATIC,11,76,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,73,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Endpoint ID:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_EP_ID,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,103,85,8 + EDITTEXT IDC_TRB_TYPE,100,103,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_RESETDEV_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Reset Device TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Slot ID:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_FORCE_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Force Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Event TRB Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "VF Interrupter Target:",IDC_STATIC,11,23,85,8 + EDITTEXT IDC_TRB_INT_TARGET,100,22,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "VF ID:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_VF_ID,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_SETLAT_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Set Latency Tolerance Value TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Best Effort Value:",IDC_STATIC,11,51,85,8 + EDITTEXT IDC_TRB_BELT,100,50,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_GETBAND_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Get Port Bandwidth TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Port Bandwidth Context Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Hub Slot ID:",IDC_STATIC,11,36,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,35,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Device Speed:",IDC_STATIC,11,51,85,8 + EDITTEXT IDC_TRB_DEV_SPEED,100,50,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,64,85,8 + EDITTEXT IDC_TRB_TYPE,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_FORCEHDR_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Force Header TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Header Lo/Mid:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Header Hi:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_HDR_HI,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Type:",IDC_STATIC,12,37,85,8 + EDITTEXT IDC_TRB_FTYPE,100,36,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Root Hub Port Number:",IDC_STATIC,11,62,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,60,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,74,85,8 + EDITTEXT IDC_TRB_TYPE,100,74,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_TRANSEVENT_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Transfer Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "TRB Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Completion Code:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Slot ID:",IDC_STATIC,11,62,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,60,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Endpoint ID:",IDC_STATIC,11,75,85,8 + EDITTEXT IDC_TRB_EP_ID,100,74,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Event Data:",IDC_TRB_ED,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,143,101,12 + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_CMNDCOMP_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Command Completion TRB" +FONT 8, "Helv" +BEGIN + RTEXT "TRB Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Completion Code:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Completion Parameter:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_COMP_LPARAM,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Slot ID:",IDC_STATIC,11,62,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,60,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "VF ID:",IDC_STATIC,11,76,85,8 + EDITTEXT IDC_TRB_VF_ID,100,74,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_PSCHANGE_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Port Status Change Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Port ID:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Completion Code:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_BANDREQU_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Bandwidth Request Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Completion Code:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Slot ID:",IDC_STATIC,11,36,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,35,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_DOORBELL_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Doorbell Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "DB Reason:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Completion Code:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Slot ID:",IDC_STATIC,11,36,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,35,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "VF ID:",IDC_STATIC,11,76,85,8 + EDITTEXT IDC_TRB_VF_ID,100,74,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_HOSTEVENT_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Host Controller Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Completion Code:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_DEVNOTEVENT_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Device Notification Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Dev Notification Data:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Notification Type:",IDC_STATIC,12,23,85,8 + EDITTEXT IDC_TRB_NOT_TYPE,100,21,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Completion Code:",IDC_STATIC,11,36,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,34,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Slot ID:",IDC_STATIC,11,48,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,47,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_NECFW_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Vendor: NEC Get Firmware Version TRB" +FONT 8, "Helv" +BEGIN + RTEXT "TRB Type:",IDC_STATIC,11,74,85,8 + EDITTEXT IDC_TRB_TYPE,100,74,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_NECUN_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Vendor: NEC Get Verification Code" +FONT 8, "Helv" +BEGIN + RTEXT "Start Code:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,74,85,8 + EDITTEXT IDC_TRB_TYPE,100,74,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_NECFWEVENT_TRB DIALOG DISCARDABLE 0, 0, 203, 174 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "NEC Firmware Event TRB" +FONT 8, "Helv" +BEGIN + RTEXT "Original Pointer:",IDC_STATIC,11,9,85,8 + EDITTEXT IDC_TRB_DATA_PTR,100,8,96,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Completion Code:",IDC_STATIC,11,24,85,8 + EDITTEXT IDC_TRB_COMP_CODE,100,22,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "Param Low:",IDC_STATIC,11,37,85,8 + EDITTEXT IDC_TRB_COMP_LPARAM,100,36,48,12,ES_RIGHT | + ES_AUTOHSCROLL + LTEXT "(Version)",IDC_STATIC,153,37,35,8 + RTEXT "Param High:",IDC_STATIC,11,51,85,8 + EDITTEXT IDC_TRB_COMP_HPARAM,100,50,48,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Slot ID:",IDC_STATIC,11,66,85,8 + EDITTEXT IDC_TRB_SLOT_ID,100,64,48,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TRB Type:",IDC_STATIC,11,89,85,8 + EDITTEXT IDC_TRB_TYPE,100,88,48,12,ES_RIGHT | ES_AUTOHSCROLL | + ES_READONLY | NOT WS_TABSTOP + CONTROL "Cycle Bit:",IDC_TRB_C,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,7,154,101,12 + DEFPUSHBUTTON "OK",IDOK,146,135,50,14 + PUSHBUTTON "Cancel",IDCANCEL,146,152,50,14 +END + +USB_DEBUG_XHCI_DLG_CONTEXT DIALOG DISCARDABLE 0, 0, 428, 455 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Context" +FONT 8, "Helv" +BEGIN + RTEXT "Drop Context Flags:",IDC_STATIC,20,18,68,8 + EDITTEXT IDC_CONTEXT_DROP,91,17,82,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_CONTEXT_DROP_B,177,17,18,12 + RTEXT "Add Context Flags:",IDC_STATIC,20,32,68,8 + EDITTEXT IDC_CONTEXT_ADD,91,31,82,12,ES_RIGHT | ES_AUTOHSCROLL + PUSHBUTTON "<>",IDC_CONTEXT_ADD_B,177,31,18,12 + RTEXT "Alt Setting:",IDC_STATIC,203,18,47,8 + EDITTEXT IDC_CONTEXT_ALT_SETTING,254,17,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Interface Num:",IDC_STATIC,203,32,47,8 + EDITTEXT IDC_CONTEXT_INTFACE_NUM,254,31,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Config Value:",IDC_STATIC,203,47,47,8 + EDITTEXT IDC_CONTEXT_CONFIG_VALUE,254,45,45,12,ES_RIGHT | + ES_AUTOHSCROLL + GROUPBOX "Slot Context",IDC_STATIC,19,64,198,382 + RTEXT "Context Entries:",IDC_STATIC,52,78,65,8 + EDITTEXT IDC_CONTEXT_ENTRIES,121,77,45,12,ES_RIGHT | + ES_AUTOHSCROLL + CONTROL "Hub",IDC_CONTEXT_HUB,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,77,93,89,10 + CONTROL "MTT",IDC_CONTEXT_MTT,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,77,105,89,10 + RTEXT "Speed:",IDC_STATIC,52,119,65,8 + EDITTEXT IDC_CONTEXT_SPEED,121,118,45,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_CONTEXT_SPEED_STR,169,119,45,11,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER, + WS_EX_STATICEDGE + RTEXT "Route String:",IDC_STATIC,49,134,68,8 + EDITTEXT IDC_CONTEXT_ROUTE_STRING,121,133,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Number of Ports:",IDC_STATIC,52,148,65,8 + EDITTEXT IDC_CONTEXT_NUM_PORTS,121,147,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Root Hub Port Number:",IDC_STATIC,36,162,81,8 + EDITTEXT IDC_CONTEXT_RH_PORT_NUM,121,161,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Max Exit Latency:",IDC_STATIC,36,176,81,8 + EDITTEXT IDC_CONTEXT_MAX_EXIT_LAT,121,176,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Interrupter Target:",IDC_STATIC,36,191,81,8 + EDITTEXT IDC_CONTEXT_INT_TARGET,121,191,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TTT:",IDC_STATIC,36,205,81,8 + EDITTEXT IDC_CONTEXT_TTT,121,205,45,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TT Port Number:",IDC_STATIC,36,219,81,8 + EDITTEXT IDC_CONTEXT_TT_PORT_NUM,121,219,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "TT Hub Slot ID:",IDC_STATIC,36,233,81,8 + EDITTEXT IDC_CONTEXT_TT_HUB_SLOT_ID,121,233,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Slot State:",IDC_STATIC,36,248,81,8 + EDITTEXT IDC_CONTEXT_SLOT_STATE,121,247,45,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_CONTEXT_SLOT_STATE_STR,169,248,45,11,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER, + WS_EX_STATICEDGE + RTEXT "USB Device Address:",IDC_STATIC,36,261,81,8 + EDITTEXT IDC_CONTEXT_DEV_ADDRESS,121,260,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [13-10h]:",IDC_STATIC,36,278,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_0,121,275,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [17-14h]:",IDC_STATIC,36,292,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_1,121,289,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [1B-18h]:",IDC_STATIC,36,306,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_2,121,303,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [1F-1Ch]:",IDC_STATIC,36,320,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_3,121,317,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [23-20h]:",IDC_STATIC,36,334,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_4,121,331,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [27-24h]:",IDC_STATIC,36,348,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_5,121,345,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [2B-28h]:",IDC_STATIC,36,362,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_6,121,359,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [2F-2Ch]:",IDC_STATIC,36,376,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_7,121,373,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [33-30h]:",IDC_STATIC,36,390,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_8,121,387,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [37-34h]:",IDC_STATIC,36,404,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_9,121,401,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [3B-38h]:",IDC_STATIC,36,418,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_10,121,415,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [3F-3Ch]:",IDC_STATIC,36,432,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_SLOT_11,121,429,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + GROUPBOX "Endpoint Context",IDC_STATIC,223,64,198,382 + RTEXT "Max ESIT Payload Hi:",IDC_STATIC,232,78,89,8 + EDITTEXT IDC_CONTEXT_MAX_ESIT_HI,324,77,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Interval:",IDC_STATIC,256,92,65,8 + EDITTEXT IDC_CONTEXT_INTERVAL,324,91,45,12,ES_RIGHT | + ES_AUTOHSCROLL + CONTROL "LSA",IDC_CONTEXT_LSA,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,280,105,89,10 + RTEXT "MaxPStreams:",IDC_STATIC,256,118,65,8 + EDITTEXT IDC_CONTEXT_MAX_PSTREAMS,324,118,45,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_CONTEXT_MAXPS_STR,372,119,45,11,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER, + WS_EX_STATICEDGE + RTEXT "Mult:",IDC_STATIC,252,134,68,8 + EDITTEXT IDC_CONTEXT_MULT,324,133,45,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "EP State:",IDC_STATIC,256,148,65,8 + EDITTEXT IDC_CONTEXT_EP_STATE,324,147,45,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_CONTEXT_EP_STATE_STR,372,148,45,11,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER, + WS_EX_STATICEDGE + RTEXT "Max Packet Size:",IDC_STATIC,240,161,81,8 + EDITTEXT IDC_CONTEXT_MAX_PACKET_SIZE,324,161,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Max Burst Size:",IDC_STATIC,240,176,81,8 + EDITTEXT IDC_CONTEXT_MAX_BURST_SIZE,324,176,45,12,ES_RIGHT | + ES_AUTOHSCROLL + CONTROL "HID",IDC_CONTEXT_HID,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,280,192,89,10 + RTEXT "EP Type:",IDC_STATIC,240,205,81,8 + EDITTEXT IDC_CONTEXT_EP_TYPE,324,205,45,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_CONTEXT_EP_TYPE_STR,372,206,45,11,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER, + WS_EX_STATICEDGE + RTEXT "CErr:",IDC_STATIC,240,219,81,8 + EDITTEXT IDC_CONTEXT_CERR,324,219,45,12,ES_RIGHT | ES_AUTOHSCROLL + RTEXT "TR Dequeue Pointer:",IDC_STATIC,240,233,81,8 + EDITTEXT IDC_CONTEXT_TR_DEQUEUE_PTR,324,233,82,12,ES_RIGHT | + ES_AUTOHSCROLL + PUSHBUTTON ">",IDC_CONTEXT_STREAM_CONTEXT,407,233,11,12,WS_DISABLED + CONTROL "DCS",IDC_CONTEXT_DCS,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,280,248,89,10 + RTEXT "Max ESIT Payload Lo:",IDC_STATIC,232,261,89,8 + EDITTEXT IDC_CONTEXT_MAX_ESIT_LO,324,260,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "Average TRB Length:",IDC_STATIC,240,274,81,8 + EDITTEXT IDC_CONTEXT_AVERAGE_LEN,324,273,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [17-14h]:",IDC_STATIC,240,292,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_0,324,289,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [1B-18h]:",IDC_STATIC,240,305,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_1,324,302,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [1F-1Ch]:",IDC_STATIC,240,320,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_2,324,317,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO [23-20h]:",IDC_STATIC,240,334,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_3,324,331,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [27-24h]:",IDC_STATIC,240,348,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_4,324,345,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [2B-28h]:",IDC_STATIC,240,361,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_5,324,358,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [2F-2Ch]:",IDC_STATIC,240,376,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_6,324,373,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [33-30h]:",IDC_STATIC,240,390,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_7,324,387,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [37-34h]:",IDC_STATIC,240,404,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_8,324,401,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [3B-38h]:",IDC_STATIC,240,417,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_9,324,414,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + RTEXT "RsvdO [3F-3Ch]:",IDC_STATIC,240,432,81,8 + EDITTEXT IDC_CONTEXT_RSVDO_EP_10,324,429,82,12,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + PUSHBUTTON "<<",IDC_CONTEXT_PREV,305,53,17,11 + EDITTEXT IDC_CONTEXT_OF_STR,325,52,73,12,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON ">>",IDC_CONTEXT_NEXT,401,53,17,11 + PUSHBUTTON "Apply",ID_APPLY,380,72,35,11,WS_DISABLED + DEFPUSHBUTTON "OK",IDOK,371,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,371,24,50,14 +END + +USB_DEBUG_XHCI_DLG_STR_CONTEXT DIALOG DISCARDABLE 0, 0, 215, 177 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "String Context" +FONT 8, "Helv" +BEGIN + DEFPUSHBUTTON "OK",IDOK,157,9,50,14 + PUSHBUTTON "Cancel",IDCANCEL,157,27,50,14 + PUSHBUTTON "Apply",ID_APPLY,47,50,35,11,WS_DISABLED + PUSHBUTTON "<<",IDC_CONTEXT_PREV,93,50,17,11 + EDITTEXT IDC_CONTEXT_OF_STR,113,50,73,12,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON ">>",IDC_CONTEXT_NEXT,189,50,17,11 + GROUPBOX "Stream Context",IDC_STATIC,9,64,198,105 + RTEXT "TR Dequeue Pointer:",IDC_STATIC,18,77,88,8 + EDITTEXT IDC_STR_CONTEXT_DQPTR,111,76,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "SCT:",IDC_STATIC,41,92,65,8 + EDITTEXT IDC_STR_CONTEXT_SCT,111,91,45,12,ES_RIGHT | + ES_AUTOHSCROLL + EDITTEXT IDC_CONTEXT_SCT_STR,159,92,45,11,ES_CENTER | + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER, + WS_EX_STATICEDGE + CONTROL "DCS",IDC_STR_CONTEXT_DCS,"Button",BS_AUTOCHECKBOX | + BS_LEFTTEXT | BS_RIGHT | WS_TABSTOP,67,107,89,10 + RTEXT "Stopped EDTLA:",IDC_STATIC,18,120,88,8 + EDITTEXT IDC_STR_CONTEXT_STOPPED,111,119,82,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO:",IDC_STATIC,41,135,65,8 + EDITTEXT IDC_STR_CONTEXT_RSVDO_0,111,134,45,12,ES_RIGHT | + ES_AUTOHSCROLL + RTEXT "RsvdO:",IDC_STATIC,41,149,65,8 + EDITTEXT IDC_STR_CONTEXT_RSVDO_1,111,149,82,12,ES_RIGHT | + ES_AUTOHSCROLL +END + +