Update on 23 Oct 2023. Expand to see details.

52c60057 Update headers and readme for 6.3.0 release.
5360ad52 Host H264 frame support.
4b097e80 Add javascript to codeql detection
70278ae3 Fixed use after free issues.
5560620e Improved standalone enum transfer flow. Turn off ASIX in standalone build. Im...
39a01206 Improved host HID clients (mouse/keyboard/remote control) deactivation sequence.
be2c7fd5 Improved standalone host CDC ACM control and data instance link management (MSRC 81489,81570)
c2368eb2 Improved AC AS management and error handing.
b9c23b38 PIMA Host/device optional interrupt endpoint support and host unused semaphore removal.
34ca3af9 Removed interface link in class linked to device.
5d3c9dd0 Improved endpoints get error handling (host CDC-ECM/ACM, storage). Moved stor...
71b08ad1 Improved host audio descriptors validation
4717e3f1 Enable weekly pipeline build to avoid CodeQL expiration
ca408b54 Checked XML tag nesting depth in Pictbridge object parsing
c300a00c Limited pictbridge array element to hexa output array size.
0e644aaa Reject fake CDC-ECM data interface not located next to its control interface.
911007a9 Improved host HID usage handling.
d0576877 Enable dummy check of python for CodeQL
2761e105 Fixed some split transfer issue.
db0dbeda Added packet length validation for received nx packet.
f5007249 Fix PIMA issues on data set extraction
3ec66399 Fixing device RNDIS bugs with zero copy
1ec77d6b Fix device HID issue when adding class memory man and zero copy.
d52e55c0 Add zero copy support in device printer
a5cb883f Added zero copy support in device CDC_ECM and RNDIS
1f967ae2 Enable codeql in onebranch pipeline
de265dbc Enable zero copy for device audio and video
53aee275 Refined memory management to reduce overhead.
This commit is contained in:
Chaoqiong Xiao 2023-10-23 05:31:40 +00:00
parent 7c928b43db
commit 26585e42dc
347 changed files with 3854 additions and 2595 deletions

View File

