aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2015-09-14 17:52:25 +0100
committerMichael Brown <mcb30@ipxe.org>2015-09-14 21:56:40 +0100
commit668dc73d526fa67957b9c10100f9ca5f2ab60522 (patch)
treecf6887506d5ac016fd04497cbd568463292903de /src/include
parent549a0caabb2f239fc702ccea3c1825518e13d121 (diff)
downloadipxe-668dc73d526fa67957b9c10100f9ca5f2ab60522.zip
ipxe-668dc73d526fa67957b9c10100f9ca5f2ab60522.tar.gz
ipxe-668dc73d526fa67957b9c10100f9ca5f2ab60522.tar.bz2
[usb] Allow for wildcard USB class IDs
Make the class ID a property of the USB driver (rather than a property of the USB device ID), and allow USB drivers to specify a wildcard ID for any of the three component IDs (class, subclass, or protocol). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/usb.h45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/include/ipxe/usb.h b/src/include/ipxe/usb.h
index 8fee00e..b3ce7b7 100644
--- a/src/include/ipxe/usb.h
+++ b/src/include/ipxe/usb.h
@@ -615,6 +615,14 @@ extern int usb_prefill ( struct usb_endpoint *ep );
extern int usb_refill ( struct usb_endpoint *ep );
extern void usb_flush ( struct usb_endpoint *ep );
+/** A USB class descriptor */
+union usb_class_descriptor {
+ /** Class */
+ struct usb_class class;
+ /** Scalar value */
+ uint32_t scalar;
+};
+
/**
* A USB function descriptor
*
@@ -627,7 +635,7 @@ struct usb_function_descriptor {
/** Product ID */
uint16_t product;
/** Class */
- struct usb_class class;
+ union usb_class_descriptor class;
/** Number of interfaces */
unsigned int count;
};
@@ -1298,19 +1306,50 @@ struct usb_device_id {
uint16_t vendor;
/** Product ID */
uint16_t product;
- /** Class */
- struct usb_class class;
};
/** Match-anything ID */
#define USB_ANY_ID 0xffff
+/** A USB class ID */
+struct usb_class_id {
+ /** Class */
+ union usb_class_descriptor class;
+ /** Class mask */
+ union usb_class_descriptor mask;
+};
+
+/** Construct USB class ID
+ *
+ * @v base Base class code (or USB_ANY_ID)
+ * @v subclass Subclass code (or USB_ANY_ID)
+ * @v protocol Protocol code (or USB_ANY_ID)
+ */
+#define USB_CLASS_ID( base, subclass, protocol ) { \
+ .class = { \
+ .class = { \
+ ( (base) & 0xff ), \
+ ( (subclass) & 0xff ), \
+ ( (protocol) & 0xff ), \
+ }, \
+ }, \
+ .mask = { \
+ .class = { \
+ ( ( (base) == USB_ANY_ID ) ? 0x00 : 0xff ), \
+ ( ( (subclass) == USB_ANY_ID ) ? 0x00 : 0xff ), \
+ ( ( (protocol) == USB_ANY_ID ) ? 0x00 : 0xff ), \
+ }, \
+ }, \
+ }
+
/** A USB driver */
struct usb_driver {
/** USB ID table */
struct usb_device_id *ids;
/** Number of entries in ID table */
unsigned int id_count;
+ /** Class ID */
+ struct usb_class_id class;
/** Driver score
*
* This is used to determine the preferred configuration for a