- Export the USB device ID format to userspace tools.
MFC after: 14 days
This commit is contained in:
parent
4c8ffb2300
commit
1d63770b39
@ -42,6 +42,8 @@
|
||||
#include <sys/callout.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbdi.h>
|
||||
@ -144,3 +146,108 @@ usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id,
|
||||
}
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Export the USB device ID format we use to userspace tools.
|
||||
*------------------------------------------------------------------------*/
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define U16_XOR "8"
|
||||
#define U32_XOR "12"
|
||||
#define U64_XOR "56"
|
||||
#define U8_BITFIELD_XOR "7"
|
||||
#define U16_BITFIELD_XOR "15"
|
||||
#define U32_BITFIELD_XOR "31"
|
||||
#define U64_BITFIELD_XOR "63"
|
||||
#else
|
||||
#define U16_XOR "0"
|
||||
#define U32_XOR "0"
|
||||
#define U64_XOR "0"
|
||||
#define U8_BITFIELD_XOR "0"
|
||||
#define U16_BITFIELD_XOR "0"
|
||||
#define U32_BITFIELD_XOR "0"
|
||||
#define U64_BITFIELD_XOR "0"
|
||||
#endif
|
||||
|
||||
#if USB_HAVE_COMPAT_LINUX
|
||||
#define MFL_SIZE "1"
|
||||
#else
|
||||
#define MFL_SIZE "0"
|
||||
#endif
|
||||
|
||||
#ifdef KLD_MODULE
|
||||
static const char __section("bus_autoconf_format") __used usb_id_format[] = {
|
||||
|
||||
/* Declare that three different sections use the same format */
|
||||
|
||||
"usb_host_id{256,:}"
|
||||
"usb_device_id{256,:}"
|
||||
"usb_dual_id{256,:}"
|
||||
|
||||
/* List size of fields in the usb_device_id structure */
|
||||
|
||||
#if ULONG_MAX >= 0xFFFFFFFFUL
|
||||
"unused{0,8}"
|
||||
"unused{0,8}"
|
||||
"unused{0,8}"
|
||||
"unused{0,8}"
|
||||
#if ULONG_MAX >= 0xFFFFFFFFFFFFFFFFULL
|
||||
"unused{0,8}"
|
||||
"unused{0,8}"
|
||||
"unused{0,8}"
|
||||
"unused{0,8}"
|
||||
#endif
|
||||
#else
|
||||
#error "Please update code."
|
||||
#endif
|
||||
|
||||
"idVendor[0]{" U16_XOR ",8}"
|
||||
"idVendor[1]{" U16_XOR ",8}"
|
||||
"idProduct[0]{" U16_XOR ",8}"
|
||||
"idProduct[1]{" U16_XOR ",8}"
|
||||
"bcdDevice_lo[0]{" U16_XOR ",8}"
|
||||
"bcdDevice_lo[1]{" U16_XOR ",8}"
|
||||
"bcdDevice_hi[0]{" U16_XOR ",8}"
|
||||
"bcdDevice_hi[1]{" U16_XOR ",8}"
|
||||
|
||||
"bDeviceClass{0,8}"
|
||||
"bDeviceSubClass{0,8}"
|
||||
"bDeviceProtocol{0,8}"
|
||||
"bInterfaceClass{0,8}"
|
||||
"bInterfaceSubClass{0,8}"
|
||||
"bInterfaceProtocol{0,8}"
|
||||
|
||||
"mf_vendor{" U8_BITFIELD_XOR ",1}"
|
||||
"mf_product{" U8_BITFIELD_XOR ",1}"
|
||||
"mf_dev_lo{" U8_BITFIELD_XOR ",1}"
|
||||
"mf_dev_hi{" U8_BITFIELD_XOR ",1}"
|
||||
|
||||
"mf_dev_class{" U8_BITFIELD_XOR ",1}"
|
||||
"mf_dev_subclass{" U8_BITFIELD_XOR ",1}"
|
||||
"mf_dev_protocol{" U8_BITFIELD_XOR ",1}"
|
||||
"mf_int_class{" U8_BITFIELD_XOR ",1}"
|
||||
|
||||
"mf_int_subclass{" U8_BITFIELD_XOR ",1}"
|
||||
"mf_int_protocol{" U8_BITFIELD_XOR ",1}"
|
||||
"unused{" U8_BITFIELD_XOR ",6}"
|
||||
|
||||
"mfl_vendor{" U16_XOR "," MFL_SIZE "}"
|
||||
"mfl_product{" U16_XOR "," MFL_SIZE "}"
|
||||
"mfl_dev_lo{" U16_XOR "," MFL_SIZE "}"
|
||||
"mfl_dev_hi{" U16_XOR "," MFL_SIZE "}"
|
||||
|
||||
"mfl_dev_class{" U16_XOR "," MFL_SIZE "}"
|
||||
"mfl_dev_subclass{" U16_XOR "," MFL_SIZE "}"
|
||||
"mfl_dev_protocol{" U16_XOR "," MFL_SIZE "}"
|
||||
"mfl_int_class{" U16_XOR "," MFL_SIZE "}"
|
||||
|
||||
"mfl_int_subclass{" U16_XOR "," MFL_SIZE "}"
|
||||
"mfl_int_protocol{" U16_XOR "," MFL_SIZE "}"
|
||||
"unused{" U16_XOR "," MFL_SIZE "}"
|
||||
"unused{" U16_XOR "," MFL_SIZE "}"
|
||||
|
||||
"unused{" U16_XOR "," MFL_SIZE "}"
|
||||
"unused{" U16_XOR "," MFL_SIZE "}"
|
||||
"unused{" U16_XOR "," MFL_SIZE "}"
|
||||
"unused{" U16_XOR "," MFL_SIZE "}"
|
||||
};
|
||||
#endif
|
||||
|
@ -270,12 +270,15 @@ struct usb_device_id {
|
||||
uint8_t match_flag_product:1;
|
||||
uint8_t match_flag_dev_lo:1;
|
||||
uint8_t match_flag_dev_hi:1;
|
||||
|
||||
uint8_t match_flag_dev_class:1;
|
||||
uint8_t match_flag_dev_subclass:1;
|
||||
uint8_t match_flag_dev_protocol:1;
|
||||
uint8_t match_flag_int_class:1;
|
||||
|
||||
uint8_t match_flag_int_subclass:1;
|
||||
uint8_t match_flag_int_protocol:1;
|
||||
uint8_t match_flag_unused:6;
|
||||
|
||||
#if USB_HAVE_COMPAT_LINUX
|
||||
/* which fields to match against */
|
||||
@ -291,7 +294,10 @@ struct usb_device_id {
|
||||
#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
|
||||
#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
|
||||
#endif
|
||||
};
|
||||
} __aligned(32);
|
||||
|
||||
/* check that the size of the structure above is correct */
|
||||
extern char usb_device_id_assert[(sizeof(struct usb_device_id) == 32) ? 1 : -1];
|
||||
|
||||
#define USB_VENDOR(vend) \
|
||||
.match_flag_vendor = 1, .idVendor = (vend)
|
||||
|
Loading…
Reference in New Issue
Block a user