GetMaxLUN(); /* Get maximum logical unit number */ for (retry = 80; retry--) { rc = TestUnitReady(); /* Test whether the unit is ready */ if (rc == OK) break; GetSenseInfo(); /* Get sense information */ } if (rc != OK) { PRINT_Err(rc); return(rc); } rc = ReadCapacity(numBlks, blkSize);/* Read capacity of the disk */ BlkSize = *blkSize;// Set global rc = Inquire(inquiryResult); return (rc); |
;-----------------------------------------------------------------------! ; InitMS! ;-----------------------------------------------------------------------! fn InitMS push{r4-r7,lr}; save regs ldrr5, =usbBase; get base register movsr7, hostBase; and host base ldrr1, =bulkReset; reset device blUsbCtrlSend; ldrr1, =clear1; clear endpoint 1 blUsbCtrlSend; ldrr1, =clear2; clear endpoint 2 blUsbCtrlSend; ;;blMaxLUN; why -- no result, not used blDevEnquiry; why -- result not used cbzr0, 1f; orrsr0, 0x810; b9f; 1:movsr12, 256; timeout 0:blTestUnitReady; wait for device ready cbzr0, 1f; ok blRequestSense; keep in phase? subsr12, 1; don't wait too long bne0b; orrsr0, 0x820; b9f; 1:blGetCapacity; get size info cbzr0, 9f; oops orrsr0, 0x830; 9:pop{r4-r7,pc}; return fe InitMS |
;-----------------------------------------------------------------------! ; DevEnquiry! ;-----------------------------------------------------------------------! fn DevEnquiry push{lr}; save regs movsr0, cmdEnquiry; setup blUsbSetupMS; movsr0, pidOut; send command wrapper movsr1, cbwSz; movsr2, 0; use tBuff blUsbBulkTD; cbnzr0, 9f; oops ; for some devices, a delay here seems to be essential ; one device needs approx 800 ms ; It might also be reqd for the 1st SCSI operation. movsr0, 0x380; delay for a bit, but why? !!! blUsbDelay; movsr0, pidIn; get payload movsr1, 36; enquiry data size movsr2, 0; use tBuff blUsbBulkTD; cbnzr0, 9f; oops addsr0, r7, devEnq; stash details addsr1, r7, tBuff; movsr2, 36; blblkcpy; movsr2, 42; only reason for doing this blUsbDump; movsr0, pidIn; get status movsr1, cswSz; movsr2, 0; use tBuff blUsbBulkTD; cbnzr0, 9f; oops ldrbr0, [r7, tBuff+12]; get status code (0 = ok) 9:pop{pc}; fe DevEnquiry |