summaryrefslogtreecommitdiff
path: root/common/core
diff options
context:
space:
mode:
Diffstat (limited to 'common/core')
-rw-r--r--common/core/inc/ux_api.h78
-rw-r--r--common/core/inc/ux_system.h9
-rw-r--r--common/core/src/ux_device_stack_descriptor_send.c140
-rw-r--r--common/core/src/ux_hcd_sim_host_request_bulk_transfer.c9
-rw-r--r--common/core/src/ux_system_initialize.c9
5 files changed, 191 insertions, 54 deletions
diff --git a/common/core/inc/ux_api.h b/common/core/inc/ux_api.h
index d0f1f93..872f6cc 100644
--- a/common/core/inc/ux_api.h
+++ b/common/core/inc/ux_api.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* ux_api.h PORTABLE C */
-/* 6.1.2 */
+/* 6.1.3 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -68,6 +68,9 @@
/* modified HCD status code, */
/* fixed compile warnings, */
/* resulting in version 6.1.2 */
+/* 12-31-2020 Chaoqiong Xiao Modified comment(s), */
+/* added BOS support, */
+/* resulting in version 6.1.3 */
/* */
/**************************************************************************/
@@ -202,7 +205,7 @@ typedef signed char SCHAR;
#define AZURE_RTOS_USBX
#define USBX_MAJOR_VERSION 6
#define USBX_MINOR_VERSION 1
-#define USBX_PATCH_VERSION 2
+#define USBX_PATCH_VERSION 3
/* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */
@@ -945,9 +948,28 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL
#define UX_OTHER_SPEED_DESCRIPTOR_ITEM 7u
#define UX_OTG_DESCRIPTOR_ITEM 9u
#define UX_INTERFACE_ASSOCIATION_DESCRIPTOR_ITEM 11u
+#define UX_BOS_DESCRIPTOR_ITEM 15u
+#define UX_DEVICE_CAPABILITY_DESCRIPTOR_ITEM 16u
#define UX_DFU_FUNCTIONAL_DESCRIPTOR_ITEM 0x21u
#define UX_HUB_DESCRIPTOR_ITEM 0x29u
+#define UX_CAPABILITY_WIRELESS_USB 0x01u
+#define UX_CAPABILITY_USB_2_0_EXTENSION 0x02u
+#define UX_CAPABILITY_SUPERSPEED_USB 0x03u
+#define UX_CAPABILITY_CONTAINER_ID 0x04u
+#define UX_CAPABILITY_PLATFORM 0x05u
+#define UX_CAPABILITY_POWER_DELIVERY 0x06u
+#define UX_CAPABILITY_BATTERY_INFO 0x07u
+#define UX_CAPABILITY_PD_CONSUMER_PORT 0x08u
+#define UX_CAPABILITY_PD_PROVIDER_PORT 0x09u
+#define UX_CAPABILITY_SUPERSPEED_PLUS 0x0Au
+#define UX_CAPABILITY_PRECISION_TIME_MEASUREMENT 0x0Bu
+#define UX_CAPABILITY_WIRELESS_USB_EXT 0x0Cu
+#define UX_CAPABILITY_BILLBOARD 0x0Du
+#define UX_CAPABILITY_AUTHENTICATION 0x0Eu
+#define UX_CAPABILITY_BILLBOARD_EX 0x0Fu
+#define UX_CAPABILITY_CONFIGURATION_SUMMARY 0x10u
+
#define UX_CONTROL_TRANSFER_TIMEOUT 1000
#define UX_NON_CONTROL_TRANSFER_TIMEOUT 5000
@@ -957,6 +979,15 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL
#define UX_ENUMERATION_THREAD_WAIT 200
+/* USB Billboard constants. */
+
+#define UX_CLASS_BILLBOARD_CLASS 0x11
+#define UX_CLASS_BILLBOARD_SUBCLASS 0x00
+#define UX_CLASS_BILLBOARD_PROTOCOL 0x00
+#define UX_CLASS_BILLBOARD_DESCRIPTOR_BILLBOARD 0x0D
+#define UX_CLASS_BILLBOARD_DESCRIPTOR_ALTERNATE_MODE 0x0F
+#define UX_CLASS_BILLBOARD_MAX_NUM_ALT_MODE 0x34
+
/* USBX 5.8 BACKWARD COMPATIBILITY DEFINITIONS. THESE DEFINITIONS ARE NOW OBSOLETE
BUT DEFINED HERE FOR COMPATIBILITY REASONS. */
@@ -1717,6 +1748,49 @@ typedef struct UX_STRING_DESCRIPTOR_STRUCT
#define UX_STRING_DESCRIPTOR_LENGTH 4
+/* Define USBX BOS Descriptor structure. */
+
+typedef struct UX_BOS_DESCRIPTOR_STRUCT
+{
+ ULONG bLength;
+ ULONG bDescriptorType;
+ ULONG wTotalLength;
+ ULONG bNumDeviceCaps;
+} UX_BOS_DESCRIPTOR;
+
+#define UX_BOS_DESCRIPTOR_ENTRIES 4
+#define UX_BOS_DESCRIPTOR_LENGTH 5
+
+
+/* Define USBX USB 2.0 Descriptor structure. */
+
+typedef struct UX_USB_2_0_EXTENSION_DESCRIPTOR_STRUCT
+{
+ ULONG bLength;
+ ULONG bDescriptorType;
+ ULONG bDevCapabilityType;
+ ULONG bmAttributes;
+} UX_USB_2_0_EXTENSION_DESCRIPTOR;
+
+#define UX_USB_2_0_EXTENSION_DESCRIPTOR_ENTRIES 4
+#define UX_USB_2_0_EXTENSION_DESCRIPTOR_LENGTH 7
+
+
+/* Define USBX Container ID Descriptor structure. */
+
+typedef struct UX_CONTAINER_ID_DESCRIPTOR_STRUCT
+{
+ ULONG bLength;
+ ULONG bDescriptorType;
+ ULONG bDevCapabilityType;
+ ULONG bReserved;
+ ULONG ContainerID[4];
+} UX_CONTAINER_ID_DESCRIPTOR;
+
+#define UX_CONTAINER_ID_DESCRIPTOR_ENTRIES 5
+#define UX_CONTAINER_ID_DESCRIPTOR_LENGTH 20
+
+
/* Define USBX DFU functional descriptor. */
typedef struct UX_DFU_FUNCTIONAL_DESCRIPTOR_STRUCT
diff --git a/common/core/inc/ux_system.h b/common/core/inc/ux_system.h
index ac46308..5c64ab2 100644
--- a/common/core/inc/ux_system.h
+++ b/common/core/inc/ux_system.h
@@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_system.h PORTABLE C */
-/* 6.1 */
+/* 6.1.3 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -43,6 +43,9 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
+/* 12-31-2020 Chaoqiong Xiao Modified comment(s), */
+/* added BOS support, */
+/* resulting in version 6.1.3 */
/* */
/**************************************************************************/
@@ -86,6 +89,10 @@ extern UCHAR _ux_system_class_pima_storage_structure[];
extern UCHAR _ux_system_class_pima_object_structure[];
extern UCHAR _ux_system_ecm_interface_descriptor_structure[];
+extern UCHAR _ux_system_bos_descriptor_structure[];
+extern UCHAR _ux_system_usb_2_0_extension_descriptor_structure[];
+extern UCHAR _ux_system_container_id_descriptor_structure[];
+
extern UINT _ux_system_host_hcd_periodic_tree_entries[32];
extern UCHAR _ux_system_host_class_hub_name[];
diff --git a/common/core/src/ux_device_stack_descriptor_send.c b/common/core/src/ux_device_stack_descriptor_send.c
index a165810..3bf18ec 100644
--- a/common/core/src/ux_device_stack_descriptor_send.c
+++ b/common/core/src/ux_device_stack_descriptor_send.c
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_descriptor_send PORTABLE C */
-/* 6.1 */
+/* 6.1.3 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -82,6 +82,9 @@
/* logic, verified memset and */
/* memcpy cases, */
/* resulting in version 6.1 */
+/* 12-31-2020 Chaoqiong Xiao Modified comment(s), */
+/* added BOS support, */
+/* resulting in version 6.1.3 */
/* */
/**************************************************************************/
UINT _ux_device_stack_descriptor_send(ULONG descriptor_type, ULONG request_index, ULONG host_length)
@@ -93,12 +96,15 @@ ULONG descriptor_index;
ULONG parsed_descriptor_index;
UX_SLAVE_TRANSFER *transfer_request;
UX_CONFIGURATION_DESCRIPTOR configuration_descriptor;
+#ifndef UX_BOS_SUPPORT_DISABLE
+UX_BOS_DESCRIPTOR bos_descriptor;
+#endif
UX_SLAVE_ENDPOINT *endpoint;
UCHAR *device_framework;
UCHAR *device_framework_end;
ULONG device_framework_length;
ULONG descriptor_length;
-ULONG configuration_descriptor_length;
+ULONG target_descriptor_length;
UINT status = UX_ERROR;
ULONG length;
UCHAR *string_memory;
@@ -195,6 +201,10 @@ ULONG string_length;
}
break;
+#ifndef UX_BOS_SUPPORT_DISABLE
+ case UX_BOS_DESCRIPTOR_ITEM:
+ /* Fall through. */
+#endif
case UX_OTHER_SPEED_DESCRIPTOR_ITEM:
/* Fall through. */
case UX_CONFIGURATION_DESCRIPTOR_ITEM:
@@ -226,64 +236,63 @@ ULONG string_length;
/* Get descriptor length. */
descriptor_length = (ULONG) *device_framework;
- /* Check if this is a configuration descriptor. We are cheating here. Instead of creating
- a OTHER SPEED descriptor, we simply scan the configuration descriptor for the Full Speed
- framework and return this configuration after we manually changed the configuration descriptor
- item into a Other Speed Descriptor. */
- if (*(device_framework + 1) == UX_CONFIGURATION_DESCRIPTOR_ITEM)
- {
+#ifndef UX_BOS_SUPPORT_DISABLE
- /* Check the index. It must be the same as the one requested. */
- if (parsed_descriptor_index == descriptor_index)
+ /* Check if we are finding BOS descriptor. */
+ if (descriptor_type == UX_BOS_DESCRIPTOR_ITEM)
+ {
+ if (*(device_framework + 1) == UX_BOS_DESCRIPTOR_ITEM)
{
- /* Parse the configuration descriptor. */
+ /* Parse the BOS descriptor. */
_ux_utility_descriptor_parse(device_framework,
- _ux_system_configuration_descriptor_structure,
- UX_CONFIGURATION_DESCRIPTOR_ENTRIES,
- (UCHAR *) &configuration_descriptor);
+ _ux_system_bos_descriptor_structure,
+ UX_BOS_DESCRIPTOR_ENTRIES,
+ (UCHAR *) &bos_descriptor);
- /* Get the length of entire configuration descriptor. */
- configuration_descriptor_length = configuration_descriptor.wTotalLength;
+ /* Get the length of entire BOS descriptor. */
+ target_descriptor_length = bos_descriptor.wTotalLength;
- /* Ensure the host does not demand a length beyond our descriptor (Windows does that)
- and do not return more than what is allowed. */
- if (configuration_descriptor_length < host_length)
- length = configuration_descriptor_length;
- else
- length = host_length;
+ /* Descriptor is found. */
+ status = UX_SUCCESS;
+ break;
+ }
+ }
+ else
+#endif
- /* Check buffer length, since total descriptors length may exceed buffer... */
- if (length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH)
- {
- /* Error trap. */
- _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_DEVICE_STACK, UX_MEMORY_INSUFFICIENT);
+ {
- /* If trace is enabled, insert this event into the trace buffer. */
- UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MEMORY_INSUFFICIENT, device, 0, 0, UX_TRACE_ERRORS, 0, 0)
+ /* Check if this is a configuration descriptor. We are cheating here. Instead of creating
+ a OTHER SPEED descriptor, we simply scan the configuration descriptor for the Full Speed
+ framework and return this configuration after we manually changed the configuration descriptor
+ item into a Other Speed Descriptor. */
+ if (*(device_framework + 1) == UX_CONFIGURATION_DESCRIPTOR_ITEM)
+ {
- /* Stall the endpoint. */
- status = dcd -> ux_slave_dcd_function(dcd, UX_DCD_STALL_ENDPOINT, endpoint);
- break;
- }
+ /* Check the index. It must be the same as the one requested. */
+ if (parsed_descriptor_index == descriptor_index)
+ {
- /* Copy the device descriptor into the transfer request memory. */
- _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer,
- device_framework, length); /* Use case of memcpy is verified. */
+ /* Parse the configuration descriptor. */
+ _ux_utility_descriptor_parse(device_framework,
+ _ux_system_configuration_descriptor_structure,
+ UX_CONFIGURATION_DESCRIPTOR_ENTRIES,
+ (UCHAR *) &configuration_descriptor);
- /* Now we need to hack the found descriptor because this request expect a OTHER_SPEED
- descriptor instead of the regular CONFIGURATION descriptor. */
- *(transfer_request -> ux_slave_transfer_request_data_pointer + 1) = (UCHAR)descriptor_type;
+ /* Get the length of entire configuration descriptor. */
+ target_descriptor_length = configuration_descriptor.wTotalLength;
- /* We can return the configuration descriptor. */
- status = _ux_device_stack_transfer_request(transfer_request, length, host_length);
- break;
- }
- else
- {
+ /* Descriptor is found. */
+ status = UX_SUCCESS;
+ break;
+ }
+ else
+ {
- /* There may be more configuration descriptors in this framework. */
- parsed_descriptor_index++;
+ /* There may be more configuration descriptors in this framework. */
+ parsed_descriptor_index++;
+ }
}
}
@@ -293,6 +302,43 @@ ULONG string_length;
/* Point to the next descriptor. */
device_framework += descriptor_length;
}
+
+ /* Send the descriptor. */
+ if (status == UX_SUCCESS)
+ {
+
+ /* Ensure the host does not demand a length beyond our descriptor (Windows does that)
+ and do not return more than what is allowed. */
+ if (target_descriptor_length < host_length)
+ length = target_descriptor_length;
+ else
+ length = host_length;
+
+ /* Check buffer length, since total descriptors length may exceed buffer... */
+ if (length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH)
+ {
+ /* Error trap. */
+ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_DEVICE_STACK, UX_MEMORY_INSUFFICIENT);
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MEMORY_INSUFFICIENT, device, 0, 0, UX_TRACE_ERRORS, 0, 0)
+
+ /* Stall the endpoint. */
+ status = dcd -> ux_slave_dcd_function(dcd, UX_DCD_STALL_ENDPOINT, endpoint);
+ break;
+ }
+
+ /* Copy the device descriptor into the transfer request memory. */
+ _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer,
+ device_framework, length); /* Use case of memcpy is verified. */
+
+ /* Now we need to hack the found descriptor because this request expect a requested
+ descriptor type instead of the regular descriptor. */
+ *(transfer_request -> ux_slave_transfer_request_data_pointer + 1) = (UCHAR)descriptor_type;
+
+ /* We can return the configuration descriptor. */
+ status = _ux_device_stack_transfer_request(transfer_request, length, host_length);
+ }
break;
case UX_STRING_DESCRIPTOR_ITEM:
diff --git a/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c b/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c
index 4036ba3..73d5289 100644
--- a/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c
+++ b/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_sim_host_request_bulk_transfer PORTABLE C */
-/* 6.1 */
+/* 6.1.3 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -71,6 +71,9 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
+/* 12-31-2020 Chaoqiong Xiao Modified comment(s), */
+/* fixed ZLP sending, */
+/* resulting in version 6.1.3 */
/* */
/**************************************************************************/
UINT _ux_hcd_sim_host_request_bulk_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request)
@@ -109,7 +112,7 @@ UCHAR * data_pointer;
transfer_request_payload_length = transfer_request -> ux_transfer_request_requested_length;
data_pointer = transfer_request -> ux_transfer_request_data_pointer;
- while (transfer_request_payload_length != 0)
+ do
{
if (transfer_request_payload_length > UX_HCD_SIM_HOST_MAX_PAYLOAD)
@@ -181,7 +184,7 @@ UCHAR * data_pointer;
previous_td -> ux_sim_host_td_next_td_transfer_request = data_td;
previous_td = data_td;
}
- }
+ } while (transfer_request_payload_length != 0);
/* At this stage, the Head and Tail in the ED are still the same and the host simulator
controller will skip this ED until we have hooked the new tail TD. */
diff --git a/common/core/src/ux_system_initialize.c b/common/core/src/ux_system_initialize.c
index 17c0d3a..214701e 100644
--- a/common/core/src/ux_system_initialize.c
+++ b/common/core/src/ux_system_initialize.c
@@ -59,13 +59,17 @@ UCHAR _ux_system_class_pima_storage_structure[] = {2,2
UCHAR _ux_system_class_pima_object_structure[] = {4,2,2,4,2,4,4,4,4,4,4,4,2,4,4};
UCHAR _ux_system_ecm_interface_descriptor_structure[] = {1,1,1,1,4,2,2,1};
+UCHAR _ux_system_bos_descriptor_structure[] = {1,1,2,1};
+UCHAR _ux_system_usb_2_0_extension_descriptor_structure[] = {1,1,1,4};
+UCHAR _ux_system_container_id_descriptor_structure[] = {1,1,1,1,4,4,4,4};
+
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_system_initialize PORTABLE C */
-/* 6.1 */
+/* 6.1.3 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -105,6 +109,9 @@ UCHAR _ux_system_ecm_interface_descriptor_structure[] = {1,1
/* verified memset and memcpy */
/* cases, */
/* resulting in version 6.1 */
+/* 12-31-2020 Chaoqiong Xiao Modified comment(s), */
+/* added BOS support, */
+/* resulting in version 6.1.3 */
/* */
/**************************************************************************/
UINT _ux_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memory_size,