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_delete                   PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function deletes an object. If the object handle is set to     */
46 /*    0xFFFFFFFF then all objects on the media are deleted.               */
47 /*                                                                        */
48 /*                                                                        */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    pima                                       Pointer to pima class    */
53 /*    pima_session                               Pointer to pima session  */
54 /*    object_handle                              The object handle        */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    Completion Status                                                   */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*  _ux_host_class_pima_command                 Pima command function     */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    USB application                                                     */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
73 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_ux_host_class_pima_object_delete(UX_HOST_CLASS_PIMA * pima,UX_HOST_CLASS_PIMA_SESSION * pima_session,ULONG object_handle)77 UINT  _ux_host_class_pima_object_delete(UX_HOST_CLASS_PIMA *pima,
78                                         UX_HOST_CLASS_PIMA_SESSION *pima_session,
79                                         ULONG 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_DELETE, 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.  1 parameter.  */
97     command.ux_host_class_pima_command_nb_parameters =  1;
98 
99     /* Parameter 1 is the Object Handle.  */
100     command.ux_host_class_pima_command_parameter_1 =  object_handle;
101 
102     /* Other parameters unused.  */
103     command.ux_host_class_pima_command_parameter_2 =  0;
104     command.ux_host_class_pima_command_parameter_3 =  0;
105     command.ux_host_class_pima_command_parameter_4 =  0;
106     command.ux_host_class_pima_command_parameter_5 =  0;
107 
108     /* Then set the command to DELETE_OBJECT.  */
109     command.ux_host_class_pima_command_operation_code =  UX_HOST_CLASS_PIMA_OC_DELETE_OBJECT;
110 
111     /* Issue the command.  */
112     status = _ux_host_class_pima_command(pima, &command, UX_HOST_CLASS_PIMA_DATA_PHASE_NONE , UX_NULL,
113                                         0, 0);
114 
115     /* Return completion status.  */
116     return(status);
117 }
118 
119