Release 6.1.12

This commit is contained in:
Yuxin Zhou 2022-07-26 02:07:18 +00:00
parent 082fd9db09
commit cd55ec7456
287 changed files with 12544 additions and 2664 deletions

View File

@ -3,3 +3,4 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/usbx_device_classes)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/usbx_host_classes)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/usbx_host_controllers)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/usbx_network)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/usbx_pictbridge)

View File

@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* ux_api.h PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -115,6 +115,13 @@
/* standalone compiling error, */
/* added CCID trace IDs, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* added feedback size defs, */
/* added shared device config */
/* descriptor for enum scan, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -282,7 +289,7 @@ typedef signed char SCHAR;
#define AZURE_RTOS_USBX
#define USBX_MAJOR_VERSION 6
#define USBX_MINOR_VERSION 1
#define USBX_PATCH_VERSION 11
#define USBX_PATCH_VERSION 12
/* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */
@ -1130,6 +1137,9 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL
#define UX_MAX_NUMBER_OF_TRANSACTIONS_MASK 0x1800u
#define UX_MAX_NUMBER_OF_TRANSACTIONS_SHIFT 11
#define UX_FEEDBACK_SIZE_FULL_SPEED 3 /* 10.10 format fits into 3 bytes. */
#define UX_FEEDBACK_SIZE_HIGH_SPEED 4 /* 12.13 format fits into 4 bytes. */
#define UX_REQUEST_DIRECTION 0x80u
#define UX_REQUEST_IN 0x80u
#define UX_REQUEST_OUT 0x00u
@ -1261,9 +1271,9 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL
#define UX_DEVICE_CONNECTION 0x81u
#define UX_DEVICE_DISCONNECTION 0x82u
/* Host change callback events : _callback(event, NULL, NULL) */
#define UX_STANDALONE_WAIT_BACKGROUND_TASK 0x00u
@ -1398,6 +1408,7 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL
#define UX_INVALID_STATE 0xfb
#define UX_INVALID_PARAMETER 0xfa
#define UX_ABORTED 0xf9
#define UX_MATH_OVERFLOW 0xf8
#define UX_TOO_MANY_DEVICES 0x11
#define UX_MEMORY_INSUFFICIENT 0x12
@ -1469,6 +1480,7 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL
#define UX_HOST_CLASS_AUDIO_WRONG_TYPE 0x80
#define UX_HOST_CLASS_AUDIO_WRONG_INTERFACE 0x81
#define UX_HOST_CLASS_AUDIO_WRONG_FREQUENCY 0x82
#define UX_CLASS_CDC_ECM_LINK_STATE_DOWN_ERROR 0x90
@ -1898,6 +1910,8 @@ typedef struct UX_DEVICE_STRUCT
ULONG ux_device_power_source;
struct UX_CONFIGURATION_STRUCT
*ux_device_current_configuration;
UCHAR *ux_device_packed_configuration;
ULONG ux_device_packed_configuration_keep_count;
#if !defined(UX_HOST_STANDALONE)
UX_SEMAPHORE ux_device_protection_semaphore;
#endif
@ -2709,7 +2723,7 @@ UINT ux_host_stack_class_instance_get(UX_HOST_CLASS *host_class, UINT class_i
UINT ux_host_stack_class_register(UCHAR *class_name, UINT (*class_entry_function)(struct UX_HOST_CLASS_COMMAND_STRUCT *));
UINT ux_host_stack_class_unregister(UINT (*class_entry_function)(struct UX_HOST_CLASS_COMMAND_STRUCT *));
UINT ux_host_stack_configuration_interface_get(UX_CONFIGURATION *configuration, UINT interface_index,
UINT alternate_setting_index, UX_INTERFACE **interface);
UINT alternate_setting_index, UX_INTERFACE **ux_interface);
UINT ux_host_stack_device_configuration_activate(UX_CONFIGURATION *configuration);
UINT ux_host_stack_device_configuration_deactivate(UX_DEVICE *device);
UINT ux_host_stack_device_configuration_get(UX_DEVICE *device, UINT configuration_index, UX_CONFIGURATION **configuration);
@ -2721,8 +2735,8 @@ UINT ux_host_stack_hcd_register(UCHAR *hcd_name, UINT (*hcd_initialize_functi
UINT ux_host_stack_hcd_unregister(UCHAR *hcd_name, ULONG hcd_param1, ULONG hcd_param2);
UINT ux_host_stack_initialize(UINT (*ux_system_host_change_function)(ULONG, UX_HOST_CLASS *, VOID *));
UINT ux_host_stack_uninitialize(VOID);
UINT ux_host_stack_interface_endpoint_get(UX_INTERFACE *interface, UINT endpoint_index, UX_ENDPOINT **endpoint);
UINT ux_host_stack_interface_setting_select(UX_INTERFACE *interface);
UINT ux_host_stack_interface_endpoint_get(UX_INTERFACE *ux_interface, UINT endpoint_index, UX_ENDPOINT **endpoint);
UINT ux_host_stack_interface_setting_select(UX_INTERFACE *ux_interface);
UINT ux_host_stack_transfer_request(UX_TRANSFER *transfer_request);
UINT ux_host_stack_transfer_request_abort(UX_TRANSFER *transfer_request);
VOID ux_host_stack_hnp_polling_thread_entry(ULONG id);
@ -2762,11 +2776,11 @@ UINT ux_device_stack_initialize(UCHAR * device_framework_high_speed, ULONG de
UCHAR * language_id_framework, ULONG language_id_framework_length,
UINT (*ux_system_slave_change_function)(ULONG));
UINT ux_device_stack_uninitialize(VOID);
UINT ux_device_stack_interface_delete(UX_SLAVE_INTERFACE *interface);
UINT ux_device_stack_interface_delete(UX_SLAVE_INTERFACE *ux_interface);
UINT ux_device_stack_interface_get(UINT interface_value);
UINT ux_device_stack_interface_set(UCHAR * device_framework, ULONG device_framework_length,
ULONG alternate_setting_value);
UINT ux_device_stack_interface_start(UX_SLAVE_INTERFACE *interface);
UINT ux_device_stack_interface_start(UX_SLAVE_INTERFACE *ux_interface);
UINT ux_device_stack_transfer_request(UX_SLAVE_TRANSFER *transfer_request, ULONG slave_length, ULONG host_length);
UINT ux_device_stack_transfer_request_abort(UX_SLAVE_TRANSFER *transfer_request, ULONG completion_code);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -168,7 +168,7 @@ UINT _ux_dcd_sim_slave_transfer_abort(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLA
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -139,6 +139,6 @@ UINT _ux_device_class_dpump_change(UX_SLAVE_CLASS_COMMAND *command);
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -25,7 +25,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_stack.h PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -49,6 +49,10 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -89,11 +93,11 @@ UINT _ux_device_stack_initialize(UCHAR * device_framework_high_speed, ULONG d
UCHAR * string_framework, ULONG string_framework_length,
UCHAR * language_id_framework, ULONG language_id_framework_length,
UINT (*ux_system_slave_change_function)(ULONG));
UINT _ux_device_stack_interface_delete(UX_SLAVE_INTERFACE *interface);
UINT _ux_device_stack_interface_delete(UX_SLAVE_INTERFACE *ux_interface);
UINT _ux_device_stack_interface_get(UINT interface_value);
UINT _ux_device_stack_interface_set(UCHAR * device_framework, ULONG device_framework_length,
ULONG alternate_setting_value);
UINT _ux_device_stack_interface_start(UX_SLAVE_INTERFACE *interface);
UINT _ux_device_stack_interface_start(UX_SLAVE_INTERFACE *ux_interface);
UINT _ux_device_stack_set_feature(ULONG request_type, ULONG request_value, ULONG request_index);
UINT _ux_device_stack_transfer_all_request_abort(UX_SLAVE_ENDPOINT *endpoint, ULONG completion_code);
UINT _ux_device_stack_transfer_request(UX_SLAVE_TRANSFER *transfer_request, ULONG slave_length, ULONG host_length);
@ -109,7 +113,7 @@ UINT _ux_device_stack_transfer_run(UX_SLAVE_TRANSFER *transfer_request, ULONG
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -272,7 +272,7 @@ UINT _ux_hcd_sim_host_transfer_run(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -82,7 +82,7 @@ extern "C" {
/* Define Data Pump Class string constants. */
#define UX_HOST_CLASS_DPUMP_GENERIC_NAME "USB DPUMP"
#define UX_HOST_CLASS_DPUMP_GENERIC_NAME "USB DPUMP"
/* Define R/W lock bits for standalone mode. */
@ -113,6 +113,6 @@ UINT _ux_host_class_dpump_ioctl(UX_HOST_CLASS_DPUMP *dpump, ULONG ioctl_funct
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_host_stack.h PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -60,6 +60,11 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* added standalone HUB, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -82,25 +87,26 @@ extern "C" {
#define UX_HOST_STACK_ENUM_PORT_ENABLE (UX_STATE_STEP + 0)
#define UX_HOST_STACK_ENUM_PORT_RESET (UX_STATE_STEP + 1)
#define UX_HOST_STACK_ENUM_PORT_RESET_WAIT (UX_STATE_STEP + 2)
#define UX_HOST_STACK_ENUM_DEVICE_ADDR_SET (UX_STATE_STEP + 3)
#define UX_HOST_STACK_ENUM_DEVICE_ADDR_SENT (UX_STATE_STEP + 4)
#define UX_HOST_STACK_ENUM_DEVICE_DESCR_READ (UX_STATE_STEP + 5)
#define UX_HOST_STACK_ENUM_DEVICE_DESCR_PARSE (UX_STATE_STEP + 6)
#define UX_HOST_STACK_ENUM_CONFIG_DESCR_READ (UX_STATE_STEP + 7)
#define UX_HOST_STACK_ENUM_CONFIG_DESCR_PARSE (UX_STATE_STEP + 8)
#define UX_HOST_STACK_ENUM_CONFIG_DESCR_NEXT (UX_STATE_STEP + 9)
#define UX_HOST_STACK_ENUM_CONFIG_SET (UX_STATE_STEP + 10)
#define UX_HOST_STACK_ENUM_CONFIG_ACTIVATE (UX_STATE_STEP + 11)
#define UX_HOST_STACK_ENUM_ACTIVATE (UX_STATE_STEP + 12)
#define UX_HOST_STACK_ENUM_ACTIVATE_WAIT (UX_STATE_STEP + 13)
#define UX_HOST_STACK_ENUM_RETRY (UX_STATE_STEP + 14)
#define UX_HOST_STACK_ENUM_NEXT (UX_STATE_STEP + 15)
#define UX_HOST_STACK_ENUM_TRANS_LOCK_WAIT (UX_STATE_STEP + 16)
#define UX_HOST_STACK_ENUM_TRANS_WAIT (UX_STATE_STEP + 17)
#define UX_HOST_STACK_ENUM_WAIT (UX_STATE_STEP + 18)
#define UX_HOST_STACK_ENUM_FAIL (UX_STATE_STEP + 19)
#define UX_HOST_STACK_ENUM_DONE (UX_STATE_STEP + 20)
#define UX_HOST_STACK_ENUM_IDLE (UX_STATE_STEP + 21)
#define UX_HOST_STACK_ENUM_HUB_OPERATION_WAIT (UX_STATE_STEP + 3)
#define UX_HOST_STACK_ENUM_DEVICE_ADDR_SET (UX_STATE_STEP + 4)
#define UX_HOST_STACK_ENUM_DEVICE_ADDR_SENT (UX_STATE_STEP + 5)
#define UX_HOST_STACK_ENUM_DEVICE_DESCR_READ (UX_STATE_STEP + 6)
#define UX_HOST_STACK_ENUM_DEVICE_DESCR_PARSE (UX_STATE_STEP + 7)
#define UX_HOST_STACK_ENUM_CONFIG_DESCR_READ (UX_STATE_STEP + 8)
#define UX_HOST_STACK_ENUM_CONFIG_DESCR_PARSE (UX_STATE_STEP + 9)
#define UX_HOST_STACK_ENUM_CONFIG_DESCR_NEXT (UX_STATE_STEP + 10)
#define UX_HOST_STACK_ENUM_CONFIG_SET (UX_STATE_STEP + 11)
#define UX_HOST_STACK_ENUM_CONFIG_ACTIVATE (UX_STATE_STEP + 12)
#define UX_HOST_STACK_ENUM_ACTIVATE (UX_STATE_STEP + 13)
#define UX_HOST_STACK_ENUM_ACTIVATE_WAIT (UX_STATE_STEP + 14)
#define UX_HOST_STACK_ENUM_RETRY (UX_STATE_STEP + 15)
#define UX_HOST_STACK_ENUM_NEXT (UX_STATE_STEP + 16)
#define UX_HOST_STACK_ENUM_TRANS_LOCK_WAIT (UX_STATE_STEP + 17)
#define UX_HOST_STACK_ENUM_TRANS_WAIT (UX_STATE_STEP + 18)
#define UX_HOST_STACK_ENUM_WAIT (UX_STATE_STEP + 19)
#define UX_HOST_STACK_ENUM_FAIL (UX_STATE_STEP + 20)
#define UX_HOST_STACK_ENUM_DONE (UX_STATE_STEP + 21)
#define UX_HOST_STACK_ENUM_IDLE (UX_STATE_STEP + 22)
/* Define Host Stack component function prototypes. */
@ -117,7 +123,7 @@ UINT _ux_host_stack_bandwidth_check(UX_HCD *hcd, UX_ENDPOINT *endpoint);
UX_HOST_CLASS * _ux_host_stack_class_call(UX_HOST_CLASS_COMMAND *class_command);
UINT _ux_host_stack_class_device_scan(UX_DEVICE *device);
UINT _ux_host_stack_class_get(UCHAR *class_name, UX_HOST_CLASS **class);
UINT _ux_host_stack_class_get(UCHAR *class_name, UX_HOST_CLASS **ux_class);
UINT _ux_host_stack_class_instance_destroy(UX_HOST_CLASS *class, VOID *class_instance);
UINT _ux_host_stack_class_instance_create(UX_HOST_CLASS *class, VOID *class_instance);
UINT _ux_host_stack_class_instance_get(UX_HOST_CLASS *class, UINT class_index, VOID **class_instance);
@ -132,7 +138,7 @@ UINT _ux_host_stack_configuration_instance_create(UX_CONFIGURATION *configura
VOID _ux_host_stack_configuration_instance_delete(UX_CONFIGURATION *configuration);
UINT _ux_host_stack_configuration_interface_get(UX_CONFIGURATION *configuration,
UINT interface_index, UINT alternate_setting_index,
UX_INTERFACE **interface);
UX_INTERFACE **ux_interface);
UINT _ux_host_stack_configuration_interface_scan(UX_CONFIGURATION *configuration);
UINT _ux_host_stack_configuration_set(UX_CONFIGURATION *configuration);
VOID _ux_host_stack_delay_ms(ULONG time);
@ -160,11 +166,11 @@ VOID _ux_host_stack_hcd_thread_entry(ULONG input);
UINT _ux_host_stack_hcd_transfer_request(UX_TRANSFER *transfer_request);
UINT _ux_host_stack_initialize(UINT (*ux_system_host_change_function)(ULONG, UX_HOST_CLASS *, VOID *));
UINT _ux_host_stack_uninitialize(VOID);
UINT _ux_host_stack_interface_endpoint_get(UX_INTERFACE *interface, UINT endpoint_index, UX_ENDPOINT **endpoint);
UINT _ux_host_stack_interface_instance_create(UX_INTERFACE *interface);
VOID _ux_host_stack_interface_instance_delete(UX_INTERFACE *interface);
UINT _ux_host_stack_interface_set(UX_INTERFACE *interface);
UINT _ux_host_stack_interface_setting_select(UX_INTERFACE *interface);
UINT _ux_host_stack_interface_endpoint_get(UX_INTERFACE *ux_interface, UINT endpoint_index, UX_ENDPOINT **endpoint);
UINT _ux_host_stack_interface_instance_create(UX_INTERFACE *ux_interface);
VOID _ux_host_stack_interface_instance_delete(UX_INTERFACE *ux_interface);
UINT _ux_host_stack_interface_set(UX_INTERFACE *ux_interface);
UINT _ux_host_stack_interface_setting_select(UX_INTERFACE *ux_interface);
UINT _ux_host_stack_interfaces_scan(UX_CONFIGURATION *configuration, UCHAR * descriptor);
VOID _ux_host_stack_new_configuration_create(UX_DEVICE *device, UX_CONFIGURATION *configuration);
UX_DEVICE *_ux_host_stack_new_device_get(VOID);
@ -172,7 +178,7 @@ UINT _ux_host_stack_new_device_create(UX_HCD *hcd, UX_DEVICE *device_owner,
UINT port_index, UINT device_speed,
UINT port_max_power,
UX_DEVICE **created_device);
UINT _ux_host_stack_new_endpoint_create(UX_INTERFACE *interface, UCHAR * interface_endpoint);
UINT _ux_host_stack_new_endpoint_create(UX_INTERFACE *ux_interface, UCHAR * interface_endpoint);
UINT _ux_host_stack_new_interface_create(UX_CONFIGURATION *configuration, UCHAR * descriptor, ULONG length);
VOID _ux_host_stack_rh_change_process(VOID);
UINT _ux_host_stack_rh_device_extraction(UX_HCD *hcd, UINT port_index);
@ -192,7 +198,7 @@ UINT _ux_host_stack_transfer_run(UX_TRANSFER *transfer_request);
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -26,7 +26,7 @@
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* ux_user.h PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* */
/* AUTHOR */
/* */
@ -78,6 +78,11 @@
/* added option to validate */
/* class code in enumeration, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added audio class features, */
/* added device CDC_ACM and */
/* printer write auto ZLP, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -88,6 +93,8 @@
/* Define various build options for the USBX port. The application should either make changes
here by commenting or un-commenting the conditional compilation defined OR supply the defines
though the compiler's equivalent of the -D option. */
/* Define USBX Generic Thread Stack Size. */
/* #define UX_THREAD_STACK_SIZE (2 * 1024) */
/* Define USBX Host Enum Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE */
@ -96,7 +103,7 @@
*/
/* Define USBX Host Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE */
/* Define USBX Host HCD Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE */
/*
#define UX_HOST_HCD_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
*/
@ -369,13 +376,22 @@
/* #define UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE */
/* Defined, device HID interrupt OUT transfer is supported. */
/* #define UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT */
/* defined, this macro enables device audio feedback endpoint support. */
/* #define UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT */
/* Defined, device HID interrupt OUT transfer is supported. */
/* Defined, class _write is pending ZLP automatically (complete transfer) after buffer is sent. */
/* #define UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT */
/* #define UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP */
/* #define UX_DEVICE_CLASS_PRINTER_WRITE_AUTO_ZLP */
/* defined, this macro enables device audio interrupt endpoint support. */
/* define UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT */
/* Defined, this macro enables device bi-directional-endpoint support. */
@ -402,6 +418,15 @@
/* #define UX_HOST_CLASS_HID_REPORT_TRANSFER_TIMEOUT 10000 */
/* Defined, host audio UAC 2.0 is supported. */
/* #define UX_HOST_CLASS_AUDIO_2_SUPPORT */
/* Defined, host audio optional feedback endpoint is supported. */
/* #define UX_HOST_CLASS_AUDIO_FEEDBACK_SUPPORT */
/* Defined, host audio optional interrupt endpoint is support. */
/* #define UX_HOST_CLASS_AUDIO_INTERRUPT_SUPPORT */
/* Defined, this value will only enable the host side of usbx. */
/* #define UX_HOST_SIDE_ONLY */

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_utility.h PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -53,6 +53,10 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added macros for RTOS calls,*/
/* fixed OHCI PRSC issue, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -168,22 +172,50 @@ extern ALIGN_TYPE _ux_utility_time_elapsed(ALIGN_TYPE, ALIGN_TYPE);
#if !defined(UX_STANDALONE)
#define _ux_system_semaphore_create _ux_utility_semaphore_create
#define _ux_system_semaphore_create_rc _ux_utility_semaphore_create
#define _ux_system_semaphore_create_norc _ux_utility_semaphore_create
#define _ux_system_semaphore_created(sem) ((sem)->tx_semaphore_id != UX_EMPTY)
#define _ux_system_semaphore_get _ux_utility_semaphore_get
#define _ux_system_semaphore_get_norc _ux_utility_semaphore_get
#define _ux_system_semaphore_waiting(sem) ((sem)->tx_semaphore_count != 0)
#define _ux_system_semaphore_delete _ux_utility_semaphore_delete
#define _ux_system_thread_create_rc _ux_utility_thread_create
#define _ux_system_semaphore_put _ux_utility_semaphore_put
#define _ux_system_thread_create _ux_utility_thread_create
#define _ux_system_thread_create_norc _ux_utility_thread_create
#define _ux_system_thread_created(t) ((t)->tx_thread_id != UX_EMPTY)
#define _ux_system_thread_delete _ux_utility_thread_delete
#define _ux_system_mutex_create _ux_utility_mutex_create
#define _ux_system_mutex_delete _ux_utility_mutex_delete
#define _ux_system_mutex_off _ux_utility_mutex_off
#define _ux_system_mutex_on _ux_utility_mutex_on
#define _ux_system_event_flags_create _ux_utility_event_flags_create
#define _ux_system_event_flags_created(e) ((e)->tx_event_flags_group_id != UX_EMPTY)
#define _ux_system_event_flags_delete _ux_utility_event_flags_delete
#define _ux_system_event_flags_get _ux_utility_event_flags_get
#define _ux_system_event_flags_set _ux_utility_event_flags_set
#define _ux_system_event_flags_set_rc _ux_utility_event_flags_set
#else
#define _ux_system_semaphore_create(sem,name,cnt) do{}while(0)
#define _ux_system_semaphore_create_rc(sem,name,cnt) (UX_SUCCESS)
#define _ux_system_semaphore_delete _ux_utility_semaphore_delete
#define _ux_system_thread_create_rc(t,name,entry,entry_param,stack,stack_size,priority,preempt_threshold,time_slice,auto_start) (UX_SUCCESS)
#define _ux_system_semaphore_create(sem,name,cnt) (UX_SUCCESS)
#define _ux_system_semaphore_create_norc(sem,name,cnt) do{}while(0)
#define _ux_system_semaphore_created(sem) (UX_FALSE)
#define _ux_system_semaphore_get(sem,opt) (UX_SUCCESS)
#define _ux_system_semaphore_get_norc(sem,opt) do{}while(0)
#define _ux_system_semaphore_waiting(sem) (UX_FALSE)
#define _ux_system_semaphore_delete(sem) do{}while(0)
#define _ux_system_semaphore_put(sem) do{}while(0)
#define _ux_system_thread_create(t,name,entry,entry_param,stack,stack_size,priority,preempt_threshold,time_slice,auto_start) (UX_SUCCESS)
#define _ux_system_thread_create_norc(t,name,entry,entry_param,stack,stack_size,priority,preempt_threshold,time_slice,auto_start) do{}while(0)
#define _ux_system_thread_created(t) (UX_FALSE)
#define _ux_system_thread_delete(t) do{}while(0)
#define _ux_system_mutex_create(mutex,name) do{}while(0)
#define _ux_system_mutex_delete(mutex) do{}while(0)
#define _ux_system_mutex_off(mutex) do{}while(0)
#define _ux_system_mutex_on(mutex) do{}while(0)
#define _ux_system_event_flags_create(g,name) (UX_SUCCESS)
#define _ux_system_event_flags_created(e) (UX_FALSE)
#define _ux_system_event_flags_delete(g) do{}while(0)
#define _ux_system_event_flags_get(g,req,gopt,actual,wopt) (*actual = 0)
#define _ux_system_event_flags_set(g,flags,option) do{(void)flags;}while(0)
#define _ux_system_event_flags_set_rc(g,flags,option) (UX_SUCCESS)
#endif
#if !defined(UX_DEVICE_STANDALONE)
@ -277,9 +309,9 @@ extern ALIGN_TYPE _ux_utility_time_elapsed(ALIGN_TYPE, ALIGN_TYPE);
#define _ux_host_mutex_delete(mutex) do{}while(0)
#define _ux_host_mutex_off(mutex) do{}while(0)
#define _ux_host_mutex_on(mutex) do{}while(0)
#define _ux_host_event_flags_create(g,name) do{}while(0)
#define _ux_host_event_flags_delete(g) do{}while(0)
#define _ux_host_event_flags_get(g,req,gopt,actual,wopt) do{}while(0)
#define _ux_host_event_flags_create(g,name) (UX_SUCCESS)
#define _ux_host_event_flags_delete(g) (UX_SUCCESS)
#define _ux_host_event_flags_get(g,req,gopt,actual,wopt) (UX_SUCCESS)
#define _ux_host_event_flags_set(g,flags,option) do{}while(0)
#define _ux_host_timer_create(t,name,func,arg,tick0,tick1,flag) (UX_SUCCESS)
#define _ux_host_timer_delete(t) do{}while(0)

View File

@ -142,7 +142,7 @@ UX_SLAVE_TRANSFER *transfer_request;
device -> ux_slave_device_descriptor.bMaxPacketSize0;
transfer_request -> ux_slave_transfer_request_transfer_length =
device -> ux_slave_device_descriptor.bMaxPacketSize0;
/* Attach the control endpoint to the transfer request. */
transfer_request -> ux_slave_transfer_request_endpoint = &device -> ux_slave_device_control_endpoint;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_activate PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -69,33 +69,37 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_activate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS_DPUMP *dpump;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_ENDPOINT *endpoint;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Store the class instance in the container. */
dpump = (UX_SLAVE_CLASS_DPUMP *) class -> ux_slave_class_instance;
dpump = (UX_SLAVE_CLASS_DPUMP *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Store the class instance into the interface. */
interface -> ux_slave_interface_class_instance = (VOID *)dpump;
interface_ptr -> ux_slave_interface_class_instance = (VOID *)dpump;
/* Now the opposite, store the interface in the class instance. */
dpump -> ux_slave_class_dpump_interface = interface;
dpump -> ux_slave_class_dpump_interface = interface_ptr;
/* Locate the endpoints. Interrupt for Control and Bulk in/out for Data. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Parse all endpoints. */
while (endpoint != UX_NULL)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_change PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -72,35 +72,39 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_change(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_DPUMP *dpump;
UX_SLAVE_CLASS *class;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_ENDPOINT *endpoint;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
dpump = (UX_SLAVE_CLASS_DPUMP *) class -> ux_slave_class_instance;
dpump = (UX_SLAVE_CLASS_DPUMP *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Locate the endpoints. Control and Bulk in/out for data. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Keep the alternate setting in the dpump structure. */
dpump -> ux_slave_class_dpump_alternate_setting = interface -> ux_slave_interface_descriptor.bAlternateSetting;
dpump -> ux_slave_class_dpump_alternate_setting = interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting;
/* If the interface to mount has a non zero alternate setting, the class is really active with
the endpoints active. If the interface reverts to alternate setting 0, it needs to have
the pending transactions terminated. */
if (interface -> ux_slave_interface_descriptor.bAlternateSetting != 0)
if (interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting != 0)
{
/* Parse all endpoints. */
@ -145,7 +149,7 @@ UX_SLAVE_ENDPOINT *endpoint;
ux_slave_transfer_request_data_pointer, 0, UX_SLAVE_REQUEST_DATA_MAX_LENGTH); /* Use case of memset is verified. */
/* Keep the alternate setting in the dpump structure. */
dpump -> ux_slave_class_dpump_alternate_setting = interface -> ux_slave_interface_descriptor.bAlternateSetting;
dpump -> ux_slave_class_dpump_alternate_setting = interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting;
#if defined(UX_DEVICE_STANDALONE)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_deactivate PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -67,28 +67,32 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_deactivate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_DPUMP *dpump;
UX_SLAVE_ENDPOINT *endpoint_in;
UX_SLAVE_ENDPOINT *endpoint_out;
UX_SLAVE_CLASS *class;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Store the class instance in the container. */
dpump = (UX_SLAVE_CLASS_DPUMP *) class -> ux_slave_class_instance;
dpump = (UX_SLAVE_CLASS_DPUMP *) class_ptr -> ux_slave_class_instance;
/* We need the interface to the class. */
interface = dpump -> ux_slave_class_dpump_interface;
interface_ptr = dpump -> ux_slave_class_dpump_interface;
/* Locate the endpoints. */
endpoint_in = interface -> ux_slave_interface_first_endpoint;
endpoint_in = interface_ptr -> 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)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_initialize PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -66,17 +66,21 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_initialize(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_CLASS_DPUMP *dpump;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_DPUMP_PARAMETER *dpump_parameter;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Create an instance of the device dpump class. */
dpump = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_SLAVE_CLASS_DPUMP));
@ -86,7 +90,7 @@ UX_SLAVE_CLASS_DPUMP_PARAMETER *dpump_parameter;
return(UX_MEMORY_INSUFFICIENT);
/* Save the address of the DPUMP instance inside the DPUMP container. */
class -> ux_slave_class_instance = (VOID *) dpump;
class_ptr -> ux_slave_class_instance = (VOID *) dpump;
/* Get the pointer to the application parameters for the cdc class. */
dpump_parameter = command -> ux_slave_class_command_parameter;

View File

@ -37,7 +37,7 @@ VOID _ux_device_class_dpump_thread(ULONG dpump_class);
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_thread PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -79,16 +79,20 @@ VOID _ux_device_class_dpump_thread(ULONG dpump_class);
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* refined macros names, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _ux_device_class_dpump_thread(ULONG dpump_class)
{
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS_DPUMP *dpump;
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_ENDPOINT *endpoint_in;
UX_SLAVE_ENDPOINT *endpoint_out;
UINT status;
@ -99,19 +103,19 @@ ULONG length;
{
/* Cast properly the dpump instance. */
UX_THREAD_EXTENSION_PTR_GET(class, UX_SLAVE_CLASS, dpump_class)
UX_THREAD_EXTENSION_PTR_GET(class_ptr, UX_SLAVE_CLASS, dpump_class)
/* Get the dpump instance from this class container. */
dpump = (UX_SLAVE_CLASS_DPUMP *) class -> ux_slave_class_instance;
dpump = (UX_SLAVE_CLASS_DPUMP *) class_ptr -> ux_slave_class_instance;
/* 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 = dpump -> ux_slave_class_dpump_interface;
interface_ptr = dpump -> ux_slave_class_dpump_interface;
/* Locate the endpoints. */
endpoint_in = interface -> ux_slave_interface_first_endpoint;
endpoint_in = interface_ptr -> 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)
@ -168,7 +172,7 @@ ULONG length;
/* We need to suspend ourselves. We will be resumed by the
device enumeration module. */
_ux_device_thread_suspend(&class -> ux_slave_class_thread);
_ux_device_thread_suspend(&class_ptr -> ux_slave_class_thread);
}
}

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_alternate_setting_get PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,13 +70,17 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_alternate_setting_get(ULONG interface_value)
{
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_DEVICE *device;
UX_SLAVE_ENDPOINT *endpoint;
UINT status;
@ -93,18 +97,18 @@ UINT status;
{
/* Obtain the pointer to the first interface attached. */
interface = device -> ux_slave_device_first_interface;
interface_ptr = device -> ux_slave_device_first_interface;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Start parsing each interface. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
#else
if (interface != UX_NULL)
if (interface_ptr != UX_NULL)
#endif
{
/* Check if this is the interface we have an inquiry for. */
if (interface -> ux_slave_interface_descriptor.bInterfaceNumber == interface_value)
if (interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber == interface_value)
{
/* Get the control endpoint of the device. */
@ -115,7 +119,7 @@ UINT status;
/* Set the value of the alternate setting in the buffer. */
*transfer_request -> ux_slave_transfer_request_data_pointer =
(UCHAR) interface -> ux_slave_interface_descriptor.bAlternateSetting;
(UCHAR) interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting;
/* Setup the length appropriately. */
transfer_request -> ux_slave_transfer_request_requested_length = 1;
@ -132,7 +136,7 @@ UINT status;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Get the next interface. */
interface = interface -> ux_slave_interface_next_interface;
interface_ptr = interface_ptr -> ux_slave_interface_next_interface;
#endif
}
}

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_alternate_setting_set PORTABLE C */
/* 6.1.9 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -81,13 +81,17 @@
/* 10-15-2021 Chaoqiong Xiao Modified comment(s), */
/* calculated payload size, */
/* resulting in version 6.1.9 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_alternate_setting_set(ULONG interface_value, ULONG alternate_setting_value)
{
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
#if !defined(UX_DEVICE_ALTERNATE_SETTING_SUPPORT_DISABLE)
UX_SLAVE_DCD *dcd;
UX_SLAVE_TRANSFER *transfer_request;
@ -102,7 +106,7 @@ UX_SLAVE_ENDPOINT *next_endpoint;
UX_SLAVE_ENDPOINT *endpoint_link;
ULONG endpoints_pool_number;
UX_SLAVE_CLASS_COMMAND class_command;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UINT status;
ULONG max_transfer_length, n_trans;
#endif
@ -118,40 +122,40 @@ ULONG max_transfer_length, n_trans;
return(UX_FUNCTION_NOT_SUPPORTED);
/* Find the current interface. */
interface = device -> ux_slave_device_first_interface;
interface_ptr = device -> ux_slave_device_first_interface;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Scan all interfaces if any. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
if (interface -> ux_slave_interface_descriptor.bInterfaceNumber == interface_value)
if (interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber == interface_value)
break;
else
interface = interface -> ux_slave_interface_next_interface;
interface_ptr = interface_ptr -> ux_slave_interface_next_interface;
}
#else
if (interface -> ux_slave_interface_descriptor.bInterfaceNumber != interface_value)
interface = UX_NULL;
if (interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber != interface_value)
interface_ptr = UX_NULL;
#endif
/* We must have found the interface pointer for the interface value
requested by the caller. */
if (interface == UX_NULL)
if (interface_ptr == UX_NULL)
{
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_INTERFACE_HANDLE_UNKNOWN);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface_ptr, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_INTERFACE_HANDLE_UNKNOWN);
}
/* If the host is requesting a change of alternate setting to the current one,
we do not need to do any work. */
if (interface -> ux_slave_interface_descriptor.bAlternateSetting == alternate_setting_value)
if (interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting == alternate_setting_value)
return(UX_SUCCESS);
#if defined(UX_DEVICE_ALTERNATE_SETTING_SUPPORT_DISABLE)
@ -160,7 +164,7 @@ ULONG max_transfer_length, n_trans;
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_FUNCTION_NOT_SUPPORTED);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, interface_ptr, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_FUNCTION_NOT_SUPPORTED);
#else
@ -230,7 +234,7 @@ ULONG max_transfer_length, n_trans;
/* We have found the right interface and alternate setting. Before
we mount all the endpoints for this interface, we need to
unmount the endpoints associated with the previous alternate setting. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
while (endpoint != UX_NULL)
{
@ -257,7 +261,7 @@ ULONG max_transfer_length, n_trans;
}
/* Now clear the interface endpoint entry. */
interface -> ux_slave_interface_first_endpoint = UX_NULL;
interface_ptr -> ux_slave_interface_first_endpoint = UX_NULL;
/* Point beyond the interface descriptor. */
device_framework_length -= (ULONG) *device_framework;
@ -344,7 +348,7 @@ ULONG max_transfer_length, n_trans;
transfer_request -> ux_slave_transfer_request_timeout = UX_WAIT_FOREVER;
/* Attach the interface to the endpoint. */
endpoint -> ux_slave_endpoint_interface = interface;
endpoint -> ux_slave_endpoint_interface = interface_ptr;
/* Attach the device to the endpoint. */
endpoint -> ux_slave_endpoint_device = device;
@ -362,15 +366,15 @@ ULONG max_transfer_length, n_trans;
}
/* Attach this endpoint to the end of the endpoint chain. */
if (interface -> ux_slave_interface_first_endpoint == UX_NULL)
if (interface_ptr -> ux_slave_interface_first_endpoint == UX_NULL)
{
interface -> ux_slave_interface_first_endpoint = endpoint;
interface_ptr -> ux_slave_interface_first_endpoint = endpoint;
}
else
{
/* Multiple endpoints exist, so find the end of the chain. */
endpoint_link = interface -> ux_slave_interface_first_endpoint;
endpoint_link = interface_ptr -> ux_slave_interface_first_endpoint;
while (endpoint_link -> ux_slave_endpoint_next_endpoint != UX_NULL)
endpoint_link = endpoint_link -> ux_slave_endpoint_next_endpoint;
endpoint_link -> ux_slave_endpoint_next_endpoint = endpoint;
@ -403,13 +407,13 @@ ULONG max_transfer_length, n_trans;
}
/* The interface descriptor in the current class must be changed to the new alternate setting. */
_ux_utility_memory_copy(&interface -> ux_slave_interface_descriptor, &interface_descriptor, sizeof(UX_INTERFACE_DESCRIPTOR)); /* Use case of memcpy is verified. */
_ux_utility_memory_copy(&interface_ptr -> ux_slave_interface_descriptor, &interface_descriptor, sizeof(UX_INTERFACE_DESCRIPTOR)); /* Use case of memcpy is verified. */
/* Get the class for the interface. */
class = _ux_system_slave -> ux_system_slave_interface_class_array[interface -> ux_slave_interface_descriptor.bInterfaceNumber];
class_ptr = _ux_system_slave -> ux_system_slave_interface_class_array[interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber];
/* Check if class driver is available. */
if (class == UX_NULL || class -> ux_slave_class_status == UX_UNUSED)
if (class_ptr == UX_NULL || class_ptr -> ux_slave_class_status == UX_UNUSED)
{
return (UX_NO_CLASS_MATCH);
@ -418,16 +422,16 @@ ULONG max_transfer_length, n_trans;
/* The interface attached to this configuration must be changed at the class
level. */
class_command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_CHANGE;
class_command.ux_slave_class_command_interface = (VOID *) interface;
class_command.ux_slave_class_command_interface = (VOID *) interface_ptr;
/* And store it. */
class_command.ux_slave_class_command_class_ptr = class;
class_command.ux_slave_class_command_class_ptr = class_ptr;
/* We can now memorize the interface pointer associated with this class. */
class -> ux_slave_class_interface = interface;
class_ptr -> ux_slave_class_interface = interface_ptr;
/* We have found a potential candidate. Call this registered class entry function to change the alternate setting. */
status = class -> ux_slave_class_entry_function(&class_command);
status = class_ptr -> ux_slave_class_entry_function(&class_command);
/* We are done here. */
return(status);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_clear_feature PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -71,6 +71,10 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_clear_feature(ULONG request_type, ULONG request_value, ULONG request_index)
@ -78,7 +82,7 @@ UINT _ux_device_stack_clear_feature(ULONG request_type, ULONG request_value, UL
UX_SLAVE_DCD *dcd;
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_ENDPOINT *endpoint_target;
@ -127,15 +131,15 @@ UX_SLAVE_ENDPOINT *endpoint_target;
/* The only clear feature for endpoint is ENDPOINT_STALL. This clears
the endpoint of the stall situation and resets its data toggle.
We need to find the endpoint through the interface(s). */
interface = device -> ux_slave_device_first_interface;
interface_ptr = device -> ux_slave_device_first_interface;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
#endif
/* Get the first endpoint for this interface. */
endpoint_target = interface -> ux_slave_interface_first_endpoint;
endpoint_target = interface_ptr -> ux_slave_interface_first_endpoint;
/* Parse all the endpoints. */
while (endpoint_target != UX_NULL)
@ -161,7 +165,7 @@ UX_SLAVE_ENDPOINT *endpoint_target;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Next interface. */
interface = interface -> ux_slave_interface_next_interface;
interface_ptr = interface_ptr -> ux_slave_interface_next_interface;
}
#endif

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_configuration_set PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -76,6 +76,10 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_configuration_set(ULONG configuration_value)
@ -88,7 +92,7 @@ ULONG descriptor_length;
UCHAR descriptor_type;
UX_CONFIGURATION_DESCRIPTOR configuration_descriptor = { 0 };
UX_INTERFACE_DESCRIPTOR interface_descriptor;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
UX_SLAVE_INTERFACE *next_interface;
#endif
@ -165,19 +169,19 @@ ULONG class_index;
{
/* Get the pointer to the first interface. */
interface = device -> ux_slave_device_first_interface;
interface_ptr = device -> ux_slave_device_first_interface;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Deactivate all the interfaces if any. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
#endif
/* Build all the fields of the Class Command. */
class_command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_DEACTIVATE;
class_command.ux_slave_class_command_interface = (VOID *) interface;
class_command.ux_slave_class_command_interface = (VOID *) interface_ptr;
/* Get the pointer to the class container of this interface. */
class_inst = interface -> ux_slave_interface_class;
class_inst = interface_ptr -> ux_slave_interface_class;
/* Store the class container. */
class_command.ux_slave_class_command_class_ptr = class_inst;
@ -190,15 +194,15 @@ ULONG class_index;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Get the next interface. */
next_interface = interface -> ux_slave_interface_next_interface;
next_interface = interface_ptr -> ux_slave_interface_next_interface;
#endif
/* Remove the interface and all endpoints associated with it. */
_ux_device_stack_interface_delete(interface);
_ux_device_stack_interface_delete(interface_ptr);
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Now we refresh the interface pointer. */
interface = next_interface;
interface_ptr = next_interface;
}
#endif

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_control_request_process PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -87,6 +87,10 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added printer support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_control_request_process(UX_SLAVE_TRANSFER *transfer_request)
@ -94,7 +98,7 @@ UINT _ux_device_stack_control_request_process(UX_SLAVE_TRANSFER *transfer_reque
UX_SLAVE_DCD *dcd;
UX_SLAVE_DEVICE *device;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_COMMAND class_command;
ULONG request_type;
ULONG request;
@ -196,10 +200,10 @@ ULONG application_data_length;
{
/* Get the class for the interface. */
class = _ux_system_slave -> ux_system_slave_interface_class_array[class_index];
class_ptr = _ux_system_slave -> ux_system_slave_interface_class_array[class_index];
/* If class is not ready, try next. */
if (class == UX_NULL)
if (class_ptr == UX_NULL)
continue;
/* Is the request target to an interface? */
@ -213,17 +217,17 @@ ULONG application_data_length;
wIndex is interface index (for recommended index sequence the interface
number is same as interface index inside configuration). */
if (((request_index & 0xFF) != class_index) ||
((class -> ux_slave_class_interface -> ux_slave_interface_descriptor.bInterfaceClass == 0x07) &&
((class_ptr -> ux_slave_class_interface -> ux_slave_interface_descriptor.bInterfaceClass == 0x07) &&
(request == 0x00) &&
*(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_INDEX + 1) != class_index))
continue;
}
/* Memorize the class in the command. */
class_command.ux_slave_class_command_class_ptr = class;
class_command.ux_slave_class_command_class_ptr = class_ptr;
/* We have found a potential candidate. Call this registered class entry function. */
status = class -> ux_slave_class_entry_function(&class_command);
status = class_ptr -> ux_slave_class_entry_function(&class_command);
/* The status simply tells us if the registered class handled the
command - if there was an issue processing the command, it would've

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_disconnect PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -73,6 +73,10 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_disconnect(VOID)
@ -80,11 +84,11 @@ UINT _ux_device_stack_disconnect(VOID)
UX_SLAVE_DCD *dcd;
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
UX_SLAVE_INTERFACE *next_interface;
#endif
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_COMMAND class_command;
UINT status = UX_ERROR;
@ -105,41 +109,41 @@ UINT status = UX_ERROR;
if (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED)
{
/* Get the pointer to the first interface. */
interface = device -> ux_slave_device_first_interface;
interface_ptr = device -> ux_slave_device_first_interface;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Parse all the interfaces if any. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
#endif
/* Build all the fields of the Class Command. */
class_command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_DEACTIVATE;
class_command.ux_slave_class_command_interface = (VOID *) interface;
class_command.ux_slave_class_command_interface = (VOID *) interface_ptr;
/* Get the pointer to the class container of this interface. */
class = interface -> ux_slave_interface_class;
class_ptr = interface_ptr -> ux_slave_interface_class;
/* Store the class container. */
class_command.ux_slave_class_command_class_ptr = class;
class_command.ux_slave_class_command_class_ptr = class_ptr;
/* If there is a class container for this instance, deactivate it. */
if (class != UX_NULL)
if (class_ptr != UX_NULL)
/* Call the class with the DEACTIVATE signal. */
class -> ux_slave_class_entry_function(&class_command);
class_ptr -> ux_slave_class_entry_function(&class_command);
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Get the next interface. */
next_interface = interface -> ux_slave_interface_next_interface;
next_interface = interface_ptr -> ux_slave_interface_next_interface;
#endif
/* Remove the interface and all endpoints associated with it. */
_ux_device_stack_interface_delete(interface);
_ux_device_stack_interface_delete(interface_ptr);
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Now we refresh the interface pointer. */
interface = next_interface;
interface_ptr = next_interface;
}
#endif

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_interface_delete PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -69,9 +69,13 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_interface_delete(UX_SLAVE_INTERFACE *interface)
UINT _ux_device_stack_interface_delete(UX_SLAVE_INTERFACE *interface_ptr)
{
UX_SLAVE_DCD *dcd;
@ -80,16 +84,16 @@ UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_ENDPOINT *next_endpoint;
/* If trace is enabled, register this object. */
UX_TRACE_OBJECT_UNREGISTER(interface);
UX_TRACE_OBJECT_UNREGISTER(interface_ptr);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_INTERFACE_DELETE, interface, 0, 0, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_INTERFACE_DELETE, interface_ptr, 0, 0, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0)
/* Get the pointer to the device. */
device = &_ux_system_slave -> ux_system_slave_device;
/* Find the first endpoints associated with this interface. */
next_endpoint = interface -> ux_slave_interface_first_endpoint;
next_endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Parse all the endpoints. */
while (next_endpoint != UX_NULL)
@ -119,14 +123,14 @@ UX_SLAVE_ENDPOINT *next_endpoint;
/* It's always from first one (to delete). */
/* Rebuild the first link. */
device -> ux_slave_device_first_interface = interface -> ux_slave_interface_next_interface;
device -> ux_slave_device_first_interface = interface_ptr -> ux_slave_interface_next_interface;
/* The interface is removed from the link, its memory must be cleaned and returned to the pool. */
interface -> ux_slave_interface_class = UX_NULL;
interface -> ux_slave_interface_class_instance = UX_NULL;
interface -> ux_slave_interface_next_interface = UX_NULL;
interface -> ux_slave_interface_first_endpoint = UX_NULL;
interface -> ux_slave_interface_status = UX_UNUSED;
interface_ptr -> ux_slave_interface_class = UX_NULL;
interface_ptr -> ux_slave_interface_class_instance = UX_NULL;
interface_ptr -> ux_slave_interface_next_interface = UX_NULL;
interface_ptr -> ux_slave_interface_first_endpoint = UX_NULL;
interface_ptr -> ux_slave_interface_status = UX_UNUSED;
/* Return successful completion. */
return(UX_SUCCESS);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_interface_get PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -71,6 +71,10 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_interface_get(UINT interface_value)
@ -78,7 +82,7 @@ UINT _ux_device_stack_interface_get(UINT interface_value)
UX_SLAVE_DCD *dcd;
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_DEVICE *device;
UX_SLAVE_ENDPOINT *endpoint;
UINT status;
@ -101,16 +105,16 @@ UINT status;
{
/* Get the pointer to the first interface. */
interface = device -> ux_slave_device_first_interface;
interface_ptr = device -> ux_slave_device_first_interface;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Parse the interfaces if any. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
#endif
/* Check if this is the interface we have an inquiry for. */
if (interface -> ux_slave_interface_descriptor.bInterfaceNumber == interface_value)
if (interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber == interface_value)
{
/* Get the pointer to the transfer request associated with the endpoint. */
@ -118,7 +122,7 @@ UINT status;
/* Set the value of the alternate setting in the buffer. */
*transfer_request -> ux_slave_transfer_request_data_pointer =
(UCHAR) interface -> ux_slave_interface_descriptor.bAlternateSetting;
(UCHAR) interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting;
/* Setup the length appropriately. */
transfer_request -> ux_slave_transfer_request_requested_length = 1;
@ -135,7 +139,7 @@ UINT status;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Get the next interface. */
interface = interface -> ux_slave_interface_next_interface;
interface_ptr = interface_ptr -> ux_slave_interface_next_interface;
}
#endif

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_interface_set PORTABLE C */
/* 6.1.9 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -79,6 +79,10 @@
/* 10-15-2021 Chaoqiong Xiao Modified comment(s), */
/* calculated payload size, */
/* resulting in version 6.1.9 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_interface_set(UCHAR * device_framework, ULONG device_framework_length,
@ -88,7 +92,7 @@ UINT _ux_device_stack_interface_set(UCHAR * device_framework, ULONG device_fram
UX_SLAVE_DCD *dcd;
UX_SLAVE_DEVICE *device;
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
UX_SLAVE_INTERFACE *interface_link;
ULONG interfaces_pool_number;
@ -114,18 +118,18 @@ ULONG max_transfer_length, n_trans;
/* Find a free interface in the pool and hook it to the
existing interface. */
interface = device -> ux_slave_device_interfaces_pool;
interface_ptr = device -> ux_slave_device_interfaces_pool;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
interfaces_pool_number = device -> ux_slave_device_interfaces_pool_number;
while (interfaces_pool_number != 0)
{
/* Check if this interface is free. */
if (interface -> ux_slave_interface_status == UX_UNUSED)
if (interface_ptr -> ux_slave_interface_status == UX_UNUSED)
break;
/* Try the next interface. */
interface++;
interface_ptr++;
/* Decrement the number of interfaces left to scan in the pool. */
interfaces_pool_number--;
@ -137,22 +141,22 @@ ULONG max_transfer_length, n_trans;
#else
/* Check if this interface is free. */
if (interface -> ux_slave_interface_status != UX_UNUSED)
if (interface_ptr -> ux_slave_interface_status != UX_UNUSED)
return(UX_MEMORY_INSUFFICIENT);
#endif
/* Mark this interface as used now. */
interface -> ux_slave_interface_status = UX_USED;
interface_ptr -> ux_slave_interface_status = UX_USED;
/* If trace is enabled, register this object. */
UX_TRACE_OBJECT_REGISTER(UX_TRACE_DEVICE_OBJECT_TYPE_INTERFACE, interface, 0, 0, 0)
UX_TRACE_OBJECT_REGISTER(UX_TRACE_DEVICE_OBJECT_TYPE_INTERFACE, interface_ptr, 0, 0, 0)
/* Parse the descriptor in something more readable. */
_ux_utility_descriptor_parse(device_framework,
_ux_system_interface_descriptor_structure,
UX_INTERFACE_DESCRIPTOR_ENTRIES,
(UCHAR *) &interface -> ux_slave_interface_descriptor);
(UCHAR *) &interface_ptr -> ux_slave_interface_descriptor);
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
@ -160,7 +164,7 @@ ULONG max_transfer_length, n_trans;
if (device -> ux_slave_device_first_interface == UX_NULL)
{
device -> ux_slave_device_first_interface = interface;
device -> ux_slave_device_first_interface = interface_ptr;
}
else
{
@ -168,12 +172,12 @@ ULONG max_transfer_length, n_trans;
interface_link = device -> ux_slave_device_first_interface;
while (interface_link -> ux_slave_interface_next_interface != UX_NULL)
interface_link = interface_link -> ux_slave_interface_next_interface;
interface_link -> ux_slave_interface_next_interface = interface;
interface_link -> ux_slave_interface_next_interface = interface_ptr;
}
#else
/* It must be very first one. */
device -> ux_slave_device_first_interface = interface;
device -> ux_slave_device_first_interface = interface_ptr;
#endif
/* Point beyond the interface descriptor. */
@ -261,7 +265,7 @@ ULONG max_transfer_length, n_trans;
transfer_request -> ux_slave_transfer_request_timeout = UX_WAIT_FOREVER;
/* Attach the interface to the endpoint. */
endpoint -> ux_slave_endpoint_interface = interface;
endpoint -> ux_slave_endpoint_interface = interface_ptr;
/* Attach the device to the endpoint. */
endpoint -> ux_slave_endpoint_device = device;
@ -279,15 +283,15 @@ ULONG max_transfer_length, n_trans;
}
/* Attach this endpoint to the end of the endpoint chain. */
if (interface -> ux_slave_interface_first_endpoint == UX_NULL)
if (interface_ptr -> ux_slave_interface_first_endpoint == UX_NULL)
{
interface -> ux_slave_interface_first_endpoint = endpoint;
interface_ptr -> ux_slave_interface_first_endpoint = endpoint;
}
else
{
/* Multiple endpoints exist, so find the end of the chain. */
endpoint_link = interface -> ux_slave_interface_first_endpoint;
endpoint_link = interface_ptr -> ux_slave_interface_first_endpoint;
while (endpoint_link -> ux_slave_endpoint_next_endpoint != UX_NULL)
endpoint_link = endpoint_link -> ux_slave_endpoint_next_endpoint;
endpoint_link -> ux_slave_endpoint_next_endpoint = endpoint;
@ -300,7 +304,7 @@ ULONG max_transfer_length, n_trans;
/* If the descriptor is a configuration or interface,
we have parsed and mounted all endpoints.
The interface attached to this configuration must be started at the class level. */
status = _ux_device_stack_interface_start(interface);
status = _ux_device_stack_interface_start(interface_ptr);
/* Return the status to the caller. */
return(status);
@ -318,7 +322,7 @@ ULONG max_transfer_length, n_trans;
/* The interface attached to this configuration must be started at the class
level. */
status = _ux_device_stack_interface_start(interface);
status = _ux_device_stack_interface_start(interface_ptr);
/* Return the status to the caller. */
return(status);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_interface_start PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -68,22 +68,26 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_interface_start(UX_SLAVE_INTERFACE *interface)
UINT _ux_device_stack_interface_start(UX_SLAVE_INTERFACE *interface_ptr)
{
UX_SLAVE_DEVICE *device;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UINT status;
UX_SLAVE_CLASS_COMMAND class_command;
/* Get the class for the interface. */
class = _ux_system_slave -> ux_system_slave_interface_class_array[interface -> ux_slave_interface_descriptor.bInterfaceNumber];
class_ptr = _ux_system_slave -> ux_system_slave_interface_class_array[interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber];
/* Check if class driver is available. */
if (class == UX_NULL)
if (class_ptr == UX_NULL)
/* There is no class driver supported. */
return (UX_NO_CLASS_MATCH);
@ -93,35 +97,35 @@ UX_SLAVE_CLASS_COMMAND class_command;
/* Build all the fields of the Class Command. */
class_command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_QUERY;
class_command.ux_slave_class_command_interface = (VOID *)interface;
class_command.ux_slave_class_command_class = interface -> ux_slave_interface_descriptor.bInterfaceClass;
class_command.ux_slave_class_command_subclass = interface -> ux_slave_interface_descriptor.bInterfaceSubClass;
class_command.ux_slave_class_command_protocol = interface -> ux_slave_interface_descriptor.bInterfaceProtocol;
class_command.ux_slave_class_command_interface = (VOID *)interface_ptr;
class_command.ux_slave_class_command_class = interface_ptr -> ux_slave_interface_descriptor.bInterfaceClass;
class_command.ux_slave_class_command_subclass = interface_ptr -> ux_slave_interface_descriptor.bInterfaceSubClass;
class_command.ux_slave_class_command_protocol = interface_ptr -> ux_slave_interface_descriptor.bInterfaceProtocol;
class_command.ux_slave_class_command_vid = device -> ux_slave_device_descriptor.idVendor;
class_command.ux_slave_class_command_pid = device -> ux_slave_device_descriptor.idProduct;
/* We can now memorize the interface pointer associated with this class. */
class -> ux_slave_class_interface = interface;
class_ptr -> ux_slave_class_interface = interface_ptr;
/* We have found a potential candidate. Call this registered class entry function. */
status = class -> ux_slave_class_entry_function(&class_command);
status = class_ptr -> ux_slave_class_entry_function(&class_command);
/* The status tells us if the registered class wants to own this class. */
if (status == UX_SUCCESS)
{
/* Store the class container. */
class_command.ux_slave_class_command_class_ptr = class;
class_command.ux_slave_class_command_class_ptr = class_ptr;
/* Store the command. */
class_command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_ACTIVATE;
/* Activate the class. */
status = class -> ux_slave_class_entry_function(&class_command);
status = class_ptr -> ux_slave_class_entry_function(&class_command);
/* If the class was successfully activated, set the class for the interface. */
if(status == UX_SUCCESS)
interface -> ux_slave_interface_class = class;
interface_ptr -> ux_slave_interface_class = class_ptr;
return(status);
}

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_set_feature PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -72,6 +72,10 @@
/* definitions, stalled on not */
/* supported device requests, */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_stack_set_feature(ULONG request_type, ULONG request_value, ULONG request_index)
@ -79,7 +83,7 @@ UINT _ux_device_stack_set_feature(ULONG request_type, ULONG request_value, ULON
UX_SLAVE_DCD *dcd;
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_ENDPOINT *endpoint_target;
@ -155,14 +159,14 @@ UX_SLAVE_ENDPOINT *endpoint_target;
/* The only set feature for endpoint is ENDPOINT_STALL. This forces
the endpoint to the stall situation.
We need to find the endpoint through the interface(s). */
interface = device -> ux_slave_device_first_interface;
interface_ptr = device -> ux_slave_device_first_interface;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
#endif
/* Get the first endpoint for this interface. */
endpoint_target = interface -> ux_slave_interface_first_endpoint;
endpoint_target = interface_ptr -> ux_slave_interface_first_endpoint;
/* Parse all the endpoints. */
while (endpoint_target != UX_NULL)
@ -185,7 +189,7 @@ UX_SLAVE_ENDPOINT *endpoint_target;
#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1
/* Next interface. */
interface = interface -> ux_slave_interface_next_interface;
interface_ptr = interface_ptr -> ux_slave_interface_next_interface;
}
#endif

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_sim_host_request_isochronous_transfer PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -74,6 +74,9 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed partial transfer, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_hcd_sim_host_request_isochronous_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request)
@ -170,15 +173,15 @@ ULONG n_trans, packet_size;
data_td -> ux_sim_host_iso_td_buffer = data_pointer;
/* Update the length of the transfer for this TD. */
data_td -> ux_sim_host_iso_td_length = isoch_packet_payload_length;
data_td -> ux_sim_host_iso_td_length = UX_MIN(transfer_request_payload_length, isoch_packet_payload_length);
/* Attach the endpoint and transfer request to the TD. */
data_td -> ux_sim_host_iso_td_transfer_request = transfer_request;
data_td -> ux_sim_host_iso_td_ed = ed;
/* Adjust the data payload length and the data payload pointer. */
transfer_request_payload_length -= isoch_packet_payload_length;
data_pointer += isoch_packet_payload_length;
transfer_request_payload_length -= data_td -> ux_sim_host_iso_td_length;
data_pointer += data_td -> ux_sim_host_iso_td_length;
/* Prepare the next frame for the next TD in advance. */
current_frame_number++;

View File

@ -36,7 +36,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_sim_host_transaction_schedule PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -91,6 +91,11 @@
/* before semaphore wakeup to */
/* avoid a race condition, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* refined device ZLP flow, */
/* adjusted control request */
/* data length handling, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_hcd_sim_host_transaction_schedule(UX_HCD_SIM_HOST *hcd_sim_host, UX_HCD_SIM_HOST_ED *ed)
@ -174,8 +179,11 @@ UX_SLAVE_DCD *dcd;
/* For control transfer, stall is for protocol error and it's cleared any time when SETUP is received */
slave_ed -> ux_sim_slave_ed_status &= ~(ULONG)UX_DCD_SIM_SLAVE_ED_STATUS_STALLED;
/* Set the length to the setup transaction buffer. */
slave_transfer_request -> ux_slave_transfer_request_actual_length = td -> ux_sim_host_td_length;
/* Validate the length to the setup transaction buffer. */
UX_ASSERT(td -> ux_sim_host_td_length == 8);
/* Reset actual data length (not including SETUP received) so far. */
slave_transfer_request -> ux_slave_transfer_request_actual_length = 0;
/* Move the buffer from the host TD to the device TD. */
_ux_utility_memory_copy(slave_transfer_request -> ux_slave_transfer_request_setup,
@ -216,9 +224,6 @@ UX_SLAVE_DCD *dcd;
slave_transfer_request -> ux_slave_transfer_request_requested_length = UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH;
}
/* Reset what we have received so far. */
slave_transfer_request -> ux_slave_transfer_request_actual_length = 0;
/* And reprogram the current buffer address to the beginning of the buffer. */
slave_transfer_request -> ux_slave_transfer_request_current_data_pointer = slave_transfer_request -> ux_slave_transfer_request_data_pointer;
@ -404,17 +409,22 @@ UX_SLAVE_DCD *dcd;
else
transaction_length = td -> ux_sim_host_td_length;
if (td -> ux_sim_host_td_direction == UX_HCD_SIM_HOST_TD_OUT)
if (transaction_length)
{
if (td -> ux_sim_host_td_direction == UX_HCD_SIM_HOST_TD_OUT)
/* Send the requested host data to the device. */
_ux_utility_memory_copy(slave_transfer_request -> ux_slave_transfer_request_current_data_pointer, td -> ux_sim_host_td_buffer,
transaction_length); /* Use case of memcpy is verified. */
/* Send the requested host data to the device. */
_ux_utility_memory_copy(slave_transfer_request -> ux_slave_transfer_request_current_data_pointer,
td -> ux_sim_host_td_buffer,
transaction_length); /* Use case of memcpy is verified. */
else
else
/* Send the requested host data to the device. */
_ux_utility_memory_copy(td -> ux_sim_host_td_buffer, slave_transfer_request -> ux_slave_transfer_request_current_data_pointer,
transaction_length); /* Use case of memcpy is verified. */
/* Send the requested host data to the device. */
_ux_utility_memory_copy(td -> ux_sim_host_td_buffer,
slave_transfer_request -> ux_slave_transfer_request_current_data_pointer,
transaction_length); /* Use case of memcpy is verified. */
}
/* Update buffers. */
td -> ux_sim_host_td_buffer += transaction_length;
@ -454,12 +464,11 @@ UX_SLAVE_DCD *dcd;
wake_host = UX_TRUE;
wake_slave = UX_TRUE;
}
else if ((slave_transfer_request -> ux_slave_transfer_request_actual_length == slave_transfer_request -> ux_slave_transfer_request_requested_length &&
slave_transfer_request -> ux_slave_transfer_request_force_zlp == UX_TRUE) ||
(transaction_length == 0) ||
(transaction_length % slave_endpoint -> ux_slave_endpoint_descriptor.wMaxPacketSize))
else if ((transaction_length == 0) ||
(transaction_length % slave_endpoint -> ux_slave_endpoint_descriptor.wMaxPacketSize))
{
/* Host got ZLP or short packet. */
wake_host = UX_TRUE;
wake_slave = UX_TRUE;
}
@ -471,8 +480,15 @@ UX_SLAVE_DCD *dcd;
wake_host = UX_TRUE;
/* Is the slaves's transfer completed? */
if (slave_transfer_request -> ux_slave_transfer_request_actual_length == slave_transfer_request -> ux_slave_transfer_request_requested_length)
wake_slave = UX_TRUE;
if (slave_transfer_request -> ux_slave_transfer_request_actual_length ==
slave_transfer_request -> ux_slave_transfer_request_requested_length)
{
if (slave_transfer_request -> ux_slave_transfer_request_requested_length == 0 ||
slave_transfer_request -> ux_slave_transfer_request_force_zlp == 0)
wake_slave = UX_TRUE;
else
slave_transfer_request -> ux_slave_transfer_request_force_zlp = 0;
}
}
if (wake_slave == UX_TRUE)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_dpump_activate PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,19 +78,23 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* internal clean up, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_class_dpump_activate(UX_HOST_CLASS_COMMAND *command)
{
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UX_HOST_CLASS_DPUMP *dpump;
UINT status;
/* The data pump is always activated by the interface descriptor and not the
device descriptor. */
interface = (UX_INTERFACE *) command -> ux_host_class_command_container;
interface_ptr = (UX_INTERFACE *) command -> ux_host_class_command_container;
/* Obtain memory for this class instance. */
dpump = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_HOST_CLASS_DPUMP));
@ -101,13 +105,13 @@ UINT status;
dpump -> ux_host_class_dpump_class = command -> ux_host_class_command_class_ptr;
/* Store the interface container into the dpump class instance. */
dpump -> ux_host_class_dpump_interface = interface;
dpump -> ux_host_class_dpump_interface = interface_ptr;
/* Store the device container into the dpump class instance. */
dpump -> ux_host_class_dpump_device = interface -> ux_interface_configuration -> ux_configuration_device;
dpump -> ux_host_class_dpump_device = interface_ptr -> ux_interface_configuration -> ux_configuration_device;
/* This instance of the device must also be stored in the interface container. */
interface -> ux_interface_class_instance = (VOID *) dpump;
interface_ptr -> ux_interface_class_instance = (VOID *) dpump;
/* Create this class instance. */
_ux_host_stack_class_instance_create(dpump -> ux_host_class_dpump_class, (VOID *) dpump);

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_dpump_ioctl PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -71,6 +71,10 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_class_dpump_ioctl(UX_HOST_CLASS_DPUMP *dpump, ULONG ioctl_function,
@ -78,7 +82,7 @@ UINT _ux_host_class_dpump_ioctl(UX_HOST_CLASS_DPUMP *dpump, ULONG ioctl_functio
{
UX_CONFIGURATION *configuration;
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UINT status;
/* Ensure the instance is valid. */
@ -104,8 +108,8 @@ UINT status;
/* The parameter value has the alternate setting number.
We need to scan the entire device framework. Only one configuration for data pump device framework. */
interface = dpump -> ux_host_class_dpump_interface;
configuration = interface -> ux_interface_configuration;
interface_ptr = dpump -> ux_host_class_dpump_interface;
configuration = interface_ptr -> ux_interface_configuration;
/* Do some verification just in case ! */
if (configuration == UX_NULL)
@ -118,25 +122,25 @@ UINT status;
}
/* Point to the first interface. */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
/* Loop on all interfaces and alternate settings for this device in search of the right alternate setting. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* Check the alternate setting. */
if (interface -> ux_interface_descriptor.bAlternateSetting == (ULONG) (ALIGN_TYPE) parameter)
if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == (ULONG) (ALIGN_TYPE) parameter)
{
/* We have found the alternate setting. Select it now. */
status = _ux_host_stack_interface_setting_select(interface);
status = _ux_host_stack_interface_setting_select(interface_ptr);
/* We are done here. */
return(status);
}
/* Next interface. */
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
}
/* We come here when the alternate setting was not found. */

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_configuration_instance_create PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -68,29 +68,33 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_configuration_instance_create(UX_CONFIGURATION *configuration)
{
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UINT status;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_CONFIGURATION_INSTANCE_CREATE, configuration, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* Obtain the first interface for this configuration. */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
/* Each selected alternate setting 0 for each interface must be created. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* Check if we are dealing with the first alternate setting. */
if (interface -> ux_interface_descriptor.bAlternateSetting == 0)
if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == 0)
{
/* Create the interface. */
status = _ux_host_stack_interface_instance_create(interface);
status = _ux_host_stack_interface_instance_create(interface_ptr);
/* Check status, the controller may have refused the endpoint creation. */
if (status != UX_SUCCESS)
@ -101,7 +105,7 @@ UINT status;
}
/* Next interface. */
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
}
/* Return successful completion. */

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_configuration_instance_delete PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -68,40 +68,44 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _ux_host_stack_configuration_instance_delete(UX_CONFIGURATION *configuration)
{
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
ULONG current_alternate_setting;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_CONFIGURATION_INSTANCE_DELETE, configuration, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* Obtain the first interface for this configuration. */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
/* In order to keep the compiler happy, we reset the alternate setting. */
current_alternate_setting = 0;
/* Each selected alternate setting for each interface must be deleted. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* If this is the first alternate setting, the current alternate setting is maintained here. */
if (interface -> ux_interface_descriptor.bAlternateSetting == 0)
if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == 0)
{
current_alternate_setting = interface -> ux_interface_current_alternate_setting;
current_alternate_setting = interface_ptr -> ux_interface_current_alternate_setting;
}
if (interface -> ux_interface_descriptor.bAlternateSetting == current_alternate_setting)
if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == current_alternate_setting)
{
_ux_host_stack_interface_instance_delete(interface);
_ux_host_stack_interface_instance_delete(interface_ptr);
}
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
}
return;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_configuration_interface_get PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -73,11 +73,15 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_configuration_interface_get(UX_CONFIGURATION *configuration,
UINT interface_index, UINT alternate_setting_index,
UX_INTERFACE **interface)
UX_INTERFACE **ux_interface)
{
UINT current_interface_number;
@ -128,7 +132,7 @@ UX_INTERFACE *current_interface;
/* We have found the right interface/alternate setting combination. Set the
interface return pointer. */
*interface = current_interface;
*ux_interface = current_interface;
/* Return success to caller. */
return(UX_SUCCESS);
@ -153,7 +157,7 @@ UX_INTERFACE *current_interface;
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_INTERFACE_HANDLE_UNKNOWN);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, ux_interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_INTERFACE_HANDLE_UNKNOWN);
}
@ -177,7 +181,7 @@ UX_INTERFACE *current_interface;
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_INTERFACE_HANDLE_UNKNOWN);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, ux_interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
/* Didn't find the right interface/alternate setting, return an error! */
return(UX_INTERFACE_HANDLE_UNKNOWN);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_configuration_interface_scan PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -73,14 +73,18 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_configuration_interface_scan(UX_CONFIGURATION *configuration)
{
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UINT nb_class_owners;
UX_HOST_CLASS *class;
UX_HOST_CLASS *class_ptr;
UX_HOST_CLASS_COMMAND class_command;
UINT status;
@ -89,42 +93,42 @@ UINT status;
nb_class_owners = 0;
/* Get the first interface container for this configuration. */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
/* We now scan all the alternate settings 0 for each of the interfaces. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* Is there a default interface? */
if(interface -> ux_interface_descriptor.bAlternateSetting == 0)
if(interface_ptr -> ux_interface_descriptor.bAlternateSetting == 0)
{
/* We have a default interface for this configuration. Call each class
with the class\subclass\protocol. We include the IAD for the cdc classes. */
class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_QUERY;
class_command.ux_host_class_command_container = (VOID *)interface;
class_command.ux_host_class_command_container = (VOID *)interface_ptr;
class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_CSP;
class_command.ux_host_class_command_class = interface -> ux_interface_descriptor.bInterfaceClass;
class_command.ux_host_class_command_subclass = interface -> ux_interface_descriptor.bInterfaceSubClass;
class_command.ux_host_class_command_protocol = interface -> ux_interface_descriptor.bInterfaceProtocol;
class_command.ux_host_class_command_iad_class = interface -> ux_interface_iad_class ;
class_command.ux_host_class_command_iad_subclass = interface -> ux_interface_iad_subclass;
class_command.ux_host_class_command_iad_protocol = interface -> ux_interface_iad_protocol;
class_command.ux_host_class_command_class = interface_ptr -> ux_interface_descriptor.bInterfaceClass;
class_command.ux_host_class_command_subclass = interface_ptr -> ux_interface_descriptor.bInterfaceSubClass;
class_command.ux_host_class_command_protocol = interface_ptr -> ux_interface_descriptor.bInterfaceProtocol;
class_command.ux_host_class_command_iad_class = interface_ptr -> ux_interface_iad_class ;
class_command.ux_host_class_command_iad_subclass = interface_ptr -> ux_interface_iad_subclass;
class_command.ux_host_class_command_iad_protocol = interface_ptr -> ux_interface_iad_protocol;
class = _ux_host_stack_class_call(&class_command);
class_ptr = _ux_host_stack_class_call(&class_command);
/* On return, either we have found a class or the interface is still an orphan. */
if (class != UX_NULL)
if (class_ptr != UX_NULL)
{
/* There is a class. */
nb_class_owners++;
interface -> ux_interface_class = class;
interface_ptr -> ux_interface_class = class_ptr;
}
}
/* point to the next interface until end of the list. */
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
}
#if defined(UX_HOST_STANDALONE)
@ -151,34 +155,34 @@ UINT status;
/* The device is in the CONFIGURED state, we have to call each of the classes
again with an ACTIVATE signal. */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* Is there a default interface? */
if (interface -> ux_interface_descriptor.bAlternateSetting == 0)
if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == 0)
{
/* We have found the default interface. If this interface is owned,
activate its class. */
class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_ACTIVATE;
class_command.ux_host_class_command_container = (VOID *) interface;
class_command.ux_host_class_command_container = (VOID *) interface_ptr;
if (interface -> ux_interface_class != UX_NULL)
if (interface_ptr -> ux_interface_class != UX_NULL)
{
/* Save the class in the command container */
class_command.ux_host_class_command_class_ptr = interface -> ux_interface_class;
class_command.ux_host_class_command_class_ptr = interface_ptr -> ux_interface_class;
/* Send the ACTIVATE command to the class */
status = interface -> ux_interface_class -> ux_host_class_entry_function(&class_command);
status = interface_ptr -> ux_interface_class -> ux_host_class_entry_function(&class_command);
}
}
/* Point to the next interface until end of the list. */
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
}
}
}

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_device_configuration_deactivate PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -77,6 +77,10 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* internal clean up, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_device_configuration_deactivate(UX_DEVICE *device)
@ -87,7 +91,7 @@ UX_INTERRUPT_SAVE_AREA
#endif
UX_HOST_CLASS_COMMAND command;
UX_CONFIGURATION *configuration;
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UINT status;
@ -158,25 +162,25 @@ UINT status;
/* If device configured configuration must be activated. */
/* We have the correct configuration, search the interface(s). */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
/* Loop to perform the search. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* Check if an instance of the interface is present. */
if (interface -> ux_interface_class_instance != UX_NULL)
if (interface_ptr -> ux_interface_class_instance != UX_NULL)
{
/* We need to stop the class instance for the device. */
command.ux_host_class_command_instance = interface -> ux_interface_class_instance;
command.ux_host_class_command_instance = interface_ptr -> ux_interface_class_instance;
/* Call the class. */
interface -> ux_interface_class -> ux_host_class_entry_function(&command);
interface_ptr -> ux_interface_class -> ux_host_class_entry_function(&command);
}
/* Move to next interface. */
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
}
/* The device can now be un-configured. */

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_device_configuration_reset PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -58,7 +58,6 @@
/* */
/* CALLED BY */
/* */
/* Application */
/* USBX Components */
/* */
/* RELEASE HISTORY */
@ -76,6 +75,10 @@
/* fixed device state support, */
/* reset device power source, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* reset shared device config */
/* descriptor for enum scan, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_device_configuration_reset(UX_DEVICE *device)
@ -109,6 +112,14 @@ UINT status;
/* No configuration is selected now. */
device -> ux_device_current_configuration = UX_NULL;
/* Packed descriptor are not valid now. */
if (device -> ux_device_packed_configuration)
{
_ux_utility_memory_free(device -> ux_device_packed_configuration);
device -> ux_device_packed_configuration = UX_NULL;
device -> ux_device_packed_configuration_keep_count = 0;
}
/* Set state of device to ADDRESSED. */
device -> ux_device_state = UX_DEVICE_ADDRESSED;

