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_uninitialize PORTABLE C */ |
37 |
|
|
/* 6.1.10 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function uninitializes all the host code for USBX to work on a */ |
45 |
|
|
/* specific platform. */ |
46 |
|
|
/* */ |
47 |
|
|
/* Note following steps must be done before host stack uninitialize: */ |
48 |
|
|
/* All HCDs must be unregistered (devices also removed). */ |
49 |
|
|
/* All classes unregistered (clients attached also removed). */ |
50 |
|
|
/* */ |
51 |
|
|
/* INPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* Completion Status */ |
57 |
|
|
/* UX_SUCCESS Uninitialized success */ |
58 |
|
|
/* */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLS */ |
61 |
|
|
/* */ |
62 |
|
|
/* _ux_utility_memory_free Free host memory */ |
63 |
|
|
/* _ux_utility_thread_delete Delete host thread */ |
64 |
|
|
/* _ux_utility_semaphore_delete Delete host semaphore */ |
65 |
|
|
/* */ |
66 |
|
|
/* CALLED BY */ |
67 |
|
|
/* */ |
68 |
|
|
/* Application */ |
69 |
|
|
/* */ |
70 |
|
|
/**************************************************************************/ |
71 |
|
3 |
UINT _ux_host_stack_uninitialize(VOID) |
72 |
|
|
{ |
73 |
|
|
|
74 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
75 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_UNINITIALIZE, 0, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) |
76 |
|
|
|
77 |
|
|
#if !defined(UX_HOST_STANDALONE) |
78 |
|
|
/* Delete enumeration thread. */ |
79 |
|
3 |
_ux_utility_thread_delete(&_ux_system_host -> ux_system_host_enum_thread); |
80 |
|
|
|
81 |
|
|
/* Delete enumeration semaphore. */ |
82 |
|
3 |
_ux_utility_semaphore_delete(&_ux_system_host -> ux_system_host_enum_semaphore); |
83 |
|
|
|
84 |
|
|
/* Free enumeration thread stack. */ |
85 |
|
3 |
_ux_utility_memory_free(_ux_system_host -> ux_system_host_enum_thread_stack); |
86 |
|
|
|
87 |
|
|
/* Delete HCD thread. */ |
88 |
|
3 |
_ux_utility_thread_delete(&_ux_system_host -> ux_system_host_hcd_thread); |
89 |
|
|
|
90 |
|
|
/* Delete HCD semaphore. */ |
91 |
|
3 |
_ux_utility_semaphore_delete(&_ux_system_host -> ux_system_host_hcd_semaphore); |
92 |
|
|
|
93 |
|
|
/* Free HCD thread stack. */ |
94 |
|
3 |
_ux_utility_memory_free(_ux_system_host -> ux_system_host_hcd_thread_stack); |
95 |
|
|
#endif |
96 |
|
|
|
97 |
|
|
#if defined(UX_OTG_SUPPORT) && !defined(UX_OTG_STANDALONE) |
98 |
|
|
|
99 |
|
|
/* Delete HNP thread. */ |
100 |
|
|
_ux_utility_thread_delete(&_ux_system_host -> ux_system_host_hnp_polling_thread); |
101 |
|
|
|
102 |
|
|
/* Free HNP thread stack. */ |
103 |
|
|
_ux_utility_memory_free(_ux_system_host -> ux_system_host_hnp_polling_thread_stack); |
104 |
|
|
#endif |
105 |
|
|
|
106 |
|
|
/* Free HCD array. */ |
107 |
|
3 |
_ux_utility_memory_free(_ux_system_host -> ux_system_host_hcd_array); |
108 |
|
|
|
109 |
|
|
/* Free Class array. */ |
110 |
|
3 |
_ux_utility_memory_free(_ux_system_host -> ux_system_host_class_array); |
111 |
|
|
|
112 |
|
|
/* Free Device array. */ |
113 |
|
3 |
_ux_utility_memory_free(_ux_system_host -> ux_system_host_device_array); |
114 |
|
|
|
115 |
|
|
/* Return success to caller. */ |
116 |
|
3 |
return(UX_SUCCESS); |
117 |
|
|
} |