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 /**                                                                       */
15 /** USBX Component                                                        */
16 /**                                                                       */
17 /**   PIMA Class                                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /* Include necessary system files.  */
24 
25 #define UX_SOURCE_CODE
26 
27 #include "ux_api.h"
28 #include "ux_host_class_pima.h"
29 #include "ux_host_stack.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _ux_host_class_pima_object_move                     PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Chaoqiong Xiao, Microsoft Corporation                               */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function moves an object from one location to another.         */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    pima                                       Pointer to pima class    */
49 /*    pima_session                               Pointer to pima session  */
50 /*    object_handle                              Object handle to move    */
51 /*    storage_id                                 destination storage ID   */
52 /*    parent_object_handle                       Parent object handle     */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    Completion Status                                                   */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*  _ux_host_class_pima_command                 Pima command function     */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    USB application                                                     */
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 /*                                                                        */
74 /**************************************************************************/
_ux_host_class_pima_object_move(UX_HOST_CLASS_PIMA * pima,UX_HOST_CLASS_PIMA_SESSION * pima_session,ULONG object_handle,ULONG storage_id,ULONG parent_object_handle)75 UINT  _ux_host_class_pima_object_move(UX_HOST_CLASS_PIMA *pima,
76                                         UX_HOST_CLASS_PIMA_SESSION *pima_session,
77                                         ULONG object_handle,
78                                         ULONG storage_id,
79                                         ULONG parent_object_handle)
80 {
81 
82 UX_HOST_CLASS_PIMA_COMMAND             command;
83 UINT                                status;
84 
85     /* If trace is enabled, insert this event into the trace buffer.  */
86     UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_PIMA_OBJECT_MOVE, pima, object_handle, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
87 
88     /* Check if this session is valid or not.  */
89     if (pima_session -> ux_host_class_pima_session_magic != UX_HOST_CLASS_PIMA_MAGIC_NUMBER)
90         return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
91 
92     /* Check if this session is opened or not.  */
93     if (pima_session -> ux_host_class_pima_session_state != UX_HOST_CLASS_PIMA_SESSION_STATE_OPENED)
94         return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
95 
96     /* Issue command to get the object info.  3 parameter.  */
97     command.ux_host_class_pima_command_nb_parameters =  3;
98 
99     /* Parameter 1 is the Object Handle.  */
100     command.ux_host_class_pima_command_parameter_1 =  object_handle;
101 
102     /* Parameter 2 is the Storage ID.  */
103     command.ux_host_class_pima_command_parameter_2 =  storage_id;
104 
105     /* Parameter 3 is the Parent Object ID.  */
106     command.ux_host_class_pima_command_parameter_3 =  parent_object_handle;
107 
108     /* Other parameters unused.  */
109     command.ux_host_class_pima_command_parameter_4 =  0;
110     command.ux_host_class_pima_command_parameter_5 =  0;
111 
112     /* Then set the command to MOVE_OBJECT.  */
113     command.ux_host_class_pima_command_operation_code =  UX_HOST_CLASS_PIMA_OC_MOVE_OBJECT;
114 
115     /* Issue the command.  */
116     status = _ux_host_class_pima_command(pima, &command, UX_HOST_CLASS_PIMA_DATA_PHASE_NONE , UX_NULL,
117                                         0, 0);
118 
119     /* Return completion status.  */
120     return(status);
121 }
122 
123