@ -185,6 +185,8 @@ target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_memory_copy.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_memory_free.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_memory_free_block_best_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_memory_byte_pool_create.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_memory_byte_pool_search.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_memory_set.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_mutex_create.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_utility_mutex_delete.c

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_dpump.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -50,10 +50,10 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -25,7 +25,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_stack.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -53,9 +53,9 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_host_stack.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -65,9 +65,9 @@
/* names conflict C++ keyword, */
/* added standalone HUB, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_system.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -53,9 +53,9 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* added device CCID name, */
/* resulting in version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -26,7 +26,7 @@
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* ux_user.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* */
/* AUTHOR */
/* */
@ -99,14 +99,15 @@
/* added option to enable */
/* basic USBX error checking, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Xiuwen Cai, CQ Xiao Modified comment(s), */
/* 10-31-2023 Xiuwen Cai, CQ Xiao Modified comment(s), */
/* refined memory management, */
/* added zero copy support */
/* in many device classes, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* added option for get string */
/* requests with zero wIndex, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -141,8 +142,8 @@
also refer to ux_port.h for descriptions on each of these options. */
/* Defined, this value represents minimal allocated memory alignment in number of bytes.
The default is UX_ALIGN_16 (0x0f) to align allocated memory to 16 bytes. */
/* #define UX_ALIGN_MIN UX_ALIGN_16 */
The default is UX_ALIGN_8 (0x07) to align allocated memory to 8 bytes. */
/* #define UX_ALIGN_MIN UX_ALIGN_8 */
/* Defined, this value represents how many ticks per seconds for a specific hardware platform.
The default is 1000 indicating 1 tick per millisecond. */
@ -239,7 +240,7 @@
*/
/* #define UX_DEVICE_CLASS_CDC_ACM_ZERO_COPY */
/* Defined, it enables zero copy and flexible queue support (works if HID owns endpoint buffer).
/* Defined, it enables device HID zero copy and flexible queue support (works if HID owns endpoint buffer).
Enabled, the internal queue buffer is directly used for transfer, the APIs are kept to keep
backword compatibility, to AVOID KEEPING BUFFERS IN APPLICATION.
Flexible queue introduces initialization parameter _event_max_number and _event_max_length,
@ -252,6 +253,27 @@
*/
/* #define UX_DEVICE_CLASS_HID_ZERO_COPY */
/* Defined, it enables device CDC_ECM zero copy support (works if CDC_ECM owns endpoint buffer).
Enabled, it requires that the NX IP default packet pool is in cache safe area, and buffer max
size is larger than UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE (1536).
*/
/* #define UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY */
/* Defined, it enables device RNDIS zero copy support (works if RNDIS owns endpoint buffer).
Enabled, it requires that the NX IP default packet pool is in cache safe area, and buffer max
size is larger than UX_DEVICE_CLASS_RNDIS_MAX_PACKET_TRANSFER_SIZE (1600).
*/
/* #define UX_DEVICE_CLASS_RNDIS_ZERO_COPY */
/* Defined, it enables zero copy support (works if PRINTER owns endpoint buffer).
Defined, it enables zero copy for bulk in/out endpoints (write/read). In this case, the endpoint
buffer is not allocated in class, application must provide the buffer for read/write, and the
buffer must meet device controller driver (DCD) buffer requirements (e.g., aligned and cache
safe if buffer is for DMA).
*/
/* #define UX_DEVICE_CLASS_PRINTER_ZERO_COPY */
/* Defined, this value represents the maximum number of bytes that can be received or transmitted
on any endpoint. This value cannot be less than the maximum packet size of any endpoint. The default
is 4096 bytes but can be reduced in memory constrained environments. For cd-rom support in the storage

View File

@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** USBX Component */
/** */
/** Utility */
/** */
@ -26,20 +26,20 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_utility.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* */
/* This file contains all the header and extern functions used by the */
/* USBX components that utilize utility functions. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* USBX components that utilize utility functions. */
/* */
/* RELEASE HISTORY */
/* */
/* 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 */
@ -57,10 +57,11 @@
/* added macros for RTOS calls,*/
/* fixed OHCI PRSC issue, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* refined memory management, */
/* added new function to check */
/* parsed size of descriptor, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -86,9 +87,10 @@ VOID _ux_utility_memory_copy(VOID *memory_destination, VOID *memory_
VOID _ux_utility_memory_free(VOID *memory);
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);
UCHAR *_ux_utility_memory_byte_pool_search(UX_MEMORY_BYTE_POOL *pool_ptr, ULONG memory_size);
UINT _ux_utility_memory_byte_pool_create(UX_MEMORY_BYTE_POOL *pool_ptr, VOID *pool_start, ULONG pool_size);
VOID _ux_utility_memory_set(VOID *destination, UCHAR value, ULONG length);
ULONG _ux_utility_pci_class_scan(ULONG pci_class, ULONG bus_number, ULONG device_number,
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);
ULONG _ux_utility_pci_read(ULONG bus_number, ULONG device_number, ULONG function_number,
@ -116,9 +118,9 @@ UINT _ux_utility_semaphore_create(UX_SEMAPHORE *semaphore, CHAR *sem
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);
UINT _ux_utility_thread_create(UX_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,
VOID *stack_start, ULONG stack_size,
UINT priority, UINT preempt_threshold,
ULONG time_slice, UINT auto_start);
UINT _ux_utility_thread_delete(UX_THREAD *thread_ptr);
@ -129,12 +131,12 @@ UINT _ux_utility_thread_sleep(ULONG ticks);
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,
ULONG expiration_input, ULONG initial_ticks, ULONG reschedule_ticks,
UINT activation_flag);
UINT _ux_utility_timer_delete(UX_TIMER *timer);
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 _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(UX_EVENT_FLAGS_GROUP*group_ptr, ULONG flags_to_set,
UINT set_option);
@ -399,7 +401,7 @@ VOID* _ux_utility_memory_allocate_add_safe(ULONG align,ULONG cache,UL
/* Define the system API mappings.
Note: this section is only applicable to
Note: this section is only applicable to
application source code, hence the conditional that turns off this
stuff when the include file is processed by the ThreadX source. */
@ -450,8 +452,8 @@ VOID* _ux_utility_memory_allocate_add_safe(ULONG align,ULONG cache,UL
#define ux_utility_event_flags_set _ux_utility_event_flags_set
#define ux_utility_unicode_to_string _ux_utility_unicode_to_string
#define ux_utility_string_to_unicode _ux_utility_string_to_unicode
#define ux_utility_delay_ms _ux_utility_delay_ms
#define ux_utility_error_callback_register _ux_utility_error_callback_register
#define ux_utility_delay_ms _ux_utility_delay_ms
#define ux_utility_error_callback_register _ux_utility_error_callback_register
#define ux_system_error_handler _ux_system_error_handler
#define ux_utility_time_get _ux_utility_time_get

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_activate PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -73,10 +73,10 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_activate(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_change PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -76,10 +76,10 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_change(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,10 +70,10 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_initialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_read PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,10 +70,10 @@
/* verified memset and memcpy */
/* cases, */
/* resulting in version 6.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_read(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,

View File

@ -39,7 +39,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_read_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,10 +78,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_read_run(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_write PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,10 +70,10 @@
/* verified memset and memcpy */
/* cases, */
/* resulting in version 6.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_write(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,

View File

@ -39,7 +39,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dpump_write_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,10 +78,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 01-31-2022 Chaoqiong Xiao Initial Version 6.1.10 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dpump_write_run(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,

View File

@ -172,7 +172,7 @@ ULONG class_index;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_stack_class_register PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -206,7 +206,7 @@ ULONG class_index;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_stack_class_register(UCHAR *class_name,

View File

@ -156,7 +156,7 @@ ULONG class_index;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_stack_class_unregister PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -187,7 +187,7 @@ ULONG class_index;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_stack_class_unregister(UCHAR *class_name,

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_control_request_process PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -94,10 +94,10 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* fixed vendor request issue, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* improved interface request */
/* process with print class, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_stack_control_request_process(UX_SLAVE_TRANSFER *transfer_request)

View File

@ -41,7 +41,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_descriptor_send PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -89,11 +89,11 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* moved compile option check, */
/* added support for get string*/
/* requests with zero wIndex, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_stack_descriptor_send(ULONG descriptor_type, ULONG request_index, ULONG host_length)

View File

@ -54,7 +54,7 @@ UX_SYSTEM_SLAVE *_ux_system_slave;
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -109,10 +109,10 @@ UX_SYSTEM_SLAVE *_ux_system_slave;
/* added CCID support, */
/* added video support, */
/* resulting in version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_stack_initialize(UCHAR * device_framework_high_speed, ULONG device_framework_length_high_speed,
@ -474,7 +474,7 @@ UCHAR *memory;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_stack_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -505,7 +505,7 @@ UCHAR *memory;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_stack_initialize(UCHAR * device_framework_high_speed, ULONG device_framework_length_high_speed,

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_stack_uninitialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -72,10 +72,10 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_stack_uninitialize(VOID)

View File

@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** USBX Component */
/** */
/** Host Simulator Controller Driver */
/** */
@ -30,43 +30,43 @@
#include "ux_dcd_sim_slave.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_sim_host_initialize PORTABLE C */
/* 6.1.10 */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_sim_host_initialize PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function initializes the simulated host controller */
/* */
/* INPUT */
/* */
/* HCD Pointer to HCD */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_hcd_sim_host_periodic_tree_create Create periodic tree */
/* _ux_utility_memory_allocate Allocate memory block */
/* _ux_utility_semaphore_put Semaphore put */
/* _ux_utility_timer_create Create timer */
/* */
/* CALLED BY */
/* */
/* */
/* This function initializes the simulated host controller */
/* */
/* INPUT */
/* */
/* HCD Pointer to HCD */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_hcd_sim_host_periodic_tree_create Create periodic tree */
/* _ux_utility_memory_allocate Allocate memory block */
/* _ux_utility_semaphore_put Semaphore put */
/* _ux_utility_timer_create Create timer */
/* */
/* CALLED BY */
/* */
/* Host Simulator Controller Driver */
/* */
/* 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 based on compile */
@ -81,6 +81,9 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* refined memory management, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_hcd_sim_host_initialize(UX_HCD *hcd)
@ -89,12 +92,12 @@ 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;
UINT status = UX_ERROR;
/* The controller initialized here is of host simulator type. */
hcd -> ux_hcd_controller_type = UX_HCD_SIM_HOST_CONTROLLER;
/* Allocate memory for this host simulator HCD instance. */
hcd_sim_host = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_HCD_SIM_HOST));
if (hcd_sim_host == UX_NULL)
@ -119,14 +122,17 @@ UINT status;
hcd -> ux_hcd_status = UX_HCD_STATUS_HALTED;
/* Allocate the list of EDs. All EDs are allocated on 16 byte memory boundary. */
hcd_sim_host -> ux_hcd_sim_host_ed_list = _ux_utility_memory_allocate(UX_ALIGN_16, UX_REGULAR_MEMORY, (ULONG)sizeof(UX_HCD_SIM_HOST_ED) * _ux_system_host -> ux_system_host_max_ed);
if (hcd_sim_host -> ux_hcd_sim_host_ed_list == UX_NULL)
status = UX_MEMORY_INSUFFICIENT;
else
status = UX_SUCCESS;
if (_ux_system_host -> ux_system_host_max_ed != 0)
{
hcd_sim_host -> ux_hcd_sim_host_ed_list = _ux_utility_memory_allocate(UX_ALIGN_16, UX_REGULAR_MEMORY, (ULONG)sizeof(UX_HCD_SIM_HOST_ED) * _ux_system_host -> ux_system_host_max_ed);
if (hcd_sim_host -> ux_hcd_sim_host_ed_list == UX_NULL)
status = UX_MEMORY_INSUFFICIENT;
else
status = UX_SUCCESS;
}
/* Allocate the list of TDs. All TDs are allocated on 32 byte memory boundary. */
if (status == UX_SUCCESS)
if ((status == UX_SUCCESS) && (_ux_system_host -> ux_system_host_max_td != 0))
{
hcd_sim_host -> ux_hcd_sim_host_td_list = _ux_utility_memory_allocate(UX_ALIGN_32, UX_REGULAR_MEMORY, (ULONG)sizeof(UX_HCD_SIM_HOST_TD) * _ux_system_host -> ux_system_host_max_td);
if (hcd_sim_host -> ux_hcd_sim_host_td_list == UX_NULL)
@ -134,7 +140,7 @@ UINT status;
}
/* Allocate the list of isochronous TDs. All TDs are allocated on 32 byte memory boundary. */
if (status == UX_SUCCESS)
if ((status == UX_SUCCESS) && (_ux_system_host -> ux_system_host_max_iso_td != 0))
{
hcd_sim_host -> ux_hcd_sim_host_iso_td_list = _ux_utility_memory_allocate(UX_ALIGN_32, UX_REGULAR_MEMORY, (ULONG)sizeof(UX_HCD_SIM_HOST_ISO_TD) * _ux_system_host -> ux_system_host_max_iso_td);
if (hcd_sim_host -> ux_hcd_sim_host_iso_td_list == UX_NULL)
@ -156,7 +162,7 @@ UINT status;
/* The periodic scheduler is not active. */
hcd_sim_host -> ux_hcd_sim_host_periodic_scheduler_active = 0;
/* We start a timer that will invoke the simulator every timer tick. */
status = _ux_host_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, UX_AUTO_ACTIVATE);
@ -197,7 +203,7 @@ UINT status;
}
}
/* Get the number of ports on the controller. The number of ports needs to be reflected both
/* 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;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_sim_host_uninitialize PORTABLE C */
/* 6.1.10 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,6 +70,9 @@
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* refined memory management, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_hcd_sim_host_uninitialize(UX_HCD_SIM_HOST *hcd_sim_host)
@ -115,9 +118,14 @@ UINT td_index;
#endif
/* 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);
if (hcd_sim_host -> ux_hcd_sim_host_iso_td_list)
_ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_iso_td_list);
if (hcd_sim_host -> ux_hcd_sim_host_td_list)
_ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_td_list);
if (hcd_sim_host -> ux_hcd_sim_host_ed_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);

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_class_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -78,8 +78,8 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_host_stack_class_get(UCHAR *class_name, UX_HOST_CLASS **host_class)
@ -145,7 +145,7 @@ ULONG class_index;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_class_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -175,7 +175,7 @@ ULONG class_index;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_class_get(UCHAR *class_name, UX_HOST_CLASS **host_class)

View File

@ -119,7 +119,7 @@ VOID **current_class_instance;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_class_instance_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -151,7 +151,7 @@ VOID **current_class_instance;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_class_instance_get(UX_HOST_CLASS *host_class, UINT class_index, VOID **class_instance)

View File

@ -180,7 +180,7 @@ ULONG class_index;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_class_register PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -211,7 +211,7 @@ ULONG class_index;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_class_register(UCHAR *class_name,

View File

@ -193,7 +193,7 @@ UX_INTERFACE *current_interface;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_configuration_interface_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -227,7 +227,7 @@ UX_INTERFACE *current_interface;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_configuration_interface_get(UX_CONFIGURATION *configuration,

View File

@ -191,7 +191,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_device_configuration_activate PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -222,7 +222,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_device_configuration_activate(UX_CONFIGURATION *configuration)

View File

@ -200,7 +200,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_device_configuration_deactivate PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -231,7 +231,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_device_configuration_deactivate(UX_DEVICE *device)

View File

@ -140,7 +140,7 @@ UX_CONFIGURATION *current_configuration;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_device_configuration_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -173,7 +173,7 @@ UX_CONFIGURATION *current_configuration;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_device_configuration_get(UX_DEVICE *device, UINT configuration_index,

View File

@ -155,7 +155,7 @@ ULONG current_device_index;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_device_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -185,7 +185,7 @@ ULONG current_device_index;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_device_get(ULONG device_index, UX_DEVICE **device)

View File

@ -154,7 +154,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_device_string_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -190,7 +190,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_device_string_get(UX_DEVICE *device, UCHAR *descriptor_buffer, ULONG length, ULONG language_id, ULONG string_index)

View File

@ -98,7 +98,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_endpoint_transfer_abort PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -129,7 +129,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_endpoint_transfer_abort(UX_ENDPOINT *endpoint)

View File

@ -163,7 +163,7 @@ ULONG hcd_index;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_hcd_register PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -193,7 +193,7 @@ ULONG hcd_index;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_hcd_register(UCHAR *hcd_name,

View File

@ -202,7 +202,7 @@ UINT hcd_name_length = 0;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_hcd_unregister PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -234,7 +234,7 @@ UINT hcd_name_length = 0;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_hcd_unregister(UCHAR *hcd_name,

View File

@ -142,7 +142,7 @@ UX_ENDPOINT *current_endpoint;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_interface_endpoint_get PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -174,7 +174,7 @@ UX_ENDPOINT *current_endpoint;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_interface_endpoint_get(UX_INTERFACE *interface_ptr, UINT endpoint_index, UX_ENDPOINT **endpoint)

View File

@ -221,7 +221,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_interface_setting_select PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -252,7 +252,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_interface_setting_select(UX_INTERFACE *interface_ptr)

View File

@ -44,7 +44,7 @@ static inline VOID _ux_host_stack_pending_transfers_run(VOID);
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_tasks_run PORTABLE C */
/* 6.2.0 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -110,6 +110,9 @@ static inline VOID _ux_host_stack_pending_transfers_run(VOID);
/* fixed activation issue on */
/* no class linked interfaces, */
/* resulting in version 6.2.0 */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* improved enum transfer, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_host_stack_tasks_run(VOID)
@ -200,8 +203,8 @@ static inline VOID _ux_host_stack_enum_address_sent(UX_DEVICE *device)
{
/* Address (request wValue) applied to device. */
device -> ux_device_address =
device -> ux_device_enum_trans -> ux_transfer_request_value;
device -> ux_device_address = device -> ux_device_control_endpoint.
ux_endpoint_transfer_request.ux_transfer_request_value & 0x7F;
device -> ux_device_state = UX_DEVICE_ADDRESSED;
/* Unlock enumeration. */
@ -625,7 +628,7 @@ INT immediate_state = UX_TRUE;
case UX_HOST_STACK_ENUM_DEVICE_ADDR_SENT:
/* Transfer error check. */
trans = device -> ux_device_enum_trans;
trans = &device -> ux_device_control_endpoint.ux_endpoint_transfer_request;
if (trans -> ux_transfer_request_completion_code != UX_SUCCESS)
{
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_RETRY;
@ -659,7 +662,7 @@ INT immediate_state = UX_TRUE;
case UX_HOST_STACK_ENUM_DEVICE_DESCR_PARSE:
/* Transfer error check. */
trans = device -> ux_device_enum_trans;
trans = &device -> ux_device_control_endpoint.ux_endpoint_transfer_request;
buffer = trans -> ux_transfer_request_data_pointer;
if (UX_HOST_STACK_ENUM_TRANS_ERROR(trans))
{
@ -707,6 +710,7 @@ INT immediate_state = UX_TRUE;
trans -> ux_transfer_request_requested_length = UX_DEVICE_DESCRIPTOR_LENGTH;
/* Issue GetDescriptor(Device) again and parse it. */
device -> ux_device_enum_trans = trans;
UX_TRANSFER_STATE_RESET(trans);
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_TRANS_WAIT;
device -> ux_device_enum_next_state = UX_HOST_STACK_ENUM_DEVICE_DESCR_PARSE;
@ -744,7 +748,7 @@ INT immediate_state = UX_TRUE;
case UX_HOST_STACK_ENUM_CONFIG_DESCR_PARSE:
/* Transfer error check. */
trans = device -> ux_device_enum_trans;
trans = &device -> ux_device_control_endpoint.ux_endpoint_transfer_request;
buffer = trans -> ux_transfer_request_data_pointer;
if (UX_HOST_STACK_ENUM_TRANS_ERROR(trans))
{
@ -792,6 +796,7 @@ INT immediate_state = UX_TRUE;
configuration -> ux_configuration_descriptor.wTotalLength;
/* Start transfer again. */
device -> ux_device_enum_trans = trans;
UX_TRANSFER_STATE_RESET(device -> ux_device_enum_trans);
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_TRANS_WAIT;
device -> ux_device_enum_next_state = UX_HOST_STACK_ENUM_CONFIG_DESCR_PARSE;
@ -866,7 +871,7 @@ INT immediate_state = UX_TRUE;
continue;
case UX_HOST_STACK_ENUM_CONFIG_ACTIVATE:
trans = device -> ux_device_enum_trans;
trans = &device -> ux_device_control_endpoint.ux_endpoint_transfer_request;
if (UX_HOST_STACK_ENUM_TRANS_ERROR(trans))
{
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_RETRY;
@ -960,6 +965,7 @@ INT immediate_state = UX_TRUE;
/* Transfer done - next state. */
if (status == UX_STATE_NEXT || status == UX_STATE_IDLE)
{
device -> ux_device_enum_trans = UX_NULL;
device -> ux_device_enum_state = device -> ux_device_enum_next_state;
continue;
}
@ -979,6 +985,7 @@ INT immediate_state = UX_TRUE;
_ux_utility_memory_free(device -> ux_device_enum_inst.ptr);
device -> ux_device_enum_inst.ptr = UX_NULL;
}
device -> ux_device_enum_trans = UX_NULL;
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_FAIL;
continue;
}
@ -996,6 +1003,7 @@ INT immediate_state = UX_TRUE;
_ux_utility_memory_free(device -> ux_device_enum_inst.ptr);
device -> ux_device_enum_inst.ptr = UX_NULL;
}
device -> ux_device_enum_trans = UX_NULL;
device -> ux_device_enum_state = UX_HOST_STACK_ENUM_RETRY;
continue;
}

View File

@ -224,7 +224,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_transfer_request PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -253,7 +253,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_transfer_request(UX_TRANSFER *transfer_request)

View File

@ -153,7 +153,7 @@ ULONG completion_code;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_transfer_request_abort PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -183,7 +183,7 @@ ULONG completion_code;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_transfer_request_abort(UX_TRANSFER *transfer_request)

View File

@ -300,7 +300,7 @@ UX_TRANSFER *previous;
/* FUNCTION RELEASE */
/* */
/* _uxe_host_stack_transfer_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -329,7 +329,7 @@ UX_TRANSFER *previous;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_host_stack_transfer_run(UX_TRANSFER *transfer_request)

View File

@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** USBX Component */
/** */
/** System */
/** */
@ -64,46 +64,46 @@ UCHAR _ux_system_usb_2_0_extension_descriptor_structure[] = {1,1
UCHAR _ux_system_container_id_descriptor_structure[] = {1,1,1,1,4,4,4,4};
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_system_initialize PORTABLE C */
/* 6.x */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_system_initialize PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function initializes the various control data structures for */
/* the USBX system. */
/* */
/* INPUT */
/* */
/* */
/* This function initializes the various control data structures for */
/* the USBX system. */
/* */
/* INPUT */
/* */
/* regular_memory_pool_start Start of non cached memory pool */
/* regular_memory_size Size of non cached memory pool */
/* regular_memory_size Size of non cached memory pool */
/* cache_safe_memory_pool_start Start of cached memory pool */
/* cache_safe_memory_size Size of cached memory pool */
/* */
/* OUTPUT */
/* */
/* cache_safe_memory_size Size of cached memory pool */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* */
/* CALLS */
/* */
/* _ux_utility_memory_allocate Allocate memory */
/* _ux_utility_memory_set Set memory */
/* _ux_utility_memory_set Set memory */
/* _ux_utility_mutex_create Create mutex */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* */
/* 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), */
/* verified memset and memcpy */
@ -115,24 +115,28 @@ 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* refined memory management, */
/* added UX_ASSERT check for */
/* STD descriptor parse size, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memory_size,
UINT _ux_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memory_size,
VOID *cache_safe_memory_pool_start, ULONG cache_safe_memory_size)
{
UX_MEMORY_BLOCK *memory_block;
ALIGN_TYPE int_memory_pool_start;
VOID *regular_memory_pool_end;
VOID *cache_safe_memory_pool_end;
ULONG memory_pool_offset;
#if !defined(UX_STANDALONE)
UINT status;
#endif
ULONG pool_size;
/* Check if the regular memory pool is valid. */
if ((regular_memory_pool_start == UX_NULL) || (regular_memory_size == 0))
return(UX_INVALID_PARAMETER);
/* Reset memory block */
_ux_utility_memory_set(regular_memory_pool_start, 0, regular_memory_size); /* Use case of memset is verified. */
@ -150,8 +154,8 @@ UINT status;
/* Add to the memory offset the size of the allocated block. */
memory_pool_offset += (ULONG)sizeof(UX_SYSTEM_HOST);
#endif
#endif
#ifndef UX_HOST_SIDE_ONLY
@ -160,8 +164,8 @@ UINT status;
/* Add to the memory offset the size of the allocated block. */
memory_pool_offset += (ULONG)sizeof(UX_SYSTEM_SLAVE);
#endif
#endif
#ifdef UX_OTG_SUPPORT
@ -171,18 +175,36 @@ UINT status;
/* Add to the memory offset the size of the allocated block. */
memory_pool_offset += (ULONG)sizeof(UX_SYSTEM_OTG);
#endif
#endif
/* Set the regular memory pool structure. */
_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] = (UX_MEMORY_BYTE_POOL *) (((UCHAR *) regular_memory_pool_start) + memory_pool_offset);
/* Set the cache safe memory for the dynamic pool */
_ux_system -> ux_system_regular_memory_pool_start = (UX_MEMORY_BLOCK *) (((UCHAR *) regular_memory_pool_start)
+ memory_pool_offset);
/* Add to the memory offset the size of the allocated block. */
memory_pool_offset += (ULONG)sizeof(UX_MEMORY_BYTE_POOL);
/* Check if the cache save memory pool is valid. */
if ((cache_safe_memory_pool_start != UX_NULL) && (cache_safe_memory_size != 0))
{
/* Set the cache safe memory pool structure. */
_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE] = (UX_MEMORY_BYTE_POOL *) (((UCHAR *) regular_memory_pool_start) + memory_pool_offset);
/* Add to the memory offset the size of the allocated block. */
memory_pool_offset += (ULONG)sizeof(UX_MEMORY_BYTE_POOL);
}
else
{
/* Set the cache safe memory pool structure to regular pool. */
_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE] = _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR];
}
/* Make sure the regular memory pool is aligned properly */
int_memory_pool_start = (ALIGN_TYPE) _ux_system -> ux_system_regular_memory_pool_start;
int_memory_pool_start += UX_ALIGN_MIN;
int_memory_pool_start &= ~((ALIGN_TYPE)UX_ALIGN_MIN);
int_memory_pool_start = (ALIGN_TYPE) (((UCHAR *) regular_memory_pool_start) + memory_pool_offset);
int_memory_pool_start += UX_ALIGN_MIN;
int_memory_pool_start &= ~((ALIGN_TYPE)UX_ALIGN_MIN);
/* Set the end of the regular memory pool. */
regular_memory_pool_end = (void *) (((UCHAR *) regular_memory_pool_start) + regular_memory_size);
@ -194,53 +216,48 @@ UINT status;
return(UX_MEMORY_INSUFFICIENT);
}
/* Now, we have a project structure allocated, save the regular memory allocation details */
_ux_system -> ux_system_regular_memory_pool_size = (ULONG) (((ALIGN_TYPE) regular_memory_pool_end) - int_memory_pool_start);
_ux_system -> ux_system_regular_memory_pool_free = _ux_system -> ux_system_regular_memory_pool_size;
_ux_system -> ux_system_regular_memory_pool_start = (UX_MEMORY_BLOCK *) int_memory_pool_start;
/* get the regular memory pool size. */
pool_size = (ULONG) (((ALIGN_TYPE) regular_memory_pool_end) - int_memory_pool_start);
/* Build the first free memory block */
memory_block = _ux_system -> ux_system_regular_memory_pool_start;
memory_block -> ux_memory_block_size = _ux_system -> ux_system_regular_memory_pool_size - (ULONG)sizeof(UX_MEMORY_BLOCK);
memory_block -> ux_memory_block_status = UX_MEMORY_UNUSED;
/* Create the regular memory pool. */
_ux_utility_memory_byte_pool_create(_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR],
(UX_MEMORY_BYTE_POOL *)int_memory_pool_start,
pool_size);
/* Check the definition of the cache safe pool. If the application or controller do not require any cache safe memory,
define the cached safe memory region as the regular memory region. */
if (cache_safe_memory_pool_start == UX_NULL)
if ((cache_safe_memory_pool_start != UX_NULL) && (cache_safe_memory_size != 0))
{
/* Cache safe memory is the same as regular memory. */
_ux_system -> ux_system_cache_safe_memory_pool_size = _ux_system -> ux_system_regular_memory_pool_size;
_ux_system -> ux_system_cache_safe_memory_pool_free = _ux_system -> ux_system_regular_memory_pool_free;
_ux_system -> ux_system_cache_safe_memory_pool_start = _ux_system -> ux_system_regular_memory_pool_start;
}
else
{
/* Reset this memory block */
_ux_utility_memory_set(cache_safe_memory_pool_start, 0, cache_safe_memory_size); /* Use case of memset is verified. */
/* Make sure the cache safe memory pool is aligned properly */
int_memory_pool_start = (ALIGN_TYPE) cache_safe_memory_pool_start;
int_memory_pool_start += UX_ALIGN_MIN;
int_memory_pool_start &= ~((ALIGN_TYPE)UX_ALIGN_MIN);
/* Save the cache safe memory allocation details */
_ux_system -> ux_system_cache_safe_memory_pool_size = cache_safe_memory_size - UX_ALIGN_MIN;
_ux_system -> ux_system_cache_safe_memory_pool_free = _ux_system -> ux_system_cache_safe_memory_pool_size;
_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); /* Use case of memset is verified. */
/* Build the first free memory block */
memory_block = _ux_system -> ux_system_cache_safe_memory_pool_start;
memory_block -> ux_memory_block_size = _ux_system -> ux_system_cache_safe_memory_pool_size - (ULONG)sizeof(UX_MEMORY_BLOCK);
memory_block -> ux_memory_block_status = UX_MEMORY_UNUSED;
cache_safe_memory_pool_end = (void *) (((UCHAR *) cache_safe_memory_pool_start) + cache_safe_memory_size);
/* Check if we have memory available. */
if (int_memory_pool_start >= (ALIGN_TYPE) cache_safe_memory_pool_end)
{
/* No memory available. */
return(UX_MEMORY_INSUFFICIENT);
}
pool_size = (ULONG) (((ALIGN_TYPE) cache_safe_memory_pool_end) - int_memory_pool_start);
_ux_utility_memory_byte_pool_create(_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE],
(UX_MEMORY_BYTE_POOL *)int_memory_pool_start, pool_size);
}
#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;
_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] -> ux_byte_pool_min_free =
_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] -> ux_byte_pool_available;
_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE] -> ux_byte_pool_min_free =
_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE] -> ux_byte_pool_available;
/* Other fields are kept zero. */
#endif
@ -255,10 +272,10 @@ UINT status;
/* Setup the head and tail pointers. */
_ux_system -> ux_system_debug_log_head = _ux_system -> ux_system_debug_log_buffer;
_ux_system -> ux_system_debug_log_tail = _ux_system -> ux_system_debug_log_buffer;
/* Keep the size in system structure variable. */
_ux_system -> ux_system_debug_log_size = UX_DEBUG_LOG_SIZE;
#endif
#if !defined(UX_STANDALONE)
@ -278,7 +295,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_system_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -310,10 +327,10 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memory_size,
UINT _uxe_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memory_size,
VOID *cache_safe_memory_pool_start, ULONG cache_safe_memory_size)
{
@ -333,8 +350,8 @@ UINT _uxe_system_initialize(VOID *regular_memory_pool_start, ULONG regular_memo
/* Sanity check. */
if ((regular_memory_pool_start == UX_NULL) || (regular_memory_size == 0))
return(UX_INVALID_PARAMETER);
/* Invoke system initialization function. */
return(_ux_system_initialize(regular_memory_pool_start, regular_memory_size,
return(_ux_system_initialize(regular_memory_pool_start, regular_memory_size,
cache_safe_memory_pool_start, cache_safe_memory_size));
}

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_utility_descriptor_pack PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -72,9 +72,9 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* optimized USB descriptors, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_utility_descriptor_pack(UCHAR * descriptor, UCHAR * descriptor_structure,

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_utility_descriptor_parse PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -72,9 +72,9 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* optimized USB descriptors, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_utility_descriptor_parse(UCHAR * raw_descriptor, UCHAR * descriptor_structure,
@ -133,7 +133,7 @@ VOID _ux_utility_descriptor_parse(UCHAR * raw_descriptor, UCHAR * descriptor_st
/* FUNCTION RELEASE */
/* */
/* _ux_utility_descriptor_parse_size PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -165,7 +165,7 @@ VOID _ux_utility_descriptor_parse(UCHAR * raw_descriptor, UCHAR * descriptor_st
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Chaoqiong Xiao Initial Version 6.x */
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
/* */
/**************************************************************************/
ULONG _ux_utility_descriptor_parse_size(UCHAR * descriptor_structure, UINT descriptor_entries, UINT size_align_mask)

View File

@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** USBX Component */
/** */
/** Utility */
/** */
@ -27,45 +27,44 @@
#include "ux_api.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_allocate PORTABLE C */
/* 6.x */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_allocate PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function allocates a block of memory for the specified size */
/* */
/* This function allocates a block of memory for the specified size */
/* and alignment. */
/* */
/* INPUT */
/* */
/* memory_alignment Memory alignment required */
/* memory_cache_flag Memory pool source */
/* memory_size_requested Number of bytes required */
/* */
/* OUTPUT */
/* */
/* Pointer to block of memory */
/* */
/* CALLS */
/* */
/* _ux_utility_memory_free_block_best_get Get best fit block of memory */
/* _ux_utility_memory_set Set block of memory */
/* */
/* CALLED BY */
/* */
/* USBX Components */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* */
/* INPUT */
/* */
/* memory_alignment Memory alignment required */
/* memory_cache_flag Memory pool source */
/* memory_size_requested Number of bytes required */
/* */
/* OUTPUT */
/* */
/* Pointer to block of memory */
/* */
/* CALLS */
/* */
/* _ux_utility_memory_free_block_best_get Get best fit block of memory */
/* _ux_utility_memory_set Set block of memory */
/* */
/* 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), */
/* verified memset and memcpy */
@ -77,24 +76,54 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* refined memory management, */
/* fixed issue in 64-bit env, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID *_ux_utility_memory_allocate(ULONG memory_alignment, ULONG memory_cache_flag,
ULONG memory_size_requested)
{
UX_MEMORY_BYTE_POOL *pool_ptr;
UCHAR *current_ptr;
UCHAR *work_ptr;
UCHAR *next_ptr;
ALIGN_TYPE *free_ptr;
UCHAR **this_block_link_ptr;
UCHAR **next_block_link_ptr;
ULONG available_bytes;
UX_MEMORY_BLOCK *memory_block;
UX_MEMORY_BLOCK *new_memory_block;
UX_MEMORY_BLOCK *leftover_memory_block;
ULONG memory_for_alignment;
ULONG memory_removed_from_pool;
ULONG leftover;
UCHAR *memory_buffer;
ALIGN_TYPE int_memory_buffer;
#ifdef UX_ENABLE_MEMORY_STATISTICS
UINT index;
#endif
/* Get the pool ptr */
if (memory_cache_flag == UX_REGULAR_MEMORY)
{
pool_ptr = _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR];
}
else if (memory_cache_flag == UX_CACHE_SAFE_MEMORY)
{
pool_ptr = _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE];
}
else
{
return(UX_NULL);
}
/* Check if pool_ptr is NX_NULL */
if (pool_ptr == UX_NULL)
{
return(UX_NULL);
}
/* Check if the memory size requested is 0. */
if (memory_size_requested == 0)
{
return(UX_NULL);
}
/* Get the mutex as this is a critical section. */
_ux_system_mutex_on(&_ux_system -> ux_system_mutex);
@ -105,99 +134,58 @@ ALIGN_TYPE int_memory_buffer;
if (memory_alignment == UX_SAFE_ALIGN)
{
/* We will use the memory_size_requested for the alignment.
/* We will use the memory_size_requested for the alignment.
But we check to see if we have a minimum or maximum alignment. */
if (memory_size_requested < UX_ALIGN_MIN)
/* No need to bother about alignment for small packets sizes. */
memory_alignment = UX_NO_ALIGN;
/* Check if we are over the maximum. */
else if (memory_size_requested > UX_MAX_SCATTER_GATHER_ALIGNMENT)
/* We are over the max alignment required. Use the maximum instead. */
memory_alignment = UX_MAX_SCATTER_GATHER_ALIGNMENT - 1;
/* We are not over the maximum, so approximate the alignment according to the size of the memory.
Check range for alignment on 4096 bytes. */
else if (memory_size_requested >= UX_ALIGN_2048 + 1)
memory_alignment = UX_ALIGN_4096;
/* Check range for alignment on 2048 bytes. */
else if (memory_size_requested >= UX_ALIGN_1024 + 1)
memory_alignment = UX_ALIGN_2048;
/* Check range for alignment on 1024 bytes. */
else if (memory_size_requested >= UX_ALIGN_512 + 1)
memory_alignment = UX_ALIGN_1024;
/* Check range for alignment on 512 bytes. */
else if (memory_size_requested >= UX_ALIGN_256 + 1)
memory_alignment = UX_ALIGN_512;
/* Check range for alignment on 256 bytes. */
else if (memory_size_requested >= UX_ALIGN_128 + 1)
memory_alignment = UX_ALIGN_256;
/* Check range for alignment on 128 bytes. */
else if (memory_size_requested >= UX_ALIGN_64 + 1)
memory_alignment = UX_ALIGN_128;
/* Check range for alignment on 64 bytes. */
else if (memory_size_requested >= UX_ALIGN_32 + 1)
memory_alignment = UX_ALIGN_64;
/* Check range for alignment on 32 bytes. */
else if (memory_size_requested >= UX_ALIGN_16 + 1)
memory_alignment = UX_ALIGN_32;
/* Check range for alignment on 16 bytes. */
else if (memory_size_requested >= UX_ALIGN_8 + 1)
memory_alignment = UX_ALIGN_16;
else
{
/* Check if we are over the maximum. */
if (memory_size_requested > UX_MAX_SCATTER_GATHER_ALIGNMENT)
/* We are over the max alignment required. Use the maximum instead. */
memory_alignment = UX_MAX_SCATTER_GATHER_ALIGNMENT - 1;
else
{
/* We are not over the maximum, so approximate the alignment according to the size of the memory.
Check range for alignment on 4096 bytes. */
if (memory_size_requested >= UX_ALIGN_2048 + 1)
memory_alignment = UX_ALIGN_4096;
else
{
/* Check range for alignment on 2048 bytes. */
if (memory_size_requested >= UX_ALIGN_1024 + 1)
memory_alignment = UX_ALIGN_2048;
else
{
/* Check range for alignment on 1024 bytes. */
if (memory_size_requested >= UX_ALIGN_512 + 1)
memory_alignment = UX_ALIGN_1024;
else
{
/* Check range for alignment on 512 bytes. */
if (memory_size_requested >= UX_ALIGN_256 + 1)
memory_alignment = UX_ALIGN_512;
else
{
/* Check range for alignment on 256 bytes. */
if (memory_size_requested >= UX_ALIGN_128 + 1)
memory_alignment = UX_ALIGN_256;
else
{
/* Check range for alignment on 128 bytes. */
if (memory_size_requested >= UX_ALIGN_64 + 1)
memory_alignment = UX_ALIGN_128;
else
{
/* Check range for alignment on 128 bytes. */
if (memory_size_requested >= UX_ALIGN_64 + 1)
memory_alignment = UX_ALIGN_128;
else
{
/* Check range for alignment on 64 bytes. */
if (memory_size_requested >= UX_ALIGN_32 + 1)
memory_alignment = UX_ALIGN_64;
else
{
/* Check range for alignment on 32 bytes. */
if (memory_size_requested >= UX_ALIGN_16 + 1)
memory_alignment = UX_ALIGN_32;
else
memory_alignment = UX_ALIGN_MIN;
}
}
}
}
}
}
}
}
}
}
memory_alignment = UX_ALIGN_MIN;
}
#else
@ -205,204 +193,161 @@ ALIGN_TYPE int_memory_buffer;
/* Check if safe alignment requested, in this case switch to UX_NO_ALIGN. */
if (memory_alignment == UX_SAFE_ALIGN)
memory_alignment = UX_NO_ALIGN;
#endif
/* Ensure the alignment meats the minimum. */
if (memory_alignment < UX_ALIGN_MIN)
memory_alignment = UX_ALIGN_MIN;
/* Adjust the memory alignment since our macros are one minus the desired alignment.
Also determine the amount of extra memory we need for the alignment, which is one
minus the actual alignment. */
memory_for_alignment = memory_alignment;
memory_alignment++;
/* We need to make sure that the next memory block buffer is 8-byte aligned too. We
do this by first adjusting the requested memory to be 8-byte aligned. One problem
now is that the memory block might not be a size that is a multiple of 8, so we need
to add the amount of memory required such that the memory buffer after the block has
the correct alignment. For example, if the memory block has a size of 12, then we need
to make sure it is placed on an 8-byte alignment that is after a 8-byte alignment so
that the memory right after the memory block is 8-byte aligned (16). */
memory_size_requested = (memory_size_requested + UX_ALIGN_MIN) & (~(ULONG)UX_ALIGN_MIN);
memory_size_requested += (((ULONG)(UX_MEMORY_BLOCK_HEADER_SIZE + UX_ALIGN_MIN) & (~(ULONG)UX_ALIGN_MIN)) - (ULONG)UX_MEMORY_BLOCK_HEADER_SIZE);
/* We need to make sure that the next memory block buffer is 16-byte aligned too. We
do this by first adjusting the requested memory to be 16-byte aligned. One problem
now is that the memory block might not be a size that is a multiple of 16, so we need
to add the amount of memory required such that the memory buffer after the block has
the correct alignment. For example, if the memory block has a size of 24, then we need
to make sure it is placed on an 8-byte alignment that is after a 16-byte alignment so
that the memory right after the memory block is 16-byte aligned (8 + 24 = 32). */
memory_size_requested = (memory_size_requested + UX_ALIGN_MIN) & (~(ULONG)UX_ALIGN_MIN);
memory_size_requested += (((ULONG)sizeof(UX_MEMORY_BLOCK) + UX_ALIGN_MIN) & (~(ULONG)UX_ALIGN_MIN)) - (ULONG)sizeof(UX_MEMORY_BLOCK);
if (memory_alignment <= UX_ALIGN_MIN)
current_ptr = _ux_utility_memory_byte_pool_search(pool_ptr, memory_size_requested);
else
current_ptr = _ux_utility_memory_byte_pool_search(pool_ptr, memory_size_requested + memory_alignment);
/* Try to find the best block for this memory by requesting the maximum amount of
memory we'll need which is calculated as follows: the amount memory requested by
the caller plus the maximum amount of memory wasted due to alignment plus 2 memory
blocks structs - one for the new memory block we'll create for the user block and one
that we might create if there is extra memory after doing the alignment. */
memory_block = _ux_utility_memory_free_block_best_get(memory_cache_flag, memory_size_requested + memory_for_alignment + (ULONG)sizeof(UX_MEMORY_BLOCK));
/* If the block returned is NULL, there is no free memory in the pool
for that size. */
if (memory_block == UX_NULL)
/* Check if we found a memory block. */
if (current_ptr == UX_NULL)
{
/* Release the protection. */
/* We could not find a memory block. */
_ux_system_mutex_off(&_ux_system -> ux_system_mutex);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MEMORY_INSUFFICIENT, memory_size_requested, 0, 0, UX_TRACE_ERRORS, 0, 0)
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, UX_MEMORY_INSUFFICIENT);
/* Return NULL to indicate no block was found. */
return(UX_NULL);
}
/* Pickup the next block's pointer. */
this_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(current_ptr);
next_ptr = *this_block_link_ptr;
/* Calculate the number of bytes available in this block. */
available_bytes = UX_UCHAR_POINTER_DIF(next_ptr, current_ptr);
available_bytes = available_bytes - UX_MEMORY_BLOCK_HEADER_SIZE;
/* Get the memory buffer for this block. */
int_memory_buffer = (ALIGN_TYPE) ((UCHAR *) memory_block + sizeof(UX_MEMORY_BLOCK));
int_memory_buffer = (ALIGN_TYPE) (UX_UCHAR_POINTER_ADD(current_ptr, UX_MEMORY_BLOCK_HEADER_SIZE));
/* Are we already aligned? */
if ((int_memory_buffer & (memory_alignment - 1)) == 0)
/* In case we are not aligned */
if ((int_memory_buffer & memory_alignment) != 0)
{
/* Setup the new memory block. */
new_memory_block = (UX_MEMORY_BLOCK *) ((UCHAR *) memory_block + sizeof(UX_MEMORY_BLOCK) + memory_size_requested);
new_memory_block -> ux_memory_block_next = memory_block -> ux_memory_block_next;
new_memory_block -> ux_memory_block_previous = memory_block;
new_memory_block -> ux_memory_block_size = memory_block -> ux_memory_block_size - memory_size_requested - (ULONG)sizeof(UX_MEMORY_BLOCK);
new_memory_block -> ux_memory_block_status = UX_MEMORY_UNUSED;
/* No, we need to align the memory buffer. */
int_memory_buffer += (ALIGN_TYPE)UX_MEMORY_BLOCK_HEADER_SIZE;
int_memory_buffer += memory_alignment;
int_memory_buffer &= ~((ALIGN_TYPE) memory_alignment);
int_memory_buffer -= (ALIGN_TYPE)UX_MEMORY_BLOCK_HEADER_SIZE;
/* 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_cache_flag;
/* Setup the new free block. */
next_ptr = (UCHAR *)int_memory_buffer;
/* Declare how much memory we removed from the pool. */
memory_removed_from_pool = memory_block -> ux_memory_block_size + (ULONG)sizeof(UX_MEMORY_BLOCK);
/* Setup the new free block. */
next_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(next_ptr);
*next_block_link_ptr = *this_block_link_ptr;
work_ptr = UX_UCHAR_POINTER_ADD(next_ptr, (sizeof(UCHAR *)));
free_ptr = UX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(work_ptr);
*free_ptr = UX_BYTE_BLOCK_FREE;
/* Increase the total fragment counter. */
pool_ptr -> ux_byte_pool_fragments++;
/* Update the current pointer to point at the newly created block. */
*this_block_link_ptr = next_ptr;
/* Calculate the available bytes. */
available_bytes -= UX_UCHAR_POINTER_DIF(next_ptr, current_ptr);
/* Set Current pointer to the aligned memory buffer. */
current_ptr = next_ptr;
}
else
/* Now we are aligned, determine if we need to split this block. */
if ((available_bytes - memory_size_requested) >= ((ULONG) UX_BYTE_BLOCK_MIN))
{
/* Align the buffer. The first thing we do is increment by the size of a
memory block because we have to make sure we have enough memory for at
least that. */
int_memory_buffer += (ULONG)sizeof(UX_MEMORY_BLOCK);
int_memory_buffer += memory_alignment - 1;
int_memory_buffer &= ~(((ALIGN_TYPE) memory_alignment) - 1);
/* Split the block. */
next_ptr = UX_UCHAR_POINTER_ADD(current_ptr, (memory_size_requested + UX_MEMORY_BLOCK_HEADER_SIZE));
/* Setup the new memory block. Note that its size is updated again later. */
new_memory_block = (UX_MEMORY_BLOCK *) (int_memory_buffer - (ULONG)sizeof(UX_MEMORY_BLOCK));
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 | memory_cache_flag;
/* Setup the new free block. */
next_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(next_ptr);
this_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(current_ptr);
*next_block_link_ptr = *this_block_link_ptr;
work_ptr = UX_UCHAR_POINTER_ADD(next_ptr, (sizeof(UCHAR *)));
free_ptr = UX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(work_ptr);
*free_ptr = UX_BYTE_BLOCK_FREE;
/* Update the current memory block. */
int_memory_buffer = (ALIGN_TYPE) ((UCHAR *) memory_block + sizeof(UX_MEMORY_BLOCK));
memory_block -> ux_memory_block_next = new_memory_block;
memory_block -> ux_memory_block_size = (ULONG) ((ALIGN_TYPE) new_memory_block - int_memory_buffer);
/* Increase the total fragment counter. */
pool_ptr -> ux_byte_pool_fragments++;
/* Update the new memory block's size. */
new_memory_block -> ux_memory_block_size -= (memory_block -> ux_memory_block_size + (ULONG)sizeof(UX_MEMORY_BLOCK));
/* Update the current pointer to point at the newly created block. */
*this_block_link_ptr = next_ptr;
/* Calculate how much memory is leftover in the new memory block after doing
the alignment. */
leftover = new_memory_block -> ux_memory_block_size - memory_size_requested;
/* Can we fit another block after the new block? */
if (leftover > sizeof(UX_MEMORY_BLOCK))
{
/* Setup the leftover memory block. */
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);
leftover_memory_block -> ux_memory_block_status = UX_MEMORY_UNUSED;
new_memory_block -> ux_memory_block_next = leftover_memory_block;
new_memory_block -> ux_memory_block_size -= leftover;
}
/* Declare how much memory we removed from the pool. */
memory_removed_from_pool = new_memory_block -> ux_memory_block_size + (ULONG)sizeof(UX_MEMORY_BLOCK);
/* The new memory block is the one we give to the user. */
memory_block = new_memory_block;
/* Set available equal to memory size for subsequent calculation. */
available_bytes = memory_size_requested;
}
/* The memory to be returned is after the block header. */
memory_buffer = ((UCHAR *) memory_block) + sizeof(UX_MEMORY_BLOCK);
/* In any case, mark the current block as allocated. */
work_ptr = UX_UCHAR_POINTER_ADD(current_ptr, (sizeof(UCHAR *)));
this_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(work_ptr);
*this_block_link_ptr = UX_BYTE_POOL_TO_UCHAR_POINTER_CONVERT(pool_ptr);
/* Reduce the number of available bytes in the pool. */
pool_ptr -> ux_byte_pool_available = pool_ptr -> ux_byte_pool_available - (available_bytes + UX_MEMORY_BLOCK_HEADER_SIZE);
/* Determine if the search pointer needs to be updated. This is only done
if the search pointer matches the block to be returned. */
if (current_ptr == pool_ptr -> ux_byte_pool_search)
{
/* Yes, update the search pointer to the next block. */
this_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(current_ptr);
pool_ptr -> ux_byte_pool_search = *this_block_link_ptr;
}
/* Adjust the pointer for the application. */
work_ptr = UX_UCHAR_POINTER_ADD(current_ptr, UX_MEMORY_BLOCK_HEADER_SIZE);
/* Clear the memory block. */
_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)
{
/* There is only one memory pool. */
_ux_system -> ux_system_regular_memory_pool_free -= memory_removed_from_pool;
}
else
{
switch (memory_cache_flag)
{
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:
/* Update the amount of free memory in the regular memory pool. */
_ux_system -> ux_system_regular_memory_pool_free -= memory_removed_from_pool;
break;
}
}
_ux_utility_memory_set(work_ptr, 0, available_bytes); /* Use case of memset is verified. */
#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;
}
index = UX_MEMORY_BYTE_POOL_REGULAR;
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;
}
index = UX_MEMORY_BYTE_POOL_CACHE_SAFE;
/* 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;
/* Update allocate count, total size. */
_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_count ++;
_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_total += (available_bytes + UX_MEMORY_BLOCK_HEADER_SIZE);
/* 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;
if (_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_max_count < _ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_count)
_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_max_count = _ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_count;
if (_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_max_total < _ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_total)
_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_max_total = _ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_total;
/* Log max usage of memory pool. */
if (_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_min_free > _ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_available)
_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_min_free = _ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_available;
#endif
/* Release the protection. */
_ux_system_mutex_off(&_ux_system -> ux_system_mutex);
/* The memory block pointer contains a memory area properly
aligned. */
return(memory_buffer);
}
return(work_ptr);
}

