Giter Site home page Giter Site logo

usbpower's Introduction

usbpower

This is a try to develop a Win upper filter driver to patch USB support adding Port-Power control feature to powered USB HUBs which support it (very few). The target is to allow uhubctl https://github.com/mvp/uhubctl to work on Windows.

This is my first driver so it will take me some time. Here below and in HOWTO directory it is what I am researching.

Background

Power per port means real switch off +5V in the USB ports.

It is included in USB 2.0 specification as a must for powered hubs (hubs with power supply), not included in laters specifications, and included again in USB 3.2 specification for all USB-C connectors.

Unfortunately there is no support to use Power per port in Windows due to a design decission.

HOWTO

KEYS:

  • = TODO (in progress, feel free to help creating an issue!
  • = Done

KNOWLEDGE:

FACTS

  • In USB messages are send via MessagePipes to Endpoints
  • Default Control Pipe to Endpoint Zero is owned and managed by USBD (USB Driver)
  • We need USB Control Transfer to check and use power per port
  • User space application calls IOCTLs to comunicate with Device Driver (or Device Driver Filter).
  • There are no IOCTLs to send USB Control Transfer from user space (application)
  • The most similar are IRP_MJ_DEVICE_CONTROL:
    • IOCTL_WRITE_REGISTERS, IOCTL_READ_REGISTERS, IOCTL_SEND_USB_REQUEST: all of them for imaging devices
    • IOCTL_USB_USER_REQUEST - USBUSER_PASS_THRU: in disuse and it looks like only allowed to admin users
  • There is a IOCTL to send USB packets but it can be used only from kernel mode (driver) it is IOCTL_INTERNAL_USB_SUBMIT_URB

INFO drivers

INFO WDF from OSR

INFO WDM (Windows Driver Model?):

I/O Control Operations: https://www-user.tu-chemnitz.de/~heha/oney_wdm/ch09d.htm

Working with the Bus Driver: https://www-user.tu-chemnitz.de/~heha/oney_wdm/ch11c.htm Control Transfers: https://www-user.tu-chemnitz.de/~heha/oney_wdm/ch11b.htm

INFO USB:

What is libusb?: https://unboxnbeyond.wordpress.com/2014/03/15/what-is-libusb/

USB made simple: http://www.usbmadesimple.co.uk/

USB specifications docs: http://www.usb.org/developers/docs/

MS WDK FORUM: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=wdk

WINDOWS API:

DeviceIoControl function: https://msdn.microsoft.com/es-es/library/windows/desktop/aa363216(v=vs.85).aspx

Calling DeviceIoControl: https://msdn.microsoft.com/es-es/library/windows/desktop/aa363147(v=vs.85).aspx

Defining I/O Control Codes: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/defining-i-o-control-codes

USB IOCTLs: https://msdn.microsoft.com/en-us/library/windows/hardware/ff537421(v=vs.85).aspx

Windows IOCTL Reference: http://www.ioctls.net/

IRP_MJ_DEVICE_CONTROL: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/irp-mj-device-control

IOCTL_INTERNAL_USB_SUBMIT_URB (real USB Request Block (packet sent) but only form kernel mode (driver) no from user space: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/usbioctl/ni-usbioctl-ioctl_internal_usb_submit_urb

IOCTL_USB_USER_REQUEST control code: https://msdn.microsoft.com/en-us/library/windows/hardware/ff537344(v=vs.85).aspx

IOCTL_SEND_USB_REQUEST IOCTL: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/usbscan/ni-usbscan-ioctl_send_usb_request

IOCTL_WRITE_REGISTERS IOCTL: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/usbscan/ni-usbscan-ioctl_write_registers

IOCTL_READ_REGISTERS IOCTL: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/usbscan/ni-usbscan-ioctl_read_registers

usbscan.h header: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/usbscan/

EXAMPLES:

UsbDk direct and exclusive access to USB devices by detaching those from Windows:

libusbK is a complete driver/library solution for vendor class usb device interfaces:

Simple URB (USB Request Block) Monitor:

usbpower's People

Contributors

manel3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.