Subversion Repositories freemyipod

Rev

Rev 892 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 892 Rev 949
Line 23... Line 23...
23
    .iProduct = 2,
23
    .iProduct = 2,
24
    .iSerialNumber = 0,
24
    .iSerialNumber = 0,
25
    .bNumConfigurations = 1,
25
    .bNumConfigurations = 1,
26
};
26
};
27
 
27
 
28
static const struct __attribute__((packed)) _usb_config1_descriptors
28
static struct __attribute__((packed)) _usb_config1_descriptors
29
{
29
{
30
    struct usb_configurationdescriptor c1;
30
    struct usb_configurationdescriptor c1;
31
    struct usb_interfacedescriptor c1_i0_a0;
31
    struct usb_interfacedescriptor c1_i0_a0;
-
 
32
    struct usb_endpointdescriptor c1_i0_a0_e1out;
-
 
33
    struct usb_endpointdescriptor c1_i0_a0_e1in;
32
} usb_config1_descriptors =
34
} usb_config1_descriptors =
33
{
35
{
34
    .c1 =
36
    .c1 =
35
    {
37
    {
36
        .bLength = sizeof(struct usb_configurationdescriptor),
38
        .bLength = sizeof(struct usb_configurationdescriptor),
Line 46... Line 48...
46
    {
48
    {
47
        .bLength = sizeof(struct usb_interfacedescriptor),
49
        .bLength = sizeof(struct usb_interfacedescriptor),
48
        .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE,
50
        .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE,
49
        .bInterfaceNumber = 0,
51
        .bInterfaceNumber = 0,
50
        .bAlternateSetting = 0,
52
        .bAlternateSetting = 0,
51
        .bNumEndpoints = 0,
53
        .bNumEndpoints = 2,
52
        .bInterfaceClass = 0xff,
54
        .bInterfaceClass = 0xff,
53
        .bInterfaceSubClass = 0x00,
55
        .bInterfaceSubClass = 0x00,
54
        .bInterfaceProtocol = 0x00,
56
        .bInterfaceProtocol = 0x00,
55
        .iInterface = 0,
57
        .iInterface = 0,
56
    },
58
    },
-
 
59
    .c1_i0_a0_e1out =
-
 
60
    {
-
 
61
        .bLength = sizeof(struct usb_endpointdescriptor),
-
 
62
        .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT,
-
 
63
        .bEndpointAddress = { .number = USBDEBUG_ENDPOINT_OUT, .direction = USB_ENDPOINT_DIRECTION_OUT },
-
 
64
        .bmAttributes = { .type = USB_ENDPOINT_ATTRIBUTE_TYPE_BULK },
-
 
65
        .wMaxPacketSize = 512,
-
 
66
        .bInterval = 1,
-
 
67
    },
-
 
68
    .c1_i0_a0_e1in =
-
 
69
    {
-
 
70
        .bLength = sizeof(struct usb_endpointdescriptor),
-
 
71
        .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT,
-
 
72
        .bEndpointAddress = { .number = USBDEBUG_ENDPOINT_IN, .direction = USB_ENDPOINT_DIRECTION_IN },
-
 
73
        .bmAttributes = { .type = USB_ENDPOINT_ATTRIBUTE_TYPE_BULK },
-
 
74
        .wMaxPacketSize = 512,
-
 
75
        .bInterval = 1,
-
 
76
    },
-
 
77
};
-
 
78
 
-
 
79
static const struct usb_interfacedescriptor usb_simpledebug_intf_desc =
-
 
80
{
-
 
81
    .bLength = sizeof(struct usb_interfacedescriptor),
-
 
82
    .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE,
-
 
83
    .bInterfaceNumber = 0,
-
 
84
    .bAlternateSetting = 0,
-
 
85
    .bNumEndpoints = 0,
-
 
86
    .bInterfaceClass = 0xff,
-
 
87
    .bInterfaceSubClass = 0x00,
-
 
88
    .bInterfaceProtocol = 0x00,
-
 
89
    .iInterface = 0,
57
};
90
};
58
 
91
 
59
static const struct usb_stringdescriptor usb_string_language =
92
static const struct usb_stringdescriptor usb_string_language =
60
{
93
{
61
    .bLength = sizeof(usb_string_language) + sizeof(*usb_string_language.wString),
94
    .bLength = sizeof(usb_string_language) + sizeof(*usb_string_language.wString),
Line 82... Line 115...
82
    &usb_string_language,
115
    &usb_string_language,
83
    &usb_string_vendor,
116
    &usb_string_vendor,
84
    &usb_string_product,
117
    &usb_string_product,
85
};
118
};
86
 
119
 
-
 
120
static const struct usb_endpoint usb_c1_i0_a0_ep1out =
-
 
121
{
-
 
122
    .number = { .number = USBDEBUG_ENDPOINT_OUT, .direction = USB_ENDPOINT_DIRECTION_OUT },
-
 
123
    .ctrl_request = usbdebug_bulk_ctrl_request,
-
 
124
    .xfer_complete = usbdebug_bulk_xfer_complete,
-
 
125
    .setup_received = NULL,
-
 
126
};
-
 
127
 
-
 
128
static const struct usb_endpoint usb_c1_i0_a0_ep1in =
-
 
129
{
-
 
130
    .number = { .number = USBDEBUG_ENDPOINT_IN, .direction = USB_ENDPOINT_DIRECTION_IN },
-
 
131
    .ctrl_request = usbdebug_bulk_ctrl_request,
-
 
132
    .xfer_complete = usbdebug_bulk_xfer_complete,
-
 
133
    .timeout = NULL,
-
 
134
};
-
 
135
 
87
static const struct usb_altsetting usb_c1_i0_a0 =
136
static const struct usb_altsetting usb_c1_i0_a0 =
88
{
137
{
-
 
138
    .set_altsetting = usbdebug_bulk_enable,
-
 
139
    .unset_altsetting = usbdebug_bulk_disable,
-
 
140
    .endpoint_count = 2,
-
 
141
    .endpoints =
-
 
142
    {
-
 
143
        &usb_c1_i0_a0_ep1out,
-
 
144
        &usb_c1_i0_a0_ep1in,
-
 
145
    },
-
 
146
};
-
 
147
 
-
 
148
static void usbglue_bus_reset(const struct usb_instance* data, int highspeed)
-
 
149
{
-
 
150
    usb_config1_descriptors.c1_i0_a0_e1out.wMaxPacketSize = highspeed ? 512 : 64;
-
 
151
    usb_config1_descriptors.c1_i0_a0_e1in.wMaxPacketSize = highspeed ? 512 : 64;
-
 
152
}
-
 
153
 
-
 
154
static struct usb_interface usb_c1_i0 =
-
 
155
{
-
 
156
    .bus_reset = usbdebug_bus_reset,
-
 
157
    .ctrl_request = usbdebug_handle_setup,
-
 
158
    .altsetting_count = 1,
-
 
159
    .altsettings =
-
 
160
    {
-
 
161
        &usb_c1_i0_a0,
-
 
162
    },
-
 
163
};
-
 
164
 
-
 
165
static const struct usb_altsetting usb_simpledebug_intf_a0 =
-
 
166
{
89
    .set_altsetting = usbdebug_enable,
167
    .set_altsetting = usbdebug_enable,
90
    .unset_altsetting = usbdebug_disable,
168
    .unset_altsetting = usbdebug_disable,
91
    .endpoint_count = 0,
169
    .endpoint_count = 0,
92
    .endpoints =
170
    .endpoints =
93
    {
171
    {
94
    },
172
    },
95
};
173
};
96
 
174
 
97
static struct usb_interface usb_c1_i0 =
175
static struct usb_interface usb_simpledebug_intf =
98
{
176
{
99
    .bus_reset = NULL,
177
    .bus_reset = NULL,
100
    .ctrl_request = usbdebug_handle_setup,
178
    .ctrl_request = usbdebug_handle_setup,
101
    .altsetting_count = 1,
179
    .altsetting_count = 1,
102
    .altsettings =
180
    .altsettings =
103
    {
181
    {
104
        &usb_c1_i0_a0,
182
        &usb_simpledebug_intf_a0,
105
    },
183
    },
106
};
184
};
107
 
185
 
108
static const struct usb_configuration usb_c1 =
186
static const struct usb_configuration usb_c1 =
109
{
187
{
Line 134... Line 212...
134
    .driver = &USB_DRIVER,
212
    .driver = &USB_DRIVER,
135
    .driver_config = &usb_driver_config,
213
    .driver_config = &usb_driver_config,
136
    .driver_state = &usb_driver_state,
214
    .driver_state = &usb_driver_state,
137
    .state = &usb_state,
215
    .state = &usb_state,
138
    .buffer = &usb_buffer,
216
    .buffer = &usb_buffer,
139
    .bus_reset = NULL,
217
    .bus_reset = usbglue_bus_reset,
140
    .ep0_setup_hook = NULL,
218
    .ep0_setup_hook = NULL,
141
    .configuration_count = 1,
219
    .configuration_count = 1,
142
    .stringdescriptor_count = 3,
220
    .stringdescriptor_count = 3,
143
    .devicedescriptor = &usb_devicedescriptor,
221
    .devicedescriptor = &usb_devicedescriptor,
144
    .stringdescriptors = usb_stringdescriptors,
222
    .stringdescriptors = usb_stringdescriptors,
Line 273... Line 351...
273
        }
351
        }
274
        if (!i && enable_debug)
352
        if (!i && enable_debug)
275
        {
353
        {
276
            struct usb_interfacedescriptor* intfdescriptor = (struct usb_interfacedescriptor*)descbuf;
354
            struct usb_interfacedescriptor* intfdescriptor = (struct usb_interfacedescriptor*)descbuf;
277
            descbuf += sizeof(struct usb_interfacedescriptor);
355
            descbuf += sizeof(struct usb_interfacedescriptor);
278
            memcpy(intfdescriptor, &usb_config1_descriptors.c1_i0_a0, sizeof(struct usb_interfacedescriptor));
356
            memcpy(intfdescriptor, &usb_simpledebug_intf_desc, sizeof(struct usb_interfacedescriptor));
279
            intfdescriptor->bInterfaceNumber = j;
357
            intfdescriptor->bInterfaceNumber = j;
280
            config->interfaces[j] = &usb_c1_i0;
358
            config->interfaces[j] = &usb_simpledebug_intf;
281
            config->interface_count++;
359
            config->interface_count++;
282
            cfgdescriptor->wTotalLength += sizeof(struct usb_interfacedescriptor);
360
            cfgdescriptor->wTotalLength += sizeof(struct usb_interfacedescriptor);
283
            cfgdescriptor->bNumInterfaces++;
361
            cfgdescriptor->bNumInterfaces++;
284
        }
362
        }
285
    }
363
    }