MODULE_DESCRIPTION("Driver for Freecom USB/IDE adaptor");
MODULE_AUTHOR("David Brown <usb-storage@davidb.org>");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("USB_STORAGE");
usb_stor_dbg(us, "Read data Freecom! (c=%d)\n", count);
/* Issue the transfer command. */
result = usb_stor_bulk_transfer_buf (us, opipe, fxfr,
FCM_PACKET_LENGTH, NULL); if (result != USB_STOR_XFER_GOOD) {
usb_stor_dbg(us, "Freecom readdata transport error\n"); return USB_STOR_TRANSPORT_ERROR;
}
/* Now transfer all of our blocks. */
usb_stor_dbg(us, "Start of read\n");
result = usb_stor_bulk_srb(us, ipipe, srb);
usb_stor_dbg(us, "freecom_readdata done!\n");
if (result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_GOOD;
}
/* Send it out. */
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
/* *TheFreecomdevicewillonlyfailifthereissomethingwrongin *USBland.Itreturnsthestatusinitsownregisters,which *comebackinthebulkpipe.
*/ if (result != USB_STOR_XFER_GOOD) {
usb_stor_dbg(us, "freecom transport error\n"); return USB_STOR_TRANSPORT_ERROR;
}
/* *Therearetimeswecanoptimizeoutthisstatusread,butit *doesn'thurtustoalwaysdoitnow.
*/
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
usb_stor_dbg(us, "foo Status result %d %u\n", result, partial); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump(us, (void *)fst, partial));
/* *Thefirmwarewilltime-outcommandsafter20seconds.Somecommands *canlegitimatelytakelongerthanthis,soweuseadifferent *commandthatonlywaitsfortheinterruptandthensendsstatus, *withouthavingtosendanewATAPIcommandtothedevice. * *NOTE:Thereissomeindicationthatadatatransferafteratimeout *maynotwork,butthatisaconditionthatshouldneverhappen.
*/ while (fst->Status & FCM_STATUS_BUSY) {
usb_stor_dbg(us, "20 second USB/ATAPI bridge TIMEOUT occurred!\n");
usb_stor_dbg(us, "fst->Status is %x\n", fst->Status);
/* Get the status again */
fcb->Type = FCM_PACKET_STATUS;
fcb->Timeout = 0;
memset (fcb->Atapi, 0, sizeof(fcb->Atapi));
memset (fcb->Filler, 0, sizeof (fcb->Filler));
/* Send it out. */
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
/* *TheFreecomdevicewillonlyfailifthereissomething *wronginUSBland.Itreturnsthestatusinitsown *registers,whichcomebackinthebulkpipe.
*/ if (result != USB_STOR_XFER_GOOD) {
usb_stor_dbg(us, "freecom transport error\n"); return USB_STOR_TRANSPORT_ERROR;
}
/* get the data */
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
usb_stor_dbg(us, "bar Status result %d %u\n", result, partial); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump(us, (void *)fst, partial));
}
if (partial != 4) return USB_STOR_TRANSPORT_ERROR; if ((fst->Status & 1) != 0) {
usb_stor_dbg(us, "operation failed\n"); return USB_STOR_TRANSPORT_FAILED;
}
/* *Thedevicemightnothaveasmuchdataavailableaswe *requested.Ifyouaskformorethanthedevicehas,thisreads *andsuchwillhang.
*/
usb_stor_dbg(us, "Device indicates that it has %d bytes available\n",
le16_to_cpu(fst->Count));
usb_stor_dbg(us, "SCSI requested %d\n", scsi_bufflen(srb));
/* Find the length we desire to read. */ switch (srb->cmnd[0]) { case INQUIRY: case REQUEST_SENSE: /* 16 or 18 bytes? spec says 18, lots of devices only have 16 */ case MODE_SENSE: case MODE_SENSE_10:
length = le16_to_cpu(fst->Count); break; default:
length = scsi_bufflen(srb);
}
/* verify that this amount is legal */ if (length > scsi_bufflen(srb)) {
length = scsi_bufflen(srb);
usb_stor_dbg(us, "Truncating request to match buffer length: %d\n",
length);
}
switch (us->srb->sc_data_direction) { case DMA_FROM_DEVICE: /* catch bogus "read 0 length" case */ if (!length) break; /* *Makesurethatthestatusindicatesthatthedevice *wantsdataaswell.
*/ if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) {
usb_stor_dbg(us, "SCSI wants data, drive doesn't have any\n"); return USB_STOR_TRANSPORT_FAILED;
}
result = freecom_readdata (srb, us, ipipe, opipe, length); if (result != USB_STOR_TRANSPORT_GOOD) return result;
usb_stor_dbg(us, "Waiting for status\n");
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_PACKET_LENGTH, &partial);
US_DEBUG(pdump(us, (void *)fst, partial));
if (partial != 4 || result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; if ((fst->Status & ERR_STAT) != 0) {
usb_stor_dbg(us, "operation failed\n"); return USB_STOR_TRANSPORT_FAILED;
} if ((fst->Reason & 3) != 3) {
usb_stor_dbg(us, "Drive seems still hungry\n"); return USB_STOR_TRANSPORT_FAILED;
}
usb_stor_dbg(us, "Transfer happy\n"); break;
case DMA_TO_DEVICE: /* catch bogus "write 0 length" case */ if (!length) break; /* *Makesurethestatusindicatesthatthedevicewantsto *sendusdata.
*/ /* !!IMPLEMENT!! */
result = freecom_writedata (srb, us, ipipe, opipe, length); if (result != USB_STOR_TRANSPORT_GOOD) return result;
usb_stor_dbg(us, "Waiting for status\n");
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_PACKET_LENGTH, &partial);
if (partial != 4 || result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; if ((fst->Status & ERR_STAT) != 0) {
usb_stor_dbg(us, "operation failed\n"); return USB_STOR_TRANSPORT_FAILED;
} if ((fst->Reason & 3) != 3) {
usb_stor_dbg(us, "Drive seems still hungry\n"); return USB_STOR_TRANSPORT_FAILED;
}
usb_stor_dbg(us, "Transfer happy\n"); break;
case DMA_NONE: /* Easy, do nothing. */ break;
default: /* should never hit here -- filtered in usb.c */
usb_stor_dbg(us, "freecom unimplemented direction: %d\n",
us->srb->sc_data_direction); /* Return fail, SCSI seems to handle this better. */ return USB_STOR_TRANSPORT_FAILED;
}
result = usb_stor_control_msg(us, us->recv_ctrl_pipe, 0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ);
buffer[32] = '\0';
usb_stor_dbg(us, "String returned from FC init is: %s\n", buffer);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.