diff options
-rw-r--r-- | apps/debug_menu.c | 12 | ||||
-rw-r--r-- | firmware/export/usb.h | 1 | ||||
-rw-r--r-- | firmware/usb.c | 21 | ||||
-rw-r--r-- | firmware/usbstack/usb_storage.c | 30 | ||||
-rw-r--r-- | firmware/usbstack/usb_storage.h | 2 |
5 files changed, 24 insertions, 42 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index e669a6a123..b944ff3aa1 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -115,9 +115,6 @@ | |||
115 | #if defined(HAVE_USBSTACK) | 115 | #if defined(HAVE_USBSTACK) |
116 | #include "usb_core.h" | 116 | #include "usb_core.h" |
117 | #endif | 117 | #endif |
118 | #ifdef USB_STORAGE | ||
119 | #include "usbstack/usb_storage.h" | ||
120 | #endif | ||
121 | 118 | ||
122 | /*---------------------------------------------------*/ | 119 | /*---------------------------------------------------*/ |
123 | /* SPECIAL DEBUG STUFF */ | 120 | /* SPECIAL DEBUG STUFF */ |
@@ -2584,15 +2581,6 @@ static bool logf_usb_serial(void) | |||
2584 | } | 2581 | } |
2585 | #endif | 2582 | #endif |
2586 | 2583 | ||
2587 | #if 0 && defined(HAVE_USBSTACK) && defined(USB_STORAGE) | ||
2588 | static bool usb_reconnect(void) | ||
2589 | { | ||
2590 | splash(HZ, "Reconnect mass storage"); | ||
2591 | usb_storage_reconnect(); | ||
2592 | return false; | ||
2593 | } | ||
2594 | #endif | ||
2595 | |||
2596 | #if CONFIG_USBOTG == USBOTG_ISP1583 | 2584 | #if CONFIG_USBOTG == USBOTG_ISP1583 |
2597 | extern int dbg_usb_num_items(void); | 2585 | extern int dbg_usb_num_items(void); |
2598 | extern char* dbg_usb_item(int selected_item, void *data, char *buffer, size_t buffer_len); | 2586 | extern char* dbg_usb_item(int selected_item, void *data, char *buffer, size_t buffer_len); |
diff --git a/firmware/export/usb.h b/firmware/export/usb.h index 90713594a5..ecbec3a914 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h | |||
@@ -132,6 +132,7 @@ void usb_signal_transfer_completion(struct usb_transfer_completion_event_data* e | |||
132 | bool usb_driver_enabled(int driver); | 132 | bool usb_driver_enabled(int driver); |
133 | bool usb_exclusive_storage(void); /* storage is available for usb */ | 133 | bool usb_exclusive_storage(void); /* storage is available for usb */ |
134 | #endif | 134 | #endif |
135 | int usb_release_exclusive_storage(void); | ||
135 | 136 | ||
136 | #ifdef USB_FIREWIRE_HANDLING | 137 | #ifdef USB_FIREWIRE_HANDLING |
137 | bool firewire_detect(void); | 138 | bool firewire_detect(void); |
diff --git a/firmware/usb.c b/firmware/usb.c index 2ac56a9c15..fa7eef40d2 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -361,14 +361,9 @@ static void usb_thread(void) | |||
361 | break; | 361 | break; |
362 | } | 362 | } |
363 | 363 | ||
364 | exclusive_storage_access = false; | ||
365 | #endif /* HAVE_USBSTACK */ | 364 | #endif /* HAVE_USBSTACK */ |
365 | num_acks_to_expect = usb_release_exclusive_storage(); | ||
366 | 366 | ||
367 | /* Tell all threads that we are back in business */ | ||
368 | num_acks_to_expect = | ||
369 | queue_broadcast(SYS_USB_DISCONNECTED, 0) - 1; | ||
370 | DEBUGF("USB extracted. Waiting for ack from %d threads...\n", | ||
371 | num_acks_to_expect); | ||
372 | break; | 367 | break; |
373 | 368 | ||
374 | case SYS_USB_DISCONNECTED_ACK: | 369 | case SYS_USB_DISCONNECTED_ACK: |
@@ -657,6 +652,20 @@ bool usb_exclusive_storage(void) | |||
657 | } | 652 | } |
658 | #endif | 653 | #endif |
659 | 654 | ||
655 | int usb_release_exclusive_storage(void) | ||
656 | { | ||
657 | int num_acks_to_expect; | ||
658 | #ifdef HAVE_USBSTACK | ||
659 | exclusive_storage_access = false; | ||
660 | #endif /* HAVE_USBSTACK */ | ||
661 | /* Tell all threads that we are back in business */ | ||
662 | num_acks_to_expect = | ||
663 | queue_broadcast(SYS_USB_DISCONNECTED, 0) - 1; | ||
664 | DEBUGF("USB extracted. Waiting for ack from %d threads...\n", | ||
665 | num_acks_to_expect); | ||
666 | return num_acks_to_expect; | ||
667 | } | ||
668 | |||
660 | #ifdef HAVE_USB_POWER | 669 | #ifdef HAVE_USB_POWER |
661 | bool usb_powered(void) | 670 | bool usb_powered(void) |
662 | { | 671 | { |
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index e769216a8d..ed9efd67c3 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c | |||
@@ -302,7 +302,6 @@ static bool check_disk_present(IF_MV_NONVOID(int volume)) | |||
302 | #endif | 302 | #endif |
303 | } | 303 | } |
304 | 304 | ||
305 | #if 0 | ||
306 | static void try_release_ata(void) | 305 | static void try_release_ata(void) |
307 | { | 306 | { |
308 | /* Check if there is a connected drive left. If not, | 307 | /* Check if there is a connected drive left. If not, |
@@ -317,10 +316,9 @@ static void try_release_ata(void) | |||
317 | } | 316 | } |
318 | if(canrelease) { | 317 | if(canrelease) { |
319 | logf("scsi release ata"); | 318 | logf("scsi release ata"); |
320 | usb_release_exclusive_ata(); | 319 | usb_release_exclusive_storage(); |
321 | } | 320 | } |
322 | } | 321 | } |
323 | #endif | ||
324 | 322 | ||
325 | #ifdef HAVE_HOTSWAP | 323 | #ifdef HAVE_HOTSWAP |
326 | void usb_storage_notify_hotswap(int volume,bool inserted) | 324 | void usb_storage_notify_hotswap(int volume,bool inserted) |
@@ -331,28 +329,14 @@ void usb_storage_notify_hotswap(int volume,bool inserted) | |||
331 | } | 329 | } |
332 | else { | 330 | else { |
333 | ejected[volume] = true; | 331 | ejected[volume] = true; |
332 | try_release_ata(); | ||
334 | } | 333 | } |
335 | } | 334 | } |
336 | #endif | 335 | #endif |
337 | 336 | ||
338 | void usb_storage_reconnect(void) | ||
339 | { | ||
340 | int i; | ||
341 | if(usb_core_driver_enabled(USB_DRIVER_MASS_STORAGE) | ||
342 | && usb_inserted()) { | ||
343 | for(i=0;i<NUM_VOLUMES;i++) | ||
344 | ejected[i] = !check_disk_present(IF_MV(i)); | ||
345 | logf("%s", __func__); | ||
346 | } | ||
347 | } | ||
348 | |||
349 | /* called by usb_core_init() */ | 337 | /* called by usb_core_init() */ |
350 | void usb_storage_init(void) | 338 | void usb_storage_init(void) |
351 | { | 339 | { |
352 | int i; | ||
353 | for(i=0;i<NUM_VOLUMES;i++) { | ||
354 | ejected[i] = !check_disk_present(IF_MV(i)); | ||
355 | } | ||
356 | logf("usb_storage_init done"); | 340 | logf("usb_storage_init done"); |
357 | } | 341 | } |
358 | 342 | ||
@@ -431,10 +415,10 @@ void usb_storage_init_connection(void) | |||
431 | #endif | 415 | #endif |
432 | usb_drv_recv(ep_out, tb.transfer_buffer, 1024); | 416 | usb_drv_recv(ep_out, tb.transfer_buffer, 1024); |
433 | 417 | ||
434 | int lun; | 418 | int i; |
435 | for(lun=0;lun<NUM_VOLUMES;lun++) | 419 | for(i=0;i<NUM_VOLUMES;i++) { |
436 | { | 420 | ejected[i] = !check_disk_present(IF_MV(i)); |
437 | queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+0); | 421 | queue_broadcast(SYS_USB_LUN_LOCKED, (i<<16)+0); |
438 | } | 422 | } |
439 | } | 423 | } |
440 | 424 | ||
@@ -691,6 +675,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
691 | #ifdef HAVE_HOTSWAP | 675 | #ifdef HAVE_HOTSWAP |
692 | if(storage_removable(lun) && !storage_present(lun)) { | 676 | if(storage_removable(lun) && !storage_present(lun)) { |
693 | ejected[lun] = true; | 677 | ejected[lun] = true; |
678 | try_release_ata(); | ||
694 | } | 679 | } |
695 | #endif | 680 | #endif |
696 | 681 | ||
@@ -893,6 +878,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
893 | { | 878 | { |
894 | logf("scsi eject"); | 879 | logf("scsi eject"); |
895 | ejected[lun]=true; | 880 | ejected[lun]=true; |
881 | try_release_ata(); | ||
896 | } | 882 | } |
897 | } | 883 | } |
898 | } | 884 | } |
diff --git a/firmware/usbstack/usb_storage.h b/firmware/usbstack/usb_storage.h index 8344419770..c76cb898bb 100644 --- a/firmware/usbstack/usb_storage.h +++ b/firmware/usbstack/usb_storage.h | |||
@@ -35,7 +35,5 @@ bool usb_storage_control_request(struct usb_ctrlrequest* req); | |||
35 | void usb_storage_notify_hotswap(int volume,bool inserted); | 35 | void usb_storage_notify_hotswap(int volume,bool inserted); |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | void usb_storage_reconnect(void); | ||
39 | |||
40 | #endif | 38 | #endif |
41 | 39 | ||