diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/isp1583.c | 114 | ||||
-rw-r--r-- | firmware/export/config-creativezvm.h | 2 | ||||
-rw-r--r-- | firmware/export/dm320.h | 2 | ||||
-rw-r--r-- | firmware/export/isp1583.h | 4 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c | 174 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/creative-zvm/ata-target.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c | 35 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/creative-zvm/usb-target.h | 6 | ||||
-rwxr-xr-x | firmware/target/arm/tms320dm320/crt0.S | 2 | ||||
-rwxr-xr-x | firmware/target/arm/tms320dm320/i2c-dm320.c | 2 |
11 files changed, 191 insertions, 154 deletions
diff --git a/firmware/drivers/isp1583.c b/firmware/drivers/isp1583.c index 9e7d601278..f373741586 100644 --- a/firmware/drivers/isp1583.c +++ b/firmware/drivers/isp1583.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "isp1583.h" | 27 | #include "isp1583.h" |
28 | #include "thread.h" | 28 | #include "thread.h" |
29 | #include "logf.h" | 29 | #include "logf.h" |
30 | #include <stdio.h> | 30 | #include "stdio.h" |
31 | 31 | ||
32 | #define DIR_RX 0 | 32 | #define DIR_RX 0 |
33 | #define DIR_TX 1 | 33 | #define DIR_TX 1 |
@@ -200,7 +200,9 @@ static int usb_receive(int n) | |||
200 | len = usb_get_packet(endpoints[n].in_buf + endpoints[n].in_ptr, | 200 | len = usb_get_packet(endpoints[n].in_buf + endpoints[n].in_ptr, |
201 | endpoints[n].in_max_len - endpoints[n].in_ptr); | 201 | endpoints[n].in_max_len - endpoints[n].in_ptr); |
202 | endpoints[n].in_ptr += len; | 202 | endpoints[n].in_ptr += len; |
203 | if (endpoints[n].in_ptr >= endpoints[n].in_min_len) { | 203 | |
204 | if (endpoints[n].in_ptr >= endpoints[n].in_min_len) | ||
205 | { | ||
204 | endpoints[n].in_min_len = -1; | 206 | endpoints[n].in_min_len = -1; |
205 | if (endpoints[n].in_done) | 207 | if (endpoints[n].in_done) |
206 | (*(endpoints[n].in_done))(n, endpoints[n].in_buf, | 208 | (*(endpoints[n].in_done))(n, endpoints[n].in_buf, |
@@ -229,10 +231,10 @@ static int usb_send(int n) | |||
229 | if (endpoints[n].halt[DIR_TX] | 231 | if (endpoints[n].halt[DIR_TX] |
230 | || !endpoints[n].enabled[DIR_TX] | 232 | || !endpoints[n].enabled[DIR_TX] |
231 | || !endpoints[n].out_in_progress) | 233 | || !endpoints[n].out_in_progress) |
232 | { | 234 | { |
233 | logf("NOT SEND TO EP!"); | 235 | logf("NOT SEND TO EP!"); |
234 | return -1; | 236 | return -1; |
235 | } | 237 | } |
236 | 238 | ||
237 | if (endpoints[n].out_ptr < 0) | 239 | if (endpoints[n].out_ptr < 0) |
238 | { | 240 | { |
@@ -246,9 +248,9 @@ static int usb_send(int n) | |||
246 | 248 | ||
247 | if (usb_out_buffer_full(n)) | 249 | if (usb_out_buffer_full(n)) |
248 | { | 250 | { |
249 | logf("BUFFER FULL!"); | 251 | logf("BUFFER FULL!"); |
250 | return -1; | 252 | return -1; |
251 | } | 253 | } |
252 | 254 | ||
253 | usb_select_endpoint(ep_index(n, DIR_TX)); | 255 | usb_select_endpoint(ep_index(n, DIR_TX)); |
254 | max_pkt_size = endpoints[n].max_pkt_size[DIR_TX]; | 256 | max_pkt_size = endpoints[n].max_pkt_size[DIR_TX]; |
@@ -261,7 +263,8 @@ static int usb_send(int n) | |||
261 | 263 | ||
262 | p = endpoints[n].out_buf + endpoints[n].out_ptr; | 264 | p = endpoints[n].out_buf + endpoints[n].out_ptr; |
263 | i = 0; | 265 | i = 0; |
264 | while (len - i >= 2) { | 266 | while (len - i >= 2) |
267 | { | ||
265 | ISP1583_DFLOW_DATA = p[i] | (p[i + 1] << 8); | 268 | ISP1583_DFLOW_DATA = p[i] | (p[i + 1] << 8); |
266 | i += 2; | 269 | i += 2; |
267 | } | 270 | } |
@@ -308,7 +311,11 @@ static void usb_unstall_endpoint(int idx) | |||
308 | static void usb_status_ack(int ep, int dir) | 311 | static void usb_status_ack(int ep, int dir) |
309 | { | 312 | { |
310 | logf("usb_status_ack(%d)", dir); | 313 | logf("usb_status_ack(%d)", dir); |
311 | usb_select_endpoint(ep_index(ep, dir)); | 314 | if(ep == EP_CONTROL) |
315 | usb_select_setup_endpoint(); | ||
316 | else | ||
317 | usb_select_endpoint(ep_index(ep, dir)); | ||
318 | |||
312 | ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_STATUS; | 319 | ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_STATUS; |
313 | } | 320 | } |
314 | 321 | ||
@@ -326,7 +333,10 @@ static void usb_handle_setup_rx(void) | |||
326 | len = usb_get_packet(setup_pkt_buf, 8); | 333 | len = usb_get_packet(setup_pkt_buf, 8); |
327 | 334 | ||
328 | if (len == 8) | 335 | if (len == 8) |
336 | { | ||
337 | ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_STATUS; /* Acknowledge packet */ | ||
329 | usb_core_control_request((struct usb_ctrlrequest*)setup_pkt_buf); | 338 | usb_core_control_request((struct usb_ctrlrequest*)setup_pkt_buf); |
339 | } | ||
330 | else | 340 | else |
331 | { | 341 | { |
332 | usb_drv_stall(0, true, false); | 342 | usb_drv_stall(0, true, false); |
@@ -388,9 +398,7 @@ void usb_helper(void) | |||
388 | { | 398 | { |
389 | if(ISP1583_GEN_INT_READ & ISP1583_INIT_INTEN_READ) | 399 | if(ISP1583_GEN_INT_READ & ISP1583_INIT_INTEN_READ) |
390 | { | 400 | { |
391 | #ifdef DEBUG | 401 | logf("Helper detected interrupt... [%d]", (int)current_tick); |
392 | logf("Helper detected interrupt... [%d]", current_tick); | ||
393 | #endif | ||
394 | usb_drv_int(); | 402 | usb_drv_int(); |
395 | } | 403 | } |
396 | return; | 404 | return; |
@@ -413,14 +421,6 @@ void usb_drv_init(void) | |||
413 | /* Disable all OTG functions */ | 421 | /* Disable all OTG functions */ |
414 | ISP1583_INIT_OTG = 0; | 422 | ISP1583_INIT_OTG = 0; |
415 | 423 | ||
416 | #if 0 | ||
417 | #ifdef USE_HIGH_SPEED | ||
418 | /* Force device to high speed */ | ||
419 | ISP1583_GEN_TSTMOD = GEN_TSTMOD_FORCEHS; | ||
420 | high_speed_mode = true; | ||
421 | #endif | ||
422 | #endif | ||
423 | |||
424 | #ifdef DEBUG | 424 | #ifdef DEBUG |
425 | logf("BUS_CONF/DA0:%d MODE0/DA1: %d MODE1: %d", (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST0), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST1), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST2)); | 425 | logf("BUS_CONF/DA0:%d MODE0/DA1: %d MODE1: %d", (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST0), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST1), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST2)); |
426 | logf("Chip ID: 0x%x", ISP1583_GEN_CHIPID); | 426 | logf("Chip ID: 0x%x", ISP1583_GEN_CHIPID); |
@@ -454,7 +454,7 @@ void usb_drv_init(void) | |||
454 | 454 | ||
455 | ZVM_SPECIFIC; | 455 | ZVM_SPECIFIC; |
456 | 456 | ||
457 | tick_add_task(usb_helper); | 457 | //tick_add_task(usb_helper); |
458 | 458 | ||
459 | logf("usb_init_device() finished"); | 459 | logf("usb_init_device() finished"); |
460 | } | 460 | } |
@@ -482,7 +482,7 @@ void usb_drv_exit(void) | |||
482 | ISP1583_INIT_MODE = INIT_MODE_GOSUSP; | 482 | ISP1583_INIT_MODE = INIT_MODE_GOSUSP; |
483 | ISP1583_INIT_MODE = 0; | 483 | ISP1583_INIT_MODE = 0; |
484 | 484 | ||
485 | tick_remove_task(usb_helper); | 485 | //tick_remove_task(usb_helper); |
486 | 486 | ||
487 | ZVM_SPECIFIC; | 487 | ZVM_SPECIFIC; |
488 | } | 488 | } |
@@ -504,7 +504,7 @@ bool usb_drv_stalled(int endpoint, bool in) | |||
504 | static void out_callback(int ep, unsigned char *buf, int len) | 504 | static void out_callback(int ep, unsigned char *buf, int len) |
505 | { | 505 | { |
506 | (void)buf; | 506 | (void)buf; |
507 | logf("out_callback(%d, 0x%x, %d)", ep, &buf, len); | 507 | logf("out_callback(%d, 0x%x, %d)", ep, (int)buf, len); |
508 | usb_status_ack(ep, DIR_RX); | 508 | usb_status_ack(ep, DIR_RX); |
509 | usb_core_transfer_complete(ep, true, 0, len); /* 0=>status succeeded, haven't worked out status failed yet... */ | 509 | usb_core_transfer_complete(ep, true, 0, len); /* 0=>status succeeded, haven't worked out status failed yet... */ |
510 | } | 510 | } |
@@ -512,14 +512,14 @@ static void out_callback(int ep, unsigned char *buf, int len) | |||
512 | static void in_callback(int ep, unsigned char *buf, int len) | 512 | static void in_callback(int ep, unsigned char *buf, int len) |
513 | { | 513 | { |
514 | (void)buf; | 514 | (void)buf; |
515 | logf("in_callback(%d, 0x%x, %d)", ep, &buf, len); | 515 | logf("in_callback(%d, 0x%x, %d)", ep, (int)buf, len); |
516 | usb_status_ack(ep, DIR_TX); | 516 | usb_status_ack(ep, DIR_TX); |
517 | usb_core_transfer_complete(ep, false, 0, len); | 517 | usb_core_transfer_complete(ep, false, 0, len); |
518 | } | 518 | } |
519 | 519 | ||
520 | int usb_drv_recv(int ep, void* ptr, int length) | 520 | int usb_drv_recv(int ep, void* ptr, int length) |
521 | { | 521 | { |
522 | logf("usb_drv_recv(%d, 0x%x, %d)", ep, &ptr, length); | 522 | logf("usb_drv_recv(%d, 0x%x, %d)", ep, (int)ptr, length); |
523 | if(ep == 0 && length == 0 && ptr == NULL) | 523 | if(ep == 0 && length == 0 && ptr == NULL) |
524 | { | 524 | { |
525 | usb_status_ack(ep, DIR_TX); | 525 | usb_status_ack(ep, DIR_TX); |
@@ -562,7 +562,7 @@ static void usb_drv_wait(int ep, bool send) | |||
562 | 562 | ||
563 | int usb_drv_send(int ep, void* ptr, int length) | 563 | int usb_drv_send(int ep, void* ptr, int length) |
564 | { | 564 | { |
565 | logf("usb_drv_send_nb(%d, 0x%x, %d)", ep, &ptr, length); | 565 | logf("usb_drv_send_nb(%d, 0x%x, %d)", ep, (int)ptr, length); |
566 | if(ep == 0 && length == 0 && ptr == NULL) | 566 | if(ep == 0 && length == 0 && ptr == NULL) |
567 | { | 567 | { |
568 | usb_status_ack(ep, DIR_RX); | 568 | usb_status_ack(ep, DIR_RX); |
@@ -624,8 +624,6 @@ void usb_drv_release_endpoint(int ep) | |||
624 | endpoints[ep & 0x7f].allocation &= mask; | 624 | endpoints[ep & 0x7f].allocation &= mask; |
625 | } | 625 | } |
626 | 626 | ||
627 | |||
628 | |||
629 | static void bus_reset(void) | 627 | static void bus_reset(void) |
630 | { | 628 | { |
631 | /* Enable CLKAON & GLINTENA */ | 629 | /* Enable CLKAON & GLINTENA */ |
@@ -656,13 +654,11 @@ void IRAM_ATTR usb_drv_int(void) | |||
656 | 654 | ||
657 | if(!ints) | 655 | if(!ints) |
658 | return; | 656 | return; |
659 | 657 | ||
660 | /* Unlock the device's registers */ | 658 | /* Unlock the device's registers */ |
661 | ISP1583_GEN_UNLCKDEV = ISP1583_UNLOCK_CODE; | 659 | ISP1583_GEN_UNLCKDEV = ISP1583_UNLOCK_CODE; |
662 | 660 | ||
663 | #if 0 | 661 | //logf(" handling int [0x%lx & 0x%lx = 0x%x]", ISP1583_GEN_INT_READ, ISP1583_INIT_INTEN_READ, (int)ints); |
664 | logf(" handling int [0x%x & 0x%x = 0x%x]", ISP1583_GEN_INT_READ, ISP1583_INIT_INTEN_READ, ints); | ||
665 | #endif | ||
666 | 662 | ||
667 | if(ints & INT_IEBRST) /* Bus reset */ | 663 | if(ints & INT_IEBRST) /* Bus reset */ |
668 | { | 664 | { |
@@ -732,10 +728,35 @@ void usb_drv_set_address(int address) | |||
732 | ISP1583_INIT_ADDRESS = (address & 0x7F) | INIT_ADDRESS_DEVEN; | 728 | ISP1583_INIT_ADDRESS = (address & 0x7F) | INIT_ADDRESS_DEVEN; |
733 | 729 | ||
734 | ZVM_SPECIFIC; | 730 | ZVM_SPECIFIC; |
735 | |||
736 | usb_status_ack(0, DIR_TX); | ||
737 | } | 731 | } |
738 | 732 | ||
733 | void usb_drv_set_test_mode(int mode) | ||
734 | { | ||
735 | logf("usb_drv_set_test_mode(%d)", mode); | ||
736 | switch(mode){ | ||
737 | case 0: | ||
738 | ISP1583_GEN_TSTMOD = 0; | ||
739 | /* Power cycle... */ | ||
740 | break; | ||
741 | case 1: | ||
742 | ISP1583_GEN_TSTMOD = GEN_TSTMOD_JSTATE; | ||
743 | break; | ||
744 | case 2: | ||
745 | ISP1583_GEN_TSTMOD = GEN_TSTMOD_KSTATE; | ||
746 | break; | ||
747 | case 3: | ||
748 | ISP1583_GEN_TSTMOD = GEN_TSTMOD_SE0_NAK; | ||
749 | break; | ||
750 | case 4: | ||
751 | //REG_PORTSC1 |= PORTSCX_PTC_PACKET; | ||
752 | break; | ||
753 | case 5: | ||
754 | //REG_PORTSC1 |= PORTSCX_PTC_FORCE_EN; | ||
755 | break; | ||
756 | } | ||
757 | } | ||
758 | |||
759 | #ifndef BOOTLOADER | ||
739 | int dbg_usb_num_items(void) | 760 | int dbg_usb_num_items(void) |
740 | { | 761 | { |
741 | return 2+USB_NUM_ENDPOINTS*2; | 762 | return 2+USB_NUM_ENDPOINTS*2; |
@@ -782,29 +803,4 @@ char* dbg_usb_item(int selected_item, void *data, char *buffer, size_t buffer_le | |||
782 | return NULL; | 803 | return NULL; |
783 | (void)data; | 804 | (void)data; |
784 | } | 805 | } |
785 | 806 | #endif | |
786 | void usb_drv_set_test_mode(int mode) | ||
787 | { | ||
788 | logf("usb_drv_set_test_mode(%d)", mode); | ||
789 | switch(mode){ | ||
790 | case 0: | ||
791 | ISP1583_GEN_TSTMOD = 0; | ||
792 | /* Power cycle... */ | ||
793 | break; | ||
794 | case 1: | ||
795 | ISP1583_GEN_TSTMOD = GEN_TSTMOD_JSTATE; | ||
796 | break; | ||
797 | case 2: | ||
798 | ISP1583_GEN_TSTMOD = GEN_TSTMOD_KSTATE; | ||
799 | break; | ||
800 | case 3: | ||
801 | ISP1583_GEN_TSTMOD = GEN_TSTMOD_SE0_NAK; | ||
802 | break; | ||
803 | case 4: | ||
804 | //REG_PORTSC1 |= PORTSCX_PTC_PACKET; | ||
805 | break; | ||
806 | case 5: | ||
807 | //REG_PORTSC1 |= PORTSCX_PTC_FORCE_EN; | ||
808 | break; | ||
809 | } | ||
810 | } | ||
diff --git a/firmware/export/config-creativezvm.h b/firmware/export/config-creativezvm.h index ea3cc871a5..2e14f7440c 100644 --- a/firmware/export/config-creativezvm.h +++ b/firmware/export/config-creativezvm.h | |||
@@ -167,8 +167,10 @@ | |||
167 | 167 | ||
168 | #define CONFIG_USBOTG USBOTG_ISP1583 | 168 | #define CONFIG_USBOTG USBOTG_ISP1583 |
169 | #define HAVE_USBSTACK | 169 | #define HAVE_USBSTACK |
170 | #define USE_ROCKBOX_USB | ||
170 | #define USB_VENDOR_ID 0x041e | 171 | #define USB_VENDOR_ID 0x041e |
171 | #define USB_PRODUCT_ID 0x4133 | 172 | #define USB_PRODUCT_ID 0x4133 |
173 | #define USB_NUM_ENDPOINTS 7 | ||
172 | 174 | ||
173 | /*DEBUGGING!*/ | 175 | /*DEBUGGING!*/ |
174 | /* | 176 | /* |
diff --git a/firmware/export/dm320.h b/firmware/export/dm320.h index 0e1623365a..bf7295d463 100644 --- a/firmware/export/dm320.h +++ b/firmware/export/dm320.h | |||
@@ -43,8 +43,6 @@ | |||
43 | #define PHY_IO_BASE2 0x00060000 | 43 | #define PHY_IO_BASE2 0x00060000 |
44 | #define DM320_REG2(addr) (*(volatile unsigned int *)(PHY_IO_BASE2 + (addr))) | 44 | #define DM320_REG2(addr) (*(volatile unsigned int *)(PHY_IO_BASE2 + (addr))) |
45 | 45 | ||
46 | /* USBOTG */ | ||
47 | #define USB_NUM_ENDPOINTS 3 | ||
48 | /* This needs to be 2048 byte aligned, but USB_QHARRAY_ATTR should take care | 46 | /* This needs to be 2048 byte aligned, but USB_QHARRAY_ATTR should take care |
49 | * of that */ | 47 | * of that */ |
50 | #define USB_QHARRAY_ATTR __attribute__((section(".qharray"),nocommon,aligned(4))) | 48 | #define USB_QHARRAY_ATTR __attribute__((section(".qharray"),nocommon,aligned(4))) |
diff --git a/firmware/export/isp1583.h b/firmware/export/isp1583.h index b65cc078f3..0bdbba886c 100644 --- a/firmware/export/isp1583.h +++ b/firmware/export/isp1583.h | |||
@@ -52,10 +52,10 @@ | |||
52 | #define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C))) | 52 | #define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C))) |
53 | #define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84))) | 53 | #define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84))) |
54 | 54 | ||
55 | #define set_int_value(a,b,value) a = value; | 55 | #define set_int_value(a,b,value) (a) = (value); |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #define ISP1583_UNLOCK_CODE (unsigned short)0xAA37 | 58 | #define ISP1583_UNLOCK_CODE ((unsigned short)0xAA37) |
59 | 59 | ||
60 | /* Initialization registers' bits */ | 60 | /* Initialization registers' bits */ |
61 | 61 | ||
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c index a55cda4c14..b945d47b4b 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c | |||
@@ -203,7 +203,7 @@ static unsigned long cfs_start; | |||
203 | static unsigned long *sectors; | 203 | static unsigned long *sectors; |
204 | 204 | ||
205 | #define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 ) | 205 | #define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 ) |
206 | #define CFS_CLUSTER2CLUSTER(x) ( CFS_START+((x)-1)*64 ) | 206 | #define CFS_CLUSTER2CLUSTER(x) ( (CFS_START/512)+((x)-1)*64 ) |
207 | 207 | ||
208 | /* Limited version of UCS -> ASCII */ | 208 | /* Limited version of UCS -> ASCII */ |
209 | static char* ucs2letostring(unsigned char* s) | 209 | static char* ucs2letostring(unsigned char* s) |
@@ -211,7 +211,7 @@ static char* ucs2letostring(unsigned char* s) | |||
211 | static char res[256]; | 211 | static char res[256]; |
212 | int i; | 212 | int i; |
213 | 213 | ||
214 | for(i=0; (s[i] == 0 && s[i+1] == 0); i++) | 214 | for(i=0; (s[i] == 0 && s[i+1] == 0 && i<256); i++) |
215 | res[i] = s[i*2]; | 215 | res[i] = s[i*2]; |
216 | 216 | ||
217 | return (char*)&res; | 217 | return (char*)&res; |
@@ -236,111 +236,134 @@ static void cfs_init(void) | |||
236 | _ata_read_sectors(0, 1, §or); | 236 | _ata_read_sectors(0, 1, §or); |
237 | hdr = (struct main_header*)§or; | 237 | hdr = (struct main_header*)§or; |
238 | 238 | ||
239 | //printf("CFS is at 0x%x", CFS_START); | 239 | logf("CFS is at 0x%x [0x%x]", CFS_START, CFS_START/512); |
240 | 240 | ||
241 | /* Read CFS header */ | 241 | /* Read CFS header */ |
242 | _ata_read_sectors(CFS_START/512, 64, §or2); | 242 | _ata_read_sectors(CFS_START/512, 64, §or2); |
243 | cfs = (struct cfs_header*)§or2; | 243 | cfs = (struct cfs_header*)§or2; |
244 | 244 | ||
245 | //printf("First inode = %d", cfs->first_inode); | 245 | logf("First inode = 0x%x", cfs->first_inode); |
246 | 246 | ||
247 | /* Read root inode */ | 247 | /* Read root inode */ |
248 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, §or2); | 248 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, §or2); |
249 | root_inode = (struct cfs_inode*)§or2; | 249 | root_inode = (struct cfs_inode*)§or2; |
250 | |||
251 | logf("Root inode = 0x%x", root_inode); | ||
252 | |||
253 | logf("0x%x 0x%x", CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), root_inode->first_class_chain[0]); | ||
250 | 254 | ||
251 | /* Read root inode's first sector */ | 255 | /* Read root inode's first sector */ |
252 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, §or2); | 256 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, §or2); |
253 | root_direntry = (struct cfs_direntry*)§or2; | 257 | root_direntry = (struct cfs_direntry*)§or2; |
254 | root_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); | 258 | root_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); |
255 | 259 | ||
260 | logf("0x%x", root_direntry->identifier); | ||
261 | |||
262 | logf("%d", root_direntry->items); | ||
263 | |||
256 | /* Search VFAT inode */ | 264 | /* Search VFAT inode */ |
257 | for(i=0; i < root_direntry->items; i++) | 265 | for(i=0; i < root_direntry->items; i++) |
258 | { | 266 | { |
259 | //printf(" * [%s] at 0x%x\n", ucs2letostring(&root_direntry_items[i].string[0]), root_direntry_items[i].inode_number); | 267 | if(root_direntry_items[i].inode_number != 0) |
260 | if(strcmp(ucs2letostring(&root_direntry_items[i].string[0]), "VFAT") == 0) | 268 | { |
261 | vfat_inode_nr = root_direntry_items[i].inode_number; | 269 | //logf(" * [%s] at 0x%x", ucs2letostring(&root_direntry_items[i].string[0]), root_direntry_items[i].inode_number); |
270 | if(strcmp(ucs2letostring(&root_direntry_items[i].string[0]), "VFAT") == 0) | ||
271 | vfat_inode_nr = root_direntry_items[i].inode_number; | ||
272 | } | ||
262 | } | 273 | } |
263 | 274 | ||
264 | /* Read VFAT inode */ | 275 | logf("VFAT inode = 0x%x", vfat_inode_nr); |
265 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, §or2); | 276 | |
266 | vfat_inode = (struct cfs_inode*)§or2; | 277 | if(vfat_inode_nr != 0) |
267 | |||
268 | /* Read VFAT inode's first sector */ | ||
269 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, §or2); | ||
270 | vfat_direntry = (struct cfs_direntry*)§or2; | ||
271 | vfat_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); | ||
272 | |||
273 | /* Search for VFAT's subinodes */ | ||
274 | for(i=0; i < vfat_direntry->items; i++) | ||
275 | { | 278 | { |
276 | //printf(" * [%s] at 0x%x\n", ucs2letostring(&vfat_direntry_items[i].string[0]), vfat_direntry_items[i].inode_number); | 279 | /* Read VFAT inode */ |
277 | if(i > 0) | 280 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, §or2); |
278 | vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number; | 281 | vfat_inode = (struct cfs_inode*)§or2; |
279 | } | ||
280 | 282 | ||
281 | /* Determine size of VFAT file */ | 283 | /* Read VFAT inode's first sector */ |
282 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); | 284 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, §or2); |
283 | inode = (struct cfs_inode*)§or; | 285 | vfat_direntry = (struct cfs_direntry*)§or2; |
284 | sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize)); | 286 | vfat_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); |
285 | 287 | ||
286 | //printf("VFAT file size: 0x%x", inode->filesize); | 288 | /* Search for VFAT's subinodes */ |
287 | 289 | for(i=0; i < vfat_direntry->items; i++) | |
288 | /* Clear data sectors */ | 290 | { |
289 | memset(§ors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long)); | 291 | logf(" * [%s] at 0x%x\n", ucs2letostring(&vfat_direntry_items[i].string[0]), vfat_direntry_items[i].inode_number); |
292 | if(i > 0) | ||
293 | vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number; | ||
294 | } | ||
290 | 295 | ||
291 | /* Read all data sectors' addresses in memory */ | 296 | /* Determine size of VFAT file */ |
292 | vfat_sector_count = 0; | 297 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); |
293 | for(i=0; vfat_inodes_nr[i] != 0; i++) | ||
294 | { | ||
295 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, §or); | ||
296 | inode = (struct cfs_inode*)§or; | 298 | inode = (struct cfs_inode*)§or; |
299 | #ifndef BOOTLOADER | ||
300 | sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize)); | ||
301 | #else | ||
302 | static unsigned long _sector[VFAT_SECTOR_SIZE(1024*1024*1024)]; /* 1GB guess */ | ||
303 | sectors = _sector; | ||
304 | #endif | ||
297 | 305 | ||
298 | /* Read second & third class chain */ | 306 | logf("VFAT file size: 0x%x", inode->filesize); |
299 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_first_cluster), 64, &vfat_data[0]); | ||
300 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]); | ||
301 | 307 | ||
302 | /* First class chain */ | 308 | /* Clear data sectors */ |
303 | for(j=0; j<12; j++) | 309 | memset(§ors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long)); |
304 | { | ||
305 | if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF && | ||
306 | inode->first_class_chain[j] != 0 | ||
307 | ) | ||
308 | sectors[vfat_sector_count++] = inode->first_class_chain[j]; | ||
309 | } | ||
310 | 310 | ||
311 | /* Second class chain */ | 311 | /* Read all data sectors' addresses in memory */ |
312 | for(j=0; j<0x8000/4; j++) | 312 | vfat_sector_count = 0; |
313 | for(i=0; vfat_inodes_nr[i] != 0; i++) | ||
313 | { | 314 | { |
314 | if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF && | 315 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, §or); |
315 | vfat_data[0][j] != 0 | 316 | inode = (struct cfs_inode*)§or; |
316 | ) | ||
317 | sectors[vfat_sector_count++] = vfat_data[0][j]; | ||
318 | } | ||
319 | 317 | ||
320 | /* Third class chain */ | 318 | /* Read second & third class chain */ |
321 | for(j=0; j<0x8000/4; j++) | 319 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_first_cluster), 64, &vfat_data[0]); |
322 | { | 320 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]); |
323 | if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF && | 321 | |
324 | vfat_data[1][j] != 0 | 322 | /* First class chain */ |
325 | ) | 323 | for(j=0; j<12; j++) |
326 | { | 324 | { |
327 | memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int)); | 325 | if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF && |
326 | inode->first_class_chain[j] != 0 | ||
327 | ) | ||
328 | sectors[vfat_sector_count++] = inode->first_class_chain[j]; | ||
329 | } | ||
328 | 330 | ||
329 | /* Read third class subchain(s) */ | 331 | /* Second class chain */ |
330 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]); | 332 | for(j=0; j<0x8000/4; j++) |
333 | { | ||
334 | if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF && | ||
335 | vfat_data[0][j] != 0 | ||
336 | ) | ||
337 | sectors[vfat_sector_count++] = vfat_data[0][j]; | ||
338 | } | ||
331 | 339 | ||
332 | for(k=0; k<0x8000/4; k++) | 340 | /* Third class chain */ |
341 | for(j=0; j<0x8000/4; j++) | ||
342 | { | ||
343 | if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF && | ||
344 | vfat_data[1][j] != 0 | ||
345 | ) | ||
333 | { | 346 | { |
334 | if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF && | 347 | memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int)); |
335 | vfat_data[0][k] != 0 | 348 | |
336 | ) | 349 | /* Read third class subchain(s) */ |
337 | sectors[vfat_sector_count++] = vfat_data[0][k]; | 350 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]); |
351 | |||
352 | for(k=0; k<0x8000/4; k++) | ||
353 | { | ||
354 | if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF && | ||
355 | vfat_data[0][k] != 0 | ||
356 | ) | ||
357 | sectors[vfat_sector_count++] = vfat_data[0][k]; | ||
358 | } | ||
338 | } | 359 | } |
339 | } | 360 | } |
340 | } | 361 | } |
341 | } | ||
342 | 362 | ||
343 | //printf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count); | 363 | logf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count); |
364 | } | ||
365 | else | ||
366 | logf("Cannot find virtual FAT filesystem!"); //TODO: panicf | ||
344 | 367 | ||
345 | cfs_inited = true; | 368 | cfs_inited = true; |
346 | } | 369 | } |
@@ -386,6 +409,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v | |||
386 | if(!cfs_inited) | 409 | if(!cfs_inited) |
387 | cfs_init(); | 410 | cfs_init(); |
388 | 411 | ||
412 | #if 0 /* Disabled for now */ | ||
389 | /* Check if count is lesser than or equal to 1 native CFS sector */ | 413 | /* Check if count is lesser than or equal to 1 native CFS sector */ |
390 | if(count <= 64) | 414 | if(count <= 64) |
391 | return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf); | 415 | return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf); |
@@ -406,8 +430,16 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v | |||
406 | 430 | ||
407 | return ret; | 431 | return ret; |
408 | } | 432 | } |
433 | #else | ||
434 | (void)start; | ||
435 | (void)count; | ||
436 | (void)buf; | ||
437 | return 0; | ||
438 | #endif | ||
409 | } | 439 | } |
410 | 440 | ||
441 | #ifdef BOOTLOADER | ||
442 | |||
411 | /* | 443 | /* |
412 | --------------------------------------------------------------------------- | 444 | --------------------------------------------------------------------------- |
413 | MiniFileSystem parsing code | 445 | MiniFileSystem parsing code |
@@ -487,3 +519,5 @@ int load_minifs_file(char* filename, unsigned char* location) | |||
487 | 519 | ||
488 | return files[found].size; | 520 | return files[found].size; |
489 | } | 521 | } |
522 | |||
523 | #endif | ||
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h index ba877a1496..64c49fe68e 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h | |||
@@ -82,6 +82,8 @@ void ata_reset(void); | |||
82 | void ata_device_init(void); | 82 | void ata_device_init(void); |
83 | bool ata_is_coldstart(void); | 83 | bool ata_is_coldstart(void); |
84 | void ide_power_enable(bool on); | 84 | void ide_power_enable(bool on); |
85 | #ifdef BOOTLOADER | ||
85 | int load_minifs_file(char* filename, unsigned char* location); | 86 | int load_minifs_file(char* filename, unsigned char* location); |
87 | #endif | ||
86 | 88 | ||
87 | #endif | 89 | #endif |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c index 97b33bdffe..7d85464b70 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "button-target.h" | 27 | #include "button-target.h" |
28 | #include "i2c-dm320.h" | 28 | #include "i2c-dm320.h" |
29 | #include "sprintf.h" | 29 | #include "sprintf.h" |
30 | #include "logf.h" | ||
30 | 31 | ||
31 | #ifdef BUTTON_DEBUG | 32 | #ifdef BUTTON_DEBUG |
32 | #include "lcd-target.h" | 33 | #include "lcd-target.h" |
@@ -36,22 +37,22 @@ | |||
36 | 37 | ||
37 | #ifndef ZEN_VISION | 38 | #ifndef ZEN_VISION |
38 | /* Creative Zen Vision:M */ | 39 | /* Creative Zen Vision:M */ |
39 | #define BTN_LEFT 0x5F00 | 40 | #define BTN_LEFT 0xAF00 |
40 | #define BTN_RIGHT 0x4F00 | 41 | #define BTN_RIGHT 0xA700 |
41 | #define BTN_BACK 0xBF00 | 42 | #define BTN_BACK 0xDF00 |
42 | #define BTN_CUSTOM 0x8F00 | 43 | #define BTN_CUSTOM 0xC700 |
43 | #define BTN_PLAY 0x2F00 | 44 | #define BTN_PLAY 0x9700 |
44 | #define BTN_POWER 0x0F00 | 45 | #define BTN_POWER 0x8700 |
45 | #define BTN_MENU 0x9F00 | 46 | #define BTN_MENU 0xCF00 |
46 | #define BTN_HOLD 0x9F06 | 47 | #define BTN_HOLD 0xCF07 |
47 | #define BTN_UNHOLD 0xAF06 | 48 | #define BTN_UNHOLD 0xD707 |
48 | 49 | ||
49 | #define BTN_REL 1 | 50 | #define BTN_REL 1 |
50 | 51 | ||
51 | #define BTN_TOUCHPAD_PRESS 0x1F00 | 52 | #define BTN_TOUCHPAD_PRESS 0x8F00 |
52 | #define BTN_TOUCHPAD_SCROLL_DOWN 0x0F03 | 53 | #define BTN_TOUCHPAD_SCROLL_DOWN 0x0F03 |
53 | #define BTN_TOUCHPAD_CORNER_DOWN 0xAF00 | 54 | #define BTN_TOUCHPAD_CORNER_DOWN 0xD700 |
54 | #define BTN_TOUCHPAD_CORNER_UP 0x3F00 | 55 | #define BTN_TOUCHPAD_CORNER_UP 0x9F00 |
55 | #define BTN_TOUCHPAD_SCROLL_UP 0x0F04 | 56 | #define BTN_TOUCHPAD_SCROLL_UP 0x0F04 |
56 | 57 | ||
57 | #define HEADPHONE_PLUGIN_A 0x5707 | 58 | #define HEADPHONE_PLUGIN_A 0x5707 |
@@ -63,8 +64,8 @@ | |||
63 | #define DOCK_UNPLUG 0xDF06 | 64 | #define DOCK_UNPLUG 0xDF06 |
64 | #define DOCK_USB_INSERT 0x2F06 | 65 | #define DOCK_USB_INSERT 0x2F06 |
65 | #define DOCK_USB_UNPLUG 0x3F06 | 66 | #define DOCK_USB_UNPLUG 0x3F06 |
66 | #define DOCK_POWER_INSERT 0x2707 | 67 | #define DOCK_POWER_INSERT 0x1707 |
67 | #define DOCK_POWER_UNPLUG 0x2F07 | 68 | #define DOCK_POWER_UNPLUG 0x1F07 |
68 | 69 | ||
69 | #else | 70 | #else |
70 | /* Creative Zen Vision */ | 71 | /* Creative Zen Vision */ |
@@ -272,6 +273,8 @@ void GIO0(void) | |||
272 | lcd_update(); | 273 | lcd_update(); |
273 | sw = !sw; | 274 | sw = !sw; |
274 | #endif | 275 | #endif |
276 | logf("PIC: 0x%x", (unsigned int)((msg[3] << 24) | | ||
277 | (msg[2] << 16) | (msg[1] << 8) | msg[0])); | ||
275 | } | 278 | } |
276 | 279 | ||
277 | static void send_command_to_pic(const unsigned char in, unsigned char* out, | 280 | static void send_command_to_pic(const unsigned char in, unsigned char* out, |
@@ -335,7 +338,8 @@ bool button_usb_connected(void) | |||
335 | { | 338 | { |
336 | return (bool)(nonbtn & NONBUTTON_USB); | 339 | return (bool)(nonbtn & NONBUTTON_USB); |
337 | } | 340 | } |
338 | 341 | ||
342 | #ifndef BOOTLOADER | ||
339 | int pic_dbg_num_items(void) | 343 | int pic_dbg_num_items(void) |
340 | { | 344 | { |
341 | return 13; | 345 | return 13; |
@@ -376,3 +380,4 @@ char* pic_dbg_item(int selected_item, void *data, char *buffer, size_t buffer_le | |||
376 | } | 380 | } |
377 | return NULL; | 381 | return NULL; |
378 | } | 382 | } |
383 | #endif | ||
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c index 9b362f003c..d3f7789ab0 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c | |||
@@ -37,7 +37,7 @@ bool usb_drv_connected(void) | |||
37 | 37 | ||
38 | int usb_detect(void) | 38 | int usb_detect(void) |
39 | { | 39 | { |
40 | if(button_usb_connected()) | 40 | if(usb_drv_connected()) |
41 | return USB_INSERTED; | 41 | return USB_INSERTED; |
42 | else | 42 | else |
43 | return USB_EXTRACTED; | 43 | return USB_EXTRACTED; |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h index 260ddad7cf..6b56d8c5c0 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h +++ b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h | |||
@@ -65,11 +65,11 @@ | |||
65 | b = value >> 16; | 65 | b = value >> 16; |
66 | 66 | ||
67 | 67 | ||
68 | #define ZVM_SPECIFIC asm volatile( \ | 68 | /*#define ZVM_SPECIFIC asm volatile( \ |
69 | "LDR R12, =0x50FFC000\n" \ | 69 | "LDR R12, =0x50FFC000\n" \ |
70 | "LDRH R12, [R12]\n" \ | 70 | "LDRH R12, [R12]\n" \ |
71 | : : : "r12") | 71 | : : : "r12");*/ |
72 | //#define ZVM_SPECIFIC | 72 | #define ZVM_SPECIFIC |
73 | 73 | ||
74 | #define USE_IRAM | 74 | #define USE_IRAM |
75 | 75 | ||
diff --git a/firmware/target/arm/tms320dm320/crt0.S b/firmware/target/arm/tms320dm320/crt0.S index c1ccd5128b..ffbe7e5d31 100755 --- a/firmware/target/arm/tms320dm320/crt0.S +++ b/firmware/target/arm/tms320dm320/crt0.S | |||
@@ -235,7 +235,7 @@ data_abort_handler: | |||
235 | mov r1, #2 | 235 | mov r1, #2 |
236 | b UIE | 236 | b UIE |
237 | 237 | ||
238 | #if defined(STUB) || defined(BOOTLOADER) | 238 | #ifdef STUB |
239 | UIE: | 239 | UIE: |
240 | b UIE | 240 | b UIE |
241 | #endif | 241 | #endif |
diff --git a/firmware/target/arm/tms320dm320/i2c-dm320.c b/firmware/target/arm/tms320dm320/i2c-dm320.c index e8098e663b..026238461b 100755 --- a/firmware/target/arm/tms320dm320/i2c-dm320.c +++ b/firmware/target/arm/tms320dm320/i2c-dm320.c | |||
@@ -146,7 +146,7 @@ int i2c_read(unsigned short address, unsigned char* buf, int count) | |||
146 | 146 | ||
147 | void i2c_init(void) | 147 | void i2c_init(void) |
148 | { | 148 | { |
149 | #if 0 //TODO: mimic OF I2C clock settings; currently this is done by the bootloader | 149 | #ifdef CREATIVE_ZVx //TODO: mimic OF I2C clock settings; currently this is done by the bootloader |
150 | IO_CLK_MOD2 &= ~CLK_MOD2_I2C; // turn I²C clock off (just to be sure) | 150 | IO_CLK_MOD2 &= ~CLK_MOD2_I2C; // turn I²C clock off (just to be sure) |
151 | IO_CLK_LPCTL1 &= ~1; // set Powerdown mode to off | 151 | IO_CLK_LPCTL1 &= ~1; // set Powerdown mode to off |
152 | IO_CLK_SEL0 &= ~0x800; // set I²C clock to PLLA | 152 | IO_CLK_SEL0 &= ~0x800; // set I²C clock to PLLA |