View File

@ -0,0 +1,130 @@
/**************************************************************************/
/* */
/* 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 */
/** */
/** USBX main stack */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_byte_pool_create PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function creates a pool of memory bytes in the specified */
/* memory area. */
/* */
/* INPUT */
/* */
/* pool_ptr Pointer to pool control block */
/* pool_start Address of beginning of pool area */
/* pool_size Number of bytes in the byte pool */
/* */
/* OUTPUT */
/* */
/* UX_SUCCESS Successful completion status */
/* */
/* CALLS */
/* */
/* None */
/* */
/* CALLED BY */
/* */
/* USBX Components */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_utility_memory_byte_pool_create(UX_MEMORY_BYTE_POOL *pool_ptr, VOID *pool_start, ULONG pool_size)
{
UCHAR *block_ptr;
UCHAR **block_indirect_ptr;
UCHAR *temp_ptr;
ALIGN_TYPE *free_ptr;
/* Initialize the byte pool control block to all zeros. */
_ux_utility_memory_set((UCHAR *)pool_ptr, 0, sizeof(UX_MEMORY_BYTE_POOL)); /* Use case of memset is verified. */
/* Round the pool size down to something that is evenly divisible by
an ULONG. */
pool_size = (pool_size/(sizeof(ALIGN_TYPE))) * (sizeof(ALIGN_TYPE));
/* Save the start and size of the pool. */
pool_ptr -> ux_byte_pool_start = UX_VOID_TO_UCHAR_POINTER_CONVERT(pool_start);
pool_ptr -> ux_byte_pool_size = pool_size;
pool_ptr -> ux_byte_pool_search = UX_VOID_TO_UCHAR_POINTER_CONVERT(pool_start);
/* Initially, the pool will have two blocks. One large block at the
beginning that is available and a small allocated block at the end
of the pool that is there just for the algorithm. Be sure to count
the available block's header in the available bytes count. */
pool_ptr -> ux_byte_pool_available = pool_size - ((sizeof(VOID *)) + (sizeof(ALIGN_TYPE)));
pool_ptr -> ux_byte_pool_fragments = ((UINT) 2);
/* Each block contains a "next" pointer that points to the next block in the pool followed by a ALIGN_TYPE
field that contains either the constant UX_BYTE_BLOCK_FREE (if the block is free) or a pointer to the
owning pool (if the block is allocated). */
/* Calculate the end of the pool's memory area. */
block_ptr = UX_VOID_TO_UCHAR_POINTER_CONVERT(pool_start);
block_ptr = UX_UCHAR_POINTER_ADD(block_ptr, pool_size);
/* Backup the end of the pool pointer and build the pre-allocated block. */
block_ptr = UX_UCHAR_POINTER_SUB(block_ptr, (sizeof(ALIGN_TYPE)));
/* Cast the pool pointer into a ULONG. */
temp_ptr = UX_BYTE_POOL_TO_UCHAR_POINTER_CONVERT(pool_ptr);
block_indirect_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(block_ptr);
*block_indirect_ptr = temp_ptr;
block_ptr = UX_UCHAR_POINTER_SUB(block_ptr, (sizeof(UCHAR *)));
block_indirect_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(block_ptr);
*block_indirect_ptr = UX_VOID_TO_UCHAR_POINTER_CONVERT(pool_start);
/* Now setup the large available block in the pool. */
temp_ptr = UX_VOID_TO_UCHAR_POINTER_CONVERT(pool_start);
block_indirect_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(temp_ptr);
*block_indirect_ptr = block_ptr;
block_ptr = UX_VOID_TO_UCHAR_POINTER_CONVERT(pool_start);
block_ptr = UX_UCHAR_POINTER_ADD(block_ptr, (sizeof(UCHAR *)));
free_ptr = UX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(block_ptr);
*free_ptr = UX_BYTE_BLOCK_FREE;
/* Return UX_SUCCESS. */
return(UX_SUCCESS);
}

