Skip to content

Commit

Permalink
apply 6.0.2 patch and add additional architectures and toolchain support
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Larson committed Aug 14, 2020
1 parent 0ae68ff commit 10ad110
Show file tree
Hide file tree
Showing 32 changed files with 4,536 additions and 48 deletions.
7 changes: 5 additions & 2 deletions common/core/inc/ux_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* ux_api.h PORTABLE C */
/* 6.0.1 */
/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand All @@ -49,6 +49,9 @@
/* 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 */
/* */
/**************************************************************************/

Expand Down Expand Up @@ -137,7 +140,7 @@ typedef signed char SCHAR;
#define AZURE_RTOS_USBX
#define USBX_MAJOR_VERSION 6
#define USBX_MINOR_VERSION 0
#define USBX_PATCH_VERSION 1
#define USBX_PATCH_VERSION 2

/* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */

Expand Down
16 changes: 15 additions & 1 deletion common/usbx_device_classes/inc/ux_device_class_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_storage.h PORTABLE C */
/* 6.0 */
/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand All @@ -41,6 +41,9 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
/* added mode related macros, */
/* resulting in version 6.0.2 */
/* */
/**************************************************************************/

Expand Down Expand Up @@ -167,12 +170,23 @@

#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_6 1
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_10 2
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_6 2
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_10 3
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAG_WP 0x80
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_6 4
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_10 8

#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_COMMAND_LENGTH_UFI 12
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_COMMAND_LENGTH_SBC 12

#define UX_SLAVE_CLASS_STORAGE_IEC_MODE_PAGE_PAGE_LENGTH 0x0A

#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_PAGE_LENGTH 0x12
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_CODE 0
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_LENGTH 1
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAGS 2
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAG_WCE (1u<<2)


/* Define Storage Class SCSI request sense command constants. */

