HomeFreeBSD

usb: add 32-bit compat for FIFOs

Description

usb: add 32-bit compat for FIFOs

Unlike most 32-bit compatability code, this isn't just a simple thunk
in the ioctl code. An ioctl (USB_FS_INIT) is used to install a
pointer to an array of usb_fs_endpoint structs which are then used
by the ugen fifo code. These struct contains an array of pointers
which requires translation. We change the interfaces around
struct usb_fs_endpoint as follows:

  • We store the size of struct usb_fs_endpoint in struct usb_fifo in the USB_FS_INIT handler so we know the ABI of the userspace array.
  • APIs to manipulate userspace struct usb_fs_endpoint objects now take a struct usb_fifo and an index rather than a pointer to the object. This allows most code to remain oblivious to the different struct usb_fs_endpoint sizes.
  • Add ugen_fs_copyin() which copies the struct usb_fs_endpoint from userspace, thunking it to the native size if required.
  • Uses of struct usb_fs_endpoint's ppBuffer member are now via ugen_fs_getbuffer() which produces a native pointer.
  • Updates to userspace are now handled by ugen_fs_update().

For clarity, single, fixed-sized members now are accessed with
fueword/suword rather than copyin/copyout.

Reviewed by: hselasky, jrtc27 (prior version)

(cherry picked from commit 0ec590d24e415dd36e38648630a0b963412ad87e)
(cherry picked from commit 8b60419b798ae9049988c529e6af3f313a5cce55)

Details

Provenance
brooksAuthored on Dec 17 2021, 9:28 PM
hselaskyCommitted on Apr 30 2023, 6:56 AM
Parents
rG8ff5099a7932: libusb(3): Implement libusb_init_context() and the needed structures and…
Branches
Unknown
Tags
Unknown