View File

@ -0,0 +1,215 @@
/**************************************************************************/
/* */
/* 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 */
/** */
/** USBX main stack */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_byte_pool_search PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function searches a byte pool for a memory block to satisfy */
/* the requested number of bytes. Merging of adjacent free blocks */
/* takes place during the search. */
/* */
/* INPUT */
/* */
/* pool_ptr Pointer to pool control block */
/* memory_size Number of bytes required */
/* */
/* OUTPUT */
/* */
/* UCHAR * Pointer to the allocated memory, */
/* if successful. Otherwise, a */
/* NULL is returned */
/* */
/* CALLS */
/* */
/* None */
/* */
/* CALLED BY */
/* */
/* USBX Components */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UCHAR *_ux_utility_memory_byte_pool_search(UX_MEMORY_BYTE_POOL *pool_ptr, ULONG memory_size)
{
UCHAR *current_ptr;
UCHAR *next_ptr;
UCHAR **this_block_link_ptr;
UCHAR **next_block_link_ptr;
ULONG available_bytes;
UINT examine_blocks;
UINT first_free_block_found = UX_FALSE;
ALIGN_TYPE *free_ptr;
UCHAR *work_ptr;
ULONG total_theoretical_available;
/* First, determine if there are enough bytes in the pool. */
/* Theoretical bytes available = free bytes + ((fragments-2) * overhead of each block) */
total_theoretical_available = pool_ptr -> ux_byte_pool_available + ((pool_ptr -> ux_byte_pool_fragments - 2) * UX_MEMORY_BLOCK_HEADER_SIZE);
if (memory_size >= total_theoretical_available)
{
/* Not enough memory, return a NULL pointer. */
return(UX_NULL);
}
/* Check if the search pointer is valid. */
if ((pool_ptr -> ux_byte_pool_search < pool_ptr -> ux_byte_pool_start) ||
(pool_ptr -> ux_byte_pool_search > pool_ptr -> ux_byte_pool_start + pool_ptr -> ux_byte_pool_size))
{
/* Return a NULL pointer. */
return(UX_NULL);
}
/* Walk through the memory pool in search for a large enough block. */
current_ptr = pool_ptr -> ux_byte_pool_search;
examine_blocks = pool_ptr -> ux_byte_pool_fragments + ((UINT) 1);
available_bytes = ((ULONG) 0);
do
{
/* Check to see if this block is free. */
work_ptr = UX_UCHAR_POINTER_ADD(current_ptr, (sizeof(UCHAR *)));
free_ptr = UX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(work_ptr);
if ((*free_ptr) == UX_BYTE_BLOCK_FREE)
{
/* Determine if this is the first free block. */
if (first_free_block_found == UX_FALSE)
{
/* This is the first free block. */
pool_ptr->ux_byte_pool_search = current_ptr;
/* Set the flag to indicate we have found the first free
block. */
first_free_block_found = UX_TRUE;
}
/* Block is free, see if it is large enough. */
/* Pickup the next block's pointer. */
this_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(current_ptr);
next_ptr = *this_block_link_ptr;
/* Calculate the number of bytes available in this block. */
available_bytes = UX_UCHAR_POINTER_DIF(next_ptr, current_ptr);
available_bytes = available_bytes - UX_MEMORY_BLOCK_HEADER_SIZE;
/* If this is large enough, we are done because our first-fit algorithm
has been satisfied! */
if (available_bytes >= memory_size)
{
/* Get out of the search loop! */
break;
}
else
{
/* Clear the available bytes variable. */
available_bytes = ((ULONG) 0);
/* Not enough memory, check to see if the neighbor is
free and can be merged. */
work_ptr = UX_UCHAR_POINTER_ADD(next_ptr, (sizeof(UCHAR *)));
free_ptr = UX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(work_ptr);
if ((*free_ptr) == UX_BYTE_BLOCK_FREE)
{
/* Yes, neighbor block can be merged! This is quickly accomplished
by updating the current block with the next blocks pointer. */
next_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(next_ptr);
*this_block_link_ptr = *next_block_link_ptr;
/* Reduce the fragment total. We don't need to increase the bytes
available because all free headers are also included in the available
count. */
pool_ptr -> ux_byte_pool_fragments--;
/* See if the search pointer is affected. */
if (pool_ptr -> ux_byte_pool_search == next_ptr)
{
/* Yes, update the search pointer. */
pool_ptr -> ux_byte_pool_search = current_ptr;
}
}
else
{
/* Neighbor is not free so we can skip over it! */
next_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(next_ptr);
current_ptr = *next_block_link_ptr;
/* Decrement the examined block count to account for this one. */
if (examine_blocks != ((UINT) 0))
{
examine_blocks--;
}
}
}
}
else
{
/* Block is not free, move to next block. */
this_block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(current_ptr);
current_ptr = *this_block_link_ptr;
}
/* Another block has been searched... decrement counter. */
if (examine_blocks != ((UINT) 0))
{
examine_blocks--;
}
} while(examine_blocks != ((UINT) 0));
/* If a block was found, just return. */
if (available_bytes == ((ULONG) 0))
{
return(UX_NULL);
}
/* Return the search pointer. */
return(current_ptr);
}

