1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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 |
|
|
/**************************************************************************/ |
67 |
|
1979 |
VOID _ux_host_stack_endpoint_instance_delete(UX_ENDPOINT *endpoint) |
68 |
|
|
{ |
69 |
|
|
|
70 |
|
|
UX_HCD *hcd; |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
/* Obtain the HCD for this endpoint. */ |
74 |
|
1979 |
hcd = UX_DEVICE_HCD_GET(endpoint -> ux_endpoint_device); |
75 |
|
|
|
76 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
77 |
|
|
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) |
78 |
|
|
|
79 |
|
|
/* Ensure the endpoint had its physical ED allocated. */ |
80 |
✓✓ |
1979 |
if (endpoint -> ux_endpoint_ed != UX_NULL) |
81 |
|
|
{ |
82 |
|
|
|
83 |
|
|
/* Destroy this endpoint. */ |
84 |
|
1707 |
hcd -> ux_hcd_entry_function(hcd, UX_HCD_DESTROY_ENDPOINT, (VOID *) endpoint); |
85 |
|
|
|
86 |
|
|
/* Free the semaphore previously attached to the transfer_request of this endpoint. */ |
87 |
|
1707 |
_ux_host_semaphore_delete(&endpoint -> ux_endpoint_transfer_request.ux_transfer_request_semaphore); |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
/* If the endpoint requested guaranteed bandwidth, free it now. */ |
91 |
✓✓ |
1979 |
switch ((endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) |
92 |
|
|
{ |
93 |
|
|
|
94 |
|
840 |
case UX_CONTROL_ENDPOINT: |
95 |
|
|
case UX_BULK_ENDPOINT: |
96 |
|
|
|
97 |
|
840 |
break; |
98 |
|
|
|
99 |
|
1139 |
default: |
100 |
|
|
|
101 |
|
|
/* Reclaim its bandwidth. */ |
102 |
|
1139 |
_ux_host_stack_bandwidth_release(hcd, endpoint); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
/* If trace is enabled, register this object. */ |
106 |
|
|
UX_TRACE_OBJECT_UNREGISTER(endpoint); |
107 |
|
|
|
108 |
|
|
/* Return to caller. */ |
109 |
|
1979 |
return; |
110 |
|
|
} |
111 |
|
|
|