View File

@ -167,7 +167,7 @@ UX_ENDPOINT *control_endpoint;
#endif
/* Update the max packet size value for the endpoint. */
control_endpoint -> ux_endpoint_descriptor.wMaxPacketSize = device -> ux_device_descriptor.bMaxPacketSize0;
control_endpoint -> ux_endpoint_descriptor.wMaxPacketSize = device -> ux_device_descriptor.bMaxPacketSize0;
/* Create a transfer_request for the GET_DESCRIPTOR request. This time, we have the complete length */
transfer_request -> ux_transfer_request_data_pointer = descriptor;
@ -206,7 +206,7 @@ UX_ENDPOINT *control_endpoint;
_ux_utility_memory_free(descriptor);
/* Return completion status. */
return(status);
return(status);
#endif
}

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_device_remove PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -80,6 +80,10 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_device_remove(UX_HCD *hcd, UX_DEVICE *parent, UINT port_index)
@ -90,7 +94,7 @@ ULONG container_index;
#endif
UX_DEVICE *device;
UX_CONFIGURATION *configuration;
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UX_HOST_CLASS_COMMAND command;
/* We need to find the device descriptor for the removed device. We can find it
@ -176,25 +180,25 @@ UX_HOST_CLASS_COMMAND command;
{
/* We have the correct configuration, search the interface(s). */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
/* Loop to perform the search. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* Check if an instance of the interface is present. */
if (interface -> ux_interface_class_instance != UX_NULL)
if (interface_ptr -> ux_interface_class_instance != UX_NULL)
{
/* We need to stop the class instance for the device. */
command.ux_host_class_command_instance = interface -> ux_interface_class_instance;
command.ux_host_class_command_instance = interface_ptr -> ux_interface_class_instance;
/* Call the class. */
interface -> ux_interface_class -> ux_host_class_entry_function(&command);
interface_ptr -> ux_interface_class -> ux_host_class_entry_function(&command);
}
/* Move to next interface. */
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
}
}
}

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_device_resources_free PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -81,13 +81,20 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* fixed standalone enum free, */
/* freed shared device config */
/* descriptor for enum scan, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_device_resources_free(UX_DEVICE *device)
{
UX_CONFIGURATION *configuration;
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UX_ENDPOINT *endpoint;
VOID *container;
ULONG current_alternate_setting;
@ -96,6 +103,9 @@ UX_HCD *hcd;
UINT device_address_byte_index;
UINT device_address_bit_index;
UCHAR device_address_byte;
#endif
#if defined(UX_HOST_STANDALONE)
UX_DEVICE *enum_next;
#endif
/* If trace is enabled, insert this event into the trace buffer. */
@ -145,26 +155,26 @@ UCHAR device_address_byte;
{
/* We have the correct configuration, search the interface(s). */
interface = configuration -> ux_configuration_first_interface;
interface_ptr = configuration -> ux_configuration_first_interface;
/* Parse all the interfaces. */
while (interface != UX_NULL)
while (interface_ptr != UX_NULL)
{
/* The alternate setting 0 has the selected alternate setting value. */
if (interface -> ux_interface_descriptor.bAlternateSetting == 0)
current_alternate_setting = interface -> ux_interface_current_alternate_setting;
if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == 0)
current_alternate_setting = interface_ptr -> ux_interface_current_alternate_setting;
/* If this is the selected interface, we need to free all the endpoints
attached to the alternate setting for this interface. */
endpoint = interface -> ux_interface_first_endpoint;
endpoint = interface_ptr -> ux_interface_first_endpoint;
/* Parse all the endpoints. */
while (endpoint != UX_NULL)
{
/* Check if this is the selected interface. */
if (interface -> ux_interface_descriptor.bAlternateSetting == current_alternate_setting)
if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == current_alternate_setting)
{
/* Delete the endpoint instance first. */
@ -183,10 +193,10 @@ UCHAR device_address_byte;
/* Memorize the interface container address. */
container = (VOID *) interface;
container = (VOID *) interface_ptr;
/* Get the next interface. */
interface = interface -> ux_interface_next_interface;
interface_ptr = interface_ptr -> ux_interface_next_interface;
/* Delete the interface container. */
_ux_utility_memory_free(container);
@ -202,6 +212,14 @@ UCHAR device_address_byte;
_ux_utility_memory_free(container);
}
/* If there was a copy of packed descriptor, free it. */
if (device -> ux_device_packed_configuration)
{
_ux_utility_memory_free(device -> ux_device_packed_configuration);
/* Pointer and keep count is set NULL later while reseting instance memory. */
}
/* We need the HCD address for the control endpoint removal and to free
the device address. */
hcd = UX_DEVICE_HCD_GET(device);
@ -250,7 +268,14 @@ UCHAR device_address_byte;
_ux_host_semaphore_delete(&device -> ux_device_protection_semaphore);
/* Now this device can be free and its container return to the pool. */
#if defined(UX_HOST_STANDALONE)
enum_next = device -> ux_device_enum_next;
_ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); /* Use case of memset is verified. */
device -> ux_device_enum_next = enum_next;
#else
_ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); /* Use case of memset is verified. */
#endif
/* Mark the device handle as unused. */
device -> ux_device_handle = UX_UNUSED;