View File

@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** USBX Component */
/** */
/** Utility */
/** */
@ -28,59 +28,70 @@
#include "ux_api.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_free PORTABLE C */
/* 6.1.10 */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_free PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function frees a previously allocated memory block. */
/* */
/* INPUT */
/* */
/* memory Pointer to memory block */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_utility_mutex_on Start system protection */
/* _ux_utility_mutex_off End system protection */
/* */
/* CALLED BY */
/* */
/* USBX Components */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* */
/* This function frees a previously allocated memory block. */
/* */
/* INPUT */
/* */
/* memory Pointer to memory block */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_utility_mutex_on Start system protection */
/* _ux_utility_mutex_off End system protection */
/* */
/* 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 */
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.1.10 */
/* 10-31-2023 Yajun Xia, CQ Xiao Modified comment(s), */
/* added some error traps, */
/* refined memory management, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_utility_memory_free(VOID *memory)
{
UX_MEMORY_BYTE_POOL *pool_ptr;
UCHAR *work_ptr;
UCHAR *temp_ptr;
UCHAR *next_block_ptr;
UX_MEMORY_BLOCK *memory_block;
UX_MEMORY_BLOCK *next_block;
ULONG memory_size_returned;
UCHAR *memory_address;
ALIGN_TYPE *free_ptr;
UX_MEMORY_BYTE_POOL **byte_pool_ptr;
UCHAR **block_link_ptr;
#ifdef UX_ENABLE_MEMORY_POOL_SANITY_CHECK
UCHAR *memory_address;
UCHAR *regular_start, *regular_end;
UCHAR *cache_safe_start, *cache_safe_end;
#endif
#ifdef UX_ENABLE_MEMORY_STATISTICS
UINT index;
#endif
/* Get the mutex as this is a critical section. */
@ -89,12 +100,13 @@ UCHAR *cache_safe_start, *cache_safe_end;
#ifdef UX_ENABLE_MEMORY_POOL_SANITY_CHECK
/* Sanity check, check if the memory is in memory pool. */
regular_start = (UCHAR *)_ux_system -> ux_system_regular_memory_pool_start;
regular_end = regular_start + _ux_system -> ux_system_regular_memory_pool_size;
regular_start += sizeof(UX_MEMORY_BLOCK);
cache_safe_start = (UCHAR *)_ux_system -> ux_system_cache_safe_memory_pool_start;
cache_safe_end = cache_safe_start + _ux_system -> ux_system_cache_safe_memory_pool_size;
cache_safe_start += sizeof(UX_MEMORY_BLOCK);
regular_start = (UCHAR *)_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] -> ux_byte_pool_start;
regular_end = regular_start + _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] -> ux_byte_pool_size;
regular_start += UX_MEMORY_BLOCK_HEADER_SIZE;
cache_safe_start = (UCHAR *)_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE] -> ux_byte_pool_start;
cache_safe_end = cache_safe_start + _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE] -> ux_byte_pool_size;
cache_safe_start += UX_MEMORY_BLOCK_HEADER_SIZE;
memory_address = (UCHAR *)memory;
if (!((memory_address >= regular_start && memory_address < regular_end) ||
(memory_address >= cache_safe_start && memory_address < cache_safe_end)))
@ -112,118 +124,104 @@ UCHAR *cache_safe_start, *cache_safe_end;
}
#endif
/* The memory block for this memory pointer is located right before the
memory. */
memory_block = (UX_MEMORY_BLOCK *) (((UCHAR *) memory) - sizeof(UX_MEMORY_BLOCK));
/* Keep track of the memory returned to the pool. */
memory_size_returned = memory_block -> ux_memory_block_size + (ULONG)sizeof(UX_MEMORY_BLOCK);
/* Set the pool pointer to NULL. */
pool_ptr = UX_NULL;
/* Check this memory block to see if it valid. */
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))
/* Determine if the memory pointer is valid. */
work_ptr = UX_VOID_TO_UCHAR_POINTER_CONVERT(memory);
if (work_ptr != UX_NULL)
{
/* Not valid. Release the protection. */
/* Back off the memory pointer to pickup its header. */
work_ptr = UX_UCHAR_POINTER_SUB(work_ptr, UX_MEMORY_BLOCK_HEADER_SIZE);
/* There is a pointer, pickup the pool pointer address. */
temp_ptr = UX_UCHAR_POINTER_ADD(work_ptr, (sizeof(UCHAR *)));
free_ptr = UX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(temp_ptr);
if ((*free_ptr) != UX_BYTE_BLOCK_FREE)
{
/* Pickup the pool pointer. */
temp_ptr = UX_UCHAR_POINTER_ADD(work_ptr, (sizeof(UCHAR *)));
byte_pool_ptr = UX_UCHAR_TO_INDIRECT_BYTE_POOL_POINTER(temp_ptr);
pool_ptr = *byte_pool_ptr;
/* See if we have a valid pool pointer. */
if ((pool_ptr == UX_NULL) ||
((pool_ptr != _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR]) &&
(pool_ptr != _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_CACHE_SAFE])))
{
/* Release the protection. */
_ux_system_mutex_off(&_ux_system -> ux_system_mutex);
/* Error trap: maybe double free/memory issue here! */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD,
UX_SYSTEM_CONTEXT_UTILITY, UX_MEMORY_CORRUPTED);
/* Return to caller. */
return;
}
}
else
{
/* Release the protection. */
_ux_system_mutex_off(&_ux_system -> ux_system_mutex);
/* Error trap: maybe double free/memory issue here! */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD,
UX_SYSTEM_CONTEXT_UTILITY, UX_MEMORY_CORRUPTED);
/* Return to caller. */
return;
}
}
else
{
/* Release the protection. */
_ux_system_mutex_off(&_ux_system -> ux_system_mutex);
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, UX_MEMORY_CORRUPTED);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_MEMORY_CORRUPTED, memory, 0, 0, UX_TRACE_ERRORS, 0, 0)
/* Error trap: maybe double free/bad flow here! */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD,
UX_SYSTEM_CONTEXT_UTILITY, UX_MEMORY_CORRUPTED);
/* Return to caller. */
return;
}
/* At this point, we know that the pool pointer is valid. */
/* Release the memory. */
temp_ptr = UX_UCHAR_POINTER_ADD(work_ptr, (sizeof(UCHAR *)));
free_ptr = UX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(temp_ptr);
*free_ptr = UX_BYTE_BLOCK_FREE;
/* Update the number of available bytes in the pool. */
block_link_ptr = UX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(work_ptr);
next_block_ptr = *block_link_ptr;
pool_ptr -> ux_byte_pool_available =
pool_ptr -> ux_byte_pool_available + UX_UCHAR_POINTER_DIF(next_block_ptr, work_ptr);
/* Determine if the free block is prior to current search pointer. */
if (work_ptr < (pool_ptr -> ux_byte_pool_search))
{
/* Yes, update the search pointer to the released block. */
pool_ptr -> ux_byte_pool_search = work_ptr;
}
#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;
}
if (((UCHAR*)memory >= _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] -> ux_byte_pool_start) &&
((UCHAR*)memory < (_ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] -> ux_byte_pool_start + _ux_system -> ux_system_memory_byte_pool[UX_MEMORY_BYTE_POOL_REGULAR] -> ux_byte_pool_size)))
index = UX_MEMORY_BYTE_POOL_REGULAR;
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;
}
index = UX_MEMORY_BYTE_POOL_CACHE_SAFE;
_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_count --;
_ux_system -> ux_system_memory_byte_pool[index] -> ux_byte_pool_alloc_total -= UX_UCHAR_POINTER_DIF(next_block_ptr, work_ptr);
#endif
/* We mark this memory block as being unused. */
memory_block -> ux_memory_block_status = UX_MEMORY_UNUSED;
/* Now we must concatenate as many free blocks as possible,
that include the blocks before and the blocks after the current
block. Scan memory backwards. */
while (memory_block -> ux_memory_block_previous !=UX_NULL)
{
/* Check if the block is free. */
if (memory_block -> ux_memory_block_previous -> ux_memory_block_status == UX_MEMORY_UNUSED)
/* The memory block before is free. This will be our starting point to
concatenate memory. */
memory_block = memory_block -> ux_memory_block_previous;
else
/* The previous memory block is not free. */
break;
}
/* The pointer to the memory block is now our first free block. We use this
starting address to concatenate all the contiguous memory block. */
next_block = memory_block -> ux_memory_block_next;
while (next_block != UX_NULL)
{
/* Determine if the memory block is used. */
if (next_block -> ux_memory_block_status != UX_MEMORY_UNUSED)
{
/* Yes, move to next block. */
memory_block -> ux_memory_block_next = next_block;
next_block -> ux_memory_block_previous = memory_block;
break;
}
memory_block -> ux_memory_block_next = next_block -> ux_memory_block_next;
memory_block -> ux_memory_block_size += next_block -> ux_memory_block_size + (ULONG)sizeof(UX_MEMORY_BLOCK);
next_block = next_block -> ux_memory_block_next;
}
/* Update the memory free in the appropriate pool. We need to know if this
block is in regular memory or cache safe memory. */
if(_ux_system -> ux_system_cache_safe_memory_pool_start == _ux_system -> ux_system_regular_memory_pool_start)
{
/* There is only one regular memory pool. */
_ux_system -> ux_system_regular_memory_pool_free += memory_size_returned;
}
else
{
/* Which pool is this memory in ? */
memory_address = (UCHAR *) _ux_system -> ux_system_regular_memory_pool_start;
/* If the memory address is in this range, we are in the regular memory pool. */
if ((UCHAR *) memory_block >= memory_address && (UCHAR *) memory_block < (memory_address + _ux_system -> ux_system_regular_memory_pool_size))
/* Update the regular memory pool. */
_ux_system -> ux_system_regular_memory_pool_free += memory_size_returned;
else
/* Update the cache safe memory pool. */
_ux_system -> ux_system_cache_safe_memory_pool_free += memory_size_returned;
}
/* Release the protection. */
_ux_system_mutex_off(&_ux_system -> ux_system_mutex);

