userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbhostmsdevicethread.cpp
author hgs
Tue, 02 Nov 2010 15:29:23 +0000
changeset 300 1d28c8722707
parent 271 dc268b18d709
permissions -rw-r--r--
201043_09
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
124
5802e2ce68ed 201015_14
hgs
parents: 33
diff changeset
     1
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     2
// All rights reserved.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     3
// This component and the accompanying materials are made available
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     5
// which accompanies this distribution, and is available
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     7
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     8
// Initial Contributors:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    10
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    11
// Contributors:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    12
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    13
// Description:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    14
// Implements a Session of a Symbian OS server for the RUsbMassStorage API
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    15
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    16
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    17
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    18
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    19
 @file
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    20
 @internalTechnology
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    21
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    22
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    23
#include <e32base.h>
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    24
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    25
#include "msctypes.h"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    26
#include "shared.h"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    27
#include "msgservice.h"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    28
#include "cusbhostmslogicalunit.h"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    29
#include "cusbhostmsdevice.h"
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    30
#include "cusbhostmssession.h"
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    31
#include "cusbhostmsdevicethread.h"
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    32
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    33
#include "OstTraceDefinitions.h"
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    34
#ifdef OST_TRACE_COMPILER_IN_USE
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    35
#include "cusbhostmsdevicethreadTraces.h"
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    36
#endif
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    37
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    38
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    39
Constructor
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    40
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    41
TDeviceHandler::TDeviceHandler(CUsbHostMsDevice& aDevice)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    42
:   iDevice(aDevice)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    43
    {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    44
    }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    45
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    46
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    47
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    48
   Services messages directed to a device. Messages associated with a single
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    49
   Logical Unit contained by the device are forwarded to the Logical Unit
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    50
   Handler.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    51
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    52
   @param aMessage
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    53
 */
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    54
void TDeviceHandler::HandleMessageL(const RMessage2& aMessage)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    55
    {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    56
    TLun lun = iDevice.GetAndSetLunL(aMessage);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    57
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    58
    switch (aMessage.Function())
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    59
        {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    60
    case EUsbHostMsSuspendLun:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    61
        iDevice.SuspendLunL(lun);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    62
        break;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    63
    case EUsbHostMsUnRegisterLun:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    64
        iDevice.RemoveLunL(lun);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    65
        break;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    66
    default:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    67
        // Try Logical Unit Handler
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    68
        CUsbHostMsLogicalUnit& lu = iDevice.GetLuL(lun);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    69
        TLogicalUnitHandler luHandler(lu);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    70
        luHandler.HandleMessageL(aMessage);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    71
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    72
        }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    73
    }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    74
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    75
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    76
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    77
   Constructor
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    78
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    79
   @param aLu Reference to the logical unit object
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    80
 */
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    81
TLogicalUnitHandler::TLogicalUnitHandler(CUsbHostMsLogicalUnit& aLu)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    82
:   iLu(aLu)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    83
    {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    84
    }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    85
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    86
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    87
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    88
   Services messages directed to a specific Logical Unit. Unrecognized messages
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    89
   will cause a PANIC.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    90
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    91
   @param aMessage
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    92
 */
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    93
void TLogicalUnitHandler::HandleMessageL(const RMessage2& aMessage)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    94
    {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    95
    switch (aMessage.Function())
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    96
        {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    97
    case EUsbHostMsNotifyChange:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    98
        iLu.NotifyChange(aMessage);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
    99
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   100
    case EUsbHostMsCancelChangeNotifier:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   101
        iLu.CancelChangeNotifierL();
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   102
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   103
    case EUsbHostMsForceRemount:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   104
        iLu.ForceCompleteNotifyChangeL();
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   105
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   106
    case EUsbHostMsRead:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   107
        iLu.ReadL(aMessage);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   108
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   109
    case EUsbHostMsWrite:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   110
        iLu.WriteL(aMessage);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   111
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   112
    case EUsbHostMsErase:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   113
        iLu.EraseL(aMessage);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   114
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   115
    case EUsbHostMsCapacity:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   116
        iLu.CapsL(aMessage);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   117
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   118
    default:
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   119
        aMessage.Panic(KUsbHostMsSrvPncCat, EUsbMsPanicIllegalIPC);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   120
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   121
        }
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   122
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   123
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   124
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   125
void CUsbHostMsDeviceThread::DoStartServerL(TAny* aPtr)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   126
    {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   127
    CActiveScheduler* s = new(ELeave) CActiveScheduler;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   128
    CActiveScheduler::Install(s);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   129
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   130
    CUsbHostMsDeviceThread* iThread = (CUsbHostMsDeviceThread*)aPtr;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   131
    CActiveScheduler::Add(iThread);
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   132
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   133
    iThread->Start();
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   134
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   135
    RThread::Rendezvous(KErrNone);
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   136
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   137
    //
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   138
    // Ready to run
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   139
    CActiveScheduler::Start();
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   140
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   141
    //
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   142
    // Cleanup the scheduler
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   143
    delete s;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   144
    }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   145
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   146
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   147
TInt CUsbHostMsDeviceThread::Entry(TAny* aPtr)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   148
    {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   149
    CTrapCleanup* cleanup = CTrapCleanup::New();
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   150
    if (!cleanup)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   151
        {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   152
        return KErrNoMemory;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   153
        }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   154
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   155
    TRAPD(error, DoStartServerL(aPtr));
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   156
    delete cleanup;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   157
    return error;
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   158
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   159
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   160
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   161
void  CUsbHostMsDeviceThread::RunL()
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   162
    {
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   163
    // called on completion of MessageRequest() or Resume()
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   164
    User::LeaveIfError(iStatus.Int());
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   165
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   166
    Lock();
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   167
    if (iUsbHostMsDevice)
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   168
        {
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   169
        if (iUsbHostMsDevice->IsSuspended())
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   170
            {
271
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   171
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   172
            RMessage2 msg = iRMessage2[iDequeueIndex];
271
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   173
            if (msg.Function() != EUsbHostMsSuspendLun)
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   174
                {
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   175
                // request resume
271
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   176
                Unlock();
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   177
                iUsbHostMsDevice->Resume(iStatus);
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   178
                SetActive();
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   179
                return;
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   180
                }
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   181
            }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   182
        }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   183
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   184
    // process message queue
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   185
    RMessage2 msg = iRMessage2[iDequeueIndex];
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   186
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   187
    iDequeueIndex++;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   188
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   189
    if(iDequeueIndex >= KMaxNumMessage)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   190
        iDequeueIndex = 0;
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   191
    if(iQueueFull)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   192
        iQueueFull = EFalse;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   193
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   194
    HandleMessage(msg);
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   195
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   196
    if ((iQueueIndex != iDequeueIndex) || iQueueFull)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   197
        {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   198
        // self completion
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   199
        TRequestStatus* status = &iStatus;
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   200
        User::RequestComplete(status, KErrNone);
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   201
        SetActive();
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   202
        }
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   203
    else
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   204
        {
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   205
        iUsbHostMsSession.MessageRequest(iStatus);
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   206
        SetActive();
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   207
        }
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   208
    Unlock();
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   209
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   210
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   211
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   212
void CUsbHostMsDeviceThread::DoCancel()
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   213
    {
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   214
    TRequestStatus* status = &iStatus;
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   215
    User::RequestComplete(status, KErrCancel);
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   216
    }
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   217
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   218
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   219
TInt CUsbHostMsDeviceThread::RunError(TInt aError)
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   220
{
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   221
    OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_10,
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   222
              ">> HOST RunError returning %d", aError);
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   223
    return KErrNone;
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   224
}
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   225
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   226
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   227
TInt CUsbHostMsDeviceThread::QueueMsg(const RMessage2& aMsg)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   228
    {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   229
    if (iQueueFull)
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   230
        {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   231
        return KErrOverflow;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   232
        }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   233
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   234
    Lock();
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   235
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   236
    iRMessage2[iQueueIndex] = aMsg;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   237
    iQueueIndex++;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   238
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   239
    if (iQueueIndex >= KMaxNumMessage)
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   240
        {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   241
        iQueueIndex = 0;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   242
        }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   243
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   244
    if (iQueueIndex == iDequeueIndex)
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   245
        {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   246
        iQueueFull = ETrue;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   247
        }
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   248
    Unlock();
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   249
    return KErrNone;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   250
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   251
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   252
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   253
CUsbHostMsDeviceThread::CUsbHostMsDeviceThread(CUsbHostMsSession& aUsbHostMsSession, TUint aToken)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   254
:   CActive(EPriorityStandard),
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   255
    iUsbHostMsSession(aUsbHostMsSession),
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   256
    iQueueFull(EFalse)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   257
    {
33
0173bcd7697c Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   258
    TBuf<32> nameBuf;
0173bcd7697c Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   259
    nameBuf.Format(_L("Host Ms ThreadMutex%8x"), aToken);
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   260
    iMutex.CreateGlobal(nameBuf,EOwnerProcess);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   261
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   262
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   263
CUsbHostMsDeviceThread::~CUsbHostMsDeviceThread()
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   264
    {
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   265
    Cancel();
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   266
    iMutex.Close();
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   267
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   268
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   269
CUsbHostMsDeviceThread* CUsbHostMsDeviceThread::NewL(CUsbHostMsSession& aUsbHostMsSession, TUint aToken)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   270
    {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   271
    CUsbHostMsDeviceThread* r = new (ELeave) CUsbHostMsDeviceThread(aUsbHostMsSession, aToken);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   272
    return r;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   273
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   274
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   275
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   276
void CUsbHostMsDeviceThread::Start()
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   277
    {
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   278
    iUsbHostMsSession.MessageRequest(iStatus);
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   279
    SetActive();
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   280
    }
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   281
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   282
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   283
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   284
 Handles the request (in the form of a message) received from the client
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   285
@param  aMessage    The received message
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   286
 */
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   287
void CUsbHostMsDeviceThread::HandleMessage(const RMessage2& aMessage)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   288
    {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   289
    TInt ret = KErrNotReady;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   290
    OstTraceExt2(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_21,
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   291
              ">> HOST DispatchMessageL Function=%d %d",
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   292
              aMessage.Function(), aMessage.Int3());
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   293
    switch (aMessage.Function())
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   294
        {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   295
    case EUsbHostMsRegisterInterface:
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   296
        TRAP(ret, RegisterInterfaceL(aMessage));
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   297
        break;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   298
    case EUsbHostMsInitialiseInterface:
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   299
        TRAP(ret, InitialiseInterfaceL(aMessage));
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   300
        // CUsbInterfaceHandler::GetMaxLun() completes asynchronously
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   301
        if (ret)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   302
            {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   303
            // Error condition needs to be completed
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   304
            break;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   305
            }
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   306
        return;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   307
    case EUsbHostMsUnRegisterInterface:
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   308
        // Check whether all luns have got uninitialised.
271
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   309
        if (iUsbHostMsDevice)
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   310
            {
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   311
            for(TInt i = 0, j = iUsbHostMsDevice->GetMaxLun(); i <= j; i++)
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   312
                TRAP_IGNORE(iUsbHostMsDevice->RemoveLunL(i));
dc268b18d709 201037_07
hgs
parents: 176
diff changeset
   313
            }
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   314
        TRAP(ret, UnRegisterInterfaceL(aMessage));
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   315
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   316
    case EUsbHostMsRegisterLun:
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   317
        TRAP(ret, RegisterLogicalUnitL(aMessage));
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   318
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   319
    case EUsbHostMsGetNumLun:
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   320
        TRAP(ret, GetNumLunL(aMessage));
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   321
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   322
    case EUsbHostMsShutdown:
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   323
        ret = Shutdown();
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   324
        break;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   325
    default:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   326
        // Try Device Handler and Logical Unit Handler
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   327
        __ASSERT_DEBUG(iUsbHostMsDevice, User::Invariant());
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   328
        TDeviceHandler deviceHandler(*iUsbHostMsDevice);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   329
        TRAP(ret, deviceHandler.HandleMessageL(aMessage));
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   330
        break;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   331
        }
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   332
    OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_22,
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   333
              ">> HOST returning %d", ret);
31
56f325a607ea Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   334
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   335
    if (aMessage.Function() != EUsbHostMsNotifyChange)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   336
        {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   337
        aMessage.Complete(ret);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   338
        }
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   339
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   340
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   341
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   342
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   343
Client request to shut down the server
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   344
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   345
return KErrNone
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   346
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   347
TInt CUsbHostMsDeviceThread::Shutdown()
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   348
    {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   349
    CActiveScheduler::Stop();
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   350
    return KErrNone;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   351
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   352
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   353
void CUsbHostMsDeviceThread::GetNumLunL(const RMessage2& aMessage)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   354
    {
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   355
    if (!iUsbHostMsDevice)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   356
        {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   357
        User::Leave(KErrNotReady);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   358
        }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   359
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   360
    TUint32 maxLun = iUsbHostMsDevice->GetMaxLun() + 1;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   361
    TPtrC8 pLun((TUint8*)&maxLun,sizeof(TUint32));
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   362
    aMessage.WriteL(0,pLun);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   363
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   364
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   365
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   366
void CUsbHostMsDeviceThread::RegisterInterfaceL(const RMessage2& aMessage)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   367
    {
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   368
    THostMassStorageConfig msDeviceConfig;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   369
    TPtr8 ptr((TUint8*)&msDeviceConfig,sizeof(THostMassStorageConfig));
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   370
    aMessage.ReadL(0, ptr);
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   371
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   372
    OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_30,
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   373
              "RegisterInterfaceL Token=%d ", msDeviceConfig.iInterfaceToken);
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   374
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   375
    iUsbHostMsDevice = CUsbHostMsDevice::NewL(msDeviceConfig);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   376
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   377
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   378
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   379
void CUsbHostMsDeviceThread::InitialiseInterfaceL(const RMessage2& aMessage)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   380
    {
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   381
    if (!iUsbHostMsDevice)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   382
        {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   383
        User::Leave(KErrNotReady);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   384
        }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   385
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   386
    TRAPD(err, iUsbHostMsDevice->InitialiseL(aMessage));
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   387
    if (err != KErrNone)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   388
        {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   389
        delete iUsbHostMsDevice;
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   390
        iUsbHostMsDevice = NULL;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   391
        User::Leave(err);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   392
        }
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   393
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   394
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   395
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   396
void CUsbHostMsDeviceThread::UnRegisterInterfaceL(const RMessage2& aMessage)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   397
    {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   398
    if (!iUsbHostMsDevice)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   399
        {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   400
        User::Leave(KErrNotReady);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   401
        }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   402
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   403
    TRAPD(err, iUsbHostMsDevice->UnInitialiseL());
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   404
    delete iUsbHostMsDevice;
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   405
    iUsbHostMsDevice = NULL;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   406
    User::LeaveIfError(err);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   407
    }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   408
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   409
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   410
void CUsbHostMsDeviceThread::RegisterLogicalUnitL(const RMessage2& aMessage)
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   411
    {
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   412
    if (!iUsbHostMsDevice)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   413
        {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   414
        User::Leave(KErrNotReady);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   415
        }
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   416
300
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   417
    TUint32 iLunId = aMessage.Int0() + 1; // Subssessions need a positive value to store in the handles. We represent Luns as LunId+1
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   418
    TPtrC8 pLun((TUint8*)&iLunId, sizeof(TUint32));
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   419
    aMessage.WriteL(3, pLun);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   420
    iLunId -= 1;    // We represent LunId in MSC from 0 to MaxLun-1 as represented in BOT
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   421
    OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSDEVICETHREAD_31,
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   422
              "RegisterLogicalUnitL LUN=%d ", iLunId);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   423
    iUsbHostMsDevice->AddLunL(iLunId);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   424
    iUsbHostMsDevice->InitLunL(iLunId);
1d28c8722707 201043_09
hgs
parents: 271
diff changeset
   425
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   426