summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/usbstack/usb_core.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c
index 8a602894d0..915c15087f 100644
--- a/firmware/usbstack/usb_core.c
+++ b/firmware/usbstack/usb_core.c
@@ -48,6 +48,10 @@
48#include "as3514.h" 48#include "as3514.h"
49#endif 49#endif
50 50
51#if !defined(HAVE_AS3514) && !defined(IPOD_ARCH)
52#include "ata.h"
53#endif
54
51 55
52/*-------------------------------------------------------------------------*/ 56/*-------------------------------------------------------------------------*/
53/* USB protocol descriptors: */ 57/* USB protocol descriptors: */
@@ -233,10 +237,11 @@ static struct usb_string_descriptor usb_string_iProduct =
233 237
234static struct usb_string_descriptor usb_string_iSerial = 238static struct usb_string_descriptor usb_string_iSerial =
235{ 239{
236 66, 240 82,
237 USB_DT_STRING, 241 USB_DT_STRING,
238 {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', 242 {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
239 '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'} 243 '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
244 '0','0','0','0','0','0','0','0'}
240}; 245};
241 246
242/* Generic for all targets */ 247/* Generic for all targets */
@@ -316,8 +321,7 @@ static void set_serial_descriptor(void)
316 321
317 /* We need to convert from a little-endian 64-bit int 322 /* We need to convert from a little-endian 64-bit int
318 into a utf-16 string of hex characters */ 323 into a utf-16 string of hex characters */
319 /* Align at the right side of the 32-digit serial number */ 324 short* p = &usb_string_iSerial.wString[15];
320 short* p = &usb_string_iSerial.wString[31];
321 uint32_t x; 325 uint32_t x;
322 int i,j; 326 int i,j;
323 327
@@ -330,6 +334,7 @@ static void set_serial_descriptor(void)
330 x >>= 4; 334 x >>= 4;
331 } 335 }
332 } 336 }
337 usb_string_iSerial.bLength=34;
333} 338}
334#elif defined(HAVE_AS3514) 339#elif defined(HAVE_AS3514)
335static void set_serial_descriptor(void) 340static void set_serial_descriptor(void)
@@ -338,6 +343,7 @@ static void set_serial_descriptor(void)
338 '8','9','A','B','C','D','E','F'}; 343 '8','9','A','B','C','D','E','F'};
339 344
340 unsigned char serial[16]; 345 unsigned char serial[16];
346 /* Align 32 digits right in the 40-digit serial number */
341 short* p = usb_string_iSerial.wString; 347 short* p = usb_string_iSerial.wString;
342 int i; 348 int i;
343 349
@@ -347,6 +353,30 @@ static void set_serial_descriptor(void)
347 *p++ = hex[(serial[i] >> 4) & 0xF]; 353 *p++ = hex[(serial[i] >> 4) & 0xF];
348 *p++ = hex[(serial[i] >> 0) & 0xF]; 354 *p++ = hex[(serial[i] >> 0) & 0xF];
349 } 355 }
356 usb_string_iSerial.bLength=66;
357}
358#else
359/* If we don't know the device serial number, use the one
360 * from the disk */
361static void set_serial_descriptor(void)
362{
363 static short hex[16] = {'0','1','2','3','4','5','6','7',
364 '8','9','A','B','C','D','E','F'};
365
366 short* p = usb_string_iSerial.wString;
367 unsigned short* identify = ata_get_identify();
368 unsigned short x;
369 int i;
370
371 for (i = 10; i < 20; i++)
372 {
373 x = betoh16(identify[i]);
374 *p++ = hex[(x >> 4) & 0xF];
375 *p++ = hex[(x >> 0) & 0xF];
376 *p++ = hex[(x >> 12) & 0xF];
377 *p++ = hex[(x >> 8) & 0xF];
378 }
379 usb_string_iSerial.bLength=82;
350} 380}
351#endif 381#endif
352 382
@@ -406,9 +436,7 @@ bool usb_core_data_connection(void)
406#ifdef USB_THREAD 436#ifdef USB_THREAD
407void usb_core_thread(void) 437void usb_core_thread(void)
408{ 438{
409#if defined(IPOD_ARCH) || defined(HAVE_AS3514)
410 set_serial_descriptor(); 439 set_serial_descriptor();
411#endif
412 440
413 while (1) { 441 while (1) {
414 struct queue_event ev; 442 struct queue_event ev;