View File

@ -12,8 +12,8 @@
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** USBX Component */
/** */
/** USBX main stack */
/** */
@ -28,57 +28,64 @@
#include "ux_api.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_free_block_best_get PORTABLE C */
/* 6.1 */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_utility_memory_free_block_best_get PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function returns the best free memory block. */
/* */
/* INPUT */
/* */
/* memory_cache_flag Memory pool source */
/* memory_size_requested Size of memory requested */
/* */
/* OUTPUT */
/* */
/* Pointer to best free block */
/* */
/* CALLS */
/* */
/* */
/* This function returns the best free memory block. */
/* */
/* It's deprecated. */
/* */
/* INPUT */
/* */
/* memory_cache_flag Memory pool source */
/* memory_size_requested Size of memory requested */
/* */
/* OUTPUT */
/* */
/* Pointer to best free block */
/* */
/* CALLS */
/* */
/* None */
/* */
/* 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 */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* deprecated for memory */
/* footprint optimization, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UX_MEMORY_BLOCK *_ux_utility_memory_free_block_best_get(ULONG memory_cache_flag,
#if 0
UX_MEMORY_BLOCK *_ux_utility_memory_free_block_best_get(ULONG memory_cache_flag,
ULONG memory_size_requested)
{
UX_MEMORY_BLOCK *memory_block;
UX_MEMORY_BLOCK *best_memory_block;
/* Reset the free memory block. */
best_memory_block = UX_NULL;
/* Check the type of memory we need. */
switch (memory_cache_flag)
{
@ -88,15 +95,15 @@ UX_MEMORY_BLOCK *best_memory_block;
/* Start at the beginning of the regular memory pool. */
memory_block = _ux_system -> ux_system_regular_memory_pool_start;
break;
case UX_CACHE_SAFE_MEMORY :
/* Start at the beginning of the cache safe memory pool. */
memory_block = _ux_system -> ux_system_cache_safe_memory_pool_start;
break;
default :
/* Wrong memory type. */
return(UX_NULL);
@ -110,11 +117,11 @@ UX_MEMORY_BLOCK *best_memory_block;
if (memory_block -> ux_memory_block_status == UX_MEMORY_UNUSED)
{
/* Check the size of this free block and see if it will
/* Check the size of this free block and see if it will
fit the memory requirement. */
if (memory_block -> ux_memory_block_size > memory_size_requested)
{
/* This memory block will do. Now see if it is the best.
The best memory block is the one whose memory is closest
to the memory requested. */
@ -129,15 +136,15 @@ UX_MEMORY_BLOCK *best_memory_block;
/* We have discovered a better fit block. */
best_memory_block = memory_block;
}
}
}
}
/* Search the next free block until the end. */
/* Search the next free block until the end. */
memory_block = memory_block -> ux_memory_block_next;
}
/* If no free memory block was found, the return value will be NULL. */
return(best_memory_block);
}
return(best_memory_block);
}
#endif

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_audio.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -65,10 +65,11 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -422,10 +423,6 @@ typedef struct UX_DEVICE_CLASS_AUDIO_STREAM_STRUCT
UX_SLAVE_INTERFACE *ux_device_class_audio_stream_interface;
UX_SLAVE_ENDPOINT *ux_device_class_audio_stream_endpoint;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
UCHAR *ux_device_class_audio_stream_endpoint_buffer;
#endif
#if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT)
UX_SLAVE_ENDPOINT *ux_device_class_audio_stream_feedback;

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_audio10.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -57,9 +57,9 @@
/* added error checks support, */
/* fixed a macro name, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* optimized USB descriptors, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_audio20.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -58,9 +58,9 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* optimized USB descriptors, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_ccid.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -42,9 +42,9 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Yajun xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun xia, CQ Xiao Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_cdc_acm.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -58,12 +58,12 @@
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added write auto ZLP, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Yajun xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun xia, CQ Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_cdc_ecm.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -55,10 +55,11 @@
/* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added wait definitions, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -99,11 +100,26 @@ VOID _ux_network_driver_link_down(VOID *ux_network_handle);
#endif
/* Option: defined, it enables zero copy support (works if CDC_ECM owns endpoint buffer).
Enabled, it requires that the NX packet pool is in cache safe area, and buffer max size is
larger than UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE (1536).
*/
/* #define UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY */
/* Bulk out endpoint buffer size, must be larger than endpoint and ethernet max packet size, and aligned in 4-bytes. */
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
#define UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE 0
#else
#define UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE UX_DEVICE_CLASS_CDC_ECM_MAX_PACKET_LENGTH
#endif
/* Bulk in endpoint buffer size, must be larger than endpoint and ethernet max packet size, and aligned in 4-bytes. */
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
#define UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE 0
#else
#define UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE UX_DEVICE_CLASS_CDC_ECM_ETHERNET_PACKET_SIZE
#endif
/* Interrupt in endpoint buffer size... */
#define UX_DEVICE_CLASS_CDC_ECM_INTERRUPTIN_BUFFER_SIZE UX_DEVICE_CLASS_CDC_ECM_INTERRUPT_RESPONSE_LENGTH
@ -370,12 +386,16 @@ typedef struct UX_SLAVE_CLASS_CDC_ECM_STRUCT
} UX_SLAVE_CLASS_CDC_ECM;
/* Define CDC ECM endpoint buffer settings (when CDC ECM owns buffer). */
#if defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
#define UX_DEVICE_CLASS_CDC_ECM_ENDPOINT_BUFFER_SIZE_CALC_OVERFLOW 0 /* No calculation, no overflow */
#else
#define UX_DEVICE_CLASS_CDC_ECM_ENDPOINT_BUFFER_SIZE_CALC_OVERFLOW \
(UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE, \
UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE) || \
UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE + \
UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE, \
UX_DEVICE_CLASS_CDC_ECM_INTERRUPTIN_BUFFER_SIZE))
#endif
#define UX_DEVICE_CLASS_CDC_ECM_ENDPOINT_BUFFER_SIZE (UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE + UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE + UX_DEVICE_CLASS_CDC_ECM_INTERRUPTIN_BUFFER_SIZE)
#define UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER(ecm) ((ecm)->ux_device_class_cdc_ecm_endpoint_buffer)
#define UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER(ecm) (UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER(ecm) + UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE)

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_dfu.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -60,9 +60,9 @@
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added macros for req types, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Yajun xia Modified comment(s), */
/* 10-31-2023 Yajun xia Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_hid.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -64,12 +64,12 @@
/* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone int out, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* moved build option check, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_pima.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -58,11 +58,12 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* optimized PIMA data sets, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -729,10 +730,11 @@ typedef struct UX_SLAVE_CLASS_PIMA_OBJECT_STRUCT
{
ULONG ux_device_class_pima_object_storage_id;
ULONG ux_device_class_pima_object_format;
ULONG ux_device_class_pima_object_protection_status;
USHORT ux_device_class_pima_object_format;
USHORT ux_device_class_pima_object_protection_status;
ULONG ux_device_class_pima_object_compressed_size;
ULONG ux_device_class_pima_object_thumb_format;
USHORT ux_device_class_pima_object_thumb_format;
USHORT _align_thumb_compressed_size;
ULONG ux_device_class_pima_object_thumb_compressed_size;
ULONG ux_device_class_pima_object_thumb_pix_width;
ULONG ux_device_class_pima_object_thumb_pix_height;
@ -740,7 +742,8 @@ typedef struct UX_SLAVE_CLASS_PIMA_OBJECT_STRUCT
ULONG ux_device_class_pima_object_image_pix_height;
ULONG ux_device_class_pima_object_image_bit_depth;
ULONG ux_device_class_pima_object_parent_object;
ULONG ux_device_class_pima_object_association_type;
USHORT ux_device_class_pima_object_association_type;
USHORT _align_association_desc;
ULONG ux_device_class_pima_object_association_desc;
ULONG ux_device_class_pima_object_sequence_number;
UCHAR ux_device_class_pima_object_filename[UX_DEVICE_CLASS_PIMA_UNICODE_MAX_LENGTH];
@ -798,9 +801,10 @@ typedef struct UX_SLAVE_CLASS_PIMA_DEVICE_STRUCT
typedef struct UX_SLAVE_CLASS_PIMA_STORAGE_STRUCT
{
ULONG ux_device_class_pima_storage_type;
ULONG ux_device_class_pima_storage_file_system_type;
ULONG ux_device_class_pima_storage_access_capability;
USHORT ux_device_class_pima_storage_type;
USHORT ux_device_class_pima_storage_file_system_type;
USHORT ux_device_class_pima_storage_access_capability;
USHORT _align_max_capacity_low;
ULONG ux_device_class_pima_storage_max_capacity_low;
ULONG ux_device_class_pima_storage_max_capacity_high;
ULONG ux_device_class_pima_storage_free_space_bytes_low;

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_printer.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -50,11 +50,11 @@
/* 03-08-2023 Yajun xia Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Yajun Xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun Xia, CQ Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* fixed error checking issue, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -77,6 +77,16 @@ extern "C" {
#define UX_DEVICE_CLASS_PRINTER_ENABLE_ERROR_CHECKING
#endif
/* Option: defined, it enables zero copy support (works if PRINTER owns endpoint buffer).
Defined, it enables zero copy for bulk in/out endpoints (write/read). In this case, the endpoint
buffer is not allocated in class, application must provide the buffer for read/write, and the
buffer must meet device controller driver (DCD) buffer requirements (e.g., aligned and cache
safe if buffer is for DMA).
*/
/* #define UX_DEVICE_CLASS_PRINTER_ZERO_COPY */
/* Defined, _write is pending ZLP automatically (complete transfer) after buffer is sent. */
/* #define UX_DEVICE_CLASS_PRINTER_WRITE_AUTO_ZLP */
@ -93,6 +103,13 @@ extern "C" {
#endif
/* Internal: check if class own endpoint buffer */
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && \
(!defined(UX_DEVICE_CLASS_PRINTER_ZERO_COPY))
#define UX_DEVICE_CLASS_PRINTER_OWN_ENDPOINT_BUFFER
#endif
/* Define Printer Class USB Class constants. */
#define UX_DEVICE_CLASS_PRINTER_CLASS 7

View File

@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_rndis.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -55,11 +55,12 @@
/* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added wait and length DEFs, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* improved error checking, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -76,11 +77,27 @@ extern "C" {
#endif
/* Option: defined, it enables zero copy support (works if HID owns endpoint buffer).
Enabled, it requires that the NX packet pool is in cache safe area, and buffer max size is
larger than UX_DEVICE_CLASS_RNDIS_MAX_PACKET_TRANSFER_SIZE (1600).
*/
/* #define UX_DEVICE_CLASS_RNDIS_ZERO_COPY */
/* Bulk out endpoint buffer size (UX_DEVICE_CLASS_RNDIS_MAX_PACKET_TRANSFER_SIZE). */
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_RNDIS_ZERO_COPY)
#define UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER_SIZE 0
#else
#define UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER_SIZE UX_DEVICE_CLASS_RNDIS_MAX_PACKET_TRANSFER_SIZE
#endif
/* Bulk in endpoint buffer size (UX_DEVICE_CLASS_RNDIS_MAX_PACKET_TRANSFER_SIZE). */
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_RNDIS_ZERO_COPY)
#define UX_DEVICE_CLASS_RNDIS_BULKIN_BUFFER_SIZE 0
#else
#define UX_DEVICE_CLASS_RNDIS_BULKIN_BUFFER_SIZE UX_DEVICE_CLASS_RNDIS_MAX_PACKET_TRANSFER_SIZE
#endif
/* Interrupt in endpoint buffer size (UX_DEVICE_CLASS_RNDIS_INTERRUPT_RESPONSE_LENGTH). */
#define UX_DEVICE_CLASS_RNDIS_INTERRUPTIN_BUFFER_SIZE UX_DEVICE_CLASS_RNDIS_INTERRUPT_RESPONSE_LENGTH
@ -597,12 +614,16 @@ typedef struct UX_SLAVE_CLASS_RNDIS_STRUCT
} UX_SLAVE_CLASS_RNDIS;
/* Define RNDIS endpoint buffer settings (when RNDIS owns buffer). */
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_RNDIS_ZERO_COPY)
#define UX_DEVICE_CLASS_RNDIS_ENDPOINT_BUFFER_SIZE_CALC_OVERFLOW 0 /* only one buffer, no calculation */
#else
#define UX_DEVICE_CLASS_RNDIS_ENDPOINT_BUFFER_SIZE_CALC_OVERFLOW \
(UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER_SIZE, \
UX_DEVICE_CLASS_RNDIS_BULKIN_BUFFER_SIZE) || \
UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER_SIZE + \
UX_DEVICE_CLASS_RNDIS_BULKIN_BUFFER_SIZE, \
UX_DEVICE_CLASS_RNDIS_INTERRUPTIN_BUFFER_SIZE))
#endif
#define UX_DEVICE_CLASS_RNDIS_ENDPOINT_BUFFER_SIZE (UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER_SIZE + UX_DEVICE_CLASS_RNDIS_BULKIN_BUFFER_SIZE + UX_DEVICE_CLASS_RNDIS_INTERRUPTIN_BUFFER_SIZE)
#define UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER(rndis) ((rndis)->ux_device_class_rndis_endpoint_buffer)
#define UX_DEVICE_CLASS_RNDIS_BULKIN_BUFFER(rndis) (UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER(rndis) + UX_DEVICE_CLASS_RNDIS_BULKOUT_BUFFER_SIZE)

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_storage.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -57,11 +57,11 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/