View File

@ -154,6 +154,8 @@ UCHAR endpoint_type;
/* If trace is enabled, register this object. */
UX_TRACE_OBJECT_REGISTER(UX_TRACE_HOST_OBJECT_TYPE_ENDPOINT, endpoint, 0, 0, 0)
/* By default transfer request contained is for endpoint itself. */
endpoint -> ux_endpoint_transfer_request.ux_transfer_request_endpoint = endpoint;
}
/* Return completion status. */

View File

@ -45,7 +45,7 @@
/* The HCD thread is initialized at the system level and the thread */
/* entry routine is invoked right away. This thread suspends until */
/* one of the HCD resumes it due to HCD activities. */
/* */
/* */
/* It's for RTOS mode. */
/* */
/* INPUT */

View File

@ -178,7 +178,7 @@ UINT status;
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
/* Protect the control endpoint semaphore here. It will be unprotected in the
transfer request function. */
transfer request function. */
status = _ux_host_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
/* Perform a GET_STATUS on this device to see if it wants to become the host. */

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_interface_endpoint_get PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,32 +70,36 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_interface_endpoint_get(UX_INTERFACE *interface, UINT endpoint_index, UX_ENDPOINT **endpoint)
UINT _ux_host_stack_interface_endpoint_get(UX_INTERFACE *interface_ptr, UINT endpoint_index, UX_ENDPOINT **endpoint)
{
UINT current_endpoint_index;
UX_ENDPOINT *current_endpoint;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_ENDPOINT_GET, interface, endpoint_index, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_ENDPOINT_GET, interface_ptr, endpoint_index, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* Do a sanity check on the interface handle. */
if (interface -> ux_interface_handle != (ULONG) (ALIGN_TYPE) interface)
if (interface_ptr -> ux_interface_handle != (ULONG) (ALIGN_TYPE) interface_ptr)
{
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_INTERFACE_HANDLE_UNKNOWN);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface_ptr, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_INTERFACE_HANDLE_UNKNOWN);
}
/* Start with the endpoint attached to the interface. */
current_endpoint = interface -> ux_interface_first_endpoint;
current_endpoint = interface_ptr -> ux_interface_first_endpoint;
/* The first endpoint has the index 0. */
current_endpoint_index = 0;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_interface_instance_create PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -67,19 +67,23 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_interface_instance_create(UX_INTERFACE *interface)
UINT _ux_host_stack_interface_instance_create(UX_INTERFACE *interface_ptr)
{
UX_ENDPOINT *endpoint;
UINT status;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_CREATE, interface, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_CREATE, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* Obtain the first endpoint for this alternate setting. */
endpoint = interface -> ux_interface_first_endpoint;
endpoint = interface_ptr -> ux_interface_first_endpoint;
/* Loop to create each endpoint. */
while (endpoint != UX_NULL)
@ -99,7 +103,7 @@ UINT status;
}
/* If trace is enabled, register this object. */
UX_TRACE_OBJECT_REGISTER(UX_TRACE_HOST_OBJECT_TYPE_INTERFACE, interface, 0, 0, 0);
UX_TRACE_OBJECT_REGISTER(UX_TRACE_HOST_OBJECT_TYPE_INTERFACE, interface_ptr, 0, 0, 0);
/* Return completion status. */
return(UX_SUCCESS);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_interface_instance_delete PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -68,21 +68,25 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _ux_host_stack_interface_instance_delete(UX_INTERFACE *interface)
VOID _ux_host_stack_interface_instance_delete(UX_INTERFACE *interface_ptr)
{
UX_ENDPOINT *endpoint;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_DELETE, interface, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_DELETE, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* If trace is enabled, register this object. */
UX_TRACE_OBJECT_UNREGISTER(interface);
UX_TRACE_OBJECT_UNREGISTER(interface_ptr);
/* Obtain the first endpoint for this alternate setting. */
endpoint = interface -> ux_interface_first_endpoint;
endpoint = interface_ptr -> ux_interface_first_endpoint;
/* Loop to delete each endpoint. */
while (endpoint != UX_NULL)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_interface_set PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,9 +70,13 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_interface_set(UX_INTERFACE *interface)
UINT _ux_host_stack_interface_set(UX_INTERFACE *interface_ptr)
{
UX_DEVICE *device;
@ -82,12 +86,12 @@ UINT status;
UX_ENDPOINT *control_endpoint;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_SET, interface, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_SET, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* Retrieve the pointer to the control endpoint and its transfer_request.
From the interface we go back to the configuration, then the device.
The device contains the default control endpoint container. */
configuration = interface -> ux_interface_configuration;
configuration = interface_ptr -> ux_interface_configuration;
device = configuration -> ux_configuration_device;
control_endpoint = &device -> ux_device_control_endpoint;
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
@ -96,8 +100,8 @@ UX_ENDPOINT *control_endpoint;
transfer_request -> ux_transfer_request_requested_length = 0;
transfer_request -> ux_transfer_request_function = UX_SET_INTERFACE;
transfer_request -> ux_transfer_request_type = UX_REQUEST_OUT | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_INTERFACE;
transfer_request -> ux_transfer_request_index = (USHORT) interface -> ux_interface_descriptor.bInterfaceNumber;
transfer_request -> ux_transfer_request_value = (USHORT) interface -> ux_interface_descriptor.bAlternateSetting;
transfer_request -> ux_transfer_request_index = (USHORT) interface_ptr -> ux_interface_descriptor.bInterfaceNumber;
transfer_request -> ux_transfer_request_value = (USHORT) interface_ptr -> ux_interface_descriptor.bAlternateSetting;
/* Send request. */
status = _ux_host_stack_transfer_request(transfer_request);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_interface_setting_select PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -57,6 +57,8 @@
/* _ux_host_stack_interface_instance_create Create interface instance */
/* _ux_host_stack_interface_instance_delete Delete interface instance */
/* _ux_host_stack_interface_set Set interface instance */
/* _ux_host_semaphore_get Get semaphore */
/* _ux_host_semaphore_put Put semaphore */
/* */
/* CALLED BY */
/* */
@ -70,9 +72,12 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* protected control request, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_interface_setting_select(UX_INTERFACE *interface)
UINT _ux_host_stack_interface_setting_select(UX_INTERFACE *interface_ptr)
{
UX_CONFIGURATION *configuration;
@ -84,22 +89,22 @@ UINT current_alternate_setting;
UINT status;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_SETTING_SELECT, interface, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_SETTING_SELECT, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* Check this alternate setting container. It must be valid before
we continue. */
if (interface -> ux_interface_handle != (ULONG) (ALIGN_TYPE) interface)
if (interface_ptr -> ux_interface_handle != (ULONG) (ALIGN_TYPE) interface_ptr)
{
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface, 0, 0, UX_TRACE_ERRORS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_INTERFACE_HANDLE_UNKNOWN, interface_ptr, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_INTERFACE_HANDLE_UNKNOWN);
}
/* From the interface, get the configuration container and the first
interface hooked to this configuration. */
configuration = interface -> ux_interface_configuration;
current_interface_number = interface -> ux_interface_descriptor.bInterfaceNumber;
configuration = interface_ptr -> ux_interface_configuration;
current_interface_number = interface_ptr -> ux_interface_descriptor.bInterfaceNumber;
current_interface = configuration -> ux_configuration_first_interface;
/* Remember the main interface to store the next alternate setting. We set the main interface
@ -157,17 +162,17 @@ UINT status;
}
/* Remember the new alternate setting. */
main_interface -> ux_interface_current_alternate_setting = interface -> ux_interface_descriptor.bAlternateSetting;
main_interface -> ux_interface_current_alternate_setting = interface_ptr -> ux_interface_descriptor.bAlternateSetting;
/* Now, the interface must be created with the new alternate setting. */
status = _ux_host_stack_interface_instance_create(interface);
status = _ux_host_stack_interface_instance_create(interface_ptr);
/* If we could not create it, we return to the default one. */
if (status != UX_SUCCESS)
{
/* Then delete the failed interface. */
_ux_host_stack_interface_instance_delete(interface);
_ux_host_stack_interface_instance_delete(interface_ptr);
/* Error, reset the main interface alternate setting to the default. */
main_interface -> ux_interface_current_alternate_setting = current_alternate_setting;
@ -179,8 +184,14 @@ UINT status;
return(status);
}
/* Protect the control endpoint semaphore here. It will be unprotected in the
transfer request function. */
status = _ux_host_semaphore_get(&configuration -> ux_configuration_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
if (status != UX_SUCCESS)
return(status);
/* Issue a SET_INTERFACE command to the target device. */
status = _ux_host_stack_interface_set(interface);
status = _ux_host_stack_interface_set(interface_ptr);
/* Check completion status. */
if (status != UX_SUCCESS)
@ -190,12 +201,13 @@ UINT status;
main_interface -> ux_interface_current_alternate_setting = current_alternate_setting;
/* Delete the current interface. */
_ux_host_stack_interface_instance_delete(interface);
_ux_host_stack_interface_instance_delete(interface_ptr);
/* Re-create the previous interface with the old alternate setting. */
_ux_host_stack_interface_instance_create(previous_interface);
/* Return error status. */
_ux_host_semaphore_put(&configuration -> ux_configuration_device -> ux_device_protection_semaphore);
return(status);
}

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_new_device_create PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -106,6 +106,10 @@
/* added standalone support, */
/* reset device power source, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* freed shared device config */
/* descriptor after enum scan, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_new_device_create(UX_HCD *hcd, UX_DEVICE *device_owner,
@ -276,6 +280,15 @@ UX_ENDPOINT *control_endpoint;
{
status = _ux_host_stack_class_interface_scan(device);
}
/* Check if there is unnecessary resource to free. */
if (device -> ux_device_packed_configuration &&
device -> ux_device_packed_configuration_keep_count == 0)
{
_ux_utility_memory_free(device -> ux_device_packed_configuration);
device -> ux_device_packed_configuration = UX_NULL;
}
/* If trace is enabled, register this object. */

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_new_device_get PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -69,6 +69,9 @@
/* definitions, verified */
/* memset and memcpy cases, */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone enum init, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UX_DEVICE *_ux_host_stack_new_device_get(VOID)
@ -78,7 +81,9 @@ UX_DEVICE *_ux_host_stack_new_device_get(VOID)
ULONG container_index;
#endif
UX_DEVICE *device;
#if defined(UX_HOST_STANDALONE)
UX_DEVICE *enum_next;
#endif
/* Start with the first device. */
device = _ux_system_host -> ux_system_host_device_array;
@ -96,8 +101,17 @@ UX_DEVICE *device;
if (device -> ux_device_handle == UX_UNUSED)
{
#if defined(UX_HOST_STANDALONE)
/* Reset the entire entry except enum link. */
enum_next = device -> ux_device_enum_next;
_ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); /* Use case of memset is verified. */
device -> ux_device_enum_next = enum_next;
#else
/* Reset the entire entry. */
_ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); /* Use case of memset is verified. */
#endif
/* This entry is now used. */
device -> ux_device_handle = UX_USED;

View File

@ -83,7 +83,7 @@
/* resulting in version 6.1.11 */
/* */
/**************************************************************************/
UINT _ux_host_stack_new_endpoint_create(UX_INTERFACE *interface,
UINT _ux_host_stack_new_endpoint_create(UX_INTERFACE *interface_ptr,
UCHAR * interface_endpoint)
{
@ -99,7 +99,7 @@ ULONG n_tran;
return(UX_MEMORY_INSUFFICIENT);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_NEW_ENDPOINT_CREATE, interface, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_NEW_ENDPOINT_CREATE, interface_ptr, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* Save the endpoint handle in the container, this is for ensuring the
endpoint container is not corrupted. */
@ -110,7 +110,7 @@ ULONG n_tran;
endpoint -> ux_endpoint_transfer_request.ux_transfer_request_endpoint = endpoint;
/* Save the pointer to the device. This is useful for the HCD layer. */
endpoint -> ux_endpoint_device = interface -> ux_interface_configuration -> ux_configuration_device;
endpoint -> ux_endpoint_device = interface_ptr -> ux_interface_configuration -> ux_configuration_device;
/* Parse the interface descriptor and make it machine independent. */
_ux_utility_descriptor_parse(interface_endpoint,
@ -173,7 +173,7 @@ ULONG n_tran;
return(UX_DESCRIPTOR_CORRUPTED);
}
if ((endpoint_type == UX_ISOCHRONOUS_ENDPOINT) ||
(interface -> ux_interface_configuration -> ux_configuration_device
(interface_ptr -> ux_interface_configuration -> ux_configuration_device
-> ux_device_speed == UX_HIGH_SPEED_DEVICE)
)
{
@ -194,22 +194,22 @@ ULONG n_tran;
/* The interface that owns this endpoint is memorized in the
endpoint container itself, easier for back chaining. */
endpoint -> ux_endpoint_interface = interface;
endpoint -> ux_endpoint_interface = interface_ptr;
/* There is 2 cases for the creation of the endpoint descriptor
if this is the first one, the endpoint descriptor is hooked
to the interface.
If it is not the first one, the endpoint is hooked to the
end of the chain of endpoints. */
if (interface -> ux_interface_first_endpoint == UX_NULL)
if (interface_ptr -> ux_interface_first_endpoint == UX_NULL)
{
interface -> ux_interface_first_endpoint = endpoint;
interface_ptr -> ux_interface_first_endpoint = endpoint;
}
else
{
list_endpoint = interface -> ux_interface_first_endpoint;
list_endpoint = interface_ptr -> ux_interface_first_endpoint;
/* Traverse the list until the end. */
while (list_endpoint -> ux_endpoint_next_endpoint != UX_NULL)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_new_interface_create PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -80,6 +80,10 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_new_interface_create(UX_CONFIGURATION *configuration,
@ -87,7 +91,7 @@ UINT _ux_host_stack_new_interface_create(UX_CONFIGURATION *configuration,
{
UX_INTERFACE *list_interface;
UX_INTERFACE *interface;
UX_INTERFACE *interface_ptr;
UINT number_endpoints;
UINT descriptor_length;
UINT descriptor_type;
@ -95,30 +99,30 @@ UINT status;
UCHAR *this_interface_descriptor;
/* Obtain memory for storing this new interface. */
interface = (UX_INTERFACE *) _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_INTERFACE));
interface_ptr = (UX_INTERFACE *) _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_INTERFACE));
/* If no memory left, exit with error. */
if (interface == UX_NULL)
if (interface_ptr == UX_NULL)
return(UX_MEMORY_INSUFFICIENT);
/* Save the interface handle in the container, this is for ensuring the
interface container is not corrupted. */
interface -> ux_interface_handle = (ULONG) (ALIGN_TYPE) interface;
interface_ptr -> ux_interface_handle = (ULONG) (ALIGN_TYPE) interface_ptr;
/* Parse the interface descriptor and make it machine independent. */
_ux_utility_descriptor_parse(descriptor,
_ux_system_interface_descriptor_structure,
UX_INTERFACE_DESCRIPTOR_ENTRIES,
(UCHAR *) &interface -> ux_interface_descriptor);
(UCHAR *) &interface_ptr -> ux_interface_descriptor);
/* The configuration that owns this interface is memorized in the
interface container itself, easier for back chaining. */
interface -> ux_interface_configuration = configuration;
interface_ptr -> ux_interface_configuration = configuration;
/* If the interface belongs to an IAD, remember the IAD Class/SubClass/Protocol. */
interface -> ux_interface_iad_class = configuration -> ux_configuration_iad_class;
interface -> ux_interface_iad_subclass = configuration -> ux_configuration_iad_subclass;
interface -> ux_interface_iad_protocol = configuration -> ux_configuration_iad_protocol;
interface_ptr -> ux_interface_iad_class = configuration -> ux_configuration_iad_class;
interface_ptr -> ux_interface_iad_subclass = configuration -> ux_configuration_iad_subclass;
interface_ptr -> ux_interface_iad_protocol = configuration -> ux_configuration_iad_protocol;
/* There is 2 cases for the creation of the interface descriptor
if this is the first one, the interface descriptor is hooked
@ -126,7 +130,7 @@ UCHAR *this_interface_descriptor;
is hooked to the end of the chain of interfaces. */
if (configuration -> ux_configuration_first_interface == UX_NULL)
{
configuration -> ux_configuration_first_interface = interface;
configuration -> ux_configuration_first_interface = interface_ptr;
}
else
{
@ -141,13 +145,13 @@ UCHAR *this_interface_descriptor;
}
/* Hook the interface. */
list_interface -> ux_interface_next_interface = interface;
list_interface -> ux_interface_next_interface = interface_ptr;
}
/* Traverse the interface in search of all endpoints that belong to it.
We need the length remaining in the descriptor and the number of endpoints
reported for this interface. */
number_endpoints = interface -> ux_interface_descriptor.bNumEndpoints;
number_endpoints = interface_ptr -> ux_interface_descriptor.bNumEndpoints;
this_interface_descriptor = descriptor;
@ -176,7 +180,7 @@ UCHAR *this_interface_descriptor;
{
/* We have found an endpoint descriptor for this interface. */
status = _ux_host_stack_new_endpoint_create(interface, descriptor);
status = _ux_host_stack_new_endpoint_create(interface_ptr, descriptor);
/* Check return status. */
if(status != UX_SUCCESS)

View File

@ -44,7 +44,7 @@ static inline VOID _ux_host_stack_pending_transfers_run(VOID);
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_tasks_run PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -100,6 +100,11 @@ static inline VOID _ux_host_stack_pending_transfers_run(VOID);
/* DATE NAME DESCRIPTION */
/* */
/* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone hub, */
/* used shared descriptor in */
/* device instance for enum, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_host_stack_tasks_run(VOID)
@ -311,6 +316,14 @@ static inline VOID _ux_host_stack_device_enumerated(UX_DEVICE *device)
UX_DEVICE_HCD_GET(device), UX_DEVICE_PARENT_GET(device),
UX_DEVICE_PORT_LOCATION_GET(device), 0);
/* Check if there is unnecessary resource to free. */
if (device -> ux_device_packed_configuration &&
device -> ux_device_packed_configuration_keep_count == 0)
{
_ux_utility_memory_free(device -> ux_device_packed_configuration);
device -> ux_device_packed_configuration = UX_NULL;
}
/* Reset enumeration state. */
device -> ux_device_enum_state = UX_STATE_IDLE;
@ -449,9 +462,12 @@ UCHAR *buffer;
switch (device -> ux_device_enum_state)
{
case UX_STATE_RESET:
/* Reset retry counts. */
device -> ux_device_enum_retry = UX_RH_ENUMERATION_RETRY;
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_PORT_ENABLE;
device -> ux_device_enum_next_state = UX_HOST_STACK_ENUM_PORT_ENABLE;
device -> ux_device_enum_retry = UX_RH_ENUMERATION_RETRY;
device -> ux_device_enum_port_status = UX_PS_CCS;
/* Fall through. */
@ -460,19 +476,25 @@ UCHAR *buffer;
/* Lock enumeration any way. */
_ux_system_host -> ux_system_host_enum_lock = device;
/* For device connected to roohub, we may need port enable (OHCI). */
#if UX_MAX_DEVICES > 1
if (UX_DEVICE_PARENT_IS_HUB(device))
#endif
{
status = _ux_host_stack_rh_port_enable(device);
if (status == UX_PORT_INDEX_UNKNOWN)
{
/* No retry, enumeration fail. */
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_FAIL;
continue;
}
/* Issue a port reset on hub side. */
device -> ux_device_flags |= UX_DEVICE_FLAG_RESET;
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_HUB_OPERATION_WAIT;
return;
}
#endif
/* For device connected to roohub, we may need port enable (OHCI). */
status = _ux_host_stack_rh_port_enable(device);
if (status == UX_PORT_INDEX_UNKNOWN)
{
/* No retry, enumeration fail. */
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_FAIL;
continue;
}
/* Wait a while after port connection. */
@ -483,15 +505,15 @@ UCHAR *buffer;
UX_MS_TO_TICK_NON_ZERO(UX_RH_ENUMERATION_RETRY_DELAY);
continue;
case UX_HOST_STACK_ENUM_PORT_RESET:
#if UX_MAX_DEVICES > 1
if (UX_DEVICE_PARENT_IS_HUB(device))
{
/* NOTE: need hub support. */
}
case UX_HOST_STACK_ENUM_HUB_OPERATION_WAIT:
/* Keep waiting, state is changed in hub tasks. */
return;
#endif
case UX_HOST_STACK_ENUM_PORT_RESET:
/* Reset may blocking, wait the reset done. */
/* Fall through. */
case UX_HOST_STACK_ENUM_PORT_RESET_WAIT:
@ -532,12 +554,6 @@ UCHAR *buffer;
(UCHAR)(1u << ((device -> ux_device_address-1) & 7u));
}
#endif
#if UX_MAX_DEVICES > 1
if (UX_DEVICE_PARENT_IS_HUB(device))
{
/* NOTE: need hub support. */
}
#endif
/* Get port status. */
status = _ux_host_stack_rh_port_status_get(device);
@ -922,7 +938,8 @@ UCHAR *buffer;
case UX_HOST_STACK_ENUM_TRANS_WAIT:
/* Poll transfer task. */
status = _ux_host_stack_transfer_run(device -> ux_device_enum_trans);
trans = device -> ux_device_enum_trans;
status = _ux_host_stack_transfer_run(trans);
/* Transfer done - next state. */
if (status == UX_STATE_NEXT || status == UX_STATE_IDLE)
@ -936,6 +953,16 @@ UCHAR *buffer;
{
/* No retry, fail. */
if (trans -> ux_transfer_request_data_pointer)
{
_ux_utility_memory_free(trans -> ux_transfer_request_data_pointer);
trans -> ux_transfer_request_data_pointer = UX_NULL;
}
if (device -> ux_device_enum_next_state == UX_HOST_STACK_ENUM_CONFIG_DESCR_PARSE)
{
_ux_utility_memory_free(device -> ux_device_enum_inst.ptr);
device -> ux_device_enum_inst.ptr = UX_NULL;
}
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_FAIL;
continue;
}
@ -943,6 +970,16 @@ UCHAR *buffer;
{
/* Error, retry. */
if (trans -> ux_transfer_request_data_pointer)
{
_ux_utility_memory_free(trans -> ux_transfer_request_data_pointer);
trans -> ux_transfer_request_data_pointer = UX_NULL;
}
if (device -> ux_device_enum_next_state == UX_HOST_STACK_ENUM_CONFIG_DESCR_PARSE)
{
_ux_utility_memory_free(device -> ux_device_enum_inst.ptr);
device -> ux_device_enum_inst.ptr = UX_NULL;
}
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_RETRY;
continue;
}
@ -989,6 +1026,14 @@ UCHAR *buffer;
{
device -> ux_device_enum_retry --;
/* Check if there is unnecessary resource to free. */
if (device -> ux_device_packed_configuration &&
device -> ux_device_packed_configuration_keep_count == 0)
{
_ux_utility_memory_free(device -> ux_device_packed_configuration);
device -> ux_device_packed_configuration = UX_NULL;
}
/* Start from port enable delay. */
device -> ux_device_enum_next_state = UX_HOST_STACK_ENUM_PORT_RESET;
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_WAIT;

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_utility_string_length_check PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -46,6 +46,9 @@
/* On success the actual length of C string is written back to UINT */
/* variable pointed by string_length_ptr (if not NULL). */
/* Otherwise the variable keeps untouched. */
/* */
/* Note NULL terminator is not counted in string length */
/* (same as C strlen). */
/* */
/* INPUT */
/* */
@ -74,6 +77,8 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_utility_string_length_check(UCHAR *string, UINT *string_length_ptr, UINT max_string_length)

View File

@ -12,6 +12,8 @@ target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_feedback_thread_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_frame_write.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_interrupt_send.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_interrupt_thread_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_ioctl.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_read_frame_free.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_audio_read_frame_get.c
@ -90,9 +92,11 @@ target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_interrupt_thread.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_read.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_read_run.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_receiver_event_free.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_receiver_event_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_receiver_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_receiver_tasks_run.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_receiver_thread.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_receiver_uninitialize.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_hid_report_get.c

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_audio.h PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -56,6 +56,9 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added interrupt support, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -76,6 +79,13 @@ extern "C" {
/* Compile option: if defined, audio feedback endpoint is supported. */
/* #define UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT */
/* Compile option: if defined, audio interrupt endpoint is supported. */
/* #define UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT */
/* Define Audio Class OS related constants. */
#define UX_DEVICE_CLASS_AUDIO_FEEDBACK_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
#define UX_DEVICE_CLASS_AUDIO_INTERRUPT_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
/* Define Audio Class function (AF) constants. */
@ -345,6 +355,11 @@ typedef struct UX_DEVICE_CLASS_AUDIO_PARAMETER_STRUCT
ULONG ux_device_class_audio_parameter_streams_nb;
UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER *ux_device_class_audio_parameter_streams;
#if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
ULONG ux_device_class_audio_parameter_status_size;
ULONG ux_device_class_audio_parameter_status_queue_size;
#endif
} UX_DEVICE_CLASS_AUDIO_PARAMETER;
@ -400,6 +415,22 @@ typedef struct UX_DEVICE_CLASS_AUDIO_STRUCT
ULONG ux_device_class_audio_streams_nb;
UX_DEVICE_CLASS_AUDIO_STREAM *ux_device_class_audio_streams;
#if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
UX_SLAVE_ENDPOINT *ux_device_class_audio_interrupt;
ULONG ux_device_class_audio_status_size; /* in Bytes. */
ULONG ux_device_class_audio_status_queue_bytes;/* in Bytes. */
ULONG ux_device_class_audio_status_queued; /* in Bytes. */
UCHAR *ux_device_class_audio_status_queue; /* in Bytes. */
UCHAR *ux_device_class_audio_status_head;
UCHAR *ux_device_class_audio_status_tail;
#if !defined(UX_DEVICE_STANDALONE)
UX_SEMAPHORE ux_device_class_audio_status_semaphore;
UX_MUTEX ux_device_class_audio_status_mutex;
#endif
#endif
} UX_DEVICE_CLASS_AUDIO;
@ -442,6 +473,9 @@ UINT _ux_device_class_audio_feedback_set(UX_DEVICE_CLASS_AUDIO_STREAM *audio,
UINT _ux_device_class_audio_feedback_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio, UCHAR *encoded_feedback);
ULONG _ux_device_class_audio_speed_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio);
VOID _ux_device_class_audio_interrupt_thread_entry(ULONG audio_inst);
UINT _ux_device_class_audio_interrupt_send(UX_DEVICE_CLASS_AUDIO *audio, UCHAR *int_data);
/* Define Device Class Audio API prototypes. */
@ -474,6 +508,8 @@ ULONG _ux_device_class_audio_speed_get(UX_DEVICE_CLASS_AUDIO_STREAM *audio);
#define ux_device_class_audio_feedback_get _ux_device_class_audio_feedback_get
#define ux_device_class_audio_feedback_set _ux_device_class_audio_feedback_set
#define ux_device_class_audio_interrupt_send _ux_device_class_audio_interrupt_send
/* Determine if a C++ compiler is being used. If so, complete the standard
C conditional started above. */
#ifdef __cplusplus

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_audio10.h PORTABLE C */
/* 6.1.8 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -50,6 +50,9 @@
/* added extern "C" keyword */
/* for compatibility with C++, */
/* resulting in version 6.1.8 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added sampling control, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -131,6 +134,13 @@ extern "C" {
#define UX_DEVICE_CLASS_AUDIO10_FU_LOUNDNESS_CONTROL 0x0A
/* Define Audio Class specific endpoint control selectors. */
#define UX_DEVICE_CLASS_AUDIO10_EP_CONTROL_UNDEFINED 0x00
#define UX_DEVICE_CLASS_AUDIO10_EP_SAMPLING_FREQ_CONTROL 0x01
#define UX_DEVICE_CLASS_AUDIO10_EP_PITCH_CONTROL 0x02
/* Define Audio Class encoding format types. */
#define UX_DEVICE_CLASS_AUDIO10_FORMAT_PCM 1
@ -351,10 +361,13 @@ typedef struct UX_DEVICE_CLASS_AUDIO10_AS_DATA_ENDPOINT_DESCRIPTOR_STRUCT
typedef struct UX_DEVICE_CLASS_AUDIO10_CONTROL_STRUCT
{
ULONG ux_device_class_audio10_control_fu_id;
ULONG ux_device_class_audio10_control_changed;
ULONG ux_device_class_audio10_control_ep_addr; /* Endpoint address for sampling frequencies control. */
UCHAR *ux_device_class_audio10_control_sam_freq_types;/* Format Type I Descriptor - bSamFreqType and followings. */
ULONG ux_device_class_audio10_control_sam_freq; /* Current sampling frequency. */
ULONG ux_device_class_audio10_control_fu_id;
USHORT ux_device_class_audio10_control_mute[1];
SHORT ux_device_class_audio10_control_volume_min[1];
SHORT ux_device_class_audio10_control_volume_max[1];
@ -362,8 +375,9 @@ typedef struct UX_DEVICE_CLASS_AUDIO10_CONTROL_STRUCT
SHORT ux_device_class_audio10_control_volume[1];
} UX_DEVICE_CLASS_AUDIO10_CONTROL;
#define UX_DEVICE_CLASS_AUDIO10_CONTROL_MUTE_CHANGED 1
#define UX_DEVICE_CLASS_AUDIO10_CONTROL_VOLUME_CHANGED 2
#define UX_DEVICE_CLASS_AUDIO10_CONTROL_MUTE_CHANGED 1u
#define UX_DEVICE_CLASS_AUDIO10_CONTROL_VOLUME_CHANGED 2u
#define UX_DEVICE_CLASS_AUDIO20_CONTROL_FREQUENCY_CHANGED 4u
typedef struct UX_DEVICE_CLASS_AUDIO10_CONTROL_GROUP_STRUCT
{

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_audio20.h PORTABLE C */
/* 6.1.8 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -50,6 +50,11 @@
/* added extern "C" keyword */
/* for compatibility with C++, */
/* resulting in version 6.1.8 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added support of multiple */
/* sampling frequencies, */
/* added clock multiplier DEFs,*/
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -139,6 +144,14 @@ extern "C" {
#define UX_DEVICE_CLASS_AUDIO20_CX_CONTROL_UNDEFINED 0x00
#define UX_DEVICE_CLASS_AUDIO20_CX_CLOCK_SELECTOR_CONTROL 0x01
/* Define Audio Class specific clock multiplier control selectors. */
#define UX_DEVICE_CLASS_AUDIO20_CM_CONTROL_UNDEFINED 0x00
#define UX_DEVICE_CLASS_AUDIO20_CM_NUMERATOR_CONTROL 0x01
#define UX_DEVICE_CLASS_AUDIO20_CM_DENOMINATOR_CONTROL 0x02
/* Define Audio Class specific terminal control selectors. */
#define UX_DEVICE_CLASS_AUDIO20_TE_CONTROL_UNDEFINED 0x00
@ -406,12 +419,14 @@ typedef struct UX_DEVICE_CLASS_AUDIO20_AS_DATA_ENDPOINT_DESCRIPTOR_STRUCT
typedef struct UX_DEVICE_CLASS_AUDIO20_CONTROL_STRUCT
{
ULONG ux_device_class_audio20_control_cs_id;
ULONG ux_device_class_audio20_control_fu_id;
ULONG ux_device_class_audio20_control_sampling_frequency;
ULONG ux_device_class_audio20_control_changed;
ULONG ux_device_class_audio20_control_cs_id;
ULONG ux_device_class_audio20_control_sampling_frequency; /* Set to 0 to customize frequencies (with following two fields). */
ULONG ux_device_class_audio20_control_sampling_frequency_cur; /* Current selected frequency. */
UCHAR *ux_device_class_audio20_control_sampling_frequency_range; /* UAC 2.0 Layer 3 parameter block of RANGE. */
ULONG ux_device_class_audio20_control_fu_id;
USHORT ux_device_class_audio20_control_mute[1];
SHORT ux_device_class_audio20_control_volume_min[1];
SHORT ux_device_class_audio20_control_volume_max[1];
@ -419,8 +434,9 @@ typedef struct UX_DEVICE_CLASS_AUDIO20_CONTROL_STRUCT
SHORT ux_device_class_audio20_control_volume[1];
} UX_DEVICE_CLASS_AUDIO20_CONTROL;
#define UX_DEVICE_CLASS_AUDIO20_CONTROL_MUTE_CHANGED 1
#define UX_DEVICE_CLASS_AUDIO20_CONTROL_VOLUME_CHANGED 2
#define UX_DEVICE_CLASS_AUDIO20_CONTROL_MUTE_CHANGED 1u
#define UX_DEVICE_CLASS_AUDIO20_CONTROL_VOLUME_CHANGED 2u
#define UX_DEVICE_CLASS_AUDIO20_CONTROL_FREQUENCY_CHANGED 4u
typedef struct UX_DEVICE_CLASS_AUDIO20_CONTROL_GROUP_STRUCT
{

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_cdc_acm.h PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -55,6 +55,9 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added write auto ZLP, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -71,6 +74,9 @@ extern "C" {
#endif
/* Defined, _write is pending ZLP automatically (complete transfer) after buffer is sent. */
/* #define UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP */
/* Define CDC Class USB Class constants. */
#define UX_SLAVE_CLASS_CDC_ACM_CLASS 10
@ -187,6 +193,7 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_STRUCT
UCHAR *ux_device_class_cdc_acm_write_buffer;
ULONG ux_device_class_cdc_acm_write_transfer_length;
ULONG ux_device_class_cdc_acm_write_host_length;
ULONG ux_device_class_cdc_acm_write_requested_length;
ULONG ux_device_class_cdc_acm_write_actual_length;
UINT ux_device_class_cdc_acm_write_status;
@ -318,7 +325,7 @@ UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance);
/* Define Device CDC Class API prototypes. */
#define ux_device_class_cdc_acm_entry _ux_device_class_cdc_acm_entry
#define ux_device_class_cdc_acm_read _ux_device_class_cdc_acm_read
#define ux_device_class_cdc_acm_read _ux_device_class_cdc_acm_read
#define ux_device_class_cdc_acm_write _ux_device_class_cdc_acm_write
#define ux_device_class_cdc_acm_ioctl _ux_device_class_cdc_acm_ioctl
#define ux_device_class_cdc_acm_write_with_callback _ux_device_class_cdc_acm_write_with_callback

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_dfu.h PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -57,6 +57,9 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added macros for req types, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -90,6 +93,9 @@ extern "C" {
#define UX_DEVICE_CLASS_DFU_MODE_DFU 2
/* Device DFU bmRequestType. */
#define UX_DEVICE_CLASS_DFU_REQTYPE_INTERFACE_SET (UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_INTERFACE) /* 00100001b, 0x21 */
#define UX_DEVICE_CLASS_DFU_REQTYPE_INTERFACE_GET (UX_REQUEST_IN | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_INTERFACE) /* 10100001b, 0xA1 */
/* Device DFU Requests */

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_hid.h PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -61,6 +61,9 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* added receiver callback, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone int out, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -121,6 +124,16 @@ extern "C" {
#define UX_DEVICE_CLASS_HID_PROTOCOL_BOOT 0
#define UX_DEVICE_CLASS_HID_PROTOCOL_REPORT 1
/* Define HID standalone read/receiver states. */
#define UX_DEVICE_CLASS_HID_READ_START (UX_STATE_STEP + 1)
#define UX_DEVICE_CLASS_HID_READ_WAIT (UX_STATE_STEP + 2)
#define UX_DEVICE_CLASS_HID_RECEIVER_START (UX_STATE_STEP + 3)
#define UX_DEVICE_CLASS_HID_RECEIVER_WAIT (UX_STATE_STEP + 4)
#define UX_DEVICE_CLASS_HID_RECEIVER_ERROR (UX_STATE_STEP + 5)
/* Define HID event info structure. */
#ifndef UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH
@ -196,10 +209,11 @@ typedef struct UX_SLAVE_CLASS_HID_STRUCT
UX_MUTEX ux_device_class_hid_read_mutex;
#else
UCHAR *ux_device_class_hid_read_buffer;
UCHAR ux_device_class_hid_read_requested_length;
UCHAR ux_device_class_hid_read_actual_length;
UCHAR ux_device_class_hid_read_transfer_length;
ULONG ux_device_class_hid_read_requested_length;
ULONG ux_device_class_hid_read_actual_length;
ULONG ux_device_class_hid_read_transfer_length;
UINT ux_device_class_hid_read_state;
UINT ux_device_class_hid_read_status;
#endif
#endif
@ -233,7 +247,7 @@ typedef struct UX_DEVICE_CLASS_HID_RECEIVER_STRUCT
#if !defined(UX_DEVICE_STANDALONE)
UX_THREAD ux_device_class_hid_receiver_thread;
#else
VOID (*ux_device_class_hid_receiver_tasks_run)(struct UX_SLAVE_CLASS_HID_STRUCT *hid);
UINT (*ux_device_class_hid_receiver_tasks_run)(struct UX_SLAVE_CLASS_HID_STRUCT *hid);
#endif
} UX_DEVICE_CLASS_HID_RECEIVER;
@ -294,6 +308,10 @@ UINT _ux_device_class_hid_receiver_event_get(UX_SLAVE_CLASS_HID *hid,
UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event);
UINT _ux_device_class_hid_receiver_event_free(UX_SLAVE_CLASS_HID *hid);
UINT _ux_device_class_hid_read_run(UX_SLAVE_CLASS_HID *hid,
UCHAR *buffer, ULONG requested_length,
ULONG *actual_length);
UINT _ux_device_class_hid_receiver_tasks_run(UX_SLAVE_CLASS_HID *hid);
/* Define Device HID Class API prototypes. */
@ -306,6 +324,7 @@ UINT _ux_device_class_hid_receiver_event_free(UX_SLAVE_CLASS_HID *hid);
#define ux_device_class_hid_protocol_get(hid) (hid -> ux_device_class_hid_protocol)
#define ux_device_class_hid_read _ux_device_class_hid_read
#define ux_device_class_hid_read_run _ux_device_class_hid_read_run
#define ux_device_class_hid_receiver_initialize _ux_device_class_hid_receiver_initialize
#define ux_device_class_hid_receiver_event_get _ux_device_class_hid_receiver_event_get

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_printer.h PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -42,6 +42,8 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@ -58,6 +60,10 @@ extern "C" {
#endif
/* Defined, _write is pending ZLP automatically (complete transfer) after buffer is sent. */
/* #define UX_DEVICE_CLASS_PRINTER_WRITE_AUTO_ZLP */
/* Define Printer Class USB Class constants. */
#define UX_DEVICE_CLASS_PRINTER_CLASS 7

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio10_control_process PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -81,6 +81,9 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* internal clean up, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added sampling control, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio10_control_process(UX_DEVICE_CLASS_AUDIO *audio,
@ -90,10 +93,13 @@ UINT _ux_device_class_audio10_control_process(UX_DEVICE_CLASS_AUDIO *audio,
UX_SLAVE_ENDPOINT *endpoint;
UX_DEVICE_CLASS_AUDIO10_CONTROL *control;
UCHAR request;
UCHAR unit_id;
UCHAR request_type;
UCHAR unit_id, ep_addr;
UCHAR control_selector;
UCHAR channel_number;
ULONG request_length;
UCHAR *desc;
ULONG sam, min, max, pos;
ULONG i;
@ -103,7 +109,9 @@ ULONG i;
/* Extract all necessary fields of the request. */
request = *(transfer -> ux_slave_transfer_request_setup + UX_DEVICE_CLASS_AUDIO_REQUEST_REQUEST);
request_type = *(transfer -> ux_slave_transfer_request_setup + UX_DEVICE_CLASS_AUDIO_REQUEST_REQUEST_TYPE);
unit_id = *(transfer -> ux_slave_transfer_request_setup + UX_DEVICE_CLASS_AUDIO_REQUEST_ENEITY_ID);
ep_addr = *(transfer -> ux_slave_transfer_request_setup + UX_DEVICE_CLASS_AUDIO_REQUEST_ENDPOINT);
control_selector = *(transfer -> ux_slave_transfer_request_setup + UX_DEVICE_CLASS_AUDIO_REQUEST_CONTROL_SELECTOR);
channel_number = *(transfer -> ux_slave_transfer_request_setup + UX_DEVICE_CLASS_AUDIO_REQUEST_CHANNEL_NUMBER);
request_length = _ux_utility_short_get(transfer -> ux_slave_transfer_request_setup + UX_SETUP_LENGTH);
@ -116,8 +124,91 @@ ULONG i;
/* Reset change map. */
control -> ux_device_class_audio10_control_changed = 0;
/* We handle endpoint requests. */
if ((request_type & UX_REQUEST_TARGET) == UX_REQUEST_TARGET_ENDPOINT &&
ep_addr == control -> ux_device_class_audio10_control_ep_addr)
{
/* Handle the request. */
switch(request)
{
case UX_DEVICE_CLASS_AUDIO10_SET_CUR:
/* Only sampling frequency control is supported. */
if (control_selector != UX_DEVICE_CLASS_AUDIO10_EP_SAMPLING_FREQ_CONTROL)
break;
/* Length check. */
if (request_length != 3)
break;
/* If frequencies not specified, no modification accepted. */
if (control -> ux_device_class_audio10_control_sam_freq_types == UX_NULL)
return(UX_SUCCESS);
/* Check sampling frequency types (UAC 1.0 Format Type I : bSamFreqType ..) for MIN and MAX. */
desc = control -> ux_device_class_audio10_control_sam_freq_types;
if (desc[0] == 0)
{
min = ((ULONG)desc[1]) | ((ULONG)desc[2] << 8) | ((ULONG)desc[3] << 16);
max = ((ULONG)desc[4]) | ((ULONG)desc[5] << 8) | ((ULONG)desc[6] << 16);
}
else
{
min = 0xFFFFFFFF;
max = 0x00000000;
for (pos = 1;
pos < (ULONG)desc[0] * 3 + 1; /* Calculate from byte, no overflow. */
pos += 3)
{
sam = (ULONG)desc[pos + 0] | ((ULONG)desc[pos + 1] << 8) | ((ULONG)desc[pos + 2] << 16);
if (sam > max)
max = sam;
if (sam < min)
min = sam;
}
}
/* Accept frequency any way.
* If it's not in range, round to min or max.
* If it's in range it's not rounded, application should check and round it. */
sam = ((ULONG)transfer -> ux_slave_transfer_request_data_pointer[0] ) |
((ULONG)transfer -> ux_slave_transfer_request_data_pointer[1] << 8) |
((ULONG)transfer -> ux_slave_transfer_request_data_pointer[2] << 16);
if (sam < min)
sam = min;
if (sam > max)
sam = max;
control -> ux_device_class_audio10_control_sam_freq = sam;
control -> ux_device_class_audio10_control_changed = UX_DEVICE_CLASS_AUDIO20_CONTROL_FREQUENCY_CHANGED;
return(UX_SUCCESS);
case UX_DEVICE_CLASS_AUDIO10_GET_CUR:
/* Sampling frequency control is supported. */
if (control_selector != UX_DEVICE_CLASS_AUDIO10_EP_SAMPLING_FREQ_CONTROL)
break;
/* Check host buffer. */
if (request_length < 3)
break;
/* Put sample frequency. */
sam = control -> ux_device_class_audio10_control_sam_freq;
transfer -> ux_slave_transfer_request_data_pointer[0] = UX_DW0(sam);
transfer -> ux_slave_transfer_request_data_pointer[1] = UX_DW1(sam);
transfer -> ux_slave_transfer_request_data_pointer[2] = UX_DW2(sam);
_ux_device_stack_transfer_request(transfer, 3, request_length);
return(UX_SUCCESS);
default:
break;
}
}
/* We handle feature unit requests. */
if (unit_id == control -> ux_device_class_audio10_control_fu_id)
if ((request_type & UX_REQUEST_TARGET) == UX_REQUEST_TARGET_INTERFACE &&
unit_id == control -> ux_device_class_audio10_control_fu_id)
{
/* Handle the request. */

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio20_control_process PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -61,7 +61,9 @@
/* */
/* _ux_utility_short_get Get 2-byte value from buffer */
/* _ux_utility_short_put Put 2-byte value to buffer */
/* _ux_utility_long_get Get 4-byte value from buffer */
/* _ux_utility_long_put Put 4-byte value to buffer */
/* _ux_utility_memory_copy Copy memory */
/* _ux_device_stack_transfer_request Issue a transfer request */
/* _ux_device_stack_endpoint_stall Endpoint stall */
/* */
@ -83,6 +85,10 @@
/* allowed answer length only */
/* when requesting range, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added support of multiple */
/* sampling frequencies, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio20_control_process(UX_DEVICE_CLASS_AUDIO *audio,
@ -98,7 +104,9 @@ UCHAR unit_id;
UCHAR control_selector;
UCHAR channel_number;
ULONG request_length;
ULONG data_length;
ULONG i;
ULONG n_sub, pos, min, max, res, freq;
/* Get instances. */
@ -129,6 +137,62 @@ ULONG i;
* The Sampling Frequency Control must support the CUR and RANGE(MIN, MAX, RES) attributes.
*/
/* Sampling frequency control, SET request. */
if ((request_type & UX_REQUEST_DIRECTION) == UX_REQUEST_OUT &&
(control_selector == UX_DEVICE_CLASS_AUDIO20_CS_SAM_FREQ_CONTROL))
{
switch(request)
{
case UX_DEVICE_CLASS_AUDIO20_CUR:
/* Check request parameter. */
if (request_length != 4)
break;
/* Check if multiple frequency supported. */
if (control -> ux_device_class_audio20_control_sampling_frequency != 0)
break;
/* Sanity check. */
UX_ASSERT(control -> ux_device_class_audio20_control_sampling_frequency_range != UX_NULL);
/* Get wNumSubRanges. */
n_sub = _ux_utility_short_get(control -> ux_device_class_audio20_control_sampling_frequency_range);
/* Get first RES. */
res = _ux_utility_long_get(control -> ux_device_class_audio20_control_sampling_frequency_range + 2 + 8);
/* Check if it's fixed single frequency. */
if (n_sub <= 1 && res == 0)
break;
/* Get frequency to set. */
freq = _ux_utility_long_get(transfer -> ux_slave_transfer_request_data_pointer);
/* Check if frequency to set is inside range. */
for (pos = 2; pos < (2 + n_sub * 12); pos += 12)
{
min = _ux_utility_long_get(control -> ux_device_class_audio20_control_sampling_frequency_range + pos);
max = _ux_utility_long_get(control -> ux_device_class_audio20_control_sampling_frequency_range + pos + 4);
if (freq >= min && freq <= max)
{
/* SET_CUR is accepted. */
if (control -> ux_device_class_audio20_control_sampling_frequency_cur != freq)
{
control -> ux_device_class_audio20_control_sampling_frequency_cur = freq;
control -> ux_device_class_audio20_control_changed = UX_DEVICE_CLASS_AUDIO20_CONTROL_FREQUENCY_CHANGED;
}
return(UX_SUCCESS);
}
}
break;
default:
break;
}
}
/* We just support sampling frequency control, GET request. */
if ((request_type & UX_REQUEST_DIRECTION) == UX_REQUEST_IN &&
(control_selector == UX_DEVICE_CLASS_AUDIO20_CS_SAM_FREQ_CONTROL))
@ -142,10 +206,11 @@ ULONG i;
if (request_length < 4)
break;
/* Send sampling frequency.
* We only support one here (from extension data).
*/
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer, control -> ux_device_class_audio20_control_sampling_frequency);
/* Send sampling frequency. */
if (control -> ux_device_class_audio20_control_sampling_frequency)
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer, control -> ux_device_class_audio20_control_sampling_frequency);
else
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer, control -> ux_device_class_audio20_control_sampling_frequency_cur);
_ux_device_stack_transfer_request(transfer, 4, request_length);
return(UX_SUCCESS);
@ -155,18 +220,45 @@ ULONG i;
if (request_length < 2)
break;
/* Send range parameters.
* We only support one here (from extension data).
* wNumSubRanges : 1
* dMIN : sampling frequency
* dMAX : sampling frequency
* dRES : 1
*/
_ux_utility_short_put(transfer -> ux_slave_transfer_request_data_pointer, 1);
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer + 2, control -> ux_device_class_audio20_control_sampling_frequency);
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer + 6, control -> ux_device_class_audio20_control_sampling_frequency);
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer + 10, 0);
_ux_device_stack_transfer_request(transfer, UX_MIN(14, request_length), request_length);
if (control -> ux_device_class_audio20_control_sampling_frequency == 0)
{
/* Send range parameters, RANGE is customized. */
UX_ASSERT(control -> ux_device_class_audio20_control_sampling_frequency_range != UX_NULL);
/* Get wNumSubRanges. */
n_sub = _ux_utility_short_get(control -> ux_device_class_audio20_control_sampling_frequency_range);
UX_ASSERT(n_sub > 0);
/* Calculate length, n_sub is 16-bit width, result not overflows ULONG. */
data_length = 2 + n_sub * 12;
UX_ASSERT(data_length <= UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH);
/* Copy data. */
data_length = UX_MIN(data_length, request_length);
_ux_utility_memory_copy(transfer -> ux_slave_transfer_request_data_pointer,
control -> ux_device_class_audio20_control_sampling_frequency_range,
data_length); /* Use case of memcpy is verified. */
}
else
{
/* Send range parameters.
* We only support one here (from extension data).
* wNumSubRanges : 1
* dMIN : sampling frequency
* dMAX : sampling frequency
* dRES : 1
*/
_ux_utility_short_put(transfer -> ux_slave_transfer_request_data_pointer, 1);
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer + 2, control -> ux_device_class_audio20_control_sampling_frequency);
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer + 6, control -> ux_device_class_audio20_control_sampling_frequency);
_ux_utility_long_put(transfer -> ux_slave_transfer_request_data_pointer + 10, 0);
data_length = UX_MIN(14, request_length);
}
/* Send data. */
_ux_device_stack_transfer_request(transfer, data_length, request_length);
return(UX_SUCCESS);
default:

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_activate PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -65,53 +65,67 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* added interrupt support, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_activate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *audio_interface;
UX_SLAVE_INTERFACE *control_interface;
UX_SLAVE_INTERFACE *stream_interface;
UX_DEVICE_CLASS_AUDIO *audio;
UX_DEVICE_CLASS_AUDIO_STREAM *stream;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *audio_class;
ULONG stream_index;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
audio_class = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
audio = (UX_DEVICE_CLASS_AUDIO *) class -> ux_slave_class_instance;
audio = (UX_DEVICE_CLASS_AUDIO *) audio_class -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
audio_interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Get the device instance. */
device = &_ux_system_slave -> ux_system_slave_device;
audio -> ux_device_class_audio_device = device;
/* We only support audio interface here. */
if (interface -> ux_slave_interface_descriptor.bInterfaceClass != UX_DEVICE_CLASS_AUDIO_CLASS)
if (audio_interface -> ux_slave_interface_descriptor.bInterfaceClass != UX_DEVICE_CLASS_AUDIO_CLASS)
return(UX_NO_CLASS_MATCH);
/* It's control interface? */
if (interface -> ux_slave_interface_descriptor.bInterfaceSubClass == UX_DEVICE_CLASS_AUDIO_SUBCLASS_CONTROL)
if (audio_interface -> ux_slave_interface_descriptor.bInterfaceSubClass == UX_DEVICE_CLASS_AUDIO_SUBCLASS_CONTROL)
{
/* Store the interface in the class instance. */
audio -> ux_device_class_audio_interface = interface;
audio -> ux_device_class_audio_interface = audio_interface;
/* Store the class instance into the interface. */
interface -> ux_slave_interface_class_instance = (VOID *)audio;
audio_interface -> ux_slave_interface_class_instance = (VOID *)audio;
#if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
/* Find interrupt endpoint (only endpoint in this AC interface). */
audio -> ux_device_class_audio_interrupt = audio_interface -> ux_slave_interface_first_endpoint;
audio -> ux_device_class_audio_status_queued = 0;
audio -> ux_device_class_audio_status_head = audio -> ux_device_class_audio_status_queue;
audio -> ux_device_class_audio_status_tail = audio -> ux_device_class_audio_status_queue;
#endif
}
else
{
/* It's streaming interface. */
stream_interface = interface;
stream_interface = audio_interface;
/* Separate driver for each interface (IAD not used)? */
if (audio -> ux_device_class_audio_interface == UX_NULL)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_change PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -75,6 +75,12 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* rx full packet for */
/* feedback, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_change(UX_SLAVE_CLASS_COMMAND *command)
@ -82,8 +88,8 @@ UINT _ux_device_class_audio_change(UX_SLAVE_CLASS_COMMAND *command)
UX_DEVICE_CLASS_AUDIO *audio;
UX_DEVICE_CLASS_AUDIO_STREAM *stream;
UX_SLAVE_CLASS *class;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_ENDPOINT *endpoint;
UCHAR *frame_buffer;
ULONG stream_index;
@ -91,20 +97,20 @@ ULONG endpoint_dir;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
audio = (UX_DEVICE_CLASS_AUDIO *) class -> ux_slave_class_instance;
audio = (UX_DEVICE_CLASS_AUDIO *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Get the interface number (base 0). */
if (audio -> ux_device_class_audio_interface)
{
/* If IAD used, calculate stream index based on interface number. */
stream_index = interface -> ux_slave_interface_descriptor.bInterfaceNumber;
stream_index = interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber;
stream_index -= audio -> ux_device_class_audio_interface -> ux_slave_interface_descriptor.bInterfaceNumber;
stream_index --;
}
@ -117,16 +123,16 @@ ULONG endpoint_dir;
stream = &audio -> ux_device_class_audio_streams[stream_index];
/* Update the interface. */
stream -> ux_device_class_audio_stream_interface = interface;
stream -> ux_device_class_audio_stream_interface = interface_ptr;
/* If the interface to mount has a non zero alternate setting, the class is really active with
the endpoints active. If the interface reverts to alternate setting 0, it needs to have
the pending transactions terminated. */
if (interface -> ux_slave_interface_descriptor.bAlternateSetting != 0)
if (interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting != 0)
{
/* Locate the endpoints. ISO IN(write)/OUT(read) for Streaming Interface. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Parse all endpoints. */
#if defined(UX_DEVICE_STANDALONE)
@ -187,9 +193,12 @@ ULONG endpoint_dir;
return(UX_MEMORY_INSUFFICIENT);
}
/* Set request length. */
/* Set request length, uses full packet for OUT to avoid possible overflow. */
endpoint -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_requested_length =
(_ux_system_slave -> ux_system_slave_speed == UX_HIGH_SPEED_DEVICE) ? 4 : 3;
endpoint_dir == UX_ENDPOINT_OUT ?
endpoint -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_transfer_length :
((_ux_system_slave -> ux_system_slave_speed == UX_HIGH_SPEED_DEVICE) ?
UX_FEEDBACK_SIZE_HIGH_SPEED : UX_FEEDBACK_SIZE_FULL_SPEED);
/* Save it. */
stream -> ux_device_class_audio_stream_feedback = endpoint;
@ -259,7 +268,7 @@ ULONG endpoint_dir;
/* Invoke stream change callback. */
if (stream -> ux_device_class_audio_stream_callbacks.ux_device_class_audio_stream_change)
stream -> ux_device_class_audio_stream_callbacks.ux_device_class_audio_stream_change(stream, interface -> ux_slave_interface_descriptor.bAlternateSetting);
stream -> ux_device_class_audio_stream_callbacks.ux_device_class_audio_stream_change(stream, interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting);
/* Return completion status. */
return(UX_SUCCESS);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_control_request PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -67,6 +67,10 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_control_request(UX_SLAVE_CLASS_COMMAND *command)
@ -74,15 +78,15 @@ UINT _ux_device_class_audio_control_request(UX_SLAVE_CLASS_COMMAND *command)
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_DEVICE *device;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_DEVICE_CLASS_AUDIO *audio;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the audio instance from this class container. */
audio = (UX_DEVICE_CLASS_AUDIO *) class -> ux_slave_class_instance;
audio = (UX_DEVICE_CLASS_AUDIO *) class_ptr -> ux_slave_class_instance;
/* Get the pointer to the device. */
device = &_ux_system_slave -> ux_system_slave_device;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_deactivate PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -67,6 +67,10 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_deactivate(UX_SLAVE_CLASS_COMMAND *command)
@ -75,15 +79,15 @@ UINT _ux_device_class_audio_deactivate(UX_SLAVE_CLASS_COMMAND *command)
UX_DEVICE_CLASS_AUDIO *audio;
UX_DEVICE_CLASS_AUDIO_STREAM *stream;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UINT i;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
audio = (UX_DEVICE_CLASS_AUDIO *) class -> ux_slave_class_instance;
audio = (UX_DEVICE_CLASS_AUDIO *) class_ptr -> ux_slave_class_instance;
/* Stop pending streams. */
stream = audio -> ux_device_class_audio_streams;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_entry PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -74,6 +74,9 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* returned request status, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_entry(UX_SLAVE_CLASS_COMMAND *command)
@ -146,10 +149,7 @@ UINT status;
case UX_SLAVE_CLASS_COMMAND_REQUEST:
/* The request command is used when the host sends a command on the control endpoint. */
_ux_device_class_audio_control_request(command);
/* Return the completion status. */
return(UX_SUCCESS);
return _ux_device_class_audio_control_request(command);
default:

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_initialize PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -80,6 +80,10 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added interrupt support, */
/* refined internal logic, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_initialize(UX_SLAVE_CLASS_COMMAND *command)
@ -94,14 +98,14 @@ UX_DEVICE_CLASS_AUDIO *audio;
UX_DEVICE_CLASS_AUDIO_PARAMETER *audio_parameter;
UX_DEVICE_CLASS_AUDIO_STREAM *stream;
UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER *stream_parameter;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *audio_class;
ULONG memory_size;
ULONG streams_size;
ULONG i;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
audio_class = command -> ux_slave_class_command_class_ptr;
/* Get the pointer to the application parameters for the audio class. */
audio_parameter = (UX_DEVICE_CLASS_AUDIO_PARAMETER *)command -> ux_slave_class_command_parameter;
@ -129,6 +133,94 @@ ULONG i;
if (audio == UX_NULL)
return(UX_MEMORY_INSUFFICIENT);
#if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
/* Create resources for interrupt endpoint support. */
/* Get status data size. */
audio -> ux_device_class_audio_status_size =
audio_parameter -> ux_device_class_audio_parameter_status_size;
/* Calculate queue size in bytes. */
if (UX_OVERFLOW_CHECK_MULV_ULONG(
audio_parameter -> ux_device_class_audio_parameter_status_queue_size,
audio_parameter -> ux_device_class_audio_parameter_status_size))
{
_ux_utility_memory_free(audio);
return(UX_MATH_OVERFLOW);
}
memory_size = audio_parameter -> ux_device_class_audio_parameter_status_queue_size *
audio_parameter -> ux_device_class_audio_parameter_status_size;
audio -> ux_device_class_audio_status_queue_bytes = memory_size;
#if defined(UX_DEVICE_STANDALONE)
#else
if (UX_OVERFLOW_CHECK_ADD_ULONG(memory_size, UX_DEVICE_CLASS_AUDIO_INTERRUPT_THREAD_STACK_SIZE))
{
_ux_utility_memory_free(audio);
return(UX_MATH_OVERFLOW);
}
memory_size += UX_DEVICE_CLASS_AUDIO_INTERRUPT_THREAD_STACK_SIZE;
audio_class -> ux_slave_class_thread_stack = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, memory_size);
if (audio_class -> ux_slave_class_thread_stack == UX_NULL)
status = UX_MEMORY_INSUFFICIENT;
if (status == UX_SUCCESS)
{
status = _ux_device_thread_create(&audio_class -> ux_slave_class_thread,
"ux_device_class_audio_status_thread",
_ux_device_class_audio_interrupt_thread_entry, (ULONG)(ALIGN_TYPE)audio,
audio_class -> ux_slave_class_thread_stack,
UX_DEVICE_CLASS_AUDIO_INTERRUPT_THREAD_STACK_SIZE,
UX_THREAD_PRIORITY_CLASS, UX_THREAD_PRIORITY_CLASS,
UX_NO_TIME_SLICE, UX_DONT_START);
if (status == UX_SUCCESS)
{
UX_THREAD_EXTENSION_PTR_SET(&(audio_class -> ux_slave_class_thread), audio)
status = _ux_device_semaphore_create(&audio -> ux_device_class_audio_status_semaphore,
"ux_device_class_audio_status_semaphore", 0);
if (status == UX_SUCCESS)
{
status = _ux_device_mutex_create(&audio -> ux_device_class_audio_status_mutex,
"ux_device_class_audio_status_mutex");
if (status != UX_SUCCESS)
status = UX_MUTEX_ERROR;
if (status != UX_SUCCESS)
_ux_device_semaphore_delete(&audio -> ux_device_class_audio_status_semaphore);
}
else
status = UX_SEMAPHORE_ERROR;
if (status != UX_SUCCESS)
_ux_device_thread_delete(&audio_class -> ux_slave_class_thread);
}
else
status = UX_THREAD_ERROR;
if (status != UX_SUCCESS)
{
_ux_utility_memory_free(audio_class -> ux_slave_class_thread_stack);
audio_class -> ux_slave_class_thread_stack = UX_NULL;
}
}
if (status != UX_SUCCESS)
{
_ux_utility_memory_free(audio);
return(status);
}
/* Status queue locates right after status stack. */
audio -> ux_device_class_audio_status_queue =
(UCHAR *)audio_class -> ux_slave_class_thread_stack +
UX_DEVICE_CLASS_AUDIO_INTERRUPT_THREAD_STACK_SIZE;
#endif
#endif
/* Save streams. */
if (streams_size)
{
@ -178,7 +270,7 @@ ULONG i;
/* Create memory block for streaming thread stack in addition. */
if (stream_parameter -> ux_device_class_audio_stream_parameter_thread_stack_size == 0)
memory_size = UX_THREAD_STACK_SIZE;
memory_size = UX_DEVICE_CLASS_AUDIO_FEEDBACK_THREAD_STACK_SIZE;
else
memory_size = stream_parameter -> ux_device_class_audio_stream_parameter_thread_stack_size;
stream -> ux_device_class_audio_stream_thread_stack = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, memory_size);
@ -199,7 +291,11 @@ ULONG i;
/* Check for successful allocation. */
if (status != UX_SUCCESS)
{
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_thread_stack);
stream -> ux_device_class_audio_stream_thread_stack = UX_NULL;
break;
}
UX_THREAD_EXTENSION_PTR_SET(&(stream -> ux_device_class_audio_stream_thread), stream)
@ -232,7 +328,11 @@ ULONG i;
/* Check for successful allocation. */
if (status != UX_SUCCESS)
{
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_feedback_thread_stack);
stream -> ux_device_class_audio_stream_feedback_thread_stack = UX_NULL;
break;
}
UX_THREAD_EXTENSION_PTR_SET(&(stream -> ux_device_class_audio_stream_feedback_thread), stream)
}
@ -255,10 +355,10 @@ ULONG i;
{
/* Save the address of the Audio instance inside the Audio container. */
class -> ux_slave_class_instance = (VOID *) audio;
audio_class -> ux_slave_class_instance = (VOID *) audio;
/* Link to class instance. */
audio -> ux_device_class_audio_class = class;
audio -> ux_device_class_audio_class = audio_class;
/* Save callbacks. */
_ux_utility_memory_copy(&audio -> ux_device_class_audio_callbacks,
@ -277,19 +377,34 @@ ULONG i;
for (i = 0; i < audio -> ux_device_class_audio_streams_nb; i ++)
{
#if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT)
if (stream -> ux_device_class_audio_stream_feedback_thread.tx_thread_id)
_ux_utility_thread_delete(&stream -> ux_device_class_audio_stream_feedback_thread);
if (stream -> ux_device_class_audio_stream_feedback_thread_stack)
{
_ux_device_thread_delete(&stream -> ux_device_class_audio_stream_feedback_thread);
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_feedback_thread_stack);
}
#endif
if (stream -> ux_device_class_audio_stream_thread.tx_thread_id)
_ux_device_thread_delete(&stream -> ux_device_class_audio_stream_thread);
if (stream -> ux_device_class_audio_stream_thread_stack)
{
_ux_device_thread_delete(&stream -> ux_device_class_audio_stream_thread);
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_thread_stack);
}
if (stream -> ux_device_class_audio_stream_buffer)
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_buffer);
stream ++;
}
#if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
#if defined(UX_DEVICE_STANDALONE)
#else
if (audio_class -> ux_slave_class_thread_stack)
{
_ux_device_thread_delete(&audio_class -> ux_slave_class_thread);
_ux_utility_memory_free(audio_class -> ux_slave_class_thread_stack);
_ux_device_semaphore_delete(&audio -> ux_device_class_audio_status_semaphore);
_ux_device_mutex_delete(&audio -> ux_device_class_audio_status_mutex);
}
#endif
#endif
_ux_utility_memory_free(audio);
return(status);

