diff options
| author | Yuxin Zhou <[email protected]> | 2021-04-03 01:05:33 +0000 |
|---|---|---|
| committer | Yuxin Zhou <[email protected]> | 2021-04-03 01:05:33 +0000 |
| commit | dfb4460f72adebdb045a2d92e39a31df9a503898 (patch) | |
| tree | 67f8da386698fb20ae35314b770aca74d6bd83bf /common/core | |
| parent | f6be93a662e24ed3ee57fc9e28aaeecb498093f5 (diff) | |
Release 6.1.6v6.1.6_rel
Diffstat (limited to 'common/core')
| -rwxr-xr-x | common/core/inc/ux_api.h | 16 | ||||
| -rw-r--r-- | common/core/inc/ux_dcd_sim_slave.h | 11 | ||||
| -rw-r--r-- | common/core/inc/ux_hcd_sim_host.h | 6 | ||||
| -rw-r--r-- | common/core/inc/ux_user_sample.h | 50 | ||||
| -rw-r--r-- | common/core/src/ux_dcd_sim_slave_endpoint_create.c | 15 | ||||
| -rw-r--r-- | common/core/src/ux_dcd_sim_slave_endpoint_status.c | 17 | ||||
| -rw-r--r-- | common/core/src/ux_dcd_sim_slave_initialize.c | 21 | ||||
| -rw-r--r-- | common/core/src/ux_dcd_sim_slave_initialize_complete.c | 24 | ||||
| -rw-r--r-- | common/core/src/ux_dcd_sim_slave_state_change.c | 26 | ||||
| -rw-r--r-- | common/core/src/ux_device_stack_get_status.c | 13 | ||||
| -rw-r--r-- | common/core/src/ux_device_stack_uninitialize.c | 9 | ||||
| -rw-r--r-- | common/core/src/ux_hcd_sim_host_initialize.c | 21 | ||||
| -rw-r--r-- | common/core/src/ux_hcd_sim_host_port_status_get.c | 13 | ||||
| -rw-r--r-- | common/core/src/ux_hcd_sim_host_transaction_schedule.c | 30 |
14 files changed, 239 insertions, 33 deletions
diff --git a/common/core/inc/ux_api.h b/common/core/inc/ux_api.h index 11969cc..1aafec1 100755 --- a/common/core/inc/ux_api.h +++ b/common/core/inc/ux_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* ux_api.h PORTABLE C */ -/* 6.1.5 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -83,6 +83,10 @@ /* resulting in version 6.1.4 */ /* 03-02-2021 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1.5 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added macros for Word/DWord */ +/* to bytes extraction, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ @@ -217,7 +221,7 @@ typedef signed char SCHAR; #define AZURE_RTOS_USBX #define USBX_MAJOR_VERSION 6 #define USBX_MINOR_VERSION 1 -#define USBX_PATCH_VERSION 5 +#define USBX_PATCH_VERSION 6 /* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */ @@ -233,6 +237,14 @@ typedef signed char SCHAR; #define UX_MIN(a, b) ((a) < (b) ? (a) : (b)) #define UX_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define UX_W0(word) ( (word) & 0xFF) +#define UX_W1(word) (((word) >> 8) & 0xFF) + +#define UX_DW0(dword) ( (dword) & 0xFF) +#define UX_DW1(dword) (((dword) >> 8) & 0xFF) +#define UX_DW2(dword) (((dword) >> 16) & 0xFF) +#define UX_DW3(dword) (((dword) >> 24) & 0xFF) + /* Safe arithmetic check macros. */ #ifndef UX_DISABLE_ARITHMETIC_CHECK diff --git a/common/core/inc/ux_dcd_sim_slave.h b/common/core/inc/ux_dcd_sim_slave.h index f9ebcff..ae7e452 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.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -44,6 +44,10 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added HCD connected to, */ +/* supported bi-dir-endpoints, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ @@ -112,7 +116,12 @@ typedef struct UX_DCD_SIM_SLAVE_STRUCT *ux_dcd_sim_slave_dcd_owner; struct UX_DCD_SIM_SLAVE_ED_STRUCT ux_dcd_sim_slave_ed[UX_DCD_SIM_SLAVE_MAX_ED]; +#ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT + struct UX_DCD_SIM_SLAVE_ED_STRUCT + ux_dcd_sim_slave_ed_in[UX_DCD_SIM_SLAVE_MAX_ED]; +#endif UINT (*ux_dcd_sim_slave_dcd_control_request_process_hub)(UX_SLAVE_TRANSFER *transfer_request); + VOID *ux_dcd_sim_slave_hcd; } UX_DCD_SIM_SLAVE; diff --git a/common/core/inc/ux_hcd_sim_host.h b/common/core/inc/ux_hcd_sim_host.h index 8bf78b9..825552c 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.1.2 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -51,6 +51,9 @@ /* 11-09-2020 Chaoqiong Xiao Modified comment(s), */ /* added HCD uninitialize, */ /* resulting in version 6.1.2 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added port status variable, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ @@ -96,6 +99,7 @@ typedef struct UX_HCD_SIM_HOST_STRUCT *ux_hcd_sim_host_hcd_owner; ULONG ux_hcd_sim_host_hcor; UINT ux_hcd_sim_host_nb_root_hubs; + ULONG ux_hcd_sim_host_port_status[1]; struct UX_HCD_SIM_HOST_ED_STRUCT *ux_hcd_sim_host_ed_list; struct UX_HCD_SIM_HOST_TD_STRUCT diff --git a/common/core/inc/ux_user_sample.h b/common/core/inc/ux_user_sample.h index ea139cf..8142147 100644 --- a/common/core/inc/ux_user_sample.h +++ b/common/core/inc/ux_user_sample.h @@ -26,7 +26,7 @@ /* PORT SPECIFIC C INFORMATION RELEASE */ /* */ /* ux_user.h PORTABLE C */ -/* 6.1.4 */ +/* 6.1.6 */ /* */ /* AUTHOR */ /* */ @@ -51,6 +51,13 @@ /* compile option for using */ /* packet pool from NetX, */ /* resulting in version 6.1.4 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added DFU_UPLOAD option, */ +/* added macro to enable */ +/* device bi-dir-endpoints, */ +/* added macro to disable CDC- */ +/* ACM transmission support, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ @@ -292,6 +299,47 @@ /* #define UX_DEVICE_CLASS_HID_MAX_EVENTS_QUEUE 8 */ + +/* Defined, this macro will disable DFU_UPLOAD support. */ + +/* #define UX_DEVICE_CLASS_DFU_UPLOAD_DISABLE */ + +/* Defined, this macro will enable DFU_GETSTATUS and DFU_GETSTATE in dfuERROR. */ + +/* #define UX_DEVICE_CLASS_DFU_ERROR_GET_ENABLE */ + +/* Defined, this macro will change status mode. + 0 - simple mode, + status is queried from application in dfuDNLOAD-SYNC and dfuMANIFEST-SYNC state, + no bwPollTimeout. + 1 - status is queried from application once requested, + b0-3 : media status + b4-7 : bStatus + b8-31: bwPollTimeout + bwPollTimeout supported. +*/ + +/* #define UX_DEVICE_CLASS_DFU_STATUS_MODE (1) */ + +/* Defined, this value represents the default DFU status bwPollTimeout. + The value is 3 bytes long (max 0xFFFFFFu). + By default the bwPollTimeout is 1 (means 1ms). + */ + +/* #define UX_DEVICE_CLASS_DFU_STATUS_POLLTIMEOUT (1) */ + +/* Defined, this macro will enable custom request process callback. */ + +/* #define UX_DEVICE_CLASS_DFU_CUSTOM_REQUEST_ENABLE */ + +/* Defined, this macro disables CDC ACM non-blocking transmission support. */ + +/* #define UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE */ + +/* Defined, this macro enables device bi-directional-endpoint support. */ + +/* #define UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT */ + /* Defined, this value will only enable the host side of usbx. */ /* #define UX_HOST_SIDE_ONLY */ 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 912d5bf..e73c10f 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.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,9 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* supported bi-dir-endpoints, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_create(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint) @@ -79,9 +82,17 @@ ULONG sim_slave_endpoint_index; /* The simulator slave controller has 16 endpoints maximum. Endpoint 0 is always control. The other endpoints are generic. We can use the endpoint number as an index. */ sim_slave_endpoint_index = endpoint ->ux_slave_endpoint_descriptor.bEndpointAddress & ~(ULONG)UX_ENDPOINT_DIRECTION; - + /* Fetch the address of the physical endpoint. */ +#ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT + ed = ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress == 0) ? + &dcd_sim_slave -> ux_dcd_sim_slave_ed[0] : + ((endpoint -> ux_slave_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) ? + &dcd_sim_slave -> ux_dcd_sim_slave_ed_in[sim_slave_endpoint_index] : + &dcd_sim_slave -> ux_dcd_sim_slave_ed[sim_slave_endpoint_index])); +#else ed = &dcd_sim_slave -> ux_dcd_sim_slave_ed[sim_slave_endpoint_index]; +#endif /* Check the endpoint status, if it is free, reserve it. If not reject this endpoint. */ if ((ed -> ux_sim_slave_ed_status & UX_DCD_SIM_SLAVE_ED_STATUS_USED) == 0) 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 a8b5c69..eec691a 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.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -67,6 +67,9 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* supported bi-dir-endpoints, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_endpoint_status(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG endpoint_index) @@ -75,8 +78,20 @@ UINT _ux_dcd_sim_slave_endpoint_status(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG e UX_DCD_SIM_SLAVE_ED *ed; +#ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT +ULONG ed_addr = endpoint_index; /* Passed value as endpoint address. */ +ULONG ed_dir = ed_addr & UX_ENDPOINT_DIRECTION; +ULONG ed_index = ed_addr & ~UX_ENDPOINT_DIRECTION; + + /* Fetch the address of the physical endpoint. */ + ed = ((ed_addr == 0) ? &dcd_sim_slave -> ux_dcd_sim_slave_ed[0] : + ((ed_dir) ? &dcd_sim_slave -> ux_dcd_sim_slave_ed_in[ed_index] : + &dcd_sim_slave -> ux_dcd_sim_slave_ed[ed_index])); +#else + /* Fetch the address of the physical endpoint. */ ed = &dcd_sim_slave -> ux_dcd_sim_slave_ed[endpoint_index]; +#endif /* Check the endpoint status, if it is free, we have a illegal endpoint. */ if ((ed -> ux_sim_slave_ed_status & UX_DCD_SIM_SLAVE_ED_STATUS_USED) == 0) diff --git a/common/core/src/ux_dcd_sim_slave_initialize.c b/common/core/src/ux_dcd_sim_slave_initialize.c index febc3bf..7af4aa3 100644 --- a/common/core/src/ux_dcd_sim_slave_initialize.c +++ b/common/core/src/ux_dcd_sim_slave_initialize.c @@ -27,6 +27,7 @@ #include "ux_api.h" #include "ux_dcd_sim_slave.h" +#include "ux_hcd_sim_host.h" /**************************************************************************/ @@ -34,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_dcd_sim_slave_initialize PORTABLE C */ -/* 6.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -66,6 +67,10 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added link with HCD, */ +/* set device to full speed, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_initialize(VOID) @@ -73,6 +78,7 @@ UINT _ux_dcd_sim_slave_initialize(VOID) UX_SLAVE_DCD *dcd; UX_DCD_SIM_SLAVE *dcd_sim_slave; +UX_HCD *hcd; /* Get the pointer to the DCD. */ @@ -97,6 +103,19 @@ UX_DCD_SIM_SLAVE *dcd_sim_slave; /* Initialize the function collector for this DCD. */ dcd -> ux_slave_dcd_function = _ux_dcd_sim_slave_function; + /* Link the HCD (always first registered one) to DCD driver. */ + if (_ux_system_host) + { + hcd = _ux_system_host -> ux_system_host_hcd_array; + if (hcd) + { + dcd_sim_slave -> ux_dcd_sim_slave_hcd = (VOID *)hcd; + } + } + + /* Set system to full speed by default. */ + _ux_system_slave -> ux_system_slave_speed = UX_FULL_SPEED_DEVICE; + /* Set the state of the controller to OPERATIONAL now. */ dcd -> ux_slave_dcd_status = UX_DCD_STATUS_OPERATIONAL; 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 820dad5..f2d0dca 100644 --- a/common/core/src/ux_dcd_sim_slave_initialize_complete.c +++ b/common/core/src/ux_dcd_sim_slave_initialize_complete.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_dcd_sim_slave_initialize_complete PORTABLE C */ -/* 6.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -69,6 +69,9 @@ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* prefixed UX to MS_TO_TICK, */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added framework init cases, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_initialize_complete(VOID) @@ -86,9 +89,22 @@ UX_SLAVE_TRANSFER *transfer_request; /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; - /* Slave simulator is a Full speed controller. */ - _ux_system_slave -> ux_system_slave_device_framework = _ux_system_slave -> ux_system_slave_device_framework_full_speed; - _ux_system_slave -> ux_system_slave_device_framework_length = _ux_system_slave -> ux_system_slave_device_framework_length_full_speed; + /* Prepare according to speed. */ + if (_ux_system_slave -> ux_system_slave_speed == UX_HIGH_SPEED_DEVICE) + { + _ux_system_slave -> ux_system_slave_device_framework = + _ux_system_slave -> ux_system_slave_device_framework_high_speed; + _ux_system_slave -> ux_system_slave_device_framework_length = + _ux_system_slave -> ux_system_slave_device_framework_length_high_speed; + } + else + { + _ux_system_slave -> ux_system_slave_device_framework = + _ux_system_slave -> ux_system_slave_device_framework_full_speed; + _ux_system_slave -> ux_system_slave_device_framework_length = + _ux_system_slave -> ux_system_slave_device_framework_length_full_speed; + + } /* Get the device framework pointer. */ device_framework = _ux_system_slave -> ux_system_slave_device_framework; 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 4ed8e3c..0b0bf15 100644 --- a/common/core/src/ux_dcd_sim_slave_state_change.c +++ b/common/core/src/ux_dcd_sim_slave_state_change.c @@ -27,6 +27,7 @@ #include "ux_api.h" #include "ux_dcd_sim_slave.h" +#include "ux_hcd_sim_host.h" /**************************************************************************/ @@ -34,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_dcd_sim_slave_state_change PORTABLE C */ -/* 6.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -68,14 +69,35 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* simulate force disconnect, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_dcd_sim_slave_state_change(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG state) { - UX_PARAMETER_NOT_USED(dcd_sim_slave); +UX_HCD *hcd; + + UX_PARAMETER_NOT_USED(state); + if (state == UX_DEVICE_FORCE_DISCONNECT) + { + + /* Simulate port detach & attach on host side. */ + + /* Get HCD. */ + hcd = (UX_HCD *)dcd_sim_slave -> ux_dcd_sim_slave_hcd; + + /* Something happened on this port. Signal it to the root hub thread. */ + if (hcd) + { + hcd -> ux_hcd_root_hub_signal[0] = 2; + _ux_utility_semaphore_put(&_ux_system_host -> ux_system_host_enum_semaphore); + } + } + /* Nothing to do in simulation mode. */ return(UX_SUCCESS); } diff --git a/common/core/src/ux_device_stack_get_status.c b/common/core/src/ux_device_stack_get_status.c index 8eb364d..73293f1 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.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -70,6 +70,9 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* supported bi-dir-endpoints, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_device_stack_get_status(ULONG request_type, ULONG request_index, ULONG request_length) @@ -143,9 +146,17 @@ ULONG data_length; case UX_REQUEST_TARGET_ENDPOINT: +#ifndef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT + /* This feature returns the halt state of a specific endpoint. The endpoint index is used to retrieve the endpoint container. */ status = dcd -> ux_slave_dcd_function(dcd, UX_DCD_ENDPOINT_STATUS, (VOID *)(ALIGN_TYPE)(request_index & (UINT)~UX_ENDPOINT_DIRECTION)); +#else + + /* This feature returns the halt state of a specific endpoint. The endpoint address + is used to retrieve the endpoint container. */ + status = dcd -> ux_slave_dcd_function(dcd, UX_DCD_ENDPOINT_STATUS, (VOID *)(ALIGN_TYPE)(request_index)); +#endif /* Check the status. We may have a unknown endpoint. */ if (status != UX_ERROR) diff --git a/common/core/src/ux_device_stack_uninitialize.c b/common/core/src/ux_device_stack_uninitialize.c index 71258ee..6d163e2 100644 --- a/common/core/src/ux_device_stack_uninitialize.c +++ b/common/core/src/ux_device_stack_uninitialize.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_device_stack_uninitialize PORTABLE C */ -/* 6.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -65,6 +65,10 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* fixed uninitialize in case */ +/* there is no EP except EP0, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_device_stack_uninitialize(VOID) @@ -110,7 +114,8 @@ ULONG endpoints_found; } /* Free the endpoint pool address in the device container. */ - _ux_utility_memory_free(device -> ux_slave_device_endpoints_pool); + if (device -> ux_slave_device_endpoints_pool) + _ux_utility_memory_free(device -> ux_slave_device_endpoints_pool); /* Free memory for interface pool. */ _ux_utility_memory_free(device -> ux_slave_device_interfaces_pool); diff --git a/common/core/src/ux_hcd_sim_host_initialize.c b/common/core/src/ux_hcd_sim_host_initialize.c index c385e75..ed1cf88 100644 --- a/common/core/src/ux_hcd_sim_host_initialize.c +++ b/common/core/src/ux_hcd_sim_host_initialize.c @@ -27,6 +27,7 @@ #include "ux_api.h" #include "ux_hcd_sim_host.h" +#include "ux_dcd_sim_slave.h" /**************************************************************************/ @@ -34,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _ux_hcd_sim_host_initialize PORTABLE C */ -/* 6.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -74,11 +75,16 @@ /* instead of using them */ /* directly, */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* added link with DCD, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_initialize(UX_HCD *hcd) { +UX_SLAVE_DCD *dcd; +UX_DCD_SIM_SLAVE *dcd_sim_slave; UX_HCD_SIM_HOST *hcd_sim_host; UINT status; @@ -176,11 +182,24 @@ UINT status; return(status); } + /* Link the HCD to DCD driver. */ + if (_ux_system_slave) + { + dcd = &_ux_system_slave -> ux_system_slave_dcd; + if (dcd) + { + dcd_sim_slave = (UX_DCD_SIM_SLAVE *) dcd -> ux_slave_dcd_controller_hardware; + if (dcd_sim_slave) + dcd_sim_slave -> ux_dcd_sim_slave_hcd = (VOID *)hcd; + } + } + /* Get the number of ports on the controller. The number of ports needs to be reflected both for the generic HCD container and the local sim_host container. In the simulator, the number of ports is hardwired to 1 only. */ hcd -> ux_hcd_nb_root_hubs = 1; hcd_sim_host -> ux_hcd_sim_host_nb_root_hubs = 1; + hcd_sim_host -> ux_hcd_sim_host_port_status[0] = UX_PS_CCS | UX_PS_DS_FS; /* Something happened on this port. Signal it to the root hub thread. */ hcd -> ux_hcd_root_hub_signal[0] = 1; 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 8c32526..8711e5f 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.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -93,6 +93,9 @@ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* used changeable status, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ ULONG _ux_hcd_sim_host_port_status_get(UX_HCD_SIM_HOST *hcd_sim_host, ULONG port_index) @@ -114,12 +117,8 @@ ULONG port_status; return(UX_PORT_INDEX_UNKNOWN); } - /* The port is valid, build the status mask for this port. This function - returns always returned a device connected. */ - port_status = UX_PS_CCS; - - /* And this is a Full speed device. */ - port_status |= UX_PS_DS_FS; + /* Returns current port status. */ + port_status = hcd_sim_host -> ux_hcd_sim_host_port_status[port_index]; /* Return port status. */ return(port_status); 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 58e6127..023de41 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.1 */ +/* 6.1.6 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ @@ -77,6 +77,10 @@ /* verified memset and memcpy */ /* cases, */ /* resulting in version 6.1 */ +/* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ +/* fixed control OUT transfer, */ +/* supported bi-dir-endpoints, */ +/* resulting in version 6.1.6 */ /* */ /**************************************************************************/ UINT _ux_hcd_sim_host_transaction_schedule(UX_HCD_SIM_HOST *hcd_sim_host, UX_HCD_SIM_HOST_ED *ed) @@ -94,6 +98,7 @@ ULONG slave_transfer_remaining; UCHAR wake_host; UCHAR wake_slave; ULONG transaction_length; +ULONG td_length; UX_SLAVE_TRANSFER *slave_transfer_request; UX_TRANSFER *transfer_request; ULONG endpoint_index; @@ -124,7 +129,15 @@ UX_SLAVE_DCD *dcd; dcd_sim_slave = (UX_DCD_SIM_SLAVE *) dcd -> ux_slave_dcd_controller_hardware; /* Get the endpoint as seen from the device side. */ +#ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT + slave_ed = ((endpoint -> ux_endpoint_descriptor.bEndpointAddress == 0) ? + &dcd_sim_slave -> ux_dcd_sim_slave_ed[0] : + ((endpoint -> ux_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) ? + &dcd_sim_slave -> ux_dcd_sim_slave_ed_in[endpoint_index] : + &dcd_sim_slave -> ux_dcd_sim_slave_ed[endpoint_index])); +#else slave_ed = &dcd_sim_slave -> ux_dcd_sim_slave_ed[endpoint_index]; +#endif /* Is this ED used? */ if ((slave_ed -> ux_sim_slave_ed_status & UX_DCD_SIM_SLAVE_ED_STATUS_USED) == 0) @@ -155,7 +168,8 @@ UX_SLAVE_DCD *dcd; slave_transfer_request -> ux_slave_transfer_request_actual_length = td -> ux_sim_host_td_length; /* 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, + _ux_utility_memory_copy(slave_transfer_request -> ux_slave_transfer_request_setup, + td -> ux_sim_host_td_buffer, 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. */ @@ -202,20 +216,22 @@ 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); /* Use case of memcpy is verified. */ + td_length = UX_MIN(data_td -> ux_sim_host_td_length, transaction_length); + _ux_utility_memory_copy(slave_transfer_request -> ux_slave_transfer_request_current_data_pointer, + data_td -> ux_sim_host_td_buffer, + 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; + slave_transfer_request -> ux_slave_transfer_request_actual_length += td_length; /* Update the host transfer's actual length. */ transfer_request -> ux_transfer_request_actual_length += transaction_length; /* Decrement the total length. */ - transaction_length -= data_td -> ux_sim_host_td_length; + transaction_length -= td_length; /* Update buffer pointer. */ - slave_transfer_request -> ux_slave_transfer_request_current_data_pointer += data_td -> ux_sim_host_td_length; + slave_transfer_request -> ux_slave_transfer_request_current_data_pointer += td_length; /* Update the td in the head. */ ed -> ux_sim_host_ed_head_td = data_td; |