View File

@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_video.h PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -44,11 +44,12 @@
/* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Yajun xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun xia, CQ Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@ -588,9 +589,6 @@ typedef struct UX_DEVICE_CLASS_VIDEO_STREAM_STRUCT
struct UX_DEVICE_CLASS_VIDEO_STRUCT *ux_device_class_video_stream_video;
UX_SLAVE_INTERFACE *ux_device_class_video_stream_interface;
UX_SLAVE_ENDPOINT *ux_device_class_video_stream_endpoint;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
UCHAR *ux_device_class_video_stream_endpoint_buffer;
#endif
ULONG ux_device_class_video_stream_error;

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_activate PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -73,10 +73,11 @@
/* 10-31-2022 Yajun Xia Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_activate(UX_SLAVE_CLASS_COMMAND *command)
@ -127,8 +128,10 @@ ULONG stream_index;
audio -> ux_device_class_audio_status_head = audio -> ux_device_class_audio_status_queue;
audio -> ux_device_class_audio_status_tail = audio -> ux_device_class_audio_status_queue;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
audio -> ux_device_class_audio_interrupt -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer = audio -> ux_device_class_audio_interrupt_buffer;
if (audio -> ux_device_class_audio_interrupt)
audio -> ux_device_class_audio_interrupt ->
ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer =
audio -> ux_device_class_audio_interrupt_buffer;
#endif
#endif
}

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_change PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -84,10 +84,11 @@
/* 10-31-2022 Yajun Xia Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_change(UX_SLAVE_CLASS_COMMAND *command)
@ -238,11 +239,11 @@ ULONG endpoint_dir;
}
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
stream -> ux_device_class_audio_stream_endpoint -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer = stream -> ux_device_class_audio_stream_endpoint_buffer;
#if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT)
stream -> ux_device_class_audio_stream_feedback -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer = stream -> ux_device_class_audio_stream_feedback_buffer;
if (stream -> ux_device_class_audio_stream_feedback)
stream -> ux_device_class_audio_stream_feedback ->
ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer =
stream -> ux_device_class_audio_stream_feedback_buffer;
#endif
#endif

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -87,10 +87,11 @@
/* 10-31-2022 Yajun Xia Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_initialize(UX_SLAVE_CLASS_COMMAND *command)
@ -259,16 +260,6 @@ ULONG i;
{
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
/* Allocate memory for stream endpoint buffer. */
stream -> ux_device_class_audio_stream_endpoint_buffer = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_CACHE_SAFE_MEMORY,
stream_parameter -> ux_device_class_audio_stream_parameter_max_frame_buffer_size);
if (stream -> ux_device_class_audio_stream_endpoint_buffer == UX_NULL)
{
status = UX_MEMORY_INSUFFICIENT;
break;
}
#if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT)
/* Allocate memory for feedback endpoint buffer. */
@ -303,7 +294,11 @@ ULONG i;
stream_parameter -> ux_device_class_audio_stream_parameter_max_frame_buffer_nb;
/* Create block of buffer buffer is cache safe for USB transfer. */
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
stream -> ux_device_class_audio_stream_buffer = (UCHAR *)_ux_utility_memory_allocate(UX_NO_ALIGN, UX_CACHE_SAFE_MEMORY, memory_size);
#else
stream -> ux_device_class_audio_stream_buffer = (UCHAR *)_ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, memory_size);
#endif
/* Check for successful allocation. */
if (stream -> ux_device_class_audio_stream_buffer == UX_NULL)
@ -465,10 +460,6 @@ ULONG i;
_ux_device_thread_delete(&stream -> ux_device_class_audio_stream_thread);
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_thread_stack);
}
#endif
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
if (stream -> ux_device_class_audio_stream_endpoint_buffer)
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_endpoint_buffer);
#endif
if (stream -> ux_device_class_audio_stream_buffer)
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_buffer);
@ -505,7 +496,7 @@ ULONG i;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_audio_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -535,9 +526,9 @@ ULONG i;
/* DATE NAME DESCRIPTION */
/* */
/* 03-08-2023 Chaoqiong Xiao Initial Version 6.2.1 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* fixed error checking issue, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_audio_initialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_interrupt_task_function PORTABLE C */
/* 6.2.0 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -71,6 +71,9 @@
/* DATE NAME DESCRIPTION */
/* */
/* 10-31-2022 Yajun Xia Initial Version 6.2.0 */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* removed an error trap, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_interrupt_task_function(UX_DEVICE_CLASS_AUDIO *audio)
@ -100,13 +103,10 @@ UCHAR *buff;
/* Get endpoint instance. */
endpoint = audio -> ux_device_class_audio_interrupt;
/* Endpoint not available, maybe it's alternate setting 0. */
/* Endpoint not available, maybe it's alternate setting 0,
or not exist in framework (accepted use case). */
if (endpoint == UX_NULL)
{
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_ENDPOINT_HANDLE_UNKNOWN);
audio -> ux_device_class_audio_interrupt_task_state = UX_STATE_RESET;
return(UX_STATE_IDLE);
}

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_read_task_function PORTABLE C */
/* 6.2.0 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -71,6 +71,11 @@
/* DATE NAME DESCRIPTION */
/* */
/* 10-31-2022 Yajun Xia Initial Version 6.2.0 */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_read_task_function(UX_DEVICE_CLASS_AUDIO_STREAM *stream)
@ -116,6 +121,13 @@ UINT status;
/* Next state: transfer wait. */
stream -> ux_device_class_audio_stream_task_state = UX_DEVICE_CLASS_AUDIO_STREAM_RW_WAIT;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
/* Zero copy: directly use stream buffer for transfer. */
transfer -> ux_slave_transfer_request_data_pointer =
stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data;
#endif
/* Reset transfer state. */
UX_SLAVE_TRANSFER_STATE_RESET(transfer);
}
@ -153,9 +165,14 @@ UINT status;
/* Frame received, log it. */
stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_length = actual_length;
stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_pos = 0;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 0
/* Copy data from endpoint buffer. */
_ux_utility_memory_copy(stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data,
transfer -> ux_slave_transfer_request_data_pointer,
actual_length); /* Use case of memcpy is verified. */
#endif
/* For simple, do not advance the transfer position if there is overflow. */
next_pos = (UCHAR *)stream -> ux_device_class_audio_stream_transfer_pos;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_read_thread_entry PORTABLE C */
/* 6.2.0 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -84,6 +84,11 @@
/* 10-31-2022 Yajun Xia Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.0 */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_device_class_audio_read_thread_entry(ULONG audio_stream)
@ -127,6 +132,13 @@ ULONG actual_length;
/* Get transfer instance. */
transfer = &endpoint -> ux_slave_endpoint_transfer_request;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
/* Zero copy: directly use frame buffer. */
transfer -> ux_slave_transfer_request_data_pointer = stream ->
ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data;
#endif
/* Start frame transfer anyway. */
status = _ux_device_stack_transfer_request(transfer, max_packet_size, max_packet_size);
@ -146,9 +158,14 @@ ULONG actual_length;
/* Frame received, log it. */
stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_length = actual_length;
stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_pos = 0;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 0
/* Copy data from endpoint buffer. */
_ux_utility_memory_copy(stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data,
transfer -> ux_slave_transfer_request_data_pointer,
actual_length); /* Use case of memcpy is verified. */
#endif
/* For simple, do not advance the transfer position if there is overflow. */
next_pos = (UCHAR *)stream -> ux_device_class_audio_stream_transfer_pos;

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_uninitialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -75,10 +75,11 @@
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed standalone compile, */
/* resulting in version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
@ -118,7 +119,6 @@ ULONG i;
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_buffer);
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_endpoint_buffer);
#if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT)
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_feedback_buffer);
#endif

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_write_task_function PORTABLE C */
/* 6.2.0 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -72,6 +72,11 @@
/* DATE NAME DESCRIPTION */
/* */
/* 10-31-2022 Yajun Xia Initial Version 6.2.0 */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_write_task_function(UX_DEVICE_CLASS_AUDIO_STREAM *stream)
@ -119,9 +124,19 @@ UINT status;
/* Start frame transfer anyway (even ZLP). */
transfer_length = stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_length;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 0
/* Stack owns buffer, copy data to it. */
if (transfer_length)
_ux_utility_memory_copy(transfer -> ux_slave_transfer_request_data_pointer,
stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data, transfer_length); /* Use case of memcpy is verified. */
#else
/* Zero copy: directly use frame buffer to transfer. */
transfer -> ux_slave_transfer_request_data_pointer = stream ->
ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data;
#endif
/* Reset transfer state. */
UX_SLAVE_TRANSFER_STATE_RESET(transfer);

View File

