usbmsc.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* USB mass-storage class driver (Bulk-Only Transport + SCSI).
  2. *
  3. * Devices are registered as `usb0..` in the block-device registry. Only the
  4. * controllers with a bulk-transfer path work: EHCI (high-speed) and xHCI
  5. * (USB2 root ports). UHCI/OHCI leave bulk_in/bulk_out NULL, so a stick on a
  6. * full/low-speed companion controller is not usable.
  7. */
  8. #ifndef USB_MSC_H
  9. #define USB_MSC_H
  10. /* Register the device probe; call before the first USB bus scan. */
  11. void usbmsc_register(void);
  12. /* Add the currently present MSC devices to the blkdev registry. Called at
  13. * the end of blk_scan(); the USB bus scan itself runs earlier at boot. */
  14. void usbmsc_blk_scan(void);
  15. /* Best-effort boot mounting: the first media read gets one bounded attempt
  16. * instead of the normal retry chain, so a stuck device cannot hold
  17. * vfs_scan_busy behind the boot scan. A later `storage` rescan uses the
  18. * full recovery path again. */
  19. void usbmsc_set_probe_only(int on);
  20. /* A full storage rescan gives every present device its long first-media-read
  21. * deadline again (the boot background probe consumes it once). */
  22. void usbmsc_begin_full_scan(void);
  23. /* Block I/O for BLK_USB devices (unit = usbmsc slot index). */
  24. int usbmsc_read(unsigned int unit, unsigned int lba, void *buf,
  25. unsigned int count);
  26. int usbmsc_write(unsigned int unit, unsigned int lba, const void *buf,
  27. unsigned int count);
  28. int usbmsc_flush(unsigned int unit);
  29. #endif