1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11 /**************************************************************************/
12 /** */
13 /** USBX Component */
14 /** */
15 /** Device CCID Class */
16 /** */
17 /**************************************************************************/
18 /**************************************************************************/
19
20 #define UX_SOURCE_CODE
21
22
23 /* Include necessary system files. */
24
25 #include "ux_api.h"
26 #include "ux_device_class_ccid.h"
27 #include "ux_device_stack.h"
28
29
30 /**************************************************************************/
31 /* */
32 /* FUNCTION RELEASE */
33 /* */
34 /* _ux_device_class_ccid_auto_seq_done PORTABLE C */
35 /* 6.3.0 */
36 /* AUTHOR */
37 /* */
38 /* Chaoqiong Xiao, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function indicates card auto sequencing done of the USB CCID */
43 /* device. */
44 /* */
45 /* Note it must be used after _icc_insert with seq_start TRUE. */
46 /* */
47 /* INPUT */
48 /* */
49 /* ccid Pointer to ccid instance */
50 /* slot Slot inserted */
51 /* icc_status Final card status */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* Completion Status */
56 /* */
57 /* CALLS */
58 /* */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
69 /* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
70 /* added standalone support, */
71 /* resulting in version 6.2.1 */
72 /* 10-31-2023 Yajun Xia Modified comment(s), */
73 /* resulting in version 6.3.0 */
74 /* */
75 /**************************************************************************/
_ux_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID * ccid,ULONG slot,ULONG icc_status)76 UINT _ux_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG icc_status)
77 {
78
79 UX_DEVICE_CLASS_CCID_SLOT *ccid_slot;
80
81 /* Sanity check. */
82 if (slot >= ccid -> ux_device_class_ccid_parameter.ux_device_class_ccid_max_n_slots)
83 return(UX_INVALID_PARAMETER);
84
85 /* Get slot instance. */
86 ccid_slot = ccid -> ux_device_class_ccid_slots;
87 ccid_slot += slot;
88
89 /* Lock states. */
90 _ux_device_class_ccid_lock(ccid);
91
92 /* Check sequencing. */
93 if (ccid_slot -> ux_device_class_ccid_slot_flags & UX_DEVICE_CLASS_CCID_FLAG_AUTO_SEQUENCING)
94 {
95 ccid_slot -> ux_device_class_ccid_slot_icc_status = (UCHAR)icc_status;
96 ccid_slot -> ux_device_class_ccid_slot_flags &= (UCHAR)~UX_DEVICE_CLASS_CCID_FLAG_AUTO_SEQUENCING;
97 }
98
99 /* Unlock states. */
100 _ux_device_class_ccid_unlock(ccid);
101
102 /* Return transfer status. */
103 return(UX_SUCCESS);
104 }
105
106 /**************************************************************************/
107 /* */
108 /* FUNCTION RELEASE */
109 /* */
110 /* _uxe_device_class_ccid_auto_seq_done PORTABLE C */
111 /* 6.3.0 */
112 /* AUTHOR */
113 /* */
114 /* Yajun Xia, Microsoft Corporation */
115 /* */
116 /* DESCRIPTION */
117 /* */
118 /* This function checks errors in CCID card auto sequencing done */
119 /* function. */
120 /* */
121 /* INPUT */
122 /* */
123 /* ccid Pointer to ccid instance */
124 /* slot Slot inserted */
125 /* icc_status Final card status */
126 /* */
127 /* OUTPUT */
128 /* */
129 /* Completion Status */
130 /* */
131 /* CALLS */
132 /* */
133 /* _ux_device_class_ccid_auto_seq_done CCID card auto sequencing */
134 /* done function. */
135 /* */
136 /* CALLED BY */
137 /* */
138 /* Application */
139 /* */
140 /* RELEASE HISTORY */
141 /* */
142 /* DATE NAME DESCRIPTION */
143 /* */
144 /* 10-31-2023 Yajun Xia Initial Version 6.3.0 */
145 /* */
146 /**************************************************************************/
_uxe_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID * ccid,ULONG slot,ULONG icc_status)147 UINT _uxe_device_class_ccid_auto_seq_done(UX_DEVICE_CLASS_CCID *ccid, ULONG slot, ULONG icc_status)
148 {
149
150 /* Sanity check. */
151 if (ccid == UX_NULL)
152 return(UX_INVALID_PARAMETER);
153
154 return(_ux_device_class_ccid_auto_seq_done(ccid, slot, icc_status));
155 }