os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/inc/cusbmsmountmanager.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/inc/cusbmsmountmanager.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,177 @@
1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// RUsbMsMountManager class.
1.18 +//
1.19 +//
1.20 +
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalTechnology
1.26 +*/
1.27 +
1.28 +#ifndef CUSBMSMOUNTMANAGER_H
1.29 +#define CUSBMSMONUTMANAGER_H
1.30 +
1.31 +
1.32 +class RUsbHubDriver;
1.33 +class TUsbInterfaceDescriptor;
1.34 +class TUsbDeviceDescriptor;
1.35 +class RUsbInterface;
1.36 +
1.37 +
1.38 +class TUsbPrint
1.39 + {
1.40 +public:
1.41 + TUsbPrint();
1.42 + void EnableDebug() {iDebug = ETrue;}
1.43 + void DisableDebug() {iDebug = EFalse;}
1.44 +
1.45 + void PrintTree(const TUsbGenericDescriptor& aDesc,
1.46 + TInt aDepth = 0);
1.47 +
1.48 + void PrintDescriptor(const TUsbDeviceDescriptor& aDeviceDesc,
1.49 + TInt aVariant = 0,
1.50 + RUsbDevice* aDevice = NULL);
1.51 +
1.52 + void PrintDescriptor(const TUsbConfigurationDescriptor& aConfigDesc,
1.53 + TInt aVariant = 0,
1.54 + RUsbDevice* aDevice = NULL);
1.55 +
1.56 + void PrintDescriptor(const TUsbEndpointDescriptor& aEndpointDesc,
1.57 + TInt aVariant = 0,
1.58 + RUsbDevice* aDevice = NULL);
1.59 +
1.60 + void PrintDescriptor(const TUsbStringDescriptor& aStringDesc,
1.61 + TInt aVariant = 0,
1.62 + RUsbDevice* aDevice = NULL);
1.63 +
1.64 + void PrintDescriptor(const TUsbInterfaceDescriptor& aInterfaceDesc,
1.65 + TInt aVariant = 0,
1.66 + RUsbDevice* aDevice = NULL);
1.67 +
1.68 +private:
1.69 + void SetLanguageToPrintL(RUsbDevice& aDevice);
1.70 +
1.71 + void PrintStringFromIndex(const TDesC& aFormatString,
1.72 + TInt aIndex,
1.73 + RUsbDevice* aDevice);
1.74 +
1.75 + TBool iDebug;
1.76 + };
1.77 +
1.78 +
1.79 +class CDevice : public CBase
1.80 + {
1.81 +public:
1.82 + static const TInt KMaxLun = 16;
1.83 +
1.84 +public:
1.85 + static CDevice* NewL();
1.86 + ~CDevice();
1.87 +private:
1.88 + void ConstructL();
1.89 + CDevice();
1.90 +
1.91 +public:
1.92 + TToken OpenDeviceL(TUint aDeviceHandle, RUsbHubDriver& aHub);
1.93 + void CloseDeviceL();
1.94 +
1.95 + void MountLogicalUnitsL();
1.96 + void DismountLogicalUnitsL();
1.97 + TToken DeviceToken() const {return iDeviceToken;};
1.98 + TUint DeviceHandle() const {return iDeviceHandle;};
1.99 +
1.100 + TLun DriveMap(TDriveMap& aDriveMap) const;
1.101 + TLun DeviceMap(TDeviceMap& aDeviceMap) const;
1.102 +
1.103 +
1.104 +private:
1.105 + TBool IsDeviceMassStorage(const TUsbInterfaceDescriptor& aInterfaceDesc,
1.106 + const TUsbDeviceDescriptor& aDeviceDesc) const;
1.107 +
1.108 + TInt GetEndpointAddress(RUsbInterface& aUsbInterface,
1.109 + TInt aInterfaceSetting,
1.110 + TUint8 aTransferType,
1.111 + TUint8 aDirection,
1.112 + TInt& aEndpointAddress) const;
1.113 +
1.114 +
1.115 +
1.116 +private:
1.117 + RUsbDevice iUsbDevice;
1.118 + TUint iDeviceHandle;
1.119 +
1.120 + RUsbHostMsDevice iUsbHostMsDevice;
1.121 +
1.122 + TToken iDeviceToken;
1.123 + TLun iNumLuns;
1.124 +
1.125 + RExtFileSystem iExt;
1.126 +
1.127 + // index is mapped to LUN
1.128 + RArray<TDriveNumber> iLuList;
1.129 +
1.130 + THostMassStorageConfig iMsConfig;
1.131 +
1.132 + TUsbPrint iUsbPrint;
1.133 + };
1.134 +
1.135 +
1.136 +class CUsbMsMountManager : public CBase
1.137 + {
1.138 +public:
1.139 + static CUsbMsMountManager* NewL();
1.140 + ~CUsbMsMountManager();
1.141 +private:
1.142 + void ConstructL();
1.143 + CUsbMsMountManager();
1.144 +
1.145 +public:
1.146 + TInt DevicesNumber() const;
1.147 + void DriveMap(TDriveMap& aDriveMap) const;
1.148 + void DeviceMap(TInt aDeviceIndex, TDeviceMap& aDeviceMap) const;
1.149 +
1.150 +
1.151 +public:
1.152 + // adds new device entry for this device
1.153 + void AddDeviceL(CDevice* aDevice);
1.154 + // removes device entry for this device
1.155 + CDevice* RemoveDeviceL(TUint aDeviceHandle);
1.156 +
1.157 + void CloseAllDevicesL();
1.158 +
1.159 + // mounts all LUNs for the device
1.160 + void MountDeviceL(TUint aDeviceHandle);
1.161 + // dismount all LUNs for this device
1.162 + void DismountDeviceL(TUint aDeviceHandle);
1.163 + // dismount all LUNs
1.164 + void DismountL();
1.165 +
1.166 +private:
1.167 + TInt GetDeviceIndexL(TToken aDeviceToken) const;
1.168 + TInt GetHandleIndexL(TUint aDeviceHandle) const;
1.169 +
1.170 +private:
1.171 + RPointerArray<CDevice> iDeviceList;
1.172 + };
1.173 +
1.174 +
1.175 +inline TInt CUsbMsMountManager::DevicesNumber() const
1.176 + {
1.177 + return iDeviceList.Count();
1.178 + }
1.179 +
1.180 +#endif // CUSBMSMOUNTMANAGER_H