mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
USB related Cosmetics, whitespace and readability fixes (FS#10147 by Tomer Shalev)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20737 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
069191d9d4
commit
00b407b04f
6 changed files with 139 additions and 158 deletions
|
@ -95,8 +95,7 @@ enum {
|
||||||
USB_DRIVER_CHARGING_ONLY,
|
USB_DRIVER_CHARGING_ONLY,
|
||||||
USB_NUM_DRIVERS
|
USB_NUM_DRIVERS
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
#ifdef HAVE_USBSTACK
|
|
||||||
struct usb_transfer_completion_event_data
|
struct usb_transfer_completion_event_data
|
||||||
{
|
{
|
||||||
unsigned char endpoint;
|
unsigned char endpoint;
|
||||||
|
|
|
@ -46,7 +46,6 @@ static struct usb_interface_descriptor __attribute__((aligned(2)))
|
||||||
.iInterface = 0
|
.iInterface = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int usb_interface;
|
static int usb_interface;
|
||||||
|
|
||||||
int usb_charging_only_request_endpoints(struct usb_class_driver *drv)
|
int usb_charging_only_request_endpoints(struct usb_class_driver *drv)
|
||||||
|
|
|
@ -100,7 +100,6 @@ static struct usb_config_descriptor __attribute__((aligned(2)))
|
||||||
.bMaxPower = (USB_MAX_CURRENT+1) / 2, /* In 2mA units */
|
.bMaxPower = (USB_MAX_CURRENT+1) / 2, /* In 2mA units */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const struct usb_qualifier_descriptor __attribute__((aligned(2)))
|
static const struct usb_qualifier_descriptor __attribute__((aligned(2)))
|
||||||
qualifier_descriptor =
|
qualifier_descriptor =
|
||||||
{
|
{
|
||||||
|
@ -242,7 +241,6 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req);
|
||||||
|
|
||||||
static unsigned char response_data[256] USB_DEVBSS_ATTR;
|
static unsigned char response_data[256] USB_DEVBSS_ATTR;
|
||||||
|
|
||||||
|
|
||||||
static short hex[16] = {'0','1','2','3','4','5','6','7',
|
static short hex[16] = {'0','1','2','3','4','5','6','7',
|
||||||
'8','9','A','B','C','D','E','F'};
|
'8','9','A','B','C','D','E','F'};
|
||||||
#ifdef IPOD_ARCH
|
#ifdef IPOD_ARCH
|
||||||
|
@ -357,15 +355,15 @@ void usb_core_exit(void)
|
||||||
for(i=0;i<USB_NUM_DRIVERS;i++) {
|
for(i=0;i<USB_NUM_DRIVERS;i++) {
|
||||||
if(drivers[i].enabled && drivers[i].disconnect != NULL)
|
if(drivers[i].enabled && drivers[i].disconnect != NULL)
|
||||||
{
|
{
|
||||||
drivers[i].disconnect ();
|
drivers[i].disconnect();
|
||||||
drivers[i].enabled = false;
|
drivers[i].enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
usb_drv_exit();
|
usb_drv_exit();
|
||||||
}
|
|
||||||
initialized = false;
|
initialized = false;
|
||||||
|
}
|
||||||
usb_state = DEFAULT;
|
usb_state = DEFAULT;
|
||||||
logf("usb_core_exit() finished");
|
logf("usb_core_exit() finished");
|
||||||
}
|
}
|
||||||
|
@ -373,6 +371,7 @@ void usb_core_exit(void)
|
||||||
void usb_core_handle_transfer_completion(
|
void usb_core_handle_transfer_completion(
|
||||||
struct usb_transfer_completion_event_data* event)
|
struct usb_transfer_completion_event_data* event)
|
||||||
{
|
{
|
||||||
|
completion_handler_t handler;
|
||||||
int ep = event->endpoint;
|
int ep = event->endpoint;
|
||||||
|
|
||||||
switch(ep) {
|
switch(ep) {
|
||||||
|
@ -382,9 +381,9 @@ void usb_core_handle_transfer_completion(
|
||||||
(struct usb_ctrlrequest*)event->data);
|
(struct usb_ctrlrequest*)event->data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(ep_data[ep].completion_handler[event->dir>>7] != NULL)
|
handler = ep_data[ep].completion_handler[event->dir>>7];
|
||||||
ep_data[ep].completion_handler[event->dir>>7](ep,event->dir,
|
if(handler != NULL)
|
||||||
event->status,event->length);
|
handler(ep,event->dir,event->status,event->length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,8 +402,7 @@ bool usb_core_any_exclusive_storage(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<USB_NUM_DRIVERS;i++) {
|
for(i=0;i<USB_NUM_DRIVERS;i++) {
|
||||||
if(drivers[i].enabled &&
|
if(drivers[i].enabled && drivers[i].needs_exclusive_storage)
|
||||||
drivers[i].needs_exclusive_storage)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -418,8 +416,7 @@ void usb_core_hotswap_event(int volume,bool inserted)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<USB_NUM_DRIVERS;i++) {
|
for(i=0;i<USB_NUM_DRIVERS;i++) {
|
||||||
if(drivers[i].enabled &&
|
if(drivers[i].enabled && drivers[i].notify_hotswap!=NULL)
|
||||||
drivers[i].notify_hotswap!=NULL)
|
|
||||||
{
|
{
|
||||||
drivers[i].notify_hotswap(volume,inserted);
|
drivers[i].notify_hotswap(volume,inserted);
|
||||||
}
|
}
|
||||||
|
@ -481,7 +478,7 @@ static void allocate_interfaces_and_endpoints(void)
|
||||||
usb_drv_release_endpoint(i | USB_DIR_IN);
|
usb_drv_release_endpoint(i | USB_DIR_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i < USB_NUM_DRIVERS; i++) {
|
for(i=0;i<USB_NUM_DRIVERS;i++) {
|
||||||
if(drivers[i].enabled) {
|
if(drivers[i].enabled) {
|
||||||
drivers[i].first_interface = interface;
|
drivers[i].first_interface = interface;
|
||||||
|
|
||||||
|
@ -762,19 +759,23 @@ void usb_core_bus_reset(void)
|
||||||
/* called by usb_drv_transfer_completed() */
|
/* called by usb_drv_transfer_completed() */
|
||||||
void usb_core_transfer_complete(int endpoint, int dir, int status,int length)
|
void usb_core_transfer_complete(int endpoint, int dir, int status,int length)
|
||||||
{
|
{
|
||||||
|
struct usb_transfer_completion_event_data *completion_event;
|
||||||
|
|
||||||
switch (endpoint) {
|
switch (endpoint) {
|
||||||
case EP_CONTROL:
|
case EP_CONTROL:
|
||||||
/* already handled */
|
/* already handled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ep_data[endpoint].completion_event.endpoint=endpoint;
|
completion_event = &ep_data[endpoint].completion_event;
|
||||||
ep_data[endpoint].completion_event.dir=dir;
|
|
||||||
ep_data[endpoint].completion_event.data=0;
|
completion_event->endpoint=endpoint;
|
||||||
ep_data[endpoint].completion_event.status=status;
|
completion_event->dir=dir;
|
||||||
ep_data[endpoint].completion_event.length=length;
|
completion_event->data=0;
|
||||||
|
completion_event->status=status;
|
||||||
|
completion_event->length=length;
|
||||||
/* All other endoints. Let the thread deal with it */
|
/* All other endoints. Let the thread deal with it */
|
||||||
usb_signal_transfer_completion(&ep_data[endpoint].completion_event);
|
usb_signal_transfer_completion(completion_event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,18 +783,21 @@ void usb_core_transfer_complete(int endpoint, int dir, int status,int length)
|
||||||
/* called by usb_drv_int() */
|
/* called by usb_drv_int() */
|
||||||
void usb_core_control_request(struct usb_ctrlrequest* req)
|
void usb_core_control_request(struct usb_ctrlrequest* req)
|
||||||
{
|
{
|
||||||
ep_data[0].completion_event.endpoint=0;
|
struct usb_transfer_completion_event_data *completion_event =
|
||||||
ep_data[0].completion_event.dir=0;
|
&ep_data[0].completion_event;
|
||||||
ep_data[0].completion_event.data=(void *)req;
|
|
||||||
ep_data[0].completion_event.status=0;
|
completion_event->endpoint=0;
|
||||||
ep_data[0].completion_event.length=0;
|
completion_event->dir=0;
|
||||||
|
completion_event->data=(void *)req;
|
||||||
|
completion_event->status=0;
|
||||||
|
completion_event->length=0;
|
||||||
logf("ctrl received %ld",current_tick);
|
logf("ctrl received %ld",current_tick);
|
||||||
usb_signal_transfer_completion(&ep_data[0].completion_event);
|
usb_signal_transfer_completion(completion_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_core_ack_control(struct usb_ctrlrequest* req)
|
int usb_core_ack_control(struct usb_ctrlrequest* req)
|
||||||
{
|
{
|
||||||
if (req->bRequestType & 0x80)
|
if (req->bRequestType & USB_DIR_IN)
|
||||||
return usb_drv_recv(EP_CONTROL, NULL, 0);
|
return usb_drv_recv(EP_CONTROL, NULL, 0);
|
||||||
else
|
else
|
||||||
return usb_drv_send(EP_CONTROL, NULL, 0);
|
return usb_drv_send(EP_CONTROL, NULL, 0);
|
||||||
|
@ -802,13 +806,6 @@ int usb_core_ack_control(struct usb_ctrlrequest* req)
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_POWER
|
||||||
unsigned short usb_allowed_current()
|
unsigned short usb_allowed_current()
|
||||||
{
|
{
|
||||||
if (usb_state == CONFIGURED)
|
return (usb_state == CONFIGURED) ? MAX(USB_MAX_CURRENT, 100) : 100;
|
||||||
{
|
|
||||||
return MAX(USB_MAX_CURRENT, 100);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,7 +46,8 @@ static struct usb_interface_descriptor __attribute__((aligned(2)))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static struct usb_endpoint_descriptor __attribute__((aligned(2))) endpoint_descriptor =
|
static struct usb_endpoint_descriptor __attribute__((aligned(2)))
|
||||||
|
endpoint_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_endpoint_descriptor),
|
.bLength = sizeof(struct usb_endpoint_descriptor),
|
||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
|
@ -77,12 +78,10 @@ static int usb_interface;
|
||||||
int usb_serial_request_endpoints(struct usb_class_driver *drv)
|
int usb_serial_request_endpoints(struct usb_class_driver *drv)
|
||||||
{
|
{
|
||||||
ep_in = usb_core_request_endpoint(USB_DIR_IN, drv);
|
ep_in = usb_core_request_endpoint(USB_DIR_IN, drv);
|
||||||
|
|
||||||
if (ep_in < 0)
|
if (ep_in < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ep_out = usb_core_request_endpoint(USB_DIR_OUT, drv);
|
ep_out = usb_core_request_endpoint(USB_DIR_OUT, drv);
|
||||||
|
|
||||||
if (ep_out < 0) {
|
if (ep_out < 0) {
|
||||||
usb_core_release_endpoint(ep_in);
|
usb_core_release_endpoint(ep_in);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -97,8 +96,7 @@ int usb_serial_set_first_interface(int interface)
|
||||||
return interface + 1;
|
return interface + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int usb_serial_get_config_descriptor(unsigned char *dest, int max_packet_size)
|
||||||
int usb_serial_get_config_descriptor(unsigned char *dest,int max_packet_size)
|
|
||||||
{
|
{
|
||||||
unsigned char *orig_dest = dest;
|
unsigned char *orig_dest = dest;
|
||||||
|
|
||||||
|
@ -245,12 +243,9 @@ void usb_serial_transfer_complete(int ep,int dir, int status, int length)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buffer_length>0)
|
if(buffer_length>0)
|
||||||
{
|
|
||||||
sendout();
|
sendout();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /*USB_SERIAL*/
|
#endif /*USB_SERIAL*/
|
||||||
|
|
|
@ -314,7 +314,7 @@ void usb_storage_try_release_storage(void)
|
||||||
bool canrelease=true;
|
bool canrelease=true;
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<NUM_VOLUMES;i++) {
|
for(i=0;i<NUM_VOLUMES;i++) {
|
||||||
if(ejected[i]==false && locked[i]==true){
|
if(ejected[i]==false && locked[i]==true) {
|
||||||
canrelease=false;
|
canrelease=false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -351,12 +351,12 @@ int usb_storage_request_endpoints(struct usb_class_driver *drv)
|
||||||
{
|
{
|
||||||
ep_in = usb_core_request_endpoint(USB_DIR_IN, drv);
|
ep_in = usb_core_request_endpoint(USB_DIR_IN, drv);
|
||||||
|
|
||||||
if (ep_in < 0)
|
if(ep_in<0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ep_out = usb_core_request_endpoint(USB_DIR_OUT, drv);
|
ep_out = usb_core_request_endpoint(USB_DIR_OUT, drv);
|
||||||
|
|
||||||
if (ep_out < 0) {
|
if(ep_out<0) {
|
||||||
usb_core_release_endpoint(ep_in);
|
usb_core_release_endpoint(ep_in);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ void usb_storage_init_connection(void)
|
||||||
|
|
||||||
audio_buffer = audio_get_buffer(false,&bufsize);
|
audio_buffer = audio_get_buffer(false,&bufsize);
|
||||||
tb.transfer_buffer =
|
tb.transfer_buffer =
|
||||||
(void *)UNCACHED_ADDR((unsigned int)(audio_buffer + 31) & 0xffffffe0);
|
(void *)UNCACHED_ADDR((unsigned int)(audio_buffer+31) & 0xffffffe0);
|
||||||
cpucache_invalidate();
|
cpucache_invalidate();
|
||||||
#ifdef USB_USE_RAMDISK
|
#ifdef USB_USE_RAMDISK
|
||||||
ramdisk_buffer = tb.transfer_buffer + BUFFER_SIZE*2;
|
ramdisk_buffer = tb.transfer_buffer + BUFFER_SIZE*2;
|
||||||
|
@ -452,7 +452,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
|
||||||
}
|
}
|
||||||
logf("scsi write %d %d", cur_cmd.sector, cur_cmd.count);
|
logf("scsi write %d %d", cur_cmd.sector, cur_cmd.count);
|
||||||
if(status==0) {
|
if(status==0) {
|
||||||
if((unsigned int)length!=(SECTOR_SIZE*cur_cmd.count)
|
if((unsigned int)length!=(SECTOR_SIZE* cur_cmd.count)
|
||||||
&& (unsigned int)length!=BUFFER_SIZE) {
|
&& (unsigned int)length!=BUFFER_SIZE) {
|
||||||
logf("unexpected length :%d",length);
|
logf("unexpected length :%d",length);
|
||||||
}
|
}
|
||||||
|
@ -478,8 +478,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
|
||||||
#else
|
#else
|
||||||
int result = storage_write_sectors(cur_cmd.lun,
|
int result = storage_write_sectors(cur_cmd.lun,
|
||||||
cur_cmd.sector,
|
cur_cmd.sector,
|
||||||
MIN(BUFFER_SIZE/SECTOR_SIZE,
|
MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
|
||||||
cur_cmd.count),
|
|
||||||
cur_cmd.data[cur_cmd.data_select]);
|
cur_cmd.data[cur_cmd.data_select]);
|
||||||
if(result != 0) {
|
if(result != 0) {
|
||||||
send_csw(UMS_STATUS_FAIL);
|
send_csw(UMS_STATUS_FAIL);
|
||||||
|
@ -489,7 +488,6 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(next_count==0) {
|
if(next_count==0) {
|
||||||
send_csw(UMS_STATUS_GOOD);
|
send_csw(UMS_STATUS_GOOD);
|
||||||
}
|
}
|
||||||
|
@ -499,7 +497,6 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
|
||||||
|
|
||||||
cur_cmd.sector = next_sector;
|
cur_cmd.sector = next_sector;
|
||||||
cur_cmd.count = next_count;
|
cur_cmd.count = next_count;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logf("Transfer failed %X",status);
|
logf("Transfer failed %X",status);
|
||||||
|
@ -516,7 +513,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
|
||||||
logf("IN received in WAITING_FOR_COMMAND");
|
logf("IN received in WAITING_FOR_COMMAND");
|
||||||
}
|
}
|
||||||
//logf("command received");
|
//logf("command received");
|
||||||
if(letoh32(cbw->signature) == CBW_SIGNATURE){
|
if(letoh32(cbw->signature) == CBW_SIGNATURE) {
|
||||||
handle_scsi(cbw);
|
handle_scsi(cbw);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -622,7 +619,6 @@ bool usb_storage_control_request(struct usb_ctrlrequest* req, unsigned char* des
|
||||||
usb_drv_reset_endpoint(ep_in, false);
|
usb_drv_reset_endpoint(ep_in, false);
|
||||||
usb_drv_reset_endpoint(ep_out, true);
|
usb_drv_reset_endpoint(ep_out, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
usb_drv_send(EP_CONTROL, NULL, 0); /* ack */
|
usb_drv_send(EP_CONTROL, NULL, 0); /* ack */
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
@ -650,7 +646,7 @@ static void send_and_read_next(void)
|
||||||
cur_cmd.sector+=(BUFFER_SIZE/SECTOR_SIZE);
|
cur_cmd.sector+=(BUFFER_SIZE/SECTOR_SIZE);
|
||||||
cur_cmd.count-=MIN(cur_cmd.count,BUFFER_SIZE/SECTOR_SIZE);
|
cur_cmd.count-=MIN(cur_cmd.count,BUFFER_SIZE/SECTOR_SIZE);
|
||||||
|
|
||||||
if(cur_cmd.count!=0){
|
if(cur_cmd.count!=0) {
|
||||||
/* already read the next bit, so we can send it out immediately when the
|
/* already read the next bit, so we can send it out immediately when the
|
||||||
* current transfer completes. */
|
* current transfer completes. */
|
||||||
#ifdef USB_USE_RAMDISK
|
#ifdef USB_USE_RAMDISK
|
||||||
|
@ -660,8 +656,7 @@ static void send_and_read_next(void)
|
||||||
#else
|
#else
|
||||||
cur_cmd.last_result = storage_read_sectors(cur_cmd.lun,
|
cur_cmd.last_result = storage_read_sectors(cur_cmd.lun,
|
||||||
cur_cmd.sector,
|
cur_cmd.sector,
|
||||||
MIN(BUFFER_SIZE/SECTOR_SIZE,
|
MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
|
||||||
cur_cmd.count),
|
|
||||||
cur_cmd.data[cur_cmd.data_select]);
|
cur_cmd.data[cur_cmd.data_select]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -781,7 +776,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCSI_MODE_SENSE_10: {
|
case SCSI_MODE_SENSE_10: {
|
||||||
if(! lun_present) {
|
if(!lun_present) {
|
||||||
send_command_failed_result();
|
send_command_failed_result();
|
||||||
cur_sense_data.sense_key=SENSE_NOT_READY;
|
cur_sense_data.sense_key=SENSE_NOT_READY;
|
||||||
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
||||||
|
@ -834,8 +829,9 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCSI_MODE_SENSE_6: {
|
case SCSI_MODE_SENSE_6: {
|
||||||
if(! lun_present) {
|
if(!lun_present) {
|
||||||
send_command_failed_result();
|
send_command_failed_result();
|
||||||
cur_sense_data.sense_key=SENSE_NOT_READY;
|
cur_sense_data.sense_key=SENSE_NOT_READY;
|
||||||
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
||||||
|
@ -856,7 +852,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
sizeof(struct mode_sense_bdesc_shortlba);
|
sizeof(struct mode_sense_bdesc_shortlba);
|
||||||
tb.ms_data_6->block_descriptor.density_code = 0;
|
tb.ms_data_6->block_descriptor.density_code = 0;
|
||||||
tb.ms_data_6->block_descriptor.reserved = 0;
|
tb.ms_data_6->block_descriptor.reserved = 0;
|
||||||
if(block_count/block_size_mult > 0xffffff){
|
if(block_count/block_size_mult > 0xffffff) {
|
||||||
tb.ms_data_6->block_descriptor.num_blocks[0] = 0xff;
|
tb.ms_data_6->block_descriptor.num_blocks[0] = 0xff;
|
||||||
tb.ms_data_6->block_descriptor.num_blocks[1] = 0xff;
|
tb.ms_data_6->block_descriptor.num_blocks[1] = 0xff;
|
||||||
tb.ms_data_6->block_descriptor.num_blocks[2] = 0xff;
|
tb.ms_data_6->block_descriptor.num_blocks[2] = 0xff;
|
||||||
|
@ -907,18 +903,17 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
|
|
||||||
case SCSI_ALLOW_MEDIUM_REMOVAL:
|
case SCSI_ALLOW_MEDIUM_REMOVAL:
|
||||||
logf("scsi allow_medium_removal %d",lun);
|
logf("scsi allow_medium_removal %d",lun);
|
||||||
if((cbw->command_block[4] & 0x03) == 0)
|
if((cbw->command_block[4] & 0x03) == 0) {
|
||||||
{
|
|
||||||
locked[lun]=false;
|
locked[lun]=false;
|
||||||
queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+0);
|
queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+0);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
locked[lun]=true;
|
locked[lun]=true;
|
||||||
queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+1);
|
queue_broadcast(SYS_USB_LUN_LOCKED, (lun<<16)+1);
|
||||||
}
|
}
|
||||||
send_csw(UMS_STATUS_GOOD);
|
send_csw(UMS_STATUS_GOOD);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCSI_READ_FORMAT_CAPACITY: {
|
case SCSI_READ_FORMAT_CAPACITY: {
|
||||||
logf("scsi read_format_capacity %d",lun);
|
logf("scsi read_format_capacity %d",lun);
|
||||||
if(lun_present) {
|
if(lun_present) {
|
||||||
|
@ -934,8 +929,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
send_command_result(tb.format_capacity_data,
|
send_command_result(tb.format_capacity_data,
|
||||||
MIN(sizeof(struct format_capacity), length));
|
MIN(sizeof(struct format_capacity), length));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
send_command_failed_result();
|
send_command_failed_result();
|
||||||
cur_sense_data.sense_key=SENSE_NOT_READY;
|
cur_sense_data.sense_key=SENSE_NOT_READY;
|
||||||
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
||||||
|
@ -943,6 +937,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCSI_READ_CAPACITY: {
|
case SCSI_READ_CAPACITY: {
|
||||||
logf("scsi read_capacity %d",lun);
|
logf("scsi read_capacity %d",lun);
|
||||||
|
|
||||||
|
@ -956,8 +951,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
send_command_result(tb.capacity_data,
|
send_command_result(tb.capacity_data,
|
||||||
MIN(sizeof(struct capacity), length));
|
MIN(sizeof(struct capacity), length));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
send_command_failed_result();
|
send_command_failed_result();
|
||||||
cur_sense_data.sense_key=SENSE_NOT_READY;
|
cur_sense_data.sense_key=SENSE_NOT_READY;
|
||||||
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
||||||
|
@ -968,7 +962,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
|
|
||||||
case SCSI_READ_10:
|
case SCSI_READ_10:
|
||||||
logf("scsi read10 %d",lun);
|
logf("scsi read10 %d",lun);
|
||||||
if(! lun_present) {
|
if(!lun_present) {
|
||||||
send_command_failed_result();
|
send_command_failed_result();
|
||||||
cur_sense_data.sense_key=SENSE_NOT_READY;
|
cur_sense_data.sense_key=SENSE_NOT_READY;
|
||||||
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
||||||
|
@ -1000,16 +994,15 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
#ifdef USB_USE_RAMDISK
|
#ifdef USB_USE_RAMDISK
|
||||||
memcpy(cur_cmd.data[cur_cmd.data_select],
|
memcpy(cur_cmd.data[cur_cmd.data_select],
|
||||||
ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE,
|
ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE,
|
||||||
MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE);
|
MIN(BUFFER_SIZE/SECTOR_SIZE,cur_cmd.count)*SECTOR_SIZE);
|
||||||
#else
|
#else
|
||||||
cur_cmd.last_result = storage_read_sectors(cur_cmd.lun,
|
cur_cmd.last_result = storage_read_sectors(cur_cmd.lun,
|
||||||
cur_cmd.sector,
|
cur_cmd.sector,
|
||||||
MIN(BUFFER_SIZE/SECTOR_SIZE,
|
MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
|
||||||
cur_cmd.count),
|
|
||||||
cur_cmd.data[cur_cmd.data_select]);
|
cur_cmd.data[cur_cmd.data_select]);
|
||||||
|
|
||||||
#ifdef TOSHIBA_GIGABEAT_S
|
#ifdef TOSHIBA_GIGABEAT_S
|
||||||
if (cur_cmd.sector == 0) {
|
if(cur_cmd.sector == 0) {
|
||||||
fix_mbr(cur_cmd.data[cur_cmd.data_select]);
|
fix_mbr(cur_cmd.data[cur_cmd.data_select]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1020,7 +1013,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
|
|
||||||
case SCSI_WRITE_10:
|
case SCSI_WRITE_10:
|
||||||
logf("scsi write10 %d",lun);
|
logf("scsi write10 %d",lun);
|
||||||
if(! lun_present) {
|
if(!lun_present) {
|
||||||
send_csw(UMS_STATUS_FAIL);
|
send_csw(UMS_STATUS_FAIL);
|
||||||
cur_sense_data.sense_key=SENSE_NOT_READY;
|
cur_sense_data.sense_key=SENSE_NOT_READY;
|
||||||
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT;
|
||||||
|
@ -1049,10 +1042,8 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
receive_block_data(cur_cmd.data[0],
|
receive_block_data(cur_cmd.data[0],
|
||||||
MIN(BUFFER_SIZE,
|
MIN(BUFFER_SIZE, cur_cmd.count*SECTOR_SIZE));
|
||||||
cur_cmd.count*SECTOR_SIZE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1127,8 +1118,8 @@ static void copy_padded(char *dest, char *src, int len)
|
||||||
/* build SCSI INQUIRY */
|
/* build SCSI INQUIRY */
|
||||||
static void fill_inquiry(IF_MV_NONVOID(int lun))
|
static void fill_inquiry(IF_MV_NONVOID(int lun))
|
||||||
{
|
{
|
||||||
memset(tb.inquiry, 0, sizeof(struct inquiry_data));
|
|
||||||
struct storage_info info;
|
struct storage_info info;
|
||||||
|
memset(tb.inquiry, 0, sizeof(struct inquiry_data));
|
||||||
storage_get_info(lun,&info);
|
storage_get_info(lun,&info);
|
||||||
copy_padded(tb.inquiry->VendorId,info.vendor,sizeof(tb.inquiry->VendorId));
|
copy_padded(tb.inquiry->VendorId,info.vendor,sizeof(tb.inquiry->VendorId));
|
||||||
copy_padded(tb.inquiry->ProductId,info.product,sizeof(tb.inquiry->ProductId));
|
copy_padded(tb.inquiry->ProductId,info.product,sizeof(tb.inquiry->ProductId));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue