Skip to content

Commit

Permalink
Update on 16 Dec 2022. Expand to see details.
Browse files Browse the repository at this point in the history
8ff89b56 Fixed build issue with UX_MAX_DEVICES=1 in host hub standalone
e39131fc Set IPV6 Address before CDC-ECM enumerated.
0b35db7c Fixed build issue with NETX.
b4205710 Added CCID standalone support.
  • Loading branch information
xiaocq2001 committed Dec 16, 2022
1 parent 60a6524 commit 2c66db9
Show file tree
Hide file tree
Showing 19 changed files with 1,351 additions and 54 deletions.
3 changes: 3 additions & 0 deletions common/usbx_device_classes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_icc_insert.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_icc_remove.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_notify_task_run.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_notify_thread_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_response.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_runner_task_run.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_runner_thread_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_tasks_run.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_thread_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_time_extension.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_device_class_ccid_uninitialize.c
Expand Down
136 changes: 131 additions & 5 deletions common/usbx_device_classes/inc/ux_device_class_ccid.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_device_class_ccid.h PORTABLE C */
/* 6.1.11 */
/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand All @@ -39,6 +39,9 @@
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.x */
/* */
/**************************************************************************/

Expand All @@ -52,13 +55,19 @@

/* Yes, C++ compiler is present. Use standard C. */
extern "C" {

#endif

#if !defined(UX_DEVICE_STANDALONE)

/* Define CCID max number of slots, 32 for 32 bit data width. */
#define UX_DEVICE_CLASS_CCID_MAX_N_SLOTS (sizeof(ALIGN_TYPE)*8)
#define UX_DEVICE_CLASS_CCID_MAX_N_SLOTS (4*8)
#else

/* To optimize the max number of slots fixed to 1. */
#define UX_DEVICE_CLASS_CCID_MAX_N_SLOTS 1
#endif

/* Thread stack size, for RTOS mode only. */
#define UX_DEVICE_CLASS_CCID_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
#define UX_DEVICE_CLASS_CCID_NOTIFY_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
#define UX_DEVICE_CLASS_CCID_RUNNER_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE
Expand Down Expand Up @@ -893,7 +902,9 @@ typedef struct UX_DEVICE_CLASS_CCID_RDR_TO_PC_DATA_RATE_AND_CLOCK_FREQUENCY_STRU


/* Define CCID message command handles, if command handle is not defined device
reports command not supported to host. */
reports command not supported to host.
In RTOS mode return normal status code (_SUCCESS/_ERROR/...).
In standalone mode return task state status code (_STATE_NEXT/_STATE_ERROR/...). */
typedef UINT (*UX_DEVICE_CLASS_CCID_HANDLE)(ULONG slot, UX_DEVICE_CLASS_CCID_MESSAGES*);
typedef struct UX_DEVICE_CLASS_CCID_HANDLES_STRUCT
{
Expand Down Expand Up @@ -949,11 +960,18 @@ typedef struct UX_DEVICE_CLASS_CCID_RUNNER_STRUCT
CHAR ux_device_class_ccid_runner_slot;
CHAR ux_device_class_ccid_runner_id;
CHAR ux_device_class_ccid_runner_command_index;
#if !defined(UX_DEVICE_STANDALONE)
UCHAR reserved;

#if !defined(UX_DEVICE_STANDALONE)
UX_THREAD ux_device_class_ccid_runner_thread;
UCHAR *ux_device_class_ccid_runner_thread_stack;
#else
UCHAR ux_device_class_ccid_runner_state;

UX_DEVICE_CLASS_CCID_HANDLE
ux_device_class_ccid_runner_handle;
UX_DEVICE_CLASS_CCID_MESSAGES
ux_device_class_ccid_runner_messages;
#endif
} UX_DEVICE_CLASS_CCID_RUNNER;

Expand Down Expand Up @@ -1005,9 +1023,113 @@ typedef struct UX_DEVICE_CLASS_CCID_STRUCT
UX_MUTEX ux_device_class_ccid_mutex;
UX_MUTEX ux_device_class_ccid_response_mutex;
UX_SEMAPHORE ux_device_class_ccid_notify_semaphore;
#else
ULONG ux_device_class_ccid_flags;

UCHAR ux_device_class_ccid_cmd_state;
CHAR ux_device_class_ccid_cmd_index;
UCHAR ux_device_class_ccid_rsp_state;
UCHAR ux_device_class_ccid_notify_state;
#endif
} UX_DEVICE_CLASS_CCID;

/* Device CCID flags. */
#define UX_DEVICE_CLASS_CCID_FLAG_LOCK 0x0001u
#define UX_DEVICE_CLASS_CCID_FLAG_CMD_RSP 0x0010u

#if defined(UX_DEVICE_STANDALONE)
#define _ux_device_class_ccid_lock(ccid) do { \
UX_INTERRUPT_SAVE_AREA \
UX_DISABLE \
if (ccid->ux_device_class_ccid_flags & UX_DEVICE_CLASS_CCID_FLAG_LOCK) \
{ \
UX_RESTORE \
return(UX_BUSY); \
} \
ccid->ux_device_class_ccid_flags |= UX_DEVICE_CLASS_CCID_FLAG_LOCK; \
UX_RESTORE \
} while(0)
#define _ux_device_class_ccid_unlock(ccid) do { \
ccid->ux_device_class_ccid_flags &= ~UX_DEVICE_CLASS_CCID_FLAG_LOCK; \
} while(0)
#else
#define _ux_device_class_ccid_lock(ccid) _ux_device_mutex_on(&ccid -> ux_device_class_ccid_mutex)
#define _ux_device_class_ccid_unlock(ccid) _ux_device_mutex_off(&ccid -> ux_device_class_ccid_mutex)
#endif

/* Device CCID states. */
#define UX_DEVICE_CLASS_CCID_CMD_IDLE (UX_STATE_STEP + 0)
#define UX_DEVICE_CLASS_CCID_CMD_START (UX_STATE_STEP + 1)
#define UX_DEVICE_CLASS_CCID_CMD_WAIT (UX_STATE_STEP + 2)
#define UX_DEVICE_CLASS_CCID_CMD_LOCK (UX_STATE_STEP + 3)
#define UX_DEVICE_CLASS_CCID_CMD_PROCESS (UX_STATE_STEP + 4)
#define UX_DEVICE_CLASS_CCID_CMD_RSP_START (UX_STATE_STEP + 5)
static inline const char *ccidCmdStateName(const UINT s)
{
switch(s)
{
case UX_DEVICE_CLASS_CCID_CMD_IDLE: return("cmdIDLE");
case UX_DEVICE_CLASS_CCID_CMD_START: return("cmdSTART");
case UX_DEVICE_CLASS_CCID_CMD_WAIT: return("cmdWAIT");
case UX_DEVICE_CLASS_CCID_CMD_LOCK: return("cmdLOCK");
case UX_DEVICE_CLASS_CCID_CMD_PROCESS: return("cmdPROCESS");
case UX_DEVICE_CLASS_CCID_CMD_RSP_START:return("cmdRSP_START");
default: return("cmd?");
}
}

#define UX_DEVICE_CLASS_CCID_RUNNER_IDLE (UX_STATE_STEP + 0)
#define UX_DEVICE_CLASS_CCID_RUNNER_START (UX_STATE_STEP + 1)
#define UX_DEVICE_CLASS_CCID_RUNNER_HANDLE (UX_STATE_STEP + 2)
#define UX_DEVICE_CLASS_CCID_RUNNER_RSP_START (UX_STATE_STEP + 3)
static inline const char *ccidRunnerStateName(const UINT s)
{
switch(s)
{
case UX_DEVICE_CLASS_CCID_RUNNER_IDLE: return("runnerIDLE");
case UX_DEVICE_CLASS_CCID_RUNNER_START: return("runnerSTART");
case UX_DEVICE_CLASS_CCID_RUNNER_HANDLE: return("runnerHANDLE");
case UX_DEVICE_CLASS_CCID_RUNNER_RSP_START: return("runnerRSP_START");
default: return("runner?");
}
}

