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 /**   PIMA 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_pima.h"
30 #include "ux_host_stack.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_host_class_pima_object_copy                     PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function copies one object from one location to another.       */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    pima                                       Pointer to pima class    */
50 /*    pima_session                               Pointer to pima session  */
51 /*    object_handle                              Object handle to move    */
52 /*    storage_id                                 destination storage ID   */
53 /*    parent_object_handle                       Parent object handle     */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    Completion Status                                                   */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*  _ux_host_class_pima_command                 Pima command function     */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    USB application                                                     */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
72 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_ux_host_class_pima_object_copy(UX_HOST_CLASS_PIMA * pima,UX_HOST_CLASS_PIMA_SESSION * pima_session,ULONG object_handle,ULONG storage_id,ULONG parent_object_handle)76 UINT  _ux_host_class_pima_object_copy(UX_HOST_CLASS_PIMA *pima,
77                                         UX_HOST_CLASS_PIMA_SESSION *pima_session,
78                                         ULONG object_handle,
79                                         ULONG storage_id,
80                                         ULONG parent_object_handle)
81 {
82 
83 UX_HOST_CLASS_PIMA_COMMAND          command;
84 UINT                                status;
85 
86     /* If trace is enabled, insert this event into the trace buffer.  */
87     UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_PIMA_OBJECT_COPY, pima, object_handle, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
88 
89     /* Check if this session is valid or not.  */
90     if (pima_session -> ux_host_class_pima_session_magic != UX_HOST_CLASS_PIMA_MAGIC_NUMBER)
91         return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
92 
93     /* Check if this session is opened or not.  */
94     if (pima_session -> ux_host_class_pima_session_state != UX_HOST_CLASS_PIMA_SESSION_STATE_OPENED)
95         return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
96 
97     /* Issue command to get the object info.  3 parameter.  */
98     command.ux_host_class_pima_command_nb_parameters =  3;
99 
100     /* Parameter 1 is the Object Handle.  */
101     command.ux_host_class_pima_command_parameter_1 =  object_handle;
102 
103     /* Parameter 2 is the Storage ID.  */
104     command.ux_host_class_pima_command_parameter_2 =  storage_id;
105 
106     /* Parameter 3 is the Parent Object ID.  */
107     command.ux_host_class_pima_command_parameter_3 =  parent_object_handle;
108 
109     /* Other parameters unused.  */
110     command.ux_host_class_pima_command_parameter_4 =  0;
111     command.ux_host_class_pima_command_parameter_5 =  0;
112 
113     /* Then set the command to COPY_OBJECT.  */
114     command.ux_host_class_pima_command_operation_code =  UX_HOST_CLASS_PIMA_OC_COPY_OBJECT;
115 
116     /* Issue the command.  */
117     status = _ux_host_class_pima_command(pima, &command, UX_HOST_CLASS_PIMA_DATA_PHASE_NONE , UX_NULL,
118                                         0, 0);
119 
120     /* Return completion status.  */
121     return(status);
122 }
123 
124