View File

@ -0,0 +1,173 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Device Audio Class */
/** */
/**************************************************************************/
/**************************************************************************/
#define UX_SOURCE_CODE
/* Include necessary system files. */
#include "ux_api.h"
#include "ux_device_class_audio.h"
#include "ux_device_stack.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_interrupt_send PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function queues audio interrupt data. */
/* */
/* Note the interrupt data size is predefined on initialization: */
/* - for Audio 1.0 interrupt status word is 2 bytes */
/* - for Audio 2.0 interrupt data message is 6 bytes */
/* */
/* INPUT */
/* */
/* audio Address of audio instance */
/* int_data Interrupt data (2 or 6 bytes) */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 07-29-2022 Chaoqiong Xiao Initial Version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_interrupt_send(UX_DEVICE_CLASS_AUDIO *audio, UCHAR *int_data)
{
#if !defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
UX_PARAMETER_NOT_USED(audio);
UX_PARAMETER_NOT_USED(int_data);
return(UX_FUNCTION_NOT_SUPPORTED);
#else
#if defined(UX_DEVICE_STANDALONE)
UX_PARAMETER_NOT_USED(audio);
UX_PARAMETER_NOT_USED(int_data);
return(UX_FUNCTION_NOT_SUPPORTED);
#else
UX_SLAVE_DEVICE *device;
UX_SLAVE_ENDPOINT *endpoint;
UCHAR *buff, *end;
ULONG size;
ULONG i;
/* Get the pointer to the device. */
device = &_ux_system_slave -> ux_system_slave_device;
/* As long as the device is in the CONFIGURED state. */
if (device -> ux_slave_device_state != UX_DEVICE_CONFIGURED)
{
/* Cannot proceed with command, the interface is down. */
return(UX_CONFIGURATION_HANDLE_UNKNOWN);
}
/* Check if endpoint is available. */
endpoint = audio -> ux_device_class_audio_interrupt;
if (endpoint == UX_NULL)
return(UX_FUNCTION_NOT_SUPPORTED);
/* Get interrupt data size. */
size = audio -> ux_device_class_audio_status_size;
/* Protect queue status. */
_ux_device_mutex_on(&audio -> ux_device_class_audio_status_mutex);
/* Check if data exist. */
buff = audio -> ux_device_class_audio_status_tail;
end = audio -> ux_device_class_audio_status_queue + audio -> ux_device_class_audio_status_queue_bytes;
for (i = 0; i < audio -> ux_device_class_audio_status_queued; i += size)
{
/* Check if data match. */
if (_ux_utility_memory_compare(buff, int_data, size) == UX_SUCCESS)
{
/* Already queued. */
_ux_device_mutex_off(&audio -> ux_device_class_audio_status_mutex);
return(UX_SUCCESS);
}
/* Next saved data. */
buff += size;
if (buff >= end)
buff = audio -> ux_device_class_audio_status_queue;
}
/* No data match before buff achieve head. */
UX_ASSERT(buff == audio -> ux_device_class_audio_status_head);
/* If no free space, return busy (pending). */
if (audio -> ux_device_class_audio_status_queued >=
audio -> ux_device_class_audio_status_queue_bytes)
{
/* No queue space, pending. */
_ux_device_mutex_off(&audio -> ux_device_class_audio_status_mutex);
return(UX_BUSY);
}
/* Copy data to head. */
_ux_utility_memory_copy(buff, int_data, size); /* Use case of memcpy is verified. */
/* Move head. */
buff += size;
if (buff >= end)
buff = audio -> ux_device_class_audio_status_queue;
audio -> ux_device_class_audio_status_head = buff;
/* Add to queued bytes. */
audio -> ux_device_class_audio_status_queued += size;
/* Unprotect queue status. */
_ux_device_mutex_off(&audio -> ux_device_class_audio_status_mutex);
/* Notify status thread to issue interrupt request. */
_ux_device_semaphore_put(&audio -> ux_device_class_audio_status_semaphore);
/* Resume interrupt thread. */
_ux_device_thread_resume(&audio -> ux_device_class_audio_class -> ux_slave_class_thread);
/* Return success. */
return(UX_SUCCESS);
#endif
#endif
}

View File

@ -0,0 +1,157 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Device Audio Class */
/** */
/**************************************************************************/
/**************************************************************************/
#define UX_SOURCE_CODE
/* Include necessary system files. */
#include "ux_api.h"
#include "ux_device_class_audio.h"
#include "ux_device_stack.h"
#if !defined(UX_DEVICE_STANDALONE) && defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_interrupt_thread_entry PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function is thread of INTERRUPT IN from the Audio class. */
/* */
/* It's for RTOS mode. */
/* */
/* INPUT */
/* */
/* audio Address of audio instance */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_system_error_handler System error trap */
/* _ux_device_thread_suspend Suspend thread used */
/* _ux_device_stack_transfer_request Issue transfer request */
/* _ux_utility_memory_copy Copy data */
/* */
/* CALLED BY */
/* */
/* ThreadX */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 07-29-2022 Chaoqiong Xiao Initial Version 6.1.12 */
/* */
/**************************************************************************/
VOID _ux_device_class_audio_interrupt_thread_entry(ULONG audio_inst)
{
UINT status;
UX_DEVICE_CLASS_AUDIO *audio;
UX_SLAVE_DEVICE *device;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_TRANSFER *transfer;
ULONG size;
UCHAR *buff;
/* Get Audio class instance. */
UX_THREAD_EXTENSION_PTR_GET(audio, UX_DEVICE_CLASS_AUDIO, audio_inst)
/* Get stack device instance. */
device = audio -> ux_device_class_audio_device;
/* This thread runs forever but can be suspended or resumed. */
while(1)
{
while (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED)
{
/* Get endpoint instance. */
endpoint = audio -> ux_device_class_audio_interrupt;
/* Endpoint not available, maybe it's alternate setting 0. */
if (endpoint == UX_NULL)
break;
/* Get transfer instance. */
transfer = &endpoint -> ux_slave_endpoint_transfer_request;
/* Get semaphore before start transfer. */
status = _ux_device_semaphore_get(&audio -> ux_device_class_audio_status_semaphore, UX_WAIT_FOREVER);
if (status != UX_SUCCESS)
{
/* Error notification! */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_SEMAPHORE_ERROR);
break;
}
/* Get interrupt data size. */
size = audio -> ux_device_class_audio_status_size;
UX_ASSERT(size <= transfer -> ux_slave_transfer_request_transfer_length);
/* Copy data in tail. */
buff = audio -> ux_device_class_audio_status_tail;
_ux_utility_memory_copy(transfer -> ux_slave_transfer_request_data_pointer,
buff, size); /* Use case of memcpy is verified. */
/* Start frame transfer anyway. */
status = _ux_device_stack_transfer_request(transfer, size, size);
/* Check transfer status. */
if (status != UX_SUCCESS)
{
/* Error notification! */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_TRANSFER_ERROR);
break;
}
/* Calculate next tail. */
buff += size;
if (buff >= (audio -> ux_device_class_audio_status_queue + audio -> ux_device_class_audio_status_queue_bytes))
buff = audio -> ux_device_class_audio_status_queue;
/* Update queue status. */
_ux_device_mutex_on(&audio -> ux_device_class_audio_status_mutex);
audio -> ux_device_class_audio_status_tail = buff;
audio -> ux_device_class_audio_status_queued -= size;
_ux_device_mutex_off(&audio -> ux_device_class_audio_status_mutex);
} /* while (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED) */
/* We need to suspend ourselves. We will be resumed by the device enumeration module or when a change of alternate setting happens. */
_ux_device_thread_suspend(&audio -> ux_device_class_audio_class -> ux_slave_class_thread);
}
}
#endif

View File

@ -82,15 +82,15 @@ UINT _ux_device_class_audio_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
UX_DEVICE_CLASS_AUDIO *audio;
UX_DEVICE_CLASS_AUDIO_STREAM *stream;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *audio_class;
ULONG i;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
audio_class = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
audio = (UX_DEVICE_CLASS_AUDIO *) class -> ux_slave_class_instance;
audio = (UX_DEVICE_CLASS_AUDIO *) audio_class -> ux_slave_class_instance;
/* Sanity check. */
if (audio != UX_NULL)
@ -114,9 +114,20 @@ ULONG i;
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_buffer);
/* Next stream instance. */
stream++;
stream ++;
}
#if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
#if !defined(UX_DEVICE_STANDALONE)
_ux_device_thread_delete(&audio_class -> ux_slave_class_thread);
_ux_utility_memory_free(audio_class -> ux_slave_class_thread_stack);
_ux_device_semaphore_delete(&audio -> ux_device_class_audio_status_semaphore);
_ux_device_mutex_delete(&audio -> ux_device_class_audio_status_mutex);
#else
#endif
#endif
/* Free the audio instance with controls and streams. */
_ux_utility_memory_free(audio);
}

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_activate PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -63,14 +63,18 @@
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_activate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_DEVICE_CLASS_CCID *ccid;
UX_SLAVE_INTERFACE *ccid_interface;
UX_SLAVE_CLASS *ccid_class;
UX_DEVICE_CLASS_CCID *ccid;
UX_SLAVE_ENDPOINT *endpoint;
ULONG endpoint_type;
UINT i;
@ -82,17 +86,17 @@ UINT i;
ccid = (UX_DEVICE_CLASS_CCID *) ccid_class -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
ccid_interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Store the class instance into the interface. */
interface -> ux_slave_interface_class_instance = (VOID *)ccid;
ccid_interface -> ux_slave_interface_class_instance = (VOID *)ccid;
/* Now the opposite, store the interface in the class instance. */
ccid -> ux_device_class_ccid_interface = interface;
ccid -> ux_device_class_ccid_interface = ccid_interface;
/* Save endpoints. */
ccid -> ux_device_class_ccid_endpoint_notify = UX_NULL;
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = ccid_interface -> ux_slave_interface_first_endpoint;
while(endpoint)
{
endpoint_type = endpoint -> ux_slave_endpoint_descriptor.bmAttributes;

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_activate PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -65,29 +65,33 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_activate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_CLASS *class;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class -> ux_slave_class_instance;
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Store the class instance into the interface. */
interface -> ux_slave_interface_class_instance = (VOID *)cdc_acm;
interface_ptr -> ux_slave_interface_class_instance = (VOID *)cdc_acm;
/* Now the opposite, store the interface in the class instance. */
cdc_acm -> ux_slave_class_cdc_acm_interface = interface;
cdc_acm -> ux_slave_class_cdc_acm_interface = interface_ptr;
/* If there is a activate function call it. */
if (cdc_acm -> ux_slave_class_cdc_acm_parameter.ux_slave_class_cdc_acm_instance_activate != UX_NULL)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_bulkin_thread PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -87,6 +87,11 @@
/* used whole buffer for write,*/
/* refined macros names, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* added auto ZLP support, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _ux_device_class_cdc_acm_bulkin_thread(ULONG cdc_acm_class)
@ -95,11 +100,12 @@ VOID _ux_device_class_cdc_acm_bulkin_thread(ULONG cdc_acm_class)
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_DEVICE *device;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
UINT status;
ULONG actual_flags;
ULONG transfer_length;
ULONG host_length;
ULONG total_length;
ULONG sent_length;
@ -111,10 +117,10 @@ ULONG sent_length;
device = &_ux_system_slave -> ux_system_slave_device;
/* This is the first time we are activated. We need the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Check the endpoint direction, if IN we have the correct endpoint. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN)
@ -162,6 +168,7 @@ ULONG sent_length;
{
/* We should send the total length. But we may have a case of ZLP. */
host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
while (total_length)
{
@ -172,17 +179,29 @@ ULONG sent_length;
transfer_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
else
{
/* We can send everything. */
transfer_length = total_length;
#if !defined(UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP)
/* Assume expected length matches length to send. */
host_length = total_length;
#else
/* Assume expected more to let stack append ZLP if needed. */
host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH + 1;
#endif
}
/* Copy the payload locally. */
_ux_utility_memory_copy (transfer_request -> ux_slave_transfer_request_data_pointer,
cdc_acm -> ux_slave_class_cdc_acm_callback_current_data_pointer,
transfer_length); /* Use case of memcpy is verified. */
/* Send the acm payload to the host. */
status = _ux_device_stack_transfer_request(transfer_request, transfer_length, transfer_length);
status = _ux_device_stack_transfer_request(transfer_request, transfer_length, host_length);
/* Check the status. */
if (status != UX_SUCCESS)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_bulkout_thread PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -79,6 +79,10 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* refined macros names, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _ux_device_class_cdc_acm_bulkout_thread(ULONG cdc_acm_class)
@ -87,7 +91,7 @@ VOID _ux_device_class_cdc_acm_bulkout_thread(ULONG cdc_acm_class)
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_DEVICE *device;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
UINT status;
@ -98,10 +102,10 @@ UINT status;
device = &_ux_system_slave -> ux_system_slave_device;
/* This is the first time we are activated. We need the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Check the endpoint direction, if OUT we have the correct endpoint. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_OUT)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_control_request PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -67,12 +67,16 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_control_request(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_DEVICE *device;
ULONG request;
@ -81,10 +85,10 @@ ULONG request_length;
ULONG transmit_length;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class -> ux_slave_class_instance;
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
/* Get the pointer to the device. */
device = &_ux_system_slave -> ux_system_slave_device;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_deactivate PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -67,28 +67,32 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_deactivate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_ENDPOINT *endpoint_in;
UX_SLAVE_ENDPOINT *endpoint_out;
UX_SLAVE_CLASS *class;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class -> ux_slave_class_instance;
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
/* We need the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint_in = interface -> ux_slave_interface_first_endpoint;
endpoint_in = interface_ptr -> 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)

View File

@ -37,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_initialize PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -83,6 +83,10 @@
/* resulting in version 6.1.10 */
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command)
@ -90,13 +94,13 @@ UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command)
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_CLASS_CDC_ACM_PARAMETER *cdc_acm_parameter;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
#if !defined(UX_DEVICE_STANDALONE)
UINT status;
#endif
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Create an instance of the device cdc_acm class. */
cdc_acm = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_SLAVE_CLASS_CDC_ACM));
@ -106,7 +110,7 @@ UINT status;
return(UX_MEMORY_INSUFFICIENT);
/* Save the address of the CDC instance inside the CDC container. */
class -> ux_slave_class_instance = (VOID *) cdc_acm;
class_ptr -> ux_slave_class_instance = (VOID *) cdc_acm;
/* Get the pointer to the application parameters for the cdc_acm class. */
cdc_acm_parameter = command -> ux_slave_class_command_parameter;
@ -148,7 +152,7 @@ UINT status;
/* Return fatal error. */
return(UX_MUTEX_ERROR);
}
#endif
/* Update the line coding fields with default values. */
@ -162,7 +166,7 @@ UINT status;
#if defined(UX_DEVICE_STANDALONE)
/* Set task function. */
class -> ux_slave_class_task_function = _ux_device_class_cdc_acm_tasks_run;
class_ptr -> ux_slave_class_task_function = _ux_device_class_cdc_acm_tasks_run;
#else
/* We need to prepare the 2 threads for sending and receiving. */

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_ioctl PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -92,6 +92,10 @@
/* added standalone support, */
/* fixed aborting return code, */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,
@ -105,7 +109,7 @@ UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER *line_state;
UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER *callback;
#endif
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
/* Let's be optimist ! */
@ -168,10 +172,10 @@ UX_SLAVE_TRANSFER *transfer_request;
case UX_SLAVE_CLASS_CDC_ACM_IOCTL_ABORT_PIPE:
/* Get the interface from the instance. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* What direction ? */
switch( (ULONG) (ALIGN_TYPE) parameter)
@ -208,7 +212,7 @@ UX_SLAVE_TRANSFER *transfer_request;
/* Get the transfer request associated with the endpoint. */
transfer_request = &endpoint -> ux_slave_endpoint_transfer_request;
#if defined(UX_DEVICE_STANDALONE)
/* Abort the transfer. */
@ -225,7 +229,7 @@ UX_SLAVE_TRANSFER *transfer_request;
/* Abort the transfer. */
_ux_device_stack_transfer_abort(transfer_request, UX_ABORTED);
}
#endif
break;
@ -234,10 +238,10 @@ UX_SLAVE_TRANSFER *transfer_request;
case UX_SLAVE_CLASS_CDC_ACM_IOCTL_SET_WRITE_TIMEOUT:
/* Get the interface from the instance. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* If it's reading timeout but endpoint is OUT, it should be the next one. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) !=
@ -269,7 +273,7 @@ UX_SLAVE_TRANSFER *transfer_request;
/* Properly cast the parameter pointer. */
callback = (UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER *) parameter;
/* Save the callback function for write. */
cdc_acm -> ux_device_class_cdc_acm_write_callback = callback -> ux_device_class_cdc_acm_parameter_write_callback;
@ -296,10 +300,10 @@ UX_SLAVE_TRANSFER *transfer_request;
{
/* Get the interface from the instance. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Get the transfer request associated with the endpoint. */
transfer_request = &endpoint -> ux_slave_endpoint_transfer_request;
@ -336,7 +340,7 @@ UX_SLAVE_TRANSFER *transfer_request;
break;
#endif
default:
/* Error trap. */

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_read PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -86,6 +86,10 @@
/* resulting in version 6.1.10 */
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
@ -94,7 +98,7 @@ UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffe
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
UINT status= UX_SUCCESS;
ULONG local_requested_length;
@ -130,10 +134,10 @@ ULONG local_requested_length;
}
/* This is the first time we are activated. We need the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Check the endpoint direction, if OUT we have the correct endpoint. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_OUT)

View File

@ -40,7 +40,7 @@ static inline VOID _ux_device_class_cdc_acm_transmission_write_run(UX_SLAVE_CLAS
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_tasks_run PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -75,6 +75,11 @@ static inline VOID _ux_device_class_cdc_acm_transmission_write_run(UX_SLAVE_CLAS
/* DATE NAME DESCRIPTION */
/* */
/* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* supported write auto ZLP, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance)
@ -125,16 +130,16 @@ static inline VOID _ux_device_class_cdc_acm_transmission_read_run(UX_SLAVE_CLASS
UINT status;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
ULONG max_transfer_length;
/* Get the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Check the endpoint direction, if OUT we have the correct endpoint. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_OUT)
@ -205,7 +210,7 @@ static inline VOID _ux_device_class_cdc_acm_transmission_write_run(UX_SLAVE_CLAS
UINT status;
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
UINT zlp = UX_FALSE;
ULONG requested_length;
@ -216,10 +221,10 @@ ULONG requested_length;
return;
/* We need the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Check the endpoint direction, if IN we have the correct endpoint. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN)
@ -239,6 +244,7 @@ ULONG requested_length;
cdc_acm -> ux_device_class_cdc_acm_write_state = UX_DEVICE_CLASS_CDC_ACM_WRITE_START;
cdc_acm -> ux_device_class_cdc_acm_write_status = UX_TRANSFER_NO_ANSWER;
cdc_acm -> ux_device_class_cdc_acm_write_actual_length = 0;
cdc_acm -> ux_device_class_cdc_acm_write_host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
if (cdc_acm -> ux_device_class_cdc_acm_write_requested_length == 0)
zlp = UX_TRUE;
@ -271,10 +277,22 @@ ULONG requested_length;
UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
else
{
/* We can proceed with the demanded length. */
cdc_acm -> ux_device_class_cdc_acm_write_transfer_length = requested_length;
#if !defined(UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP)
/* Assume expected length matches length to send. */
cdc_acm -> ux_device_class_cdc_acm_write_host_length = requested_length;
#else
/* Assume expected more to let stack append ZLP if needed. */
cdc_acm -> ux_device_class_cdc_acm_write_host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH + 1;
#endif
}
/* On a out, we copy the buffer to the caller. Not very efficient but it makes the API
easier. */
_ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer,
@ -291,7 +309,7 @@ ULONG requested_length;
/* Send the request to the device controller. */
status = _ux_device_stack_transfer_run(transfer_request,
cdc_acm -> ux_device_class_cdc_acm_write_transfer_length,
cdc_acm -> ux_device_class_cdc_acm_write_transfer_length);
cdc_acm -> ux_device_class_cdc_acm_write_host_length);
/* Error case. */
if (status < UX_STATE_NEXT)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_uninitialize PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,19 +78,23 @@
/* resulting in version 6.1.10 */
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_CLASS_CDC_ACM *cdc_acm;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class -> ux_slave_class_instance;
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM *) class_ptr -> ux_slave_class_instance;
/* Sanity check. */
if (cdc_acm != UX_NULL)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_write PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -51,7 +51,8 @@
/* cdc_acm Address of cdc_acm class */
/* instance */
/* buffer Pointer to data to write */
/* requested_length Length of bytes to write */
/* requested_length Length of bytes to write, */
/* set to 0 to issue ZLP */
/* actual_length Pointer to save number of */
/* bytes written */
/* */
@ -82,10 +83,15 @@
/* 10-15-2021 Chaoqiong Xiao Modified comment(s), */
/* fixed compile issue, */
/* resulting in version 6.1.9 */
/* 01-31-2022x Chaoqiong Xiao Modified comment(s), */
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.10 */
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* added auto ZLP support, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
@ -94,9 +100,10 @@ UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buff
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
ULONG local_requested_length;
ULONG local_host_length;
UINT status = 0;
/* If trace is enabled, insert this event into the trace buffer. */
@ -129,10 +136,10 @@ UINT status = 0;
}
/* We need the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Check the endpoint direction, if IN we have the correct endpoint. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN)
@ -169,6 +176,7 @@ UINT status = 0;
else
{
/* Check if we need more transactions. */
local_host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
while (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED && requested_length != 0)
{
@ -179,9 +187,21 @@ UINT status = 0;
local_requested_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
else
{
/* We can proceed with the demanded length. */
local_requested_length = requested_length;
#if !defined(UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP)
/* Assume the length match expectation. */
local_host_length = requested_length;
#else
/* Assume expecting more, so ZLP is appended in stack. */
local_host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH + 1;
#endif
}
/* On a out, we copy the buffer to the caller. Not very efficient but it makes the API
easier. */
@ -189,7 +209,7 @@ UINT status = 0;
buffer, local_requested_length); /* Use case of memcpy is verified. */
/* Send the request to the device controller. */
status = _ux_device_stack_transfer_request(transfer_request, local_requested_length, local_requested_length);
status = _ux_device_stack_transfer_request(transfer_request, local_requested_length, local_host_length);
/* Check the status */
if (status == UX_SUCCESS)

