os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/cmassstoragefsm.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @internalTechnology
sl@0
    19
*/
sl@0
    20
sl@0
    21
#include <e32base.h>
sl@0
    22
sl@0
    23
#include "usbmshostpanic.h"
sl@0
    24
#include "debug.h"
sl@0
    25
#include "msdebug.h"
sl@0
    26
sl@0
    27
#include "msctypes.h"
sl@0
    28
#include "mprotocol.h"
sl@0
    29
#include "mblocktransferprotocol.h"
sl@0
    30
#include "tspcclientinterface.h"
sl@0
    31
#include "cscsiprotocol.h"
sl@0
    32
#include "cmassstoragefsm.h"
sl@0
    33
sl@0
    34
sl@0
    35
/**
sl@0
    36
Constructor
sl@0
    37
sl@0
    38
@param aScsiProtocol A reference to CScsiProtocol
sl@0
    39
*/
sl@0
    40
TMassStorage::TMassStorage(CScsiProtocol& aScsiProtocol)
sl@0
    41
:   iScsiProtocol(aScsiProtocol)
sl@0
    42
    {
sl@0
    43
	__MSFNLOG
sl@0
    44
    }
sl@0
    45
sl@0
    46
sl@0
    47
/**
sl@0
    48
Clear StatusCheck flag. Periodic status checking is used for removable media.
sl@0
    49
*/
sl@0
    50
void CMassStorageFsm::ClearStatusCheck()
sl@0
    51
{
sl@0
    52
	__MSFNLOG
sl@0
    53
	iStatusCheck = EFalse;
sl@0
    54
}
sl@0
    55
sl@0
    56
sl@0
    57
/**
sl@0
    58
Set StatusCheck flag. Periodic status checking is used for removable media.
sl@0
    59
*/
sl@0
    60
void CMassStorageFsm::SetStatusCheck()
sl@0
    61
{
sl@0
    62
	__MSFNLOG
sl@0
    63
	iStatusCheck = ETrue;
sl@0
    64
}
sl@0
    65
sl@0
    66
sl@0
    67
/**
sl@0
    68
Get the boolean state of StatusCheck flag.
sl@0
    69
sl@0
    70
@return TBool ETrue if StatusCheck flag is set
sl@0
    71
*/
sl@0
    72
TBool CMassStorageFsm::IsStatusCheck() const
sl@0
    73
{
sl@0
    74
	__MSFNSLOG
sl@0
    75
	return iStatusCheck;
sl@0
    76
}
sl@0
    77
sl@0
    78
sl@0
    79
/**
sl@0
    80
Device supports SCSI BLOCK COMMANDS.
sl@0
    81
sl@0
    82
@return TBool Returns ETrue if the SBC interface is initialised
sl@0
    83
*/
sl@0
    84
TBool TMassStorage::IsSbcSet() const
sl@0
    85
    {
sl@0
    86
	__MSFNSLOG
sl@0
    87
    return iScsiProtocol.MsIsSbcSet();
sl@0
    88
    }
sl@0
    89
sl@0
    90
/**
sl@0
    91
Device is removable media
sl@0
    92
sl@0
    93
@return TBool Returns ETrue if removable
sl@0
    94
*/
sl@0
    95
TBool TMassStorage::IsRemovableMedia() const
sl@0
    96
    {
sl@0
    97
	__MSFNSLOG
sl@0
    98
    return iScsiProtocol.MsIsRemovableMedia();
sl@0
    99
    }
sl@0
   100
sl@0
   101
/**
sl@0
   102
Retrieve the sense info returned by a call to SenseL
sl@0
   103
sl@0
   104
@return const TSenseInfo& Returns the SCSI SENSE info
sl@0
   105
*/
sl@0
   106
const TSenseInfo& TMassStorage::MsSenseInfo() const
sl@0
   107
    {
sl@0
   108
	__MSFNSLOG
sl@0
   109
    return iScsiProtocol.MsSenseInfo();
sl@0
   110
    }
sl@0
   111
sl@0
   112
sl@0
   113
/** SCSI Request */
sl@0
   114
TMassStorage::TEvent TMassStorage::InquiryL()
sl@0
   115
    {
sl@0
   116
	__MSFNLOG
sl@0
   117
    TEvent event = EEvCommandFailed;
sl@0
   118
sl@0
   119
    switch (iScsiProtocol.MsInquiryL())
sl@0
   120
        {
sl@0
   121
    case KErrNone:
sl@0
   122
        event = EEvCommandPassed;
sl@0
   123
        break;
sl@0
   124
    case KErrCommandFailed:
sl@0
   125
        event = EEvCommandFailed;
sl@0
   126
        break;
sl@0
   127
    case KErrNotSupported:
sl@0
   128
        __SCSIPRINT(_L("INQUIRY Command returned NOT SUPPORTED"));
sl@0
   129
        User::Leave(KErrNotSupported);
sl@0
   130
        break;
sl@0
   131
    default:
sl@0
   132
        User::Leave(KErrUnknown);
sl@0
   133
        break;
sl@0
   134
        }
sl@0
   135
    return event;
sl@0
   136
    }
sl@0
   137
sl@0
   138
sl@0
   139
/** SCSI Request */
sl@0
   140
TMassStorage::TEvent TMassStorage::SenseL()
sl@0
   141
    {
sl@0
   142
	__MSFNLOG
sl@0
   143
    TEvent event = EEvCommandPassed;
sl@0
   144
    switch (iScsiProtocol.MsRequestSenseL())
sl@0
   145
        {
sl@0
   146
    case KErrNone:
sl@0
   147
        break;
sl@0
   148
    case KErrCommandFailed:
sl@0
   149
        __SCSIPRINT(_L("REQUEST SENSE Command Failed"));
sl@0
   150
        User::Leave(KErrNotSupported);
sl@0
   151
        break;
sl@0
   152
    default:
sl@0
   153
        User::Leave(KErrUnknown);
sl@0
   154
        break;
sl@0
   155
        }
sl@0
   156
    return event;
sl@0
   157
    }
sl@0
   158
sl@0
   159
sl@0
   160
/** SCSI Request */
sl@0
   161