#define UX_DEVICE_CLASS_CCID_RSP_IDLE (UX_STATE_STEP + 0)
#define UX_DEVICE_CLASS_CCID_RSP_START (UX_STATE_STEP + 1)
#define UX_DEVICE_CLASS_CCID_RSP_WAIT (UX_STATE_STEP + 2)
#define UX_DEVICE_CLASS_CCID_RSP_LOCK (UX_STATE_STEP + 3)
#define UX_DEVICE_CLASS_CCID_RSP_UPDATE (UX_STATE_STEP + 4)
#define UX_DEVICE_CLASS_CCID_RSP_DONE (UX_STATE_STEP + 5)
static inline const char *ccidRspStateName(const UINT s)
{
switch(s)
{
case UX_DEVICE_CLASS_CCID_RSP_IDLE: return("rspIDLE");
case UX_DEVICE_CLASS_CCID_RSP_START: return("rspSTART");
case UX_DEVICE_CLASS_CCID_RSP_WAIT: return("rspWAIT");
case UX_DEVICE_CLASS_CCID_RSP_LOCK: return("rspLOCK");
case UX_DEVICE_CLASS_CCID_RSP_UPDATE: return("rspUPDATE");
case UX_DEVICE_CLASS_CCID_RSP_DONE: return("rspDONE");
default: return("rsp?");
}
}

#define UX_DEVICE_CLASS_CCID_NOTIFY_IDLE (UX_STATE_STEP + 0)
#define UX_DEVICE_CLASS_CCID_NOTIFY_LOCK (UX_STATE_STEP + 1)
#define UX_DEVICE_CLASS_CCID_NOTIFY_START (UX_STATE_STEP + 2)
#define UX_DEVICE_CLASS_CCID_NOTIFY_WAIT (UX_STATE_STEP + 3)
static inline const char *ccidNotifyStateName(const UINT s)
{
switch(s)
{
case UX_DEVICE_CLASS_CCID_NOTIFY_IDLE: return("notifyIDLE");
case UX_DEVICE_CLASS_CCID_NOTIFY_LOCK: return("notifyLOCK");
case UX_DEVICE_CLASS_CCID_NOTIFY_START: return("notifySTART");
case UX_DEVICE_CLASS_CCID_NOTIFY_WAIT: return("notifyWAIT");
default: return("notify?");
}
}

/* Define Device CCID command settings. */
extern const UX_DEVICE_CLASS_CCID_COMMAND_SETT _ux_device_class_ccid_command_sett[];

Expand All @@ -1022,6 +1144,10 @@ VOID _ux_device_class_ccid_thread_entry(ULONG ccid_instance);
VOID _ux_device_class_ccid_notify_thread_entry(ULONG ccid_instance);
VOID _ux_device_class_ccid_runner_thread_entry(ULONG runner_instance);

UINT _ux_device_class_ccid_tasks_run(VOID *instance);
UINT _ux_device_class_ccid_notify_task_run(UX_DEVICE_CLASS_CCID *ccid);
UINT _ux_device_class_ccid_runner_task_run(UX_DEVICE_CLASS_CCID *ccid);

UINT _ux_device_class_ccid_control_abort(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG seq);

UINT _ux_device_class_ccid_response(UX_DEVICE_CLASS_CCID *ccid, UCHAR *buffer, ULONG length);
Expand Down
24 changes: 23 additions & 1 deletion common/usbx_device_classes/src/ux_device_class_ccid_activate.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_activate PORTABLE C */
/* 6.1.12 */
/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -67,6 +67,9 @@
/* fixed parameter/variable */
/* names conflict C++ keyword, */
/* resulting in version 6.1.12 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_activate(UX_SLAVE_CLASS_COMMAND *command)
Expand All @@ -77,7 +80,9 @@ UX_SLAVE_CLASS *ccid_class;
UX_DEVICE_CLASS_CCID *ccid;
UX_SLAVE_ENDPOINT *endpoint;
ULONG endpoint_type;
#if !defined(UX_DEVICE_STANDALONE)
UINT i;
#endif

/* Get the class container. */
ccid_class = command -> ux_slave_class_command_class_ptr;
Expand Down Expand Up @@ -115,6 +120,22 @@ UINT i;
endpoint = endpoint -> ux_slave_endpoint_next_endpoint;
}

#if defined(UX_DEVICE_STANDALONE)

/* Initialize slots (optimized for 1 slot). */
ccid -> ux_device_class_ccid_slots -> ux_device_class_ccid_slot_runner = -1;
ccid -> ux_device_class_ccid_slots -> ux_device_class_ccid_slot_icc_status =
UX_DEVICE_CLASS_CCID_ICC_NOT_PRESENT;

