1
10
13
14
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
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
181
187
188
189
190
196
197
201
202
203
204
205
206
207
208
209
210
211
213
214
215
216
229
230
231
232
233
234
235
236
237
238
239
240
241
243
244
245
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_stack.h"
#if UX_MAX_DEVICES > 1...
...
VOID _ux_host_stack_bandwidth_release(UX_HCD *hcd, UX_ENDPOINT *endpoint)
{
UX_DEVICE *device;
UX_DEVICE *parent_device;
USHORT hcd_bandwidth_claimed;
USHORT max_packet_size;
LONG packet_size;
USHORT tt_bandwidth_claimed = 0;
ULONG port_index;
ULONG port_map;
ULONG tt_index;
const UCHAR overheads[4][3] = {
{63, 45, 173},
{ 0, 9, 38},
{ 0, 13, 55},
{19, 13, 55}
...};
device = endpoint -> ux_endpoint_device;
/* ... */
max_packet_size = endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_PACKET_SIZE_MASK;
packet_size = (max_packet_size * 7 + 5) / 6;
packet_size += overheads[endpoint -> ux_endpoint_descriptor.bmAttributes & UX_MASK_ENDPOINT_TYPE][device -> ux_device_speed];
max_packet_size = (USHORT)packet_size;
if (device -> ux_device_speed == UX_HIGH_SPEED_DEVICE)
{
max_packet_size = (USHORT)(max_packet_size *
(((endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_NUMBER_OF_TRANSACTIONS_MASK) >>
UX_MAX_NUMBER_OF_TRANSACTIONS_SHIFT) + 1));
}if (device -> ux_device_speed == UX_HIGH_SPEED_DEVICE) { ... }
if (hcd -> ux_hcd_version != 0x200)
{
if (device -> ux_device_speed == UX_LOW_SPEED_DEVICE)
hcd_bandwidth_claimed = (USHORT)(max_packet_size * 8 * 5);
else
{
if (device -> ux_device_speed == UX_FULL_SPEED_DEVICE)
hcd_bandwidth_claimed = (USHORT)(max_packet_size * 5);
else
hcd_bandwidth_claimed = (USHORT)max_packet_size;
}else { ... }
}if (hcd -> ux_hcd_version != 0x200) { ... }
else
{
hcd_bandwidth_claimed = (USHORT)max_packet_size;
if (device -> ux_device_speed == UX_LOW_SPEED_DEVICE)
tt_bandwidth_claimed = (USHORT)(max_packet_size * 8);
else
tt_bandwidth_claimed = (USHORT)max_packet_size;
}else { ... }
hcd -> ux_hcd_available_bandwidth += hcd_bandwidth_claimed;
/* ... */
if ((device -> ux_device_speed == UX_HIGH_SPEED_DEVICE) || (hcd -> ux_hcd_version != 0x200))
{
return;
}if ((device -> ux_device_speed == UX_HIGH_SPEED_DEVICE) || (hcd -> ux_hcd_version != 0x200)) { ... }
parent_device = device -> ux_device_parent;
if (parent_device == UX_NULL)
{
return;
}if (parent_device == UX_NULL) { ... }
/* ... */
port_index = device -> ux_device_port_location - 1;
while (parent_device != UX_NULL)
{
if (parent_device -> ux_device_speed == UX_HIGH_SPEED_DEVICE)
{
/* ... */
port_map = (ULONG)(1 << port_index);
for (tt_index = 0; tt_index < UX_MAX_TT; tt_index++)
{
if ((parent_device -> ux_device_hub_tt[tt_index].ux_hub_tt_port_mapping & port_map) != 0)
{
/* ... */
parent_device -> ux_device_hub_tt[tt_index].ux_hub_tt_max_bandwidth += tt_bandwidth_claimed;
return;
}if ((parent_device -> ux_device_hub_tt[tt_index].ux_hub_tt_port_mapping & port_map) != 0) { ... }
}for (tt_index = 0; tt_index < UX_MAX_TT; tt_index++) { ... }
return;
}if (parent_device -> ux_device_speed == UX_HIGH_SPEED_DEVICE) { ... }
port_index = parent_device -> ux_device_port_location - 1;
parent_device = parent_device -> ux_device_parent;
}while (parent_device != UX_NULL) { ... }
/* ... */
return;
}{ ... }
#endif... /* ... */