summaryrefslogtreecommitdiff
path: root/firmware/usbstack
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usbstack')
-rw-r--r--firmware/usbstack/usb_storage.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 9fae7fc354..b526d7bb6d 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -219,6 +219,7 @@ static void send_block_data(void *data,int size);
219static void receive_block_data(void *data,int size); 219static void receive_block_data(void *data,int size);
220static void identify2inquiry(int lun); 220static void identify2inquiry(int lun);
221static void send_and_read_next(void); 221static void send_and_read_next(void);
222static bool ejected[NUM_VOLUMES];
222 223
223static enum { 224static enum {
224 WAITING_FOR_COMMAND, 225 WAITING_FOR_COMMAND,
@@ -231,6 +232,9 @@ static enum {
231/* called by usb_code_init() */ 232/* called by usb_code_init() */
232void usb_storage_init(void) 233void usb_storage_init(void)
233{ 234{
235 int i;
236 for(i=0;i<NUM_VOLUMES;i++)
237 ejected[i]=false;
234 logf("usb_storage_init done"); 238 logf("usb_storage_init done");
235} 239}
236 240
@@ -473,6 +477,9 @@ static void handle_scsi(struct command_block_wrapper* cbw)
473 block_count = (identify[61] << 16 | identify[60]); 477 block_count = (identify[61] << 16 | identify[60]);
474#endif 478#endif
475 479
480 if(ejected[lun])
481 lun_present = false;
482
476#ifdef MAX_LOG_SECTOR_SIZE 483#ifdef MAX_LOG_SECTOR_SIZE
477 block_size_mult = disk_sector_multiplier; 484 block_size_mult = disk_sector_multiplier;
478#endif 485#endif
@@ -634,6 +641,14 @@ static void handle_scsi(struct command_block_wrapper* cbw)
634 641
635 case SCSI_START_STOP_UNIT: 642 case SCSI_START_STOP_UNIT:
636 logf("scsi start_stop unit %d",lun); 643 logf("scsi start_stop unit %d",lun);
644 if((cbw->command_block[4] & 0xf0) == 0) /* Process start and eject bits */
645 {
646 if((cbw->command_block[4] & 0x01) == 0 &&
647 (cbw->command_block[4] & 0x02) != 0) /* Stop and eject */
648 {
649 ejected[lun]=true;
650 }
651 }
637 send_csw(UMS_STATUS_GOOD); 652 send_csw(UMS_STATUS_GOOD);
638 break; 653 break;
639 654