1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** USBX Component                                                        */
17 /**                                                                       */
18 /**   Host Data Pump Class                                                */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /* Include necessary system files.  */
25 
26 #define UX_SOURCE_CODE
27 
28 #include "ux_api.h"
29 #include "ux_host_class_dpump.h"
30 #include "ux_host_stack.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_host_class_dpump_entry                          PORTABLE C      */
38 /*                                                           6.1.10       */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function is the entry point of the dpump class. It will be     */
46 /*    called by the USBX stack enumeration module when there is a new     */
47 /*    dpump on the bus or when the USB dpump is removed.                  */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    command                                Data pump class command      */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    Completion Status                                                   */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    _ux_host_class_dpump_activate       Activate dpump class            */
60 /*    _ux_host_class_dpump_deactivate     Deactivate dpump class          */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Data pump Class                                                     */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
71 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
74 /*                                            added standalone support,   */
75 /*                                            resulting in version 6.1.10 */
76 /*                                                                        */
77 /**************************************************************************/
_ux_host_class_dpump_entry(UX_HOST_CLASS_COMMAND * command)78 UINT  _ux_host_class_dpump_entry(UX_HOST_CLASS_COMMAND *command)
79 {
80 
81 UINT    status;
82 
83 
84     /* The command request will tell us we need to do here, either a enumeration
85        query, an activation or a deactivation.  */
86     switch (command -> ux_host_class_command_request)
87     {
88 
89     case UX_HOST_CLASS_COMMAND_QUERY:
90 
91         /* The query command is used to let the stack enumeration process know if we want to own
92            this device or not.  */
93         if((command -> ux_host_class_command_usage == UX_HOST_CLASS_COMMAND_USAGE_CSP) &&
94                              (command -> ux_host_class_command_class == UX_HOST_CLASS_DPUMP_CLASS) &&
95                              (command -> ux_host_class_command_subclass == UX_HOST_CLASS_DPUMP_SUBCLASS) &&
96                              (command -> ux_host_class_command_protocol == UX_HOST_CLASS_DPUMP_PROTOCOL))
97             return(UX_SUCCESS);
98         else
99             return(UX_NO_CLASS_MATCH);
100 
101     case UX_HOST_CLASS_COMMAND_ACTIVATE:
102 
103         /* The activate command is used when the device inserted has found a parent and
104            is ready to complete the enumeration.  */
105         status =  _ux_host_class_dpump_activate(command);
106         return(status);
107 
108     case UX_HOST_CLASS_COMMAND_ACTIVATE_WAIT:
109         return(UX_STATE_NEXT);
110 
111     case UX_HOST_CLASS_COMMAND_DEACTIVATE:
112 
113         /* The deactivate command is used when the device has been extracted either
114            directly or when its parents has been extracted.  */
115         status =  _ux_host_class_dpump_deactivate(command);
116         return(status);
117 
118     default:
119 
120         /* Error trap. */
121         _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_FUNCTION_NOT_SUPPORTED);
122 
123         /* If trace is enabled, insert this event into the trace buffer.  */
124         UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
125 
126         return(UX_FUNCTION_NOT_SUPPORTED);
127     }
128 }
129 
130