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
96
97
98
99
100
102
103
104
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
126
127
129
144
145
146
147
148
149
150
151
156
157
158
159
164
165
166
171
182
183
184
185
186
187
188
189
190
192
193
194
199
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_stack.h"
...
...
UINT _ux_host_stack_new_endpoint_create(UX_INTERFACE *interface,
UCHAR * interface_endpoint)
{
UX_ENDPOINT *endpoint;
UX_ENDPOINT *list_endpoint;
ULONG endpoint_type;
ULONG packet_size;
ULONG n_tran;
endpoint = (UX_ENDPOINT *) _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, sizeof(UX_ENDPOINT));
if (endpoint == UX_NULL)
return(UX_MEMORY_INSUFFICIENT);
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_NEW_ENDPOINT_CREATE, interface, endpoint, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
/* ... */
endpoint -> ux_endpoint = (ULONG) (ALIGN_TYPE) endpoint;
/* ... */
endpoint -> ux_endpoint_transfer_request.ux_transfer_request_endpoint = endpoint;
endpoint -> ux_endpoint_device = interface -> ux_interface_configuration -> ux_configuration_device;
_ux_utility_descriptor_parse(interface_endpoint,
_ux_system_endpoint_descriptor_structure,
UX_ENDPOINT_DESCRIPTOR_ENTRIES,
(UCHAR *) &endpoint -> ux_endpoint_descriptor);
endpoint_type = endpoint -> ux_endpoint_descriptor.bmAttributes & UX_MASK_ENDPOINT_TYPE;
if (endpoint -> ux_endpoint_descriptor.wMaxPacketSize == 0)
{
_ux_utility_memory_free(endpoint);
return(UX_DESCRIPTOR_CORRUPTED);
}if (endpoint -> ux_endpoint_descriptor.wMaxPacketSize == 0) { ... }
/* ... */
if (endpoint_type == UX_CONTROL_ENDPOINT || endpoint_type == UX_BULK_ENDPOINT)
{
for (packet_size = 8; packet_size <= 512; packet_size <<= 1)
{
if (packet_size == endpoint -> ux_endpoint_descriptor.wMaxPacketSize)
break;
}for (packet_size = 8; packet_size <= 512; packet_size <<= 1) { ... }
if (packet_size > 512)
{
_ux_utility_memory_free(endpoint);
return(UX_DESCRIPTOR_CORRUPTED);
}if (packet_size > 512) { ... }
}if (endpoint_type == UX_CONTROL_ENDPOINT || endpoint_type == UX_BULK_ENDPOINT) { ... }
if (endpoint_type == UX_INTERRUPT_ENDPOINT || endpoint_type == UX_ISOCHRONOUS_ENDPOINT)
{
packet_size = endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_PACKET_SIZE_MASK;
if (packet_size > 1024)
{
_ux_utility_memory_free(endpoint);
return(UX_DESCRIPTOR_CORRUPTED);
}if (packet_size > 1024) { ... }
n_tran = endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_NUMBER_OF_TRANSACTIONS_MASK;
if (n_tran >= UX_MAX_NUMBER_OF_TRANSACTIONS_MASK)
{
_ux_utility_memory_free(endpoint);
return(UX_DESCRIPTOR_CORRUPTED);
}if (n_tran >= UX_MAX_NUMBER_OF_TRANSACTIONS_MASK) { ... }
if (endpoint -> ux_endpoint_descriptor.bInterval < 1)
{
_ux_utility_memory_free(endpoint);
return(UX_DESCRIPTOR_CORRUPTED);
}if (endpoint -> ux_endpoint_descriptor.bInterval < 1) { ... }
if ((endpoint_type == UX_ISOCHRONOUS_ENDPOINT) ||
(interface -> ux_interface_configuration -> ux_configuration_device
-> ux_device_speed == UX_HIGH_SPEED_DEVICE)
)
{
if (endpoint -> ux_endpoint_descriptor.bInterval > 16)
{
_ux_utility_memory_free(endpoint);
return(UX_DESCRIPTOR_CORRUPTED);
}if (endpoint -> ux_endpoint_descriptor.bInterval > 16) { ... }
}if ((endpoint_type == UX_ISOCHRONOUS_ENDPOINT) || (interface -> ux_interface_configuration -> ux_configuration_device -> ux_device_speed == UX_HIGH_SPEED_DEVICE)) { ... }
packet_size *= (n_tran + 1);
}if (endpoint_type == UX_INTERRUPT_ENDPOINT || endpoint_type == UX_ISOCHRONOUS_ENDPOINT) { ... }
endpoint -> ux_endpoint_transfer_request.ux_transfer_request_packet_length = packet_size;
/* ... */
endpoint -> ux_endpoint_interface = interface;
/* ... */
if (interface -> ux_interface_first_endpoint == UX_NULL)
{
interface -> ux_interface_first_endpoint = endpoint;
}if (interface -> ux_interface_first_endpoint == UX_NULL) { ... }
else
{
list_endpoint = interface -> ux_interface_first_endpoint;
while (list_endpoint -> ux_endpoint_next_endpoint != UX_NULL)
list_endpoint = list_endpoint -> ux_endpoint_next_endpoint;
list_endpoint -> ux_endpoint_next_endpoint = endpoint;
}else { ... }
return(UX_SUCCESS);
}{ ... }
...