X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2Fgoodfet.maxusbmass;h=de25c6ef0c08baed2ab67bdb290b1de177a9f520;hp=088264266e2fba16909d346bb748937ac0d8295c;hb=b41a0644a0777cb50ff080b8f8c3995f6ee19183;hpb=3a1dba16a3f6c27250e1e9566171abe48537cc89 diff --git a/client/goodfet.maxusbmass b/client/goodfet.maxusbmass index 0882642..de25c6e 100755 --- a/client/goodfet.maxusbmass +++ b/client/goodfet.maxusbmass @@ -11,6 +11,13 @@ import time; from GoodFETMAXUSB import *; +def zeros(length): + """Returns a list of zeroes of the specified length.""" + l=range(0,length); + for foo in l: + l[foo]=0; + return l; + class GoodFETMAXUSBMass(GoodFETMAXUSBDevice): """This emulates a USB Mass Storage device.""" @@ -309,15 +316,22 @@ class GoodFETMAXUSBMass(GoodFETMAXUSBDevice): status=0x00; elif verb==0x1A: #Mode Sense (6) # I should probably send six bytes here. + print "Mode Sense (6) requesting %i byte Page Code %02x" % ( + dtlen,ord(cb[2])&0x3F); + #This is completely wrong. response=[0x12,0,0,0, 0,0,0,0x1C]; - self.writebytes(rEP3INFIFO, - response); - self.wregAS(rEP3INBC, - len(response)); + self.fifo_ep3in_tx(response); + elif verb==0x5A: #Mode Sense (10) + # I should probably send ten bytes here. + print "Mode Sense (10) requesting %i byte Page Code %02x" % ( + dtlen,ord(cb[2])&0x3F); + #This is completely wrong. + response=[0x12,0x00,0,0, 0,0,0,0x1C] + self.fifo_ep3in_tx(response); elif verb==0x23: #Read Format Capacity response=[ 0x00, 0,0x00,0x08, #Capacity list length. - 0,0x00,x10,0x00, # Number of sectors, implying 10MB. + 0,0x00,0x10,0x00, # Number of sectors, implying 10MB. 0x01,0x00, #reserved/desciptor code. 0x02,0x00 # 512 bytes/sector. Why is this twice? ]; @@ -365,13 +379,14 @@ class GoodFETMAXUSBMass(GoodFETMAXUSBDevice): #sys.exit(); elif verb==0x2A: #WRITE SECTOR print "Haven't implemented WRITE SECTOR."; - sys.exit(); + #sys.exit(); else: print "ERROR: Unknown SCSI command block verb %02x." % verb; status=1; #Command Failed if dtlen>0: - print "Perhaps I should send %i bytes of dummy data here." % dtlen; - sys.exit(1); + print "Sending %i bytes of dummy data here." % dtlen; + self.fifo_ep3in_tx(zeros(dtlen)); + #sys.exit(1); cbw=self.lastCBW; #Now we need to send the CSW.