summaryrefslogtreecommitdiff
path: root/common/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/core/src')
-rw-r--r--common/core/src/ux_device_stack_descriptor_send.c12
-rw-r--r--common/core/src/ux_system_initialize.c19
-rw-r--r--common/core/src/ux_utility_descriptor_pack.c89
-rw-r--r--common/core/src/ux_utility_descriptor_parse.c176
-rw-r--r--common/core/src/ux_utility_memory_allocate.c7
5 files changed, 225 insertions, 78 deletions
diff --git a/common/core/src/ux_device_stack_descriptor_send.c b/common/core/src/ux_device_stack_descriptor_send.c
index f8dae5a..4ce10a8 100644
--- a/common/core/src/ux_device_stack_descriptor_send.c
+++ b/common/core/src/ux_device_stack_descriptor_send.c
@@ -91,6 +91,8 @@
/* resulting in version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* moved compile option check, */
+/* added support for get string*/
+/* requests with zero wIndex, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
@@ -399,6 +401,16 @@ ULONG string_length;
}
else
{
+#ifdef UX_DEVICE_ENABLE_GET_STRING_WITH_ZERO_LANGUAGE_ID
+
+ /* Check if the language ID is zero. */
+ if (request_index == 0)
+ {
+
+ /* Get the first language ID in the language ID framework. */
+ request_index = _ux_utility_short_get(_ux_system_slave -> ux_system_slave_language_id_framework);
+ }
+#endif
/* The host wants a specific string index returned. Get the string framework pointer
and length. */
diff --git a/common/core/src/ux_system_initialize.c b/common/core/src/ux_system_initialize.c
index f6f7202..06fc65e 100644
--- a/common/core/src/ux_system_initialize.c
+++ b/common/core/src/ux_system_initialize.c
@@ -69,7 +69,7 @@ UCHAR _ux_system_container_id_descriptor_structure[] = {1,1
/* FUNCTION RELEASE */
/* */
/* _ux_system_initialize PORTABLE C */
-/* 6.1.10 */
+/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -115,6 +115,10 @@ UCHAR _ux_system_container_id_descriptor_structure[] = {1,1
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
+/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
+/* added UX_ASSERT check for */
+/* STD descriptor parse size, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _ux_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memory_size,
@@ -313,6 +317,19 @@ UINT _uxe_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memo
VOID *cache_safe_memory_pool_start, ULONG cache_safe_memory_size)
{
+ /* Compiling option check of descriptors structs. */
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_endpoint_descriptor_structure, UX_ENDPOINT_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_ENDPOINT_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_device_descriptor_structure, UX_DEVICE_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_DEVICE_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_configuration_descriptor_structure, UX_CONFIGURATION_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_CONFIGURATION_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_interface_descriptor_structure, UX_INTERFACE_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_INTERFACE_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_interface_association_descriptor_structure, UX_INTERFACE_ASSOCIATION_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_INTERFACE_ASSOCIATION_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_string_descriptor_structure, UX_STRING_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_STRING_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_dfu_functional_descriptor_structure, UX_DFU_FUNCTIONAL_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_DFU_FUNCTIONAL_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_bos_descriptor_structure, UX_BOS_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_BOS_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_usb_2_0_extension_descriptor_structure, UX_USB_2_0_EXTENSION_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_USB_2_0_EXTENSION_DESCRIPTOR));
+ UX_ASSERT((_ux_utility_descriptor_parse_size(_ux_system_container_id_descriptor_structure, UX_CONTAINER_ID_DESCRIPTOR_ENTRIES, 0x3u)) == sizeof(UX_CONTAINER_ID_DESCRIPTOR));
+
+
/* Sanity check. */
if ((regular_memory_pool_start == UX_NULL) || (regular_memory_size == 0))
return(UX_INVALID_PARAMETER);
diff --git a/common/core/src/ux_utility_descriptor_pack.c b/common/core/src/ux_utility_descriptor_pack.c
index 574c56c..bc85c55 100644
--- a/common/core/src/ux_utility_descriptor_pack.c
+++ b/common/core/src/ux_utility_descriptor_pack.c
@@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
-/** */
-/** USBX Component */
+/** */
+/** USBX Component */
/** */
/** Utility */
/** */
@@ -28,50 +28,53 @@
#include "ux_api.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _ux_utility_descriptor_pack PORTABLE C */
-/* 6.1 */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_utility_descriptor_pack PORTABLE C */
+/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
+/* */
/* This function will pack an application structure into a USB */
-/* descriptor. */
-/* */
-/* INPUT */
-/* */
-/* descriptor Pointer to the unpacked */
+/* descriptor. */
+/* */
+/* INPUT */
+/* */
+/* descriptor Pointer to the unpacked */
/* descriptor */
/* descriptor_structure Components of the descriptor */
-/* descriptor_entries Number of entries in the */
+/* descriptor_entries Number of entries in the */
/* descriptor */
/* raw_descriptor Pointer to packed descriptor */
-/* */
-/* OUTPUT */
-/* */
+/* */
+/* OUTPUT */
+/* */
/* None */
-/* */
-/* CALLS */
-/* */
+/* */
+/* CALLS */
+/* */
/* _ux_utility_long_put Put 32-bit value */
/* _ux_utility_short_put Put 16-bit value */
-/* */
-/* CALLED BY */
-/* */
-/* USBX Components */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
-/* */
+/* */
+/* 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), */
/* resulting in version 6.1 */
+/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
+/* optimized USB descriptors, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
VOID _ux_utility_descriptor_pack(UCHAR * descriptor, UCHAR * descriptor_structure,
@@ -90,27 +93,37 @@ VOID _ux_utility_descriptor_pack(UCHAR * descriptor, UCHAR * descriptor_structu
insert it into the target descriptor. */
case 4:
+ /* Increase address so it's aligned. */
+ while((ALIGN_TYPE)descriptor & 3u)
+ descriptor++;
+
+ /* Put the DW. */
_ux_utility_long_put(raw_descriptor, *((ULONG *) descriptor));
raw_descriptor += 4;
- break;
+ descriptor += 4;
+ break;
case 2:
- _ux_utility_short_put(raw_descriptor, (USHORT)*((ULONG *) descriptor));
+ /* Increase address so it's aligned. */
+ while((ALIGN_TYPE)descriptor & 1u)
+ descriptor++;
+
+ /* Put the Word. */
+ _ux_utility_short_put(raw_descriptor, (USHORT)*((USHORT *) descriptor));
raw_descriptor += 2;
- break;
+ descriptor += 2;
+ break;
default:
- *raw_descriptor = (UCHAR) *((ULONG *) descriptor);
+ /* Put the byte. */
+ *raw_descriptor = (UCHAR) *((UCHAR *) descriptor);
raw_descriptor++;
+ descriptor++;
}
-
- /* Add the size of the component to the destination. */
- descriptor += 4;
}
/* Return to caller. */
return;
}
-
diff --git a/common/core/src/ux_utility_descriptor_parse.c b/common/core/src/ux_utility_descriptor_parse.c
index ff23559..86bbd85 100644
--- a/common/core/src/ux_utility_descriptor_parse.c
+++ b/common/core/src/ux_utility_descriptor_parse.c
@@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
-/** */
-/** USBX Component */
+/** */
+/** USBX Component */
/** */
/** Utility */
/** */
@@ -28,50 +28,53 @@
#include "ux_api.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _ux_utility_descriptor_parse PORTABLE C */
-/* 6.1 */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_utility_descriptor_parse PORTABLE C */
+/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
+/* */
/* This function will unpack a USB descriptor from the bus into a */
-/* memory aligned structure. */
-/* */
-/* INPUT */
-/* */
+/* memory aligned structure. */
+/* */
+/* INPUT */
+/* */
/* raw_descriptor Pointer to packed descriptor */
/* descriptor_structure Components of the descriptor */
-/* descriptor_entries Number of entries in the */
+/* descriptor_entries Number of entries in the */
/* descriptor */
-/* descriptor Pointer to the unpacked */
+/* descriptor Pointer to the unpacked */
/* descriptor */
-/* */
-/* OUTPUT */
-/* */
+/* */
+/* OUTPUT */
+/* */
/* None */
-/* */
-/* CALLS */
-/* */
+/* */
+/* CALLS */
+/* */
/* _ux_utility_long_get Get 32-bit value */
/* _ux_utility_short_get Get 16-bit value */
-/* */
-/* CALLED BY */
-/* */
-/* USBX Components */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
-/* */
+/* */
+/* 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), */
/* resulting in version 6.1 */
+/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
+/* optimized USB descriptors, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
VOID _ux_utility_descriptor_parse(UCHAR * raw_descriptor, UCHAR * descriptor_structure,
@@ -90,27 +93,126 @@ VOID _ux_utility_descriptor_parse(UCHAR * raw_descriptor, UCHAR * descriptor_st
insert it into the target descriptor. */
case 4:
+ /* Padding zeros so address is aligned. */
+ while((ALIGN_TYPE) descriptor & 3u)
+ *descriptor++ = 0;
+
+ /* Save the DW. */
*((ULONG *) descriptor) = _ux_utility_long_get(raw_descriptor);
raw_descriptor += 4;
- break;
+ descriptor += 4;
+ break;
case 2:
- *((ULONG *) descriptor) = (ULONG) _ux_utility_short_get(raw_descriptor);
+ /* Padding zeros so address is aligned. */
+ while((ALIGN_TYPE) descriptor & 1u)
+ *descriptor++ = 0;
+
+ /* Save the word. */
+ *((USHORT *) descriptor) = (USHORT) _ux_utility_short_get(raw_descriptor);
raw_descriptor += 2;
- break;
+ descriptor += 2;
+ break;
default:
- *((ULONG *) descriptor) = (ULONG) *raw_descriptor;
+ /* Save the byte. */
+ *((UCHAR *) descriptor) = (UCHAR) *raw_descriptor;
raw_descriptor++;
+ descriptor ++;
}
-
- /* Add the size of the component to the destination. */
- descriptor += 4;
}
/* Return to caller. */
return;
}
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_utility_descriptor_parse_size PORTABLE C */
+/* 6.x */
+/* AUTHOR */
+/* */
+/* Chaoqiong Xiao, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function will calculate the size of a parsed USB descriptor. */
+/* */
+/* INPUT */
+/* */
+/* descriptor_structure Components of the descriptor */
+/* descriptor_entries Number of entries in the */
+/* descriptor */
+/* size_align_mask Size alignment mask */
+/* */
+/* OUTPUT */
+/* */
+/* size Size of the parsed descriptor */
+/* */
+/* CALLS */
+/* */
+/* None */
+/* */
+/* CALLED BY */
+/* */
+/* USBX Components */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
+/* */
+/**************************************************************************/
+ULONG _ux_utility_descriptor_parse_size(UCHAR * descriptor_structure, UINT descriptor_entries, UINT size_align_mask)
+{
+
+ULONG size = 0;
+ULONG entry_size;
+
+ /* Loop on all the entries in this descriptor. */
+ while(descriptor_entries--)
+ {
+
+ /* Get entry size. */
+ entry_size = (ULONG)*descriptor_structure ++;
+
+ /* Check the size then build the component from the source and
+ insert it into the target descriptor. */
+ switch(entry_size)
+ {
+
+ case 4: /* Fall through. */
+ case 2:
+
+ /* Padding zeros so address is aligned. */
+ while(size & (entry_size - 1))
+ size++;
+
+ /* Add to the size. */
+ size += entry_size;
+ break;
+
+ case 1:
+
+ /* Add to the size. */
+ size += 1;
+ break;
+
+ default:
+
+ /* Invalid entry size. */
+ return(0);
+ }
+ }
+
+ /* Align the size. */
+ size = (size + size_align_mask) & (~size_align_mask);
+
+ /* Return the size. */
+ return(size);
+}
diff --git a/common/core/src/ux_utility_memory_allocate.c b/common/core/src/ux_utility_memory_allocate.c
index 48d8620..547b03d 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.1.11 */
+/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -77,6 +77,9 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* internal clean up, */
/* resulting in version 6.1.11 */
+/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
+/* fixed issue in 64-bit env, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
VOID *_ux_utility_memory_allocate(ULONG memory_alignment, ULONG memory_cache_flag,
@@ -306,7 +309,7 @@ ALIGN_TYPE int_memory_buffer;
{
/* Setup the leftover memory block. */
- leftover_memory_block = (UX_MEMORY_BLOCK *) (((ALIGN_TYPE) new_memory_block + sizeof(UX_MEMORY_BLOCK) + memory_size_requested) & 0xFFFFFFFFu);
+ leftover_memory_block = (UX_MEMORY_BLOCK *) (((ALIGN_TYPE) new_memory_block + sizeof(UX_MEMORY_BLOCK) + memory_size_requested));
leftover_memory_block -> ux_memory_block_next = new_memory_block -> ux_memory_block_next;
leftover_memory_block -> ux_memory_block_previous = new_memory_block;
leftover_memory_block -> ux_memory_block_size = leftover - (ULONG)sizeof(UX_MEMORY_BLOCK);