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_transfer_abort PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function aborts a pending transfer to\from an object. */
46 /* INPUT */
47 /* */
48 /* pima Pointer to pima class */
49 /* pima_session Pointer to pima session */
50 /* object_handle The object handle */
51 /* object Pointer to object info */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* Completion Status */
56 /* */
57 /* CALLS */
58 /* */
59 /* _ux_host_class_pima_request_cancel Cancel request */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* USB application */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
70 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
71 /* resulting in version 6.1 */
72 /* */
73 /**************************************************************************/
_ux_host_class_pima_object_transfer_abort(UX_HOST_CLASS_PIMA * pima,UX_HOST_CLASS_PIMA_SESSION * pima_session,ULONG object_handle,UX_HOST_CLASS_PIMA_OBJECT * object)74 UINT _ux_host_class_pima_object_transfer_abort(UX_HOST_CLASS_PIMA *pima,
75 UX_HOST_CLASS_PIMA_SESSION *pima_session,
76 ULONG object_handle, UX_HOST_CLASS_PIMA_OBJECT *object)
77 {
78
79 UINT status;
80
81 UX_PARAMETER_NOT_USED(object_handle);
82
83 /* If trace is enabled, insert this event into the trace buffer. */
84 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_PIMA_OBJECT_TRANSFER_ABORT, pima, object_handle, object, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
85
86 /* Check if this session is valid or not. */
87 if (pima_session -> ux_host_class_pima_session_magic != UX_HOST_CLASS_PIMA_MAGIC_NUMBER)
88 return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
89
90 /* Check if this session is opened or not. */
91 if (pima_session -> ux_host_class_pima_session_state != UX_HOST_CLASS_PIMA_SESSION_STATE_OPENED)
92 return (UX_HOST_CLASS_PIMA_RC_SESSION_NOT_OPEN);
93
94 /* Check if the object is already closed. */
95 if (object -> ux_host_class_pima_object_state != UX_HOST_CLASS_PIMA_OBJECT_STATE_OPENED)
96 return (UX_HOST_CLASS_PIMA_RC_OBJECT_ALREADY_CLOSED );
97
98 /* Cancel the current request. */
99 status = _ux_host_class_pima_request_cancel(pima);
100
101 /* The transfer for this transaction was aborted. No need to issue a status phase when the object is closed. */
102 object -> ux_host_class_pima_object_transfer_status = UX_HOST_CLASS_PIMA_OBJECT_TRANSFER_STATUS_ABORTED;
103
104 /* Reset the potential ZLP condition. */
105 pima -> ux_host_class_pima_zlp_flag = UX_HOST_CLASS_PIMA_ZLP_NONE;
106
107 /* Return completion status. */
108 return(status);
109 }
110
111