Skip to content

osrusbfx2 step5: Add 40+ uncovered USB DDIs and fix URB allocation bug#1361

Open
limitedge wants to merge 1 commit intomicrosoft:mainfrom
limitedge:fix/osrfx2-usb-ddi-coverage
Open

osrusbfx2 step5: Add 40+ uncovered USB DDIs and fix URB allocation bug#1361
limitedge wants to merge 1 commit intomicrosoft:mainfrom
limitedge:fix/osrfx2-usb-ddi-coverage

Conversation

@limitedge
Copy link

This PR extends the wdf_osrfx2_lab/kmdf/step5 sample to demonstrate 40+ previously uncovered USB DDIs from wdfusb.h and usbdlib.h, and adds the missing IOCTLs needed by the test app.

Bug Fix

  • Fix BSOD 0x144 (BUGCODE_USB_DRIVER): Replaced stack-allocated URBs with USBD_UrbAllocate-allocated URBs for WdfUsbTargetDeviceSendUrbSynchronously and WdfUsbTargetDeviceFormatRequestForUrb, as required by USBD_CLIENT_CONTRACT_VERSION_602.

New DDIs Covered — wdfusb.h (19)

DDI Usage
WdfUsbInterfaceGetNumEndpoints Query endpoint count on current alternate setting
WdfUsbInterfaceGetEndpointInformation Retrieve endpoint descriptor info
WdfUsbTargetPipeGetType Identify pipe type (bulk/interrupt/iso)
WDF_USB_PIPE_DIRECTION_IN / _OUT Check pipe direction
WdfUsbTargetDeviceAllocAndQueryString Retrieve USB string descriptor
WdfUsbTargetDeviceSendUrbSynchronously Send raw URB synchronously
WdfUsbTargetDeviceFormatRequestForUrb Format request for async URB submission
WdfUsbTargetDeviceFormatRequestForString Format request for string descriptor
WdfUsbTargetDeviceFormatRequestForCyclePort Cycle the USB port
WdfUsbTargetPipeFormatRequestForReset Reset a USB pipe
WdfUsbTargetPipeFormatRequestForAbort Abort pending pipe transfers
WdfUsbTargetPipeWriteSynchronously Synchronous bulk write
WDF_USB_CONTROL_SETUP_PACKET_INIT Initialize raw control setup packet
WDF_USB_CONTROL_SETUP_PACKET_INIT_GET_STATUS Build GET_STATUS request
WDF_USB_CONTROL_SETUP_PACKET_INIT_FEATURE Build SET/CLEAR_FEATURE request
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_DECONFIG Build deconfigure params
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_URB Build select-config-by-URB params
WDF_USB_INTERFACE_SELECT_SETTING_PARAMS_INIT_URB Build select-interface-by-URB params
WdfUsbTargetDeviceWdmGetConfigurationHandle Get WDM config handle from WDF USB device

New DDIs Covered — usbdlib.h (13)

DDI Usage
USBD_UrbAllocate / USBD_UrbFree Modern URB allocation/deallocation
USBD_IsochUrbAllocate Allocate isochronous URB
USBD_SelectConfigUrbAllocateAndBuild Build select-configuration URB
USBD_SelectInterfaceUrbAllocateAndBuild Build select-interface URB
USBD_AssignUrbToIoStackLocation Assign URB to IRP stack (v602 pattern)
USBD_CloseHandle Close USBD handle
USBD_IsInterfaceVersionSupported Query USBD interface version support
USBD_GetInterfaceLength Get interface descriptor length
USBD_GetPdoRegistryParameter Read device registry parameter
USBD_CreateConfigurationRequestEx Legacy config request creation
USBD_ValidateConfigurationDescriptor Validate config descriptor
USBD_ParseConfigurationDescriptorEx Parse config descriptor for interfaces
GET_ISO_URB_SIZE / UsbBuildGetStatusRequest URB helper macros

New IOCTLs for Test App Compatibility (8)

  • IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY — Read LED bar graph state
  • IOCTL_OSRUSBFX2_READ_SWITCHES — Read DIP switch state
  • IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY — Read 7-segment display
  • IOCTL_OSRUSBFX2_SET_7_SEGMENT_DISPLAY — Set 7-segment display
  • IOCTL_OSRUSBFX2_GET_CONFIG_DESCRIPTOR — Retrieve USB config descriptor
  • IOCTL_OSRUSBFX2_RESET_DEVICE — Reset USB port
  • IOCTL_OSRUSBFX2_REENUMERATE_DEVICE — Force device re-enumeration
  • IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE — Stub (returns STATUS_NOT_SUPPORTED)

Testing

  • Built and tested on ARM64 (Qualcomm) with OSR USB-FX2 LK hardware
  • All test app interactive options (1-6, 8-11) verified working
  • No bugchecks or driver errors

- Fix BSOD 0x144: Use USBD_UrbAllocate instead of stack-allocated URBs
  for USBD_CLIENT_CONTRACT_VERSION_602 compliance
- Add GET_BAR_GRAPH_DISPLAY, READ_SWITCHES, GET/SET_7_SEGMENT_DISPLAY,
  GET_CONFIG_DESCRIPTOR, RESET_DEVICE, REENUMERATE_DEVICE IOCTLs
- Add vendor command defines and BAR_GRAPH_STATE/SWITCH_STATE structures
- Renumber custom DDI-coverage IOCTLs to avoid index collisions
- Tested on ARM64 with OSR USB-FX2 LK hardware
@limitedge limitedge requested a review from a team as a code owner March 24, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant