diff options
Diffstat (limited to 'common/core')
215 files changed, 2877 insertions, 1067 deletions
diff --git a/common/core/CMakeLists.txt b/common/core/CMakeLists.txt index ce38377..054f49c 100644 --- a/common/core/CMakeLists.txt +++ b/common/core/CMakeLists.txt @@ -49,6 +49,7 @@ target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/ux_hcd_sim_host_asynch_schedule.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_hcd_sim_host_asynchronous_endpoint_create.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_hcd_sim_host_asynchronous_endpoint_destroy.c + ${CMAKE_CURRENT_LIST_DIR}/src/ux_hcd_sim_host_controller_disable.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_hcd_sim_host_ed_obtain.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_hcd_sim_host_ed_td_clean.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_hcd_sim_host_endpoint_reset.c @@ -96,6 +97,7 @@ target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_class_instance_verify.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_class_interface_scan.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_class_register.c + ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_class_unregister.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_configuration_descriptor_parse.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_configuration_enumerate.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_configuration_instance_create.c @@ -119,6 +121,7 @@ target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_hcd_register.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_hcd_thread_entry.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_hcd_transfer_request.c + ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_hcd_unregister.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_hnp_polling_thread_entry.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_initialize.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_interface_endpoint_get.c @@ -138,6 +141,7 @@ target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_role_swap.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_transfer_request.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_transfer_request_abort.c + ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_stack_uninitialize.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_system_error_handler.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_system_initialize.c ${CMAKE_CURRENT_LIST_DIR}/src/ux_system_uninitialize.c diff --git a/common/core/inc/ux_api.h b/common/core/inc/ux_api.h index 4dacbcf..a26e257 100644 --- a/common/core/inc/ux_api.h +++ b/common/core/inc/ux_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* ux_api.h PORTABLE C */ -/* 6.0.2 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -44,14 +44,24 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ -/* 06-30-2020 Chaoqiong Xiao Modified comment(s), and */ -/* updated product constants, */ -/* avoided div 0 in overflow */ -/* checking macro, */ -/* resulting in version 6.0.1 */ -/* 08-14-2020 Chaoqiong Xiao Modified comment(s), and */ -/* updated product constants, */ -/* resulting in version 6.0.2 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* added query usage of device */ +/* ClassSubclassProtocol, */ +/* added option to disable FX */ +/* media integration, prefixed */ +/* UX to MS_TO_TICK, added */ +/* APIs and macros related to */ +/* uninitialize, optimized */ +/* based on compile */ +/* definitions, updated */ +/* product constants, used */ +/* host class extension */ +/* pointer for class specific */ +/* structured data, used UX */ +/* prefix to refer to TX */ +/* symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ @@ -113,13 +123,59 @@ typedef signed char SCHAR; #endif /* UX_ENABLE_ASSERT */ +/* Convert from millisecond to ThreadX Tick value. */ +#define UX_MS_TO_TICK(ms) ((ms) * (UX_PERIODIC_RATE) / 1000) + +/* Deprecated, left to be compatible with apps already using MS_TO_TICK. */ +#define MS_TO_TICK(ms) UX_MS_TO_TICK(ms) + + +/* If UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE is defined, + it define USBX device max number of endpoints (1~n). + else max number of endpoints are from scan result. + It must be equal to or larger than max number of endpoints + can be activated at the same time. */ +#ifndef UX_MAX_DEVICE_ENDPOINTS +#define UX_MAX_DEVICE_ENDPOINTS 6 +#endif + +/* If UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE is defined, + it define USBX device max number of interfacess (1~n). + else max number of interfacess are from scan result. + It must be equal to or larger than max number of interfaces + in a activated configuration. */ +#ifndef UX_MAX_DEVICE_INTERFACES +#define UX_MAX_DEVICE_INTERFACES 6 +#endif + + +/* Define USBX device max bInterfaceNumber of interfaces (0 ~ n), + it must be larger than max bInterfaceNumber in USB + framework descriptors. */ #ifndef UX_MAX_SLAVE_INTERFACES #define UX_MAX_SLAVE_INTERFACES 16 #endif -/* Convert from millisecond to ThreadX Tick value. */ -#define MS_TO_TICK(ms) ((ms) * (UX_PERIODIC_RATE) / 1000) +/* Define USBX max number of devices (1 ~ n). */ +#ifndef UX_MAX_DEVICES +#define UX_MAX_DEVICES 4 +#endif + +/* Define USBX max number of HCDs (1 ~ n). */ +#ifndef UX_MAX_HCD +#define UX_MAX_HCD 2 +#endif + +/* Define USBX max root hub port (1 ~ n). */ +#ifndef UX_MAX_ROOTHUB_PORT +#define UX_MAX_ROOTHUB_PORT 4 +#endif + +/* Define USBX max TT. */ +#ifndef UX_MAX_TT +#define UX_MAX_TT 8 +#endif /* Define USBX Host Enum Thread Stack Size. */ #ifndef UX_HOST_ENUM_THREAD_STACK_SIZE @@ -139,8 +195,8 @@ typedef signed char SCHAR; /* Define basic constants for the USBX Stack. */ #define AZURE_RTOS_USBX #define USBX_MAJOR_VERSION 6 -#define USBX_MINOR_VERSION 0 -#define USBX_PATCH_VERSION 2 +#define USBX_MINOR_VERSION 1 +#define USBX_PATCH_VERSION 0 /* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */ @@ -311,7 +367,7 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #define UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_DELETE (UX_TRACE_HOST_STACK_EVENTS_BASE + 16) /* I1 = device , I2 = endpoint */ #define UX_TRACE_HOST_STACK_ENDPOINT_RESET (UX_TRACE_HOST_STACK_EVENTS_BASE + 17) /* I1 = device , I2 = endpoint */ #define UX_TRACE_HOST_STACK_ENDPOINT_TRANSFER_ABORT (UX_TRACE_HOST_STACK_EVENTS_BASE + 18) /* I1 = endpoint */ -#define UX_TRACE_HOST_STACK_HCD_REGISTER (UX_TRACE_HOST_STACK_EVENTS_BASE + 19) /* I1 = hcd name */ +#define UX_TRACE_HOST_STACK_HCD_REGISTER (UX_TRACE_HOST_STACK_EVENTS_BASE + 19) /* I1 = hcd name , I2 = parameter 1 , I3 = parameter 2 */ #define UX_TRACE_HOST_STACK_INITIALIZE (UX_TRACE_HOST_STACK_EVENTS_BASE + 20) /* */ #define UX_TRACE_HOST_STACK_INTERFACE_ENDPOINT_GET (UX_TRACE_HOST_STACK_EVENTS_BASE + 21) /* I1 = interface , I2 = endpoint index */ #define UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_CREATE (UX_TRACE_HOST_STACK_EVENTS_BASE + 22) /* I1 = interface */ @@ -326,6 +382,10 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #define UX_TRACE_HOST_STACK_RH_DEVICE_INSERTION (UX_TRACE_HOST_STACK_EVENTS_BASE + 31) /* I1 = hcd , I2 = port index */ #define UX_TRACE_HOST_STACK_TRANSFER_REQUEST (UX_TRACE_HOST_STACK_EVENTS_BASE + 32) /* I1 = device , I2 = endpoint , I3 = transfer request */ #define UX_TRACE_HOST_STACK_TRANSFER_REQUEST_ABORT (UX_TRACE_HOST_STACK_EVENTS_BASE + 33) /* I1 = device , I2 = endpoint , I3 = transfer request */ +#define UX_TRACE_HOST_STACK_UNINITIALIZE (UX_TRACE_HOST_STACK_EVENTS_BASE + 34) /* */ +#define UX_TRACE_HOST_STACK_HCD_UNREGISTER (UX_TRACE_HOST_STACK_EVENTS_BASE + 35) /* I1 = hcd name , I2 = parameter 1 , I3 = parameter 2 */ +#define UX_TRACE_HOST_STACK_CLASS_REGISTER (UX_TRACE_HOST_STACK_EVENTS_BASE + 36) /* I1 = class name , I2 = entry function */ +#define UX_TRACE_HOST_STACK_CLASS_UNREGISTER (UX_TRACE_HOST_STACK_EVENTS_BASE + 37) /* I1 = class entry */ /* Define the USBX host class events. */ @@ -640,17 +700,119 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #endif #endif + +/* Define interrupts lockout constructs to protect the memory allocation/release which could happen + under ISR in the device stack. */ + +#ifndef UX_INTERRUPT_SAVE_AREA +#define UX_INTERRUPT_SAVE_AREA TX_INTERRUPT_SAVE_AREA +#endif + +#ifndef UX_DISABLE +#define UX_DISABLE TX_DISABLE +#endif + +#ifndef UX_RESTORE +#define UX_RESTORE TX_RESTORE +#endif + + +/* Define thread/timer related things. */ + +#ifndef UX_EMPTY +#define UX_EMPTY TX_EMPTY +#endif + +#ifndef UX_TIMER +#define UX_TIMER TX_TIMER +#endif + +#ifndef UX_THREAD +#define UX_THREAD TX_THREAD +#endif + +#ifndef UX_AUTO_START +#define UX_AUTO_START TX_AUTO_START +#endif + +#ifndef UX_DONT_START +#define UX_DONT_START TX_DONT_START +#endif + +#ifndef UX_AUTO_ACTIVATE +#define UX_AUTO_ACTIVATE TX_AUTO_ACTIVATE +#endif + +#ifndef UX_NO_ACTIVATE +#define UX_NO_ACTIVATE TX_NO_ACTIVATE +#endif + +#ifndef UX_THREAD_GET_SYSTEM_STATE +#define UX_THREAD_GET_SYSTEM_STATE TX_THREAD_GET_SYSTEM_STATE +#endif + +#ifndef UX_WAIT_FOREVER +#define UX_WAIT_FOREVER TX_WAIT_FOREVER +#endif + +#ifndef UX_NO_WAIT +#define UX_NO_WAIT TX_NO_WAIT +#endif + +#ifndef UX_NO_TIME_SLICE +#define UX_NO_TIME_SLICE TX_NO_TIME_SLICE +#endif + + +/* Define semaphore related things. */ + +#ifndef UX_SEMAPHORE +#define UX_SEMAPHORE TX_SEMAPHORE +#endif + + +/* Define mutex related things. */ + +#ifndef UX_MUTEX +#define UX_MUTEX TX_MUTEX +#endif + + +/* Define event flags group related things. */ + +#ifndef UX_EVENT_FLAGS_GROUP +#define UX_EVENT_FLAGS_GROUP TX_EVENT_FLAGS_GROUP +#endif + +#ifndef UX_OR_CLEAR +#define UX_OR_CLEAR TX_OR_CLEAR +#endif + +#ifndef UX_OR +#define UX_OR TX_OR +#endif + +#ifndef UX_AND_CLEAR +#define UX_AND_CLEAR TX_AND_CLEAR +#endif + +#ifndef UX_AND +#define UX_AND TX_AND +#endif + +#ifndef UX_NO_EVENTS +#define UX_NO_EVENTS TX_NO_EVENTS +#endif + + /* Define basic USBX constants. */ #define UX_NULL ((void*)0) #define UX_TRUE 1 #define UX_FALSE 0 -#define UX_MAX_TT 8 #define UX_TT_MASK 0x1FF #define UX_TT_BANDWIDTH 6000 #define UX_SLAVE_ENDPOINT_DEFAULT_BUFFER_SIZE 256 -#define UX_REGULAR_MEMORY 0 -#define UX_CACHE_SAFE_MEMORY 1 #define UX_MAX_BYTES_PER_FRAME_FS 1157 #define UX_MAX_BYTES_PER_MICROFRAME_HS 5785 @@ -691,11 +853,14 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL /* Define Generic USBX constants. */ -#define UX_WAIT_FOREVER 0xffffffff #define UX_UNUSED 0 #define UX_USED 1 -#define UX_MEMORY_UNUSED 0x12345678 -#define UX_MEMORY_USED 0x87654321 + +#define UX_MEMORY_UNUSED 0x00000000u +#define UX_MEMORY_USED 0x80000000u +#define UX_REGULAR_MEMORY 0 +#define UX_CACHE_SAFE_MEMORY 1 + #define UX_NO_ALIGN 0 #define UX_ALIGN_16 0x0f #define UX_ALIGN_MIN 0x0f @@ -821,6 +986,8 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #define UX_DEVICE_REMOVAL 2 #define UX_HID_CLIENT_INSERTION 3 #define UX_HID_CLIENT_REMOVAL 4 +#define UX_STORAGE_MEDIA_INSERTION 5 +#define UX_STORAGE_MEDIA_REMOVAL 6 /* Define USBX transfer request status constants. */ @@ -1059,6 +1226,7 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #define UX_HOST_CLASS_COMMAND_QUERY 1 #define UX_HOST_CLASS_COMMAND_ACTIVATE 2 #define UX_HOST_CLASS_COMMAND_DEACTIVATE 3 +#define UX_HOST_CLASS_COMMAND_DESTROY 4 #define UX_SLAVE_CLASS_COMMAND_QUERY 1 #define UX_SLAVE_CLASS_COMMAND_ACTIVATE 2 @@ -1070,6 +1238,7 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #define UX_HOST_CLASS_COMMAND_USAGE_PIDVID 1 #define UX_HOST_CLASS_COMMAND_USAGE_CSP 2 +#define UX_HOST_CLASS_COMMAND_USAGE_DCSP 3 #define UX_HOST_CLASS_INSTANCE_FREE 0 #define UX_HOST_CLASS_INSTANCE_LIVE 1 @@ -1191,15 +1360,18 @@ typedef struct UX_HOST_CLASS_COMMAND_STRUCT typedef struct UX_HOST_CLASS_STRUCT { +#if defined(UX_NAME_REFERENCED_BY_POINTER) + const UCHAR *ux_host_class_name; +#else UCHAR ux_host_class_name[UX_MAX_CLASS_NAME_LENGTH + 1]; /* "+1" for string null-terminator */ +#endif + UINT ux_host_class_status; - UINT (*ux_host_class_entry_function) (struct UX_HOST_CLASS_COMMAND_STRUCT *) ; - UINT ux_host_class_nb_devices_owned; + UINT (*ux_host_class_entry_function) (struct UX_HOST_CLASS_COMMAND_STRUCT *); VOID *ux_host_class_first_instance; VOID *ux_host_class_client; - TX_THREAD ux_host_class_thread; - VOID *ux_host_class_thread_stack; VOID *ux_host_class_media; + VOID *ux_host_class_ext; } UX_HOST_CLASS; @@ -1219,7 +1391,7 @@ typedef struct UX_TRANSFER_STRUCT UINT ux_transfer_request_value; UINT ux_transfer_request_index; VOID (*ux_transfer_request_completion_function) (struct UX_TRANSFER_STRUCT *); - TX_SEMAPHORE ux_transfer_request_semaphore; + UX_SEMAPHORE ux_transfer_request_semaphore; VOID *ux_transfer_request_class_instance; ULONG ux_transfer_request_maximum_length; ULONG ux_transfer_request_timeout_value; @@ -1228,7 +1400,7 @@ typedef struct UX_TRANSFER_STRUCT struct UX_TRANSFER_STRUCT *ux_transfer_request_next_transfer_request; VOID *ux_transfer_request_user_specific; - TX_THREAD *ux_transfer_request_thread_pending; + UX_THREAD *ux_transfer_request_thread_pending; } UX_TRANSFER; @@ -1376,31 +1548,66 @@ typedef struct UX_DEVICE_STRUCT ULONG ux_device_state; ULONG ux_device_address; ULONG ux_device_speed; - ULONG ux_device_port_location; - ULONG ux_device_max_power; ULONG ux_device_power_source; UINT ux_device_current_configuration; - TX_SEMAPHORE ux_device_protection_semaphore; - struct UX_DEVICE_STRUCT - *ux_device_parent; + UX_SEMAPHORE ux_device_protection_semaphore; struct UX_HOST_CLASS_STRUCT *ux_device_class; VOID *ux_device_class_instance; - struct UX_HCD_STRUCT - *ux_device_hcd; struct UX_CONFIGURATION_STRUCT *ux_device_first_configuration; - struct UX_DEVICE_STRUCT - *ux_device_next_device; struct UX_DEVICE_DESCRIPTOR_STRUCT ux_device_descriptor; struct UX_ENDPOINT_STRUCT ux_device_control_endpoint; + ULONG ux_device_port_location; +#if UX_MAX_HCD > 1 + struct UX_HCD_STRUCT + *ux_device_hcd; +#endif +#if UX_MAX_DEVICES > 1 + struct UX_DEVICE_STRUCT + *ux_device_parent; + ULONG ux_device_max_power; struct UX_HUB_TT_STRUCT ux_device_hub_tt[UX_MAX_TT]; +#endif } UX_DEVICE; +#if UX_MAX_HCD > 1 +#define UX_DEVICE_HCD_GET(d) ((d)->ux_device_hcd) +#define UX_DEVICE_HCD_SET(d,h) do { (d)->ux_device_hcd = (h); } while(0) +#define UX_DEVICE_HCD_MATCH(d,h) ((d)->ux_device_hcd == (h)) +#else +#define UX_DEVICE_HCD_GET(d) (_ux_system_host->ux_system_host_hcd_array) +#define UX_DEVICE_HCD_SET(d,h) +#define UX_DEVICE_HCD_MATCH(d,h) (_ux_system_host->ux_system_host_hcd_array == (h)) +#endif + + +#if UX_MAX_DEVICES > 1 +#define UX_DEVICE_PARENT_GET(d) ((d)->ux_device_parent) +#define UX_DEVICE_PARENT_SET(d,p) do { (d)->ux_device_parent = (p); } while(0) +#define UX_DEVICE_PARENT_MATCH(d,p) ((d)->ux_device_parent == (p)) +#define UX_DEVICE_PARENT_IS_HUB(d) ((d)->ux_device_parent != UX_NULL) +#define UX_DEVICE_PARENT_IS_ROOTHUB(d) ((d)->ux_device_parent == UX_NULL) +#define UX_DEVICE_MAX_POWER_GET(d) ((d)->ux_device_max_power) +#define UX_DEVICE_MAX_POWER_SET(d,p) do {(d)->ux_device_max_power = (p); } while(0) +#else +#define UX_DEVICE_PARENT_GET(d) (UX_NULL) +#define UX_DEVICE_PARENT_SET(d,p) UX_PARAMETER_NOT_USED(p) +#define UX_DEVICE_PARENT_MATCH(d,p) ((p) == UX_NULL) +#define UX_DEVICE_PARENT_IS_HUB(d) (UX_FALSE) +#define UX_DEVICE_PARENT_IS_ROOTHUB(d) (UX_TRUE) +#define UX_DEVICE_MAX_POWER_GET(d) (UX_MAX_SELF_POWER) +#define UX_DEVICE_MAX_POWER_SET(d,p) UX_PARAMETER_NOT_USED(p) +#endif +#define UX_DEVICE_PORT_LOCATION_GET(d) ((d)->ux_device_port_location) +#define UX_DEVICE_PORT_LOCATION_SET(d,l) do { (d)->ux_device_port_location = (l); } while(0) +#define UX_DEVICE_PORT_LOCATION_MATCH(d,l) ((d)->ux_device_port_location == (l)) + + /* Define USBX Configuration Descriptor structure. */ typedef struct UX_CONFIGURATION_DESCRIPTOR_STRUCT @@ -1523,24 +1730,34 @@ typedef struct UX_DFU_FUNCTIONAL_DESCRIPTOR_STRUCT typedef struct UX_HCD_STRUCT { +#if defined(UX_NAME_REFERENCED_BY_POINTER) + const UCHAR *ux_hcd_name; +#else UCHAR ux_hcd_name[UX_MAX_HCD_NAME_LENGTH + 1]; /* "+1" for string null-terminator */ - UCHAR ux_hcd_address[16]; +#endif + UINT ux_hcd_status; UINT ux_hcd_controller_type; - UINT ux_hcd_otg_capabilities; UINT ux_hcd_irq; UINT ux_hcd_nb_root_hubs; - UINT ux_hcd_root_hub_signal[16]; + UINT ux_hcd_root_hub_signal[UX_MAX_ROOTHUB_PORT]; UINT ux_hcd_nb_devices; - UINT ux_hcd_power_switch; UINT ux_hcd_thread_signal; ULONG ux_hcd_rh_device_connection; ULONG ux_hcd_io; - ULONG ux_hcd_available_bandwidth; - ULONG ux_hcd_maximum_transfer_request_size; - ULONG ux_hcd_version; UINT (*ux_hcd_entry_function) (struct UX_HCD_STRUCT *, UINT, VOID *); void *ux_hcd_controller_hardware; + +#if defined(UX_OTG_SUPPORT) + UINT ux_hcd_otg_capabilities; +#endif + +#if UX_MAX_DEVICES > 1 + UCHAR ux_hcd_address[16]; + UINT ux_hcd_power_switch; + ULONG ux_hcd_available_bandwidth; + ULONG ux_hcd_version; +#endif } UX_HCD; @@ -1561,7 +1778,7 @@ typedef struct UX_SLAVE_TRANSFER_STRUCT ULONG ux_slave_transfer_request_completion_code; ULONG ux_slave_transfer_request_phase; VOID (*ux_slave_transfer_request_completion_function) (struct UX_SLAVE_TRANSFER_STRUCT *); - TX_SEMAPHORE ux_slave_transfer_request_semaphore; + UX_SEMAPHORE ux_slave_transfer_request_semaphore; ULONG ux_slave_transfer_request_timeout; ULONG ux_slave_transfer_request_force_zlp; UCHAR ux_slave_transfer_request_setup[UX_SETUP_SIZE]; @@ -1639,7 +1856,6 @@ typedef struct UX_SLAVE_DEVICE_STRUCT typedef struct UX_SLAVE_DCD_STRUCT { - UCHAR ux_slave_dcd_name[32]; UINT ux_slave_dcd_status; UINT ux_slave_dcd_controller_type; UINT ux_slave_dcd_otg_capabilities; @@ -1676,12 +1892,17 @@ typedef struct UX_SLAVE_CLASS_COMMAND_STRUCT typedef struct UX_SLAVE_CLASS_STRUCT { +#if defined(UX_NAME_REFERENCED_BY_POINTER) + const UCHAR *ux_slave_class_name; +#else UCHAR ux_slave_class_name[UX_MAX_CLASS_NAME_LENGTH + 1]; /* "+1" for string null-terminator */ +#endif + UINT ux_slave_class_status; - UINT (*ux_slave_class_entry_function) (struct UX_SLAVE_CLASS_COMMAND_STRUCT *) ; + UINT (*ux_slave_class_entry_function) (struct UX_SLAVE_CLASS_COMMAND_STRUCT *); VOID *ux_slave_class_instance; VOID *ux_slave_class_client; - TX_THREAD ux_slave_class_thread; + UX_THREAD ux_slave_class_thread; VOID *ux_slave_class_thread_stack; VOID *ux_slave_class_interface_parameter; ULONG ux_slave_class_interface_number; @@ -1714,18 +1935,41 @@ typedef struct UX_SYSTEM_STRUCT UX_MEMORY_BLOCK *ux_system_cache_safe_memory_pool_start; ULONG ux_system_cache_safe_memory_pool_size; ULONG ux_system_cache_safe_memory_pool_free; +#ifdef UX_ENABLE_MEMORY_STATISTICS + UCHAR *ux_system_regular_memory_pool_base; + ALIGN_TYPE ux_system_regular_memory_pool_max_start_offset; + ALIGN_TYPE ux_system_regular_memory_pool_min_free; + UCHAR *ux_system_cache_safe_memory_pool_base; + ALIGN_TYPE ux_system_cache_safe_memory_pool_max_start_offset; + ALIGN_TYPE ux_system_cache_safe_memory_pool_min_free; + ULONG ux_system_regular_memory_pool_alloc_count; + ULONG ux_system_regular_memory_pool_alloc_total; + ULONG ux_system_regular_memory_pool_alloc_max_count; + ULONG ux_system_regular_memory_pool_alloc_max_total; + ULONG ux_system_cache_safe_memory_pool_alloc_count; + ULONG ux_system_cache_safe_memory_pool_alloc_total; + ULONG ux_system_cache_safe_memory_pool_alloc_max_count; + ULONG ux_system_cache_safe_memory_pool_alloc_max_total; +#endif + UINT ux_system_thread_lowest_priority; - TX_MUTEX ux_system_mutex; - ULONG ux_system_debug_code; - ULONG ux_system_debug_count; + UX_MUTEX ux_system_mutex; + +#ifndef UX_DISABLE_ERROR_HANDLER UINT ux_system_last_error; UINT ux_system_error_count; + VOID (*ux_system_error_callback_function) (UINT system_level, UINT system_context, UINT error_code); +#endif + +#ifdef UX_ENABLE_DEBUG_LOG + ULONG ux_system_debug_code; + ULONG ux_system_debug_count; UCHAR *ux_system_debug_log_buffer; UCHAR *ux_system_debug_log_head; UCHAR *ux_system_debug_log_tail; ULONG ux_system_debug_log_size; - VOID (*ux_system_debug_callback_function) (UCHAR *debug_message, ULONG debug_value) ; - VOID (*ux_system_error_callback_function) (UINT system_level, UINT system_context, UINT error_code) ; + VOID (*ux_system_debug_callback_function) (UCHAR *debug_message, ULONG debug_value); +#endif } UX_SYSTEM; @@ -1734,30 +1978,70 @@ typedef struct UX_SYSTEM_STRUCT typedef struct UX_SYSTEM_HOST_STRUCT { +#if UX_MAX_CLASS_DRIVER > 1 UINT ux_system_host_max_class; - UINT ux_system_host_registered_class; +#endif UX_HOST_CLASS *ux_system_host_class_array; + +#if UX_MAX_HCD > 1 UINT ux_system_host_max_hcd; - UX_HCD *ux_system_host_hcd_array; +#endif UINT ux_system_host_registered_hcd; - UX_DEVICE *ux_system_host_device_array; + UX_HCD *ux_system_host_hcd_array; + +#if UX_MAX_DEVICES > 1 ULONG ux_system_host_max_devices; +#endif + UX_DEVICE *ux_system_host_device_array; + ULONG ux_system_host_max_ed; ULONG ux_system_host_max_td; ULONG ux_system_host_max_iso_td; - UINT ux_system_host_rhsc_hcd; + UCHAR *ux_system_host_enum_thread_stack; - TX_THREAD ux_system_host_enum_thread; - TX_SEMAPHORE ux_system_host_enum_semaphore; + UX_THREAD ux_system_host_enum_thread; + UX_SEMAPHORE ux_system_host_enum_semaphore; + +#if UX_MAX_DEVICES > 1 VOID (*ux_system_host_enum_hub_function) (VOID); +#endif + UCHAR *ux_system_host_hcd_thread_stack; - TX_THREAD ux_system_host_hcd_thread; + UX_THREAD ux_system_host_hcd_thread; + UX_SEMAPHORE ux_system_host_hcd_semaphore; + +#if defined(UX_OTG_SUPPORT) UCHAR *ux_system_host_hnp_polling_thread_stack; - TX_THREAD ux_system_host_hnp_polling_thread; - TX_SEMAPHORE ux_system_host_hcd_semaphore; + UX_THREAD ux_system_host_hnp_polling_thread; +#endif + UINT (*ux_system_host_change_function) (ULONG, UX_HOST_CLASS *, VOID *); } UX_SYSTEM_HOST; +#if UX_MAX_CLASS_DRIVER > 1 +#define UX_SYSTEM_HOST_MAX_CLASS_GET() (_ux_system_host->ux_system_host_max_class) +#define UX_SYSTEM_HOST_MAX_CLASS_SET(n) do { _ux_system_host->ux_system_host_max_class = (n); } while(0) +#else +#define UX_SYSTEM_HOST_MAX_CLASS_GET() (1) +#define UX_SYSTEM_HOST_MAX_CLASS_SET(n) UX_PARAMETER_NOT_USED(n) +#endif + +#if UX_MAX_HCD > 1 +#define UX_SYSTEM_HOST_MAX_HCD_GET() (_ux_system_host->ux_system_host_max_hcd) +#define UX_SYSTEM_HOST_MAX_HCD_SET(n) do { _ux_system_host->ux_system_host_max_hcd = (n); } while(0) +#else +#define UX_SYSTEM_HOST_MAX_HCD_GET() (1) +#define UX_SYSTEM_HOST_MAX_HCD_SET(n) UX_PARAMETER_NOT_USED(n) +#endif + +#if UX_MAX_DEVICES > 1 +#define UX_SYSTEM_HOST_MAX_DEVICES_SET(n) do { _ux_system_host->ux_system_host_max_devices = (n); } while(0) +#define UX_SYSTEM_HOST_MAX_DEVICES_GET() (_ux_system_host->ux_system_host_max_devices) +#else +#define UX_SYSTEM_HOST_MAX_DEVICES_SET(n) UX_PARAMETER_NOT_USED(n) +#define UX_SYSTEM_HOST_MAX_DEVICES_GET() (1) +#endif + typedef struct UX_SYSTEM_SLAVE_STRUCT { @@ -1776,8 +2060,9 @@ typedef struct UX_SYSTEM_SLAVE_STRUCT ULONG ux_system_slave_language_id_framework_length; UCHAR *ux_system_slave_dfu_framework; ULONG ux_system_slave_dfu_framework_length; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 UINT ux_system_slave_max_class; - UINT ux_system_slave_registered_class; +#endif UX_SLAVE_CLASS *ux_system_slave_class_array; UX_SLAVE_CLASS *ux_system_slave_interface_class_array[UX_MAX_SLAVE_INTERFACES]; ULONG ux_system_slave_speed; @@ -1795,12 +2080,20 @@ typedef struct UX_SYSTEM_SLAVE_STRUCT } UX_SYSTEM_SLAVE; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 +#define UX_SYSTEM_DEVICE_MAX_CLASS_SET(n) do { _ux_system_slave->ux_system_slave_max_class = (n); } while(0) +#define UX_SYSTEM_DEVICE_MAX_CLASS_GET() (_ux_system_slave->ux_system_slave_max_class) +#else +#define UX_SYSTEM_DEVICE_MAX_CLASS_SET(n) do { UX_PARAMETER_NOT_USED(n); } while(0) +#define UX_SYSTEM_DEVICE_MAX_CLASS_GET() (1) +#endif + typedef struct UX_SYSTEM_OTG_STRUCT { - TX_THREAD ux_system_otg_thread; + UX_THREAD ux_system_otg_thread; UCHAR *ux_system_otg_thread_stack; - TX_SEMAPHORE ux_system_otg_semaphore; + UX_SEMAPHORE ux_system_otg_semaphore; UINT (*ux_system_otg_function) (ULONG); ULONG ux_system_otg_mode; ULONG ux_system_otg_io; @@ -1829,7 +2122,7 @@ typedef struct UX_HOST_CLASS_DPUMP_STRUCT UX_ENDPOINT *ux_host_class_dpump_bulk_in_endpoint; UX_ENDPOINT *ux_host_class_dpump_interrupt_endpoint; UINT ux_host_class_dpump_state; - TX_SEMAPHORE ux_host_class_dpump_semaphore; + UX_SEMAPHORE ux_host_class_dpump_semaphore; } UX_HOST_CLASS_DPUMP; @@ -1855,13 +2148,16 @@ typedef struct UX_HOST_CLASS_DPUMP_STRUCT #define ux_host_stack_class_instance_destroy _ux_host_stack_class_instance_destroy #define ux_host_stack_class_instance_get _ux_host_stack_class_instance_get #define ux_host_stack_class_register _ux_host_stack_class_register +#define ux_host_stack_class_unregister _ux_host_stack_class_unregister #define ux_host_stack_configuration_interface_get _ux_host_stack_configuration_interface_get #define ux_host_stack_device_configuration_get _ux_host_stack_device_configuration_get #define ux_host_stack_device_configuration_select _ux_host_stack_device_configuration_select #define ux_host_stack_device_get _ux_host_stack_device_get #define ux_host_stack_endpoint_transfer_abort _ux_host_stack_endpoint_transfer_abort #define ux_host_stack_hcd_register _ux_host_stack_hcd_register +#define ux_host_stack_hcd_unregister _ux_host_stack_hcd_unregister #define ux_host_stack_initialize _ux_host_stack_initialize +#define ux_host_stack_uninitialize _ux_host_stack_uninitialize #define ux_host_stack_interface_endpoint_get _ux_host_stack_interface_endpoint_get #define ux_host_stack_interface_setting_select _ux_host_stack_interface_setting_select #define ux_host_stack_transfer_request _ux_host_stack_transfer_request diff --git a/common/core/inc/ux_dcd_sim_slave.h b/common/core/inc/ux_dcd_sim_slave.h index 82bf23c..f9ebcff 100644 --- a/common/core/inc/ux_dcd_sim_slave.h +++ b/common/core/inc/ux_dcd_sim_slave.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_dcd_sim_slave.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -42,6 +42,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ diff --git a/common/core/inc/ux_device_class_dpump.h b/common/core/inc/ux_device_class_dpump.h index cfed0b2..2216d37 100644 --- a/common/core/inc/ux_device_class_dpump.h +++ b/common/core/inc/ux_device_class_dpump.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_device_class_dpump.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -41,6 +41,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ diff --git a/common/core/inc/ux_device_stack.h b/common/core/inc/ux_device_stack.h index f9ad783..7cecf2d 100644 --- a/common/core/inc/ux_device_stack.h +++ b/common/core/inc/ux_device_stack.h @@ -25,7 +25,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_device_stack.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -40,6 +40,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ diff --git a/common/core/inc/ux_hcd_sim_host.h b/common/core/inc/ux_hcd_sim_host.h index fae2c9d..4012012 100644 --- a/common/core/inc/ux_hcd_sim_host.h +++ b/common/core/inc/ux_hcd_sim_host.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_hcd_sim_host.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -42,6 +42,12 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* added controller disable, */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ @@ -105,7 +111,7 @@ typedef struct UX_HCD_SIM_HOST_STRUCT UINT ux_hcd_sim_host_periodic_scheduler_active; UINT ux_hcd_sim_host_interruptible; ULONG ux_hcd_sim_host_interrupt_count; - TX_TIMER ux_hcd_sim_host_timer; + UX_TIMER ux_hcd_sim_host_timer; } UX_HCD_SIM_HOST; @@ -141,7 +147,7 @@ typedef struct UX_HCD_SIM_HOST_ED_STRUCT typedef struct UX_HCD_SIM_HOST_TD_STRUCT { - UCHAR * ux_sim_host_td_buffer; + UCHAR * ux_sim_host_td_buffer; ULONG ux_sim_host_td_length; struct UX_HCD_SIM_HOST_TD_STRUCT *ux_sim_host_td_next_td; @@ -174,7 +180,7 @@ typedef struct UX_HCD_SIM_HOST_TD_STRUCT typedef struct UX_HCD_SIM_HOST_ISO_TD_STRUCT { - UCHAR * ux_sim_host_iso_td_buffer; + UCHAR * ux_sim_host_iso_td_buffer; ULONG ux_sim_host_iso_td_length; struct UX_HCD_SIM_HOST_ISO_TD_STRUCT *ux_sim_host_iso_td_next_td; @@ -204,6 +210,7 @@ UINT _ux_hcd_sim_host_entry(UX_HCD *hcd, UINT function, VOID *parameter); UINT _ux_hcd_sim_host_frame_number_get(UX_HCD_SIM_HOST *hcd_sim_host, ULONG *frame_number); VOID _ux_hcd_sim_host_frame_number_set(UX_HCD_SIM_HOST *hcd_sim_host, ULONG frame_number); UINT _ux_hcd_sim_host_initialize(UX_HCD *hcd); +UINT _ux_hcd_sim_host_controller_disable(UX_HCD_SIM_HOST *hcd); UINT _ux_hcd_sim_host_interrupt_endpoint_create(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint); VOID _ux_hcd_sim_host_iso_queue_process(UX_HCD_SIM_HOST *hcd_sim_host); VOID _ux_hcd_sim_host_iso_schedule(UX_HCD_SIM_HOST *hcd_sim_host); diff --git a/common/core/inc/ux_host_class_dpump.h b/common/core/inc/ux_host_class_dpump.h index 4b3907e..c3c9047 100644 --- a/common/core/inc/ux_host_class_dpump.h +++ b/common/core/inc/ux_host_class_dpump.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_host_class_dpump.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -41,6 +41,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ diff --git a/common/core/inc/ux_host_stack.h b/common/core/inc/ux_host_stack.h index ec62880..e17f9f1 100644 --- a/common/core/inc/ux_host_stack.h +++ b/common/core/inc/ux_host_stack.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_host_stack.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -41,6 +41,11 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* added uninitialize APIs, */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ @@ -50,9 +55,16 @@ /* Define Host Stack component function prototypes. */ +#if UX_MAX_DEVICES > 1 VOID _ux_host_stack_bandwidth_release(UX_HCD *hcd, UX_ENDPOINT *endpoint); VOID _ux_host_stack_bandwidth_claim(UX_HCD *hcd, UX_ENDPOINT *endpoint); UINT _ux_host_stack_bandwidth_check(UX_HCD *hcd, UX_ENDPOINT *endpoint); +#else +#define _ux_host_stack_bandwidth_release(a,b) +#define _ux_host_stack_bandwidth_claim(a,b) +#define _ux_host_stack_bandwidth_check(a,b) (UX_SUCCESS) +#endif + 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); @@ -63,6 +75,7 @@ UINT _ux_host_stack_class_instance_verify(UCHAR *class_name, VOID *class_inst UINT _ux_host_stack_class_interface_scan(UX_DEVICE *device); 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_descriptor_parse(UX_DEVICE *device, UX_CONFIGURATION *configuration, UINT configuration_index); UINT _ux_host_stack_configuration_enumerate(UX_DEVICE *device); UINT _ux_host_stack_configuration_instance_create(UX_CONFIGURATION *configuration); @@ -88,9 +101,11 @@ UINT _ux_host_stack_endpoint_transfer_abort(UX_ENDPOINT *endpoint); VOID _ux_host_stack_enum_thread_entry(ULONG input); UINT _ux_host_stack_hcd_register(UCHAR *hcd_name, UINT (*hcd_init_function)(struct UX_HCD_STRUCT *), ULONG hcd_param1, ULONG hcd_param2); +UINT _ux_host_stack_hcd_unregister(UCHAR *hcd_name, ULONG hcd_param1, ULONG hcd_param2); 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); @@ -109,8 +124,12 @@ UINT _ux_host_stack_rh_device_extraction(UX_HCD *hcd, UINT port_index); UINT _ux_host_stack_rh_device_insertion(UX_HCD *hcd, UINT port_index); 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); UINT _ux_host_stack_role_swap(UX_DEVICE *device); +#if defined(UX_OTG_SUPPORT) +VOID _ux_host_stack_hnp_polling_thread_entry(ULONG id); +#endif + + #endif diff --git a/common/core/inc/ux_system.h b/common/core/inc/ux_system.h index 06f898b..ac46308 100644 --- a/common/core/inc/ux_system.h +++ b/common/core/inc/ux_system.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_system.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -41,6 +41,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ diff --git a/common/core/inc/ux_user_sample.h b/common/core/inc/ux_user_sample.h index b7bb606..7f046fb 100644 --- a/common/core/inc/ux_user_sample.h +++ b/common/core/inc/ux_user_sample.h @@ -26,7 +26,7 @@ /* PORT SPECIFIC C INFORMATION RELEASE */ /* */ /* ux_user.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* */ /* AUTHOR */ /* */ @@ -45,6 +45,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ diff --git a/common/core/inc/ux_utility.h b/common/core/inc/ux_utility.h index 3f2b6e4..ae74c90 100644 --- a/common/core/inc/ux_utility.h +++ b/common/core/inc/ux_utility.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* ux_utility.h PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -41,6 +41,12 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* added timer delete, used UX */ +/* prefix to refer to TX */ +/* symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ @@ -66,10 +72,10 @@ ULONG _ux_utility_string_length_get(UCHAR *string); UINT _ux_utility_string_length_check(UCHAR *input_string, UINT *string_length_ptr, UINT max_string_length); UX_MEMORY_BLOCK *_ux_utility_memory_free_block_best_get(ULONG memory_cache_flag, ULONG memory_size_requested); VOID _ux_utility_memory_set(VOID *destination, UCHAR value, ULONG length); -UINT _ux_utility_mutex_create(TX_MUTEX *mutex, CHAR *mutex_name); -UINT _ux_utility_mutex_delete(TX_MUTEX *mutex); -VOID _ux_utility_mutex_off(TX_MUTEX *mutex); -VOID _ux_utility_mutex_on(TX_MUTEX *mutex); +UINT _ux_utility_mutex_create(UX_MUTEX *mutex, CHAR *mutex_name); +UINT _ux_utility_mutex_delete(UX_MUTEX *mutex); +VOID _ux_utility_mutex_off(UX_MUTEX *mutex); +VOID _ux_utility_mutex_on(UX_MUTEX *mutex); ULONG _ux_utility_pci_class_scan(ULONG pci_class, ULONG bus_number, ULONG device_number, ULONG function_number, ULONG *current_bus_number, ULONG *current_device_number, ULONG *current_function_number); @@ -78,44 +84,51 @@ ULONG _ux_utility_pci_read(ULONG bus_number, ULONG device_number, ULO VOID _ux_utility_pci_write(ULONG bus_number, ULONG device_number, ULONG function_number, ULONG offset, ULONG value, UINT write_size); VOID *_ux_utility_physical_address(VOID *virtual_address); -UINT _ux_utility_semaphore_create(TX_SEMAPHORE *semaphore, CHAR *semaphore_name, UINT initial_count); -UINT _ux_utility_semaphore_delete(TX_SEMAPHORE *semaphore); -UINT _ux_utility_semaphore_get(TX_SEMAPHORE *semaphore, ULONG semaphore_signal); -UINT _ux_utility_semaphore_put(TX_SEMAPHORE *semaphore); +UINT _ux_utility_semaphore_create(UX_SEMAPHORE *semaphore, CHAR *semaphore_name, UINT initial_count); +UINT _ux_utility_semaphore_delete(UX_SEMAPHORE *semaphore); +UINT _ux_utility_semaphore_get(UX_SEMAPHORE *semaphore, ULONG semaphore_signal); +UINT _ux_utility_semaphore_put(UX_SEMAPHORE *semaphore); VOID _ux_utility_set_interrupt_handler(UINT irq, VOID (*interrupt_handler)(VOID)); ULONG _ux_utility_short_get(UCHAR * address); ULONG _ux_utility_short_get_big_endian(UCHAR * address); VOID _ux_utility_short_put(UCHAR * address, USHORT value); VOID _ux_utility_short_put_big_endian(UCHAR * address, USHORT value); -UINT _ux_utility_thread_create(TX_THREAD *thread_ptr, CHAR *name, +UINT _ux_utility_thread_create(UX_THREAD *thread_ptr, CHAR *name, VOID (*entry_function)(ULONG), ULONG entry_input, VOID *stack_start, ULONG stack_size, UINT priority, UINT preempt_threshold, ULONG time_slice, UINT auto_start); -UINT _ux_utility_thread_delete(TX_THREAD *thread_ptr); +UINT _ux_utility_thread_delete(UX_THREAD *thread_ptr); VOID _ux_utility_thread_relinquish(VOID); UINT _ux_utility_thread_schedule_other(UINT caller_priority); -UINT _ux_utility_thread_resume(TX_THREAD *thread_ptr); +UINT _ux_utility_thread_resume(UX_THREAD *thread_ptr); UINT _ux_utility_thread_sleep(ULONG ticks); -UINT _ux_utility_thread_suspend(TX_THREAD *thread_ptr); -TX_THREAD *_ux_utility_thread_identify(VOID); -UINT _ux_utility_timer_create(TX_TIMER *timer, CHAR *timer_name, VOID (*expiration_function) (ULONG), +UINT _ux_utility_thread_suspend(UX_THREAD *thread_ptr); +UX_THREAD *_ux_utility_thread_identify(VOID); +UINT _ux_utility_timer_create(UX_TIMER *timer, CHAR *timer_name, VOID (*expiration_function) (ULONG), ULONG expiration_input, ULONG initial_ticks, ULONG reschedule_ticks, UINT activation_flag); +UINT _ux_utility_timer_delete(UX_TIMER *timer); VOID *_ux_utility_virtual_address(VOID *physical_address); -UINT _ux_utility_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR *name); -UINT _ux_utility_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr); -UINT _ux_utility_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags, +UINT _ux_utility_event_flags_create(UX_EVENT_FLAGS_GROUP*group_ptr, CHAR *name); +UINT _ux_utility_event_flags_delete(UX_EVENT_FLAGS_GROUP*group_ptr); +UINT _ux_utility_event_flags_get(UX_EVENT_FLAGS_GROUP*group_ptr, ULONG requested_flags, UINT get_option, ULONG *actual_flags_ptr, ULONG wait_option); -UINT _ux_utility_event_flags_set(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG flags_to_set, +UINT _ux_utility_event_flags_set(UX_EVENT_FLAGS_GROUP*group_ptr, ULONG flags_to_set, UINT set_option); VOID _ux_utility_unicode_to_string(UCHAR *source, UCHAR *destination); VOID _ux_utility_string_to_unicode(UCHAR *source, UCHAR *destination); -VOID _ux_system_error_handler(UINT system_level, UINT system_context, UINT error_code); VOID _ux_utility_debug_callback_register(VOID (*debug_callback)(UCHAR *, ULONG)); -VOID _ux_utility_error_callback_register(VOID (*error_callback)(UINT system_level, UINT system_context, UINT error_code)); VOID _ux_utility_delay_ms(ULONG ms_wait); +#ifdef UX_DISABLE_ERROR_HANDLER +#define _ux_system_error_handler(system_level, system_context, error_code) do {} while(0) +#define _ux_utility_error_callback_register(error_callback) do {} while(0) +#else +VOID _ux_system_error_handler(UINT system_level, UINT system_context, UINT error_code); +VOID _ux_utility_error_callback_register(VOID (*error_callback)(UINT system_level, UINT system_context, UINT error_code)); +#endif + #define UX_UTILITY_ADD_SAFE(add_a, add_b, result, status) do { \ if (UX_OVERFLOW_CHECK_ADD_ULONG(add_a, add_b)) \ status = UX_ERROR; \ @@ -174,6 +187,14 @@ VOID* _ux_utility_memory_allocate_add_safe(ULONG align,ULONG cache,UL #endif /* UX_DISABLE_ARITHMETIC_CHECK */ + +#if defined(UX_NAME_REFERENCED_BY_POINTER) +#define ux_utility_name_match(n0,n1,l) ((n0) == (n1)) +#else +#define ux_utility_name_match(n0,n1,l) (_ux_utility_memory_compare(n0,n1,l) == UX_SUCCESS) +#endif + + /* Define the system API mappings. Note: this section is only applicable to application source code, hence the conditional that turns off this diff --git a/common/core/src/ux_dcd_sim_slave_address_set.c b/common/core/src/ux_dcd_sim_slave_address_set.c index 703312e..82f2819 100644 --- a/common/core/src/ux_dcd_sim_slave_address_set.c +++ b/common/core/src/ux_dcd_sim_slave_address_set.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_address_set PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_address_set PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_address_set(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG address) diff --git a/common/core/src/ux_dcd_sim_slave_endpoint_create.c b/common/core/src/ux_dcd_sim_slave_endpoint_create.c index 3dcc2d2..912d5bf 100644 --- a/common/core/src/ux_dcd_sim_slave_endpoint_create.c +++ b/common/core/src/ux_dcd_sim_slave_endpoint_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_dcd_sim_slave_endpoint_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_create(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint) diff --git a/common/core/src/ux_dcd_sim_slave_endpoint_destroy.c b/common/core/src/ux_dcd_sim_slave_endpoint_destroy.c index 0fabe5f..b9690ed 100644 --- a/common/core/src/ux_dcd_sim_slave_endpoint_destroy.c +++ b/common/core/src/ux_dcd_sim_slave_endpoint_destroy.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_endpoint_destroy PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_endpoint_destroy PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_destroy(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint) diff --git a/common/core/src/ux_dcd_sim_slave_endpoint_reset.c b/common/core/src/ux_dcd_sim_slave_endpoint_reset.c index a2659f6..6dc0083 100644 --- a/common/core/src/ux_dcd_sim_slave_endpoint_reset.c +++ b/common/core/src/ux_dcd_sim_slave_endpoint_reset.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_endpoint_reset PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_endpoint_reset PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_reset(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint) diff --git a/common/core/src/ux_dcd_sim_slave_endpoint_stall.c b/common/core/src/ux_dcd_sim_slave_endpoint_stall.c index 00c53f0..53e2601 100644 --- a/common/core/src/ux_dcd_sim_slave_endpoint_stall.c +++ b/common/core/src/ux_dcd_sim_slave_endpoint_stall.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_endpoint_stall PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_endpoint_stall PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_stall(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint) diff --git a/common/core/src/ux_dcd_sim_slave_endpoint_status.c b/common/core/src/ux_dcd_sim_slave_endpoint_status.c index 1830cb6..a8b5c69 100644 --- a/common/core/src/ux_dcd_sim_slave_endpoint_status.c +++ b/common/core/src/ux_dcd_sim_slave_endpoint_status.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_dcd_sim_slave_endpoint_status PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_status(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG endpoint_index) diff --git a/common/core/src/ux_dcd_sim_slave_frame_number_get.c b/common/core/src/ux_dcd_sim_slave_frame_number_get.c index 6f87b2d..1901dbe 100644 --- a/common/core/src/ux_dcd_sim_slave_frame_number_get.c +++ b/common/core/src/ux_dcd_sim_slave_frame_number_get.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_frame_number_get PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_frame_number_get PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_frame_number_get(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG *frame_number) diff --git a/common/core/src/ux_dcd_sim_slave_function.c b/common/core/src/ux_dcd_sim_slave_function.c index bd58839..f3e332b 100644 --- a/common/core/src/ux_dcd_sim_slave_function.c +++ b/common/core/src/ux_dcd_sim_slave_function.c @@ -30,10 +30,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_function PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_function PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -76,6 +76,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_function(UX_SLAVE_DCD *dcd, UINT function, VOID *parameter) diff --git a/common/core/src/ux_dcd_sim_slave_initialize.c b/common/core/src/ux_dcd_sim_slave_initialize.c index 4499ae6..febc3bf 100644 --- a/common/core/src/ux_dcd_sim_slave_initialize.c +++ b/common/core/src/ux_dcd_sim_slave_initialize.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_initialize PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_initialize PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_initialize(VOID) diff --git a/common/core/src/ux_dcd_sim_slave_initialize_complete.c b/common/core/src/ux_dcd_sim_slave_initialize_complete.c index 7e22c85..820dad5 100644 --- a/common/core/src/ux_dcd_sim_slave_initialize_complete.c +++ b/common/core/src/ux_dcd_sim_slave_initialize_complete.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_initialize_complete PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_initialize_complete PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,9 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* prefixed UX to MS_TO_TICK, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_initialize_complete(VOID) @@ -102,7 +105,7 @@ UX_SLAVE_TRANSFER *transfer_request; transfer_request = &device -> ux_slave_device_control_endpoint.ux_slave_endpoint_transfer_request; /* Set the timeout to be for Control Endpoint. */ - transfer_request -> ux_slave_transfer_request_timeout = MS_TO_TICK(UX_CONTROL_TRANSFER_TIMEOUT); + transfer_request -> ux_slave_transfer_request_timeout = UX_MS_TO_TICK(UX_CONTROL_TRANSFER_TIMEOUT); /* Adjust the current data pointer as well. */ transfer_request -> ux_slave_transfer_request_current_data_pointer = diff --git a/common/core/src/ux_dcd_sim_slave_state_change.c b/common/core/src/ux_dcd_sim_slave_state_change.c index eacd3d8..4ed8e3c 100644 --- a/common/core/src/ux_dcd_sim_slave_state_change.c +++ b/common/core/src/ux_dcd_sim_slave_state_change.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_dcd_sim_slave_state_change PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_state_change(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG state) diff --git a/common/core/src/ux_dcd_sim_slave_transfer_abort.c b/common/core/src/ux_dcd_sim_slave_transfer_abort.c index f3c56b4..9648aab 100644 --- a/common/core/src/ux_dcd_sim_slave_transfer_abort.c +++ b/common/core/src/ux_dcd_sim_slave_transfer_abort.c @@ -33,8 +33,8 @@ /* */ /* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_transfer_abort PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_transfer_abort PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_transfer_abort(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request) diff --git a/common/core/src/ux_dcd_sim_slave_transfer_request.c b/common/core/src/ux_dcd_sim_slave_transfer_request.c index 5e1d530..41c8485 100644 --- a/common/core/src/ux_dcd_sim_slave_transfer_request.c +++ b/common/core/src/ux_dcd_sim_slave_transfer_request.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_dcd_sim_slave_transfer_request PORTABLE C */ -/* 6.0 */ +/* _ux_dcd_sim_slave_transfer_request PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +71,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_transfer_request(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request) diff --git a/common/core/src/ux_device_class_dpump_activate.c b/common/core/src/ux_device_class_dpump_activate.c index 1e0d307..e2f401d 100644 --- a/common/core/src/ux_device_class_dpump_activate.c +++ b/common/core/src/ux_device_class_dpump_activate.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_dpump_activate PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_class_dpump_activate(UX_SLAVE_CLASS_COMMAND *command) diff --git a/common/core/src/ux_device_class_dpump_change.c b/common/core/src/ux_device_class_dpump_change.c index e4e759a..6c6b90e 100644 --- a/common/core/src/ux_device_class_dpump_change.c +++ b/common/core/src/ux_device_class_dpump_change.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_dpump_change PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_class_dpump_change(UX_SLAVE_CLASS_COMMAND *command) @@ -133,9 +137,9 @@ UX_SLAVE_ENDPOINT *endpoint; /* Reset the endpoint buffers. */ _ux_utility_memory_set(dpump -> ux_slave_class_dpump_bulkout_endpoint -> ux_slave_endpoint_transfer_request. - ux_slave_transfer_request_data_pointer, 0, UX_SLAVE_REQUEST_DATA_MAX_LENGTH); + ux_slave_transfer_request_data_pointer, 0, UX_SLAVE_REQUEST_DATA_MAX_LENGTH); /* Use case of memset is verified. */ _ux_utility_memory_set(dpump -> ux_slave_class_dpump_bulkin_endpoint -> ux_slave_endpoint_transfer_request. - ux_slave_transfer_request_data_pointer, 0, UX_SLAVE_REQUEST_DATA_MAX_LENGTH); + 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; diff --git a/common/core/src/ux_device_class_dpump_deactivate.c b/common/core/src/ux_device_class_dpump_deactivate.c index 420ae11..188efe9 100644 --- a/common/core/src/ux_device_class_dpump_deactivate.c +++ b/common/core/src/ux_device_class_dpump_deactivate.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_dpump_deactivate PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_class_dpump_deactivate(UX_SLAVE_CLASS_COMMAND *command) diff --git a/common/core/src/ux_device_class_dpump_entry.c b/common/core/src/ux_device_class_dpump_entry.c index d91272d..10c3aac 100644 --- a/common/core/src/ux_device_class_dpump_entry.c +++ b/common/core/src/ux_device_class_dpump_entry.c @@ -33,8 +33,8 @@ /* */ /* FUNCTION RELEASE */ /* */ -/* _ux_class_device_dpump_entry PORTABLE C */ -/* 6.0 */ +/* _ux_device_class_dpump_entry PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,6 +70,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_class_dpump_entry(UX_SLAVE_CLASS_COMMAND *command) diff --git a/common/core/src/ux_device_class_dpump_initialize.c b/common/core/src/ux_device_class_dpump_initialize.c index 8096878..50f88e4 100644 --- a/common/core/src/ux_device_class_dpump_initialize.c +++ b/common/core/src/ux_device_class_dpump_initialize.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_dpump_initialize PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_class_dpump_initialize(UX_SLAVE_CLASS_COMMAND *command) diff --git a/common/core/src/ux_device_class_dpump_read.c b/common/core/src/ux_device_class_dpump_read.c index 2a607e4..7108cf5 100644 --- a/common/core/src/ux_device_class_dpump_read.c +++ b/common/core/src/ux_device_class_dpump_read.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_dpump_read PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_class_dpump_read(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer, @@ -143,7 +147,7 @@ ULONG local_requested_length; /* We need to copy the buffer locally. */ _ux_utility_memory_copy(buffer, transfer_request -> ux_slave_transfer_request_data_pointer, - local_requested_length); + local_requested_length); /* Use case of memcpy is verified. */ /* Next buffer address. */ buffer += transfer_request -> ux_slave_transfer_request_actual_length; diff --git a/common/core/src/ux_device_class_dpump_thread.c b/common/core/src/ux_device_class_dpump_thread.c index 254ea75..598f6e7 100644 --- a/common/core/src/ux_device_class_dpump_thread.c +++ b/common/core/src/ux_device_class_dpump_thread.c @@ -37,7 +37,7 @@ VOID _ux_device_class_dpump_thread(ULONG dpump_class); /* FUNCTION RELEASE */ /* */ /* _ux_device_class_dpump_thread PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,6 +70,10 @@ VOID _ux_device_class_dpump_thread(ULONG dpump_class); /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_device_class_dpump_thread(ULONG dpump_class) @@ -141,7 +145,7 @@ ULONG length; /* Copy the buffer to the target in endpoint. */ _ux_utility_memory_copy(endpoint_in -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer, endpoint_out -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer, - length); + length); /* Use case of memcpy is verified. */ /* Now we send the packet back to the host. On the endpoint In. */ transfer_request = &endpoint_in -> ux_slave_endpoint_transfer_request; diff --git a/common/core/src/ux_device_class_dpump_write.c b/common/core/src/ux_device_class_dpump_write.c index 676bf69..4d72b42 100644 --- a/common/core/src/ux_device_class_dpump_write.c +++ b/common/core/src/ux_device_class_dpump_write.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_class_dpump_write PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_class_dpump_write(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer, @@ -138,7 +142,7 @@ UINT status; /* 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, - buffer, local_requested_length); + 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); diff --git a/common/core/src/ux_device_stack_alternate_setting_get.c b/common/core/src/ux_device_stack_alternate_setting_get.c index 8d26f59..9e61808 100644 --- a/common/core/src/ux_device_stack_alternate_setting_get.c +++ b/common/core/src/ux_device_stack_alternate_setting_get.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_alternate_setting_get PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_alternate_setting_get PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_alternate_setting_get(ULONG interface_value) @@ -91,8 +95,12 @@ UINT status; /* Obtain the pointer to the first interface attached. */ interface = 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) +#else + if (interface != UX_NULL) +#endif { /* Check if this is the interface we have an inquiry for. */ @@ -122,8 +130,10 @@ UINT status; return(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; +#endif } } diff --git a/common/core/src/ux_device_stack_alternate_setting_set.c b/common/core/src/ux_device_stack_alternate_setting_set.c index 5e67f76..d48d506 100644 --- a/common/core/src/ux_device_stack_alternate_setting_set.c +++ b/common/core/src/ux_device_stack_alternate_setting_set.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_alternate_setting_set PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_alternate_setting_set PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,11 +73,19 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, verified */ +/* memset and memcpy cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_alternate_setting_set(ULONG interface_value, ULONG alternate_setting_value) { +UX_SLAVE_DEVICE *device; +UX_SLAVE_INTERFACE *interface; +#if !defined(UX_DEVICE_ALTERNATE_SETTING_SUPPORT_DISABLE) UX_SLAVE_DCD *dcd; UX_SLAVE_TRANSFER *transfer_request; UCHAR *device_framework; @@ -86,36 +94,29 @@ ULONG descriptor_length; UCHAR descriptor_type; UX_CONFIGURATION_DESCRIPTOR configuration_descriptor; UX_INTERFACE_DESCRIPTOR interface_descriptor; -UX_SLAVE_DEVICE *device; UX_SLAVE_ENDPOINT *endpoint; UX_SLAVE_ENDPOINT *next_endpoint; -UX_SLAVE_INTERFACE *interface; UX_SLAVE_ENDPOINT *endpoint_link; ULONG endpoints_pool_number; UX_SLAVE_CLASS_COMMAND class_command; UX_SLAVE_CLASS *class; UINT status; +#endif /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_ALTERNATE_SETTING_SET, interface_value, alternate_setting_value, 0, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0) - /* Get the pointer to the DCD. */ - dcd = &_ux_system_slave->ux_system_slave_dcd; - - /* We may have multiple configurations! */ - device_framework = _ux_system_slave -> ux_system_slave_device_framework; - device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length; - /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; /* Protocol error must be reported when it's unconfigured */ if (device -> ux_slave_device_state != UX_DEVICE_CONFIGURED) - return UX_FUNCTION_NOT_SUPPORTED; + return(UX_FUNCTION_NOT_SUPPORTED); /* Find the current interface. */ interface = 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) { @@ -125,6 +126,10 @@ UINT status; else interface = interface -> ux_slave_interface_next_interface; } +#else + if (interface -> ux_slave_interface_descriptor.bInterfaceNumber != interface_value) + interface = UX_NULL; +#endif /* We must have found the interface pointer for the interface value requested by the caller. */ @@ -139,12 +144,30 @@ UINT status; 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) return(UX_SUCCESS); - + +#if defined(UX_DEVICE_ALTERNATE_SETTING_SUPPORT_DISABLE) + + /* If alternate setting is disabled, do error trap. */ + _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) + + return(UX_FUNCTION_NOT_SUPPORTED); +#else + + /* Get the pointer to the DCD. */ + dcd = &_ux_system_slave->ux_system_slave_dcd; + + /* We may have multiple configurations! */ + device_framework = _ux_system_slave -> ux_system_slave_device_framework; + device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length; + /* Parse the device framework and locate a configuration descriptor. */ while (device_framework_length != 0) { @@ -352,7 +375,7 @@ UINT status; } /* 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)); + _ux_utility_memory_copy(&interface -> 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]; @@ -404,5 +427,6 @@ UINT status; /* Return error completion. */ return(UX_ERROR); +#endif } diff --git a/common/core/src/ux_device_stack_class_register.c b/common/core/src/ux_device_stack_class_register.c index b65b725..9895699 100644 --- a/common/core/src/ux_device_stack_class_register.c +++ b/common/core/src/ux_device_stack_class_register.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_class_register PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_class_register PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,6 +74,11 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, verified */ +/* memset and memcpy cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_class_register(UCHAR *class_name, @@ -83,11 +88,13 @@ UINT _ux_device_stack_class_register(UCHAR *class_name, VOID *parameter) { -UX_SLAVE_CLASS *class; -ULONG class_index; +UX_SLAVE_CLASS *class_inst; UINT status; UX_SLAVE_CLASS_COMMAND command; UINT class_name_length = 0; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 +ULONG class_index; +#endif /* Get the length of the class name (exclude null-terminator). */ @@ -98,34 +105,42 @@ UINT class_name_length = 0; /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_CLASS_REGISTER, class_name, interface_number, parameter, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0) + /* Get first class. */ + class_inst = _ux_system_slave -> ux_system_slave_class_array; + +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* We need to parse the class table to find an empty spot. */ - class = _ux_system_slave -> ux_system_slave_class_array; for (class_index = 0; class_index < _ux_system_slave -> ux_system_slave_max_class; class_index++) { +#endif /* Check if this class is already used. */ - if (class -> ux_slave_class_status == UX_UNUSED) + if (class_inst -> ux_slave_class_status == UX_UNUSED) { +#if defined(UX_NAME_REFERENCED_BY_POINTER) + class_inst -> ux_slave_class_name = (const UCHAR *)class_name; +#else /* We have found a free container for the class. Copy the name (with null-terminator). */ - _ux_utility_memory_copy(class -> ux_slave_class_name, class_name, class_name_length + 1); + _ux_utility_memory_copy(class_inst -> ux_slave_class_name, class_name, class_name_length + 1); /* Use case of memcpy is verified. */ +#endif /* Memorize the entry function of this class. */ - class -> ux_slave_class_entry_function = class_entry_function; + class_inst -> ux_slave_class_entry_function = class_entry_function; /* Memorize the pointer to the application parameter. */ - class -> ux_slave_class_interface_parameter = parameter; + class_inst -> ux_slave_class_interface_parameter = parameter; /* Memorize the configuration number on which this instance will be called. */ - class -> ux_slave_class_configuration_number = configuration_number; + class_inst -> ux_slave_class_configuration_number = configuration_number; /* Memorize the interface number on which this instance will be called. */ - class -> ux_slave_class_interface_number = interface_number; + class_inst -> ux_slave_class_interface_number = interface_number; /* Build all the fields of the Class Command to initialize the class. */ command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_INITIALIZE; command.ux_slave_class_command_parameter = parameter; - command.ux_slave_class_command_class_ptr = class; + command.ux_slave_class_command_class_ptr = class_inst; /* Call the class initialization routine. */ status = class_entry_function(&command); @@ -135,15 +150,17 @@ UINT class_name_length = 0; return(status); /* Make this class used now. */ - class -> ux_slave_class_status = UX_USED; + class_inst -> ux_slave_class_status = UX_USED; /* Return successful completion. */ return(UX_SUCCESS); } +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* Move to the next class. */ - class++; + class_inst ++; } +#endif /* No more entries in the class table. */ return(UX_MEMORY_INSUFFICIENT); diff --git a/common/core/src/ux_device_stack_class_unregister.c b/common/core/src/ux_device_stack_class_unregister.c index 9fa2d1c..8e89d9c 100644 --- a/common/core/src/ux_device_stack_class_unregister.c +++ b/common/core/src/ux_device_stack_class_unregister.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_class_unregister PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_class_unregister PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,43 +71,56 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_class_unregister(UCHAR *class_name, UINT (*class_entry_function)(struct UX_SLAVE_CLASS_COMMAND_STRUCT *)) { -UX_SLAVE_CLASS *class; -ULONG class_index; +UX_SLAVE_CLASS *class_inst; UINT status; UX_SLAVE_CLASS_COMMAND command; +#if !defined(UX_NAME_REFERENCED_BY_POINTER) UINT class_name_length = 0; +#endif +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 +ULONG class_index; +#endif /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_CLASS_UNREGISTER, class_name, 0, 0, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0) +#if !defined(UX_NAME_REFERENCED_BY_POINTER) /* Get the length of the class name (exclude null-terminator). */ status = _ux_utility_string_length_check(class_name, &class_name_length, UX_MAX_CLASS_NAME_LENGTH); if (status) return(status); +#endif + + class_inst = _ux_system_slave -> ux_system_slave_class_array; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* We need to parse the class table to find the right class. */ - class = _ux_system_slave -> ux_system_slave_class_array; for (class_index = 0; class_index < _ux_system_slave -> ux_system_slave_max_class; class_index++) { +#endif /* Check if this class is the right one. */ - if (class -> ux_slave_class_status == UX_USED) + if (class_inst -> ux_slave_class_status == UX_USED) { /* We have found a used container with a class. Compare the name (include null-terminator). */ - if (_ux_utility_memory_compare(class -> ux_slave_class_name, class_name, class_name_length + 1) == UX_SUCCESS) + if (ux_utility_name_match(class_inst -> ux_slave_class_name, class_name, class_name_length + 1)) { /* Build all the fields of the Class Command to uninitialize the class. */ command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_UNINITIALIZE; - command.ux_slave_class_command_class_ptr = class; + command.ux_slave_class_command_class_ptr = class_inst; /* Call the class uninitialization routine. */ status = class_entry_function(&command); @@ -117,19 +130,21 @@ UINT class_name_length = 0; return(status); /* Make this class unused now. */ - class -> ux_slave_class_status = UX_UNUSED; + class_inst -> ux_slave_class_status = UX_UNUSED; /* Erase the instance of the class. */ - class -> ux_slave_class_instance = UX_NULL; + class_inst -> ux_slave_class_instance = UX_NULL; /* Return successful completion. */ return(UX_SUCCESS); } } +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* Move to the next class. */ - class++; + class_inst ++; } +#endif /* No class match. */ return(UX_NO_CLASS_MATCH); diff --git a/common/core/src/ux_device_stack_clear_feature.c b/common/core/src/ux_device_stack_clear_feature.c index 02356d0..5d078b0 100644 --- a/common/core/src/ux_device_stack_clear_feature.c +++ b/common/core/src/ux_device_stack_clear_feature.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_stack_clear_feature PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_clear_feature(ULONG request_type, ULONG request_value, ULONG request_index) @@ -125,8 +129,10 @@ UX_SLAVE_ENDPOINT *endpoint_target; We need to find the endpoint through the interface(s). */ interface = device -> ux_slave_device_first_interface; +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 while (interface != UX_NULL) { +#endif /* Get the first endpoint for this interface. */ endpoint_target = interface -> ux_slave_interface_first_endpoint; @@ -153,9 +159,12 @@ UX_SLAVE_ENDPOINT *endpoint_target; endpoint_target = endpoint_target -> ux_slave_endpoint_next_endpoint; } +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 /* Next interface. */ interface = interface -> ux_slave_interface_next_interface; } +#endif + /* Intentional fallthrough and go into the default case. */ /* fall through */ diff --git a/common/core/src/ux_device_stack_configuration_get.c b/common/core/src/ux_device_stack_configuration_get.c index f069038..569db9a 100644 --- a/common/core/src/ux_device_stack_configuration_get.c +++ b/common/core/src/ux_device_stack_configuration_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_stack_configuration_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_configuration_get(VOID) diff --git a/common/core/src/ux_device_stack_configuration_set.c b/common/core/src/ux_device_stack_configuration_set.c index 6c55218..7723c75 100644 --- a/common/core/src/ux_device_stack_configuration_set.c +++ b/common/core/src/ux_device_stack_configuration_set.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_configuration_set PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_configuration_set PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_configuration_set(ULONG configuration_value) @@ -85,15 +89,19 @@ UCHAR descriptor_type; UX_CONFIGURATION_DESCRIPTOR configuration_descriptor = { 0 }; UX_INTERFACE_DESCRIPTOR interface_descriptor; UX_SLAVE_INTERFACE *interface; +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 UX_SLAVE_INTERFACE *next_interface; -UX_SLAVE_CLASS *class; +#endif +UX_SLAVE_CLASS *class_inst; UX_SLAVE_CLASS *current_class = UX_NULL; UX_SLAVE_CLASS_COMMAND class_command; UX_SLAVE_DEVICE *device; ULONG iad_flag; ULONG iad_first_interface = 0; ULONG iad_number_interfaces = 0; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 ULONG class_index; +#endif /* If trace is enabled, insert this event into the trace buffer. */ @@ -159,35 +167,41 @@ ULONG class_index; /* Get the pointer to the first interface. */ interface = 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) { - +#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; /* Get the pointer to the class container of this interface. */ - class = interface -> ux_slave_interface_class; + class_inst = interface -> 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_inst; /* If there is a class container for this instance, deactivate it. */ - if (class != UX_NULL) + if (class_inst != UX_NULL) /* Call the class with the DEACTIVATE signal. */ - class -> ux_slave_class_entry_function(&class_command); + class_inst -> 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; +#endif /* Remove the interface and all endpoints associated with it. */ _ux_device_stack_interface_delete(interface); +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 /* Now we refresh the interface pointer. */ interface = next_interface; } +#endif + } /* No configuration is selected. */ @@ -273,35 +287,41 @@ ULONG class_index; { /* First interface. Scan the list of classes to find a match. */ - class = _ux_system_slave -> ux_system_slave_class_array; + class_inst = _ux_system_slave -> ux_system_slave_class_array; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* Parse all the class drivers. */ for (class_index = 0; class_index < _ux_system_slave -> ux_system_slave_max_class; class_index++) { +#endif /* Check if this class driver is used. */ - if (class -> ux_slave_class_status == UX_USED) + if (class_inst -> ux_slave_class_status == UX_USED) { /* Check if this is the same interface for the same configuration. */ - if ((interface_descriptor.bInterfaceNumber == class -> ux_slave_class_interface_number) && - (configuration_value == class -> ux_slave_class_configuration_number)) + if ((interface_descriptor.bInterfaceNumber == class_inst -> ux_slave_class_interface_number) && + (configuration_value == class_inst -> ux_slave_class_configuration_number)) { /* Memorize the class in the class/interface array. */ - _ux_system_slave -> ux_system_slave_interface_class_array[interface_descriptor.bInterfaceNumber] = class; + _ux_system_slave -> ux_system_slave_interface_class_array[interface_descriptor.bInterfaceNumber] = class_inst; /* And again as the current class. */ - current_class = class; + current_class = class_inst; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* We are done here. */ break; +#endif } } +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* Move to the next registered class. */ - class++; + class_inst ++; } +#endif } else @@ -322,32 +342,38 @@ ULONG class_index; { /* First interface. Scan the list of classes to find a match. */ - class = _ux_system_slave -> ux_system_slave_class_array; + class_inst = _ux_system_slave -> ux_system_slave_class_array; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* Parse all the class drivers. */ for (class_index = 0; class_index < _ux_system_slave -> ux_system_slave_max_class; class_index++) { +#endif /* Check if this class driver is used. */ - if (class -> ux_slave_class_status == UX_USED) + if (class_inst -> ux_slave_class_status == UX_USED) { /* Check if this is the same interface for the same configuration. */ - if ((interface_descriptor.bInterfaceNumber == class -> ux_slave_class_interface_number) && - (configuration_value == class -> ux_slave_class_configuration_number)) + if ((interface_descriptor.bInterfaceNumber == class_inst -> ux_slave_class_interface_number) && + (configuration_value == class_inst -> ux_slave_class_configuration_number)) { /* Memorize the class in the class/interface array. */ - _ux_system_slave -> ux_system_slave_interface_class_array[interface_descriptor.bInterfaceNumber] = class; + _ux_system_slave -> ux_system_slave_interface_class_array[interface_descriptor.bInterfaceNumber] = class_inst; +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* We are done here. */ break; +#endif } } +#if UX_MAX_SLAVE_CLASS_DRIVER > 1 /* Move to the next registered class. */ - class++; + class_inst ++; } +#endif } /* Set the interface. */ diff --git a/common/core/src/ux_device_stack_control_request_process.c b/common/core/src/ux_device_stack_control_request_process.c index 3fbf671..3386dfd 100644 --- a/common/core/src/ux_device_stack_control_request_process.c +++ b/common/core/src/ux_device_stack_control_request_process.c @@ -30,10 +30,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_control_request_process PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_control_request_process PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -78,6 +78,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_control_request_process(UX_SLAVE_TRANSFER *transfer_request) diff --git a/common/core/src/ux_device_stack_descriptor_send.c b/common/core/src/ux_device_stack_descriptor_send.c index a1906fb..a165810 100644 --- a/common/core/src/ux_device_stack_descriptor_send.c +++ b/common/core/src/ux_device_stack_descriptor_send.c @@ -12,8 +12,8 @@ /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Device Stack */ /** */ @@ -29,12 +29,18 @@ #include "ux_device_stack.h" +#if (UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH < UX_DEVICE_DESCRIPTOR_LENGTH) || \ + (UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH < UX_DEVICE_QUALIFIER_DESCRIPTOR_LENGTH) || \ + (UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH < UX_OTG_DESCRIPTOR_LENGTH) +#error UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH too small, please check +#endif + /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_descriptor_send PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_descriptor_send PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -51,26 +57,31 @@ /* */ /* OUTPUT */ /* */ -/* Completion Status */ +/* Completion Status */ +/* */ +/* CALLS */ /* */ -/* CALLS */ -/* */ -/* (ux_slave_dcd_function) DCD dispatch function */ +/* (ux_slave_dcd_function) DCD dispatch function */ /* _ux_device_stack_transfer_request Process transfer request */ -/* _ux_utility_descriptor_parse Parse descriptor */ -/* _ux_utility_memory_copy Memory copy */ -/* _ux_utility_short_get Get short value */ -/* */ -/* CALLED BY */ -/* */ -/* Application */ +/* _ux_utility_descriptor_parse Parse descriptor */ +/* _ux_utility_memory_copy Memory copy */ +/* _ux_utility_short_get Get short value */ +/* */ +/* CALLED BY */ +/* */ +/* Application */ /* Device Stack */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized descriptor search */ +/* logic, verified memset and */ +/* memcpy cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_descriptor_send(ULONG descriptor_type, ULONG request_index, ULONG host_length) @@ -103,7 +114,7 @@ ULONG string_length; /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; - + /* Get the control endpoint associated with the device. */ endpoint = &device -> ux_slave_device_control_endpoint; @@ -115,41 +126,42 @@ ULONG string_length; /* Isolate the descriptor index. */ descriptor_index = descriptor_type & 0xff; - + /* Reset the parsed index. */ parsed_descriptor_index = 0; - + /* Shift the descriptor type in the low byte field. */ descriptor_type = (UCHAR) ((descriptor_type >> 8) & 0xff); + /* Default descriptor length is host length. */ + length = host_length; + /* What type of descriptor do we need to return? */ switch (descriptor_type) { case UX_DEVICE_DESCRIPTOR_ITEM: - /* Setup the length appropriately. */ + /* Setup device descriptor length. */ if (host_length > UX_DEVICE_DESCRIPTOR_LENGTH) length = UX_DEVICE_DESCRIPTOR_LENGTH; - else - length = host_length; - - /* Copy the device descriptor into the transfer request memory. */ - _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, - _ux_system_slave -> ux_system_slave_device_framework, length); - - /* Perform the data transfer. */ - status = _ux_device_stack_transfer_request(transfer_request, length, host_length); - break; + /* Fall through. */ case UX_DEVICE_QUALIFIER_DESCRIPTOR_ITEM: - /* Setup the length appropriately. */ - if (host_length > UX_DEVICE_QUALIFIER_DESCRIPTOR_LENGTH) + /* Setup qualifier descriptor length. */ + if (descriptor_type == UX_DEVICE_QUALIFIER_DESCRIPTOR_ITEM && + host_length > UX_DEVICE_QUALIFIER_DESCRIPTOR_LENGTH) length = UX_DEVICE_QUALIFIER_DESCRIPTOR_LENGTH; - else - length = host_length; - + + /* Fall through. */ + case UX_OTG_DESCRIPTOR_ITEM: + + /* Setup OTG descriptor length. */ + if (descriptor_type == UX_OTG_DESCRIPTOR_ITEM && + host_length > UX_OTG_DESCRIPTOR_LENGTH) + length = UX_OTG_DESCRIPTOR_LENGTH; + /* We may or may not have a device qualifier descriptor. */ device_framework = _ux_system_slave -> ux_system_slave_device_framework; device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length; @@ -158,20 +170,17 @@ ULONG string_length; /* Parse the device framework and locate a device qualifier descriptor. */ while (device_framework < device_framework_end) { - - /* Get the type of the current descriptor. */ - descriptor_type = *(device_framework + 1); - /* And its length. */ + /* Get descriptor length. */ descriptor_length = (ULONG) *device_framework; - - /* Check if this is a device qualifier descriptor. */ - if (descriptor_type == UX_DEVICE_QUALIFIER_DESCRIPTOR_ITEM) + + /* Check if this is a descriptor expected. */ + if (*(device_framework + 1) == descriptor_type) { - - /* Copy the device qualifier descriptor into the transfer request memory. */ - _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, - device_framework, length); + + /* Copy the device descriptor into the transfer request memory. */ + _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, + device_framework, length); /* Use case of memcpy is verified. */ /* Perform the data transfer. */ status = _ux_device_stack_transfer_request(transfer_request, length, host_length); @@ -184,77 +193,44 @@ ULONG string_length; /* Point to the next descriptor. */ device_framework += descriptor_length; } - break; - case UX_OTG_DESCRIPTOR_ITEM: - - /* Setup the length appropriately. */ - if (host_length > UX_OTG_DESCRIPTOR_LENGTH) - length = UX_OTG_DESCRIPTOR_LENGTH; - else - length = host_length; - - /* We may or may not have a OTG descriptor. */ - device_framework = _ux_system_slave -> ux_system_slave_device_framework; - device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length; - device_framework_end = device_framework + device_framework_length; + case UX_OTHER_SPEED_DESCRIPTOR_ITEM: + /* Fall through. */ + case UX_CONFIGURATION_DESCRIPTOR_ITEM: - /* Parse the device framework and locate a OTG descriptor. */ - while (device_framework < device_framework_end) + if (descriptor_type == UX_OTHER_SPEED_DESCRIPTOR_ITEM) { - - /* Get the type of the current descriptor. */ - descriptor_type = *(device_framework + 1); - - /* And its length. */ - descriptor_length = (ULONG) *device_framework; - - /* Check if this is a OTG descriptor. */ - if (descriptor_type == UX_OTG_DESCRIPTOR_ITEM) - { - - /* Copy the device OTG descriptor into the transfer request memory. */ - _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, - device_framework, length); - - /* Perform the data transfer. */ - status = _ux_device_stack_transfer_request(transfer_request, length, host_length); - break; - } - /* Adjust what is left of the device framework. */ - device_framework_length -= descriptor_length; - - /* Point to the next descriptor. */ - device_framework += descriptor_length; + /* This request is used by the host to find out the capability of this device + if it was running at full speed. The behavior is the same as in a GET_CONFIGURATIOn descriptor + but we do not use the current device framework but rather the full speed framework. */ + device_framework = _ux_system_slave -> ux_system_slave_device_framework_full_speed; + device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length_full_speed; + device_framework_end = device_framework + device_framework_length; } - break; - - case UX_OTHER_SPEED_DESCRIPTOR_ITEM: + else + { - /* This request is used by the host to find out the capability of this device - if it was running at full speed. The behavior is the same as in a GET_CONFIGURATIOn descriptor - but we do not use the current device framework but rather the full speed framework. */ - device_framework = _ux_system_slave -> ux_system_slave_device_framework_full_speed; - device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length_full_speed; - device_framework_end = device_framework + device_framework_length; + /* We may have multiple configurations !, the index will tell us what + configuration descriptor we need to return. */ + device_framework = _ux_system_slave -> ux_system_slave_device_framework; + device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length; + device_framework_end = device_framework + device_framework_length; + } /* Parse the device framework and locate a configuration descriptor. */ while (device_framework < device_framework_end) { - /* Get the type of the current descriptor. */ - descriptor_type = *(device_framework + 1); - - /* And its length. */ + /* Get descriptor length. */ descriptor_length = (ULONG) *device_framework; - + /* Check if this is a configuration descriptor. We are cheating here. Instead of creating a OTHER SPEED descriptor, we simply scan the configuration descriptor for the Full Speed framework and return this configuration after we manually changed the configuration descriptor item into a Other Speed Descriptor. */ - if (descriptor_type == UX_CONFIGURATION_DESCRIPTOR_ITEM) + if (*(device_framework + 1) == UX_CONFIGURATION_DESCRIPTOR_ITEM) { /* Check the index. It must be the same as the one requested. */ @@ -274,8 +250,8 @@ ULONG string_length; and do not return more than what is allowed. */ if (configuration_descriptor_length < host_length) length = configuration_descriptor_length; - else - length = host_length; + else + length = host_length; /* Check buffer length, since total descriptors length may exceed buffer... */ if (length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) @@ -292,92 +268,12 @@ ULONG string_length; } /* Copy the device descriptor into the transfer request memory. */ - _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, - device_framework, length); + _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, + device_framework, length); /* Use case of memcpy is verified. */ - /* Now we need to hack the found descriptor because this request expect a OTHER_SPEED + /* Now we need to hack the found descriptor because this request expect a OTHER_SPEED descriptor instead of the regular CONFIGURATION descriptor. */ - *(transfer_request -> ux_slave_transfer_request_data_pointer + 1) = UX_OTHER_SPEED_DESCRIPTOR_ITEM; - - /* We can return the configuration descriptor. */ - status = _ux_device_stack_transfer_request(transfer_request, length, host_length); - break; - } - else - { - - /* There may be more configuration descriptors in this framework. */ - parsed_descriptor_index++; - } - } - - /* Adjust what is left of the device framework. */ - device_framework_length -= descriptor_length; - - /* Point to the next descriptor. */ - device_framework += descriptor_length; - } - break; - - case UX_CONFIGURATION_DESCRIPTOR_ITEM: - - /* We may have multiple configurations !, the index will tell us what - configuration descriptor we need to return. */ - device_framework = _ux_system_slave -> ux_system_slave_device_framework; - device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length; - device_framework_end = device_framework + device_framework_length; - - /* Parse the device framework and locate a configuration descriptor. */ - while (device_framework < device_framework_end) - { - - /* Get the type of the current descriptor. */ - descriptor_type = *(device_framework + 1); - - /* And its length. */ - descriptor_length = (ULONG) *device_framework; - - /* Check if this is a configuration descriptor. */ - if (descriptor_type == UX_CONFIGURATION_DESCRIPTOR_ITEM) - { - - /* Check the index. It must be the same as the one requested. */ - if (parsed_descriptor_index == descriptor_index) - { - - /* Parse the configuration descriptor. */ - _ux_utility_descriptor_parse(device_framework, - _ux_system_configuration_descriptor_structure, - UX_CONFIGURATION_DESCRIPTOR_ENTRIES, - (UCHAR *) &configuration_descriptor); - - /* Get the length of entire configuration descriptor. */ - configuration_descriptor_length = configuration_descriptor.wTotalLength; - - /* Ensure the host does not demand a length beyond our descriptor (Windows does that) - and do not return more than what is allowed. */ - if (configuration_descriptor_length < host_length) - length = configuration_descriptor_length; - else - length = host_length; - - /* Check buffer length, since total descriptors length may exceed buffer... */ - if (length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) - { - /* Error trap. */ - _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_DEVICE_STACK, UX_MEMORY_INSUFFICIENT); - - /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MEMORY_INSUFFICIENT, device, 0, 0, UX_TRACE_ERRORS, 0, 0) - - /* Stall the endpoint. */ - status = dcd -> ux_slave_dcd_function(dcd, UX_DCD_STALL_ENDPOINT, endpoint); - break; - } - - /* Copy the device descriptor into the transfer request memory. */ - _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, - device_framework, length); + *(transfer_request -> ux_slave_transfer_request_data_pointer + 1) = (UCHAR)descriptor_type; /* We can return the configuration descriptor. */ status = _ux_device_stack_transfer_request(transfer_request, length, host_length); @@ -401,7 +297,7 @@ ULONG string_length; case UX_STRING_DESCRIPTOR_ITEM: - /* We need to filter for the index 0 which is the language ID string. */ + /* We need to filter for the index 0 which is the language ID string. */ if (descriptor_index == 0) { @@ -431,13 +327,13 @@ ULONG string_length; /* Store the language ID into the buffer. */ _ux_utility_memory_copy(string_memory+2, _ux_system_slave -> ux_system_slave_language_id_framework, - _ux_system_slave -> ux_system_slave_language_id_framework_length); + _ux_system_slave -> ux_system_slave_language_id_framework_length); /* Use case of memcpy is verified. */ /* Filter the length asked/required. */ if (host_length > _ux_system_slave -> ux_system_slave_language_id_framework_length + 2) length = _ux_system_slave -> ux_system_slave_language_id_framework_length + 2; else - length = host_length; + length = host_length; /* We can return the string language ID descriptor. */ status = _ux_device_stack_transfer_request(transfer_request, length, host_length); @@ -449,16 +345,16 @@ ULONG string_length; and length. */ string_framework = _ux_system_slave -> ux_system_slave_string_framework; string_framework_length = _ux_system_slave -> ux_system_slave_string_framework_length; - - /* We search through the string framework until we find the right index. + + /* We search through the string framework until we find the right index. The index is in the lower byte of the descriptor type. */ while (string_framework_length != 0) { - + /* Ensure we have the correct language page. */ if (_ux_utility_short_get(string_framework) == request_index) { - + /* Check the index. */ if (*(string_framework + 2) == descriptor_index) { @@ -480,7 +376,7 @@ ULONG string_length; /* We have a request to send back a string. Use the transfer request buffer. */ string_memory = transfer_request -> ux_slave_transfer_request_data_pointer; - + /* Store the length in the string buffer. The length of the string descriptor is stored in the third byte, hence the ' + 3'. The encoding must be in 16-bit @@ -491,27 +387,27 @@ ULONG string_length; /* Store the Descriptor type. */ *(string_memory + 1) = UX_STRING_DESCRIPTOR_ITEM; - + /* Create the Unicode string. */ for (string_length = 0; string_length < *(string_framework + 3) ; string_length ++) { - + /* Insert a Unicode byte. */ *(string_memory + 2 + (string_length * 2)) = *(string_framework + 4 + string_length); /* Insert a zero after the Unicode byte. */ *(string_memory + 2 + (string_length * 2) + 1) = 0; - } + } /* Filter the length asked/required. */ if (host_length > (UINT)((*(string_framework + 3)*2) + 2)) length = (ULONG)((*(string_framework + 3)*2) + 2); else - length = host_length; - + length = host_length; + /* We can return the string descriptor. */ status = _ux_device_stack_transfer_request(transfer_request, length, host_length); - break; + break; } } @@ -527,7 +423,7 @@ ULONG string_length; /* Could not find the required string index. Stall the endpoint. */ dcd -> ux_slave_dcd_function(dcd, UX_DCD_STALL_ENDPOINT, endpoint); return(UX_ERROR); - } + } } break; diff --git a/common/core/src/ux_device_stack_disconnect.c b/common/core/src/ux_device_stack_disconnect.c index bb2586d..eac6fc0 100644 --- a/common/core/src/ux_device_stack_disconnect.c +++ b/common/core/src/ux_device_stack_disconnect.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_disconnect PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_disconnect PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_disconnect(VOID) @@ -77,7 +81,9 @@ UINT _ux_device_stack_disconnect(VOID) UX_SLAVE_DCD *dcd; UX_SLAVE_DEVICE *device; UX_SLAVE_INTERFACE *interface; +#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_COMMAND class_command; UINT status = UX_ERROR; @@ -101,9 +107,11 @@ UINT status = UX_ERROR; /* Get the pointer to the first interface. */ interface = 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) { +#endif /* Build all the fields of the Class Command. */ class_command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_DEACTIVATE; @@ -121,15 +129,19 @@ UINT status = UX_ERROR; /* Call the class with the DEACTIVATE signal. */ class -> 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; +#endif /* Remove the interface and all endpoints associated with it. */ _ux_device_stack_interface_delete(interface); +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 /* Now we refresh the interface pointer. */ interface = next_interface; } +#endif /* Mark the device as attached now. */ device -> ux_slave_device_state = UX_DEVICE_ATTACHED; diff --git a/common/core/src/ux_device_stack_endpoint_stall.c b/common/core/src/ux_device_stack_endpoint_stall.c index 53127aa..6b7ad50 100644 --- a/common/core/src/ux_device_stack_endpoint_stall.c +++ b/common/core/src/ux_device_stack_endpoint_stall.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_endpoint_stall PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_endpoint_stall PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,12 +65,17 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_endpoint_stall(UX_SLAVE_ENDPOINT *endpoint) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA UX_SLAVE_DCD *dcd; UINT status; @@ -87,7 +92,7 @@ UINT status; /* Ensure we don't change the endpoint's state after disconnection routine resets it. */ - TX_DISABLE + UX_DISABLE /* Check if the device is in a valid state; as soon as the device is out of the RESET state, transfers occur and thus endpoints may be stalled. */ @@ -102,7 +107,7 @@ UINT status; } /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE /* Return completion status. */ return(status); diff --git a/common/core/src/ux_device_stack_get_status.c b/common/core/src/ux_device_stack_get_status.c index 1a14d9e..8eb364d 100644 --- a/common/core/src/ux_device_stack_get_status.c +++ b/common/core/src/ux_device_stack_get_status.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_stack_get_status PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_get_status(ULONG request_type, ULONG request_index, ULONG request_length) diff --git a/common/core/src/ux_device_stack_host_wakeup.c b/common/core/src/ux_device_stack_host_wakeup.c index b10d85e..60ed3f6 100644 --- a/common/core/src/ux_device_stack_host_wakeup.c +++ b/common/core/src/ux_device_stack_host_wakeup.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_host_wakeup PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_host_wakeup PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_host_wakeup(VOID) diff --git a/common/core/src/ux_device_stack_initialize.c b/common/core/src/ux_device_stack_initialize.c index 4b9ca52..15e3eb3 100644 --- a/common/core/src/ux_device_stack_initialize.c +++ b/common/core/src/ux_device_stack_initialize.c @@ -47,10 +47,10 @@ UX_SYSTEM_SLAVE *_ux_system_slave; /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_initialize PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_initialize PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -93,6 +93,10 @@ UX_SYSTEM_SLAVE *_ux_system_slave; /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_initialize(UCHAR * device_framework_high_speed, ULONG device_framework_length_high_speed, @@ -107,14 +111,17 @@ UX_SLAVE_INTERFACE *interfaces_pool; UX_SLAVE_TRANSFER *transfer_request; UINT status; ULONG interfaces_found; -ULONG local_interfaces_found; ULONG endpoints_found; +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) +ULONG max_interface_number; +ULONG local_interfaces_found; ULONG local_endpoints_found; ULONG endpoints_in_interface_found; UCHAR *device_framework; ULONG device_framework_length; UCHAR descriptor_type; ULONG descriptor_length; +#endif UCHAR *memory; /* If trace is enabled, insert this event into the trace buffer. */ @@ -140,7 +147,7 @@ UCHAR *memory; _ux_system_slave -> ux_system_slave_language_id_framework_length = language_id_framework_length; /* Store the max number of slave class drivers in the project structure. */ - _ux_system_slave -> ux_system_slave_max_class = UX_MAX_SLAVE_CLASS_DRIVER; + UX_SYSTEM_DEVICE_MAX_CLASS_SET(UX_MAX_SLAVE_CLASS_DRIVER); /* Store the device state change function callback. */ _ux_system_slave -> ux_system_slave_change_function = ux_system_slave_change_function; @@ -169,10 +176,18 @@ UCHAR *memory; status = UX_MEMORY_INSUFFICIENT; else status = UX_SUCCESS; - + +#if defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) + + /* No scan, just assign predefined value. */ + interfaces_found = UX_MAX_SLAVE_INTERFACES; + endpoints_found = UX_MAX_DEVICE_ENDPOINTS; +#else + /* Reset all values we are using during the scanning of the framework. */ interfaces_found = 0; endpoints_found = 0; + max_interface_number = 0; /* Go on to scan interfaces if no error. */ if (status == UX_SUCCESS) @@ -229,6 +244,10 @@ UCHAR *memory; endpoints_in_interface_found = (ULONG) *(device_framework + 4); } + /* Check and update max interface number. */ + if (*(device_framework + 2) > max_interface_number) + max_interface_number = *(device_framework + 2); + break; case UX_CONFIGURATION_DESCRIPTOR_ITEM: @@ -297,9 +316,24 @@ UCHAR *memory; status = UX_DESCRIPTOR_CORRUPTED; } + + /* We do a sanity check on the finding. Max interface number should not exceed limit. */ + if (status == UX_SUCCESS && + max_interface_number >= UX_MAX_SLAVE_INTERFACES) + { + + /* Error trap. */ + _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_INIT, UX_MEMORY_INSUFFICIENT); + + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MEMORY_INSUFFICIENT, device_framework, 0, 0, UX_TRACE_ERRORS, 0, 0) + + status = UX_MEMORY_INSUFFICIENT; + } } +#endif - /* Go on to allocate endpoints pool if no error. */ + /* Go on to allocate interfaces pool if no error. */ if (status == UX_SUCCESS) { diff --git a/common/core/src/ux_device_stack_interface_delete.c b/common/core/src/ux_device_stack_interface_delete.c index 9d8ca4e..3b61df4 100644 --- a/common/core/src/ux_device_stack_interface_delete.c +++ b/common/core/src/ux_device_stack_interface_delete.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_interface_delete PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_interface_delete PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_interface_delete(UX_SLAVE_INTERFACE *interface) diff --git a/common/core/src/ux_device_stack_interface_get.c b/common/core/src/ux_device_stack_interface_get.c index 38b444b..112ac8e 100644 --- a/common/core/src/ux_device_stack_interface_get.c +++ b/common/core/src/ux_device_stack_interface_get.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_interface_get PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_interface_get PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_interface_get(UINT interface_value) @@ -98,10 +102,12 @@ UINT status; /* Get the pointer to the first interface. */ interface = 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) { +#endif /* Check if this is the interface we have an inquiry for. */ if (interface -> ux_slave_interface_descriptor.bInterfaceNumber == interface_value) @@ -127,9 +133,12 @@ UINT status; return(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; } +#endif + } /* The alternate setting value was not found, so we return a stall error. */ diff --git a/common/core/src/ux_device_stack_interface_set.c b/common/core/src/ux_device_stack_interface_set.c index 82bc3fd..8670861 100644 --- a/common/core/src/ux_device_stack_interface_set.c +++ b/common/core/src/ux_device_stack_interface_set.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_interface_set PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_interface_set PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_interface_set(UCHAR * device_framework, ULONG device_framework_length, @@ -82,13 +86,15 @@ UX_SLAVE_DCD *dcd; UX_SLAVE_DEVICE *device; UX_SLAVE_TRANSFER *transfer_request; UX_SLAVE_INTERFACE *interface; +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 UX_SLAVE_INTERFACE *interface_link; +ULONG interfaces_pool_number; +#endif UX_SLAVE_ENDPOINT *endpoint; UX_SLAVE_ENDPOINT *endpoint_link; ULONG descriptor_length; UCHAR descriptor_type; ULONG endpoints_pool_number; -ULONG interfaces_pool_number; UINT status; UX_PARAMETER_NOT_USED(alternate_setting_value); @@ -105,16 +111,14 @@ UINT status; /* Find a free interface in the pool and hook it to the existing interface. */ interface = 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) - { - /* Mark this interface as used now. */ - interface -> ux_slave_interface_status = UX_USED; break; - } /* Try the next interface. */ interface++; @@ -126,6 +130,16 @@ UINT status; /* Did we find a free interface ? */ if (interfaces_pool_number == 0) return(UX_MEMORY_INSUFFICIENT); +#else + + /* Check if this interface is free. */ + if (interface -> ux_slave_interface_status != UX_UNUSED) + return(UX_MEMORY_INSUFFICIENT); + +#endif + + /* Mark this interface as used now. */ + interface -> 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) @@ -136,6 +150,8 @@ UINT status; UX_INTERFACE_DESCRIPTOR_ENTRIES, (UCHAR *) &interface -> ux_slave_interface_descriptor); +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 + /* Attach this interface to the end of the interface chain. */ if (device -> ux_slave_device_first_interface == UX_NULL) { @@ -150,6 +166,11 @@ UINT status; interface_link = interface_link -> ux_slave_interface_next_interface; interface_link -> ux_slave_interface_next_interface = interface; } +#else + + /* It must be very first one. */ + device -> ux_slave_device_first_interface = interface; +#endif /* Point beyond the interface descriptor. */ device_framework_length -= (ULONG) *device_framework; diff --git a/common/core/src/ux_device_stack_interface_start.c b/common/core/src/ux_device_stack_interface_start.c index 98747ef..1b8edc7 100644 --- a/common/core/src/ux_device_stack_interface_start.c +++ b/common/core/src/ux_device_stack_interface_start.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_interface_start PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_interface_start PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_interface_start(UX_SLAVE_INTERFACE *interface) diff --git a/common/core/src/ux_device_stack_microsoft_extension_register.c b/common/core/src/ux_device_stack_microsoft_extension_register.c index 983e535..32d87e9 100644 --- a/common/core/src/ux_device_stack_microsoft_extension_register.c +++ b/common/core/src/ux_device_stack_microsoft_extension_register.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_microsoft_extension_register PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_microsoft_extension_register PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_microsoft_extension_register(ULONG vendor_request, diff --git a/common/core/src/ux_device_stack_set_feature.c b/common/core/src/ux_device_stack_set_feature.c index e8cca96..53f1ba9 100644 --- a/common/core/src/ux_device_stack_set_feature.c +++ b/common/core/src/ux_device_stack_set_feature.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_stack_set_feature PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,11 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, stalled on not */ +/* supported device requests, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_set_feature(ULONG request_type, ULONG request_value, ULONG request_index) @@ -121,25 +126,29 @@ UX_SLAVE_ENDPOINT *endpoint_target; #ifdef UX_OTG_SUPPORT /* Check if we have a A_HNP_SUPPORT Feature. This is set when the Host is HNP capable. */ if (request_value == UX_OTG_FEATURE_A_HNP_SUPPORT) + { /* Store the A_HNP_SUPPORT flag. */ _ux_system_otg -> ux_system_otg_slave_set_feature_flag |= UX_OTG_FEATURE_A_HNP_SUPPORT; - else - { - /* Check if the host asks us to perform HNP. If also we become the host. */ - if (request_value == UX_OTG_FEATURE_B_HNP_ENABLE) - { + /* OK. */ + return(UX_SUCCESS); + } - /* The ISR will pick up the suspend event and check if we need to become IDLE or HOST. */ - _ux_system_otg -> ux_system_otg_slave_set_feature_flag |= UX_OTG_FEATURE_B_HNP_ENABLE; + /* Check if the host asks us to perform HNP. If also we become the host. */ + if (request_value == UX_OTG_FEATURE_B_HNP_ENABLE) + { - } + /* The ISR will pick up the suspend event and check if we need to become IDLE or HOST. */ + _ux_system_otg -> ux_system_otg_slave_set_feature_flag |= UX_OTG_FEATURE_B_HNP_ENABLE; + /* OK. */ + return(UX_SUCCESS); } #endif - - break; + + /* Request value not supported. */ + return(UX_FUNCTION_NOT_SUPPORTED); case UX_REQUEST_TARGET_ENDPOINT: @@ -148,9 +157,10 @@ UX_SLAVE_ENDPOINT *endpoint_target; We need to find the endpoint through the interface(s). */ interface = device -> ux_slave_device_first_interface; +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 while (interface != UX_NULL) { - +#endif /* Get the first endpoint for this interface. */ endpoint_target = interface -> ux_slave_interface_first_endpoint; @@ -173,9 +183,11 @@ UX_SLAVE_ENDPOINT *endpoint_target; endpoint_target = endpoint_target -> ux_slave_endpoint_next_endpoint; } +#if !defined(UX_DEVICE_INITIALIZE_FRAMEWORK_SCAN_DISABLE) || UX_MAX_DEVICE_INTERFACES > 1 /* Next interface. */ interface = interface -> ux_slave_interface_next_interface; } +#endif /* We get here when the endpoint is wrong. Should not happen though. */ /* Intentionally fall through into the default case. */ @@ -188,8 +200,4 @@ UX_SLAVE_ENDPOINT *endpoint_target; /* No more work to do here. The command failed but the upper layer does not depend on it. */ return(UX_SUCCESS); } - - /* Return the function status. */ - return(UX_SUCCESS); } - diff --git a/common/core/src/ux_device_stack_transfer_abort.c b/common/core/src/ux_device_stack_transfer_abort.c index 49a58d9..9b17b5a 100644 --- a/common/core/src/ux_device_stack_transfer_abort.c +++ b/common/core/src/ux_device_stack_transfer_abort.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_transfer_abort PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_transfer_abort PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,12 +71,17 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_transfer_abort(UX_SLAVE_TRANSFER *transfer_request, ULONG completion_code) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA UX_SLAVE_DCD *dcd; @@ -92,7 +97,7 @@ UX_SLAVE_DCD *dcd; transfer_request -> ux_slave_transfer_request_completion_code = UX_TRANSFER_BUS_RESET; /* Ensure we're not preempted by the transfer completion ISR. */ - TX_DISABLE + UX_DISABLE /* It's possible the transfer already completed. Ensure it hasn't before doing the abort. */ if (transfer_request -> ux_slave_transfer_request_status == UX_TRANSFER_STATUS_PENDING) @@ -102,7 +107,7 @@ UX_SLAVE_DCD *dcd; dcd -> ux_slave_dcd_function(dcd, UX_DCD_TRANSFER_ABORT, (VOID *) transfer_request); /* Restore interrupts. Note that the transfer request should not be modified now. */ - TX_RESTORE + UX_RESTORE /* We need to set the completion code for the transfer to aborted. Note that the transfer request function cannot simultaneously modify this @@ -117,7 +122,7 @@ UX_SLAVE_DCD *dcd; { /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE } /* This function never fails. */ diff --git a/common/core/src/ux_device_stack_transfer_all_request_abort.c b/common/core/src/ux_device_stack_transfer_all_request_abort.c index 48c7d3f..2837a40 100644 --- a/common/core/src/ux_device_stack_transfer_all_request_abort.c +++ b/common/core/src/ux_device_stack_transfer_all_request_abort.c @@ -31,10 +31,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_transfer_all_request_abort PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_transfer_all_request_abort PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_transfer_all_request_abort(UX_SLAVE_ENDPOINT *endpoint, ULONG completion_code) diff --git a/common/core/src/ux_device_stack_transfer_request.c b/common/core/src/ux_device_stack_transfer_request.c index 20f3aa9..08e2353 100644 --- a/common/core/src/ux_device_stack_transfer_request.c +++ b/common/core/src/ux_device_stack_transfer_request.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_stack_transfer_request PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +71,11 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_transfer_request(UX_SLAVE_TRANSFER *transfer_request, @@ -78,7 +83,7 @@ UINT _ux_device_stack_transfer_request(UX_SLAVE_TRANSFER *transfer_request, ULONG host_length) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA UX_SLAVE_DCD *dcd; UINT status; @@ -92,7 +97,7 @@ ULONG device_state; /* Disable interrupts to prevent the disconnection ISR from preempting us while we check the device state and set the transfer status. */ - TX_DISABLE + UX_DISABLE /* Get the device state. */ device_state = _ux_system_slave -> ux_system_slave_device.ux_slave_device_state; @@ -108,12 +113,12 @@ ULONG device_state; { /* The device is in an invalid state. Restore interrupts and return error. */ - TX_RESTORE + UX_RESTORE return(UX_TRANSFER_NOT_READY); } /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_TRANSFER_REQUEST, transfer_request, 0, 0, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0) diff --git a/common/core/src/ux_device_stack_uninitialize.c b/common/core/src/ux_device_stack_uninitialize.c index 7a1c63e..71258ee 100644 --- a/common/core/src/ux_device_stack_uninitialize.c +++ b/common/core/src/ux_device_stack_uninitialize.c @@ -30,10 +30,10 @@ /**************************************************************************/ /* */ -/* FUNCTION RELEASE */ +/* FUNCTION RELEASE */ /* */ -/* _ux_device_stack_uninitialize PORTABLE C */ -/* 6.0 */ +/* _ux_device_stack_uninitialize PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,6 +63,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_device_stack_uninitialize(VOID) diff --git a/common/core/src/ux_hcd_sim_host_asynch_queue_process.c b/common/core/src/ux_hcd_sim_host_asynch_queue_process.c index d771e9e..eb4a458 100644 --- a/common/core/src/ux_hcd_sim_host_asynch_queue_process.c +++ b/common/core/src/ux_hcd_sim_host_asynch_queue_process.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_asynch_queue_process PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_asynch_queue_process(UX_HCD_SIM_HOST *hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_asynch_schedule.c b/common/core/src/ux_hcd_sim_host_asynch_schedule.c index a0cefc4..1e78487 100644 --- a/common/core/src/ux_hcd_sim_host_asynch_schedule.c +++ b/common/core/src/ux_hcd_sim_host_asynch_schedule.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_asynch_schedule PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_asynch_schedule(UX_HCD_SIM_HOST *hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_create.c b/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_create.c index 0cb523f..48bee36 100644 --- a/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_create.c +++ b/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_asynchronous_endpoint_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_asynchronous_endpoint_create(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint) diff --git a/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_destroy.c b/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_destroy.c index 71bbda2..c09aff5 100644 --- a/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_destroy.c +++ b/common/core/src/ux_hcd_sim_host_asynchronous_endpoint_destroy.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_asynchronous_endpoint_destroy PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_asynchronous_endpoint_destroy(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint) diff --git a/common/core/src/ux_hcd_sim_host_controller_disable.c b/common/core/src/ux_hcd_sim_host_controller_disable.c new file mode 100644 index 0000000..2109e9e --- /dev/null +++ b/common/core/src/ux_hcd_sim_host_controller_disable.c @@ -0,0 +1,98 @@ +/**************************************************************************/ +/* */ +/* 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 */ +/** */ +/** Host Simulator Controller Driver */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + +#define UX_SOURCE_CODE + + +/* Include necessary system files. */ + +#include "ux_api.h" +#include "ux_hcd_sim_host.h" + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_hcd_sim_host_controller_disable PORTABLE C */ +/* 6.1 */ +/* AUTHOR */ +/* */ +/* Chaoqiong Xiao, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function will disable the simulated host controller. */ +/* The controller will release all its resources (memory, IO ...). */ +/* After this, the controller will not send SOF any longer. */ +/* */ +/* INPUT */ +/* */ +/* hcd_sim_host Pointer to host controller */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* */ +/* CALLS */ +/* */ +/* _ux_utility_memory_free Free memory block */ +/* _ux_utility_timer_delete Delete timer */ +/* */ +/* CALLED BY */ +/* */ +/* Host Simulator Controller Driver */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 09-30-2020 Chaoqiong Xiao Initial Version 6.1 */ +/* */ +/**************************************************************************/ +UINT _ux_hcd_sim_host_controller_disable(UX_HCD_SIM_HOST *hcd_sim_host) +{ + +UX_HCD *hcd = hcd_sim_host -> ux_hcd_sim_host_hcd_owner; + + + /* Set the state of the controller to HALTED first. */ + hcd -> ux_hcd_status = UX_HCD_STATUS_HALTED; + + /* Get simulated host controller. */ + hcd_sim_host = (UX_HCD_SIM_HOST *)hcd -> ux_hcd_controller_hardware; + + /* Delete timer. */ + _ux_utility_timer_delete(&hcd_sim_host -> ux_hcd_sim_host_timer); + + /* Free TD/ED memories. */ + _ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_iso_td_list); + _ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_td_list); + _ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_ed_list); + + /* Free simulated host controller memory. */ + _ux_utility_memory_free(hcd_sim_host); + hcd -> ux_hcd_controller_hardware = UX_NULL; + + /* Return successful completion. */ + return(UX_SUCCESS); +} diff --git a/common/core/src/ux_hcd_sim_host_ed_obtain.c b/common/core/src/ux_hcd_sim_host_ed_obtain.c index 1045bd5..3615186 100644 --- a/common/core/src/ux_hcd_sim_host_ed_obtain.c +++ b/common/core/src/ux_hcd_sim_host_ed_obtain.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_ed_obtain PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UX_HCD_SIM_HOST_ED *_ux_hcd_sim_host_ed_obtain(UX_HCD_SIM_HOST *hcd_sim_host) @@ -83,7 +87,7 @@ ULONG ed_index; { /* The ED may have been used, so we reset all fields. */ - _ux_utility_memory_set(ed, 0, sizeof(UX_HCD_SIM_HOST_ED)); + _ux_utility_memory_set(ed, 0, sizeof(UX_HCD_SIM_HOST_ED)); /* Use case of memset is verified. */ /* This ED is now marked as USED. */ ed -> ux_sim_host_ed_status = UX_USED; diff --git a/common/core/src/ux_hcd_sim_host_ed_td_clean.c b/common/core/src/ux_hcd_sim_host_ed_td_clean.c index 658c616..3e574d4 100644 --- a/common/core/src/ux_hcd_sim_host_ed_td_clean.c +++ b/common/core/src/ux_hcd_sim_host_ed_td_clean.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_ed_td_clean PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_ed_td_clean(UX_HCD_SIM_HOST_ED *ed) diff --git a/common/core/src/ux_hcd_sim_host_endpoint_reset.c b/common/core/src/ux_hcd_sim_host_endpoint_reset.c index 49eed9e..20e1ec8 100644 --- a/common/core/src/ux_hcd_sim_host_endpoint_reset.c +++ b/common/core/src/ux_hcd_sim_host_endpoint_reset.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_endpoint_reset PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_endpoint_reset(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint) diff --git a/common/core/src/ux_hcd_sim_host_entry.c b/common/core/src/ux_hcd_sim_host_entry.c index 02cce35..f9872db 100644 --- a/common/core/src/ux_hcd_sim_host_entry.c +++ b/common/core/src/ux_hcd_sim_host_entry.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_entry PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -82,6 +82,9 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* added controller disable, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_entry(UX_HCD *hcd, UINT function, VOID *parameter) @@ -113,7 +116,7 @@ UX_HCD_SIM_HOST *hcd_sim_host; case UX_HCD_DISABLE_CONTROLLER: - status = UX_SUCCESS; + status = _ux_hcd_sim_host_controller_disable(hcd_sim_host); break; diff --git a/common/core/src/ux_hcd_sim_host_frame_number_get.c b/common/core/src/ux_hcd_sim_host_frame_number_get.c index 2b90a2d..93a4c25 100644 --- a/common/core/src/ux_hcd_sim_host_frame_number_get.c +++ b/common/core/src/ux_hcd_sim_host_frame_number_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_frame_number_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_frame_number_get(UX_HCD_SIM_HOST *hcd_sim_host, ULONG *frame_number) diff --git a/common/core/src/ux_hcd_sim_host_frame_number_set.c b/common/core/src/ux_hcd_sim_host_frame_number_set.c index e593b74..fd07a5d 100644 --- a/common/core/src/ux_hcd_sim_host_frame_number_set.c +++ b/common/core/src/ux_hcd_sim_host_frame_number_set.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_frame_number_set PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_frame_number_set(UX_HCD_SIM_HOST *hcd_sim_host, ULONG frame_number) diff --git a/common/core/src/ux_hcd_sim_host_initialize.c b/common/core/src/ux_hcd_sim_host_initialize.c index 5d83260..c385e75 100644 --- a/common/core/src/ux_hcd_sim_host_initialize.c +++ b/common/core/src/ux_hcd_sim_host_initialize.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_initialize PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,13 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, used UX prefix */ +/* to refer to TX symbols */ +/* instead of using them */ +/* directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_initialize(UX_HCD *hcd) @@ -92,10 +99,12 @@ UINT status; /* Initialize the function collector for this HCD. */ hcd -> ux_hcd_entry_function = _ux_hcd_sim_host_entry; - + +#if UX_MAX_DEVICES > 1 /* Initialize the max bandwidth for periodic endpoints. In simulation this is not very important. */ hcd -> ux_hcd_available_bandwidth = UX_HCD_SIM_HOST_AVAILABLE_BANDWIDTH; +#endif /* Set the state of the controller to HALTED first. */ hcd -> ux_hcd_status = UX_HCD_STATUS_HALTED; @@ -141,7 +150,7 @@ UINT status; /* We start a timer that will invoke the simulator every timer tick. */ status = _ux_utility_timer_create(&hcd_sim_host -> ux_hcd_sim_host_timer, "USBX Simulation Timer", - _ux_hcd_sim_host_timer_function, (ULONG) (ALIGN_TYPE) hcd_sim_host, 1, 1, TX_AUTO_ACTIVATE); + _ux_hcd_sim_host_timer_function, (ULONG) (ALIGN_TYPE) hcd_sim_host, 1, 1, UX_AUTO_ACTIVATE); } UX_TIMER_EXTENSION_PTR_SET(&(hcd_sim_host -> ux_hcd_sim_host_timer), hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_interrupt_endpoint_create.c b/common/core/src/ux_hcd_sim_host_interrupt_endpoint_create.c index a42fa8d..daa6811 100644 --- a/common/core/src/ux_hcd_sim_host_interrupt_endpoint_create.c +++ b/common/core/src/ux_hcd_sim_host_interrupt_endpoint_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_interrupt_endpoint_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -86,6 +86,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_interrupt_endpoint_create(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint) diff --git a/common/core/src/ux_hcd_sim_host_iso_queue_process.c b/common/core/src/ux_hcd_sim_host_iso_queue_process.c index 7b88faa..33a00b1 100644 --- a/common/core/src/ux_hcd_sim_host_iso_queue_process.c +++ b/common/core/src/ux_hcd_sim_host_iso_queue_process.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_iso_queue_process PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_iso_queue_process(UX_HCD_SIM_HOST *hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_iso_schedule.c b/common/core/src/ux_hcd_sim_host_iso_schedule.c index f4206b5..1069aca 100644 --- a/common/core/src/ux_hcd_sim_host_iso_schedule.c +++ b/common/core/src/ux_hcd_sim_host_iso_schedule.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_iso_schedule PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_iso_schedule(UX_HCD_SIM_HOST *hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_isochronous_endpoint_create.c b/common/core/src/ux_hcd_sim_host_isochronous_endpoint_create.c index ef7f738..196b7cb 100644 --- a/common/core/src/ux_hcd_sim_host_isochronous_endpoint_create.c +++ b/common/core/src/ux_hcd_sim_host_isochronous_endpoint_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_isochronous_endpoint_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_isochronous_endpoint_create(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint) diff --git a/common/core/src/ux_hcd_sim_host_isochronous_td_obtain.c b/common/core/src/ux_hcd_sim_host_isochronous_td_obtain.c index fbd44b0..571f4fb 100644 --- a/common/core/src/ux_hcd_sim_host_isochronous_td_obtain.c +++ b/common/core/src/ux_hcd_sim_host_isochronous_td_obtain.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_isochronous_td_obtain PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UX_HCD_SIM_HOST_ISO_TD *_ux_hcd_sim_host_isochronous_td_obtain(UX_HCD_SIM_HOST *hcd_sim_host) @@ -83,7 +87,7 @@ ULONG td_index; { /* The TD may have been used, so we reset all fields. */ - _ux_utility_memory_set(td, 0, sizeof(UX_HCD_SIM_HOST_ISO_TD)); + _ux_utility_memory_set(td, 0, sizeof(UX_HCD_SIM_HOST_ISO_TD)); /* Use case of memset is verified. */ /* This TD is now marked as USED. */ td -> ux_sim_host_iso_td_status = UX_USED; diff --git a/common/core/src/ux_hcd_sim_host_least_traffic_list_get.c b/common/core/src/ux_hcd_sim_host_least_traffic_list_get.c index 24982b4..3573f7f 100644 --- a/common/core/src/ux_hcd_sim_host_least_traffic_list_get.c +++ b/common/core/src/ux_hcd_sim_host_least_traffic_list_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_least_traffic_list_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UX_HCD_SIM_HOST_ED *_ux_hcd_sim_host_least_traffic_list_get(UX_HCD_SIM_HOST *hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_periodic_endpoint_destroy.c b/common/core/src/ux_hcd_sim_host_periodic_endpoint_destroy.c index 2ae407c..03dbd12 100644 --- a/common/core/src/ux_hcd_sim_host_periodic_endpoint_destroy.c +++ b/common/core/src/ux_hcd_sim_host_periodic_endpoint_destroy.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_periodic_endpoint_destroy PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_periodic_endpoint_destroy(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint) diff --git a/common/core/src/ux_hcd_sim_host_periodic_schedule.c b/common/core/src/ux_hcd_sim_host_periodic_schedule.c index 1a6c3e2..9b5c579 100644 --- a/common/core/src/ux_hcd_sim_host_periodic_schedule.c +++ b/common/core/src/ux_hcd_sim_host_periodic_schedule.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_periodic_schedule PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_periodic_schedule(UX_HCD_SIM_HOST *hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_periodic_tree_create.c b/common/core/src/ux_hcd_sim_host_periodic_tree_create.c index 87669a6..ff9491c 100644 --- a/common/core/src/ux_hcd_sim_host_periodic_tree_create.c +++ b/common/core/src/ux_hcd_sim_host_periodic_tree_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_periodic_tree_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_periodic_tree_create(UX_HCD_SIM_HOST *hcd_sim_host) diff --git a/common/core/src/ux_hcd_sim_host_port_reset.c b/common/core/src/ux_hcd_sim_host_port_reset.c index 6974740..8be6740 100644 --- a/common/core/src/ux_hcd_sim_host_port_reset.c +++ b/common/core/src/ux_hcd_sim_host_port_reset.c @@ -36,7 +36,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_port_reset PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_port_reset(UX_HCD_SIM_HOST *hcd_sim_host, ULONG port_index) diff --git a/common/core/src/ux_hcd_sim_host_port_status_get.c b/common/core/src/ux_hcd_sim_host_port_status_get.c index 50555f3..8c32526 100644 --- a/common/core/src/ux_hcd_sim_host_port_status_get.c +++ b/common/core/src/ux_hcd_sim_host_port_status_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_port_status_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -91,6 +91,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_hcd_sim_host_port_status_get(UX_HCD_SIM_HOST *hcd_sim_host, ULONG port_index) diff --git a/common/core/src/ux_hcd_sim_host_regular_td_obtain.c b/common/core/src/ux_hcd_sim_host_regular_td_obtain.c index ade397e..f3973ef 100644 --- a/common/core/src/ux_hcd_sim_host_regular_td_obtain.c +++ b/common/core/src/ux_hcd_sim_host_regular_td_obtain.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_regular_td_obtain PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UX_HCD_SIM_HOST_TD *_ux_hcd_sim_host_regular_td_obtain(UX_HCD_SIM_HOST *hcd_sim_host) @@ -89,7 +93,7 @@ ULONG td_index; { /* The TD may have been used, so we reset all fields. */ - _ux_utility_memory_set(td, 0, sizeof(UX_HCD_SIM_HOST_TD)); + _ux_utility_memory_set(td, 0, sizeof(UX_HCD_SIM_HOST_TD)); /* Use case of memset is verified. */ /* This TD is now marked as USED. */ td -> ux_sim_host_td_status = UX_USED; diff --git a/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c b/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c index 28c72aa..4036ba3 100644 --- a/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c +++ b/common/core/src/ux_hcd_sim_host_request_bulk_transfer.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_request_bulk_transfer PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_request_bulk_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request) diff --git a/common/core/src/ux_hcd_sim_host_request_control_transfer.c b/common/core/src/ux_hcd_sim_host_request_control_transfer.c index 9e0a2e0..f1d8de1 100644 --- a/common/core/src/ux_hcd_sim_host_request_control_transfer.c +++ b/common/core/src/ux_hcd_sim_host_request_control_transfer.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_request_control_transfer PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,6 +74,9 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* prefixed UX to MS_TO_TICK, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_request_control_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request) @@ -292,7 +295,7 @@ UCHAR *data_pointer; hcd_sim_host -> ux_hcd_sim_host_queue_empty = UX_FALSE; /* Wait for the completion of the transfer request. */ - status = _ux_utility_semaphore_get(&transfer_request -> ux_transfer_request_semaphore, MS_TO_TICK(UX_CONTROL_TRANSFER_TIMEOUT)); + status = _ux_utility_semaphore_get(&transfer_request -> ux_transfer_request_semaphore, UX_MS_TO_TICK(UX_CONTROL_TRANSFER_TIMEOUT)); /* If the semaphore did not succeed we probably have a time out. */ if (status != UX_SUCCESS) diff --git a/common/core/src/ux_hcd_sim_host_request_interupt_transfer.c b/common/core/src/ux_hcd_sim_host_request_interupt_transfer.c index 02ab430..71cf33a 100644 --- a/common/core/src/ux_hcd_sim_host_request_interupt_transfer.c +++ b/common/core/src/ux_hcd_sim_host_request_interupt_transfer.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_request_interrupt_transfer PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_request_interrupt_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request) diff --git a/common/core/src/ux_hcd_sim_host_request_isochronous_transfer.c b/common/core/src/ux_hcd_sim_host_request_isochronous_transfer.c index fd037ce..d48b0d7 100644 --- a/common/core/src/ux_hcd_sim_host_request_isochronous_transfer.c +++ b/common/core/src/ux_hcd_sim_host_request_isochronous_transfer.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_request_isochronous_transfer PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_request_isochronous_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request) diff --git a/common/core/src/ux_hcd_sim_host_request_transfer.c b/common/core/src/ux_hcd_sim_host_request_transfer.c index 827856b..b422e2d 100644 --- a/common/core/src/ux_hcd_sim_host_request_transfer.c +++ b/common/core/src/ux_hcd_sim_host_request_transfer.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_request_transfer PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -75,6 +75,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_request_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request) diff --git a/common/core/src/ux_hcd_sim_host_timer_function.c b/common/core/src/ux_hcd_sim_host_timer_function.c index f65e0c0..673fbe0 100644 --- a/common/core/src/ux_hcd_sim_host_timer_function.c +++ b/common/core/src/ux_hcd_sim_host_timer_function.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_timer_function PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_hcd_sim_host_timer_function(ULONG hcd_sim_host_addr) diff --git a/common/core/src/ux_hcd_sim_host_transaction_schedule.c b/common/core/src/ux_hcd_sim_host_transaction_schedule.c index af75c68..58e6127 100644 --- a/common/core/src/ux_hcd_sim_host_transaction_schedule.c +++ b/common/core/src/ux_hcd_sim_host_transaction_schedule.c @@ -36,7 +36,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_transaction_schedule PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,6 +73,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_transaction_schedule(UX_HCD_SIM_HOST *hcd_sim_host, UX_HCD_SIM_HOST_ED *ed) @@ -152,7 +156,7 @@ UX_SLAVE_DCD *dcd; /* Move the buffer from the host TD to the device TD. */ _ux_utility_memory_copy(slave_transfer_request -> ux_slave_transfer_request_setup, td -> ux_sim_host_td_buffer, - td -> ux_sim_host_td_length); + td -> ux_sim_host_td_length); /* Use case of memcpy is verified. */ /* The setup phase never fails. We acknowledge the transfer code here by taking the TD out of the endpoint. */ ed -> ux_sim_host_ed_head_td = td -> ux_sim_host_td_next_td; @@ -173,6 +177,10 @@ UX_SLAVE_DCD *dcd; /* Get the length we expect from the SETUP packet. */ slave_transfer_request -> ux_slave_transfer_request_requested_length = _ux_utility_short_get(slave_transfer_request -> ux_slave_transfer_request_setup + 6); + /* Avoid buffer overflow. */ + if (slave_transfer_request -> ux_slave_transfer_request_requested_length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) + 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; @@ -195,7 +203,7 @@ UX_SLAVE_DCD *dcd; /* Copy the amount of data in the td into the slave transaction buffer. */ _ux_utility_memory_copy(slave_transfer_request -> ux_slave_transfer_request_current_data_pointer, data_td -> ux_sim_host_td_buffer, - data_td -> ux_sim_host_td_length); + data_td -> ux_sim_host_td_length); /* Use case of memcpy is verified. */ /* Add to the actual payload length. */ slave_transfer_request -> ux_slave_transfer_request_actual_length += data_td -> ux_sim_host_td_length; @@ -363,13 +371,13 @@ UX_SLAVE_DCD *dcd; /* 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); + transaction_length); /* Use case of memcpy is verified. */ 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); + transaction_length); /* Use case of memcpy is verified. */ /* Update buffers. */ td -> ux_sim_host_td_buffer += transaction_length; diff --git a/common/core/src/ux_hcd_sim_host_transfer_abort.c b/common/core/src/ux_hcd_sim_host_transfer_abort.c index a205018..c7dfbd2 100644 --- a/common/core/src/ux_hcd_sim_host_transfer_abort.c +++ b/common/core/src/ux_hcd_sim_host_transfer_abort.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_transfer_abort PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_transfer_abort(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request) diff --git a/common/core/src/ux_host_class_dpump_activate.c b/common/core/src/ux_host_class_dpump_activate.c index 1a69150..c9b4863 100644 --- a/common/core/src/ux_host_class_dpump_activate.c +++ b/common/core/src/ux_host_class_dpump_activate.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_activate PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,6 +70,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_activate(UX_HOST_CLASS_COMMAND *command) diff --git a/common/core/src/ux_host_class_dpump_configure.c b/common/core/src/ux_host_class_dpump_configure.c index 5b3867d..bc276e4 100644 --- a/common/core/src/ux_host_class_dpump_configure.c +++ b/common/core/src/ux_host_class_dpump_configure.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_configure PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_configure(UX_HOST_CLASS_DPUMP *dpump) @@ -76,7 +80,9 @@ UINT _ux_host_class_dpump_configure(UX_HOST_CLASS_DPUMP *dpump) UINT status; UX_CONFIGURATION *configuration; +#if UX_MAX_DEVICES > 1 UX_DEVICE *parent_device; +#endif /* If the device has been configured already, we don't need to do it @@ -98,7 +104,8 @@ UX_DEVICE *parent_device; return(UX_CONFIGURATION_HANDLE_UNKNOWN); } - + +#if UX_MAX_DEVICES > 1 /* Check the dpump power source and check the parent power source for incompatible connections. */ if (dpump -> ux_host_class_dpump_device -> ux_device_power_source == UX_DEVICE_BUS_POWERED) @@ -118,6 +125,7 @@ UX_DEVICE *parent_device; return(UX_CONNECTION_INCOMPATIBLE); } } +#endif /* We have the valid configuration. Ask the USBX stack to set this configuration. */ status = _ux_host_stack_device_configuration_select(configuration); diff --git a/common/core/src/ux_host_class_dpump_deactivate.c b/common/core/src/ux_host_class_dpump_deactivate.c index 3fab273..23426c3 100644 --- a/common/core/src/ux_host_class_dpump_deactivate.c +++ b/common/core/src/ux_host_class_dpump_deactivate.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_deactivate PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_deactivate(UX_HOST_CLASS_COMMAND *command) diff --git a/common/core/src/ux_host_class_dpump_endpoints_get.c b/common/core/src/ux_host_class_dpump_endpoints_get.c index 466c423..453e481 100644 --- a/common/core/src/ux_host_class_dpump_endpoints_get.c +++ b/common/core/src/ux_host_class_dpump_endpoints_get.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_endpoints_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_endpoints_get(UX_HOST_CLASS_DPUMP *dpump) diff --git a/common/core/src/ux_host_class_dpump_entry.c b/common/core/src/ux_host_class_dpump_entry.c index 6be5385..58bfaf1 100644 --- a/common/core/src/ux_host_class_dpump_entry.c +++ b/common/core/src/ux_host_class_dpump_entry.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_entry PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_entry(UX_HOST_CLASS_COMMAND *command) diff --git a/common/core/src/ux_host_class_dpump_ioctl.c b/common/core/src/ux_host_class_dpump_ioctl.c index 7e197ea..acc728d 100644 --- a/common/core/src/ux_host_class_dpump_ioctl.c +++ b/common/core/src/ux_host_class_dpump_ioctl.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_ioctl PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_ioctl(UX_HOST_CLASS_DPUMP *dpump, ULONG ioctl_function, diff --git a/common/core/src/ux_host_class_dpump_read.c b/common/core/src/ux_host_class_dpump_read.c index 363eb0b..806b801 100644 --- a/common/core/src/ux_host_class_dpump_read.c +++ b/common/core/src/ux_host_class_dpump_read.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_read PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,6 +74,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_read(UX_HOST_CLASS_DPUMP *dpump, UCHAR *data_pointer, diff --git a/common/core/src/ux_host_class_dpump_write.c b/common/core/src/ux_host_class_dpump_write.c index ceba568..d1a714b 100644 --- a/common/core/src/ux_host_class_dpump_write.c +++ b/common/core/src/ux_host_class_dpump_write.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_dpump_write PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,6 +74,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_class_dpump_write(UX_HOST_CLASS_DPUMP *dpump, UCHAR * data_pointer, diff --git a/common/core/src/ux_host_stack_bandwidth_check.c b/common/core/src/ux_host_stack_bandwidth_check.c index aa2e6c9..fab117a 100644 --- a/common/core/src/ux_host_stack_bandwidth_check.c +++ b/common/core/src/ux_host_stack_bandwidth_check.c @@ -29,12 +29,13 @@ #include "ux_host_stack.h" +#if UX_MAX_DEVICES > 1 /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_bandwidth_check PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -75,6 +76,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_bandwidth_check(UX_HCD *hcd, UX_ENDPOINT *endpoint) @@ -267,4 +272,4 @@ const UCHAR overheads[4][3] = { /* We get here when we have not found a 2.0 hub in the list and we got to the root port. */ return(UX_SUCCESS); } - +#endif /* #if UX_MAX_DEVICES > 1 */ diff --git a/common/core/src/ux_host_stack_bandwidth_claim.c b/common/core/src/ux_host_stack_bandwidth_claim.c index 1227bc4..5001d80 100644 --- a/common/core/src/ux_host_stack_bandwidth_claim.c +++ b/common/core/src/ux_host_stack_bandwidth_claim.c @@ -29,12 +29,13 @@ #include "ux_host_stack.h" +#if UX_MAX_DEVICES > 1 /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_bandwidth_claim PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,6 +75,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_bandwidth_claim(UX_HCD *hcd, UX_ENDPOINT *endpoint) @@ -242,3 +247,4 @@ const UCHAR overheads[4][3] = { to the root port. */ return; } +#endif /* #if UX_MAX_DEVICES > 1 */ diff --git a/common/core/src/ux_host_stack_bandwidth_release.c b/common/core/src/ux_host_stack_bandwidth_release.c index 082af6f..c1469e0 100644 --- a/common/core/src/ux_host_stack_bandwidth_release.c +++ b/common/core/src/ux_host_stack_bandwidth_release.c @@ -29,12 +29,13 @@ #include "ux_host_stack.h" +#if UX_MAX_DEVICES > 1 /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_bandwidth_release PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,6 +74,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_bandwidth_release(UX_HCD *hcd, UX_ENDPOINT *endpoint) @@ -237,4 +242,4 @@ const UCHAR overheads[4][3] = { to the root port. */ return; } - +#endif /* #if UX_MAX_DEVICES > 1 */ diff --git a/common/core/src/ux_host_stack_class_call.c b/common/core/src/ux_host_stack_class_call.c index f3a8513..710e683 100644 --- a/common/core/src/ux_host_stack_class_call.c +++ b/common/core/src/ux_host_stack_class_call.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_call PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,44 +66,51 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UX_HOST_CLASS *_ux_host_stack_class_call(UX_HOST_CLASS_COMMAND *class_command) { -UX_HOST_CLASS *class; +UINT status = UX_NO_CLASS_MATCH; +UX_HOST_CLASS *class_inst; +#if UX_MAX_CLASS_DRIVER > 1 ULONG class_index; -UINT status; - +#endif /* Start from the 1st registered classes with USBX. */ - class = _ux_system_host -> ux_system_host_class_array; + class_inst = _ux_system_host -> ux_system_host_class_array; /* Parse all the class drivers. */ +#if UX_MAX_CLASS_DRIVER > 1 for (class_index = 0; class_index < _ux_system_host -> ux_system_host_max_class; class_index++) { +#endif /* Check if this class driver is used. */ - if (class -> ux_host_class_status == UX_USED) + if (class_inst -> ux_host_class_status == UX_USED) { /* We have found a potential candidate. Call this registered class entry function. */ - status = class -> ux_host_class_entry_function(class_command); + status = class_inst -> ux_host_class_entry_function(class_command); /* The status tells us if the registered class wants to own this class. */ if (status == UX_SUCCESS) { /* Yes, return this class pointer. */ - return(class); + return(class_inst); } } - +#if UX_MAX_CLASS_DRIVER > 1 /* Move to the next registered class. */ - class++; - } + class_inst ++; + } +#endif /* There is no driver who want to own this class! */ return(UX_NULL); } - diff --git a/common/core/src/ux_host_stack_class_device_scan.c b/common/core/src/ux_host_stack_class_device_scan.c index e3ffaa4..5e9d1ae 100644 --- a/common/core/src/ux_host_stack_class_device_scan.c +++ b/common/core/src/ux_host_stack_class_device_scan.c @@ -29,12 +29,19 @@ #include "ux_host_stack.h" +#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DISABLE) +#if defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_VIDPID_DISABLE) && \ + defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DCSP_DISABLE) +#error When device driver scan is enabled at least one of scan method must be enabled in (VIDPID, DeviceClassSubclassProtocol) +#endif +#endif + /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_device_scan PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,13 +74,18 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used query usage of device */ +/* ClassSubclassProtocol, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_device_scan(UX_DEVICE *device) { +#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DISABLE) UINT status; -UX_HOST_CLASS *class; +UX_HOST_CLASS *class_inst = UX_NULL; UX_HOST_CLASS_COMMAND class_command; /* Perform the command initialization. */ @@ -89,36 +101,30 @@ UX_HOST_CLASS_COMMAND class_command; class_command.ux_host_class_command_iad_subclass = 0; class_command.ux_host_class_command_iad_protocol = 0; +#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_VIDPID_DISABLE) /* We start with the PID/VID for this device. */ class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_PIDVID; - class = _ux_host_stack_class_call(&class_command); + class_inst = _ux_host_stack_class_call(&class_command); +#endif +#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DCSP_DISABLE) /* On return, either we have found a class or the device is still an orphan. */ - if (class != UX_NULL) + if (class_inst == UX_NULL) { - device -> ux_device_class = class; - class_command.ux_host_class_command_class_ptr = class; - class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_ACTIVATE; - status = device -> ux_device_class -> ux_host_class_entry_function(&class_command); + /* It the PID/VID did not work, we continue looking for the Class\Subclass\Protocol match. */ + class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_DCSP; + class_inst = _ux_host_stack_class_call(&class_command); - /* Return result of activation. */ - return(status); } - - /* It the PID/VID did not work, we continue looking for the Class\Subclass\Protocol match. */ - class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_QUERY; - class_command.ux_host_class_command_container = (VOID *) device; - class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_CSP; - - class = _ux_host_stack_class_call(&class_command); +#endif /* On return, either we have found a class or the device is still an orphan. */ - if (class != UX_NULL) + if (class_inst != UX_NULL) { - device -> ux_device_class = class; - class_command.ux_host_class_command_class_ptr = class; + device -> ux_device_class = class_inst; + class_command.ux_host_class_command_class_ptr = class_inst; class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_ACTIVATE; status = device -> ux_device_class -> ux_host_class_entry_function(&class_command); @@ -126,6 +132,8 @@ UX_HOST_CLASS_COMMAND class_command; return(status); } +#endif + /* Return an error. */ return(UX_NO_CLASS_MATCH); } diff --git a/common/core/src/ux_host_stack_class_get.c b/common/core/src/ux_host_stack_class_get.c index 121d48b..bb57f3e 100644 --- a/common/core/src/ux_host_stack_class_get.c +++ b/common/core/src/ux_host_stack_class_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,33 +74,46 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_get(UCHAR *class_name, UX_HOST_CLASS **host_class) { UX_HOST_CLASS *class_ptr; -ULONG class_index; +#if !defined(UX_NAME_REFERENCED_BY_POINTER) UINT status; UINT class_name_length = 0; +#endif +#if UX_MAX_CLASS_DRIVER > 1 +ULONG class_index; +#endif - +#if !defined(UX_NAME_REFERENCED_BY_POINTER) /* Get the length of the class name (exclude null-terminator). */ status = _ux_utility_string_length_check(class_name, &class_name_length, UX_MAX_CLASS_NAME_LENGTH); if (status) return(status); +#endif - /* We need to parse the class driver table. */ + /* Get first class. */ class_ptr = _ux_system_host -> ux_system_host_class_array; + +#if UX_MAX_CLASS_DRIVER > 1 + /* We need to parse the class driver table. */ for (class_index = 0; class_index < _ux_system_host -> ux_system_host_max_class; class_index++) { +#endif /* Check if this class is already being used. */ if (class_ptr -> ux_host_class_status == UX_USED) { /* We have found a container. Check if this is the one we need (compare including null-terminator). */ - if (_ux_utility_memory_compare(class_ptr -> ux_host_class_name, class_name, class_name_length + 1) == UX_SUCCESS) + if (ux_utility_name_match(class_ptr -> ux_host_class_name, class_name, class_name_length + 1)) { /* The class container was found. Update the pointer to the class container for the caller. */ @@ -111,9 +124,11 @@ UINT class_name_length = 0; } } +#if UX_MAX_CLASS_DRIVER > 1 /* Move to the next class. */ class_ptr++; - } + } +#endif /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_UNKNOWN, class_name, 0, 0, UX_TRACE_ERRORS, 0, 0) diff --git a/common/core/src/ux_host_stack_class_instance_create.c b/common/core/src/ux_host_stack_class_instance_create.c index 2784ca0..068cd3f 100644 --- a/common/core/src/ux_host_stack_class_instance_create.c +++ b/common/core/src/ux_host_stack_class_instance_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_instance_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_instance_create(UX_HOST_CLASS *host_class, VOID *class_instance) diff --git a/common/core/src/ux_host_stack_class_instance_destroy.c b/common/core/src/ux_host_stack_class_instance_destroy.c index 0ab3709..7ee71a6 100644 --- a/common/core/src/ux_host_stack_class_instance_destroy.c +++ b/common/core/src/ux_host_stack_class_instance_destroy.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_instance_destroy PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_instance_destroy(UX_HOST_CLASS *host_class, VOID *class_instance) diff --git a/common/core/src/ux_host_stack_class_instance_get.c b/common/core/src/ux_host_stack_class_instance_get.c index 8259858..63b63f0 100644 --- a/common/core/src/ux_host_stack_class_instance_get.c +++ b/common/core/src/ux_host_stack_class_instance_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_instance_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +71,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_instance_get(UX_HOST_CLASS *host_class, UINT class_index, VOID **class_instance) diff --git a/common/core/src/ux_host_stack_class_instance_verify.c b/common/core/src/ux_host_stack_class_instance_verify.c index 41aa28c..46230cf 100644 --- a/common/core/src/ux_host_stack_class_instance_verify.c +++ b/common/core/src/ux_host_stack_class_instance_verify.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_instance_verify PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,34 +70,47 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_instance_verify(UCHAR *class_name, VOID *class_instance) { -UX_HOST_CLASS *class; -ULONG class_index; -VOID **current_class_instance; -UINT status; -UINT class_name_length = 0; - +UX_HOST_CLASS *class_inst; +#if UX_MAX_CLASS_DRIVER > 1 +ULONG class_index; +#endif +VOID **current_class_instance; +#if !defined(UX_NAME_REFERENCED_BY_POINTER) +UINT status; +UINT class_name_length = 0; +#endif +#if !defined(UX_NAME_REFERENCED_BY_POINTER) /* Get the length of the class name (exclude null-terminator). */ status = _ux_utility_string_length_check(class_name, &class_name_length, UX_MAX_CLASS_NAME_LENGTH); if (status) return(status); +#endif + + /* Get first class. */ + class_inst = _ux_system_host -> ux_system_host_class_array; +#if UX_MAX_CLASS_DRIVER > 1 /* We need to parse the class table. */ - class = _ux_system_host -> ux_system_host_class_array; for(class_index = 0; class_index < _ux_system_host -> ux_system_host_max_class; class_index++) { +#endif /* Check if this class is already used. */ - if (class -> ux_host_class_status == UX_USED) + if (class_inst -> ux_host_class_status == UX_USED) { /* Start with the first class instance attached to the class container. */ - current_class_instance = class -> ux_host_class_first_instance; + current_class_instance = class_inst -> ux_host_class_first_instance; /* Traverse the list of the class instances until we find the correct instance. */ while (current_class_instance != UX_NULL) @@ -109,7 +122,7 @@ UINT class_name_length = 0; { /* We have found the class container. Check if this is the one we need (compare including null-terminator). */ - if (_ux_utility_memory_compare(class -> ux_host_class_name, class_name, class_name_length + 1) == UX_SUCCESS) + if (ux_utility_name_match(class_inst-> ux_host_class_name, class_name, class_name_length + 1)) return(UX_SUCCESS); } @@ -117,11 +130,12 @@ UINT class_name_length = 0; current_class_instance = *current_class_instance; } } +#if UX_MAX_CLASS_DRIVER > 1 /* Move to the next class. */ - class++; + class_inst ++; } - +#endif /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, class_instance, 0, 0, UX_TRACE_ERRORS, 0, 0) @@ -129,4 +143,3 @@ UINT class_name_length = 0; /* This class does not exist. */ return(UX_HOST_CLASS_INSTANCE_UNKNOWN); } - diff --git a/common/core/src/ux_host_stack_class_interface_scan.c b/common/core/src/ux_host_stack_class_interface_scan.c index d202d77..62b39e8 100644 --- a/common/core/src/ux_host_stack_class_interface_scan.c +++ b/common/core/src/ux_host_stack_class_interface_scan.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_class_interface_scan PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -81,6 +81,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_interface_scan(UX_DEVICE *device) diff --git a/common/core/src/ux_host_stack_class_register.c b/common/core/src/ux_host_stack_class_register.c index 5628401..d8570db 100644 --- a/common/core/src/ux_host_stack_class_register.c +++ b/common/core/src/ux_host_stack_class_register.c @@ -12,8 +12,8 @@ /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Host Stack */ /** */ @@ -29,89 +29,111 @@ #include "ux_host_stack.h" -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _ux_host_stack_class_register PORTABLE C */ -/* 6.0 */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_host_stack_class_register PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ -/* */ -/* This function registers a USB class to the USB stack. The Class */ -/* must specify an entry point for the USB stack to send commands */ +/* */ +/* This function registers a USB class to the USB stack. The Class */ +/* must specify an entry point for the USB stack to send commands */ /* such as: */ /* */ /* UX_HOST_CLASS_COMMAND_QUERY */ /* UX_HOST_CLASS_COMMAND_ACTIVATE */ -/* UX_HOST_CLASS_COMMAND_DESTROY */ +/* UX_HOST_CLASS_COMMAND_DESTROY */ /* */ /* Note: The C string of class_name must be NULL-terminated and the */ /* length of it (without the NULL-terminator itself) must be no larger */ /* than UX_MAX_CLASS_NAME_LENGTH. */ -/* */ -/* INPUT */ -/* */ -/* class_name Name of class */ -/* class_entry_function Entry function of the class */ -/* */ -/* OUTPUT */ -/* */ -/* Completion Status */ -/* */ -/* CALLS */ -/* */ +/* */ +/* INPUT */ +/* */ +/* class_name Name of class */ +/* class_entry_function Entry function of the class */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* */ +/* CALLS */ +/* */ /* _ux_utility_string_length_check Check C string and return */ /* length if null-terminated */ -/* _ux_utility_memory_copy Copy memory block */ -/* */ -/* CALLED BY */ -/* */ -/* Application */ -/* USBX Components */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* _ux_utility_memory_copy Copy memory block */ +/* */ +/* CALLED BY */ +/* */ +/* Application */ +/* USBX Components */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, verified */ +/* memset and memcpy cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_class_register(UCHAR *class_name, UINT (*class_entry_function)(struct UX_HOST_CLASS_COMMAND_STRUCT *)) { -UX_HOST_CLASS *class; -ULONG class_index; +UX_HOST_CLASS *class_inst; +#if !defined(UX_NAME_REFERENCED_BY_POINTER) UINT status; UINT class_name_length = 0; +#endif +#if UX_MAX_CLASS_DRIVER > 1 +ULONG class_index; +#endif + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_CLASS_REGISTER, class_name, class_entry_function, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) +#if !defined(UX_NAME_REFERENCED_BY_POINTER) /* Get the length of the class name (exclude null-terminator). */ status = _ux_utility_string_length_check(class_name, &class_name_length, UX_MAX_CLASS_NAME_LENGTH); if (status) return(status); +#endif + /* Get first class. */ + class_inst = _ux_system_host -> ux_system_host_class_array; + +#if UX_MAX_CLASS_DRIVER > 1 /* We need to parse the class table to find an empty spot. */ - class = _ux_system_host -> ux_system_host_class_array; for (class_index = 0; class_index < _ux_system_host -> ux_system_host_max_class; class_index++) { +#endif /* Check if this class is already used. */ - if (class -> ux_host_class_status == UX_UNUSED) + if (class_inst -> ux_host_class_status == UX_UNUSED) { +#if defined(UX_NAME_REFERENCED_BY_POINTER) + class_inst -> ux_host_class_name = (const UCHAR *) class_name; +#else + /* We have found a free container for the class. Copy the name (with null-terminator). */ - _ux_utility_memory_copy(class -> ux_host_class_name, class_name, class_name_length + 1); - + _ux_utility_memory_copy(class_inst -> ux_host_class_name, class_name, class_name_length + 1); /* Use case of memcpy is verified. */ +#endif + /* Memorize the entry function of this class. */ - class -> ux_host_class_entry_function = class_entry_function; + class_inst -> ux_host_class_entry_function = class_entry_function; /* Mark it as used. */ - class -> ux_host_class_status = UX_USED; + class_inst -> ux_host_class_status = UX_USED; /* Return successful completion. */ return(UX_SUCCESS); @@ -123,7 +145,7 @@ UINT class_name_length = 0; { /* Check for an already installed class entry function. */ - if(class -> ux_host_class_entry_function == class_entry_function) + if(class_inst -> ux_host_class_entry_function == class_entry_function) { /* Error trap. */ @@ -136,11 +158,12 @@ UINT class_name_length = 0; return(UX_HOST_CLASS_ALREADY_INSTALLED); } } - +#if UX_MAX_CLASS_DRIVER > 1 /* Move to the next class. */ - class++; - } - + class_inst ++; + } +#endif + /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MEMORY_ARRAY_FULL, class_name, 0, 0, UX_TRACE_ERRORS, 0, 0) @@ -150,4 +173,3 @@ UINT class_name_length = 0; /* No more entries in the class table. */ return(UX_MEMORY_ARRAY_FULL); } - diff --git a/common/core/src/ux_host_stack_class_unregister.c b/common/core/src/ux_host_stack_class_unregister.c new file mode 100644 index 0000000..69b4194 --- /dev/null +++ b/common/core/src/ux_host_stack_class_unregister.c @@ -0,0 +1,125 @@ +/**************************************************************************/ +/* */ +/* 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 */ +/** */ +/** Host Stack */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/* Include necessary system files. */ + +#define UX_SOURCE_CODE + +#include "ux_api.h" +#include "ux_host_stack.h" + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_host_stack_class_unregister PORTABLE C */ +/* 6.1 */ +/* AUTHOR */ +/* */ +/* Chaoqiong Xiao, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function unregisters a USB class from the USB stack. */ +/* */ +/* Note following steps must be done before host class unregister: */ +/* All devices related to the class must be removed. */ +/* */ +/* INPUT */ +/* */ +/* class_name Name of class */ +/* class_entry_function Entry function of the class */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* UX_SUCCESS Class unregistered */ +/* UX_NO_CLASS_MATCH Class not found */ +/* */ +/* CALLS */ +/* */ +/* (class_entry_function) Entry function of the class */ +/* */ +/* CALLED BY */ +/* */ +/* Application */ +/* USBX Components */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 09-30-2020 Chaoqiong Xiao Initial Version 6.1 */ +/* */ +/**************************************************************************/ +UINT _ux_host_stack_class_unregister(UINT (*class_entry_function)(struct UX_HOST_CLASS_COMMAND_STRUCT *)) +{ + +UX_HOST_CLASS *class_inst; +UX_HOST_CLASS_COMMAND class_command; +#if UX_MAX_CLASS_DRIVER > 1 +ULONG class_index; +#endif + + + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_CLASS_UNREGISTER, class_entry_function, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + + /* Get first class. */ + class_inst = _ux_system_host -> ux_system_host_class_array; + +#if UX_MAX_CLASS_DRIVER > 1 + /* We need to parse the class table to find right class instance. */ + for (class_index = 0; class_index < _ux_system_host -> ux_system_host_max_class; class_index++) + { +#endif + + /* Check if the class is expected. */ + if (class_inst -> ux_host_class_entry_function == class_entry_function) + { + + /* Initialize the class command with the generic parameters. */ + class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_DESTROY; + class_command.ux_host_class_command_class_ptr = (VOID *)class_inst; + + /* Invoke command for class destroy. */ + class_inst -> ux_host_class_entry_function(&class_command); + + /* Mark as free. */ + class_inst -> ux_host_class_entry_function = UX_NULL; + class_inst -> ux_host_class_status = UX_UNUSED; + + /* Class unregistered success. */ + return(UX_SUCCESS); + } + +#if UX_MAX_CLASS_DRIVER > 1 + /* Move to the next class. */ + class_inst ++; + } +#endif + + /* No more entries in the class table. */ + return(UX_NO_CLASS_MATCH); +} diff --git a/common/core/src/ux_host_stack_configuration_descriptor_parse.c b/common/core/src/ux_host_stack_configuration_descriptor_parse.c index 4677860..4984dbc 100644 --- a/common/core/src/ux_host_stack_configuration_descriptor_parse.c +++ b/common/core/src/ux_host_stack_configuration_descriptor_parse.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_configuration_descriptor_parse PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,6 +73,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_configuration_descriptor_parse(UX_DEVICE *device, UX_CONFIGURATION *configuration, diff --git a/common/core/src/ux_host_stack_configuration_enumerate.c b/common/core/src/ux_host_stack_configuration_enumerate.c index 5b7158d..64ddd4c 100644 --- a/common/core/src/ux_host_stack_configuration_enumerate.c +++ b/common/core/src/ux_host_stack_configuration_enumerate.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_configuration_enumerate PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -79,6 +79,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_configuration_enumerate(UX_DEVICE *device) diff --git a/common/core/src/ux_host_stack_configuration_instance_create.c b/common/core/src/ux_host_stack_configuration_instance_create.c index 4c2aaa7..26834b3 100644 --- a/common/core/src/ux_host_stack_configuration_instance_create.c +++ b/common/core/src/ux_host_stack_configuration_instance_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_configuration_instance_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_configuration_instance_create(UX_CONFIGURATION *configuration) diff --git a/common/core/src/ux_host_stack_configuration_instance_delete.c b/common/core/src/ux_host_stack_configuration_instance_delete.c index e537523..64d9e25 100644 --- a/common/core/src/ux_host_stack_configuration_instance_delete.c +++ b/common/core/src/ux_host_stack_configuration_instance_delete.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_configuration_instance_delete PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_configuration_instance_delete(UX_CONFIGURATION *configuration) diff --git a/common/core/src/ux_host_stack_configuration_interface_get.c b/common/core/src/ux_host_stack_configuration_interface_get.c index 6c6362e..77e760c 100644 --- a/common/core/src/ux_host_stack_configuration_interface_get.c +++ b/common/core/src/ux_host_stack_configuration_interface_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_configuration_interface_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +71,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_configuration_interface_get(UX_CONFIGURATION *configuration, diff --git a/common/core/src/ux_host_stack_configuration_set.c b/common/core/src/ux_host_stack_configuration_set.c index bda29c4..26312d0 100644 --- a/common/core/src/ux_host_stack_configuration_set.c +++ b/common/core/src/ux_host_stack_configuration_set.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_configuration_set PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_configuration_set(UX_CONFIGURATION *configuration) @@ -93,11 +97,11 @@ UX_HCD *hcd; /* For HNP to work the device has to be connected directly to the Root Hub and not a down stream hub. If the parent is NULL, the device is on the root hub. */ - if (device -> ux_device_parent == UX_NULL) + if (UX_DEVICE_PARENT_IS_ROOTHUB(device)) { /* With the device we have the pointer to the HCD. */ - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(device); /* Check the HCD to ensure we have an OTG host controller. */ if (hcd -> ux_hcd_otg_capabilities & UX_HCD_OTG_CAPABLE) diff --git a/common/core/src/ux_host_stack_delay_ms.c b/common/core/src/ux_host_stack_delay_ms.c index fa96985..f024382 100644 --- a/common/core/src/ux_host_stack_delay_ms.c +++ b/common/core/src/ux_host_stack_delay_ms.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_delay_ms PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_delay_ms(ULONG time) diff --git a/common/core/src/ux_host_stack_device_address_set.c b/common/core/src/ux_host_stack_device_address_set.c index 436d0e6..9734d0e 100644 --- a/common/core/src/ux_host_stack_device_address_set.c +++ b/common/core/src/ux_host_stack_device_address_set.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_address_set PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,19 +65,26 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_address_set(UX_DEVICE *device) { + +UINT status = UX_ERROR; UX_TRANSFER *transfer_request; -UINT status; UX_ENDPOINT *control_endpoint; +USHORT device_address; +#if UX_MAX_DEVICES > 1 UX_HCD *hcd; UINT address_byte_index; UINT address_bit_index; UCHAR device_address_byte; -USHORT device_address; +#endif /* Retrieve the pointer to the control endpoint. */ control_endpoint = &device -> ux_device_control_endpoint; @@ -85,11 +92,15 @@ USHORT device_address; /* Retrieve the transfer request pointer. */ transfer_request = &control_endpoint -> ux_endpoint_transfer_request; + /* Initialize device address to 1. */ + device_address = 1; + +#if UX_MAX_DEVICES > 1 + /* We need the HCD pointer as well. */ - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(device); /* Calculate the new address of this device. We start with address 1. */ - device_address = 1; for (address_byte_index = 0; address_byte_index < 16; address_byte_index++) { @@ -108,51 +119,62 @@ USHORT device_address; /* Store the address mask byte. */ hcd -> ux_hcd_address[address_byte_index] = device_address_byte; - - /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_ADDRESS_SET, device, device_address, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) - /* Create a transfer request for the SET_ADDRESS request. */ - transfer_request -> ux_transfer_request_data_pointer = UX_NULL; - transfer_request -> ux_transfer_request_requested_length = 0; - transfer_request -> ux_transfer_request_function = UX_SET_ADDRESS; - transfer_request -> ux_transfer_request_type = UX_REQUEST_OUT | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_DEVICE; - transfer_request -> ux_transfer_request_value = device_address; - transfer_request -> ux_transfer_request_index = 0; + /* OK, apply address. */ + status = UX_SUCCESS; + break; + } + + /* This address was already taken, increment to the next address. */ + device_address++; + } + + /* If address found, break the loop. */ + if (status == UX_SUCCESS) + { + break; + } + } + if (status == UX_ERROR) - /* Send request to HCD layer. */ - status = _ux_host_stack_transfer_request(transfer_request); + /* We should never get here! */ + return(UX_ERROR); +#endif - /* Now, this address will be the one used in future transfers. The transfer may have failed and therefore - all the device resources including the new address will be free.*/ - device -> ux_device_address = (ULONG) device_address; + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_ADDRESS_SET, device, device_address, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) - /* Check completion status. */ - if (status == UX_SUCCESS) - { + /* Create a transfer request for the SET_ADDRESS request. */ + transfer_request -> ux_transfer_request_data_pointer = UX_NULL; + transfer_request -> ux_transfer_request_requested_length = 0; + transfer_request -> ux_transfer_request_function = UX_SET_ADDRESS; + transfer_request -> ux_transfer_request_type = UX_REQUEST_OUT | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_DEVICE; + transfer_request -> ux_transfer_request_value = device_address; + transfer_request -> ux_transfer_request_index = 0; - /* Some devices need some time to accept this address. */ - _ux_utility_delay_ms(UX_DEVICE_ADDRESS_SET_WAIT); + /* Send request to HCD layer. */ + status = _ux_host_stack_transfer_request(transfer_request); - /* Return successful status. */ - return(status); - } - else - { + /* Now, this address will be the one used in future transfers. The transfer may have failed and therefore + all the device resources including the new address will be free.*/ + device -> ux_device_address = (ULONG) device_address; - /* We have an error at the first device transaction. This is mostly - due to the device having failed on the reset after power up. - we will try again either at the root hub or regular hub. */ - return(status); - } - } + /* Check completion status. */ + if (status == UX_SUCCESS) + { - /* This address was already taken, increment to the next address. */ - device_address++; - } + /* Some devices need some time to accept this address. */ + _ux_utility_delay_ms(UX_DEVICE_ADDRESS_SET_WAIT); + + /* Return successful status. */ + return(status); } + else + { - /* We should never get here! */ - return(UX_ERROR); + /* We have an error at the first device transaction. This is mostly + due to the device having failed on the reset after power up. + we will try again either at the root hub or regular hub. */ + return(status); + } } - diff --git a/common/core/src/ux_host_stack_device_configuration_get.c b/common/core/src/ux_host_stack_device_configuration_get.c index bdd772c..7b8d952 100644 --- a/common/core/src/ux_host_stack_device_configuration_get.c +++ b/common/core/src/ux_host_stack_device_configuration_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_configuration_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_configuration_get(UX_DEVICE *device, UINT configuration_index, diff --git a/common/core/src/ux_host_stack_device_configuration_reset.c b/common/core/src/ux_host_stack_device_configuration_reset.c index 91f3f50..b340d75 100644 --- a/common/core/src/ux_host_stack_device_configuration_reset.c +++ b/common/core/src/ux_host_stack_device_configuration_reset.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_configuration_reset PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_configuration_reset(UX_DEVICE *device) diff --git a/common/core/src/ux_host_stack_device_configuration_select.c b/common/core/src/ux_host_stack_device_configuration_select.c index 7d66915..dd8224a 100644 --- a/common/core/src/ux_host_stack_device_configuration_select.c +++ b/common/core/src/ux_host_stack_device_configuration_select.c @@ -1,11 +1,3 @@ - - - - - - - - /**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ @@ -42,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_configuration_select PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -82,6 +74,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_configuration_select(UX_CONFIGURATION *configuration) @@ -134,7 +130,7 @@ UINT status; with the amount of power the device is consuming before allowing it to be configured. Otherwise we may run the risk of an over current fault. */ - if (configuration -> ux_configuration_descriptor.MaxPower > device -> ux_device_max_power) + if (configuration -> ux_configuration_descriptor.MaxPower > UX_DEVICE_MAX_POWER_GET(device)) { /* Error trap. */ diff --git a/common/core/src/ux_host_stack_device_descriptor_read.c b/common/core/src/ux_host_stack_device_descriptor_read.c index 968155e..61ac87b 100644 --- a/common/core/src/ux_host_stack_device_descriptor_read.c +++ b/common/core/src/ux_host_stack_device_descriptor_read.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_descriptor_read PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_descriptor_read(UX_DEVICE *device) diff --git a/common/core/src/ux_host_stack_device_get.c b/common/core/src/ux_host_stack_device_get.c index d323ff5..82dd9c4 100644 --- a/common/core/src/ux_host_stack_device_get.c +++ b/common/core/src/ux_host_stack_device_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,19 +69,25 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_get(ULONG device_index, UX_DEVICE **device) { UX_DEVICE *current_device; +#if UX_MAX_DEVICES > 1 ULONG current_device_index; +#endif /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_GET, device_index, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) /* Check if the device index is still within the limits. */ - if (device_index >= _ux_system_host -> ux_system_host_max_devices) + if (device_index >= UX_SYSTEM_HOST_MAX_DEVICES_GET()) { /* Error trap. */ @@ -93,6 +99,8 @@ ULONG current_device_index; return(UX_DEVICE_HANDLE_UNKNOWN); } +#if UX_MAX_DEVICES > 1 + /* Start with the first device. */ current_device = _ux_system_host -> ux_system_host_device_array; current_device_index = 0; @@ -123,6 +131,16 @@ ULONG current_device_index; /* Move to next device. */ current_device++; } +#else + + /* Only one device, just check if it's used. */ + current_device = _ux_system_host -> ux_system_host_device_array; + if (current_device -> ux_device_handle != UX_UNUSED) + { + *device = current_device; + return(UX_SUCCESS); + } +#endif /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_DEVICE_HANDLE_UNKNOWN, device, 0, 0, UX_TRACE_ERRORS, 0, 0) @@ -130,4 +148,3 @@ ULONG current_device_index; /* Return error. */ return(UX_DEVICE_HANDLE_UNKNOWN); } - diff --git a/common/core/src/ux_host_stack_device_remove.c b/common/core/src/ux_host_stack_device_remove.c index f82e923..020c900 100644 --- a/common/core/src/ux_host_stack_device_remove.c +++ b/common/core/src/ux_host_stack_device_remove.c @@ -12,8 +12,8 @@ /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Host Stack */ /** */ @@ -29,58 +29,64 @@ #include "ux_host_stack.h" -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _ux_host_stack_device_remove PORTABLE C */ -/* 6.0 */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_host_stack_device_remove PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ -/* */ -/* This function will remove a USB device from the bus. */ -/* */ -/* INPUT */ -/* */ +/* */ +/* This function will remove a USB device from the bus. */ +/* */ +/* INPUT */ +/* */ /* HCD Pointer to the HCD */ /* parent The parent device address */ -/* port_index Index of the port on which the*/ +/* port_index Index of the port on which the*/ /* change of status occurred */ -/* */ -/* OUTPUT */ -/* */ -/* Completion Status */ -/* */ -/* CALLS */ -/* */ -/* _ux_host_stack_device_resources_free Free all device resources */ -/* */ -/* CALLED BY */ -/* */ -/* USBX Components */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* */ +/* CALLS */ +/* */ +/* _ux_host_stack_device_resources_free Free all device resources */ +/* */ +/* CALLED BY */ +/* */ +/* USBX Components */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_remove(UX_HCD *hcd, UX_DEVICE *parent, UINT port_index) { +#if UX_MAX_DEVICES > 1 ULONG container_index; +#endif UX_DEVICE *device; UX_CONFIGURATION *configuration; UX_INTERFACE *interface; UX_HOST_CLASS_COMMAND command; - /* We need to find the device descriptor for the removed device. We can find it + /* We need to find the device descriptor for the removed device. We can find it with the parent device and the port it was attached to. Start with the first device. */ - device = _ux_system_host -> ux_system_host_device_array; + device = _ux_system_host -> ux_system_host_device_array; /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_REMOVE, hcd, parent, port_index, device, UX_TRACE_HOST_STACK_EVENTS, 0, 0) @@ -88,6 +94,7 @@ UX_HOST_CLASS_COMMAND command; /* If trace is enabled, unregister this object. */ UX_TRACE_OBJECT_UNREGISTER(device); +#if UX_MAX_DEVICES > 1 /* Start at the beginning of the list. */ container_index = 0; @@ -100,93 +107,105 @@ UX_HOST_CLASS_COMMAND command; { /* Check for the parent device and the port location and the controller. */ - if((device -> ux_device_parent == parent) && (device -> ux_device_port_location == port_index) && - (device -> ux_device_hcd == hcd)) - { + if( UX_DEVICE_PARENT_MATCH(device, parent) && + UX_DEVICE_PORT_LOCATION_MATCH(device, port_index) && + UX_DEVICE_HCD_MATCH(device, hcd)) + break; + } - /* We have found the device to be removed. */ - device -> ux_device_state = UX_DEVICE_REMOVED; + /* Move to the next device entry. */ + device++; + } - /* We have found the device to be removed. Initialize the class - command with the generic parameters. */ - command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_DEACTIVATE; + /* Device not found. */ + if (container_index > _ux_system_host -> ux_system_host_max_devices) +#else + UX_PARAMETER_NOT_USED(parent); + UX_PARAMETER_NOT_USED(port_index); - /* The device may have a class associated with the device container or its interfaces. */ - if (device -> ux_device_class_instance != UX_NULL) - { + /* Device is available and HCD is expected. */ + if (device -> ux_device_handle == UX_UNUSED || + !UX_DEVICE_HCD_MATCH(device, hcd)) +#endif + { - /* We need to stop the class instance for the device. */ - command.ux_host_class_command_instance = device -> ux_device_class_instance; - - /* Call the class. */ - device -> ux_device_class -> ux_host_class_entry_function(&command); - } - else - { + /* Error trap. */ + _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_DEVICE_HANDLE_UNKNOWN); - /* Search for the active configuration. */ - configuration = device -> ux_device_first_configuration; + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_DEVICE_HANDLE_UNKNOWN, device, 0, 0, UX_TRACE_ERRORS, 0, 0) - /* Parse the interface(s) for this device in search of the classes - who own this device. */ - while (configuration != UX_NULL) - { + /* We get here when we could not find the device. */ + return(UX_DEVICE_HANDLE_UNKNOWN); + } - /* Is this the correct configuration? */ - if (configuration -> ux_configuration_descriptor.bConfigurationValue == - device -> ux_device_current_configuration) - { + /* We have found the device to be removed. */ + device -> ux_device_state = UX_DEVICE_REMOVED; - /* We have the correct configuration, search the interface(s). */ - interface = configuration -> ux_configuration_first_interface; - - /* Loop to perform the search. */ - while (interface != UX_NULL) - { + /* We have found the device to be removed. Initialize the class + command with the generic parameters. */ + command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_DEACTIVATE; - /* Check if an instance of the interface is present. */ - if (interface -> ux_interface_class_instance != UX_NULL) - { + /* The device may have a class associated with the device container or its interfaces. */ + if (device -> ux_device_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; - - /* Call the class. */ - interface -> ux_interface_class -> ux_host_class_entry_function(&command); - } + /* We need to stop the class instance for the device. */ + command.ux_host_class_command_instance = device -> ux_device_class_instance; - /* Move to next interface. */ - interface = interface -> ux_interface_next_interface; - } - } + /* Call the class. */ + device -> ux_device_class -> ux_host_class_entry_function(&command); + } + else + { - /* Move to next configuration in the list. */ - configuration = configuration -> ux_configuration_next_configuration; - } - } + /* Search for the active configuration. */ + configuration = device -> ux_device_first_configuration; - /* Now all the resources for this device must be free. */ - _ux_host_stack_device_resources_free(device); + /* Parse the interface(s) for this device in search of the classes + who own this device. */ + while (configuration != UX_NULL) + { - /* Decrement the number of devices on this bus. */ - hcd -> ux_hcd_nb_devices--; + /* Is this the correct configuration? */ + if (configuration -> ux_configuration_descriptor.bConfigurationValue == + device -> ux_device_current_configuration) + { - /* We are done with this device removal. */ - return(UX_SUCCESS); - } - } + /* We have the correct configuration, search the interface(s). */ + interface = configuration -> ux_configuration_first_interface; - /* Move to the next device entry. */ - device++; + /* Loop to perform the search. */ + while (interface != UX_NULL) + { + + /* Check if an instance of the interface is present. */ + if (interface -> 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; + + /* Call the class. */ + interface -> ux_interface_class -> ux_host_class_entry_function(&command); + } + + /* Move to next interface. */ + interface = interface -> ux_interface_next_interface; + } + } + + /* Move to next configuration in the list. */ + configuration = configuration -> ux_configuration_next_configuration; + } } - /* Error trap. */ - _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_DEVICE_HANDLE_UNKNOWN); + /* Now all the resources for this device must be free. */ + _ux_host_stack_device_resources_free(device); - /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_DEVICE_HANDLE_UNKNOWN, device, 0, 0, UX_TRACE_ERRORS, 0, 0) + /* Decrement the number of devices on this bus. */ + hcd -> ux_hcd_nb_devices--; - /* We get here when we could not find the device. */ - return(UX_DEVICE_HANDLE_UNKNOWN); + /* We are done with this device removal. */ + return(UX_SUCCESS); } - diff --git a/common/core/src/ux_host_stack_device_resources_free.c b/common/core/src/ux_host_stack_device_resources_free.c index 050f970..f77b3fd 100644 --- a/common/core/src/ux_host_stack_device_resources_free.c +++ b/common/core/src/ux_host_stack_device_resources_free.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_device_resources_free PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,6 +73,11 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, verified */ +/* memset and memcpy cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_device_resources_free(UX_DEVICE *device) @@ -84,9 +89,11 @@ UX_ENDPOINT *endpoint; VOID *container; ULONG current_alternate_setting; UX_HCD *hcd; +#if UX_MAX_DEVICES > 1 UINT device_address_byte_index; UINT device_address_bit_index; UCHAR device_address_byte; +#endif /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_RESOURCE_FREE, device, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) @@ -161,7 +168,7 @@ UCHAR device_address_byte; /* We need the HCD address for the control endpoint removal and to free the device address. */ - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(device); /* Was the control endpoint already created ? */ if (device -> ux_device_control_endpoint.ux_endpoint_state != 0) @@ -181,6 +188,7 @@ UCHAR device_address_byte; /* The semaphore attached to the control endpoint must be destroyed. */ _ux_utility_semaphore_delete(&device -> ux_device_control_endpoint.ux_endpoint_transfer_request.ux_transfer_request_semaphore); +#if UX_MAX_DEVICES > 1 /* Check if the device had an assigned address. */ if (device -> ux_device_address != 0) { @@ -199,13 +207,14 @@ UCHAR device_address_byte; /* Free the address. */ hcd -> ux_hcd_address[device_address_byte_index] &= (UCHAR)~device_address_byte; - } + } +#endif /* The semaphore for endpoint 0 protection must be destroyed. */ _ux_utility_semaphore_delete(&device -> ux_device_protection_semaphore); /* Now this device can be free and its container return to the pool. */ - _ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); + _ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); /* Use case of memset is verified. */ /* Mark the device handle as unused. */ device -> ux_device_handle = UX_UNUSED; diff --git a/common/core/src/ux_host_stack_endpoint_instance_create.c b/common/core/src/ux_host_stack_endpoint_instance_create.c index f24a8c4..e804631 100644 --- a/common/core/src/ux_host_stack_endpoint_instance_create.c +++ b/common/core/src/ux_host_stack_endpoint_instance_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_endpoint_instance_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,20 +69,22 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_endpoint_instance_create(UX_ENDPOINT *endpoint) { UX_HCD *hcd; -UX_DEVICE *device; UINT status; UCHAR endpoint_type; /* Obtain the HCD for this endpoint. */ - device = endpoint -> ux_endpoint_device; - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(endpoint -> ux_endpoint_device); /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_CREATE, device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) diff --git a/common/core/src/ux_host_stack_endpoint_instance_delete.c b/common/core/src/ux_host_stack_endpoint_instance_delete.c index 66e69a9..5de4ade 100644 --- a/common/core/src/ux_host_stack_endpoint_instance_delete.c +++ b/common/core/src/ux_host_stack_endpoint_instance_delete.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_endpoint_instance_delete PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,18 +68,20 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_endpoint_instance_delete(UX_ENDPOINT *endpoint) { UX_HCD *hcd; -UX_DEVICE *device; /* Obtain the HCD for this endpoint. */ - device = endpoint -> ux_endpoint_device; - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(endpoint -> ux_endpoint_device); /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_DELETE, device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) diff --git a/common/core/src/ux_host_stack_endpoint_reset.c b/common/core/src/ux_host_stack_endpoint_reset.c index 78753de..2941b7e 100644 --- a/common/core/src/ux_host_stack_endpoint_reset.c +++ b/common/core/src/ux_host_stack_endpoint_reset.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_endpoint_reset PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_endpoint_reset(UX_ENDPOINT *endpoint) @@ -106,7 +110,7 @@ UINT status; { /* Pickup HCD pointer. */ - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(device); /* Call HCD entry function. */ status = hcd -> ux_hcd_entry_function(hcd, UX_HCD_RESET_ENDPOINT, endpoint); diff --git a/common/core/src/ux_host_stack_endpoint_transfer_abort.c b/common/core/src/ux_host_stack_endpoint_transfer_abort.c index f0b7ed5..ba6edc2 100644 --- a/common/core/src/ux_host_stack_endpoint_transfer_abort.c +++ b/common/core/src/ux_host_stack_endpoint_transfer_abort.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_endpoint_transfer_abort PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_endpoint_transfer_abort(UX_ENDPOINT *endpoint) diff --git a/common/core/src/ux_host_stack_enum_thread_entry.c b/common/core/src/ux_host_stack_enum_thread_entry.c index 29d6e8a..93b6a23 100644 --- a/common/core/src/ux_host_stack_enum_thread_entry.c +++ b/common/core/src/ux_host_stack_enum_thread_entry.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_enum_thread_entry PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -78,6 +78,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_enum_thread_entry(ULONG input) @@ -92,6 +96,7 @@ VOID _ux_host_stack_enum_thread_entry(ULONG input) /* Wait for the semaphore to be put by the root hub or a regular hub. */ _ux_utility_semaphore_get(&_ux_system_host -> ux_system_host_enum_semaphore, UX_WAIT_FOREVER); +#if UX_MAX_DEVICES > 1 /* We try the hub first. For this we look into the USBX project structure to see if there is at least one hub. */ if (_ux_system_host -> ux_system_host_enum_hub_function != UX_NULL) @@ -100,6 +105,7 @@ VOID _ux_host_stack_enum_thread_entry(ULONG input) /* Yes, there is a HUB function, call it! */ _ux_system_host -> ux_system_host_enum_hub_function(); } +#endif /* The signal may be also coming from the root hub, call the root hub handler. */ _ux_host_stack_rh_change_process(); diff --git a/common/core/src/ux_host_stack_hcd_register.c b/common/core/src/ux_host_stack_hcd_register.c index 5aa1b3e..5894b6a 100644 --- a/common/core/src/ux_host_stack_hcd_register.c +++ b/common/core/src/ux_host_stack_hcd_register.c @@ -12,8 +12,8 @@ /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Host Stack */ /** */ @@ -29,51 +29,58 @@ #include "ux_host_stack.h" -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _ux_host_stack_hcd_register PORTABLE C */ -/* 6.0 */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_host_stack_hcd_register PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ -/* */ +/* */ /* This function registers a USB controller driver with the USBX stack */ -/* and invokes the HCD driver's initialization function. */ +/* and invokes the HCD driver's initialization function. */ /* */ /* Note: The C string of hcd_name must be NULL-terminated and the */ /* length of it (without the NULL-terminator itself) must be no larger */ /* than UX_MAX_HCD_NAME_LENGTH. */ -/* */ -/* INPUT */ -/* */ -/* hcd_name Name of HCD to register */ -/* hcd_entry_function Entry function of HCD driver */ -/* */ -/* OUTPUT */ -/* */ -/* Completion Status */ -/* */ -/* */ -/* CALLS */ -/* */ +/* */ +/* INPUT */ +/* */ +/* hcd_name Name of HCD to register */ +/* hcd_entry_function Entry function of HCD driver */ +/* hcd_param1 Parameter 1 of HCD */ +/* hcd_param2 Parameter 2 of HCD */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* */ +/* */ +/* CALLS */ +/* */ /* _ux_utility_string_length_check Check and return C string */ /* length if no error */ -/* _ux_utility_memory_copy Copy name into HCD structure */ -/* (hcd_init_function) Init function of HCD driver */ -/* */ -/* CALLED BY */ -/* */ -/* Application */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* _ux_utility_memory_copy Copy name into HCD structure */ +/* (hcd_init_function) Init function of HCD driver */ +/* */ +/* CALLED BY */ +/* */ +/* Application */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, verified */ +/* memset and memcpy cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_hcd_register(UCHAR *hcd_name, @@ -81,23 +88,34 @@ UINT _ux_host_stack_hcd_register(UCHAR *hcd_name, { UX_HCD *hcd; -ULONG hcd_index; UINT status; +#if !defined(UX_NAME_REFERENCED_BY_POINTER) UINT hcd_name_length = 0; +#endif +#if UX_MAX_HCD > 1 +ULONG hcd_index; +#endif + /* If trace is enabled, insert this event into the trace buffer. */ - UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_HCD_REGISTER, hcd_name, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_HCD_REGISTER, hcd_name, hcd_param1, hcd_param2, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) +#if !defined(UX_NAME_REFERENCED_BY_POINTER) /* Get the length of the class name (exclude null-terminator). */ status = _ux_utility_string_length_check(hcd_name, &hcd_name_length, UX_MAX_HCD_NAME_LENGTH); if (status) return(status); +#endif - /* We need to parse the controller driver table to find an empty spot. */ + /* Get HCD. */ hcd = _ux_system_host -> ux_system_host_hcd_array; + +#if UX_MAX_HCD > 1 + /* We need to parse the controller driver table to find an empty spot. */ for(hcd_index = 0; hcd_index < _ux_system_host -> ux_system_host_max_hcd; hcd_index++) { +#endif /* Is this slot available? */ if(hcd -> ux_hcd_status == UX_UNUSED) @@ -105,13 +123,18 @@ UINT hcd_name_length = 0; /* Yes, setup the new HCD entry. */ +#if defined(UX_NAME_REFERENCED_BY_POINTER) + hcd -> ux_hcd_name = (const UCHAR *)hcd_name; +#else + /* Initialize the array of the new controller with its name (include null-terminator). */ - _ux_utility_memory_copy(hcd -> ux_hcd_name, hcd_name, hcd_name_length + 1); + _ux_utility_memory_copy(hcd -> ux_hcd_name, hcd_name, hcd_name_length + 1); /* Use case of memcpy is verified. */ +#endif /* Store the hardware resources of the controller */ hcd -> ux_hcd_io = hcd_param1; hcd -> ux_hcd_irq = hcd_param2; - + /* This controller is now used */ hcd -> ux_hcd_status = UX_USED; @@ -124,10 +147,11 @@ UINT hcd_name_length = 0; /* Return the completion status to the caller. */ return(status); } - +#if UX_MAX_HCD > 1 /* Try the next HCD structure */ - hcd++; - } + hcd++; + } +#endif /* We have exhausted the array of the HCDs, return an error. */ return(UX_MEMORY_INSUFFICIENT); diff --git a/common/core/src/ux_host_stack_hcd_thread_entry.c b/common/core/src/ux_host_stack_hcd_thread_entry.c index cc01793..70be1fa 100644 --- a/common/core/src/ux_host_stack_hcd_thread_entry.c +++ b/common/core/src/ux_host_stack_hcd_thread_entry.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_hcd_thread_entry PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_hcd_thread_entry(ULONG input) @@ -75,7 +79,7 @@ VOID _ux_host_stack_hcd_thread_entry(ULONG input) UINT hcd_index; UX_HCD *hcd; -UX_INT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA UX_PARAMETER_NOT_USED(input); @@ -88,10 +92,14 @@ UX_INT_SAVE_AREA thread to process. */ _ux_utility_semaphore_get(&_ux_system_host -> ux_system_host_hcd_semaphore, UX_WAIT_FOREVER); +#if UX_MAX_HCD > 1 /* This thread was awaken by one or more HCD controllers. Check each of the HCDs to see who posted work to do. */ for(hcd_index = 0; hcd_index < _ux_system_host -> ux_system_host_registered_hcd; hcd_index++) { +#else + hcd_index = 0; +#endif /* Pickup HCD pointer. */ hcd = &_ux_system_host -> ux_system_host_hcd_array[hcd_index]; @@ -102,11 +110,14 @@ UX_INT_SAVE_AREA /* Yes, call the HCD function to process the work. */ hcd -> ux_hcd_entry_function(hcd, UX_HCD_PROCESS_DONE_QUEUE, UX_NULL); - UX_DISABLE_INTS + UX_DISABLE hcd -> ux_hcd_thread_signal--; - UX_RESTORE_INTS + UX_RESTORE } + +#if UX_MAX_HCD > 1 } +#endif } } diff --git a/common/core/src/ux_host_stack_hcd_transfer_request.c b/common/core/src/ux_host_stack_hcd_transfer_request.c index 02bfe6a..5511e7f 100644 --- a/common/core/src/ux_host_stack_hcd_transfer_request.c +++ b/common/core/src/ux_host_stack_hcd_transfer_request.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_hcd_transfer_request PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,22 +65,20 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_hcd_transfer_request(UX_TRANSFER *transfer_request) { -UX_ENDPOINT *endpoint; -UX_DEVICE *device; UINT status; UX_HCD *hcd; - /* Get the endpoint container from the transfer request. */ - endpoint = transfer_request -> ux_transfer_request_endpoint; - - /* Obtain the HCD for this endpoint. */ - device = endpoint -> ux_endpoint_device; - hcd = device -> ux_device_hcd; + /* Obtain the HCD. */ + hcd = UX_DEVICE_HCD_GET(transfer_request -> ux_transfer_request_endpoint -> ux_endpoint_device); /* Call the HCD entry function to process the transfer request. */ status = hcd -> ux_hcd_entry_function(hcd, UX_HCD_TRANSFER_REQUEST, (VOID *) transfer_request); diff --git a/common/core/src/ux_host_stack_hcd_unregister.c b/common/core/src/ux_host_stack_hcd_unregister.c new file mode 100644 index 0000000..0fdc6d5 --- /dev/null +++ b/common/core/src/ux_host_stack_hcd_unregister.c @@ -0,0 +1,189 @@ +/**************************************************************************/ +/* */ +/* 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 */ +/** */ +/** Host Stack */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/* Include necessary system files. */ + +#define UX_SOURCE_CODE + +#include "ux_api.h" +#include "ux_host_stack.h" + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_host_stack_hcd_unregister PORTABLE C */ +/* 6.1 */ +/* AUTHOR */ +/* */ +/* Chaoqiong Xiao, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function unregisters a USB host controller driver (HCD) with */ +/* the USBX stack, removes all devices rooted from that controller and */ +/* disable/stop the controller. */ +/* */ +/* INPUT */ +/* */ +/* hcd_name Name of HCD to unregister */ +/* hcd_param1 Parameter 1 of HCD */ +/* hcd_param2 Parameter 2 of HCD */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* UX_SUCCESS HCD unregistered, related */ +/* devices removed and hardware */ +/* disabled/stopped success */ +/* UX_ERROR HCD not found */ +/* */ +/* CALLS */ +/* */ +/* _ux_utility_string_length_check Check and return C string */ +/* length if no error */ +/* _ux_utility_memory_compare Memory compare */ +/* (ux_hcd_entry_function) HCD dispatch entry function */ +/* */ +/* CALLED BY */ +/* */ +/* Application */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 09-30-2020 Chaoqiong Xiao Initial Version 6.1 */ +/* */ +/**************************************************************************/ +UINT _ux_host_stack_hcd_unregister(UCHAR *hcd_name, + ULONG hcd_param1, ULONG hcd_param2) +{ + +UINT status; +UX_DEVICE *device; +UX_HCD *hcd; +#if UX_MAX_CLASS_DRIVER > 1 || UX_MAX_DEVICES > 1 +ULONG scan_index; +#endif +#if !defined(UX_NAME_REFERENCED_BY_POINTER) +UINT hcd_name_length = 0; +#endif + + + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_HCD_UNREGISTER, hcd_name, hcd_param1, hcd_param2, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + +#if !defined(UX_NAME_REFERENCED_BY_POINTER) + /* Get the length of the class name (exclude null-terminator). */ + status = _ux_utility_string_length_check(hcd_name, + &hcd_name_length, UX_MAX_HCD_NAME_LENGTH); + if (status) + return(status); +#endif + + /* Get first HCD. */ + hcd = _ux_system_host -> ux_system_host_hcd_array; + + /* Default to not found status. */ + status = UX_FALSE; + +#if UX_MAX_CLASS_DRIVER > 1 + /* We need to parse the controller driver table to find an empty spot. */ + for (scan_index = 0; + scan_index < _ux_system_host -> ux_system_host_max_hcd; + scan_index++) + { +#endif + + /* Is this slot available and saved hcd_parameters match? */ + if (hcd -> ux_hcd_status == UX_USED && + hcd -> ux_hcd_io == hcd_param1 && + hcd -> ux_hcd_irq == hcd_param2) + { + + + /* Yes, compare the name (with null terminator). */ + status = ux_utility_name_match(hcd -> ux_hcd_name, + hcd_name, hcd_name_length + 1); +#if UX_MAX_CLASS_DRIVER > 1 + + /* Break if name match (found HCD). */ + if (status == UX_TRUE) + break; +#endif + } + +#if UX_MAX_CLASS_DRIVER > 1 + /* Try the next HCD structure */ + hcd ++; + } +#endif + + /* No valid HCD found. */ + if (status != UX_TRUE) + return(UX_ERROR); + + /* Now disable controller. */ + hcd -> ux_hcd_entry_function(hcd, UX_HCD_DISABLE_CONTROLLER, UX_NULL); + + /* Get first device. */ + device = _ux_system_host -> ux_system_host_device_array; + +#if UX_MAX_DEVICES > 1 + /* Remove all devices connected to the controller. */ + for (scan_index = 0; + scan_index < _ux_system_host -> ux_system_host_max_devices; + scan_index ++) + { +#else + + /* No device. */ + if (device -> ux_device_handle == UX_UNUSED) + return(UX_SUCCESS); +#endif + + /* Is this device on the HCD root hub? */ + if (UX_DEVICE_HCD_MATCH(device, hcd) && + UX_DEVICE_PARENT_IS_ROOTHUB(device)) + { + + /* Remove the device (and downstream things connected to it). */ + _ux_host_stack_device_remove(hcd, UX_DEVICE_PARENT_GET(device), + UX_DEVICE_PORT_LOCATION_GET(device)); + + /* The device has been removed, so the port is free again. */ + hcd -> ux_hcd_rh_device_connection &= (ULONG) + ~(1 << device -> ux_device_port_location); + } + +#if UX_MAX_DEVICES > 1 + } +#endif + + /* And we have one new controller unregistered. */ + _ux_system_host -> ux_system_host_registered_hcd --; + + return(UX_SUCCESS); +} diff --git a/common/core/src/ux_host_stack_hnp_polling_thread_entry.c b/common/core/src/ux_host_stack_hnp_polling_thread_entry.c index d01d2da..d185cdf 100644 --- a/common/core/src/ux_host_stack_hnp_polling_thread_entry.c +++ b/common/core/src/ux_host_stack_hnp_polling_thread_entry.c @@ -29,12 +29,13 @@ #include "ux_host_stack.h" +#if defined(UX_OTG_SUPPORT) /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_hnp_polling_thread_entry PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +72,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_hnp_polling_thread_entry(ULONG argument) @@ -134,7 +139,7 @@ UINT status; container_index = 0; /* Search the list until the end. */ - while (container_index++ < _ux_system_host -> ux_system_host_max_devices) + while (container_index++ < UX_SYSTEM_HOST_MAX_DEVICES_GET()) { /* Until we have found a used entry. */ @@ -142,8 +147,8 @@ UINT status; { /* Check for the parent device and the port location and the controller. */ - if((device -> ux_device_port_location == port_index) && - (device -> ux_device_hcd == hcd)) + if(UX_DEVICE_PORT_LOCATION_MATCH(device, port_index) && + UX_DEVICE_HCD_MATCH(device, hcd)) { /* We have a device on a OTG port. But is it a OTG HNP capable device ? @@ -229,4 +234,4 @@ UINT status; } } } - +#endif /* #if defined(UX_OTG_SUPPORT) */ diff --git a/common/core/src/ux_host_stack_initialize.c b/common/core/src/ux_host_stack_initialize.c index f8b6072..3363872 100644 --- a/common/core/src/ux_host_stack_initialize.c +++ b/common/core/src/ux_host_stack_initialize.c @@ -87,7 +87,7 @@ UCHAR _ux_system_host_hcd_simulator_name[] = "ux_ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_initialize PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -124,6 +124,13 @@ UCHAR _ux_system_host_hcd_simulator_name[] = "ux_ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, used UX prefix */ +/* to refer to TX symbols */ +/* instead of using them */ +/* directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_initialize(UINT (*ux_system_host_change_function)(ULONG, UX_HOST_CLASS *, VOID *)) @@ -137,12 +144,12 @@ UCHAR *memory; /* Initialize some of the global so that we don't have to recompile the core code when one item is adjusted. */ - _ux_system_host -> ux_system_host_max_class = UX_MAX_CLASS_DRIVER; - _ux_system_host -> ux_system_host_max_hcd = UX_MAX_HCD; - _ux_system_host -> ux_system_host_max_devices = UX_MAX_DEVICES; _ux_system_host -> ux_system_host_max_ed = UX_MAX_ED; _ux_system_host -> ux_system_host_max_td = UX_MAX_TD; _ux_system_host -> ux_system_host_max_iso_td = UX_MAX_ISO_TD; + UX_SYSTEM_HOST_MAX_CLASS_SET(UX_MAX_CLASS_DRIVER); + UX_SYSTEM_HOST_MAX_HCD_SET(UX_MAX_HCD); + UX_SYSTEM_HOST_MAX_DEVICES_SET(UX_MAX_DEVICES); /* Set the change device function address. */ _ux_system_host -> ux_system_host_change_function = ux_system_host_change_function; @@ -235,7 +242,7 @@ UCHAR *memory; status = _ux_utility_thread_create(&_ux_system_host -> ux_system_host_enum_thread, "ux_system_host_enum_thread", _ux_host_stack_enum_thread_entry, 0, _ux_system_host -> ux_system_host_enum_thread_stack, UX_HOST_ENUM_THREAD_STACK_SIZE, UX_THREAD_PRIORITY_ENUM, - UX_THREAD_PRIORITY_ENUM, UX_NO_TIME_SLICE, TX_AUTO_START); + UX_THREAD_PRIORITY_ENUM, UX_NO_TIME_SLICE, UX_AUTO_START); /* Check the completion status. */ if(status != UX_SUCCESS) @@ -248,7 +255,7 @@ UCHAR *memory; status = _ux_utility_thread_create(&_ux_system_host -> ux_system_host_hcd_thread, "ux_host_stack_hcd_thread", _ux_host_stack_hcd_thread_entry, 0, _ux_system_host -> ux_system_host_hcd_thread_stack, UX_HOST_HCD_THREAD_STACK_SIZE, UX_THREAD_PRIORITY_HCD, - UX_THREAD_PRIORITY_HCD, UX_NO_TIME_SLICE,TX_AUTO_START); + UX_THREAD_PRIORITY_HCD, UX_NO_TIME_SLICE,UX_AUTO_START); /* Check the completion status. */ if(status != UX_SUCCESS) @@ -273,7 +280,7 @@ UCHAR *memory; status = _ux_utility_thread_create(&_ux_system_host -> ux_system_host_hnp_polling_thread, "ux_host_stack_hnp_polling_thread", _ux_host_stack_hnp_polling_thread_entry, 0, _ux_system_host -> ux_system_host_hnp_polling_thread_stack, UX_HOST_HNP_POLLING_THREAD_STACK_SIZE, UX_THREAD_PRIORITY_ENUM, - UX_THREAD_PRIORITY_ENUM, UX_NO_TIME_SLICE, TX_AUTO_START); + UX_THREAD_PRIORITY_ENUM, UX_NO_TIME_SLICE, UX_AUTO_START); /* Check the completion status. */ if (status != UX_SUCCESS) diff --git a/common/core/src/ux_host_stack_interface_endpoint_get.c b/common/core/src/ux_host_stack_interface_endpoint_get.c index 549b79b..237babc 100644 --- a/common/core/src/ux_host_stack_interface_endpoint_get.c +++ b/common/core/src/ux_host_stack_interface_endpoint_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_interface_endpoint_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_interface_endpoint_get(UX_INTERFACE *interface, UINT endpoint_index, UX_ENDPOINT **endpoint) diff --git a/common/core/src/ux_host_stack_interface_instance_create.c b/common/core/src/ux_host_stack_interface_instance_create.c index 79482fc..57cd956 100644 --- a/common/core/src/ux_host_stack_interface_instance_create.c +++ b/common/core/src/ux_host_stack_interface_instance_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_interface_instance_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_interface_instance_create(UX_INTERFACE *interface) diff --git a/common/core/src/ux_host_stack_interface_instance_delete.c b/common/core/src/ux_host_stack_interface_instance_delete.c index f12b1f5..4ecbef6 100644 --- a/common/core/src/ux_host_stack_interface_instance_delete.c +++ b/common/core/src/ux_host_stack_interface_instance_delete.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_interface_instance_delete PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_interface_instance_delete(UX_INTERFACE *interface) diff --git a/common/core/src/ux_host_stack_interface_set.c b/common/core/src/ux_host_stack_interface_set.c index dd62866..a75eec5 100644 --- a/common/core/src/ux_host_stack_interface_set.c +++ b/common/core/src/ux_host_stack_interface_set.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_interface_set PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_interface_set(UX_INTERFACE *interface) diff --git a/common/core/src/ux_host_stack_interface_setting_select.c b/common/core/src/ux_host_stack_interface_setting_select.c index 5fb24a7..145fce6 100644 --- a/common/core/src/ux_host_stack_interface_setting_select.c +++ b/common/core/src/ux_host_stack_interface_setting_select.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_interface_setting_select PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_interface_setting_select(UX_INTERFACE *interface) diff --git a/common/core/src/ux_host_stack_interfaces_scan.c b/common/core/src/ux_host_stack_interfaces_scan.c index 41cf9cd..1f4c143 100644 --- a/common/core/src/ux_host_stack_interfaces_scan.c +++ b/common/core/src/ux_host_stack_interfaces_scan.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_interfaces_scan PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_interfaces_scan(UX_CONFIGURATION *configuration, UCHAR * descriptor) diff --git a/common/core/src/ux_host_stack_new_configuration_create.c b/common/core/src/ux_host_stack_new_configuration_create.c index e982289..9153441 100644 --- a/common/core/src/ux_host_stack_new_configuration_create.c +++ b/common/core/src/ux_host_stack_new_configuration_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_new_configuration_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_new_configuration_create(UX_DEVICE *device, UX_CONFIGURATION *configuration) diff --git a/common/core/src/ux_host_stack_new_device_create.c b/common/core/src/ux_host_stack_new_device_create.c index 387cba9..af6a109 100644 --- a/common/core/src/ux_host_stack_new_device_create.c +++ b/common/core/src/ux_host_stack_new_device_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_new_device_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -92,6 +92,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_new_device_create(UX_HCD *hcd, UX_DEVICE *device_owner, @@ -104,6 +108,7 @@ UINT status; UX_ENDPOINT *control_endpoint; +#if UX_MAX_DEVICES > 1 /* Verify the number of devices attached to the HCD already. Normally a HCD can have up to 127 devices but that can be tailored. */ if (hcd -> ux_hcd_nb_devices > UX_MAX_USB_DEVICES) @@ -117,6 +122,7 @@ UX_ENDPOINT *control_endpoint; return(UX_TOO_MANY_DEVICES); } +#endif /* Get a new device container to store this new device. */ device = _ux_host_stack_new_device_get(); @@ -143,11 +149,11 @@ UX_ENDPOINT *control_endpoint; Initialize the device structure. */ device -> ux_device_handle = (ULONG) (ALIGN_TYPE) device; device -> ux_device_state = UX_DEVICE_ATTACHED; - device -> ux_device_parent = device_owner; - device -> ux_device_hcd = hcd; device -> ux_device_speed = device_speed; - device -> ux_device_port_location = port_index; - device -> ux_device_max_power = port_max_power; + UX_DEVICE_MAX_POWER_SET(device, port_max_power); + UX_DEVICE_PARENT_SET(device, device_owner); + UX_DEVICE_HCD_SET(device, hcd); + UX_DEVICE_PORT_LOCATION_SET(device, port_index); /* Create a semaphore for the device. This is to protect endpoint 0 mostly for OTG HNP polling. The initial count is 1 as a mutex mechanism. */ diff --git a/common/core/src/ux_host_stack_new_device_get.c b/common/core/src/ux_host_stack_new_device_get.c index 88fbb2f..62d5e4c 100644 --- a/common/core/src/ux_host_stack_new_device_get.c +++ b/common/core/src/ux_host_stack_new_device_get.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_new_device_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,23 +64,32 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, verified */ +/* memset and memcpy cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UX_DEVICE *_ux_host_stack_new_device_get(VOID) { +#if UX_MAX_DEVICES > 1 ULONG container_index; +#endif UX_DEVICE *device; /* Start with the first device. */ device = _ux_system_host -> ux_system_host_device_array; +#if UX_MAX_DEVICES > 1 /* Reset the container index. */ container_index = 0; /* Search the list until the end. */ while (container_index++ < _ux_system_host -> ux_system_host_max_devices) +#endif { /* Until we have found an unused entry. */ @@ -88,7 +97,7 @@ UX_DEVICE *device; { /* Reset the entire entry. */ - _ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); + _ux_utility_memory_set(device, 0, sizeof(UX_DEVICE)); /* Use case of memset is verified. */ /* This entry is now used. */ device -> ux_device_handle = UX_USED; @@ -96,9 +105,11 @@ UX_DEVICE *device; /* Return the device pointer. */ return(device); } +#if UX_MAX_DEVICES > 1 /* Move to the next device entry. */ device++; +#endif } /* No unused devices, return NULL. */ diff --git a/common/core/src/ux_host_stack_new_endpoint_create.c b/common/core/src/ux_host_stack_new_endpoint_create.c index abadc00..d1ef9ee 100644 --- a/common/core/src/ux_host_stack_new_endpoint_create.c +++ b/common/core/src/ux_host_stack_new_endpoint_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_new_endpoint_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_new_endpoint_create(UX_INTERFACE *interface, diff --git a/common/core/src/ux_host_stack_new_interface_create.c b/common/core/src/ux_host_stack_new_interface_create.c index 14c9c5a..0d15252 100644 --- a/common/core/src/ux_host_stack_new_interface_create.c +++ b/common/core/src/ux_host_stack_new_interface_create.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_new_interface_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -78,6 +78,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_new_interface_create(UX_CONFIGURATION *configuration, diff --git a/common/core/src/ux_host_stack_rh_change_process.c b/common/core/src/ux_host_stack_rh_change_process.c index 91bc167..8a6b1f3 100644 --- a/common/core/src/ux_host_stack_rh_change_process.c +++ b/common/core/src/ux_host_stack_rh_change_process.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_rh_change_process PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,9 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used new interrupt macros, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_host_stack_rh_change_process(VOID) @@ -76,7 +79,7 @@ UX_HCD *hcd; UINT hcd_index; ULONG port_status; UINT port_index; -UX_INT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA /* This thread was maybe awaken by one or more HCD controllers. Check each of the HCD to see where there has been a change of topology. */ @@ -102,9 +105,9 @@ UX_INT_SAVE_AREA UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_RH_CHANGE_PROCESS, port_index, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) /* Reset that port activity signal. */ - UX_DISABLE_INTS + UX_DISABLE hcd -> ux_hcd_root_hub_signal[port_index]--; - UX_RESTORE_INTS + UX_RESTORE /* Call HCD for port status. */ port_status = hcd -> ux_hcd_entry_function(hcd, UX_HCD_GET_PORT_STATUS, (VOID *)((ALIGN_TYPE)port_index)); @@ -139,9 +142,9 @@ UX_INT_SAVE_AREA { /* We need to get back in synch now. */ - UX_DISABLE_INTS + UX_DISABLE hcd -> ux_hcd_root_hub_signal[port_index] = 0; - UX_RESTORE_INTS + UX_RESTORE /* First extract the device. */ _ux_host_stack_rh_device_extraction(hcd,port_index); diff --git a/common/core/src/ux_host_stack_rh_device_extraction.c b/common/core/src/ux_host_stack_rh_device_extraction.c index 90d8b80..42182e7 100644 --- a/common/core/src/ux_host_stack_rh_device_extraction.c +++ b/common/core/src/ux_host_stack_rh_device_extraction.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_rh_device_extraction PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_rh_device_extraction(UX_HCD *hcd, UINT port_index) diff --git a/common/core/src/ux_host_stack_rh_device_insertion.c b/common/core/src/ux_host_stack_rh_device_insertion.c index fe08260..a30ed4a 100644 --- a/common/core/src/ux_host_stack_rh_device_insertion.c +++ b/common/core/src/ux_host_stack_rh_device_insertion.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_rh_device_insertion PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* checked HCD status before */ +/* retrying enumeration, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_rh_device_insertion(UX_HCD *hcd, UINT port_index) @@ -142,11 +146,18 @@ UINT status; /* Return success to the caller. */ return(UX_SUCCESS); } - else if (index_loop < UX_RH_ENUMERATION_RETRY - 1) + else + { + + /* Return error if HCD is dead. */ + if (hcd -> ux_hcd_status != UX_HCD_STATUS_OPERATIONAL) + return(UX_CONTROLLER_DEAD); - /* Simulate remove to free allocated resources before retry. */ + /* Simulate remove to free allocated resources if retry. */ + if (index_loop < UX_RH_ENUMERATION_RETRY - 1) _ux_host_stack_device_remove(hcd, UX_NULL, port_index); } + } /* We get here if something did not go well. Either the port did not respond well to the ENABLE\RESET phases or the device did not enumerate well diff --git a/common/core/src/ux_host_stack_role_swap.c b/common/core/src/ux_host_stack_role_swap.c index f28b32a..46aee96 100644 --- a/common/core/src/ux_host_stack_role_swap.c +++ b/common/core/src/ux_host_stack_role_swap.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_role_swap PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,11 +68,21 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_role_swap(UX_DEVICE *device) { +#if !defined(UX_OTG_SUPPORT) + + UX_PARAMETER_NOT_USED(device); + return(UX_FUNCTION_NOT_SUPPORTED); +#else + UX_ENDPOINT *control_endpoint; UX_TRANSFER *transfer_request; UINT status; @@ -111,5 +121,5 @@ UINT status; _ux_system_otg -> ux_system_otg_change_mode_event = 0; return(UX_SUCCESS); +#endif } - diff --git a/common/core/src/ux_host_stack_transfer_request.c b/common/core/src/ux_host_stack_transfer_request.c index 8c093be..8f7740f 100644 --- a/common/core/src/ux_host_stack_transfer_request.c +++ b/common/core/src/ux_host_stack_transfer_request.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_transfer_request PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -78,12 +78,19 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, used UX prefix */ +/* to refer to TX symbols */ +/* instead of using them */ +/* directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_transfer_request(UX_TRANSFER *transfer_request) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA UX_ENDPOINT *endpoint; UX_DEVICE *device; @@ -99,7 +106,7 @@ UINT status; /* Ensure we are not preempted by the enum thread while we check the device state and set the transfer status. */ - TX_DISABLE + UX_DISABLE /* We can only transfer when the device is ATTACHED, ADDRESSED OR CONFIGURED. */ if ((device -> ux_device_state == UX_DEVICE_ATTACHED) || (device -> ux_device_state == UX_DEVICE_ADDRESSED) @@ -117,7 +124,7 @@ UINT status; { /* The device is in an invalid state. Restore interrupts and return error. */ - TX_RESTORE + UX_RESTORE /* Check if this is endpoint 0. */ if ((endpoint -> ux_endpoint_descriptor.bEndpointAddress & (UINT)~UX_ENDPOINT_DIRECTION) == 0) @@ -136,13 +143,13 @@ UINT status; } /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_TRANSFER_REQUEST, device, endpoint, transfer_request, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) /* With the device we have the pointer to the HCD. */ - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(device); /* If this is endpoint 0, we protect the endpoint from a possible re-entry. */ if ((endpoint -> ux_endpoint_descriptor.bEndpointAddress & (UINT)~UX_ENDPOINT_DIRECTION) == 0) diff --git a/common/core/src/ux_host_stack_transfer_request_abort.c b/common/core/src/ux_host_stack_transfer_request_abort.c index cbdaa19..1b51853 100644 --- a/common/core/src/ux_host_stack_transfer_request_abort.c +++ b/common/core/src/ux_host_stack_transfer_request_abort.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_host_stack_transfer_request_abort PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,28 +73,24 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* optimized based on compile */ +/* definitions, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_host_stack_transfer_request_abort(UX_TRANSFER *transfer_request) { -UX_ENDPOINT *endpoint; -UX_DEVICE *device; UX_HCD *hcd; ULONG completion_code; - /* Get the endpoint container from the transfer request. */ - endpoint = transfer_request -> ux_transfer_request_endpoint; - - /* Get the device container from the endpoint. */ - device = endpoint -> ux_endpoint_device; - /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_TRANSFER_REQUEST_ABORT, device, endpoint, transfer_request, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) /* With the device we have the pointer to the HCD. */ - hcd = device -> ux_device_hcd; + hcd = UX_DEVICE_HCD_GET(transfer_request -> ux_transfer_request_endpoint -> ux_endpoint_device); /* Check pending transaction. */ if (transfer_request -> ux_transfer_request_completion_code == UX_TRANSFER_STATUS_PENDING) diff --git a/common/core/src/ux_host_stack_uninitialize.c b/common/core/src/ux_host_stack_uninitialize.c new file mode 100644 index 0000000..770a44a --- /dev/null +++ b/common/core/src/ux_host_stack_uninitialize.c @@ -0,0 +1,121 @@ +/**************************************************************************/ +/* */ +/* 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 */ +/** */ +/** Host Stack */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/* Include necessary system files. */ + +#define UX_SOURCE_CODE + +#include "ux_api.h" +#include "ux_host_stack.h" + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_host_stack_uninitialize PORTABLE C */ +/* 6.1 */ +/* AUTHOR */ +/* */ +/* Chaoqiong Xiao, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function uninitializes all the host code for USBX to work on a */ +/* specific platform. */ +/* */ +/* Note following steps must be done before host stack uninitialize: */ +/* All HCDs must be unregistered (devices also removed). */ +/* All classes unregistered (clients attached also removed). */ +/* */ +/* INPUT */ +/* */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* UX_SUCCESS Uninitialized success */ +/* */ +/* */ +/* CALLS */ +/* */ +/* _ux_utility_memory_free Free host memory */ +/* _ux_utility_thread_delete Delete host thread */ +/* _ux_utility_semaphore_delete Delete host semaphore */ +/* */ +/* CALLED BY */ +/* */ +/* Application */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 09-30-2020 Chaoqiong Xiao Initial Version 6.1 */ +/* */ +/**************************************************************************/ +UINT _ux_host_stack_uninitialize(VOID) +{ + + /* If trace is enabled, insert this event into the trace buffer. */ + UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_UNINITIALIZE, 0, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) + + /* Delete enumeration thread. */ + _ux_utility_thread_delete(&_ux_system_host -> ux_system_host_enum_thread); + + /* Delete enumeration semaphore. */ + _ux_utility_semaphore_delete(&_ux_system_host -> ux_system_host_enum_semaphore); + + /* Free enumeration thread stack. */ + _ux_utility_memory_free(_ux_system_host -> ux_system_host_enum_thread_stack); + + /* Delete HCD thread. */ + _ux_utility_thread_delete(&_ux_system_host -> ux_system_host_hcd_thread); + + /* Delete HCD semaphore. */ + _ux_utility_semaphore_delete(&_ux_system_host -> ux_system_host_hcd_semaphore); + + /* Free HCD thread stack. */ + _ux_utility_memory_free(_ux_system_host -> ux_system_host_hcd_thread_stack); + +#if UX_OTG_SUPPORT + + /* Delete HNP thread. */ + _ux_utility_thread_delete(&_ux_system_host -> ux_system_host_hnp_polling_thread); + + /* Free HNP thread stack. */ + _ux_utility_memory_free(_ux_system_host -> ux_system_host_hnp_polling_thread_stack); +#endif + + /* Free HCD array. */ + _ux_utility_memory_free(_ux_system_host -> ux_system_host_hcd_array); + + /* Free Class array. */ + _ux_utility_memory_free(_ux_system_host -> ux_system_host_class_array); + + /* Free Device array. */ + _ux_utility_memory_free(_ux_system_host -> ux_system_host_device_array); + + /* Return success to caller. */ + return(UX_SUCCESS); +} diff --git a/common/core/src/ux_system_error_handler.c b/common/core/src/ux_system_error_handler.c index 530c925..939a16a 100644 --- a/common/core/src/ux_system_error_handler.c +++ b/common/core/src/ux_system_error_handler.c @@ -27,13 +27,13 @@ #include "ux_api.h" - +#ifndef UX_DISABLE_ERROR_HANDLER /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_system_error_handler PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,11 +66,13 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_system_error_handler(UINT system_level, UINT system_context, UINT error_code) { - + /* Save the last system error code. */ _ux_system -> ux_system_last_error = error_code; @@ -85,3 +87,4 @@ VOID _ux_system_error_handler(UINT system_level, UINT system_context, UINT err _ux_system -> ux_system_error_callback_function(system_level, system_context, error_code); } } +#endif diff --git a/common/core/src/ux_system_initialize.c b/common/core/src/ux_system_initialize.c index b232f8d..17c0d3a 100644 --- a/common/core/src/ux_system_initialize.c +++ b/common/core/src/ux_system_initialize.c @@ -65,7 +65,7 @@ UCHAR _ux_system_ecm_interface_descriptor_structure[] = {1,1 /* FUNCTION RELEASE */ /* */ /* _ux_system_initialize PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -101,6 +101,10 @@ UCHAR _ux_system_ecm_interface_descriptor_structure[] = {1,1 /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memory_size, @@ -114,7 +118,7 @@ UINT status; ULONG memory_pool_offset; /* Reset memory block */ - _ux_utility_memory_set(regular_memory_pool_start, 0, regular_memory_size); + _ux_utility_memory_set(regular_memory_pool_start, 0, regular_memory_size); /* Use case of memset is verified. */ /* Set the _ux_system structure at the start of our regular memory */ _ux_system = (UX_SYSTEM *) regular_memory_pool_start; @@ -207,7 +211,7 @@ ULONG memory_pool_offset; _ux_system -> ux_system_cache_safe_memory_pool_start = (UX_MEMORY_BLOCK *) int_memory_pool_start; /* Reset this memory block */ - _ux_utility_memory_set(_ux_system -> ux_system_cache_safe_memory_pool_start, 0, _ux_system -> ux_system_cache_safe_memory_pool_size); + _ux_utility_memory_set(_ux_system -> ux_system_cache_safe_memory_pool_start, 0, _ux_system -> ux_system_cache_safe_memory_pool_size); /* Use case of memset is verified. */ /* Build the first free memory block */ memory_block = _ux_system -> ux_system_cache_safe_memory_pool_start; @@ -215,6 +219,15 @@ ULONG memory_pool_offset; memory_block -> ux_memory_block_status = UX_MEMORY_UNUSED; } +#ifdef UX_ENABLE_MEMORY_STATISTICS + _ux_system -> ux_system_regular_memory_pool_base = (UCHAR *) _ux_system -> ux_system_regular_memory_pool_start; + _ux_system -> ux_system_regular_memory_pool_min_free = _ux_system -> ux_system_regular_memory_pool_free; + _ux_system -> ux_system_cache_safe_memory_pool_base = (UCHAR *) _ux_system -> ux_system_cache_safe_memory_pool_start; + _ux_system -> ux_system_cache_safe_memory_pool_min_free = _ux_system -> ux_system_cache_safe_memory_pool_free; + + /* Other fields are kept zero. */ +#endif + #ifdef UX_ENABLE_DEBUG_LOG /* Obtain memory for storing the debug log. */ diff --git a/common/core/src/ux_system_uninitialize.c b/common/core/src/ux_system_uninitialize.c index c00a36a..5b20e04 100644 --- a/common/core/src/ux_system_uninitialize.c +++ b/common/core/src/ux_system_uninitialize.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_system_uninitialize PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,6 +63,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_system_uninitialize(VOID) diff --git a/common/core/src/ux_trace_event_insert.c b/common/core/src/ux_trace_event_insert.c index 33ae201..0cd38f8 100644 --- a/common/core/src/ux_trace_event_insert.c +++ b/common/core/src/ux_trace_event_insert.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_trace_event_insert PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,6 +73,11 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ #ifdef UX_TRACE_INSERT_MACROS @@ -80,14 +85,14 @@ VOID _ux_trace_event_insert(ULONG event_id, ULONG info_field_1, ULONG info_fiel ULONG filter, TX_TRACE_BUFFER_ENTRY **current_event, ULONG *current_timestamp) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA TX_TRACE_BUFFER_ENTRY *event; ULONG timestamp; /* Disable interrupts. */ - TX_DISABLE + UX_DISABLE /* Pickup the current event. */ event = _tx_trace_buffer_current_ptr; @@ -134,7 +139,7 @@ ULONG timestamp; } /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE } #endif diff --git a/common/core/src/ux_trace_event_update.c b/common/core/src/ux_trace_event_update.c index 516f783..06e8be2 100644 --- a/common/core/src/ux_trace_event_update.c +++ b/common/core/src/ux_trace_event_update.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_trace_event_update PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,17 +71,22 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ #ifdef UX_TRACE_INSERT_MACROS VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, ULONG event_id, ULONG info_field_1, ULONG info_field_2, ULONG info_field_3, ULONG info_field_4) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA /* Disable interrupts. */ - TX_DISABLE + UX_DISABLE /* Determine if the event exists and is still the event originally inserted into the trace. */ if ((event) && (event -> tx_trace_buffer_entry_event_id == event_id) && (event -> tx_trace_buffer_entry_time_stamp == timestamp)) @@ -122,7 +127,7 @@ TX_INTERRUPT_SAVE_AREA } } /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE } #endif diff --git a/common/core/src/ux_trace_object_register.c b/common/core/src/ux_trace_object_register.c index 8a1758f..04f86e3 100644 --- a/common/core/src/ux_trace_object_register.c +++ b/common/core/src/ux_trace_object_register.c @@ -36,7 +36,7 @@ extern VOID _tx_trace_object_register(UCHAR , VOID *, CHAR *, ULONG , ULONG ); /* FUNCTION RELEASE */ /* */ /* _ux_trace_object_register PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,22 +70,27 @@ extern VOID _tx_trace_object_register(UCHAR , VOID *, CHAR *, ULONG , ULONG ); /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_trace_object_register(UCHAR object_type, VOID *object_ptr, CHAR *object_name, ULONG parameter_1, ULONG parameter_2) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA /* Disable interrupts. */ - TX_DISABLE + UX_DISABLE /* Call actual object register function. */ _tx_trace_object_register(object_type, object_ptr, object_name, parameter_1, parameter_2); /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE } #endif diff --git a/common/core/src/ux_trace_object_unregister.c b/common/core/src/ux_trace_object_unregister.c index 88417db..8e553b0 100644 --- a/common/core/src/ux_trace_object_unregister.c +++ b/common/core/src/ux_trace_object_unregister.c @@ -36,7 +36,7 @@ extern VOID _tx_trace_object_unregister(VOID *); /* FUNCTION RELEASE */ /* */ /* _ux_trace_object_unregister PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,21 +66,26 @@ extern VOID _tx_trace_object_unregister(VOID *); /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_trace_object_unregister(VOID *object_ptr) { -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA /* Disable interrupts. */ - TX_DISABLE + UX_DISABLE /* Call actual object unregister function. */ _tx_trace_object_unregister(object_ptr); /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE } #endif diff --git a/common/core/src/ux_utility_debug_callback_register.c b/common/core/src/ux_utility_debug_callback_register.c index 59b35c4..fada5de 100644 --- a/common/core/src/ux_utility_debug_callback_register.c +++ b/common/core/src/ux_utility_debug_callback_register.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_debug_callback_register PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_debug_callback_register(VOID (*debug_callback)(UCHAR *, ULONG)) diff --git a/common/core/src/ux_utility_debug_log.c b/common/core/src/ux_utility_debug_log.c index a7fdddf..d7d1f0c 100644 --- a/common/core/src/ux_utility_debug_log.c +++ b/common/core/src/ux_utility_debug_log.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_debug_log PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,6 +74,12 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, used UX prefix to */ +/* refer to TX symbols instead */ +/* of using them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_debug_log(UCHAR *debug_location, UCHAR *debug_message, ULONG debug_code, @@ -88,7 +94,7 @@ ULONG parameter_shift; UCHAR parameter_hexa; ULONG local_parameter_value; ULONG current_time; -TX_INTERRUPT_SAVE_AREA +UX_INTERRUPT_SAVE_AREA /* Is USBX system completely initialized ? */ if (_ux_system -> ux_system_debug_log_size == 0) @@ -97,7 +103,7 @@ TX_INTERRUPT_SAVE_AREA return; /* Entering critical area. Disable interrupts. */ - TX_DISABLE + UX_DISABLE /* Store the debug value as the last debug value recorded. */ _ux_system -> ux_system_debug_code = debug_code; @@ -117,7 +123,10 @@ TX_INTERRUPT_SAVE_AREA total_debug_message_length = debug_location_string_length + debug_message_string_length + 10 + 10 + 10 + 10 + 5; /* Can we accommodate this debug value message at the current location ? */ - if (_ux_system -> ux_system_debug_log_head + total_debug_message_length > _ux_system -> ux_system_debug_log_buffer + _ux_system -> ux_system_debug_log_size) + if (total_debug_message_length >= _ux_system -> ux_system_debug_log_size) + return; + if (_ux_system -> ux_system_debug_log_head + total_debug_message_length > + ux_system -> ux_system_debug_log_buffer + _ux_system -> ux_system_debug_log_size) { /* The debug value log to insert goes beyond the end of the log buffer, rewind to the beginning. */ @@ -125,7 +134,7 @@ TX_INTERRUPT_SAVE_AREA } /* Copy the time strings and parameters in the log buffer. */ - _ux_utility_memory_copy(_ux_system -> ux_system_debug_log_head, "At time : ", 10); + _ux_utility_memory_copy(_ux_system -> ux_system_debug_log_head, "At time : ", 10); /* Use case of memcpy is verified. */ _ux_system -> ux_system_debug_log_head += 10; /* Get the time value from TX. */ @@ -173,11 +182,11 @@ TX_INTERRUPT_SAVE_AREA _ux_system -> ux_system_debug_log_head++; /* Copy the strings and parameters in the log buffer. */ - _ux_utility_memory_copy(_ux_system -> ux_system_debug_log_head, debug_location, debug_location_string_length); + _ux_utility_memory_copy(_ux_system -> ux_system_debug_log_head, debug_location, debug_location_string_length); /* Use case of memcpy is verified. */ _ux_system -> ux_system_debug_log_head += debug_location_string_length; *_ux_system -> ux_system_debug_log_head = ','; _ux_system -> ux_system_debug_log_head++; - _ux_utility_memory_copy(_ux_system -> ux_system_debug_log_head, debug_message, debug_message_string_length); + _ux_utility_memory_copy(_ux_system -> ux_system_debug_log_head, debug_message, debug_message_string_length); /* Use case of memcpy is verified. */ _ux_system -> ux_system_debug_log_head += debug_message_string_length; *_ux_system -> ux_system_debug_log_head = ','; _ux_system -> ux_system_debug_log_head++; @@ -301,7 +310,7 @@ TX_INTERRUPT_SAVE_AREA } /* Restore interrupts. */ - TX_RESTORE + UX_RESTORE /* We are done here. No return codes. */ return; diff --git a/common/core/src/ux_utility_delay_ms.c b/common/core/src/ux_utility_delay_ms.c index 78c1dc8..cb212c3 100644 --- a/common/core/src/ux_utility_delay_ms.c +++ b/common/core/src/ux_utility_delay_ms.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_delay_ms PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_delay_ms(ULONG ms_wait) diff --git a/common/core/src/ux_utility_descriptor_pack.c b/common/core/src/ux_utility_descriptor_pack.c index 6db1b61..574c56c 100644 --- a/common/core/src/ux_utility_descriptor_pack.c +++ b/common/core/src/ux_utility_descriptor_pack.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_descriptor_pack PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,6 +70,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_descriptor_pack(UCHAR * descriptor, UCHAR * descriptor_structure, diff --git a/common/core/src/ux_utility_descriptor_parse.c b/common/core/src/ux_utility_descriptor_parse.c index 496a406..ff23559 100644 --- a/common/core/src/ux_utility_descriptor_parse.c +++ b/common/core/src/ux_utility_descriptor_parse.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_descriptor_parse PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,6 +70,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_descriptor_parse(UCHAR * raw_descriptor, UCHAR * descriptor_structure, diff --git a/common/core/src/ux_utility_error_callback_register.c b/common/core/src/ux_utility_error_callback_register.c index cf77f0f..b0809db 100644 --- a/common/core/src/ux_utility_error_callback_register.c +++ b/common/core/src/ux_utility_error_callback_register.c @@ -26,12 +26,14 @@ #include "ux_api.h" + +#ifndef UX_DISABLE_ERROR_HANDLER /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_utility_error_callback_register PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_error_callback_register(VOID (*error_callback)(UINT system_level, UINT system_context, UINT error_code)) @@ -76,3 +80,5 @@ VOID _ux_utility_error_callback_register(VOID (*error_callback)(UINT system_lev /* We are done here. No return codes. */ return; } +#endif + diff --git a/common/core/src/ux_utility_event_flags_create.c b/common/core/src/ux_utility_event_flags_create.c index 8d43c58..bb7d72f 100644 --- a/common/core/src/ux_utility_event_flags_create.c +++ b/common/core/src/ux_utility_event_flags_create.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_event_flags_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,9 +64,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR *name) +UINT _ux_utility_event_flags_create(UX_EVENT_FLAGS_GROUP*group_ptr, CHAR *name) { UINT status; diff --git a/common/core/src/ux_utility_event_flags_delete.c b/common/core/src/ux_utility_event_flags_delete.c index e6ed879..f7b4628 100644 --- a/common/core/src/ux_utility_event_flags_delete.c +++ b/common/core/src/ux_utility_event_flags_delete.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_event_flags_delete PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr) +UINT _ux_utility_event_flags_delete(UX_EVENT_FLAGS_GROUP*group_ptr) { UINT status; diff --git a/common/core/src/ux_utility_event_flags_get.c b/common/core/src/ux_utility_event_flags_get.c index ee634a4..2ec5c45 100644 --- a/common/core/src/ux_utility_event_flags_get.c +++ b/common/core/src/ux_utility_event_flags_get.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_event_flags_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,9 +68,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags, +UINT _ux_utility_event_flags_get(UX_EVENT_FLAGS_GROUP*group_ptr, ULONG requested_flags, UINT get_option, ULONG *actual_flags_ptr, ULONG wait_option) { diff --git a/common/core/src/ux_utility_event_flags_set.c b/common/core/src/ux_utility_event_flags_set.c index 4c01799..1449745 100644 --- a/common/core/src/ux_utility_event_flags_set.c +++ b/common/core/src/ux_utility_event_flags_set.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_event_flags_set PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,9 +66,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_event_flags_set(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG flags_to_set, +UINT _ux_utility_event_flags_set(UX_EVENT_FLAGS_GROUP*group_ptr, ULONG flags_to_set, UINT set_option) { diff --git a/common/core/src/ux_utility_long_get.c b/common/core/src/ux_utility_long_get.c index 46b4053..9c34f2f 100644 --- a/common/core/src/ux_utility_long_get.c +++ b/common/core/src/ux_utility_long_get.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_long_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,6 +63,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_utility_long_get(UCHAR * address) diff --git a/common/core/src/ux_utility_long_get_big_endian.c b/common/core/src/ux_utility_long_get_big_endian.c index 96b59fc..ecf3dac 100644 --- a/common/core/src/ux_utility_long_get_big_endian.c +++ b/common/core/src/ux_utility_long_get_big_endian.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_long_get_big_endian PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,6 +63,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_utility_long_get_big_endian(UCHAR * address) diff --git a/common/core/src/ux_utility_long_put.c b/common/core/src/ux_utility_long_put.c index b68b441..3192c72 100644 --- a/common/core/src/ux_utility_long_put.c +++ b/common/core/src/ux_utility_long_put.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_long_put PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_long_put(UCHAR * address, ULONG value) diff --git a/common/core/src/ux_utility_long_put_big_endian.c b/common/core/src/ux_utility_long_put_big_endian.c index a7e6244..eee3a3c 100644 --- a/common/core/src/ux_utility_long_put_big_endian.c +++ b/common/core/src/ux_utility_long_put_big_endian.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_long_put_big_endian PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_long_put_big_endian(UCHAR * address, ULONG value) diff --git a/common/core/src/ux_utility_memory_allocate.c b/common/core/src/ux_utility_memory_allocate.c index c874fb6..3b55043 100644 --- a/common/core/src/ux_utility_memory_allocate.c +++ b/common/core/src/ux_utility_memory_allocate.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_allocate PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,10 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* verified memset and memcpy */ +/* cases, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID *_ux_utility_memory_allocate(ULONG memory_alignment, ULONG memory_cache_flag, @@ -257,7 +261,7 @@ ALIGN_TYPE int_memory_buffer; /* Update the current memory block. */ memory_block -> ux_memory_block_size = memory_size_requested; memory_block -> ux_memory_block_next = new_memory_block; - memory_block -> ux_memory_block_status = UX_MEMORY_USED; + memory_block -> ux_memory_block_status = UX_MEMORY_USED | memory_cache_flag; /* Declare how much memory we removed from the pool. */ memory_removed_from_pool = memory_block -> ux_memory_block_size + (ULONG)sizeof(UX_MEMORY_BLOCK); @@ -277,7 +281,7 @@ ALIGN_TYPE int_memory_buffer; new_memory_block -> ux_memory_block_previous = memory_block; new_memory_block -> ux_memory_block_next = memory_block -> ux_memory_block_next; new_memory_block -> ux_memory_block_size = memory_block -> ux_memory_block_size; - new_memory_block -> ux_memory_block_status = UX_MEMORY_USED; + new_memory_block -> ux_memory_block_status = UX_MEMORY_USED | memory_cache_flag; /* Update the current memory block. */ int_memory_buffer = (ALIGN_TYPE) ((UCHAR *) memory_block + sizeof(UX_MEMORY_BLOCK)); @@ -317,7 +321,7 @@ ALIGN_TYPE int_memory_buffer; memory_buffer = ((UCHAR *) memory_block) + sizeof(UX_MEMORY_BLOCK); /* Clear the memory block. */ - _ux_utility_memory_set(memory_buffer, 0, memory_size_requested); + _ux_utility_memory_set(memory_buffer, 0, memory_size_requested); /* Use case of memset is verified. */ /* Update the memory free in the pool. */ if (_ux_system -> ux_system_cache_safe_memory_pool_start == _ux_system -> ux_system_regular_memory_pool_start) @@ -335,6 +339,7 @@ ALIGN_TYPE int_memory_buffer; case UX_CACHE_SAFE_MEMORY: /* Update the amount of free memory in the cache safe memory pool. */ _ux_system -> ux_system_cache_safe_memory_pool_free -= memory_removed_from_pool; + break; default: @@ -345,6 +350,46 @@ ALIGN_TYPE int_memory_buffer; } } +#ifdef UX_ENABLE_MEMORY_STATISTICS + + /* Update allocate count, total size. */ + if (memory_cache_flag == UX_REGULAR_MEMORY) + { + _ux_system -> ux_system_regular_memory_pool_alloc_count ++; + _ux_system -> ux_system_regular_memory_pool_alloc_total += memory_size_requested; + if (_ux_system -> ux_system_regular_memory_pool_alloc_max_count < _ux_system -> ux_system_regular_memory_pool_alloc_count) + _ux_system -> ux_system_regular_memory_pool_alloc_max_count = _ux_system -> ux_system_regular_memory_pool_alloc_count; + if (_ux_system -> ux_system_regular_memory_pool_alloc_max_total < _ux_system -> ux_system_regular_memory_pool_alloc_total) + _ux_system -> ux_system_regular_memory_pool_alloc_max_total = _ux_system -> ux_system_regular_memory_pool_alloc_total; + } + else + { + _ux_system -> ux_system_cache_safe_memory_pool_alloc_count ++; + _ux_system -> ux_system_cache_safe_memory_pool_alloc_total += memory_size_requested; + if (_ux_system -> ux_system_cache_safe_memory_pool_alloc_max_count < _ux_system -> ux_system_cache_safe_memory_pool_alloc_count) + _ux_system -> ux_system_cache_safe_memory_pool_alloc_max_count = _ux_system -> ux_system_cache_safe_memory_pool_alloc_count; + if (_ux_system -> ux_system_cache_safe_memory_pool_alloc_max_total < _ux_system -> ux_system_cache_safe_memory_pool_alloc_total) + _ux_system -> ux_system_cache_safe_memory_pool_alloc_max_total = _ux_system -> ux_system_cache_safe_memory_pool_alloc_total; + } + + /* Log max usage of regular memory pool. */ + memory_removed_from_pool = (ALIGN_TYPE)_ux_system -> ux_system_regular_memory_pool_start - + (ALIGN_TYPE)_ux_system -> ux_system_regular_memory_pool_base; + if (memory_removed_from_pool > _ux_system -> ux_system_regular_memory_pool_max_start_offset) + _ux_system -> ux_system_regular_memory_pool_max_start_offset = memory_removed_from_pool; + if (_ux_system -> ux_system_regular_memory_pool_min_free > _ux_system -> ux_system_regular_memory_pool_free) + _ux_system -> ux_system_regular_memory_pool_min_free = _ux_system -> ux_system_regular_memory_pool_free; + + /* Log max usage of cache safe memory pool. */ + memory_removed_from_pool = (ALIGN_TYPE)_ux_system -> ux_system_cache_safe_memory_pool_start - + (ALIGN_TYPE)_ux_system -> ux_system_cache_safe_memory_pool_base; + if (memory_removed_from_pool > _ux_system -> ux_system_cache_safe_memory_pool_max_start_offset) + _ux_system -> ux_system_cache_safe_memory_pool_max_start_offset = memory_removed_from_pool; + if (_ux_system -> ux_system_cache_safe_memory_pool_min_free > _ux_system -> ux_system_cache_safe_memory_pool_free) + _ux_system -> ux_system_cache_safe_memory_pool_min_free = _ux_system -> ux_system_cache_safe_memory_pool_free; + +#endif + /* Release the protection. */ _ux_utility_mutex_off(&_ux_system -> ux_system_mutex); diff --git a/common/core/src/ux_utility_memory_allocate_add_safe.c b/common/core/src/ux_utility_memory_allocate_add_safe.c index 9a972d5..138b1f5 100644 --- a/common/core/src/ux_utility_memory_allocate_add_safe.c +++ b/common/core/src/ux_utility_memory_allocate_add_safe.c @@ -32,7 +32,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_allocate_add_safe PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,6 +68,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID* _ux_utility_memory_allocate_add_safe(ULONG align,ULONG cache,ULONG size_add_a,ULONG size_add_b) diff --git a/common/core/src/ux_utility_memory_allocate_mulc_safe.c b/common/core/src/ux_utility_memory_allocate_mulc_safe.c index 000a465..5d3cd91 100644 --- a/common/core/src/ux_utility_memory_allocate_mulc_safe.c +++ b/common/core/src/ux_utility_memory_allocate_mulc_safe.c @@ -32,7 +32,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_allocate_mulc_safe PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID* _ux_utility_memory_allocate_mulc_safe(ULONG align,ULONG cache,ULONG size_mul_v,ULONG size_mul_c) diff --git a/common/core/src/ux_utility_memory_allocate_mulv_safe.c b/common/core/src/ux_utility_memory_allocate_mulv_safe.c index 6054ef7..1d5ea05 100644 --- a/common/core/src/ux_utility_memory_allocate_mulv_safe.c +++ b/common/core/src/ux_utility_memory_allocate_mulv_safe.c @@ -32,7 +32,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_allocate_mulv_safe PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID* _ux_utility_memory_allocate_mulv_safe(ULONG align,ULONG cache,ULONG size_mul_v0,ULONG size_mul_v1) diff --git a/common/core/src/ux_utility_memory_compare.c b/common/core/src/ux_utility_memory_compare.c index 713e11e..705af04 100644 --- a/common/core/src/ux_utility_memory_compare.c +++ b/common/core/src/ux_utility_memory_compare.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_compare PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_utility_memory_compare(VOID *memory_source, VOID *memory_destination, ULONG length) diff --git a/common/core/src/ux_utility_memory_copy.c b/common/core/src/ux_utility_memory_copy.c index 0bb83d0..e7d448b 100644 --- a/common/core/src/ux_utility_memory_copy.c +++ b/common/core/src/ux_utility_memory_copy.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_copy PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +66,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_memory_copy(VOID *memory_destination, VOID *memory_source, ULONG length) diff --git a/common/core/src/ux_utility_memory_free.c b/common/core/src/ux_utility_memory_free.c index 02d28f6..54fed00 100644 --- a/common/core/src/ux_utility_memory_free.c +++ b/common/core/src/ux_utility_memory_free.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_free PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_memory_free(VOID *memory) @@ -85,7 +87,8 @@ UCHAR *memory_address; memory_size_returned = memory_block -> ux_memory_block_size + (ULONG)sizeof(UX_MEMORY_BLOCK); /* Check this memory block to see if it valid. */ - if (memory_block -> ux_memory_block_status != UX_MEMORY_USED) + if (memory_block -> ux_memory_block_status != (UX_MEMORY_USED | UX_REGULAR_MEMORY) && + memory_block -> ux_memory_block_status != (UX_MEMORY_USED | UX_CACHE_SAFE_MEMORY)) { /* Not valid. Release the protection. */ @@ -101,6 +104,21 @@ UCHAR *memory_address; return; } +#ifdef UX_ENABLE_MEMORY_STATISTICS + + /* Update allocate count, total size. */ + if (memory_block -> ux_memory_block_status == (UX_MEMORY_USED | UX_REGULAR_MEMORY)) + { + _ux_system -> ux_system_regular_memory_pool_alloc_count --; + _ux_system -> ux_system_regular_memory_pool_alloc_total -= memory_block -> ux_memory_block_size; + } + else + { + _ux_system -> ux_system_cache_safe_memory_pool_alloc_count --; + _ux_system -> ux_system_cache_safe_memory_pool_alloc_total -= memory_block -> ux_memory_block_size; + } +#endif + /* We mark this memory block as being unused. */ memory_block -> ux_memory_block_status = UX_MEMORY_UNUSED; @@ -131,7 +149,7 @@ UCHAR *memory_address; { /* Determine if the memory block is used. */ - if (next_block -> ux_memory_block_status == UX_MEMORY_USED) + if (next_block -> ux_memory_block_status != UX_MEMORY_UNUSED) { /* Yes, move to next block. */ diff --git a/common/core/src/ux_utility_memory_free_block_best_get.c b/common/core/src/ux_utility_memory_free_block_best_get.c index b6294bb..87179f3 100644 --- a/common/core/src/ux_utility_memory_free_block_best_get.c +++ b/common/core/src/ux_utility_memory_free_block_best_get.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_free_block_best_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UX_MEMORY_BLOCK *_ux_utility_memory_free_block_best_get(ULONG memory_cache_flag, diff --git a/common/core/src/ux_utility_memory_set.c b/common/core/src/ux_utility_memory_set.c index 5cf7a7f..fda88e9 100644 --- a/common/core/src/ux_utility_memory_set.c +++ b/common/core/src/ux_utility_memory_set.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_memory_set PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_memory_set(VOID *destination, UCHAR value, ULONG length) diff --git a/common/core/src/ux_utility_mutex_create.c b/common/core/src/ux_utility_mutex_create.c index b8bb410..c262290 100644 --- a/common/core/src/ux_utility_mutex_create.c +++ b/common/core/src/ux_utility_mutex_create.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_mutex_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,9 +64,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_mutex_create(TX_MUTEX *mutex, CHAR *mutex_name) +UINT _ux_utility_mutex_create(UX_MUTEX *mutex, CHAR *mutex_name) { UINT status; diff --git a/common/core/src/ux_utility_mutex_delete.c b/common/core/src/ux_utility_mutex_delete.c index caed65c..f2b2ced 100644 --- a/common/core/src/ux_utility_mutex_delete.c +++ b/common/core/src/ux_utility_mutex_delete.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_mutex_delete PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_mutex_delete(TX_MUTEX *mutex) +UINT _ux_utility_mutex_delete(UX_MUTEX *mutex) { UINT status; diff --git a/common/core/src/ux_utility_mutex_off.c b/common/core/src/ux_utility_mutex_off.c index 03ccec2..839ebc0 100644 --- a/common/core/src/ux_utility_mutex_off.c +++ b/common/core/src/ux_utility_mutex_off.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_mutex_off PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -VOID _ux_utility_mutex_off(TX_MUTEX *mutex) +VOID _ux_utility_mutex_off(UX_MUTEX *mutex) { /* Call ThreadX to release protection. */ diff --git a/common/core/src/ux_utility_mutex_on.c b/common/core/src/ux_utility_mutex_on.c index 14a4aa2..bbb17b1 100644 --- a/common/core/src/ux_utility_mutex_on.c +++ b/common/core/src/ux_utility_mutex_on.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_mutex_on PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -VOID _ux_utility_mutex_on(TX_MUTEX *mutex) +VOID _ux_utility_mutex_on(UX_MUTEX *mutex) { UINT status; diff --git a/common/core/src/ux_utility_pci_class_scan.c b/common/core/src/ux_utility_pci_class_scan.c index 672fada..f1a5f71 100644 --- a/common/core/src/ux_utility_pci_class_scan.c +++ b/common/core/src/ux_utility_pci_class_scan.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_pci_class_scan PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,6 +70,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_utility_pci_class_scan(ULONG pci_class, ULONG bus_number, ULONG device_number, diff --git a/common/core/src/ux_utility_pci_read.c b/common/core/src/ux_utility_pci_read.c index 22cd473..5ced97b 100644 --- a/common/core/src/ux_utility_pci_read.c +++ b/common/core/src/ux_utility_pci_read.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_pci_read PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +71,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_utility_pci_read(ULONG bus_number, ULONG device_number, ULONG function_number, diff --git a/common/core/src/ux_utility_pci_write.c b/common/core/src/ux_utility_pci_write.c index a17655d..c8635e2 100644 --- a/common/core/src/ux_utility_pci_write.c +++ b/common/core/src/ux_utility_pci_write.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_pci_write PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -71,6 +71,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_pci_write(ULONG bus_number, ULONG device_number, ULONG function_number, diff --git a/common/core/src/ux_utility_physical_address.c b/common/core/src/ux_utility_physical_address.c index 8709155..9143057 100644 --- a/common/core/src/ux_utility_physical_address.c +++ b/common/core/src/ux_utility_physical_address.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_physical_address PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID *_ux_utility_physical_address(VOID *virtual_address) diff --git a/common/core/src/ux_utility_semaphore_create.c b/common/core/src/ux_utility_semaphore_create.c index ec411fa..db380d8 100644 --- a/common/core/src/ux_utility_semaphore_create.c +++ b/common/core/src/ux_utility_semaphore_create.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_semaphore_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,9 +65,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_semaphore_create(TX_SEMAPHORE *semaphore, CHAR *semaphore_name, UINT initial_count) +UINT _ux_utility_semaphore_create(UX_SEMAPHORE *semaphore, CHAR *semaphore_name, UINT initial_count) { UINT status; diff --git a/common/core/src/ux_utility_semaphore_delete.c b/common/core/src/ux_utility_semaphore_delete.c index d9d3ea5..fdc3a4e 100644 --- a/common/core/src/ux_utility_semaphore_delete.c +++ b/common/core/src/ux_utility_semaphore_delete.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_semaphore_delete PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_semaphore_delete(TX_SEMAPHORE *semaphore) +UINT _ux_utility_semaphore_delete(UX_SEMAPHORE *semaphore) { UINT status; diff --git a/common/core/src/ux_utility_semaphore_get.c b/common/core/src/ux_utility_semaphore_get.c index 8627b5d..4fc1188 100644 --- a/common/core/src/ux_utility_semaphore_get.c +++ b/common/core/src/ux_utility_semaphore_get.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_semaphore_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,21 +65,26 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_semaphore_get(TX_SEMAPHORE *semaphore, ULONG semaphore_signal) +UINT _ux_utility_semaphore_get(UX_SEMAPHORE *semaphore, ULONG semaphore_signal) { UINT status; -TX_THREAD *my_thread; +UX_THREAD *my_thread; CHAR *name; UINT state; ULONG run_count; UINT priority; UINT preemption_threshold; ULONG time_slice; -TX_THREAD *next_thread; -TX_THREAD *suspended_thread; +UX_THREAD *next_thread; +UX_THREAD *suspended_thread; /* Call TX to know my own tread. */ my_thread = tx_thread_identify(); diff --git a/common/core/src/ux_utility_semaphore_put.c b/common/core/src/ux_utility_semaphore_put.c index ba1df05..8502dad 100644 --- a/common/core/src/ux_utility_semaphore_put.c +++ b/common/core/src/ux_utility_semaphore_put.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_semaphore_put PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_semaphore_put(TX_SEMAPHORE *semaphore) +UINT _ux_utility_semaphore_put(UX_SEMAPHORE *semaphore) { UINT status; diff --git a/common/core/src/ux_utility_set_interrupt_handler.c b/common/core/src/ux_utility_set_interrupt_handler.c index fd30c78..7a0cac1 100644 --- a/common/core/src/ux_utility_set_interrupt_handler.c +++ b/common/core/src/ux_utility_set_interrupt_handler.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_set_interrupt_handler PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_set_interrupt_handler(UINT irq, VOID (*interrupt_handler)(VOID)) diff --git a/common/core/src/ux_utility_short_get.c b/common/core/src/ux_utility_short_get.c index 99b43fd..3a24c42 100644 --- a/common/core/src/ux_utility_short_get.c +++ b/common/core/src/ux_utility_short_get.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_short_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,6 +63,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_utility_short_get(UCHAR * address) diff --git a/common/core/src/ux_utility_short_get_big_endian.c b/common/core/src/ux_utility_short_get_big_endian.c index ac3cd35..f6cefa3 100644 --- a/common/core/src/ux_utility_short_get_big_endian.c +++ b/common/core/src/ux_utility_short_get_big_endian.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_short_get_big_endian PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,6 +63,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_utility_short_get_big_endian(UCHAR * address) diff --git a/common/core/src/ux_utility_short_put.c b/common/core/src/ux_utility_short_put.c index 3655e5b..330882b 100644 --- a/common/core/src/ux_utility_short_put.c +++ b/common/core/src/ux_utility_short_put.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_short_put PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_short_put(UCHAR * address, USHORT value) diff --git a/common/core/src/ux_utility_short_put_big_endian.c b/common/core/src/ux_utility_short_put_big_endian.c index f382255..7d20be6 100644 --- a/common/core/src/ux_utility_short_put_big_endian.c +++ b/common/core/src/ux_utility_short_put_big_endian.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_short_put_big_endian PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_short_put_big_endian(UCHAR * address, USHORT value) diff --git a/common/core/src/ux_utility_string_length_check.c b/common/core/src/ux_utility_string_length_check.c index 4ecc3cb..f4a2a0a 100644 --- a/common/core/src/ux_utility_string_length_check.c +++ b/common/core/src/ux_utility_string_length_check.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_string_length_check PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,6 +72,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_utility_string_length_check(UCHAR *string, UINT *string_length_ptr, UINT max_string_length) diff --git a/common/core/src/ux_utility_string_length_get.c b/common/core/src/ux_utility_string_length_get.c index 6522612..a151d9b 100644 --- a/common/core/src/ux_utility_string_length_get.c +++ b/common/core/src/ux_utility_string_length_get.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_string_length_get PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ ULONG _ux_utility_string_length_get(UCHAR *string) diff --git a/common/core/src/ux_utility_string_to_unicode.c b/common/core/src/ux_utility_string_to_unicode.c index 6ec0b47..7f2ed63 100644 --- a/common/core/src/ux_utility_string_to_unicode.c +++ b/common/core/src/ux_utility_string_to_unicode.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_string_to_unicode PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -73,6 +73,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_string_to_unicode(UCHAR *source, UCHAR *destination) diff --git a/common/core/src/ux_utility_thread_create.c b/common/core/src/ux_utility_thread_create.c index 0a5d969..c7cdcd6 100644 --- a/common/core/src/ux_utility_thread_create.c +++ b/common/core/src/ux_utility_thread_create.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_thread_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -72,9 +72,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_thread_create(TX_THREAD *thread_ptr, CHAR *name, +UINT _ux_utility_thread_create(UX_THREAD *thread_ptr, CHAR *name, VOID (*entry_function)(ULONG), ULONG entry_input, VOID *stack_start, ULONG stack_size, UINT priority, UINT preempt_threshold, diff --git a/common/core/src/ux_utility_thread_delete.c b/common/core/src/ux_utility_thread_delete.c index dd9aad5..b6b90ca 100644 --- a/common/core/src/ux_utility_thread_delete.c +++ b/common/core/src/ux_utility_thread_delete.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_thread_delete PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,9 +64,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_thread_delete(TX_THREAD *thread_ptr) +UINT _ux_utility_thread_delete(UX_THREAD *thread_ptr) { UINT status; diff --git a/common/core/src/ux_utility_thread_identify.c b/common/core/src/ux_utility_thread_identify.c index 02f640d..36a67d6 100644 --- a/common/core/src/ux_utility_thread_identify.c +++ b/common/core/src/ux_utility_thread_identify.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_thread_identify PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,14 +64,19 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -TX_THREAD *_ux_utility_thread_identify(VOID) +UX_THREAD *_ux_utility_thread_identify(VOID) { /* If we're under interrupt, the thread returned by tx_thread_identify is the thread running prior to the ISR. Instead, we set it to null. */ - return(TX_THREAD_GET_SYSTEM_STATE() ? UX_NULL : tx_thread_identify()); + return(UX_THREAD_GET_SYSTEM_STATE() ? UX_NULL : tx_thread_identify()); } diff --git a/common/core/src/ux_utility_thread_relinquish.c b/common/core/src/ux_utility_thread_relinquish.c index d7f687a..5875fd7 100644 --- a/common/core/src/ux_utility_thread_relinquish.c +++ b/common/core/src/ux_utility_thread_relinquish.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_thread_relinquish PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -61,6 +61,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_thread_relinquish(VOID) diff --git a/common/core/src/ux_utility_thread_resume.c b/common/core/src/ux_utility_thread_resume.c index 2bb13a6..c440516 100644 --- a/common/core/src/ux_utility_thread_resume.c +++ b/common/core/src/ux_utility_thread_resume.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_thread_resume PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_thread_resume(TX_THREAD *thread_ptr) +UINT _ux_utility_thread_resume(UX_THREAD *thread_ptr) { UINT status; diff --git a/common/core/src/ux_utility_thread_schedule_other.c b/common/core/src/ux_utility_thread_schedule_other.c index 388031e..aa6537c 100644 --- a/common/core/src/ux_utility_thread_schedule_other.c +++ b/common/core/src/ux_utility_thread_schedule_other.c @@ -32,8 +32,8 @@ /* */ /* FUNCTION RELEASE */ /* */ -/* _ux_utility_thread_priority_change PORTABLE C */ -/* 6.0 */ +/* _ux_utility_thread_schedule_other PORTABLE C */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,11 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_utility_thread_schedule_other(UINT caller_priority) @@ -72,7 +77,7 @@ UINT _ux_utility_thread_schedule_other(UINT caller_priority) UINT status; UINT old_priority; -TX_THREAD *my_thread; +UX_THREAD *my_thread; UX_PARAMETER_NOT_USED(caller_priority); diff --git a/common/core/src/ux_utility_thread_sleep.c b/common/core/src/ux_utility_thread_sleep.c index cfa494e..337e604 100644 --- a/common/core/src/ux_utility_thread_sleep.c +++ b/common/core/src/ux_utility_thread_sleep.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_thread_sleep PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_utility_thread_sleep(ULONG ticks) diff --git a/common/core/src/ux_utility_thread_suspend.c b/common/core/src/ux_utility_thread_suspend.c index 304ce18..6ea47c0 100644 --- a/common/core/src/ux_utility_thread_suspend.c +++ b/common/core/src/ux_utility_thread_suspend.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_thread_suspend PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -63,9 +63,14 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* used UX prefix to refer to */ +/* TX symbols instead of using */ +/* them directly, */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ -UINT _ux_utility_thread_suspend(TX_THREAD *thread_ptr) +UINT _ux_utility_thread_suspend(UX_THREAD *thread_ptr) { UINT status; diff --git a/common/core/src/ux_utility_timer_create.c b/common/core/src/ux_utility_timer_create.c index 04c3c69..1bb973f 100644 --- a/common/core/src/ux_utility_timer_create.c +++ b/common/core/src/ux_utility_timer_create.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_timer_create PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _ux_utility_timer_create(TX_TIMER *timer, CHAR *timer_name, VOID (*expiration_function) (ULONG), diff --git a/common/core/src/ux_utility_timer_delete.c b/common/core/src/ux_utility_timer_delete.c new file mode 100644 index 0000000..7e384ef --- /dev/null +++ b/common/core/src/ux_utility_timer_delete.c @@ -0,0 +1,79 @@ +/**************************************************************************/ +/* */ +/* 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 */ +/** */ +/** Utility */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/* Include necessary system files. */ + +#define UX_SOURCE_CODE + +#include "ux_api.h" + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_utility_timer_delete PORTABLE C */ +/* 6.1 */ +/* AUTHOR */ +/* */ +/* Chaoqiong Xiao, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function deletes a timer. */ +/* */ +/* INPUT */ +/* */ +/* timer Pointer to timer */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* */ +/* CALLS */ +/* */ +/* tx_timer_delete ThreadX timer delete */ +/* */ +/* CALLED BY */ +/* */ +/* USBX Components */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 09-30-2020 Chaoqiong Xiao Initial Version 6.1 */ +/* */ +/**************************************************************************/ +UINT _ux_utility_timer_delete(TX_TIMER *timer) +{ + +UINT status; + + + /* Call ThreadX to delete the timer object. */ + status = tx_timer_delete(timer); + + /* Return completion status. */ + return(status); +} diff --git a/common/core/src/ux_utility_unicode_to_string.c b/common/core/src/ux_utility_unicode_to_string.c index aeb1564..530ff6b 100644 --- a/common/core/src/ux_utility_unicode_to_string.c +++ b/common/core/src/ux_utility_unicode_to_string.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_unicode_to_string PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _ux_utility_unicode_to_string(UCHAR *source, UCHAR *destination) diff --git a/common/core/src/ux_utility_virtual_address.c b/common/core/src/ux_utility_virtual_address.c index 5bb4e95..cb9151d 100644 --- a/common/core/src/ux_utility_virtual_address.c +++ b/common/core/src/ux_utility_virtual_address.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_utility_virtual_address PORTABLE C */ -/* 6.0 */ +/* 6.1 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -64,6 +64,8 @@ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ +/* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID *_ux_utility_virtual_address(VOID *physical_address) |