TMassStorage::TEvent TMassStorage::TestUnitReadyL()
sl@0
   162
    {
sl@0
   163
	__MSFNLOG
sl@0
   164
    // KErrCommandFailed indictates that device is NOT READY
sl@0
   165
    TInt err = iScsiProtocol.MsTestUnitReadyL();
sl@0
   166
    return (err == KErrNone) ? EEvCommandPassed : EEvCommandFailed;
sl@0
   167
    }
sl@0
   168
sl@0
   169
sl@0
   170
/** SCSI Request */
sl@0
   171
TMassStorage::TEvent TMassStorage::StartStopUnitL(TBool aStart)
sl@0
   172
    {
sl@0
   173
	__MSFNLOG
sl@0
   174
    TInt err = iScsiProtocol.MsStartStopUnitL(aStart);
sl@0
   175
    return (err == KErrNone) ? EEvCommandPassed : EEvCommandFailed;
sl@0
   176
    }
sl@0
   177
sl@0
   178
sl@0
   179
/** SCSI Request */
sl@0
   180
TMassStorage::TEvent TMassStorage::PreventAllowMediumRemovalL(TBool aPrevent)
sl@0
   181
    {
sl@0
   182
	__MSFNLOG
sl@0
   183
    // KErrCommandFailed indictates that device is NOT READY
sl@0
   184
    TInt err = iScsiProtocol.MsPreventAllowMediaRemovalL(aPrevent);
sl@0
   185
    return (err == KErrNone) ? EEvCommandPassed : EEvCommandFailed;
sl@0
   186
    }
sl@0
   187
sl@0
   188
sl@0
   189
/** SCSI Request */
sl@0
   190
TMassStorage::TEvent TMassStorage::ReadCapacityL()
sl@0
   191
    {
sl@0
   192
	__MSFNLOG
sl@0
   193
    TInt err = iScsiProtocol.MsReadCapacityL();
sl@0
   194
    return ErrToEvent(err);
sl@0
   195
    }
sl@0
   196
sl@0
   197
sl@0
   198
/** SCSI Request */
sl@0
   199
TMassStorage::TEvent TMassStorage::ModeSense10L()
sl@0
   200
    {
sl@0
   201
	__MSFNLOG
sl@0
   202
    TInt err = iScsiProtocol.MsModeSense10L();
sl@0
   203
    return ErrToEvent(err);
sl@0
   204
    }
sl@0
   205
sl@0
   206
sl@0
   207
/** SCSI Request */
sl@0
   208
TMassStorage::TEvent TMassStorage::ModeSense6L()
sl@0
   209
    {
sl@0
   210
	__MSFNLOG
sl@0
   211
    TInt err = iScsiProtocol.MsModeSense6L();
sl@0
   212
    return ErrToEvent(err);
sl@0
   213
    }
sl@0
   214
sl@0
   215
sl@0
   216
/**
sl@0
   217
Creates and returns a pointer to CMassStorageFsm.
sl@0
   218
sl@0
   219
@param aScsiProtocol A reference to the protocol providing the interface to the
sl@0
   220
mass storage device.
sl@0
   221
sl@0
   222
@return CMassStorageFsm* A pointer to the newly created object
sl@0
   223
*/
sl@0
   224
CMassStorageFsm* CMassStorageFsm::NewL(CScsiProtocol& aScsiProtocol)
sl@0
   225
{
sl@0
   226
	__MSFNSLOG
sl@0
   227
	CMassStorageFsm* r = new (ELeave) CMassStorageFsm(aScsiProtocol);
sl@0
   228
sl@0
   229
	CleanupStack::PushL(r);
sl@0
   230
	r->ConstructL();
sl@0
   231
	CleanupStack::Pop();
sl@0
   232
	return r;
sl@0
   233
}
sl@0
   234
sl@0
   235
void CMassStorageFsm::ConstructL()
sl@0
   236
    {
sl@0
   237
	__MSFNLOG
sl@0
   238
    TInt i = 0;
sl@0
   239
    // EInquiryState,
sl@0
   240
    iStateTable[i++] = new (ELeave) TInquiryState;
sl@0
   241
    // EInquirySenseState,
sl@0
   242
    iStateTable[i++] = new (ELeave) TInquirySenseState;
sl@0
   243
    // ENotReadyState,
sl@0
   244
    iStateTable[i++] = new (ELeave) TNotReadyState;
sl@0
   245
    // ENotReadySenseState,
sl@0
   246
    iStateTable[i++] = new (ELeave) TNotReadySenseState;
sl@0
   247
    // EStartUnitState
sl@0
   248
    iStateTable[i++] = new (ELeave) TStartUnitState;
sl@0
   249
    //EStartUnitSenseState,
sl@0
   250
    iStateTable[i++] = new (ELeave) TStartUnitSenseState;
sl@0
   251
    //EPreventAllowMediumRemovalState,
sl@0
   252
    iStateTable[i++] = new (ELeave) TPreventMediumRemovalState;
sl@0
   253
    //EPreventAllowMediumRemovalSenseState,
sl@0
   254
    iStateTable[i++] = new (ELeave) TPreventMediumRemovalSenseState;
sl@0
   255
    //EReadCapacity10State,
sl@0
   256
    iStateTable[i++] = new (ELeave) TReadCapacity10State;
sl@0
   257
    //EModeSense10State,
sl@0
   258
    iStateTable[i++] = new (ELeave) TModeSense10State;
sl@0
   259
    //EModeSense10SenseState,
sl@0
   260
    iStateTable[i++] = new (ELeave) TModeSense10SenseState;
sl@0
   261
    //EModeSense6State,
sl@0
   262
    iStateTable[i++] = new (ELeave) TModeSense6State;
sl@0
   263
    //EModeSense6SenseState,
sl@0
   264
    iStateTable[i++] = new (ELeave) TModeSense6SenseState;
sl@0
   265
    //EConnectedState,
sl@0
   266
    iStateTable[i++] = new (ELeave) TConnectedState;
sl@0
   267
    //EStatusCheck
sl@0
   268
    iStateTable[i++] = new (ELeave) TStatusCheckState;
sl@0
   269
    //EAllowMediumRemovalState,
sl@0
   270
    iStateTable[i++] = new (ELeave) TAllowMediumRemovalState;
sl@0
   271
    //EStopUnitState,
sl@0
   272
    iStateTable[i++] = new (ELeave) TStopUnitState;
sl@0
   273
    //ESenseState,
sl@0
   274
    iStateTable[i++] = new (ELeave) TSenseState;
sl@0
   275
sl@0
   276
#ifdef __DEBUG
sl@0
   277
    // verify state table
sl@0
   278
    for (TInt i = 0; i < iStateTable.Count(), i++)
sl@0
   279
        {
sl@0
   280
        __ASSERT_DEBUG(i == iStateTable[i].iStateId, User::Invariant());
sl@0
   281
        }
sl@0
   282
#endif
sl@0
   283
sl@0
   284
    SetState(TMassStorageState::EInquiryState);
sl@0
   285
    }
