userlibandfileserver/fileserver/shostmassstorage/server/protocol/cscsiprotocol.cpp
branchanywhere
changeset 41 d32f34975bbf
parent 33 0173bcd7697c
child 62 4a8fed1c0ef6
equal deleted inserted replaced
40:04a1b74efd48 41:d32f34975bbf
    68 void CScsiProtocol::ConstructL(TLun aLun)
    68 void CScsiProtocol::ConstructL(TLun aLun)
    69     {
    69     {
    70 	__MSFNLOG
    70 	__MSFNLOG
    71     iFsm = CMassStorageFsm::NewL(*this);
    71     iFsm = CMassStorageFsm::NewL(*this);
    72 	iState = EDisconnected;
    72 	iState = EDisconnected;
       
    73 
       
    74     const TInt blockLength = 0x200;
       
    75 
       
    76     iHeadbuf.CreateL(blockLength);
       
    77     iTailbuf.CreateL(blockLength);
    73     }
    78     }
    74 
    79 
    75 
    80 
    76 CScsiProtocol::CScsiProtocol(MTransport& aTransport)
    81 CScsiProtocol::CScsiProtocol(MTransport& aTransport)
    77 :   iSpcInterface(aTransport),
    82 :   iSpcInterface(aTransport),
    83 
    88 
    84 CScsiProtocol::~CScsiProtocol()
    89 CScsiProtocol::~CScsiProtocol()
    85     {
    90     {
    86 	__MSFNLOG
    91 	__MSFNLOG
    87     delete iFsm;
    92     delete iFsm;
       
    93     iHeadbuf.Close();
       
    94     iTailbuf.Close();
    88     delete iSbcInterface;
    95     delete iSbcInterface;
    89     }
    96     }
    90 
    97 
    91 
    98 
    92 void CScsiProtocol::InitialiseUnitL()
    99 void CScsiProtocol::InitialiseUnitL()
   251         }
   258         }
   252 
   259 
   253 	TLba lastLba;
   260 	TLba lastLba;
   254 	TUint32 blockLength;
   261 	TUint32 blockLength;
   255 
   262 
   256 	TInt err = iSbcInterface->ReadCapacity10L(lastLba, blockLength);
   263     // Retry ReadCapacity10L if stalled
       
   264     TInt stallCounter = 4;
       
   265     TInt err = KErrNone;
       
   266     do
       
   267         {
       
   268         err = iSbcInterface->ReadCapacity10L(lastLba, blockLength);
       
   269         } while (err == KErrCommandStalled && stallCounter-- > 0);
       
   270 
       
   271 
   257     if (err)
   272     if (err)
   258         {
   273         {
   259         if (err == KErrCommandFailed)
   274         if (err == KErrCommandFailed)
   260             {
   275             {
   261             // Clear sense error
   276             // Clear sense error
   349 
   364 
   350     iRemovableMedia = info.iRemovable;
   365     iRemovableMedia = info.iRemovable;
   351 
   366 
   352     // SCSI Block device
   367     // SCSI Block device
   353     iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport());
   368     iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport());
       
   369     iSbcInterface->InitBuffers(&iHeadbuf, &iTailbuf);
   354 
   370 
   355     return KErrNone;
   371     return KErrNone;
   356     }
   372     }
   357 
   373 
   358 
   374 
   651     {
   667     {
   652 	__MSFNLOG
   668 	__MSFNLOG
   653     // SCSI Block device
   669     // SCSI Block device
   654     ASSERT(iSbcInterface == NULL);
   670     ASSERT(iSbcInterface == NULL);
   655     iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport());
   671     iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport());
   656     iSbcInterface->SetCapacity(aBlockLen, aLastLba);
   672     iSbcInterface->InitBuffers(&iHeadbuf, &iTailbuf);
       
   673     iSbcInterface->SetCapacityL(aBlockLen, aLastLba);
   657     }
   674     }
   658 
   675 
   659 
   676 
   660 void CScsiProtocol::ResetSbc()
   677 void CScsiProtocol::ResetSbc()
   661     {
   678     {