Expand Down
33 changes: 20 additions & 13 deletions common/usbx_device_classes/src/ux_device_class_storage_mode_sense.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ UCHAR usbx_device_class_storage_mode_sense_page_cdrom[USBX_DEVICE_CLASS_STORAGE_
#else
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CDROM_LENGTH (0)
#endif
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CACHE_LENGTH (0x12 + 2)
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_IEC_LENGTH (0x0A + 2)
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CACHE_LENGTH (UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_PAGE_LENGTH + 2)
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_IEC_LENGTH (UX_SLAVE_CLASS_STORAGE_IEC_MODE_PAGE_PAGE_LENGTH + 2)

/* Ensure sense pages can fit in the bulk in endpoint's transfer buffer. */
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_ALL_RESPONSE_LENGTH ( \
Expand All @@ -65,7 +65,7 @@ UCHAR usbx_device_class_storage_mode_sense_page_cdrom[USBX_DEVICE_CLASS_STORAGE_
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_storage_mode_sense PORTABLE C */
/* 6.0 */
/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -104,6 +104,11 @@ UCHAR usbx_device_class_storage_mode_sense_page_cdrom[USBX_DEVICE_CLASS_STORAGE_
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
/* used mode related macros, */
/* verified memset and memcpy */
/* cases, */
/* resulting in version 6.0.2 */
/* */
/**************************************************************************/
UINT _ux_device_class_storage_mode_sense(UX_SLAVE_CLASS_STORAGE *storage,
Expand All @@ -120,7 +125,7 @@ ULONG page_code;
ULONG mode_sense_command;
UCHAR read_only_flag;
ULONG response_header_length;
ULONG medium_type_index;
ULONG flags_index;
ULONG mode_data_length;
UCHAR *page_pointer;
ULONG page_length;
Expand All @@ -146,7 +151,7 @@ ULONG page_length;

/* Extract the length to be returned by the cbwcb. */
mode_sense_reply_length = (ULONG) *(cbwcb + UX_SLAVE_CLASS_STORAGE_MODE_SENSE_ALLOCATION_LENGTH_6);
medium_type_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_6;
flags_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_6;
response_header_length = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_6;
}

Expand All @@ -155,7 +160,7 @@ ULONG page_length;

/* Extract the length to be returned by the cbwcb. */
mode_sense_reply_length = _ux_utility_short_get_big_endian(cbwcb + UX_SLAVE_CLASS_STORAGE_MODE_SENSE_ALLOCATION_LENGTH_10);
medium_type_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_10;
flags_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_10;
response_header_length = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_10;
}

Expand All @@ -164,13 +169,13 @@ ULONG page_length;
mode_sense_reply_length = UX_SLAVE_CLASS_STORAGE_BUFFER_SIZE;

/* Ensure memory buffer cleaned. */
_ux_utility_memory_set(transfer_request -> ux_slave_transfer_request_data_pointer, 0, mode_sense_reply_length);
_ux_utility_memory_set(transfer_request -> ux_slave_transfer_request_data_pointer, 0, mode_sense_reply_length); /* Use case of memset is verified. */

/* Establish READ ONLY flag. */
if (storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_media_read_only_flag == UX_TRUE)

/* This device is Read Only. */
read_only_flag = 0x80;
read_only_flag = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAG_WP;

else

Expand All @@ -191,7 +196,7 @@ ULONG page_length;
page_length = USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CDROM_LENGTH;

/* Copy page data. */
_ux_utility_memory_copy(page_pointer, usbx_device_class_storage_mode_sense_page_cdrom, page_length);
_ux_utility_memory_copy(page_pointer, usbx_device_class_storage_mode_sense_page_cdrom, page_length); /* Use case of memcpy is verified. */

/* Update pointer and length. */
mode_data_length += page_length;
Expand All @@ -210,10 +215,12 @@ ULONG page_length;
*(page_pointer) = UX_SLAVE_CLASS_STORAGE_PAGE_CODE_CACHE;

/* Store the length of the page data. */
*(page_pointer + 1) = 0x12;
*(page_pointer + UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_LENGTH) =
UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_PAGE_LENGTH;

/* Set the Write Cache Enabled (WCE) bit. */
*(page_pointer + 2) |= 0x04;
*(page_pointer + UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAGS) |=
UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAG_WCE;

mode_data_length += page_length;
page_pointer += page_length;
Expand All @@ -229,7 +236,7 @@ ULONG page_length;
*(page_pointer) = UX_SLAVE_CLASS_STORAGE_PAGE_CODE_IEC;

/* Store the length of the page data. */
*(page_pointer + 1) = 0x0A;
*(page_pointer + 1) = UX_SLAVE_CLASS_STORAGE_IEC_MODE_PAGE_PAGE_LENGTH;

mode_data_length += page_length;
page_pointer += page_length;
Expand All @@ -242,7 +249,7 @@ ULONG page_length;
_ux_utility_short_put_big_endian(transfer_request -> ux_slave_transfer_request_data_pointer, (USHORT)mode_data_length);

/* Store the write protection flag. */
*(transfer_request -> ux_slave_transfer_request_data_pointer + medium_type_index + 1) = read_only_flag;
*(transfer_request -> ux_slave_transfer_request_data_pointer + flags_index) = read_only_flag;

/* Send a payload with the response buffer. */
_ux_device_stack_transfer_request(transfer_request, mode_sense_reply_length, mode_sense_reply_length);
Expand Down
8 changes: 6 additions & 2 deletions common/usbx_host_classes/inc/ux_host_class_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_host_class_hid.h PORTABLE C */
/* 6.0 */
/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand All @@ -41,6 +41,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
/* fixed struct field */
/* definition issues, */
/* resulting in version 6.0.2 */
/* */
/**************************************************************************/

Expand Down Expand Up @@ -847,7 +851,7 @@ typedef struct UX_HOST_CLASS_HID_FIELD_STRUCT
ULONG ux_host_class_hid_field_number_usage;
ULONG *ux_host_class_hid_field_values;
ULONG ux_host_class_hid_field_number_values;
struct UX_HOST_CLASS_HID_REPORT
struct UX_HOST_CLASS_HID_REPORT_STRUCT
*ux_host_class_hid_field_report;
struct UX_HOST_CLASS_HID_FIELD_STRUCT
*ux_host_class_hid_field_next_field;
Expand Down
25 changes: 24 additions & 1 deletion common/usbx_host_classes/src/ux_host_class_hid_idle_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hid_idle_get PORTABLE C */
/* 6.0 */
/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -70,6 +70,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
/* protected default control */
/* endpoint before using it, */
/* resulting in version 6.0.2 */
/* */
/**************************************************************************/
UINT _ux_host_class_hid_idle_get(UX_HOST_CLASS_HID *hid, USHORT *idle_time, USHORT report_id)
Expand Down Expand Up @@ -116,6 +120,25 @@ UINT status;
return(UX_MEMORY_INSUFFICIENT);
}

/* Protect the control endpoint semaphore here. It will be unprotected in the
transfer request function. */
status = _ux_utility_semaphore_get(&hid -> ux_host_class_hid_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);

/* Check for status. */
if (status != UX_SUCCESS)
{

/* Something went wrong. */

/* Free allocated memory. */
_ux_utility_memory_free(idle_byte);

/* Unprotect thread reentry to this instance. */
_ux_utility_semaphore_put(&hid -> ux_host_class_hid_semaphore);

return(status);
}

/* Create a transfer request for the GET_IDLE request. */
transfer_request -> ux_transfer_request_data_pointer = idle_byte;
transfer_request -> ux_transfer_request_requested_length = 1;
Expand Down
21 changes: 20 additions & 1 deletion common/usbx_host_classes/src/ux_host_class_hid_idle_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hid_idle_set PORTABLE C */
/* 6.0 */
/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -70,6 +70,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
/* protected default control */
/* endpoint before using it, */
/* resulting in version 6.0.2 */
/* */
/**************************************************************************/
UINT _ux_host_class_hid_idle_set(UX_HOST_CLASS_HID *hid, USHORT idle_time, USHORT report_id)
Expand Down Expand Up @@ -97,6 +101,21 @@ UINT status;
if (status != UX_SUCCESS)
return(status);

/* Protect the control endpoint semaphore here. It will be unprotected in the
transfer request function. */
status = _ux_utility_semaphore_get(&hid -> ux_host_class_hid_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);

/* Check for status. */
if (status != UX_SUCCESS)
{

/* Something went wrong. */
/* Unprotect thread reentry to this instance. */
_ux_utility_semaphore_put(&hid -> ux_host_class_hid_semaphore);

return(status);
}

/* We need to get the default control endpoint transfer request pointer. */
control_endpoint = &hid -> ux_host_class_hid_device -> ux_device_control_endpoint;
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
Expand Down
14 changes: 10 additions & 4 deletions common/usbx_host_classes/src/ux_host_class_hid_report_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hid_report_get PORTABLE C */
/* 6.0 */
/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -75,6 +75,11 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
/* verified memset and memcpy */
/* cases, accepted both INPUT */
/* and FEATURE reports, */
/* resulting in version 6.0.2 */
/* */
/**************************************************************************/
UINT _ux_host_class_hid_report_get(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report)
Expand Down Expand Up @@ -112,8 +117,9 @@ UINT status;
/* Get the report pointer from the caller. */
hid_report = client_report -> ux_host_class_hid_client_report;

/* Ensure this is a INPUT report. */
if (hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_INPUT)
/* Ensure this is a INPUT report or FEATURE report. */
if (hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_INPUT &&
hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_FEATURE)
{

/* Unprotect thread reentry to this instance. */
Expand Down Expand Up @@ -202,7 +208,7 @@ UINT status;
{

/* We have enough memory to store the raw buffer. */
_ux_utility_memory_copy(client_report -> ux_host_class_hid_client_report_buffer, report_buffer, transfer_request -> ux_transfer_request_actual_length);
_ux_utility_memory_copy(client_report -> ux_host_class_hid_client_report_buffer, report_buffer, transfer_request -> ux_transfer_request_actual_length); /* Use case of memcpy is verified. */

/* Set status to success. */
status = UX_SUCCESS;
Expand Down
Loading

0 comments on commit 10ad110

Please sign in to comment.