1 /* This tests the case where there is no interrupt endpoint in the CDC-ECM control
2    interface. Host should not report an error since this endpoint is optional. */
3 
4 #include "usbx_ux_test_cdc_ecm.h"
5 
6 static unsigned char no_interrupt_endpoint_configuration_descriptor[] = {
7 
8     /* Device Descriptor */
9     0x12, /* bLength */
10     0x01, /* bDescriptorType */
11     0x10, 0x01, /* bcdUSB */
12     0xef, /* bDeviceClass - Depends on bDeviceSubClass */
13     0x02, /* bDeviceSubClass - Depends on bDeviceProtocol */
14     0x01, /* bDeviceProtocol - There's an IAD */
15     0x40, /* bMaxPacketSize0 */
16     0x70, 0x07, /* idVendor */
17     0x42, 0x10, /* idProduct */
18     0x00, 0x01, /* bcdDevice */
19     0x01, /* iManufacturer */
20     0x02, /* iProduct */
21     0x03, /* iSerialNumber */
22     0x01, /* bNumConfigurations */
23 
24     /* Configuration Descriptor */
25     0x09, /* bLength */
26     0x02, /* bDescriptorType */
27     0x5f, 0x00, /* wTotalLength */
28     0x02, /* bNumInterfaces */
29     0x01, /* bConfigurationValue */
30     0x00, /* iConfiguration */
31     0xc0, /* bmAttributes - Self-powered */
32     0x00, /* bMaxPower */
33 
34     /* Interface Association Descriptor */
35     0x08, /* bLength */
36     0x0b, /* bDescriptorType */
37     0x00, /* bFirstInterface */
38     0x02, /* bInterfaceCount */
39     0x02, /* bFunctionClass - CDC - Communication */
40     0x06, /* bFunctionSubClass - ECM */
41     0x00, /* bFunctionProtocol - No class specific protocol required */
42     0x00, /* iFunction */
43 
44     /* Interface Descriptor */
45     0x09, /* bLength */
46     0x04, /* bDescriptorType */
47     0x00, /* bInterfaceNumber */
48     0x00, /* bAlternateSetting */
49     0x02, /* bNumEndpoints */
50     0x02, /* bInterfaceClass - CDC - Communication */
51     0x06, /* bInterfaceSubClass - ECM */
52     0x00, /* bInterfaceProtocol - No class specific protocol required */
53     0x00, /* iInterface */
54 
55     /* CDC Header Functional Descriptor */
56     0x05, /* bLength */
57     0x24, /* bDescriptorType */
58     0x00, /* bDescriptorSubType */
59     0x10, 0x01, /* bcdCDC */
60 
61     /* CDC ECM Functional Descriptor */
62     0x0d, /* bLength */
63     0x24, /* bDescriptorType */
64     0x0f, /* bDescriptorSubType */
65     0x04, /* iMACAddress */
66     0x00, 0x00, 0x00, 0x00, /* bmEthernetStatistics */
67     0xea, 0x05, /* wMaxSegmentSize */
68     0x00, 0x00, /* wNumberMCFilters */
69     0x00, /* bNumberPowerFilters */
70 
71     /* CDC Union Functional Descriptor */
72     0x05, /* bLength */
73     0x24, /* bDescriptorType */
74     0x06, /* bDescriptorSubType */
75     0x00, /* bmMasterInterface */
76     0x01, /* bmSlaveInterface0 */
77 
78     /* ??? out (to hit non-in case) */
79     /* Endpoint Descriptor */
80     0x07, /* bLength */
81     0x05, /* bDescriptorType */
82     0x01, /* bEndpointAddress */
83     0x02, /* bmAttributes - Bulk */
84     0x40, 0x00, /* wMaxPacketSize */
85     0x00, /* bInterval */
86 
87     /* ??? in (to hit non-interrupt case) */
88     /* Endpoint Descriptor */
89     0x07, /* bLength */
90     0x05, /* bDescriptorType */
91     0x82, /* bEndpointAddress */
92     0x02, /* bmAttributes - Bulk */
93     0x40, 0x00, /* wMaxPacketSize */
94     0x00, /* bInterval */
95 
96     /* Interface Descriptor */
97     0x09, /* bLength */
98     0x04, /* bDescriptorType */
99     0x01, /* bInterfaceNumber */
100     0x00, /* bAlternateSetting */
101     0x00, /* bNumEndpoints */
102     0x0a, /* bInterfaceClass - CDC - Data */
103     0x00, /* bInterfaceSubClass - Should be 0x00 */
104     0x00, /* bInterfaceProtocol - No class specific protocol required */
105     0x00, /* iInterface */
106 
107     /* Interface Descriptor */
108     0x09, /* bLength */
109     0x04, /* bDescriptorType */
110     0x01, /* bInterfaceNumber */
111     0x01, /* bAlternateSetting */
112     0x02, /* bNumEndpoints */
113     0x0a, /* bInterfaceClass - CDC - Data */
114     0x00, /* bInterfaceSubClass - Should be 0x00 */
115     0x00, /* bInterfaceProtocol - No class specific protocol required */
116     0x00, /* iInterface */
117 
118     /* Endpoint Descriptor */
119     0x07, /* bLength */
120     0x05, /* bDescriptorType */
121     0x03, /* bEndpointAddress */
122     0x02, /* bmAttributes - Bulk */
123     0x40, 0x00, /* wMaxPacketSize */
124     0x00, /* bInterval */
125 
126     /* Endpoint Descriptor */
127     0x07, /* bLength */
128     0x05, /* bDescriptorType */
129     0x84, /* bEndpointAddress */
130     0x02, /* bmAttributes - Bulk */
131     0x40, 0x00, /* wMaxPacketSize */
132     0x00, /* bInterval */
133 
134 };
135 
136 static DEVICE_INIT_DATA device_init_data = {
137     .framework = no_interrupt_endpoint_configuration_descriptor,
138     .framework_length = sizeof(no_interrupt_endpoint_configuration_descriptor),
139     .dont_register_hcd = 1,
140 };
141 
142 /* Define what the initial system looks like.  */
143 #ifdef CTEST
test_application_define(void * first_unused_memory)144 void test_application_define(void *first_unused_memory)
145 #else
146 void usbx_cdc_ecm_control_interface_no_interrupt_endpoint_test_application_define(void *first_unused_memory)
147 #endif
148 {
149 
150     /* Inform user.  */
151     printf("Running CDC-ECM No Interrupt Endpoint Test.......................... ");
152 
153     stepinfo("\n");
154 
155     ux_test_cdc_ecm_initialize_use_framework(first_unused_memory, &device_init_data);
156 }
157 
post_init_host()158 static void post_init_host()
159 {
160 
161     /* Enumerate. */
162     UX_TEST_CHECK_SUCCESS(ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, _ux_test_hcd_sim_host_initialize, 0, 0));
163 
164     /* The HCD init function put()s the HCD semaphore, so we can do this here. */
165     ux_test_wait_for_enum_thread_completion();
166 }
167 
post_init_device()168 static void post_init_device()
169 {
170 }