blob: 24ac9e7ab35e823764add18162119dea697bec35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Host Simulator Controller Driver */
/** */
/**************************************************************************/
/**************************************************************************/
#define UX_SOURCE_CODE
/* Include necessary system files. */
#include "ux_api.h"
#include "ux_hcd_sim_host.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_sim_host_uninitialize PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function will uninitialize the simulated host controller. */
/* The controller will release all its resources (memory, IO ...). */
/* After this, the controller will not send SOF any longer. */
/* */
/* INPUT */
/* */
/* hcd_sim_host Pointer to host controller */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_utility_memory_free Free memory block */
/* _ux_utility_timer_delete Delete timer */
/* */
/* CALLED BY */
/* */
/* Host Simulator Controller Driver */
/* */
/**************************************************************************/
UINT _ux_hcd_sim_host_uninitialize(UX_HCD_SIM_HOST *hcd_sim_host)
{
UX_HCD *hcd = hcd_sim_host -> ux_hcd_sim_host_hcd_owner;
#if defined(UX_HOST_STANDALONE)
UX_HCD_SIM_HOST_TD *td;
UINT td_index;
#endif
/* Set the state of the controller to HALTED first. */
hcd -> ux_hcd_status = UX_HCD_STATUS_HALTED;
/* Get simulated host controller. */
hcd_sim_host = (UX_HCD_SIM_HOST *)hcd -> ux_hcd_controller_hardware;
/* Delete timer. */
_ux_host_timer_delete(&hcd_sim_host -> ux_hcd_sim_host_timer);
#if defined(UX_HOST_STANDALONE)
/* Check if there is pending SETUP TD, free buffers of them. */
for (td_index = 0; td_index < _ux_system_host -> ux_system_host_max_td; td_index++)
{
td = &hcd_sim_host -> ux_hcd_sim_host_td_list[td_index];
/* Skip free TDs. */
if (td -> ux_sim_host_td_status == UX_UNUSED)
continue;
/* Skip TDs not for setup. */
if ((td -> ux_sim_host_td_status & UX_HCD_SIM_HOST_TD_SETUP_PHASE) == 0)
continue;
/* Skip TDs already freed. */
if (td -> ux_sim_host_td_buffer == UX_NULL)
continue;
/* Free the TD buffer. */
_ux_utility_memory_free(td -> ux_sim_host_td_buffer);
}
#endif
/* Free TD/ED memories. */
if (hcd_sim_host -> ux_hcd_sim_host_iso_td_list)
_ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_iso_td_list);
if (hcd_sim_host -> ux_hcd_sim_host_td_list)
_ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_td_list);
if (hcd_sim_host -> ux_hcd_sim_host_ed_list)
_ux_utility_memory_free(hcd_sim_host -> ux_hcd_sim_host_ed_list);
/* Free simulated host controller memory. */
_ux_utility_memory_free(hcd_sim_host);
hcd -> ux_hcd_controller_hardware = UX_NULL;
/* Set the state of the controller to UNUSED first. */
hcd -> ux_hcd_status = UX_UNUSED;
/* Return successful completion. */
return(UX_SUCCESS);
}
|