Skip to content

Commit 10ad110

Browse files
author
Scott Larson
committed
apply 6.0.2 patch and add additional architectures and toolchain support
1 parent 0ae68ff commit 10ad110

File tree

32 files changed

+4536
-48
lines changed

32 files changed

+4536
-48
lines changed

common/core/inc/ux_api.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* APPLICATION INTERFACE DEFINITION RELEASE */
2727
/* */
2828
/* ux_api.h PORTABLE C */
29-
/* 6.0.1 */
29+
/* 6.0.2 */
3030
/* AUTHOR */
3131
/* */
3232
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -49,6 +49,9 @@
4949
/* avoided div 0 in overflow */
5050
/* checking macro, */
5151
/* resulting in version 6.0.1 */
52+
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), and */
53+
/* updated product constants, */
54+
/* resulting in version 6.0.2 */
5255
/* */
5356
/**************************************************************************/
5457

@@ -137,7 +140,7 @@ typedef signed char SCHAR;
137140
#define AZURE_RTOS_USBX
138141
#define USBX_MAJOR_VERSION 6
139142
#define USBX_MINOR_VERSION 0
140-
#define USBX_PATCH_VERSION 1
143+
#define USBX_PATCH_VERSION 2
141144

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

common/usbx_device_classes/inc/ux_device_class_storage.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* COMPONENT DEFINITION RELEASE */
2727
/* */
2828
/* ux_device_class_storage.h PORTABLE C */
29-
/* 6.0 */
29+
/* 6.0.2 */
3030
/* AUTHOR */
3131
/* */
3232
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -41,6 +41,9 @@
4141
/* DATE NAME DESCRIPTION */
4242
/* */
4343
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
44+
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
45+
/* added mode related macros, */
46+
/* resulting in version 6.0.2 */
4447
/* */
4548
/**************************************************************************/
4649

@@ -167,12 +170,23 @@
167170

168171
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_6 1
169172
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_10 2
173+
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_6 2
174+
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_10 3
175+
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAG_WP 0x80
170176
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_6 4
171177
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_10 8
172178

173179
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_COMMAND_LENGTH_UFI 12
174180
#define UX_SLAVE_CLASS_STORAGE_MODE_SENSE_COMMAND_LENGTH_SBC 12
175181

182+
#define UX_SLAVE_CLASS_STORAGE_IEC_MODE_PAGE_PAGE_LENGTH 0x0A
183+
184+
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_PAGE_LENGTH 0x12
185+
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_CODE 0
186+
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_LENGTH 1
187+
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAGS 2
188+
#define UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAG_WCE (1u<<2)
189+
176190

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

