os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/msproxy/hostusbmsfactory.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/msproxy/hostusbmsfactory.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,106 @@
1.4 +// Copyright (c) 2008-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 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @internalTechnology
1.22 +*/
1.23 +
1.24 +#include <f32fsys.h>
1.25 +#include <e32property.h>
1.26 +
1.27 +#include "hostusbmsproxy.h"
1.28 +#include "hostusbmsfactory.h"
1.29 +#include "debug.h"
1.30 +
1.31 +CUsbHostMsProxyDriveFactory::CUsbHostMsProxyDriveFactory()
1.32 + {
1.33 + __MSFNSLOG
1.34 + }
1.35 +
1.36 +CUsbHostMsProxyDriveFactory::~CUsbHostMsProxyDriveFactory()
1.37 + {
1.38 + __MSFNSLOG
1.39 + }
1.40 +
1.41 +TInt CUsbHostMsProxyDriveFactory::Install()
1.42 + {
1.43 + __MSFNSLOG
1.44 + _LIT(KLoggerName,"usbhostms");
1.45 + return SetName(&KLoggerName);
1.46 + }
1.47 +
1.48 +TInt CUsbHostMsProxyDriveFactory::CreateProxyDrive(CProxyDrive*& aMountProxyDrive,CMountCB* aMount)
1.49 + {
1.50 + __MSFNSLOG
1.51 + aMountProxyDrive = new CUsbHostMsProxyDrive(aMount,this);
1.52 + return (aMountProxyDrive==NULL) ? KErrNoMemory : KErrNone;
1.53 + }
1.54 +
1.55 +
1.56 +extern "C" {
1.57 +
1.58 +
1.59 +/*
1.60 +Create the proxy drive factory object for the usbhost mass storage proxy
1.61 +*/
1.62 +EXPORT_C CExtProxyDriveFactory* CreateFileSystem()
1.63 + {
1.64 + __MSFNSLOG
1.65 + return new CUsbHostMsProxyDriveFactory();
1.66 + }
1.67 +}
1.68 +
1.69 +/*
1.70 +This function will be called to kick off a speculative probe for USB mass storage devices.
1.71 +This function issues an application session request (through publish and subscribe) to the USB manager.
1.72 +Upon USB Manager receiving this application session request in consent with the USB watcher application,
1.73 +the Bus request is passed to the OTG component to bringup the VBus, thus enumerating the mass storage
1.74 +devices Upon enumerating the FDF will communicate with the Mount Manager which will allocate mass storage
1.75 +drives for the logical units and continues drive access through the Usb host mass storage proxy drive.
1.76 +
1.77 +Ps: Note that the this request cant be handled by the MSC since, in the scenario where MSC is not running
1.78 +initially, the request will try to create the process. Creation of process will involve the file server inturn
1.79 +to load the MSC binary (.exe) to run. Since the RMessages are handled sequentially, the file server would not
1.80 +be able to service the request until the AsyncEnuerate is completed. Where, the process creation will wait
1.81 +for the rendezvous to complete creating the deadlock situation. Hence the application session request is handled
1.82 +in the factory object itself!
1.83 +*/
1.84 +void CUsbHostMsProxyDriveFactory::AsyncEnumerate()
1.85 +{
1.86 + __MSFNSLOG
1.87 +
1.88 + RProperty prop;
1.89 + TInt ret;
1.90 +
1.91 + /* The property category is the USB manager */
1.92 + const TUid KUidUsbManCategory={0x101fe1db};
1.93 + /* The Key used is #6 for the Usb request session */
1.94 + const TInt KUsbRequestSessionProperty = 6;
1.95 +
1.96 + /* By this time the property should be available and allow us to get the handle.
1.97 + If the property is not created (for some reason), we do not have anything to do */
1.98 + ret = prop.Attach(KUidUsbManCategory, KUsbRequestSessionProperty);
1.99 + __PXYPRINT1(_L("Property attach returned %d"),ret);
1.100 + if(ret == KErrNone)
1.101 + {
1.102 + /* The Usb Manager does not evaluate the value passed through this property.
1.103 + We pass 1 (an arbitary value) for completion */
1.104 + ret = prop.Set(KUidUsbManCategory, KUsbRequestSessionProperty, 1);
1.105 + __PXYPRINT1(_L("Property set returned %d"),ret);
1.106 + prop.Close();
1.107 + }
1.108 +}
1.109 +