View File

@ -37,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_write_run PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,6 +78,11 @@
/* DATE NAME DESCRIPTION */
/* */
/* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* added auto ZLP support, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm,
@ -86,7 +91,7 @@ UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm,
UX_SLAVE_ENDPOINT *endpoint;
UX_SLAVE_DEVICE *device;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_TRANSFER *transfer_request;
UINT zlp = UX_FALSE;
UINT status = 0;
@ -124,10 +129,10 @@ UINT status = 0;
}
/* We need the interface to the class. */
interface = cdc_acm -> ux_slave_class_cdc_acm_interface;
interface_ptr = cdc_acm -> ux_slave_class_cdc_acm_interface;
/* Locate the endpoints. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Check the endpoint direction, if IN we have the correct endpoint. */
if ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) != UX_ENDPOINT_IN)
@ -149,6 +154,7 @@ UINT status = 0;
cdc_acm -> ux_device_class_cdc_acm_write_buffer = buffer;
cdc_acm -> ux_device_class_cdc_acm_write_requested_length = requested_length;
cdc_acm -> ux_device_class_cdc_acm_write_actual_length = 0;
cdc_acm -> ux_device_class_cdc_acm_write_host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
if (requested_length == 0)
zlp = UX_TRUE;
@ -176,10 +182,23 @@ UINT status = 0;
UX_SLAVE_REQUEST_DATA_MAX_LENGTH;
else
{
/* We can proceed with the demanded length. */
cdc_acm -> ux_device_class_cdc_acm_write_transfer_length = requested_length;
#if !defined(UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP)
/* Assume expected length and transfer length match. */
cdc_acm -> ux_device_class_cdc_acm_write_host_length = requested_length;
#else
/* Assume expected more than transfer to let stack append ZLP if needed. */
cdc_acm -> ux_device_class_cdc_acm_write_host_length = UX_SLAVE_REQUEST_DATA_MAX_LENGTH + 1;
#endif
}
/* On a out, we copy the buffer to the caller. Not very efficient but it makes the API
easier. */
_ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer,
@ -196,7 +215,7 @@ UINT status = 0;
/* Send the request to the device controller. */
status = _ux_device_stack_transfer_run(transfer_request,
cdc_acm -> ux_device_class_cdc_acm_write_transfer_length,
cdc_acm -> ux_device_class_cdc_acm_write_transfer_length);
cdc_acm -> ux_device_class_cdc_acm_write_host_length);
/* Error case. */
if (status < UX_STATE_NEXT)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_activate PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,6 +78,10 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_activate(UX_SLAVE_CLASS_COMMAND *command)
@ -87,34 +91,34 @@ UINT _ux_device_class_cdc_ecm_activate(UX_SLAVE_CLASS_COMMAND *command)
return(UX_FUNCTION_NOT_SUPPORTED);
#else
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_CLASS *class;
UX_SLAVE_ENDPOINT *endpoint;
ULONG physical_address_msw;
ULONG physical_address_lsw;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Check if this is the Control or Data interface. */
if (command -> ux_slave_class_command_class == UX_DEVICE_CLASS_CDC_ECM_CLASS_COMMUNICATION_CONTROL)
{
/* Store the class instance into the interface. */
interface -> ux_slave_interface_class_instance = (VOID *)cdc_ecm;
interface_ptr -> ux_slave_interface_class_instance = (VOID *)cdc_ecm;
/* Now the opposite, store the interface in the class instance. */
cdc_ecm -> ux_slave_class_cdc_ecm_interface = interface;
cdc_ecm -> ux_slave_class_cdc_ecm_interface = interface_ptr;
/* Locate the interrupt endpoint. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Parse all endpoints. */
while (endpoint != UX_NULL)
@ -150,7 +154,7 @@ ULONG physical_address_lsw;
else
/* This is the DATA Class, only store the cdc_ecm instance in the interface. */
interface -> ux_slave_interface_class_instance = (VOID *)cdc_ecm;
interface_ptr -> ux_slave_interface_class_instance = (VOID *)cdc_ecm;
/* Reset the CDC ECM alternate setting to 0. */
cdc_ecm -> ux_slave_class_cdc_ecm_current_alternate_setting = 0;
@ -165,11 +169,11 @@ ULONG physical_address_lsw;
/* Does the data class have bulk endpoint declared ? If yes we need to start link.
If not, the host will change the alternate setting at a later stage. */
if (interface -> ux_slave_interface_descriptor.bNumEndpoints != 0)
if (interface_ptr -> ux_slave_interface_descriptor.bNumEndpoints != 0)
{
/* Locate the endpoints. Control and Bulk in/out for Data Interface. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* Parse all endpoints. */
while (endpoint != UX_NULL)

View File

@ -88,7 +88,7 @@
VOID _ux_device_class_cdc_ecm_bulkin_thread(ULONG cdc_ecm_class)
{
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_DEVICE *device;
UX_SLAVE_TRANSFER *transfer_request;
@ -99,10 +99,10 @@ UCHAR *packet_header;
ULONG transfer_length;
/* Cast properly the cdc_ecm instance. */
UX_THREAD_EXTENSION_PTR_GET(class, UX_SLAVE_CLASS, cdc_ecm_class)
UX_THREAD_EXTENSION_PTR_GET(class_ptr, UX_SLAVE_CLASS, cdc_ecm_class)
/* Get the cdc_ecm instance from this class container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Get the pointer to the device. */
device = &_ux_system_slave -> ux_system_slave_device;

View File

@ -88,7 +88,7 @@
VOID _ux_device_class_cdc_ecm_bulkout_thread(ULONG cdc_ecm_class)
{
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_DEVICE *device;
UX_SLAVE_TRANSFER *transfer_request;
@ -97,10 +97,10 @@ NX_PACKET *packet;
ULONG ip_given_length;
/* Cast properly the cdc_ecm instance. */
UX_THREAD_EXTENSION_PTR_GET(class, UX_SLAVE_CLASS, cdc_ecm_class)
UX_THREAD_EXTENSION_PTR_GET(class_ptr, UX_SLAVE_CLASS, cdc_ecm_class)
/* Get the cdc_ecm instance from this class container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Get the pointer to the device. */
device = &_ux_system_slave -> ux_system_slave_device;

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_change PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -81,32 +81,36 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_change(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_CLASS *class;
UX_SLAVE_ENDPOINT *endpoint;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Locate the endpoints. Control and Bulk in/out for Data Interface. */
endpoint = interface -> ux_slave_interface_first_endpoint;
endpoint = interface_ptr -> ux_slave_interface_first_endpoint;
/* If the interface to mount has a non zero alternate setting, the class is really active with
the endpoints active. If the interface reverts to alternate setting 0, it needs to have
the pending transactions terminated. */
if (interface -> ux_slave_interface_descriptor.bAlternateSetting != 0)
if (interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting != 0)
{
/* Parse all endpoints. */
@ -198,7 +202,7 @@ UX_SLAVE_ENDPOINT *endpoint;
}
/* Set the CDC ECM alternate setting to the new one. */
cdc_ecm -> ux_slave_class_cdc_ecm_current_alternate_setting = interface -> ux_slave_interface_descriptor.bAlternateSetting;
cdc_ecm -> ux_slave_class_cdc_ecm_current_alternate_setting = interface_ptr -> ux_slave_interface_descriptor.bAlternateSetting;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_CDC_ECM_CHANGE, cdc_ecm, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_control_request PORTABLE C */
/* 6.1 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -66,6 +66,10 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_control_request(UX_SLAVE_CLASS_COMMAND *command)
@ -75,7 +79,7 @@ UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_DEVICE *device;
ULONG request;
ULONG request_value;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
/* Get the pointer to the device. */
@ -89,10 +93,10 @@ UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
request_value = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_VALUE);
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the cdc_ecm instance from this class container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Here we proceed only the standard request we know of at the device level. */
switch (request)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_deactivate PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -75,30 +75,34 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_deactivate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_CLASS *class;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. Normally the interface can be derived
from the class instance but since CDC_ECM has 2 interfaces and we only store the Control
interface in the class container, we used the class_command pointer to retrieve the
correct interface which issued the deactivation. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Check if this is the Control or Data interface. We only need to dismount the link and abort the
transfer once for the 2 classes. */
if (interface -> ux_slave_interface_descriptor.bInterfaceClass == UX_DEVICE_CLASS_CDC_ECM_CLASS_COMMUNICATION_CONTROL)
if (interface_ptr -> ux_slave_interface_descriptor.bInterfaceClass == UX_DEVICE_CLASS_CDC_ECM_CLASS_COMMUNICATION_CONTROL)
{
/* Is the link state up? */

View File

@ -34,7 +34,7 @@ UX_DEVICE_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE_ASSERT
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_initialize PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -85,6 +85,10 @@ UX_DEVICE_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE_ASSERT
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_initialize(UX_SLAVE_CLASS_COMMAND *command)
@ -96,12 +100,12 @@ UINT _ux_device_class_cdc_ecm_initialize(UX_SLAVE_CLASS_COMMAND *command)
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_CLASS_CDC_ECM_PARAMETER *cdc_ecm_parameter;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UINT status;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Create an instance of the device cdc_ecm class. */
cdc_ecm = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_SLAVE_CLASS_CDC_ECM));
@ -178,14 +182,14 @@ UINT status;
{
status = _ux_device_thread_create(&cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread , "ux_slave_class_cdc_ecm_interrupt_thread",
_ux_device_class_cdc_ecm_interrupt_thread,
(ULONG) (ALIGN_TYPE) class, (VOID *) cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread_stack ,
(ULONG) (ALIGN_TYPE) class_ptr, (VOID *) cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread_stack ,
UX_THREAD_STACK_SIZE, UX_THREAD_PRIORITY_CLASS,
UX_THREAD_PRIORITY_CLASS, UX_NO_TIME_SLICE, UX_DONT_START);
if (status != UX_SUCCESS)
status = (UX_THREAD_ERROR);
}
UX_THREAD_EXTENSION_PTR_SET(&(cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread), class)
UX_THREAD_EXTENSION_PTR_SET(&(cdc_ecm -> ux_slave_class_cdc_ecm_interrupt_thread), class_ptr)
/* Check the creation of this thread. */
if (status == UX_SUCCESS)
@ -196,7 +200,7 @@ UINT status;
does not start until we have a instance of the class. */
status = _ux_device_thread_create(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread , "ux_slave_class_cdc_ecm_bulkout_thread",
_ux_device_class_cdc_ecm_bulkout_thread,
(ULONG) (ALIGN_TYPE) class, (VOID *) cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread_stack ,
(ULONG) (ALIGN_TYPE) class_ptr, (VOID *) cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread_stack ,
UX_THREAD_STACK_SIZE, UX_THREAD_PRIORITY_CLASS,
UX_THREAD_PRIORITY_CLASS, UX_NO_TIME_SLICE, UX_DONT_START);
if (status != UX_SUCCESS)
@ -204,14 +208,14 @@ UINT status;
else
{
UX_THREAD_EXTENSION_PTR_SET(&(cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread), class)
UX_THREAD_EXTENSION_PTR_SET(&(cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread), class_ptr)
/* Bulk endpoint treatment needs to be running in a different thread. So start
a new thread. We pass a pointer to the cdc_ecm instance to the new thread. This thread
does not start until we have a instance of the class. */
status = _ux_device_thread_create(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread , "ux_slave_class_cdc_ecm_bulkin_thread",
_ux_device_class_cdc_ecm_bulkin_thread,
(ULONG) (ALIGN_TYPE) class, (VOID *) cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread_stack ,
(ULONG) (ALIGN_TYPE) class_ptr, (VOID *) cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread_stack ,
UX_THREAD_STACK_SIZE, UX_THREAD_PRIORITY_CLASS,
UX_THREAD_PRIORITY_CLASS, UX_NO_TIME_SLICE, UX_DONT_START);
if (status != UX_SUCCESS)
@ -219,7 +223,7 @@ UINT status;
else
{
UX_THREAD_EXTENSION_PTR_SET(&(cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread), class)
UX_THREAD_EXTENSION_PTR_SET(&(cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_thread), class_ptr)
/* Create a event flag group for the cdc_ecm class to synchronize with the event interrupt thread. */
status = _ux_utility_event_flags_create(&cdc_ecm -> ux_slave_class_cdc_ecm_event_flags_group, "ux_device_class_cdc_ecm_event_flag");
@ -229,7 +233,7 @@ UINT status;
{
/* Save the address of the CDC_ECM instance inside the CDC_ECM container. */
class -> ux_slave_class_instance = (VOID *) cdc_ecm;
class_ptr -> ux_slave_class_instance = (VOID *) cdc_ecm;
/* Get the pointer to the application parameters for the cdc_ecm class. */
cdc_ecm_parameter = command -> ux_slave_class_command_parameter;

View File

@ -85,7 +85,7 @@
VOID _ux_device_class_cdc_ecm_interrupt_thread(ULONG cdc_ecm_class)
{
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_DEVICE *device;
UX_SLAVE_TRANSFER *transfer_request;
@ -94,10 +94,10 @@ ULONG actual_flags;
UCHAR *notification_buffer;
/* Cast properly the cdc_ecm instance. */
UX_THREAD_EXTENSION_PTR_GET(class, UX_SLAVE_CLASS, cdc_ecm_class)
UX_THREAD_EXTENSION_PTR_GET(class_ptr, UX_SLAVE_CLASS, cdc_ecm_class)
/* Get the cdc_ecm instance from this class container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Get the pointer to the device. */
device = &_ux_system_slave -> ux_system_slave_device;

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_uninitialize PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,20 +78,24 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_CLASS_CDC_ECM *cdc_ecm;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class -> ux_slave_class_instance;
cdc_ecm = (UX_SLAVE_CLASS_CDC_ECM *) class_ptr -> ux_slave_class_instance;
/* Sanity check. */
if (cdc_ecm != UX_NULL)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dfu_activate PORTABLE C */
/* 6.1.10 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -76,29 +76,33 @@
/* resulting in version 6.1.6 */
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.10 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_dfu_activate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_INTERFACE *interface;
UX_SLAVE_INTERFACE *interface_ptr;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_DFU *dfu;
UX_SLAVE_CLASS *class;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
dfu = (UX_SLAVE_CLASS_DFU *) class -> ux_slave_class_instance;
dfu = (UX_SLAVE_CLASS_DFU *) class_ptr -> ux_slave_class_instance;
/* Get the interface that owns this instance. */
interface = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
interface_ptr = (UX_SLAVE_INTERFACE *) command -> ux_slave_class_command_interface;
/* Store the class instance into the interface. */
interface -> ux_slave_interface_class_instance = (VOID *)dfu;
interface_ptr -> ux_slave_interface_class_instance = (VOID *)dfu;
/* Now the opposite, store the interface in the class instance. */
dfu -> ux_slave_class_dfu_interface = interface;
dfu -> ux_slave_class_dfu_interface = interface_ptr;
/* Check the protocol activation field to determine in which state of the DFU class
we are. */

View File

@ -40,7 +40,7 @@ static inline VOID _ux_device_class_dfu_status_get(UX_SLAVE_CLASS_DFU *,
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dfu_control_request PORTABLE C */
/* 6.1.11 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -92,6 +92,14 @@ static inline VOID _ux_device_class_dfu_status_get(UX_SLAVE_CLASS_DFU *,
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* checked r/w callback status,*/
/* resulting in version 6.1.11 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* added UPLOAD length check */
/* in _UPLOAD_IDLE state, */
/* added DNLOAD REQ */
/* validation, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_dfu_control_request(UX_SLAVE_CLASS_COMMAND *command)
@ -99,10 +107,11 @@ UINT _ux_device_class_dfu_control_request(UX_SLAVE_CLASS_COMMAND *command)
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_DEVICE *device;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
UX_SLAVE_CLASS_DFU *dfu;
ULONG request;
ULONG request_type;
ULONG request_value;
ULONG request_length;
ULONG actual_length;
@ -116,10 +125,10 @@ ULONG media_status;
device = &_ux_system_slave -> ux_system_slave_device;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the storage instance from this class container. */
dfu = (UX_SLAVE_CLASS_DFU *) class -> ux_slave_class_instance;
dfu = (UX_SLAVE_CLASS_DFU *) class_ptr -> ux_slave_class_instance;
/* Get the pointer to the transfer request associated with the control endpoint. */
transfer_request = &device -> ux_slave_device_control_endpoint.ux_slave_endpoint_transfer_request;
@ -143,6 +152,7 @@ ULONG media_status;
/* Extract all necessary fields of the request. */
request = *(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_REQUEST);
request_type = *(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_REQUEST_TYPE);
/* Pickup the request wValue. */
request_value = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_VALUE);
@ -287,8 +297,20 @@ ULONG media_status;
case UX_SLAVE_CLASS_DFU_COMMAND_DOWNLOAD :
/* Command verify: check bmRequestType and data length. */
if ((request_type != UX_DEVICE_CLASS_DFU_REQTYPE_INTERFACE_SET) ||
(request_length != transfer_request -> ux_slave_transfer_request_actual_length))
{
/* Zero length download is not accepted. Stall the endpoint. */
_ux_device_stack_endpoint_stall(&device -> ux_slave_device_control_endpoint);
/* In the system, state the DFU state machine to dfu ERROR. */
_ux_system_slave -> ux_system_slave_device_dfu_state_machine = UX_SYSTEM_DFU_STATE_DFU_ERROR;
}
/* We received a DOWNLOAD command. Check the length field of the request. It cannot be 0. */
if (request_length == 0)
else if (request_length == 0)
{
/* Zero length download is not accepted. Stall the endpoint. */
@ -540,9 +562,21 @@ ULONG media_status;
case UX_SLAVE_CLASS_DFU_COMMAND_DOWNLOAD :
/* Command verify: check bmRequestType and data length. */
if ((request_type != UX_DEVICE_CLASS_DFU_REQTYPE_INTERFACE_SET) ||
(request_length != transfer_request -> ux_slave_transfer_request_actual_length))
{
/* Zero length download is not accepted. Stall the endpoint. */
_ux_device_stack_endpoint_stall(&device -> ux_slave_device_control_endpoint);
/* In the system, state the DFU state machine to dfu ERROR. */
_ux_system_slave -> ux_system_slave_device_dfu_state_machine = UX_SYSTEM_DFU_STATE_DFU_ERROR;
}
/* We received a DOWNLOAD command. Check the length field of the request. If it is 0,
we are done with the transfer. */
if (request_length == 0)
else if (request_length == 0)
{
/* Send the notification of end of download to application. */
@ -795,7 +829,7 @@ ULONG media_status;
break;
#ifndef UX_DEVICE_CLASS_DFU_UPLOAD_DISABLE
case UX_SLAVE_CLASS_DFU_STATUS_STATE_DFU_UPLOAD_IDLE:
case UX_SLAVE_CLASS_DFU_STATUS_STATE_DFU_UPLOAD_IDLE: /* bitCanUpload == 1. */
/* Here we process only the request we can accept in the DFU mode UPLOAD IDLE state. */
switch (request)
@ -803,6 +837,14 @@ ULONG media_status;
case UX_SLAVE_CLASS_DFU_COMMAND_UPLOAD:
/* Check if length > wTransferSize (we can support max of control buffer size). */
if (request_length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH)
{
_ux_device_stack_endpoint_stall(&device -> ux_slave_device_control_endpoint);
_ux_system_slave -> ux_system_slave_device_dfu_state_machine = UX_SYSTEM_DFU_STATE_DFU_ERROR;
break;
}
/* Length 0 case undefined, just keep state. */
if (request_length == 0)
break;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dfu_deactivate PORTABLE C */
/* 6.1.6 */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -69,20 +69,24 @@
/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */
/* removed endpoints aborting, */
/* resulting in version 6.1.6 */
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _ux_device_class_dfu_deactivate(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_CLASS_DFU *dfu;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS *class_ptr;
/* Get the class container. */
class = command -> ux_slave_class_command_class_ptr;
class_ptr = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
dfu = (UX_SLAVE_CLASS_DFU *) class -> ux_slave_class_instance;
dfu = (UX_SLAVE_CLASS_DFU *) class_ptr -> ux_slave_class_instance;
/* If there is a deactivate function call it. */
if (dfu -> ux_slave_class_dfu_instance_deactivate != UX_NULL)

Some files were not shown because too many files have changed in this diff Show More