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)

Details

Provenance
brooksAuthored on Dec 17 2021, 9:28 PM
Parents
rG45b48cbc2b58: usb: real freebsd32 support for most ioctls
Branches
Unknown
Tags
Unknown