sl@0
   286
sl@0
   287
sl@0
   288
CMassStorageFsm::CMassStorageFsm(CScsiProtocol& aScsiProtocol)
sl@0
   289
:   TMassStorage(aScsiProtocol),
sl@0
   290
    iStartStopUnitRequired(EFalse)
sl@0
   291
    {
sl@0
   292
	__MSFNLOG
sl@0
   293
    }
sl@0
   294
sl@0
   295
CMassStorageFsm::~CMassStorageFsm()
sl@0
   296
    {
sl@0
   297
	__MSFNLOG
sl@0
   298
sl@0
   299
    for (TInt i = 0; i < iStateTable.Count(); i++)
sl@0
   300
        {
sl@0
   301
        delete iStateTable[i];
sl@0
   302
        }
sl@0
   303
    }
sl@0
   304
sl@0
   305
sl@0
   306
TMassStorage::TEvent CMassStorageFsm::EntryL()
sl@0
   307
    {
sl@0
   308
	__MSFNLOG
sl@0
   309
sl@0
   310
    return iState->EntryL(*this);
sl@0
   311
    }
sl@0
   312
sl@0
   313
sl@0
   314
/**
sl@0
   315
Run FSM to connect device.
sl@0
   316
sl@0
   317
@return TInt KErrCompletion if successful otherwise KErrNotSupported
sl@0
   318
*/
sl@0
   319
TInt CMassStorageFsm::ConnectLogicalUnitL()
sl@0
   320
    {
sl@0
   321
	__MSFNLOG
sl@0
   322
    TInt err = KErrNone;
sl@0
   323
    for (;;)
sl@0
   324
         {
sl@0
   325
         err = ProcessStateL();
sl@0
   326
         if (err)
sl@0
   327
             break;
sl@0
   328
         }
sl@0
   329
    return err;
sl@0
   330
    }
sl@0
   331
sl@0
   332
sl@0
   333
/**
sl@0
   334
Run FSM to disconnect the device.
sl@0
   335
sl@0
   336
@return TInt KErrCompletion if successful otherwise KErrNotSupported
sl@0
   337
*/
sl@0
   338
TInt CMassStorageFsm::DisconnectLogicalUnitL()
sl@0
   339
    {
sl@0
   340
	__MSFNLOG
sl@0
   341
    TInt err = KErrNone;
sl@0
   342
    for (;;)
sl@0
   343
         {
sl@0
   344
         TInt err = ProcessStateL();
sl@0
   345
         if (err)
sl@0
   346
             break;
sl@0
   347
         }
sl@0
   348
    return err;
sl@0
   349
    }
sl@0
   350
sl@0
   351
sl@0
   352
/**
sl@0
   353
Return current FSM state.
sl@0
   354
sl@0
   355
@return TBool ETrue if FSM state is Connected State
sl@0
   356
*/
sl@0
   357
TBool CMassStorageFsm::IsConnected() const
sl@0
   358
    {
sl@0
   359
	__MSFNSLOG
sl@0
   360
    return iState->iStateId == TMassStorageState::EConnectedState ? ETrue : EFalse;
sl@0
   361
    }
sl@0
   362
sl@0
   363
sl@0
   364
TInt CMassStorageFsm::ProcessStateL()
sl@0
   365
    {
sl@0
   366
	__MSFNLOG
sl@0
   367
    TMassStorage::TEvent event = TMassStorage::EEvCommandFailed;
sl@0
   368
    TRAPD(err,  event = EntryL());
sl@0
   369
    if (err == KErrNotSupported)
sl@0
   370
        {
sl@0
   371
        return KErrNotSupported;
sl@0
   372
        }
sl@0
   373
    User::LeaveIfError(err);
sl@0
   374
sl@0
   375
    __HOSTPRINT1(_L("FSM event=%d"), event);
sl@0
   376
    switch (event)
sl@0
   377
        {
sl@0
   378
    case TMassStorage::EEvCommandPassed:
sl@0
   379
        err = ScsiCommandPassed();
sl@0
   380
        break;
sl@0
   381
    case TMassStorage::EEvCommandFailed:
sl@0
   382
        err = ScsiCommandFailed();
sl@0
   383
        break;
sl@0
   384
    case TMassStorage::EEvCommandError:
sl@0
   385
        err = ScsiCommandError();
sl@0
   386
        break;
sl@0
   387
    default:
sl@0
   388
        User::Panic(KUsbMsHostPanicCat, EMsFsmEvent);
sl@0
   389
        break;
sl@0
   390
        }
sl@0
   391
sl@0
   392
    __HOSTPRINT1(_L("FSM ProcessState completed=%d"), err);
sl@0
   393
    return err;
sl@0
   394
    }
sl@0
   395
sl@0
   396
sl@0
   397
TInt CMassStorageFsm::ScsiCommandPassed()
sl@0
   398
    {
sl@0
   399
	__MSFNLOG
sl@0
   400
    return iState->ScsiCommandPassed(*this);
sl@0
   401
    }
sl@0
   402
sl@0
   403
sl@0
   404
TInt CMassStorageFsm::ScsiCommandFailed()
sl@0
   405
    {
sl@0
   406
	__MSFNLOG
sl@0
   407
    return iState->ScsiCommandFailed(*this);
sl@0
   408
    }
sl@0
   409
sl@0
   410
sl@0
   411
TInt CMassStorageFsm::ScsiCommandError()
sl@0
   412
    {
sl@0
   413
	__MSFNLOG
sl@0
   414
    return iState->ScsiCommandError(*this);
sl@0
   415
    }
sl@0
   416
sl@0
   417
sl@0
   418
/**
sl@0
   419
Constructor
sl@0
   420
sl@0
   421
@param aStateId The state id of the state implementation
sl@0
   422
*/
sl@0
   423
