os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/inc/cusbmsmountmanager.h
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) 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
// RUsbMsMountManager class.
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file
sl@0
    22
 @internalTechnology
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef CUSBMSMOUNTMANAGER_H
sl@0
    26
#define CUSBMSMONUTMANAGER_H
sl@0
    27
sl@0
    28
sl@0
    29
class RUsbHubDriver;
sl@0
    30
class TUsbInterfaceDescriptor;
sl@0
    31
class TUsbDeviceDescriptor;
sl@0
    32
class RUsbInterface;
sl@0
    33
sl@0
    34
sl@0
    35
class TUsbPrint
sl@0
    36
    {
sl@0
    37
public:
sl@0
    38
    TUsbPrint();
sl@0
    39
    void EnableDebug() {iDebug = ETrue;}
sl@0
    40
    void DisableDebug() {iDebug = EFalse;}
sl@0
    41
sl@0
    42
    void PrintTree(const TUsbGenericDescriptor& aDesc,
sl@0
    43
                   TInt aDepth = 0);
sl@0
    44
sl@0
    45
    void PrintDescriptor(const TUsbDeviceDescriptor& aDeviceDesc,
sl@0
    46
                         TInt aVariant = 0,
sl@0
    47
                         RUsbDevice* aDevice = NULL);
sl@0
    48
sl@0
    49
    void PrintDescriptor(const TUsbConfigurationDescriptor& aConfigDesc,
sl@0
    50
                         TInt aVariant = 0,
sl@0
    51
                         RUsbDevice* aDevice = NULL);
sl@0
    52
sl@0
    53
    void PrintDescriptor(const TUsbEndpointDescriptor& aEndpointDesc,
sl@0
    54
                         TInt aVariant = 0,
sl@0
    55
                         RUsbDevice* aDevice = NULL);
sl@0
    56
sl@0
    57
    void PrintDescriptor(const TUsbStringDescriptor& aStringDesc,
sl@0
    58
                         TInt aVariant = 0,
sl@0
    59
                         RUsbDevice* aDevice = NULL);
sl@0
    60
sl@0
    61
    void PrintDescriptor(const TUsbInterfaceDescriptor& aInterfaceDesc,
sl@0
    62
                         TInt aVariant = 0,
sl@0
    63
                         RUsbDevice* aDevice = NULL);
sl@0
    64
sl@0
    65
private:
sl@0
    66
    void SetLanguageToPrintL(RUsbDevice& aDevice);
sl@0
    67
sl@0
    68
    void PrintStringFromIndex(const TDesC& aFormatString,
sl@0
    69
                              TInt aIndex,
sl@0
    70
                              RUsbDevice* aDevice);
sl@0
    71
sl@0
    72
    TBool iDebug;
sl@0
    73
    };
sl@0
    74
sl@0
    75
sl@0
    76
class CDevice : public CBase
sl@0
    77
    {
sl@0
    78
public:
sl@0
    79
    static const TInt KMaxLun = 16;
sl@0
    80
sl@0
    81
public:
sl@0
    82
    static CDevice* NewL();
sl@0
    83
    ~CDevice();
sl@0
    84
private:
sl@0
    85
    void ConstructL();
sl@0
    86
    CDevice();
sl@0
    87
sl@0
    88
public:
sl@0
    89
    TToken OpenDeviceL(TUint aDeviceHandle, RUsbHubDriver& aHub);
sl@0
    90
    void CloseDeviceL();
sl@0
    91
sl@0
    92
    void MountLogicalUnitsL();
sl@0
    93
    void DismountLogicalUnitsL();
sl@0
    94
    TToken DeviceToken() const {return iDeviceToken;};
sl@0
    95
    TUint DeviceHandle() const {return iDeviceHandle;};
sl@0
    96
sl@0
    97
    TLun DriveMap(TDriveMap& aDriveMap) const;
sl@0
    98
    TLun DeviceMap(TDeviceMap& aDeviceMap) const;
sl@0
    99
sl@0
   100
sl@0
   101
private:
sl@0
   102
    TBool IsDeviceMassStorage(const TUsbInterfaceDescriptor& aInterfaceDesc,
sl@0
   103
                              const TUsbDeviceDescriptor& aDeviceDesc) const;
sl@0
   104
sl@0
   105
    TInt GetEndpointAddress(RUsbInterface& aUsbInterface,
sl@0
   106
                            TInt aInterfaceSetting,
sl@0
   107
                            TUint8 aTransferType,
sl@0
   108
                            TUint8 aDirection,
sl@0
   109
                            TInt& aEndpointAddress) const;
sl@0
   110
sl@0
   111
sl@0
   112
sl@0
   113
private:
sl@0
   114
    RUsbDevice iUsbDevice;
sl@0
   115
    TUint iDeviceHandle;
sl@0
   116
sl@0
   117
    RUsbHostMsDevice iUsbHostMsDevice;
sl@0
   118
sl@0
   119
    TToken iDeviceToken;
sl@0
   120
    TLun iNumLuns;
sl@0
   121
sl@0
   122
    RExtFileSystem iExt;
sl@0
   123
sl@0
   124
    // index is mapped to LUN
sl@0
   125
    RArray<TDriveNumber> iLuList;
sl@0
   126
sl@0
   127
    THostMassStorageConfig iMsConfig;
sl@0
   128
sl@0
   129
    TUsbPrint iUsbPrint;
sl@0
   130
    };
sl@0
   131
sl@0
   132
sl@0
   133
class CUsbMsMountManager : public CBase
sl@0
   134
    {
sl@0
   135
public:
sl@0
   136
	static CUsbMsMountManager* NewL();
sl@0
   137
	~CUsbMsMountManager();
sl@0
   138
private:
sl@0
   139
    void ConstructL();
sl@0
   140
	CUsbMsMountManager();
sl@0
   141
sl@0
   142
public:
sl@0
   143
    TInt DevicesNumber() const;
sl@0
   144
    void DriveMap(TDriveMap& aDriveMap) const;
sl@0
   145
    void DeviceMap(TInt aDeviceIndex, TDeviceMap& aDeviceMap) const;
sl@0
   146
sl@0
   147
sl@0
   148
public:
sl@0
   149
    // adds new device entry for this device
sl@0
   150
    void AddDeviceL(CDevice* aDevice);
sl@0
   151
    // removes device entry for this device
sl@0
   152
    CDevice* RemoveDeviceL(TUint aDeviceHandle);
sl@0
   153
sl@0
   154
    void CloseAllDevicesL();
sl@0
   155
sl@0
   156
    // mounts all LUNs for the device
sl@0
   157
    void MountDeviceL(TUint aDeviceHandle);
sl@0
   158
    // dismount all LUNs for this device
sl@0
   159
    void DismountDeviceL(TUint aDeviceHandle);
sl@0
   160
    // dismount all LUNs
sl@0
   161
    void DismountL();
sl@0
   162
sl@0
   163
private:
sl@0
   164
    TInt GetDeviceIndexL(TToken aDeviceToken) const;
sl@0
   165
    TInt GetHandleIndexL(TUint aDeviceHandle) const;
sl@0
   166
sl@0
   167
private:
sl@0
   168
    RPointerArray<CDevice> iDeviceList;
sl@0
   169
    };
sl@0
   170
sl@0
   171
sl@0
   172
inline TInt CUsbMsMountManager::DevicesNumber() const
sl@0
   173
    {
sl@0
   174
    return iDeviceList.Count();
sl@0
   175
    }
sl@0
   176
sl@0
   177
#endif // CUSBMSMOUNTMANAGER_H