libraries/iosrv/client/memoryaccesscmd.cpp
changeset 0 7f656887cf89
child 86 849a0b46c767
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // memoryaccesscmd.cpp
       
     2 // 
       
     3 // Copyright (c) 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 #include <fshell/memoryaccesscmd.h>
       
    13 
       
    14 using namespace IoUtils;
       
    15 
       
    16 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
    17 __ASSERT_COMPILE(sizeof(RMemoryAccess) == sizeof(TUint32) * 3);
       
    18 #endif
       
    19 
       
    20 __ASSERT_COMPILE(sizeof(CMemoryAccessCommandBase) == 62*4); // Otherwise CCommandBase has changed or RMemoryAccess has
       
    21 
       
    22 EXPORT_C CMemoryAccessCommandBase::CMemoryAccessCommandBase()
       
    23 	: CCommandBase()
       
    24 	{
       
    25 	}
       
    26 
       
    27 EXPORT_C CMemoryAccessCommandBase::CMemoryAccessCommandBase(TUint aFlags)
       
    28 	: CCommandBase(aFlags)
       
    29 	{
       
    30 	}
       
    31 
       
    32 EXPORT_C void CMemoryAccessCommandBase::LoadMemoryAccessL()
       
    33 	{
       
    34 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
    35 	__ASSERT_COMPILE(_FOFF(CMemoryAccessCommandBase, iMemAccess) == 59*4); // Otherwise something strange has gone wrong in CCommandBase
       
    36 	if (iMemAccess.Handle()) return; // Already open
       
    37 
       
    38 	TInt err = RMemoryAccess::LoadDriver();
       
    39 	if (err != KErrAlreadyExists)
       
    40 		{
       
    41 		LeaveIfErr(err, _L("Couldn't load %S.LDD"), &KMemoryAccessName);
       
    42 		}
       
    43 	LeaveIfErr(iMemAccess.Open(), _L("Couldn't open RMemoryAccess"));
       
    44 #else
       
    45 	LeaveIfErr(KErrNotSupported, _L("Can't load memoryaccess because FSHELL_MEMORY_ACCESS_SUPPORT is not defined");
       
    46 #endif
       
    47 	}
       
    48 
       
    49 EXPORT_C CMemoryAccessCommandBase::~CMemoryAccessCommandBase()
       
    50 	{
       
    51 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
    52 	iMemAccess.Close();
       
    53 	// Don't unload memaccess, we want to keep loaded so it can monitor stuff
       
    54 #endif
       
    55 	}