TMassStorageState::TMassStorageState(TStateId aStateId)
sl@0
   424
:   iStateId(aStateId)
sl@0
   425
    {
sl@0
   426
	__MSFNLOG
sl@0
   427
    }
sl@0
   428
sl@0
   429
sl@0
   430
/** 
sl@0
   431
   Default state does nothing. Used by states where the stalled event is not 
sl@0
   432
   applicable 
sl@0
   433
   
sl@0
   434
   @param aFsm
sl@0
   435
   
sl@0
   436
   @return TInt
sl@0
   437
 */
sl@0
   438
TInt TMassStorageState::ScsiCommandError(CMassStorageFsm& /* aFsm */)
sl@0
   439
    {
sl@0
   440
    return KErrNone;
sl@0
   441
    }
sl@0
   442
sl@0
   443
sl@0
   444
TInt TMassStorageState::SenseError(CMassStorageFsm& aFsm)
sl@0
   445
    {
sl@0
   446
	__MSFNLOG
sl@0
   447
    TInt ret = KErrNone;
sl@0
   448
    const TSenseInfo& senseInfo = aFsm.MsSenseInfo();
sl@0
   449
sl@0
   450
    if (senseInfo.iSenseCode == TSenseInfo::EUnitAttention)
sl@0
   451
        {
sl@0
   452
        aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
   453
        }
sl@0
   454
    else
sl@0
   455
        {
sl@0
   456
        aFsm.SetState(TMassStorageState::ENotReadyState);
sl@0
   457
        ret = KErrCompletion;
sl@0
   458
        }
sl@0
   459
    return ret;
sl@0
   460
    }
sl@0
   461
sl@0
   462
sl@0
   463
/**
sl@0
   464
sl@0
   465
*/
sl@0
   466
TInquiryState::TInquiryState()
sl@0
   467
:   TMassStorageState(EInquiryState)
sl@0
   468
    {
sl@0
   469
	__MSFNLOG
sl@0
   470
    }
sl@0
   471
sl@0
   472
sl@0
   473
TMassStorage::TEvent TInquiryState::EntryL(CMassStorageFsm& aFsm)
sl@0
   474
    {
sl@0
   475
	__MSFNLOG
sl@0
   476
    return aFsm.InquiryL();
sl@0
   477
    };
sl@0
   478
sl@0
   479
sl@0
   480
TInt TInquiryState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   481
    {
sl@0
   482
	__MSFNLOG
sl@0
   483
    aFsm.SetState(ENotReadyState);
sl@0
   484
    return KErrNone;
sl@0
   485
    };
sl@0
   486
sl@0
   487
sl@0
   488
TInt TInquiryState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   489
    {
sl@0
   490
	__MSFNLOG
sl@0
   491
    aFsm.SetState(EInquirySenseState);
sl@0
   492
    return KErrNone;
sl@0
   493
    }
sl@0
   494
sl@0
   495
sl@0
   496
/**
sl@0
   497
sl@0
   498
*/
sl@0
   499
TInquirySenseState::TInquirySenseState()
sl@0
   500
:   TMassStorageState(EInquirySenseState)
sl@0
   501
    {
sl@0
   502
	__MSFNLOG
sl@0
   503
    }
sl@0
   504
sl@0
   505
sl@0
   506
TMassStorage::TEvent TInquirySenseState::EntryL(CMassStorageFsm& aFsm)
sl@0
   507
    {
sl@0
   508
	__MSFNLOG
sl@0
   509
    return aFsm.SenseL();
sl@0
   510
    };
sl@0
   511
sl@0
   512
sl@0
   513
TInt TInquirySenseState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   514
    {
sl@0
   515
	__MSFNLOG
sl@0
   516
    // SENSE ERROR
sl@0
   517
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
   518
    return KErrCompletion;
sl@0
   519
    };
sl@0
   520
sl@0
   521
sl@0
   522
TInt TInquirySenseState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   523
    {
sl@0
   524
	__MSFNLOG
sl@0
   525
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
   526
    return KErrCompletion;
sl@0
   527
    }
sl@0
   528
sl@0
   529
sl@0
   530
/**
sl@0
   531
sl@0
   532
*/
sl@0
   533
TNotReadyState::TNotReadyState()
sl@0
   534
:   TMassStorageState(ENotReadyState)
sl@0
   535
    {
sl@0
   536
	__MSFNLOG
sl@0
   537
    }
sl@0
   538
sl@0
   539
sl@0
   540
TMassStorage::TEvent TNotReadyState::EntryL(CMassStorageFsm& aFsm)
sl@0
   541
    {
sl@0
   542
	__MSFNLOG
sl@0
   543
    return aFsm.TestUnitReadyL();
sl@0
   544
    }
sl@0
   545
sl@0
   546
sl@0
   547
TInt TNotReadyState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   548
    {
sl@0
   549
	__MSFNLOG
sl@0
   550
    if (aFsm.IsSbcSet())
sl@0
   551
        {
sl@0
   552
        if (aFsm.IsRemovableMedia())
sl@0
   553
            aFsm.SetState(TMassStorageState::EPreventRemovalState);
sl@0
   554
        else
sl@0
   555
            aFsm.SetState(TMassStorageState::EReadCapacityState);
sl@0
   556
        }
sl@0
   557
    else
sl@0
   558
        aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
   559
    return KErrNone;
sl@0
   560
    }
sl@0
   561
sl@0
   562
sl@0
   563
TInt TNotReadyState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   564
    {
sl@0
   565
	__MSFNLOG
sl@0
   566
    aFsm.SetState(TMassStorageState::ENotReadySenseState);
sl@0
   567
    return KErrNone;
sl@0
   568
    }
sl@0
   569
sl@0
   570
sl@0
   571
/**
sl@0
   572
sl@0
   573
*/
sl@0
   574
TNotReadySenseState::TNotReadySenseState()
sl@0
   575
:   TMassStorageState(ENotReadySenseState)
sl@0
   576
    {
sl@0
   577
	__MSFNLOG
sl@0
   578
    }
sl@0
   579
sl@0
   580
sl@0
   581
TMassStorage::TEvent TNotReadySenseState::EntryL(CMassStorageFsm& aFsm)
sl@0
   582
    {
sl@0
   583
	__MSFNLOG
sl@0
   584
    return aFsm.SenseL();
sl@0
   585
    }
