diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2008-02-29 18:33:54 +0000 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2008-02-29 18:33:54 +0000 |
commit | f712c7ff361c327376f9773d34be02428e01e080 (patch) | |
tree | e54f3fb8d002395c1175bf5d54535dfbafafb8e7 | |
parent | d6adda13566cc71d1ca931eb95b117dcbcd54998 (diff) | |
download | rockbox-f712c7ff361c327376f9773d34be02428e01e080.tar.gz rockbox-f712c7ff361c327376f9773d34be02428e01e080.zip |
fix alignment and packed-ness of USB structs
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16455 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/usb_ch9.h | 8 | ||||
-rw-r--r-- | firmware/usbstack/usb_core.c | 44 |
2 files changed, 26 insertions, 26 deletions
diff --git a/firmware/export/usb_ch9.h b/firmware/export/usb_ch9.h index 4c272c338a..1bfc152a8a 100644 --- a/firmware/export/usb_ch9.h +++ b/firmware/export/usb_ch9.h | |||
@@ -227,7 +227,7 @@ struct usb_config_descriptor { | |||
227 | uint8_t iConfiguration; | 227 | uint8_t iConfiguration; |
228 | uint8_t bmAttributes; | 228 | uint8_t bmAttributes; |
229 | uint8_t bMaxPower; | 229 | uint8_t bMaxPower; |
230 | } __attribute__ ((packed,aligned(2))); | 230 | } __attribute__ ((packed)); |
231 | 231 | ||
232 | #define USB_DT_CONFIG_SIZE 9 | 232 | #define USB_DT_CONFIG_SIZE 9 |
233 | 233 | ||
@@ -245,7 +245,7 @@ struct usb_string_descriptor { | |||
245 | uint8_t bDescriptorType; | 245 | uint8_t bDescriptorType; |
246 | 246 | ||
247 | uint16_t wString[]; /* UTF-16LE encoded */ | 247 | uint16_t wString[]; /* UTF-16LE encoded */ |
248 | } __attribute__ ((packed,aligned(2))); | 248 | } __attribute__ ((packed)); |
249 | 249 | ||
250 | /* note that "string" zero is special, it holds language codes that | 250 | /* note that "string" zero is special, it holds language codes that |
251 | * the device supports, not Unicode characters. | 251 | * the device supports, not Unicode characters. |
@@ -285,7 +285,7 @@ struct usb_endpoint_descriptor { | |||
285 | /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ | 285 | /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ |
286 | //uint8_t bRefresh; | 286 | //uint8_t bRefresh; |
287 | //uint8_t bSynchAddress; | 287 | //uint8_t bSynchAddress; |
288 | } __attribute__ ((packed,aligned(2))); | 288 | } __attribute__ ((packed)); |
289 | 289 | ||
290 | #define USB_DT_ENDPOINT_SIZE 7 | 290 | #define USB_DT_ENDPOINT_SIZE 7 |
291 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ | 291 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ |
@@ -304,7 +304,7 @@ struct usb_qualifier_descriptor { | |||
304 | uint8_t bMaxPacketSize0; | 304 | uint8_t bMaxPacketSize0; |
305 | uint8_t bNumConfigurations; | 305 | uint8_t bNumConfigurations; |
306 | uint8_t bRESERVED; | 306 | uint8_t bRESERVED; |
307 | } __attribute__ ((packed,aligned(2))); | 307 | } __attribute__ ((packed)); |
308 | 308 | ||
309 | /*-------------------------------------------------------------------------*/ | 309 | /*-------------------------------------------------------------------------*/ |
310 | 310 | ||
diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c index fdfd049002..a864ac8b3a 100644 --- a/firmware/usbstack/usb_core.c +++ b/firmware/usbstack/usb_core.c | |||
@@ -58,7 +58,7 @@ | |||
58 | #define USB_SC_SCSI 0x06 /* Transparent */ | 58 | #define USB_SC_SCSI 0x06 /* Transparent */ |
59 | #define USB_PROT_BULK 0x50 /* bulk only */ | 59 | #define USB_PROT_BULK 0x50 /* bulk only */ |
60 | 60 | ||
61 | static const struct usb_device_descriptor device_descriptor= { | 61 | static const struct usb_device_descriptor __attribute__((aligned(2))) device_descriptor= { |
62 | .bLength = sizeof(struct usb_device_descriptor), | 62 | .bLength = sizeof(struct usb_device_descriptor), |
63 | .bDescriptorType = USB_DT_DEVICE, | 63 | .bDescriptorType = USB_DT_DEVICE, |
64 | #ifdef USE_HIGH_SPEED | 64 | #ifdef USE_HIGH_SPEED |
@@ -77,9 +77,9 @@ static const struct usb_device_descriptor device_descriptor= { | |||
77 | .iProduct = 2, | 77 | .iProduct = 2, |
78 | .iSerialNumber = 3, | 78 | .iSerialNumber = 3, |
79 | .bNumConfigurations = 1 | 79 | .bNumConfigurations = 1 |
80 | }; | 80 | } ; |
81 | 81 | ||
82 | struct usb_config_descriptor config_descriptor = | 82 | struct usb_config_descriptor __attribute__((aligned(2))) config_descriptor = |
83 | { | 83 | { |
84 | .bLength = sizeof(struct usb_config_descriptor), | 84 | .bLength = sizeof(struct usb_config_descriptor), |
85 | .bDescriptorType = USB_DT_CONFIG, | 85 | .bDescriptorType = USB_DT_CONFIG, |
@@ -93,7 +93,7 @@ struct usb_config_descriptor config_descriptor = | |||
93 | 93 | ||
94 | #ifdef USB_CHARGING_ONLY | 94 | #ifdef USB_CHARGING_ONLY |
95 | /* dummy interface for charging-only */ | 95 | /* dummy interface for charging-only */ |
96 | struct usb_interface_descriptor charging_interface_descriptor = | 96 | struct usb_interface_descriptor __attribute__((aligned(2))) charging_interface_descriptor = |
97 | { | 97 | { |
98 | .bLength = sizeof(struct usb_interface_descriptor), | 98 | .bLength = sizeof(struct usb_interface_descriptor), |
99 | .bDescriptorType = USB_DT_INTERFACE, | 99 | .bDescriptorType = USB_DT_INTERFACE, |
@@ -109,7 +109,7 @@ struct usb_interface_descriptor charging_interface_descriptor = | |||
109 | 109 | ||
110 | #ifdef USB_STORAGE | 110 | #ifdef USB_STORAGE |
111 | /* storage interface */ | 111 | /* storage interface */ |
112 | struct usb_interface_descriptor mass_storage_interface_descriptor = | 112 | struct usb_interface_descriptor __attribute__((aligned(2))) mass_storage_interface_descriptor = |
113 | { | 113 | { |
114 | .bLength = sizeof(struct usb_interface_descriptor), | 114 | .bLength = sizeof(struct usb_interface_descriptor), |
115 | .bDescriptorType = USB_DT_INTERFACE, | 115 | .bDescriptorType = USB_DT_INTERFACE, |
@@ -122,7 +122,7 @@ struct usb_interface_descriptor mass_storage_interface_descriptor = | |||
122 | .iInterface = 0 | 122 | .iInterface = 0 |
123 | }; | 123 | }; |
124 | 124 | ||
125 | struct usb_endpoint_descriptor mass_storage_ep_in_descriptor = | 125 | struct usb_endpoint_descriptor __attribute__((aligned(2))) mass_storage_ep_in_descriptor = |
126 | { | 126 | { |
127 | .bLength = sizeof(struct usb_endpoint_descriptor), | 127 | .bLength = sizeof(struct usb_endpoint_descriptor), |
128 | .bDescriptorType = USB_DT_ENDPOINT, | 128 | .bDescriptorType = USB_DT_ENDPOINT, |
@@ -131,7 +131,7 @@ struct usb_endpoint_descriptor mass_storage_ep_in_descriptor = | |||
131 | .wMaxPacketSize = 16, | 131 | .wMaxPacketSize = 16, |
132 | .bInterval = 0 | 132 | .bInterval = 0 |
133 | }; | 133 | }; |
134 | struct usb_endpoint_descriptor mass_storage_ep_out_descriptor = | 134 | struct usb_endpoint_descriptor __attribute__((aligned(2))) mass_storage_ep_out_descriptor = |
135 | { | 135 | { |
136 | .bLength = sizeof(struct usb_endpoint_descriptor), | 136 | .bLength = sizeof(struct usb_endpoint_descriptor), |
137 | .bDescriptorType = USB_DT_ENDPOINT, | 137 | .bDescriptorType = USB_DT_ENDPOINT, |
@@ -144,7 +144,7 @@ struct usb_endpoint_descriptor mass_storage_ep_out_descriptor = | |||
144 | 144 | ||
145 | #ifdef USB_SERIAL | 145 | #ifdef USB_SERIAL |
146 | /* serial interface */ | 146 | /* serial interface */ |
147 | struct usb_interface_descriptor serial_interface_descriptor = | 147 | struct usb_interface_descriptor __attribute__((aligned(2))) serial_interface_descriptor = |
148 | { | 148 | { |
149 | .bLength = sizeof(struct usb_interface_descriptor), | 149 | .bLength = sizeof(struct usb_interface_descriptor), |
150 | .bDescriptorType = USB_DT_INTERFACE, | 150 | .bDescriptorType = USB_DT_INTERFACE, |
@@ -157,7 +157,7 @@ struct usb_interface_descriptor serial_interface_descriptor = | |||
157 | .iInterface = 0 | 157 | .iInterface = 0 |
158 | }; | 158 | }; |
159 | 159 | ||
160 | struct usb_endpoint_descriptor serial_ep_in_descriptor = | 160 | struct usb_endpoint_descriptor __attribute__((aligned(2))) serial_ep_in_descriptor = |
161 | { | 161 | { |
162 | .bLength = sizeof(struct usb_endpoint_descriptor), | 162 | .bLength = sizeof(struct usb_endpoint_descriptor), |
163 | .bDescriptorType = USB_DT_ENDPOINT, | 163 | .bDescriptorType = USB_DT_ENDPOINT, |
@@ -166,7 +166,7 @@ struct usb_endpoint_descriptor serial_ep_in_descriptor = | |||
166 | .wMaxPacketSize = 16, | 166 | .wMaxPacketSize = 16, |
167 | .bInterval = 0 | 167 | .bInterval = 0 |
168 | }; | 168 | }; |
169 | struct usb_endpoint_descriptor serial_ep_out_descriptor = | 169 | struct usb_endpoint_descriptor __attribute__((aligned(2))) serial_ep_out_descriptor = |
170 | { | 170 | { |
171 | .bLength = sizeof(struct usb_endpoint_descriptor), | 171 | .bLength = sizeof(struct usb_endpoint_descriptor), |
172 | .bDescriptorType = USB_DT_ENDPOINT, | 172 | .bDescriptorType = USB_DT_ENDPOINT, |
@@ -179,7 +179,7 @@ struct usb_endpoint_descriptor serial_ep_out_descriptor = | |||
179 | 179 | ||
180 | #ifdef USB_BENCHMARK | 180 | #ifdef USB_BENCHMARK |
181 | /* bulk test interface */ | 181 | /* bulk test interface */ |
182 | struct usb_interface_descriptor benchmark_interface_descriptor = | 182 | struct usb_interface_descriptor __attribute__((aligned(2))) benchmark_interface_descriptor = |
183 | { | 183 | { |
184 | .bLength = sizeof(struct usb_interface_descriptor), | 184 | .bLength = sizeof(struct usb_interface_descriptor), |
185 | .bDescriptorType = USB_DT_INTERFACE, | 185 | .bDescriptorType = USB_DT_INTERFACE, |
@@ -192,7 +192,7 @@ struct usb_interface_descriptor benchmark_interface_descriptor = | |||
192 | .iInterface = 4 | 192 | .iInterface = 4 |
193 | }; | 193 | }; |
194 | 194 | ||
195 | struct usb_endpoint_descriptor benchmark_ep_in_descriptor = | 195 | struct usb_endpoint_descriptor __attribute__((aligned(2))) benchmark_ep_in_descriptor = |
196 | { | 196 | { |
197 | .bLength = sizeof(struct usb_endpoint_descriptor), | 197 | .bLength = sizeof(struct usb_endpoint_descriptor), |
198 | .bDescriptorType = USB_DT_ENDPOINT, | 198 | .bDescriptorType = USB_DT_ENDPOINT, |
@@ -212,7 +212,7 @@ struct usb_endpoint_descriptor benchmark_ep_out_descriptor = | |||
212 | }; | 212 | }; |
213 | #endif | 213 | #endif |
214 | 214 | ||
215 | static const struct usb_qualifier_descriptor qualifier_descriptor = | 215 | static const struct usb_qualifier_descriptor __attribute__((aligned(2))) qualifier_descriptor = |
216 | { | 216 | { |
217 | .bLength = sizeof(struct usb_qualifier_descriptor), | 217 | .bLength = sizeof(struct usb_qualifier_descriptor), |
218 | .bDescriptorType = USB_DT_DEVICE_QUALIFIER, | 218 | .bDescriptorType = USB_DT_DEVICE_QUALIFIER, |
@@ -224,21 +224,21 @@ static const struct usb_qualifier_descriptor qualifier_descriptor = | |||
224 | .bNumConfigurations = 1 | 224 | .bNumConfigurations = 1 |
225 | }; | 225 | }; |
226 | 226 | ||
227 | static struct usb_string_descriptor usb_string_iManufacturer = | 227 | static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iManufacturer = |
228 | { | 228 | { |
229 | 24, | 229 | 24, |
230 | USB_DT_STRING, | 230 | USB_DT_STRING, |
231 | {'R','o','c','k','b','o','x','.','o','r','g'} | 231 | {'R','o','c','k','b','o','x','.','o','r','g'} |
232 | }; | 232 | }; |
233 | 233 | ||
234 | static struct usb_string_descriptor usb_string_iProduct = | 234 | static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iProduct = |
235 | { | 235 | { |
236 | 42, | 236 | 42, |
237 | USB_DT_STRING, | 237 | USB_DT_STRING, |
238 | {'R','o','c','k','b','o','x',' ','m','e','d','i','a',' ','p','l','a','y','e','r'} | 238 | {'R','o','c','k','b','o','x',' ','m','e','d','i','a',' ','p','l','a','y','e','r'} |
239 | }; | 239 | }; |
240 | 240 | ||
241 | static struct usb_string_descriptor usb_string_iSerial = | 241 | static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iSerial = |
242 | { | 242 | { |
243 | 82, | 243 | 82, |
244 | USB_DT_STRING, | 244 | USB_DT_STRING, |
@@ -250,21 +250,21 @@ static struct usb_string_descriptor usb_string_iSerial = | |||
250 | /* Generic for all targets */ | 250 | /* Generic for all targets */ |
251 | 251 | ||
252 | /* this is stringid #0: languages supported */ | 252 | /* this is stringid #0: languages supported */ |
253 | static struct usb_string_descriptor lang_descriptor = | 253 | static struct usb_string_descriptor __attribute__((aligned(2))) lang_descriptor = |
254 | { | 254 | { |
255 | 4, | 255 | 4, |
256 | USB_DT_STRING, | 256 | USB_DT_STRING, |
257 | {0x0409} /* LANGID US English */ | 257 | {0x0409} /* LANGID US English */ |
258 | }; | 258 | }; |
259 | 259 | ||
260 | static struct usb_string_descriptor usb_string_usb_benchmark = | 260 | static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_usb_benchmark = |
261 | { | 261 | { |
262 | 40, | 262 | 40, |
263 | USB_DT_STRING, | 263 | USB_DT_STRING, |
264 | {'B','u','l','k',' ','t','e','s','t',' ','i','n','t','e','r','f','a','c','e'} | 264 | {'B','u','l','k',' ','t','e','s','t',' ','i','n','t','e','r','f','a','c','e'} |
265 | }; | 265 | }; |
266 | 266 | ||
267 | static struct usb_string_descriptor usb_string_charging_only = | 267 | static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_charging_only = |
268 | { | 268 | { |
269 | 28, | 269 | 28, |
270 | USB_DT_STRING, | 270 | USB_DT_STRING, |
@@ -580,7 +580,7 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req) | |||
580 | switch (req->wValue >> 8) { /* type */ | 580 | switch (req->wValue >> 8) { /* type */ |
581 | case USB_DT_DEVICE: | 581 | case USB_DT_DEVICE: |
582 | ptr = &device_descriptor; | 582 | ptr = &device_descriptor; |
583 | size = sizeof device_descriptor; | 583 | size = sizeof(struct usb_device_descriptor); |
584 | break; | 584 | break; |
585 | 585 | ||
586 | case USB_DT_OTHER_SPEED_CONFIG: | 586 | case USB_DT_OTHER_SPEED_CONFIG: |
@@ -606,7 +606,7 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req) | |||
606 | } | 606 | } |
607 | config_descriptor.bDescriptorType=USB_DT_OTHER_SPEED_CONFIG; | 607 | config_descriptor.bDescriptorType=USB_DT_OTHER_SPEED_CONFIG; |
608 | } | 608 | } |
609 | size = sizeof(config_descriptor); | 609 | size = sizeof(struct usb_config_descriptor); |
610 | 610 | ||
611 | #ifdef USB_CHARGING_ONLY | 611 | #ifdef USB_CHARGING_ONLY |
612 | if(usb_core_charging_enabled){ | 612 | if(usb_core_charging_enabled){ |
@@ -682,7 +682,7 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req) | |||
682 | 682 | ||
683 | case USB_DT_DEVICE_QUALIFIER: | 683 | case USB_DT_DEVICE_QUALIFIER: |
684 | ptr = &qualifier_descriptor; | 684 | ptr = &qualifier_descriptor; |
685 | size = sizeof qualifier_descriptor; | 685 | size = sizeof (struct usb_qualifier_descriptor); |
686 | break; | 686 | break; |
687 | 687 | ||
688 | default: | 688 | default: |