usb: Implemented support for sending the Microsoft OS-specific descriptor component of a platform capability descriptor
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
c1247110d8
commit
b7ddb7c7c0
@@ -87,6 +87,8 @@ typedef struct __attribute__((packed)) usb_bos_uuid {
|
|||||||
uint8_t e[6];
|
uint8_t e[6];
|
||||||
} usb_bos_uuid;
|
} usb_bos_uuid;
|
||||||
|
|
||||||
|
#define USB_BOS_UUID_SIZE sizeof(usb_bos_uuid)
|
||||||
|
|
||||||
typedef struct usb_device_capability_descriptor {
|
typedef struct usb_device_capability_descriptor {
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
@@ -125,6 +127,8 @@ typedef struct __attribute__((packed)) usb_platform_device_capability_descriptor
|
|||||||
usb_bos_uuid PlatformCapabilityUUID;
|
usb_bos_uuid PlatformCapabilityUUID;
|
||||||
|
|
||||||
/* Descriptor ends here. The following are used internally: */
|
/* Descriptor ends here. The following are used internally: */
|
||||||
|
/* This is a type-erased struct of the platform-specific capability data */
|
||||||
|
const void *CapabilityData;
|
||||||
} usb_platform_device_capability_descriptor;
|
} usb_platform_device_capability_descriptor;
|
||||||
|
|
||||||
#define USB_DCT_PLATFORM_SIZE 20U
|
#define USB_DCT_PLATFORM_SIZE 20U
|
||||||
|
|||||||
@@ -76,6 +76,17 @@ enum microsoft_registry_types {
|
|||||||
{0x65U, 0x9dU, 0x9eU, 0x64U, 0x8aU, 0x9fU}, \
|
{0x65U, 0x9dU, 0x9eU, 0x64U, 0x8aU, 0x9fU}, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MICROSOFT_WINDOWS_VERSION_WINBLUE 0x06030000
|
||||||
|
|
||||||
|
typedef struct microsoft_os_descriptor_set_information {
|
||||||
|
uint32_t dwWindowsVersion;
|
||||||
|
uint16_t wMSOSDescriptorSetTotalLength;
|
||||||
|
uint8_t bMS_VendorCode;
|
||||||
|
uint8_t bAltEnumCode;
|
||||||
|
} microsoft_os_descriptor_set_information;
|
||||||
|
|
||||||
|
#define MICROSOFT_OS_DESCRIPTOR_SET_INFORMATION_SIZE sizeof(microsoft_os_descriptor_set_information)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|||||||
@@ -38,8 +38,12 @@ LGPL License Terms @ref lgpl_license
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libopencm3/usb/usbd.h>
|
#include <libopencm3/usb/usbd.h>
|
||||||
#include <libopencm3/usb/bos.h>
|
#include <libopencm3/usb/bos.h>
|
||||||
|
#include <libopencm3/usb/microsoft.h>
|
||||||
#include "usb_private.h"
|
#include "usb_private.h"
|
||||||
|
|
||||||
|
static const usb_bos_uuid microsoft_os_descriptor_platform_capability_id =
|
||||||
|
MICROSOFT_OS_DESCRIPTOR_PLATFORM_CAPABILITY_ID;
|
||||||
|
|
||||||
int usbd_register_set_config_callback(usbd_device *usbd_dev,
|
int usbd_register_set_config_callback(usbd_device *usbd_dev,
|
||||||
usbd_set_config_callback callback)
|
usbd_set_config_callback callback)
|
||||||
{
|
{
|
||||||
@@ -149,8 +153,14 @@ static uint16_t build_devcap_platform(const usb_platform_device_capability_descr
|
|||||||
len -= count;
|
len -= count;
|
||||||
const uint16_t total = count;
|
const uint16_t total = count;
|
||||||
|
|
||||||
|
if (!memcmp(&plat->PlatformCapabilityUUID, µsoft_os_descriptor_platform_capability_id, USB_BOS_UUID_SIZE)) {
|
||||||
|
const microsoft_os_descriptor_set_information *info = plat->CapabilityData;
|
||||||
|
count = MIN(len, MICROSOFT_OS_DESCRIPTOR_SET_INFORMATION_SIZE);
|
||||||
|
memcpy(buf + total, info, count);
|
||||||
|
return total + count;
|
||||||
|
}
|
||||||
|
|
||||||
return total;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This can return 0 to indicate an error in the descriptor */
|
/* This can return 0 to indicate an error in the descriptor */
|
||||||
|
|||||||
Reference in New Issue
Block a user