sl@0
   586
sl@0
   587
sl@0
   588
TInt TNotReadySenseState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   589
    {
sl@0
   590
	__MSFNLOG
sl@0
   591
    const TSenseInfo& senseInfo = aFsm.MsSenseInfo();
sl@0
   592
    TInt ret = KErrNone;
sl@0
   593
sl@0
   594
    if (senseInfo.iSenseCode == TSenseInfo::ENotReady &&
sl@0
   595
        senseInfo.iAdditional == TSenseInfo::EAscLogicalUnitNotReady &&
sl@0
   596
        senseInfo.iQualifier == TSenseInfo::EAscqInitializingCommandRequired)
sl@0
   597
        {
sl@0
   598
        aFsm.SetStartStopUnitRequired(ETrue);
sl@0
   599
        aFsm.SetState(TMassStorageState::EStartUnitState);
sl@0
   600
        }
sl@0
   601
    else
sl@0
   602
        {
sl@0
   603
        ret = TMassStorageState::SenseError(aFsm);
sl@0
   604
        }
sl@0
   605
sl@0
   606
    return ret;
sl@0
   607
    }
sl@0
   608
sl@0
   609
sl@0
   610
TInt TNotReadySenseState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   611
    {
sl@0
   612
	__MSFNLOG
sl@0
   613
    return TMassStorageState::SenseError(aFsm);
sl@0
   614
    }
sl@0
   615
sl@0
   616
sl@0
   617
/**
sl@0
   618
sl@0
   619
*/
sl@0
   620
TStartUnitState::TStartUnitState()
sl@0
   621
:   TMassStorageState(EPreventRemovalState)
sl@0
   622
    {
sl@0
   623
	__MSFNLOG
sl@0
   624
    }
sl@0
   625
sl@0
   626
sl@0
   627
TMassStorage::TEvent TStartUnitState::EntryL(CMassStorageFsm& aFsm)
sl@0
   628
    {
sl@0
   629
	__MSFNLOG
sl@0
   630
    return aFsm.StartStopUnitL(ETrue);
sl@0
   631
    }
sl@0
   632
sl@0
   633
sl@0
   634
TInt TStartUnitState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   635
    {
sl@0
   636
	__MSFNLOG
sl@0
   637
    if (aFsm.IsRemovableMedia())
sl@0
   638
        aFsm.SetState(TMassStorageState::EPreventRemovalState);
sl@0
   639
    else
sl@0
   640
        aFsm.SetState(TMassStorageState::EReadCapacityState);
sl@0
   641
    return KErrNone;
sl@0
   642
    }
sl@0
   643
sl@0
   644
sl@0
   645
TInt TStartUnitState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   646
    {
sl@0
   647
	__MSFNLOG
sl@0
   648
    aFsm.SetState(TMassStorageState::EPreventRemovalSenseState);
sl@0
   649
    return KErrNone;
sl@0
   650
    }
sl@0
   651
sl@0
   652
/**
sl@0
   653
sl@0
   654
*/
sl@0
   655
TStartUnitSenseState::TStartUnitSenseState()
sl@0
   656
:   TMassStorageState(EPreventRemovalSenseState)
sl@0
   657
    {
sl@0
   658
	__MSFNLOG
sl@0
   659
    }
sl@0
   660
sl@0
   661
sl@0
   662
TMassStorage::TEvent TStartUnitSenseState::EntryL(CMassStorageFsm& aFsm)
sl@0
   663
    {
sl@0
   664
	__MSFNLOG
sl@0
   665
    return aFsm.SenseL();
sl@0
   666
    }
sl@0
   667
sl@0
   668
sl@0
   669
TInt TStartUnitSenseState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   670
    {
sl@0
   671
	__MSFNLOG
sl@0
   672
    if (aFsm.IsRemovableMedia())
sl@0
   673
        aFsm.SetState(TMassStorageState::EPreventRemovalState);
sl@0
   674
    else
sl@0
   675
        aFsm.SetState(TMassStorageState::EReadCapacityState);
sl@0
   676
sl@0
   677
    return KErrNone;
sl@0
   678
    }
sl@0
   679
sl@0
   680
sl@0
   681
TInt TStartUnitSenseState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   682
    {
sl@0
   683
	__MSFNLOG
sl@0
   684
    TInt ret = KErrCompletion;
sl@0
   685
    const TSenseInfo& senseInfo = aFsm.MsSenseInfo();
sl@0
   686
sl@0
   687
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
   688
    if (senseInfo.iSenseCode == TSenseInfo::EIllegalRequest)
sl@0
   689
        {
sl@0
   690
        aFsm.SetState(TMassStorageState::EReadCapacityState);
sl@0
   691
        ret = KErrNone;
sl@0
   692
        }
sl@0
   693
    else
sl@0
   694
        {
sl@0
   695
        ret = TMassStorageState::SenseError(aFsm);
sl@0
   696
        }
sl@0
   697
sl@0
   698
    return ret;
sl@0
   699
    }
sl@0
   700
sl@0
   701
sl@0
   702
/**
sl@0
   703
sl@0
   704
*/
sl@0
   705
TPreventMediumRemovalState::TPreventMediumRemovalState()
sl@0
   706
:   TMassStorageState(EPreventRemovalState)
sl@0
   707
    {
sl@0
   708
	__MSFNLOG
sl@0
   709
    }
sl@0
   710
sl@0
   711
sl@0
   712
TMassStorage::TEvent TPreventMediumRemovalState::EntryL(CMassStorageFsm& aFsm)
sl@0
   713
    {
sl@0
   714
	__MSFNLOG
sl@0
   715
    return aFsm.PreventAllowMediumRemovalL(ETrue);
sl@0
   716
    }
sl@0
   717
sl@0
   718
sl@0
   719
TInt TPreventMediumRemovalState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   720
    {
sl@0
   721
	__MSFNLOG
sl@0
   722
    aFsm.SetState(TMassStorageState::EReadCapacityState);
sl@0
   723
    return KErrNone;
sl@0
   724
    }
sl@0
   725
sl@0
   726
sl@0
   727
TInt TPreventMediumRemovalState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   728
    {
sl@0
   729
	__MSFNLOG
sl@0
   730
    aFsm.SetState(TMassStorageState::EPreventRemovalSenseState);
sl@0
   731
    return KErrNone;
sl@0
   732
    }
