aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/usb/usb_ioctl.h
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2021-12-17 21:28:13 +0000
committerBrooks Davis <brooks@FreeBSD.org>2021-12-17 21:28:13 +0000
commit45b48cbc2b5819cd6e3dee3632d66e55d5d7c101 (patch)
tree09688edfee03fb45f8d8d6de0d0316ab9b62fd50 /sys/dev/usb/usb_ioctl.h
parent16f02a4cb4594326b6687eeedde5feb9cb40cba4 (diff)
downloadsrc-45b48cbc2b5819cd6e3dee3632d66e55d5d7c101.tar.gz
src-45b48cbc2b5819cd6e3dee3632d66e55d5d7c101.zip
usb: real freebsd32 support for most ioctls
Use thunks or alternative access methods to support ioctls without the COMPAT_32BIT hacks that store pointers in uint64_t's on 32-bit platforms. This should allow a normal i386 libusb to work. On CheriBSD, the sizes of the structs will differ between CheriABI (the default) and freebsd64 no matter what so we need proper compat support there. This change paves the way. Reviewed by: hselasky, jrtc27 (prior version)
Diffstat (limited to 'sys/dev/usb/usb_ioctl.h')
-rw-r--r--sys/dev/usb/usb_ioctl.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/sys/dev/usb/usb_ioctl.h b/sys/dev/usb/usb_ioctl.h
index 39783305ca6b..9d35588f1138 100644
--- a/sys/dev/usb/usb_ioctl.h
+++ b/sys/dev/usb/usb_ioctl.h
@@ -346,4 +346,61 @@ struct usb_gen_quirk {
#define USB_DEV_QUIRK_ADD _IOW ('Q', 2, struct usb_gen_quirk)
#define USB_DEV_QUIRK_REMOVE _IOW ('Q', 3, struct usb_gen_quirk)
+#ifdef _KERNEL
+#ifdef COMPAT_FREEBSD32
+
+struct usb_read_dir32 {
+ uint32_t urd_data;
+ uint32_t urd_startentry;
+ uint32_t urd_maxlen;
+};
+#define USB_READ_DIR32 \
+ _IOC_NEWTYPE(USB_READ_DIR, struct usb_read_dir32)
+
+struct usb_ctl_request32 {
+ uint32_t ucr_data;
+ uint16_t ucr_flags;
+ uint16_t ucr_actlen;
+ uint8_t ucr_addr;
+ struct usb_device_request ucr_request;
+};
+#define USB_REQUEST32 _IOC_NEWTYPE(USB_REQUEST, struct usb_ctl_request32)
+#define USB_DO_REQUEST32 _IOC_NEWTYPE(USB_DO_REQUEST, struct usb_ctl_request32)
+
+struct usb_gen_descriptor32 {
+ uint32_t ugd_data; /* void * */
+ uint16_t ugd_lang_id;
+ uint16_t ugd_maxlen;
+ uint16_t ugd_actlen;
+ uint16_t ugd_offset;
+ uint8_t ugd_config_index;
+ uint8_t ugd_string_index;
+ uint8_t ugd_iface_index;
+ uint8_t ugd_altif_index;
+ uint8_t ugd_endpt_index;
+ uint8_t ugd_report_type;
+ uint8_t reserved[8];
+};
+
+#define USB_GET_REPORT_DESC32 \
+ _IOC_NEWTYPE(USB_GET_REPORT_DESC, struct usb_gen_descriptor32)
+#define USB_GET_REPORT32 \
+ _IOC_NEWTYPE(USB_GET_REPORT, struct usb_gen_descriptor32)
+#define USB_SET_REPORT32 \
+ _IOC_NEWTYPE(USB_SET_REPORT, struct usb_gen_descriptor32)
+#define USB_GET_FULL_DESC32 \
+ _IOC_NEWTYPE(USB_GET_FULL_DESC, struct usb_gen_descriptor32)
+#define USB_GET_STRING_DESC32 \
+ _IOC_NEWTYPE(USB_GET_STRING_DESC, struct usb_gen_descriptor32)
+#define USB_GET_IFACE_DRIVER32 \
+ _IOC_NEWTYPE(USB_GET_IFACE_DRIVER, struct usb_gen_descriptor32)
+
+void usb_gen_descriptor_from32(struct usb_gen_descriptor *ugd,
+ const struct usb_gen_descriptor32 *ugd32);
+void update_usb_gen_descriptor32(struct usb_gen_descriptor32 *ugd32,
+ struct usb_gen_descriptor *ugd);
+
+#endif /* COMPAT_FREEBSD32 */
+#endif /* _KERNEL */
+
#endif /* _USB_IOCTL_H_ */