blob: 1dbe44e81f8bebdcf550039e56b5837e45d710b6 (
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/***************************************************************************
* 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 */
/** */
/** EHCI Controller Driver */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_hcd_ehci.h"
#include "ux_host_stack.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_ehci_interrupt_endpoint_destroy PORTABLE C */
/* 6.1.11 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function will destroy an interrupt endpoint. */
/* */
/* INPUT */
/* */
/* hcd_ehci Pointer to EHCI controller */
/* endpoint Pointer to endpoint */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_hcd_ehci_door_bell_wait Setup doorbell wait */
/* _ux_utility_physical_address Get physical address */
/* _ux_host_mutex_on Get mutex */
/* _ux_host_mutex_off Put mutex */
/* _ux_hcd_ehci_periodic_descriptor_link Link/unlink descriptor */
/* */
/* CALLED BY */
/* */
/* EHCI Controller Driver */
/* */
/**************************************************************************/
UINT _ux_hcd_ehci_interrupt_endpoint_destroy(UX_HCD_EHCI *hcd_ehci, UX_ENDPOINT *endpoint)
{
UX_EHCI_ED *ed;
UX_EHCI_ED *prev_ed;
ULONG frindex;
ULONG max_packet_size;
/* From the endpoint container fetch the EHCI ED descriptor. */
ed = (UX_EHCI_ED *) endpoint -> ux_endpoint_ed;
/* Access to periodic list. */
_ux_host_mutex_on(&hcd_ehci -> ux_hcd_ehci_periodic_mutex);
/* Unlink the periodic item. */
_ux_hcd_ehci_periodic_descriptor_link(ed -> ux_ehci_ed_previous_ed,
UX_NULL, UX_NULL, ed -> ux_ehci_ed_queue_head);
/* Update the interrupt ED scan list. */
prev_ed = hcd_ehci -> ux_hcd_ehci_interrupt_ed_list;
/* Check if ED in head of scan list. */
if (prev_ed == ed)
/* Point head to the next ED. */
hcd_ehci -> ux_hcd_ehci_interrupt_ed_list = ed -> ux_ehci_ed_next_ed;
else
{
/* Try to find previous ED in scan list. */
/* It's at head now. */
while(prev_ed -> ux_ehci_ed_next_ed)
{
/* The expected ED is found. */
if (prev_ed -> ux_ehci_ed_next_ed == ed)
{
/* Point next to next of the ED. */
prev_ed -> ux_ehci_ed_next_ed = ed -> ux_ehci_ed_next_ed;
break;
}
/* Try next ED. */
prev_ed = prev_ed -> ux_ehci_ed_next_ed;
}
}
/* Update micro-frame loads of anchor. */
/* Calculate max packet size. */
#if defined(UX_HCD_EHCI_SPLIT_TRANSFER_ENABLE)
if (endpoint -> ux_endpoint_device -> ux_device_speed != UX_HIGH_SPEED_DEVICE)
max_packet_size = endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_PACKET_SIZE_MASK;
else
#endif
{
max_packet_size = endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_NUMBER_OF_TRANSACTIONS_MASK;
max_packet_size >>= UX_MAX_NUMBER_OF_TRANSACTIONS_SHIFT;
if (max_packet_size < 3)
max_packet_size ++;
max_packet_size *= endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_PACKET_SIZE_MASK;
}
/* Update according to ED S-Mask. */
for(frindex = 0; frindex < 8; frindex ++)
{
/* Check schedule mask. */
if ((ed -> ux_ehci_ed_cap1 & (UX_EHCI_SMASK_0 << frindex)))
{
#if defined(UX_HCD_EHCI_SPLIT_TRANSFER_ENABLE)
/* Start split check. */
if (endpoint -> ux_endpoint_device -> ux_device_speed != UX_HIGH_SPEED_DEVICE)
{
/* Decrement the start split count. */
ed -> REF_AS.INTR.ux_ehci_ed_anchor -> REF_AS.ANCHOR.ux_ehci_ed_microframe_ssplit_count[frindex] --;
/* Check next endpoint if it's IN (load in C-Mask). */
if (endpoint -> ux_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION)
continue;
}
#endif
/* Decrement the microframe load. */
ed -> REF_AS.INTR.ux_ehci_ed_anchor -> REF_AS.ANCHOR.ux_ehci_ed_microframe_load[frindex] = (USHORT)(ed -> REF_AS.INTR.ux_ehci_ed_anchor -> REF_AS.ANCHOR.ux_ehci_ed_microframe_load[frindex] - max_packet_size);
/* S-Mask found, no C-Mask at the same time, skip C-Mask check. */
continue;
}
#if defined(UX_HCD_EHCI_SPLIT_TRANSFER_ENABLE)
/* Complete split interrupt IN check in C-Mask. */
if ((endpoint -> ux_endpoint_device -> ux_device_speed != UX_HIGH_SPEED_DEVICE) &&
(endpoint -> ux_endpoint_descriptor.bEndpointAddress & UX_ENDPOINT_DIRECTION) &&
(ed -> ux_ehci_ed_cap1 & (UX_EHCI_CMASK_0 << frindex)))
{
/* Decrement the microframe load. */
ed -> REF_AS.INTR.ux_ehci_ed_anchor -> REF_AS.ANCHOR.ux_ehci_ed_microframe_load[frindex] = (USHORT)(ed -> REF_AS.INTR.ux_ehci_ed_anchor -> REF_AS.ANCHOR.ux_ehci_ed_microframe_load[frindex] - max_packet_size);
}
#endif
}
/* Release periodic list. */
_ux_host_mutex_off(&hcd_ehci -> ux_hcd_ehci_periodic_mutex);
/* Arm the doorbell and wait for its completion. */
_ux_hcd_ehci_door_bell_wait(hcd_ehci);
/* Now we can safely make the ED free. */
ed -> ux_ehci_ed_status = UX_UNUSED;
/* Return successful completion. */
return(UX_SUCCESS);
}
|