sl@0
   733
sl@0
   734
/**
sl@0
   735
sl@0
   736
*/
sl@0
   737
TPreventMediumRemovalSenseState::TPreventMediumRemovalSenseState()
sl@0
   738
:   TMassStorageState(EPreventRemovalSenseState)
sl@0
   739
    {
sl@0
   740
	__MSFNLOG
sl@0
   741
    }
sl@0
   742
sl@0
   743
sl@0
   744
TMassStorage::TEvent TPreventMediumRemovalSenseState::EntryL(CMassStorageFsm& aFsm)
sl@0
   745
    {
sl@0
   746
	__MSFNLOG
sl@0
   747
    return aFsm.SenseL();
sl@0
   748
    }
sl@0
   749
sl@0
   750
sl@0
   751
TInt TPreventMediumRemovalSenseState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   752
    {
sl@0
   753
	__MSFNLOG
sl@0
   754
    aFsm.SetState(TMassStorageState::EReadCapacityState);
sl@0
   755
    return KErrNone;
sl@0
   756
    }
sl@0
   757
sl@0
   758
sl@0
   759
sl@0
   760
sl@0
   761
TInt TPreventMediumRemovalSenseState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   762
    {
sl@0
   763
	__MSFNLOG
sl@0
   764
    TInt ret = KErrCompletion;
sl@0
   765
    const TSenseInfo& senseInfo = aFsm.MsSenseInfo();
sl@0
   766
sl@0
   767
    if (senseInfo.iSenseCode == TSenseInfo::EIllegalRequest)
sl@0
   768
        {
sl@0
   769
        aFsm.SetState(TMassStorageState::EReadCapacityState);
sl@0
   770
        ret = KErrNone;
sl@0
   771
        }
sl@0
   772
    else
sl@0
   773
        {
sl@0
   774
        ret = TMassStorageState::SenseError(aFsm);
sl@0
   775
        }
sl@0
   776
    return ret;
sl@0
   777
    }
sl@0
   778
sl@0
   779
sl@0
   780
/**
sl@0
   781
sl@0
   782
*/
sl@0
   783
TReadCapacity10State::TReadCapacity10State()
sl@0
   784
:   TMassStorageState(EReadCapacityState)
sl@0
   785
    {
sl@0
   786
	__MSFNLOG
sl@0
   787
    }
sl@0
   788
sl@0
   789
sl@0
   790
TMassStorage::TEvent TReadCapacity10State::EntryL(CMassStorageFsm& aFsm)
sl@0
   791
    {
sl@0
   792
	__MSFNLOG
sl@0
   793
    return aFsm.ReadCapacityL();
sl@0
   794
    };
sl@0
   795
sl@0
   796
sl@0
   797
TInt TReadCapacity10State::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   798
    {
sl@0
   799
	__MSFNLOG
sl@0
   800
    aFsm.SetState(EModeSense10State);
sl@0
   801
    return KErrNone;
sl@0
   802
    };
sl@0
   803
sl@0
   804
sl@0
   805
TInt TReadCapacity10State::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   806
    {
sl@0
   807
	__MSFNLOG
sl@0
   808
    aFsm.SetState(TMassStorageState::ESenseState);
sl@0
   809
    return KErrCompletion;
sl@0
   810
    }
sl@0
   811
sl@0
   812
sl@0
   813
TInt TReadCapacity10State::ScsiCommandError(CMassStorageFsm& aFsm)
sl@0
   814
    {
sl@0
   815
	__MSFNLOG
sl@0
   816
    aFsm.SetState(TMassStorageState::ENotReadyState);
sl@0
   817
    return KErrCompletion;
sl@0
   818
    }
sl@0
   819
sl@0
   820
sl@0
   821
/**
sl@0
   822
sl@0
   823
*/
sl@0
   824
TModeSense10State::TModeSense10State()
sl@0
   825
:   TMassStorageState(EModeSense10State)
sl@0
   826
    {
sl@0
   827
	__MSFNLOG
sl@0
   828
    }
sl@0
   829
sl@0
   830
sl@0
   831
TMassStorage::TEvent TModeSense10State::EntryL(CMassStorageFsm& aFsm)
sl@0
   832
    {
sl@0
   833
	__MSFNLOG
sl@0
   834
    return aFsm.ModeSense10L();
sl@0
   835
    };
sl@0
   836
sl@0
   837
sl@0
   838
TInt TModeSense10State::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   839
    {
sl@0
   840
	__MSFNLOG
sl@0
   841
    aFsm.SetState(EConnectedState);
sl@0
   842
    return KErrCompletion;
sl@0
   843
    };
sl@0
   844
sl@0
   845
sl@0
   846
TInt TModeSense10State::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   847
    {
sl@0
   848
	__MSFNLOG
sl@0
   849
    aFsm.SetState(EModeSense10SenseState);
sl@0
   850
    return KErrNone;
sl@0
   851
    }
sl@0
   852
sl@0
   853
sl@0
   854
TInt TModeSense10State::ScsiCommandError(CMassStorageFsm& aFsm)
sl@0
   855
    {
sl@0
   856
	__MSFNLOG
sl@0
   857
    aFsm.SetState(EModeSense6State);
sl@0
   858
    return KErrNone;
sl@0
   859
    }
sl@0
   860
sl@0
   861
/**
sl@0
   862
sl@0
   863
*/
sl@0
   864
TModeSense10SenseState::TModeSense10SenseState()
sl@0
   865
:   TMassStorageState(EModeSense10SenseState)
sl@0
   866
    {
sl@0
   867
	__MSFNLOG
sl@0
   868
    }
sl@0
   869
sl@0
   870
sl@0
   871
TMassStorage::TEvent TModeSense10SenseState::EntryL(CMassStorageFsm& aFsm)
sl@0
   872
    {
sl@0
   873
	__MSFNLOG
sl@0
   874
    return aFsm.SenseL();
sl@0
   875
    };
sl@0
   876
sl@0
   877
sl@0
   878
