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_delete PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function deletes an object. If the object handle is set to */
45 /* 0xFFFFFFFF then all objects on the media are deleted. */
46 /* */
47 /* */
48 /* */
49 /* INPUT */
50 /* */
51 /* pima Pointer to pima class */
52 /* pima_session Pointer to pima session */
53 /* object_handle The 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_delete(UX_HOST_CLASS_PIMA * pima,UX_HOST_CLASS_PIMA_SESSION * pima_session,ULONG object_handle)76 UINT _ux_host_class_pima_object_delete(UX_HOST_CLASS_PIMA *pima,
77 UX_HOST_CLASS_PIMA_SESSION *pima_session,
78 ULONG object_handle)
79 {
80
81 UX_HOST_CLASS_PIMA_COMMAND command;
82 UINT status;
83
84 /* If trace is enabled, insert this event into the trace buffer. */
85 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_PIMA_OBJECT_DELETE, pima, object_handle, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
86
87 /* Check if this session is valid or not. */
88 if (pima_session -> ux_host_class_pima_session_magic != UX_HOST_CLASS_PIMA_MAGIC_NUMBER)
89 return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
90
91 /* Check if this session is opened or not. */
92 if (pima_session -> ux_host_class_pima_session_state != UX_HOST_CLASS_PIMA_SESSION_STATE_OPENED)
93 return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
94
95 /* Issue command to get the object info. 1 parameter. */
96 command.ux_host_class_pima_command_nb_parameters = 1;
97
98 /* Parameter 1 is the Object Handle. */
99 command.ux_host_class_pima_command_parameter_1 = object_handle;
100
101 /* Other parameters unused. */
102 command.ux_host_class_pima_command_parameter_2 = 0;
103 command.ux_host_class_pima_command_parameter_3 = 0;
104 command.ux_host_class_pima_command_parameter_4 = 0;
105 command.ux_host_class_pima_command_parameter_5 = 0;
106
107 /* Then set the command to DELETE_OBJECT. */
108 command.ux_host_class_pima_command_operation_code = UX_HOST_CLASS_PIMA_OC_DELETE_OBJECT;
109
110 /* Issue the command. */
111 status = _ux_host_class_pima_command(pima, &command, UX_HOST_CLASS_PIMA_DATA_PHASE_NONE , UX_NULL,
112 0, 0);
113
114 /* Return completion status. */
115 return(status);
116 }
117
118 /**************************************************************************/
119 /* */
120 /* FUNCTION RELEASE */
121 /* */
122 /* _uxe_host_class_pima_object_delete PORTABLE C */
123 /* 6.3.0 */
124 /* AUTHOR */
125 /* */
126 /* Yajun Xia, Microsoft Corporation */
127 /* */
128 /* DESCRIPTION */
129 /* */
130 /* This function checks errors in pima object delete function call. */
131 /* */
132 /* INPUT */
133 /* */
134 /* pima Pointer to pima class */
135 /* pima_session Pointer to pima session */
136 /* object_handle The object handle */
137 /* */
138 /* OUTPUT */
139 /* */
140 /* Completion Status */
141 /* */
142 /* CALLS */
143 /* */
144 /* _ux_host_class_pima_object_delete Delete pima object */
145 /* */
146 /* CALLED BY */
147 /* */
148 /* USB application */
149 /* */
150 /* RELEASE HISTORY */
151 /* */
152 /* DATE NAME DESCRIPTION */
153 /* */
154 /* 10-31-2023 Yajun xia Initial Version 6.3.0 */
155 /* */
156 /**************************************************************************/
_uxe_host_class_pima_object_delete(UX_HOST_CLASS_PIMA * pima,UX_HOST_CLASS_PIMA_SESSION * pima_session,ULONG object_handle)157 UINT _uxe_host_class_pima_object_delete(UX_HOST_CLASS_PIMA *pima,
158 UX_HOST_CLASS_PIMA_SESSION *pima_session,
159 ULONG object_handle)
160 {
161
162 /* Sanity checks. */
163 if ((pima == UX_NULL) || (pima_session == UX_NULL))
164 return(UX_INVALID_PARAMETER);
165
166 /* Call the actual pima object delete function. */
167 return(_ux_host_class_pima_object_delete(pima, pima_session, object_handle));
168 }