|
@ -22,8 +22,10 @@ |
|
|
#define USB_DESCRIPTORS_H |
|
|
#define USB_DESCRIPTORS_H |
|
|
|
|
|
|
|
|
#include <libopencm3/usb/usbd.h> |
|
|
#include <libopencm3/usb/usbd.h> |
|
|
|
|
|
#include <libopencm3/usb/bos.h> |
|
|
#include <libopencm3/usb/cdc.h> |
|
|
#include <libopencm3/usb/cdc.h> |
|
|
#include <libopencm3/usb/dfu.h> |
|
|
#include <libopencm3/usb/dfu.h> |
|
|
|
|
|
#include <libopencm3/usb/microsoft.h> |
|
|
|
|
|
|
|
|
#include "usb.h" |
|
|
#include "usb.h" |
|
|
#include "serialno.h" |
|
|
#include "serialno.h" |
|
@ -35,7 +37,7 @@ |
|
|
static const struct usb_device_descriptor dev_desc = { |
|
|
static const struct usb_device_descriptor dev_desc = { |
|
|
.bLength = USB_DT_DEVICE_SIZE, |
|
|
.bLength = USB_DT_DEVICE_SIZE, |
|
|
.bDescriptorType = USB_DT_DEVICE, |
|
|
.bDescriptorType = USB_DT_DEVICE, |
|
|
.bcdUSB = 0x0200, |
|
|
.bcdUSB = 0x0201, |
|
|
.bDeviceClass = 0xEF, /* Miscellaneous Device */ |
|
|
.bDeviceClass = 0xEF, /* Miscellaneous Device */ |
|
|
.bDeviceSubClass = 2, /* Common Class */ |
|
|
.bDeviceSubClass = 2, /* Common Class */ |
|
|
.bDeviceProtocol = 1, /* Interface Association */ |
|
|
.bDeviceProtocol = 1, /* Interface Association */ |
|
@ -46,7 +48,7 @@ static const struct usb_device_descriptor dev_desc = { |
|
|
#endif |
|
|
#endif |
|
|
.idVendor = 0x1D50, |
|
|
.idVendor = 0x1D50, |
|
|
.idProduct = 0x6018, |
|
|
.idProduct = 0x6018, |
|
|
.bcdDevice = 0x0100, |
|
|
.bcdDevice = 0x0108, |
|
|
.iManufacturer = 1, |
|
|
.iManufacturer = 1, |
|
|
.iProduct = 2, |
|
|
.iProduct = 2, |
|
|
.iSerialNumber = 3, |
|
|
.iSerialNumber = 3, |
|
@ -406,9 +408,131 @@ static const char *const usb_strings[] = { |
|
|
"Black Magic GDB Server", |
|
|
"Black Magic GDB Server", |
|
|
"Black Magic UART Port", |
|
|
"Black Magic UART Port", |
|
|
"Black Magic DFU", |
|
|
"Black Magic DFU", |
|
|
#if defined(PLATFORM_HAS_TRACESWO) |
|
|
#ifdef PLATFORM_HAS_TRACESWO |
|
|
"Black Magic Trace Capture", |
|
|
"Black Magic Trace Capture", |
|
|
#endif |
|
|
#endif |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#define DESCRIPTOR_SETS 1U |
|
|
|
|
|
|
|
|
|
|
|
static const struct { |
|
|
|
|
|
microsoft_os_feature_compatible_id_descriptor driver_binding; |
|
|
|
|
|
} microsoft_os_dfu_if_features = { |
|
|
|
|
|
.driver_binding = |
|
|
|
|
|
{ |
|
|
|
|
|
.header = |
|
|
|
|
|
{ |
|
|
|
|
|
.wLength = MICROSOFT_OS_FEATURE_COMPATIBLE_ID_DESCRIPTOR_SIZE, |
|
|
|
|
|
.wDescriptorType = MICROSOFT_OS_FEATURE_COMPATIBLE_ID, |
|
|
|
|
|
}, |
|
|
|
|
|
.compatible_id = MICROSOFT_OS_COMPATIBLE_ID_WINUSB, |
|
|
|
|
|
.sub_compatible_id = MICROSOFT_OS_COMPATIBLE_ID_NONE, |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef PLATFORM_HAS_TRACESWO |
|
|
|
|
|
static const struct { |
|
|
|
|
|
microsoft_os_feature_compatible_id_descriptor driver_binding; |
|
|
|
|
|
} microsoft_os_trace_if_features = { |
|
|
|
|
|
.driver_binding = |
|
|
|
|
|
{ |
|
|
|
|
|
.header = |
|
|
|
|
|
{ |
|
|
|
|
|
.wLength = MICROSOFT_OS_FEATURE_COMPATIBLE_ID_DESCRIPTOR_SIZE, |
|
|
|
|
|
.wDescriptorType = MICROSOFT_OS_FEATURE_COMPATIBLE_ID, |
|
|
|
|
|
}, |
|
|
|
|
|
.compatible_id = MICROSOFT_OS_COMPATIBLE_ID_WINUSB, |
|
|
|
|
|
.sub_compatible_id = MICROSOFT_OS_COMPATIBLE_ID_NONE, |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static const microsoft_os_descriptor_function_subset_header microsoft_os_descriptor_function_subsets[] = { |
|
|
|
|
|
{ |
|
|
|
|
|
.wLength = MICROSOFT_OS_DESCRIPTOR_FUNCTION_SUBSET_HEADER_SIZE, |
|
|
|
|
|
.wDescriptorType = MICROSOFT_OS_SUBSET_HEADER_FUNCTION, |
|
|
|
|
|
.bFirstInterface = DFU_IF_NO, |
|
|
|
|
|
.bReserved = 0, |
|
|
|
|
|
.wTotalLength = 0, |
|
|
|
|
|
|
|
|
|
|
|
.feature_descriptors = µsoft_os_dfu_if_features, |
|
|
|
|
|
.num_feature_descriptors = 1, |
|
|
|
|
|
}, |
|
|
|
|
|
#ifdef PLATFORM_HAS_TRACESWO |
|
|
|
|
|
{ |
|
|
|
|
|
.wLength = MICROSOFT_OS_DESCRIPTOR_FUNCTION_SUBSET_HEADER_SIZE, |
|
|
|
|
|
.wDescriptorType = MICROSOFT_OS_SUBSET_HEADER_FUNCTION, |
|
|
|
|
|
.bFirstInterface = TRACE_IF_NO, |
|
|
|
|
|
.bReserved = 0, |
|
|
|
|
|
.wTotalLength = 0, |
|
|
|
|
|
|
|
|
|
|
|
.feature_descriptors = µsoft_os_trace_if_features, |
|
|
|
|
|
.num_feature_descriptors = 1, |
|
|
|
|
|
}, |
|
|
|
|
|
#endif |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const microsoft_os_descriptor_config_subset_header microsoft_os_descriptor_config_subset = { |
|
|
|
|
|
.wLength = MICROSOFT_OS_DESCRIPTOR_CONFIG_SUBSET_HEADER_SIZE, |
|
|
|
|
|
.wDescriptorType = MICROSOFT_OS_SUBSET_HEADER_CONFIGURATION, |
|
|
|
|
|
.bConfigurationValue = 1, |
|
|
|
|
|
.bReserved = 0, |
|
|
|
|
|
.wTotalLength = 0, |
|
|
|
|
|
|
|
|
|
|
|
.function_subset_headers = microsoft_os_descriptor_function_subsets, |
|
|
|
|
|
.num_function_subset_headers = ARRAY_LENGTH(microsoft_os_descriptor_function_subsets), |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const microsoft_os_descriptor_set_header microsoft_os_descriptor_sets[DESCRIPTOR_SETS] = { |
|
|
|
|
|
{ |
|
|
|
|
|
.wLength = MICROSOFT_OS_DESCRIPTOR_SET_HEADER_SIZE, |
|
|
|
|
|
.wDescriptorType = MICROSOFT_OS_SET_HEADER, |
|
|
|
|
|
.dwWindowsVersion = MICROSOFT_WINDOWS_VERSION_WINBLUE, |
|
|
|
|
|
.wTotalLength = 0, |
|
|
|
|
|
|
|
|
|
|
|
.vendor_code = 1, |
|
|
|
|
|
.num_config_subset_headers = 1, |
|
|
|
|
|
.config_subset_headers = µsoft_os_descriptor_config_subset, |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const microsoft_os_descriptor_set_information microsoft_os_descriptor_set_info = { |
|
|
|
|
|
.dwWindowsVersion = MICROSOFT_WINDOWS_VERSION_WINBLUE, |
|
|
|
|
|
.wMSOSDescriptorSetTotalLength = |
|
|
|
|
|
MICROSOFT_OS_DESCRIPTOR_SET_HEADER_SIZE + MICROSOFT_OS_DESCRIPTOR_CONFIG_SUBSET_HEADER_SIZE + |
|
|
|
|
|
#ifdef PLATFORM_HAS_TRACESWO |
|
|
|
|
|
MICROSOFT_OS_DESCRIPTOR_FUNCTION_SUBSET_HEADER_SIZE + MICROSOFT_OS_FEATURE_COMPATIBLE_ID_DESCRIPTOR_SIZE + |
|
|
|
|
|
#endif |
|
|
|
|
|
MICROSOFT_OS_DESCRIPTOR_FUNCTION_SUBSET_HEADER_SIZE + MICROSOFT_OS_FEATURE_COMPATIBLE_ID_DESCRIPTOR_SIZE, |
|
|
|
|
|
.bMS_VendorCode = 1, |
|
|
|
|
|
.bAltEnumCode = 0, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const struct { |
|
|
|
|
|
usb_platform_device_capability_descriptor platform_descriptor; |
|
|
|
|
|
} __attribute__((packed)) device_capability_descriptors = { |
|
|
|
|
|
.platform_descriptor = |
|
|
|
|
|
{ |
|
|
|
|
|
.device_capability_descriptor = |
|
|
|
|
|
{ |
|
|
|
|
|
.bLength = USB_DCT_PLATFORM_SIZE + MICROSOFT_OS_DESCRIPTOR_SET_INFORMATION_SIZE, |
|
|
|
|
|
.bDescriptorType = USB_DT_DEVICE_CAPABILITY, |
|
|
|
|
|
.bDevCapabilityType = USB_DCT_PLATFORM, |
|
|
|
|
|
}, |
|
|
|
|
|
.bReserved = 0, |
|
|
|
|
|
.PlatformCapabilityUUID = MICROSOFT_OS_DESCRIPTOR_PLATFORM_CAPABILITY_ID, |
|
|
|
|
|
|
|
|
|
|
|
.CapabilityData = µsoft_os_descriptor_set_info, |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const usb_bos_descriptor bos = { |
|
|
|
|
|
.bLength = USB_DT_BOS_SIZE, |
|
|
|
|
|
.bDescriptorType = USB_DT_BOS, |
|
|
|
|
|
.wTotalLength = 0, |
|
|
|
|
|
.bNumDeviceCaps = 1, |
|
|
|
|
|
|
|
|
|
|
|
.device_capability_descriptors = &device_capability_descriptors, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
#endif /*USB_DESCRIPTORS_H*/ |
|
|
#endif /*USB_DESCRIPTORS_H*/ |
|
|