common/usbx_device_classes/src/ux_device_class_storage_mode_sense.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ UCHAR usbx_device_class_storage_mode_sense_page_cdrom[USBX_DEVICE_CLASS_STORAGE_
4747
#else
4848
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CDROM_LENGTH (0)
4949
#endif
50-
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CACHE_LENGTH (0x12 + 2)
51-
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_IEC_LENGTH (0x0A + 2)
50+
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CACHE_LENGTH (UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_PAGE_LENGTH + 2)
51+
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_IEC_LENGTH (UX_SLAVE_CLASS_STORAGE_IEC_MODE_PAGE_PAGE_LENGTH + 2)
5252

5353
/* Ensure sense pages can fit in the bulk in endpoint's transfer buffer. */
5454
#define USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_ALL_RESPONSE_LENGTH ( \
@@ -65,7 +65,7 @@ UCHAR usbx_device_class_storage_mode_sense_page_cdrom[USBX_DEVICE_CLASS_STORAGE_
6565
/* FUNCTION RELEASE */
6666
/* */
6767
/* _ux_device_class_storage_mode_sense PORTABLE C */
68-
/* 6.0 */
68+
/* 6.0.2 */
6969
/* AUTHOR */
7070
/* */
7171
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -104,6 +104,11 @@ UCHAR usbx_device_class_storage_mode_sense_page_cdrom[USBX_DEVICE_CLASS_STORAGE_
104104
/* DATE NAME DESCRIPTION */
105105
/* */
106106
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
107+
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
108+
/* used mode related macros, */
109+
/* verified memset and memcpy */
110+
/* cases, */
111+
/* resulting in version 6.0.2 */
107112
/* */
108113
/**************************************************************************/
109114
UINT _ux_device_class_storage_mode_sense(UX_SLAVE_CLASS_STORAGE *storage,
@@ -120,7 +125,7 @@ ULONG page_code;
120125
ULONG mode_sense_command;
121126
UCHAR read_only_flag;
122127
ULONG response_header_length;
123-
ULONG medium_type_index;
128+
ULONG flags_index;
124129
ULONG mode_data_length;
125130
UCHAR *page_pointer;
126131
ULONG page_length;
@@ -146,7 +151,7 @@ ULONG page_length;
146151

147152
/* Extract the length to be returned by the cbwcb. */
148153
mode_sense_reply_length = (ULONG) *(cbwcb + UX_SLAVE_CLASS_STORAGE_MODE_SENSE_ALLOCATION_LENGTH_6);
149-
medium_type_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_6;
154+
flags_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_6;
150155
response_header_length = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_6;
151156
}
152157

@@ -155,7 +160,7 @@ ULONG page_length;
155160

156161
/* Extract the length to be returned by the cbwcb. */
157162
mode_sense_reply_length = _ux_utility_short_get_big_endian(cbwcb + UX_SLAVE_CLASS_STORAGE_MODE_SENSE_ALLOCATION_LENGTH_10);
158-
medium_type_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_MEDIUM_TYPE_10;
163+
flags_index = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAGS_10;
159164
response_header_length = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_HEADER_LENGTH_10;
160165
}
161166

@@ -164,13 +169,13 @@ ULONG page_length;
164169
mode_sense_reply_length = UX_SLAVE_CLASS_STORAGE_BUFFER_SIZE;
165170

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

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

172177
/* This device is Read Only. */
173-
read_only_flag = 0x80;
178+
read_only_flag = UX_SLAVE_CLASS_STORAGE_MODE_SENSE_PARAMETER_FLAG_WP;
174179

175180
else
176181

@@ -191,7 +196,7 @@ ULONG page_length;
191196
page_length = USBX_DEVICE_CLASS_STORAGE_MODE_SENSE_PAGE_CDROM_LENGTH;
192197

193198
/* Copy page data. */
194-
_ux_utility_memory_copy(page_pointer, usbx_device_class_storage_mode_sense_page_cdrom, page_length);
199+
_ux_utility_memory_copy(page_pointer, usbx_device_class_storage_mode_sense_page_cdrom, page_length); /* Use case of memcpy is verified. */
195200

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

212217
/* Store the length of the page data. */
213-
*(page_pointer + 1) = 0x12;
218+
*(page_pointer + UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_LENGTH) =
219+
UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_PAGE_LENGTH;
214220

215221
/* Set the Write Cache Enabled (WCE) bit. */
216-
*(page_pointer + 2) |= 0x04;
222+
*(page_pointer + UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAGS) |=
223+
UX_SLAVE_CLASS_STORAGE_CACHING_MODE_PAGE_FLAG_WCE;
217224

218225
mode_data_length += page_length;
219226
page_pointer += page_length;
@@ -229,7 +236,7 @@ ULONG page_length;
229236
*(page_pointer) = UX_SLAVE_CLASS_STORAGE_PAGE_CODE_IEC;
230237

231238
/* Store the length of the page data. */
232-
*(page_pointer + 1) = 0x0A;
239+
*(page_pointer + 1) = UX_SLAVE_CLASS_STORAGE_IEC_MODE_PAGE_PAGE_LENGTH;
233240

234241
mode_data_length += page_length;
235242
page_pointer += page_length;
@@ -242,7 +249,7 @@ ULONG page_length;
242249
_ux_utility_short_put_big_endian(transfer_request -> ux_slave_transfer_request_data_pointer, (USHORT)mode_data_length);
243250

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

247254
/* Send a payload with the response buffer. */
248255
_ux_device_stack_transfer_request(transfer_request, mode_sense_reply_length, mode_sense_reply_length);

common/usbx_host_classes/inc/ux_host_class_hid.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* COMPONENT DEFINITION RELEASE */
2727
/* */
2828
/* ux_host_class_hid.h PORTABLE C */
29-
/* 6.0 */
29+
/* 6.0.2 */
3030
/* AUTHOR */
3131
/* */
3232
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -41,6 +41,10 @@
4141
/* DATE NAME DESCRIPTION */
4242
/* */
4343
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
44+
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
45+
/* fixed struct field */
46+
/* definition issues, */
47+
/* resulting in version 6.0.2 */
4448
/* */
4549
/**************************************************************************/
4650

@@ -847,7 +851,7 @@ typedef struct UX_HOST_CLASS_HID_FIELD_STRUCT
847851
ULONG ux_host_class_hid_field_number_usage;
848852
ULONG *ux_host_class_hid_field_values;
849853
ULONG ux_host_class_hid_field_number_values;
850-
struct UX_HOST_CLASS_HID_REPORT
854+
struct UX_HOST_CLASS_HID_REPORT_STRUCT
851855
*ux_host_class_hid_field_report;
852856
struct UX_HOST_CLASS_HID_FIELD_STRUCT
853857
*ux_host_class_hid_field_next_field;

common/usbx_host_classes/src/ux_host_class_hid_idle_get.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/* FUNCTION RELEASE */
3636
/* */
3737
/* _ux_host_class_hid_idle_get PORTABLE C */
38-
/* 6.0 */
38+
/* 6.0.2 */
3939
/* AUTHOR */
4040
/* */
4141
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -70,6 +70,10 @@
7070
/* DATE NAME DESCRIPTION */
7171
/* */
7272
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
73+
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
74+
/* protected default control */
75+
/* endpoint before using it, */
76+
/* resulting in version 6.0.2 */
7377
/* */
7478
/**************************************************************************/
7579
UINT _ux_host_class_hid_idle_get(UX_HOST_CLASS_HID *hid, USHORT *idle_time, USHORT report_id)
@@ -116,6 +120,25 @@ UINT status;
116120
return(UX_MEMORY_INSUFFICIENT);
117121
}
118122

123+
/* Protect the control endpoint semaphore here. It will be unprotected in the
124+
transfer request function. */
125+
status = _ux_utility_semaphore_get(&hid -> ux_host_class_hid_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
126+
127+
/* Check for status. */
128+
if (status != UX_SUCCESS)
129+
{
130+
131+
/* Something went wrong. */
132+
133+
/* Free allocated memory. */
134+
_ux_utility_memory_free(idle_byte);
135+
136+
/* Unprotect thread reentry to this instance. */
137+
_ux_utility_semaphore_put(&hid -> ux_host_class_hid_semaphore);
138+
139+
return(status);
140+
}
141+
119142
/* Create a transfer request for the GET_IDLE request. */
120143
transfer_request -> ux_transfer_request_data_pointer = idle_byte;
121144
transfer_request -> ux_transfer_request_requested_length = 1;

common/usbx_host_classes/src/ux_host_class_hid_idle_set.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/* FUNCTION RELEASE */
3636
/* */
3737
/* _ux_host_class_hid_idle_set PORTABLE C */
38-
/* 6.0 */
38+
/* 6.0.2 */
3939
/* AUTHOR */
4040
/* */
4141
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -70,6 +70,10 @@
7070
/* DATE NAME DESCRIPTION */
7171
/* */
7272
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
73+
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
74+
/* protected default control */
75+
/* endpoint before using it, */
76+
/* resulting in version 6.0.2 */
7377
/* */
7478
/**************************************************************************/
7579
UINT _ux_host_class_hid_idle_set(UX_HOST_CLASS_HID *hid, USHORT idle_time, USHORT report_id)
@@ -97,6 +101,21 @@ UINT status;
97101
if (status != UX_SUCCESS)
98102
return(status);
99103

104+
/* Protect the control endpoint semaphore here. It will be unprotected in the
105+
transfer request function. */
106+
status = _ux_utility_semaphore_get(&hid -> ux_host_class_hid_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
107+
108+
/* Check for status. */
109+
if (status != UX_SUCCESS)
110+
{
111+
112+
/* Something went wrong. */
113+
/* Unprotect thread reentry to this instance. */
114+
_ux_utility_semaphore_put(&hid -> ux_host_class_hid_semaphore);
115+
116+
return(status);
117+
}
118+
100119
/* We need to get the default control endpoint transfer request pointer. */
101120
control_endpoint = &hid -> ux_host_class_hid_device -> ux_device_control_endpoint;
102121
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;

common/usbx_host_classes/src/ux_host_class_hid_report_get.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/* FUNCTION RELEASE */
3636
/* */
3737
/* _ux_host_class_hid_report_get PORTABLE C */
38-
/* 6.0 */
38+
/* 6.0.2 */
3939
/* AUTHOR */
4040
/* */
4141
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -75,6 +75,11 @@
7575
/* DATE NAME DESCRIPTION */
7676
/* */
7777
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
78+
/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
79+
/* verified memset and memcpy */
80+
/* cases, accepted both INPUT */
81+
/* and FEATURE reports, */
82+
/* resulting in version 6.0.2 */
7883
/* */
7984
/**************************************************************************/
8085
UINT _ux_host_class_hid_report_get(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report)
@@ -112,8 +117,9 @@ UINT status;
112117
/* Get the report pointer from the caller. */
113118
hid_report = client_report -> ux_host_class_hid_client_report;
114119

115-
/* Ensure this is a INPUT report. */
116-
if (hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_INPUT)
120+
/* Ensure this is a INPUT report or FEATURE report. */
121+
if (hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_INPUT &&
122+
hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_FEATURE)
117123
{
118124

119125
/* Unprotect thread reentry to this instance. */
@@ -202,7 +208,7 @@ UINT status;
202208
{
203209

204210
/* We have enough memory to store the raw buffer. */
205-
_ux_utility_memory_copy(client_report -> ux_host_class_hid_client_report_buffer, report_buffer, transfer_request -> ux_transfer_request_actual_length);
211+
_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. */
206212

207213
/* Set status to success. */
208214
status = UX_SUCCESS;

0 commit comments

Comments
 (0)