TInt TModeSense10SenseState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   879
    {
sl@0
   880
	__MSFNLOG
sl@0
   881
    TInt ret = KErrCompletion;
sl@0
   882
    const TSenseInfo& senseInfo = aFsm.MsSenseInfo();
sl@0
   883
sl@0
   884
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
   885
    if (senseInfo.iSenseCode == TSenseInfo::EIllegalRequest)
sl@0
   886
        {
sl@0
   887
        aFsm.SetState(TMassStorageState::EModeSense6State);
sl@0
   888
        ret = KErrNone;
sl@0
   889
        }
sl@0
   890
    else
sl@0
   891
        {
sl@0
   892
        ret = TMassStorageState::SenseError(aFsm);
sl@0
   893
        }
sl@0
   894
    return ret;
sl@0
   895
    };
sl@0
   896
sl@0
   897
sl@0
   898
TInt TModeSense10SenseState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   899
    {
sl@0
   900
	__MSFNLOG
sl@0
   901
    aFsm.SetState(EInquirySenseState);
sl@0
   902
    return KErrCompletion;
sl@0
   903
    }
sl@0
   904
sl@0
   905
/**
sl@0
   906
sl@0
   907
*/
sl@0
   908
TModeSense6State::TModeSense6State()
sl@0
   909
:   TMassStorageState(EModeSense6State)
sl@0
   910
    {
sl@0
   911
	__MSFNLOG
sl@0
   912
    }
sl@0
   913
sl@0
   914
sl@0
   915
TMassStorage::TEvent TModeSense6State::EntryL(CMassStorageFsm& aFsm)
sl@0
   916
    {
sl@0
   917
	__MSFNLOG
sl@0
   918
    return aFsm.ModeSense6L();
sl@0
   919
    };
sl@0
   920
sl@0
   921
sl@0
   922
TInt TModeSense6State::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   923
    {
sl@0
   924
	__MSFNLOG
sl@0
   925
    aFsm.SetState(EConnectedState);
sl@0
   926
    return KErrCompletion;
sl@0
   927
    };
sl@0
   928
sl@0
   929
sl@0
   930
TInt TModeSense6State::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   931
    {
sl@0
   932
	__MSFNLOG
sl@0
   933
    aFsm.SetState(EModeSense6SenseState);
sl@0
   934
    return KErrNone;
sl@0
   935
    }
sl@0
   936
sl@0
   937
sl@0
   938
TInt TModeSense6State::ScsiCommandError(CMassStorageFsm& aFsm)
sl@0
   939
    {
sl@0
   940
	__MSFNLOG
sl@0
   941
    // If device responds with protocol error, ignore the error and assume the
sl@0
   942
    // device is not write protected
sl@0
   943
    aFsm.SetState(EConnectedState);
sl@0
   944
    return KErrCompletion;
sl@0
   945
    }
sl@0
   946
sl@0
   947
sl@0
   948
/**
sl@0
   949
sl@0
   950
*/
sl@0
   951
TModeSense6SenseState::TModeSense6SenseState()
sl@0
   952
:   TMassStorageState(EModeSense6SenseState)
sl@0
   953
    {
sl@0
   954
	__MSFNLOG
sl@0
   955
    }
sl@0
   956
sl@0
   957
sl@0
   958
TMassStorage::TEvent TModeSense6SenseState::EntryL(CMassStorageFsm& aFsm)
sl@0
   959
    {
sl@0
   960
	__MSFNLOG
sl@0
   961
    return aFsm.SenseL();
sl@0
   962
    };
sl@0
   963
sl@0
   964
sl@0
   965
TInt TModeSense6SenseState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
   966
    {
sl@0
   967
	__MSFNLOG
sl@0
   968
    TInt ret = KErrCompletion;
sl@0
   969
    const TSenseInfo& senseInfo = aFsm.MsSenseInfo();
sl@0
   970
sl@0
   971
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
   972
    if (senseInfo.iSenseCode == TSenseInfo::EIllegalRequest)
sl@0
   973
        {
sl@0
   974
        aFsm.SetState(TMassStorageState::EConnectedState);
sl@0
   975
        }
sl@0
   976
    else
sl@0
   977
        {
sl@0
   978
        ret = TMassStorageState::SenseError(aFsm);
sl@0
   979
        }
sl@0
   980
    return ret;
sl@0
   981
    };
sl@0
   982
sl@0
   983
sl@0
   984
TInt TModeSense6SenseState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
   985
    {
sl@0
   986
	__MSFNLOG
sl@0
   987
    aFsm.SetState(EInquirySenseState);
sl@0
   988
    return KErrCompletion;
sl@0
   989
    }
sl@0
   990
sl@0
   991
sl@0
   992
sl@0
   993
/**
sl@0
   994
sl@0
   995
*/
sl@0
   996
TConnectedState::TConnectedState()
sl@0
   997
:   TMassStorageState(EConnectedState)
sl@0
   998
    {
sl@0
   999
	__MSFNLOG
sl@0
  1000
    }
sl@0
  1001
sl@0
  1002
sl@0
  1003
TMassStorage::TEvent TConnectedState::EntryL(CMassStorageFsm& /* aFsm */)
sl@0
  1004
    {
sl@0
  1005
	__MSFNLOG
sl@0
  1006
    return TMassStorage::EEvCommandPassed;
sl@0
  1007
    };
sl@0
  1008
sl@0
  1009
sl@0
  1010
TInt TConnectedState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
  1011
    {
sl@0
  1012
	__MSFNLOG
sl@0
  1013
    TInt ret = KErrNone;
sl@0
  1014
sl@0
  1015
    if (aFsm.IsRemovableMedia())
sl@0
  1016
        {
sl@0
  1017
		if(aFsm.IsStatusCheck())
sl@0
  1018
			{
sl@0
  1019
			aFsm.SetState(TMassStorageState::EStatusCheckState);
sl@0
  1020
			}
sl@0
  1021
		else
sl@0
  1022
            {
sl@0
  1023
            aFsm.SetState(TMassStorageState::EAllowRemovalState);
sl@0
  1024
            }
sl@0
  1025
        }
sl@0
  1026
    else if (aFsm.StartStopUnitRequired())
sl@0
  1027
        {
sl@0
  1028
        aFsm.SetState(TMassStorageState::EStopUnitState);
sl@0
  1029
        }
sl@0
  1030
    else
sl@0
  1031
        {
sl@0
  1032
		aFsm.SetState(TMassStorageState::ENotReadyState);
sl@0
  1033
		ret = KErrCompletion;
sl@0
  1034
        }
sl@0
  1035
    return ret;
sl@0
  1036
    };