/* Initialize task states. */
ccid -> ux_device_class_ccid_cmd_state = UX_DEVICE_CLASS_CCID_CMD_START;
ccid -> ux_device_class_ccid_rsp_state = UX_DEVICE_CLASS_CCID_RSP_IDLE;
ccid -> ux_device_class_ccid_notify_state = UX_DEVICE_CLASS_CCID_NOTIFY_IDLE;

/* Initialize runner task state (optimized for 1 slot). */
ccid -> ux_device_class_ccid_runners -> ux_device_class_ccid_runner_state = UX_DEVICE_CLASS_CCID_RUNNER_IDLE;
#else

/* Initialize slots. */
for (i = 0;
i < ccid -> ux_device_class_ccid_parameter.ux_device_class_ccid_max_n_slots;
Expand All @@ -139,6 +160,7 @@ UINT i;
_ux_device_thread_resume(&ccid -> ux_device_class_ccid_runners[i].
ux_device_class_ccid_runner_thread);
}
#endif

/* If there is a activate function call it. */
if (ccid -> ux_device_class_ccid_parameter.ux_device_class_ccid_instance_activate != UX_NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_auto_seq_done PORTABLE C */
/* 6.1.11 */
/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -67,6 +67,9 @@
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG icc_status)
Expand All @@ -83,7 +86,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
ccid_slot += slot;

/* Lock states. */
_ux_device_mutex_on(&ccid -> ux_device_class_ccid_mutex);
_ux_device_class_ccid_lock(ccid);

/* Check sequencing. */
if (ccid_slot -> ux_device_class_ccid_slot_flags & UX_DEVICE_CLASS_CCID_FLAG_AUTO_SEQUENCING)
Expand All @@ -93,7 +96,7 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
}

/* Unlock states. */
_ux_device_mutex_off(&ccid -> ux_device_class_ccid_mutex);
_ux_device_class_ccid_unlock(ccid);

/* Return transfer status. */
return(UX_SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_auto_seq_start PORTABLE C */
/* 6.1.11 */
/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -63,6 +63,9 @@
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_auto_seq_start(UX_DEVICE_CLASS_CCID *ccid, ULONG slot)
Expand All @@ -79,13 +82,13 @@ UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
ccid_slot += slot;

/* Lock states. */
_ux_device_mutex_on(&ccid -> ux_device_class_ccid_mutex);
_ux_device_class_ccid_lock(ccid);

/* Set state of auto sequencing. */
ccid_slot -> ux_device_class_ccid_slot_flags |= UX_DEVICE_CLASS_CCID_FLAG_AUTO_SEQUENCING;

/* Unlock states. */
_ux_device_mutex_off(&ccid -> ux_device_class_ccid_mutex);
_ux_device_class_ccid_unlock(ccid);

/* Return transfer status. */
return(UX_SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_ccid_control_abort PORTABLE C */
/* 6.1.11 */
/* 6.x */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
Expand Down Expand Up @@ -64,6 +64,9 @@
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
/* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */
/* added standalone support, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _ux_device_class_ccid_control_abort(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG seq)
Expand Down Expand Up @@ -131,6 +134,13 @@ UX_DEVICE_CLASS_CCID_MESSAGE_HEADER *msg;
}
}

#if defined(UX_DEVICE_STANDALONE)
if (ccid -> ux_device_class_ccid_cmd_state == UX_DEVICE_CLASS_CCID_CMD_WAIT)
ccid -> ux_device_class_ccid_cmd_state = UX_DEVICE_CLASS_CCID_CMD_START;
if (ccid -> ux_device_class_ccid_rsp_state == UX_DEVICE_CLASS_CCID_RSP_WAIT)
ccid -> ux_device_class_ccid_rsp_state = UX_DEVICE_CLASS_CCID_RSP_IDLE;
#endif

/* Set aborting state. */
ccid_slot -> ux_device_class_ccid_slot_aborting = UX_TRUE;
ccid_slot -> ux_device_class_ccid_slot_aborting_seq = (UCHAR)seq;
Expand Down
Loading

0 comments on commit 2c66db9

Please sign in to comment.