userlibandfileserver/fileserver/shostmassstorage/msproxy/hostusbmsfactory.cpp
author hgs
Tue, 02 Nov 2010 15:42:21 +0000
changeset 301 172f33f13d7d
parent 300 1d28c8722707
permissions -rw-r--r--
201043_12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
300
1d28c8722707 201043_09
hgs
parents: 0
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
//
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
 @file
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    18
 @internalTechnology
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    19
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    20
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    21
#include <f32fsys.h>
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    22
#include <e32property.h>
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    23
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    24
#include "hostusbmsproxy.h"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    25
#include "hostusbmsfactory.h"
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    26
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    27
#include "OstTraceDefinitions.h"
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    28
#ifdef OST_TRACE_COMPILER_IN_USE
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    29
#include "hostusbmsfactoryTraces.h"
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    30
#endif
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    31
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    32
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    33
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    34
CUsbHostMsProxyDriveFactory::CUsbHostMsProxyDriveFactory()
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    35
    {
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    36
    }
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
CUsbHostMsProxyDriveFactory::~CUsbHostMsProxyDriveFactory()
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    39
    {
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    40
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    41
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    42
TInt CUsbHostMsProxyDriveFactory::Install()
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    43
    {
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    44
    _LIT(KLoggerName,"usbhostms");
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    45
    return SetName(&KLoggerName);
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    46
    }
0
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
TInt CUsbHostMsProxyDriveFactory::CreateProxyDrive(CProxyDrive*& aMountProxyDrive,CMountCB* aMount)
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    49
    {
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    50
    aMountProxyDrive = new CUsbHostMsProxyDrive(aMount,this);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    51
    return (aMountProxyDrive==NULL) ? KErrNoMemory : KErrNone;
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    52
    }
0
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
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    55
extern "C" {
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    56
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    57
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    58
/*
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    59
Create the proxy drive factory object for the usbhost mass storage proxy
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    60
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    61
EXPORT_C CExtProxyDriveFactory* CreateFileSystem()
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    62
    {
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    63
    return new CUsbHostMsProxyDriveFactory();
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    64
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    65
}
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    66
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    67
/*
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    68
This function will be called to kick off a speculative probe for USB mass storage devices.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    69
This function issues an application session request (through publish and subscribe) to the USB manager.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    70
Upon USB Manager receiving this application session request in consent with the USB watcher application,
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    71
the Bus request is passed to the OTG  component to bringup the VBus, thus enumerating the mass storage
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    72
devices Upon enumerating the FDF will communicate with the Mount Manager which will allocate mass storage
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    73
drives for the logical units and continues drive access through the Usb host mass storage proxy drive.
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
Ps: Note that the this request cant be handled by the MSC since, in the scenario where MSC is not running
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    76
initially, the request will try to create the process. Creation of process will involve the file server inturn
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    77
to load the MSC binary (.exe) to run. Since the RMessages are handled sequentially, the file server would not
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    78
be able to service the request until the AsyncEnuerate is completed. Where, the process creation will wait
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    79
for the rendezvous to complete creating the deadlock situation. Hence the application session request is handled
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    80
in the factory object itself!
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    81
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    82
void CUsbHostMsProxyDriveFactory::AsyncEnumerate()
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    83
{
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    84
    RProperty prop;
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    85
    TInt ret;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    86
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    87
    /* The property category is the USB manager */
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    88
    const TUid KUidUsbManCategory={0x101fe1db};
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    89
    /* The Key used is #6 for the Usb request session */
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    90
    const TInt KUsbRequestSessionProperty = 6;
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    91
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    92
    /* By this time the property should be available and allow us to get the handle.
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    93
        If the property is not created (for some reason), we do not have anything to do */
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    94
    ret = prop.Attach(KUidUsbManCategory, KUsbRequestSessionProperty);
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    95
    OstTrace1(TRACE_SHOSTMASSSTORAGE_PROXY, HOSTUSBMSFACTORY_11,
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    96
              "Property attach returned %d", ret);
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    97
    if(ret == KErrNone)
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    98
    {
300
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
    99
        /* The Usb Manager does not evaluate the value passed through this property.
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
   100
            We pass 1 (an arbitary value) for completion */
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
   101
        ret = prop.Set(KUidUsbManCategory, KUsbRequestSessionProperty, 1);
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
   102
        OstTrace1(TRACE_SHOSTMASSSTORAGE_PROXY, HOSTUSBMSFACTORY_12,
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
   103
                  "Property set returned %d", ret);
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
   104
        prop.Close();
1d28c8722707 201043_09
hgs
parents: 0
diff changeset
   105
    }
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   106
}
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   107