sl@0
  1037
sl@0
  1038
sl@0
  1039
TInt TConnectedState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
  1040
    {
sl@0
  1041
	__MSFNLOG
sl@0
  1042
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
  1043
    return KErrCompletion;
sl@0
  1044
    }
sl@0
  1045
sl@0
  1046
sl@0
  1047
/**
sl@0
  1048
sl@0
  1049
*/
sl@0
  1050
TStatusCheckState::TStatusCheckState()
sl@0
  1051
:   TMassStorageState(EStatusCheckState)
sl@0
  1052
    {
sl@0
  1053
	__MSFNLOG
sl@0
  1054
    }
sl@0
  1055
sl@0
  1056
sl@0
  1057
TMassStorage::TEvent TStatusCheckState::EntryL(CMassStorageFsm& aFsm)
sl@0
  1058
    {
sl@0
  1059
	__MSFNLOG
sl@0
  1060
    return aFsm.TestUnitReadyL();
sl@0
  1061
    };
sl@0
  1062
sl@0
  1063
sl@0
  1064
TInt TStatusCheckState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
  1065
    {
sl@0
  1066
	__MSFNLOG
sl@0
  1067
    aFsm.SetState(EConnectedState);
sl@0
  1068
    return KErrCompletion;
sl@0
  1069
    };
sl@0
  1070
sl@0
  1071
sl@0
  1072
TInt TStatusCheckState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
  1073
    {
sl@0
  1074
	__MSFNLOG
sl@0
  1075
	aFsm.SetState(ESenseState);
sl@0
  1076
    return KErrNone;
sl@0
  1077
    }
sl@0
  1078
sl@0
  1079
sl@0
  1080
/**
sl@0
  1081
sl@0
  1082
*/
sl@0
  1083
TAllowMediumRemovalState::TAllowMediumRemovalState()
sl@0
  1084
:   TMassStorageState(EAllowRemovalState)
sl@0
  1085
    {
sl@0
  1086
	__MSFNLOG
sl@0
  1087
    }
sl@0
  1088
sl@0
  1089
sl@0
  1090
TMassStorage::TEvent TAllowMediumRemovalState::EntryL(CMassStorageFsm& aFsm)
sl@0
  1091
    {
sl@0
  1092
	__MSFNLOG
sl@0
  1093
    return aFsm.PreventAllowMediumRemovalL(EFalse);
sl@0
  1094
    }
sl@0
  1095
sl@0
  1096
sl@0
  1097
TInt TAllowMediumRemovalState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
  1098
    {
sl@0
  1099
	__MSFNLOG
sl@0
  1100
    TInt ret = KErrNone;
sl@0
  1101
    if (aFsm.StartStopUnitRequired())
sl@0
  1102
        {
sl@0
  1103
        aFsm.SetState(TMassStorageState::EStopUnitState);
sl@0
  1104
        }
sl@0
  1105
    else
sl@0
  1106
        {
sl@0
  1107
        aFsm.SetState(ENotReadyState);
sl@0
  1108
        ret = KErrCompletion;
sl@0
  1109
        }
sl@0
  1110
    return ret;
sl@0
  1111
    };
sl@0
  1112
sl@0
  1113
sl@0
  1114
TInt TAllowMediumRemovalState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
  1115
    {
sl@0
  1116
	__MSFNLOG
sl@0
  1117
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
  1118
    return KErrCompletion;
sl@0
  1119
    }
sl@0
  1120
sl@0
  1121
sl@0
  1122
/**
sl@0
  1123
sl@0
  1124
*/
sl@0
  1125
TStopUnitState::TStopUnitState()
sl@0
  1126
:   TMassStorageState(EStopUnitState)
sl@0
  1127
    {
sl@0
  1128
	__MSFNLOG
sl@0
  1129
    }
sl@0
  1130
sl@0
  1131
sl@0
  1132
TMassStorage::TEvent TStopUnitState::EntryL(CMassStorageFsm& aFsm)
sl@0
  1133
    {
sl@0
  1134
	__MSFNLOG
sl@0
  1135
    return aFsm.StartStopUnitL(EFalse);
sl@0
  1136
    }
sl@0
  1137
sl@0
  1138
sl@0
  1139
TInt TStopUnitState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
  1140
    {
sl@0
  1141
	__MSFNLOG
sl@0
  1142
    aFsm.SetState(ENotReadyState);
sl@0
  1143
    return KErrCompletion;
sl@0
  1144
    };
sl@0
  1145
sl@0
  1146
sl@0
  1147
TInt TStopUnitState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
  1148
    {
sl@0
  1149
	__MSFNLOG
sl@0
  1150
    aFsm.SetState(TMassStorageState::EInquiryState);
sl@0
  1151
    return KErrCompletion;
sl@0
  1152
    }
sl@0
  1153
sl@0
  1154
sl@0
  1155
/**
sl@0
  1156
sl@0
  1157
*/
sl@0
  1158
TSenseState::TSenseState()
sl@0
  1159
:   TMassStorageState(EConnectedState)
sl@0
  1160
    {
sl@0
  1161
	__MSFNLOG
sl@0
  1162
    }
sl@0
  1163
sl@0
  1164
sl@0
  1165
TMassStorage::TEvent TSenseState::EntryL(CMassStorageFsm& aFsm)
sl@0
  1166
    {
sl@0
  1167
	__MSFNLOG
sl@0
  1168
    return aFsm.SenseL();
sl@0
  1169
    };
sl@0
  1170
sl@0
  1171
sl@0
  1172
TInt TSenseState::ScsiCommandPassed(CMassStorageFsm& aFsm)
sl@0
  1173
    {
sl@0
  1174
	__MSFNLOG
sl@0
  1175
    aFsm.SetState(ENotReadyState);
sl@0
  1176
    return KErrCompletion;
sl@0
  1177
    };
sl@0
  1178
sl@0
  1179
sl@0
  1180
TInt TSenseState::ScsiCommandFailed(CMassStorageFsm& aFsm)
sl@0
  1181
    {
sl@0
  1182
	__MSFNLOG
sl@0
  1183
    // This event should not happen
sl@0
  1184
    aFsm.SetState(EInquiryState);
sl@0
  1185
    return KErrCompletion;
sl@0
  1186
    }
sl@0
  1187