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 /** */
14 /** USBX Component */
15 /** */
16 /** Device CCID Class */
17 /** */
18 /**************************************************************************/
19 /**************************************************************************/
20
21 #define UX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "ux_api.h"
27 #include "ux_device_class_ccid.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_ccid_entry PORTABLE C */
36 /* 6.1.11 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function is the entry point of the device CCID class. It */
44 /* will be called by the device stack enumeration module when the */
45 /* host has sent a SET_CONFIGURATION command and the ccid interface */
46 /* needs to be mounted. */
47 /* */
48 /* INPUT */
49 /* */
50 /* command Pointer to class command */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* Completion Status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _ux_device_class_ccid_initialize Initialize ccid class */
59 /* _ux_device_class_ccid_uninitialize Uninitialize ccid class */
60 /* _ux_device_class_ccid_activate Activate ccid class */
61 /* _ux_device_class_ccid_deactivate Deactivate ccid class */
62 /* _ux_device_class_ccid_control_request Request control */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* USBX Device Stack */
67 /* */
68 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 04-25-2022 Chaoqiong Xiao Initial Version 6.1.11 */
73 /* */
74 /**************************************************************************/
_ux_device_class_ccid_entry(UX_SLAVE_CLASS_COMMAND * command)75 UINT _ux_device_class_ccid_entry(UX_SLAVE_CLASS_COMMAND *command)
76 {
77
78 UINT status;
79
80
81 /* The command request will tell us we need to do here, either a enumeration
82 query, an activation or a deactivation. */
83 switch (command -> ux_slave_class_command_request)
84 {
85
86 case UX_SLAVE_CLASS_COMMAND_INITIALIZE:
87
88 /* Call the init function of the CCID class. */
89 status = _ux_device_class_ccid_initialize(command);
90
91 /* Return the completion status. */
92 return(status);
93
94 case UX_SLAVE_CLASS_COMMAND_UNINITIALIZE:
95
96 /* Call the init function of the CCID class. */
97 status = _ux_device_class_ccid_uninitialize(command);
98
99 /* Return the completion status. */
100 return(status);
101
102 case UX_SLAVE_CLASS_COMMAND_QUERY:
103
104 /* Check the CLASS definition in the interface descriptor. */
105 if (command -> ux_slave_class_command_class == UX_DEVICE_CLASS_CCID_CLASS)
106 return(UX_SUCCESS);
107 else
108 return(UX_NO_CLASS_MATCH);
109
110 case UX_SLAVE_CLASS_COMMAND_ACTIVATE:
111
112 /* The activate command is used when the host has sent a SET_CONFIGURATION command
113 and this interface has to be mounted. Both Bulk endpoints have to be mounted
114 and the ccid thread needs to be activated. */
115 status = _ux_device_class_ccid_activate(command);
116
117 /* Return the completion status. */
118 return(status);
119
120 case UX_SLAVE_CLASS_COMMAND_DEACTIVATE:
121
122 /* The deactivate command is used when the device has been extracted.
123 The device endpoints have to be dismounted and the ccid thread canceled. */
124 status = _ux_device_class_ccid_deactivate(command);
125
126 /* Return the completion status. */
127 return(status);
128
129 case UX_SLAVE_CLASS_COMMAND_REQUEST:
130
131 /* The request command is used when the host sends a command on the control endpoint. */
132 status = _ux_device_class_ccid_control_request(command);
133
134 /* Return the completion status. */
135 return(status);
136
137 default:
138
139 /* If trace is enabled, insert this event into the trace buffer. */
140 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
141
142 /* Return an error. */
143 return(UX_FUNCTION_NOT_SUPPORTED);
144 }
145 }
146