@ -78,6 +78,11 @@
/* 10-31-2022 Yajun Xia Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.0 */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes */
/* with zero copy enabled, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_device_class_audio_write_thread_entry(ULONG audio_stream)
@ -118,9 +123,19 @@ ULONG actual_length;
/* Start frame transfer anyway (even ZLP). */
transfer_length = stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_length;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 0
/* Stack owns endpoint buffer, copy to buffer. */
if (transfer_length)
_ux_utility_memory_copy(transfer -> ux_slave_transfer_request_data_pointer,
stream -> ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data, transfer_length); /* Use case of memcpy is verified. */
#else
/* Zero copy: directly use frame buffer to transfer. */
transfer -> ux_slave_transfer_request_data_pointer = stream ->
ux_device_class_audio_stream_transfer_pos -> ux_device_class_audio_frame_data;
#endif
/* Issue transfer request, thread blocked until transfer done. */
status = _ux_device_stack_transfer_request(transfer, transfer_length, transfer_length);

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_activate PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,10 +70,10 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_activate(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_auto_seq_done PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,8 +70,8 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG icc_status)
@ -109,7 +109,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_ccid_auto_seq_done PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -142,7 +142,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG icc_status)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_hardware_error PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -67,8 +67,8 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_hardware_error(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG error)
@ -147,7 +147,7 @@ UX_DEVICE_CLASS_CCID_RDR_TO_PC_SLOT_STATUS_HEADER *rsp;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_ccid_hardware_error PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -178,7 +178,7 @@ UX_DEVICE_CLASS_CCID_RDR_TO_PC_SLOT_STATUS_HEADER *rsp;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_ccid_hardware_error(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG error)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_icc_insert PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -70,8 +70,8 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_icc_insert(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG seq_start)
@ -134,7 +134,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_ccid_icc_insert PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -165,7 +165,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_ccid_icc_insert(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG seq_start)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_icc_remove PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -66,8 +66,8 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_icc_remove(UX_DEVICE_CLASS_CCID *ccid, ULONG slot)
@ -127,7 +127,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_ccid_icc_remove PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -157,7 +157,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_ccid_icc_remove(UX_DEVICE_CLASS_CCID *ccid, ULONG slot)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -75,10 +75,10 @@
/* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.2.1 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_initialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_time_extension PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -64,8 +64,8 @@
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_time_extension(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG wt)
@ -134,7 +134,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_ccid_icc_insert PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -167,7 +167,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_ccid_time_extension(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG wt)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_uninitialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -66,10 +66,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_uninitialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_bulkin_thread PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -92,11 +92,11 @@
/* names conflict C++ keyword, */
/* added auto ZLP support, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_device_class_cdc_acm_bulkin_thread(ULONG cdc_acm_class)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_bulkout_thread PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -83,11 +83,11 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_device_class_cdc_acm_bulkout_thread(ULONG cdc_acm_class)

View File

@ -37,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -87,11 +87,11 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_ioctl PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -96,8 +96,8 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,
@ -365,7 +365,7 @@ UX_SLAVE_TRANSFER *transfer_request;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_cdc_acm_ioctl PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -397,7 +397,7 @@ UX_SLAVE_TRANSFER *transfer_request;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_read PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -90,11 +90,11 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Yajun Xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun Xia, CQ Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
@ -273,7 +273,7 @@ ULONG local_requested_length;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_cdc_acm_read PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -308,7 +308,7 @@ ULONG local_requested_length;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,

View File

@ -37,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_read_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -83,12 +83,12 @@
/* 10-31-2022 Yajun Xia Modified comment(s), */
/* fixed return code, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Yajun Xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun Xia, CQ Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* fixed return code, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm,
@ -322,7 +322,7 @@ UINT status = UX_SUCCESS;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_cdc_acm_read_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -363,7 +363,7 @@ UINT status = UX_SUCCESS;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm,

View File

@ -43,7 +43,7 @@ static inline VOID _ux_device_class_cdc_acm_transmission_write_run(UX_SLAVE_CLAS
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_tasks_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -86,11 +86,11 @@ static inline VOID _ux_device_class_cdc_acm_transmission_write_run(UX_SLAVE_CLAS
/* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
/* fixed compile warnings, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_uninitialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -82,11 +82,11 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_uninitialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_write PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -92,11 +92,11 @@
/* names conflict C++ keyword, */
/* added auto ZLP support, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Yajun Xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun Xia, CQ Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
@ -305,7 +305,7 @@ UINT status = 0;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_cdc_acm_write PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -340,7 +340,7 @@ UINT status = 0;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,

View File

@ -37,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_write_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -87,12 +87,12 @@
/* 10-31-2022 Yajun Xia Modified comment(s), */
/* fixed return code, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Yajun Xia, CQ Xiao Modified comment(s), */
/* 10-31-2023 Yajun Xia, CQ Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* fixed return code, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm,
@ -341,7 +341,7 @@ UINT zlp = UX_FALSE;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_cdc_acm_write_run PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -381,7 +381,7 @@ UINT zlp = UX_FALSE;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm,

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_acm_write_with_callback PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -81,8 +81,8 @@
/* resulting in version 6.1.10 */
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1.11 */
/* xx-xx-xxxx Yajun Xia Modified comment(s), */
/* resulting in version 6.x */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
@ -172,7 +172,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_cdc_acm_write_with_callback PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -205,7 +205,7 @@ UINT status;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_activate PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -82,10 +82,11 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_activate(UX_SLAVE_CLASS_COMMAND *command)
@ -200,7 +201,7 @@ ULONG physical_address_lsw;
/* We have found the bulk in endpoint, save it. */
cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_endpoint = endpoint;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && !defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
endpoint -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer =
UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER(cdc_ecm);
#endif
@ -215,7 +216,7 @@ ULONG physical_address_lsw;
/* We have found the bulk out endpoint, save it. */
cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_endpoint = endpoint;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && !defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
endpoint -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer =
UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER(cdc_ecm);
#endif
@ -240,11 +241,17 @@ ULONG physical_address_lsw;
/* Wake up the Interrupt thread and send a network notification to the host. */
_ux_device_event_flags_set(&cdc_ecm -> ux_slave_class_cdc_ecm_event_flags_group, UX_DEVICE_CLASS_CDC_ECM_NETWORK_NOTIFICATION_EVENT, UX_OR);
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
/* There is no endpoint buffer. */
#else
/* Reset the endpoint buffers. */
_ux_utility_memory_set(cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_endpoint -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer, 0, UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE); /* Use case of memset is verified. */
_ux_utility_memory_set(cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_endpoint -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer, 0, UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE); /* Use case of memset is verified. */
#endif
/* Resume the endpoint threads. */
_ux_device_thread_resume(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread);

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_bulkin_thread PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -86,10 +86,11 @@
/* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
/* used NX API to copy data, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_device_class_cdc_ecm_bulkin_thread(ULONG cdc_ecm_class)
@ -104,6 +105,9 @@ ULONG actual_flags;
NX_PACKET *current_packet;
ULONG transfer_length;
ULONG copied;
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY) && !defined(NX_DISABLE_PACKET_CHAIN)
NX_PACKET *packet;
#endif
/* Cast properly the cdc_ecm instance. */
UX_THREAD_EXTENSION_PTR_GET(class_ptr, UX_SLAVE_CLASS, cdc_ecm_class)
@ -154,7 +158,84 @@ ULONG copied;
/* If the link is down no need to rearm a packet. */
if (cdc_ecm -> ux_slave_class_cdc_ecm_link_state == UX_DEVICE_CLASS_CDC_ECM_LINK_STATE_UP)
{
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
/* Default to success. */
status = UX_SUCCESS;
#ifndef NX_DISABLE_PACKET_CHAIN
/* Check if packet is chained, allocate a new packet to fill the total data. */
if (current_packet -> nx_packet_next)
{
/* Check if collection of chained data can fit in one packet. */
if (current_packet -> nx_packet_length >
current_packet -> nx_packet_pool_owner -> nx_packet_pool_payload_size)
status = UX_TRANSFER_BUFFER_OVERFLOW;
else
{
/* Allocate a new packet for chain data collection. */
status = nx_packet_allocate(cdc_ecm -> ux_slave_class_cdc_ecm_packet_pool, &packet,
NX_RECEIVE_PACKET, UX_MS_TO_TICK(UX_DEVICE_CLASS_CDC_ECM_PACKET_POOL_WAIT));
if (status == UX_SUCCESS)
{
/* Copy the packet to the buffer. */
status = nx_packet_data_extract_offset(current_packet, 0,
packet -> nx_packet_prepend_ptr,
current_packet -> nx_packet_length, &copied);
if (status == NX_SUCCESS)
{
packet -> nx_packet_length = current_packet -> nx_packet_length;
/* Release the chained packet. */
nx_packet_transmit_release(current_packet);
/* Use copied packet instead. */
current_packet = packet;
}
}
}
/* Can not copy/buffer issue. */
if (status != UX_SUCCESS)
status = UX_TRANSFER_BUFFER_OVERFLOW;
}
#endif
if (status == UX_SUCCESS)
{
/* Set the transfer request data pointer to the packet buffer. */
transfer_request -> ux_slave_transfer_request_data_pointer = current_packet -> nx_packet_prepend_ptr;
/* Calculate the transfer length. */
transfer_length = current_packet -> nx_packet_length;
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_CDC_ECM_PACKET_TRANSMIT, cdc_ecm, 0, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
/* Send the request to the device controller. */
status = _ux_device_stack_transfer_request(transfer_request, transfer_length, transfer_length + 1);
}
/* Check error code. */
if (status != UX_SUCCESS)
{
/* Is this not a transfer abort? (this is expected to happen) */
if (status != UX_TRANSFER_BUS_RESET)
{
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, status);
}
}
#else
/* Can the packet fit in the transfer requests data buffer? */
if (current_packet -> nx_packet_length <= UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE)
{
@ -197,6 +278,7 @@ ULONG copied;
/* Report error to application. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_TRANSFER_BUFFER_OVERFLOW);
}
#endif
}
/* Free the packet that was just sent. First do some housekeeping. */

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_bulkout_thread PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -88,10 +88,11 @@
/* used pool from NX IP inst, */
/* used NX API to copy data, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
VOID _ux_device_class_cdc_ecm_bulkout_thread(ULONG cdc_ecm_class)
@ -171,10 +172,20 @@ USB_NETWORK_DEVICE_TYPE *ux_nx_device;
/* Reset the queue pointer of this packet. */
packet -> nx_packet_queue_next = UX_NULL;
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
/* Send the request to the device controller. */
transfer_request -> ux_slave_transfer_request_data_pointer = packet -> nx_packet_prepend_ptr + sizeof(USHORT);
status = _ux_device_stack_transfer_request(transfer_request,
packet -> nx_packet_pool_owner -> nx_packet_pool_payload_size - sizeof(USHORT),
packet -> nx_packet_pool_owner -> nx_packet_pool_payload_size - sizeof(USHORT));
#else
/* Send the request to the device controller. */
status = _ux_device_stack_transfer_request(transfer_request, UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE,
UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE);
#endif
/* Check the completion code. */
if (status == UX_SUCCESS)
@ -188,6 +199,15 @@ USB_NETWORK_DEVICE_TYPE *ux_nx_device;
packet -> nx_packet_prepend_ptr += sizeof(USHORT);
packet -> nx_packet_append_ptr += sizeof(USHORT);
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
/* Data already in packet. */
packet -> nx_packet_length = transfer_request -> ux_slave_transfer_request_actual_length;
/* Send that packet to the NetX USB broker. */
_ux_network_driver_packet_received(cdc_ecm -> ux_slave_class_cdc_ecm_network_handle, packet);
#else
/* Copy the received packet in the IP packet data area. */
status = nx_packet_data_append(packet,
transfer_request -> ux_slave_transfer_request_data_pointer,
@ -207,6 +227,7 @@ USB_NETWORK_DEVICE_TYPE *ux_nx_device;
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_CLASS_MALFORMED_PACKET_RECEIVED_ERROR);
nx_packet_release(packet);
}
#endif
}
else

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_change PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -85,10 +85,11 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_change(UX_SLAVE_CLASS_COMMAND *command)
@ -130,7 +131,7 @@ UX_SLAVE_ENDPOINT *endpoint;
/* We have found the bulk in endpoint, save it. */
cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_endpoint = endpoint;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && !defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
endpoint -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer =
UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER(cdc_ecm);
@ -143,7 +144,7 @@ UX_SLAVE_ENDPOINT *endpoint;
/* We have found the bulk out endpoint, save it. */
cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_endpoint = endpoint;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && !defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
endpoint -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer =
UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER(cdc_ecm);
@ -166,11 +167,17 @@ UX_SLAVE_ENDPOINT *endpoint;
/* Communicate the state with the network driver. */
_ux_network_driver_link_up(cdc_ecm -> ux_slave_class_cdc_ecm_network_handle);
#if (UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1) && defined(UX_DEVICE_CLASS_CDC_ECM_ZERO_COPY)
/* There is no endpoint buffer. */
#else
/* Reset the endpoint buffers. */
_ux_utility_memory_set(cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_endpoint -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer, 0, UX_DEVICE_CLASS_CDC_ECM_BULKOUT_BUFFER_SIZE); /* Use case of memset is verified. */
_ux_utility_memory_set(cdc_ecm -> ux_slave_class_cdc_ecm_bulkin_endpoint -> ux_slave_endpoint_transfer_request.
ux_slave_transfer_request_data_pointer, 0, UX_DEVICE_CLASS_CDC_ECM_BULKIN_BUFFER_SIZE); /* Use case of memset is verified. */
#endif
/* Resume the endpoint threads. */
_ux_device_thread_resume(&cdc_ecm -> ux_slave_class_cdc_ecm_bulkout_thread);

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -89,10 +89,10 @@
/* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
/* removed internal NX pool, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_initialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_cdc_ecm_uninitialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -85,10 +85,10 @@
/* 10-31-2022 Chaoqiong Xiao Modified comment(s), */
/* removed internal NX pool, */
/* resulting in version 6.2.0 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_cdc_ecm_uninitialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_dfu_entry PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -72,9 +72,9 @@
/* 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 Yajun Xia Modified comment(s), */
/* 10-31-2023 Yajun Xia Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_dfu_entry(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -260,7 +260,7 @@ ULONG descriptor_length;
/* FUNCTION RELEASE */
/* */
/* _uxe_device_class_dfu_initialize PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Yajun Xia, Microsoft Corporation */
@ -291,7 +291,7 @@ ULONG descriptor_length;
/* */
/* DATE NAME DESCRIPTION */
/* */
/* xx-xx-xxxx Yajun Xia Initial Version 6.x */
/* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
/* */
/**************************************************************************/
UINT _uxe_device_class_dfu_initialize(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_hid_activate PORTABLE C */
/* 6.x */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@ -84,11 +84,11 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added zero copy support, */
/* added a new mode to manage */
/* endpoint buffer in classes, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_hid_activate(UX_SLAVE_CLASS_COMMAND *command)

View File

@ -73,9 +73,9 @@
/* 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), */
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */
/* added error checks support, */
/* resulting in version 6.x */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _ux_device_class_hid_entry(UX_SLAVE_CLASS_COMMAND *command)

Some files were not shown because too many files have changed in this diff Show More