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 /** Host Stack */
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_stack.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_host_stack_endpoint_instance_delete PORTABLE C */
37 /* 6.1.10 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function will delete an endpoint instance. It does not delete */
45 /* the endpoint container but it removes the HCD endpoint and reclaims */
46 /* the bandwidth. */
47 /* */
48 /* INPUT */
49 /* */
50 /* endpoint Endpoint to delete */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* None */
55 /* */
56 /* CALLS */
57 /* */
58 /* _ux_host_stack_bandwidth_release Release bandwidth */
59 /* _ux_utility_semaphore_delete Semaphore delete */
60 /* (ux_hcd_entry_function) HCD entry function */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* USBX Components */
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 /* optimized based on compile */
73 /* definitions, */
74 /* resulting in version 6.1 */
75 /* 06-02-2021 Chaoqiong Xiao Modified comment(s), */
76 /* fixed trace enabled error, */
77 /* resulting in version 6.1.7 */
78 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
79 /* added standalone support, */
80 /* resulting in version 6.1.10 */
81 /* */
82 /**************************************************************************/
_ux_host_stack_endpoint_instance_delete(UX_ENDPOINT * endpoint)83 VOID _ux_host_stack_endpoint_instance_delete(UX_ENDPOINT *endpoint)
84 {
85
86 UX_HCD *hcd;
87
88
89 /* Obtain the HCD for this endpoint. */
90 hcd = UX_DEVICE_HCD_GET(endpoint -> ux_endpoint_device);
91
92 /* If trace is enabled, insert this event into the trace buffer. */
93 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_ENDPOINT_INSTANCE_DELETE, endpoint -> ux_endpoint_device, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
94
95 /* Ensure the endpoint had its physical ED allocated. */
96 if (endpoint -> ux_endpoint_ed != UX_NULL)
97 {
98
99 /* Destroy this endpoint. */
100 hcd -> ux_hcd_entry_function(hcd, UX_HCD_DESTROY_ENDPOINT, (VOID *) endpoint);
101
102 /* Free the semaphore previously attached to the transfer_request of this endpoint. */
103 _ux_host_semaphore_delete(&endpoint -> ux_endpoint_transfer_request.ux_transfer_request_semaphore);
104 }
105
106 /* If the endpoint requested guaranteed bandwidth, free it now. */
107 switch ((endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE)
108 {
109
110 case UX_CONTROL_ENDPOINT:
111 case UX_BULK_ENDPOINT:
112
113 break;
114
115 default:
116
117 /* Reclaim its bandwidth. */
118 _ux_host_stack_bandwidth_release(hcd, endpoint);
119 }
120
121 /* If trace is enabled, register this object. */
122 UX_TRACE_OBJECT_UNREGISTER(endpoint);
123
124 /* Return to caller. */
125 return;
126 }
127
128