From 62802608052e632026fd409f4c3af85be47c04db Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Wed, 2 Jun 2021 06:46:57 +0000 Subject: [PATCH] Release 6.1.7 --- common/core/inc/ux_api.h | 21 +++++-- common/core/inc/ux_user_sample.h | 19 +++++- .../src/ux_dcd_sim_slave_endpoint_reset.c | 28 ++++++++- .../src/ux_host_stack_class_device_scan.c | 6 +- ...host_stack_device_configuration_activate.c | 11 ++-- ...st_stack_device_configuration_deactivate.c | 11 ++-- .../ux_host_stack_endpoint_instance_create.c | 9 ++- .../ux_host_stack_endpoint_instance_delete.c | 7 ++- .../ux_host_stack_transfer_request_abort.c | 10 +++- .../src/ux_device_class_storage_thread.c | 60 ++++++++++--------- 10 files changed, 131 insertions(+), 51 deletions(-) diff --git a/common/core/inc/ux_api.h b/common/core/inc/ux_api.h index 1aafec1..6361c45 100755 --- 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.6 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -87,6 +87,11 @@ /* added macros for Word/DWord */ /* to bytes extraction, */ /* resulting in version 6.1.6 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added trace dependency test,*/ +/* changed transfer timeout */ +/* value, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ @@ -221,7 +226,7 @@ typedef signed char SCHAR; #define AZURE_RTOS_USBX #define USBX_MAJOR_VERSION 6 #define USBX_MINOR_VERSION 1 -#define USBX_PATCH_VERSION 6 +#define USBX_PATCH_VERSION 7 /* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */ @@ -330,6 +335,9 @@ VOID _ux_utility_debug_log(UCHAR *debug_location, UCHAR *debug_message, ULONG de /* Determine if tracing is enabled. */ #ifdef TX_ENABLE_EVENT_TRACE +#ifndef UX_TRACE_INSERT_MACROS +#error UX_TRACE_INSERT_MACROS must be defined to support TX_ENABLE_EVENT_TRACE +#endif /* Trace is enabled. Remap calls so that interrupts can be disabled around the actual event logging. */ @@ -999,8 +1007,13 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #define UX_CAPABILITY_CONFIGURATION_SUMMARY 0x10u -#define UX_CONTROL_TRANSFER_TIMEOUT 1000 -#define UX_NON_CONTROL_TRANSFER_TIMEOUT 5000 +#ifndef UX_CONTROL_TRANSFER_TIMEOUT +#define UX_CONTROL_TRANSFER_TIMEOUT 10000 +#endif + +#ifndef UX_NON_CONTROL_TRANSFER_TIMEOUT +#define UX_NON_CONTROL_TRANSFER_TIMEOUT 50000 +#endif #define UX_PORT_ENABLE_WAIT 50 #define UX_DEVICE_ADDRESS_SET_WAIT 50 #define UX_HIGH_SPEED_DETECTION_HANDSHAKE_SUSPEND_WAIT 200 diff --git a/common/core/inc/ux_user_sample.h b/common/core/inc/ux_user_sample.h index 8142147..584ed8e 100644 --- a/common/core/inc/ux_user_sample.h +++ b/common/core/inc/ux_user_sample.h @@ -26,7 +26,7 @@ /* PORT SPECIFIC C INFORMATION RELEASE */ /* */ /* ux_user.h PORTABLE C */ -/* 6.1.6 */ +/* 6.1.7 */ /* */ /* AUTHOR */ /* */ @@ -58,6 +58,10 @@ /* added macro to disable CDC- */ /* ACM transmission support, */ /* resulting in version 6.1.6 */ +/* 06-02-2021 Xiuwen Cai Modified comment(s), added */ +/* transfer timeout value */ +/* options, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ @@ -96,6 +100,19 @@ */ #define UX_PERIODIC_RATE (TX_TIMER_TICKS_PER_SECOND) +/* Define control transfer timeout value in millisecond. + The default is 10000 milliseconds. */ +/* +#define UX_CONTROL_TRANSFER_TIMEOUT 10000 +*/ + +/* Define non control transfer timeout value in millisecond. + The default is 50000 milliseconds. */ +/* +#define UX_NON_CONTROL_TRANSFER_TIMEOUT 50000 +*/ + + /* Defined, this value is the maximum number of classes that can be loaded by USBX. This value represents the class container and not the number of instances of a class. For instance, if a particular implementation of USBX needs the hub class, the printer class, and the storage diff --git a/common/core/src/ux_dcd_sim_slave_endpoint_reset.c b/common/core/src/ux_dcd_sim_slave_endpoint_reset.c index 6dc0083..e4d7e74 100644 --- a/common/core/src/ux_dcd_sim_slave_endpoint_reset.c +++ b/common/core/src/ux_dcd_sim_slave_endpoint_reset.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_dcd_sim_slave_endpoint_reset PORTABLE C */ -/* 6.1 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,20 +67,44 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* cleared transfer flag and */ +/* waked up suspended thread, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_reset(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint) { UX_DCD_SIM_SLAVE_ED *ed; +ULONG transfer_waiting; +UX_SLAVE_TRANSFER *transfer; UX_PARAMETER_NOT_USED(dcd_sim_slave); /* Get the physical endpoint address in the endpoint container. */ ed = (UX_DCD_SIM_SLAVE_ED *) endpoint -> ux_slave_endpoint_ed; + /* Save waiting status for non-zero endpoints. */ + if (ed -> ux_sim_slave_ed_index) + { + transfer_waiting = ed -> ux_sim_slave_ed_status; + transfer_waiting &= UX_DCD_SIM_SLAVE_ED_STATUS_TRANSFER; + } + else + transfer_waiting = 0; + /* Set the state of the endpoint to not stalled. */ - ed -> ux_sim_slave_ed_status &= ~(ULONG)UX_DCD_SIM_SLAVE_ED_STATUS_STALLED; + ed -> ux_sim_slave_ed_status &= ~(ULONG)(UX_DCD_SIM_SLAVE_ED_STATUS_STALLED | + transfer_waiting); + + /* If some thread is pending, signal wakeup. */ + if (transfer_waiting) + { + transfer = &endpoint -> ux_slave_endpoint_transfer_request; + transfer -> ux_slave_transfer_request_completion_code = UX_TRANSFER_BUS_RESET; + _ux_utility_semaphore_put(&transfer -> ux_slave_transfer_request_semaphore); + } /* This function never fails. */ return(UX_SUCCESS); diff --git a/common/core/src/ux_host_stack_class_device_scan.c b/common/core/src/ux_host_stack_class_device_scan.c index 5e9d1ae..41d796c 100644 --- a/common/core/src/ux_host_stack_class_device_scan.c +++ b/common/core/src/ux_host_stack_class_device_scan.c @@ -41,7 +41,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_device_scan PORTABLE C */ -/* 6.1 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -78,6 +78,9 @@ /* used query usage of device */ /* ClassSubclassProtocol, */ /* resulting in version 6.1 */ +/* 06-02-2021 Bhupendra Naphade Modified comment(s), */ +/* removed duplicate line, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_device_scan(UX_DEVICE *device) @@ -95,7 +98,6 @@ UX_HOST_CLASS_COMMAND class_command; class_command.ux_host_class_command_pid = device -> ux_device_descriptor.idProduct; class_command.ux_host_class_command_class = device -> ux_device_descriptor.bDeviceClass; class_command.ux_host_class_command_subclass = device -> ux_device_descriptor.bDeviceSubClass; - class_command.ux_host_class_command_subclass = device -> ux_device_descriptor.bDeviceSubClass; class_command.ux_host_class_command_protocol = device -> ux_device_descriptor.bDeviceProtocol; class_command.ux_host_class_command_iad_class = 0; class_command.ux_host_class_command_iad_subclass = 0; diff --git a/common/core/src/ux_host_stack_device_configuration_activate.c b/common/core/src/ux_host_stack_device_configuration_activate.c index 47f659a..864bae8 100644 --- a/common/core/src/ux_host_stack_device_configuration_activate.c +++ b/common/core/src/ux_host_stack_device_configuration_activate.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_configuration_activate PORTABLE C */ -/* 6.1.4 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +71,9 @@ /* DATE NAME DESCRIPTION */ /* */ /* 02-02-2021 Chaoqiong Xiao Initial Version 6.1.4 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* fixed trace enabled error, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_configuration_activate(UX_CONFIGURATION *configuration) @@ -93,12 +96,12 @@ UINT status; return(UX_CONFIGURATION_HANDLE_UNKNOWN); } - /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_CONFIGURATION_ACTIVATE, device, configuration, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) - /* Get the device container for this configuration. */ device = configuration -> ux_configuration_device; + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_CONFIGURATION_ACTIVATE, device, configuration, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + /* Protect the control endpoint semaphore here. It will be unprotected in the transfer request function. */ status = _ux_utility_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER); diff --git a/common/core/src/ux_host_stack_device_configuration_deactivate.c b/common/core/src/ux_host_stack_device_configuration_deactivate.c index 384b556..7012dce 100644 --- a/common/core/src/ux_host_stack_device_configuration_deactivate.c +++ b/common/core/src/ux_host_stack_device_configuration_deactivate.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_configuration_deactivate PORTABLE C */ -/* 6.1.4 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,9 @@ /* DATE NAME DESCRIPTION */ /* */ /* 02-02-2021 Chaoqiong Xiao Initial Version 6.1.4 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* fixed trace enabled error, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_configuration_deactivate(UX_DEVICE *device) @@ -92,6 +95,9 @@ UINT status; return(UX_DEVICE_HANDLE_UNKNOWN); } + /* Get the configuration. */ + configuration = device -> ux_device_current_configuration; + /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_CONFIGURATION_DEACTIVATE, device, configuration, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) @@ -112,9 +118,6 @@ UINT status; return(UX_SEMAPHORE_ERROR); } - /* Get the configuration. */ - configuration = device -> ux_device_current_configuration; - /* Check for the state of the device, if not configured, we are done. */ if (device -> ux_device_state != UX_DEVICE_CONFIGURED) { diff --git a/common/core/src/ux_host_stack_endpoint_instance_create.c b/common/core/src/ux_host_stack_endpoint_instance_create.c index e804631..10409ef 100644 --- a/common/core/src/ux_host_stack_endpoint_instance_create.c +++ b/common/core/src/ux_host_stack_endpoint_instance_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_endpoint_instance_create PORTABLE C */ -/* 6.1 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,6 +73,11 @@ /* optimized based on compile */ /* definitions, */ /* resulting in version 6.1 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* fixed trace enabled error, */ +/* filled default endpoint */ +/* request endpoint pointer, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ UINT _ux_host_stack_endpoint_instance_create(UX_ENDPOINT *endpoint) @@ -87,7 +92,7 @@ UCHAR endpoint_type; hcd = UX_DEVICE_HCD_GET(endpoint -> ux_endpoint_device); /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_CREATE, device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_CREATE, endpoint -> ux_endpoint_device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) /* If the endpoint needs guaranteed bandwidth, check if we have enough */ diff --git a/common/core/src/ux_host_stack_endpoint_instance_delete.c b/common/core/src/ux_host_stack_endpoint_instance_delete.c index 5de4ade..60ada60 100644 --- a/common/core/src/ux_host_stack_endpoint_instance_delete.c +++ b/common/core/src/ux_host_stack_endpoint_instance_delete.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_endpoint_instance_delete PORTABLE C */ -/* 6.1 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,9 @@ /* optimized based on compile */ /* definitions, */ /* resulting in version 6.1 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* fixed trace enabled error, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ VOID _ux_host_stack_endpoint_instance_delete(UX_ENDPOINT *endpoint) @@ -84,7 +87,7 @@ UX_HCD *hcd; hcd = UX_DEVICE_HCD_GET(endpoint -> ux_endpoint_device); /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_DELETE, device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_DELETE, endpoint -> ux_endpoint_device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) /* Ensure the endpoint had its physical ED allocated. */ if (endpoint -> ux_endpoint_ed != UX_NULL) diff --git a/common/core/src/ux_host_stack_transfer_request_abort.c b/common/core/src/ux_host_stack_transfer_request_abort.c index 1b51853..c0b2820 100644 --- a/common/core/src/ux_host_stack_transfer_request_abort.c +++ b/common/core/src/ux_host_stack_transfer_request_abort.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_transfer_request_abort PORTABLE C */ -/* 6.1 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -77,6 +77,9 @@ /* optimized based on compile */ /* definitions, */ /* resulting in version 6.1 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* fixed trace enabled error, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ UINT _ux_host_stack_transfer_request_abort(UX_TRANSFER *transfer_request) @@ -87,7 +90,10 @@ ULONG completion_code; /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_TRANSFER_REQUEST_ABORT, device, endpoint, transfer_request, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_TRANSFER_REQUEST_ABORT, + transfer_request -> ux_transfer_request_endpoint -> ux_endpoint_device, + transfer_request -> ux_transfer_request_endpoint, + transfer_request, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) /* With the device we have the pointer to the HCD. */ hcd = UX_DEVICE_HCD_GET(transfer_request -> ux_transfer_request_endpoint -> ux_endpoint_device); diff --git a/common/usbx_device_classes/src/ux_device_class_storage_thread.c b/common/usbx_device_classes/src/ux_device_class_storage_thread.c index 5f189f6..da174e0 100644 --- a/common/usbx_device_classes/src/ux_device_class_storage_thread.c +++ b/common/usbx_device_classes/src/ux_device_class_storage_thread.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_storage_thread PORTABLE C */ -/* 6.1.6 */ +/* 6.1.7 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -107,6 +107,10 @@ /* fixed compile issues with */ /* some macro options, */ /* resulting in version 6.1.6 */ +/* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* get interface and endpoints */ +/* from configured device, */ +/* resulting in version 6.1.7 */ /* */ /**************************************************************************/ VOID _ux_device_class_storage_thread(ULONG storage_class) @@ -140,39 +144,39 @@ UCHAR *cbw_cb; /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; - /* This is the first time we are activated. We need the interface to the class. */ - interface = storage -> ux_slave_class_storage_interface; - - /* Locate the endpoints. */ - endpoint_in = interface -> ux_slave_interface_first_endpoint; - - /* Check the endpoint direction, if IN we have the correct endpoint. */ - if ((endpoint_in -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN) - { - - /* Wrong direction, we found the OUT endpoint first. */ - endpoint_out = endpoint_in; - - /* So the next endpoint has to be the IN endpoint. */ - endpoint_in = endpoint_out -> ux_slave_endpoint_next_endpoint; - } - else - { - - /* We found the endpoint IN first, so next endpoint is OUT. */ - endpoint_out = endpoint_in -> ux_slave_endpoint_next_endpoint; - } - - /* All SCSI commands are on the endpoint OUT, from the host. */ - transfer_request = &endpoint_out -> ux_slave_endpoint_transfer_request; - /* As long as the device is in the CONFIGURED state. */ while (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED) { /* We assume the worst situation. */ status = UX_ERROR; - + + /* This is the first time we are activated. We need the interface to the class. */ + interface = storage -> ux_slave_class_storage_interface; + + /* Locate the endpoints. */ + endpoint_in = interface -> ux_slave_interface_first_endpoint; + + /* Check the endpoint direction, if IN we have the correct endpoint. */ + if ((endpoint_in -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN) + { + + /* Wrong direction, we found the OUT endpoint first. */ + endpoint_out = endpoint_in; + + /* So the next endpoint has to be the IN endpoint. */ + endpoint_in = endpoint_out -> ux_slave_endpoint_next_endpoint; + } + else + { + + /* We found the endpoint IN first, so next endpoint is OUT. */ + endpoint_out = endpoint_in -> ux_slave_endpoint_next_endpoint; + } + + /* All SCSI commands are on the endpoint OUT, from the host. */ + transfer_request = &endpoint_out -> ux_slave_endpoint_transfer_request; + /* Check state, they must be both RESET. */ if (endpoint_out -> ux_slave_endpoint_state == UX_ENDPOINT_RESET && (UCHAR)storage -> ux_slave_class_storage_csw_status != UX_SLAVE_CLASS_STORAGE_CSW_PHASE_ERROR)