stvariants/montblanc/test/symbian/e32/timestamp/d_timestamp.cpp
changeset 14 cf4c5641c6dd
parent 12 a80bfc23ff0e
child 15 ac35e54b1f85
child 17 ce191d16bb9a
child 19 703c56cf2669
equal deleted inserted replaced
12:a80bfc23ff0e 14:cf4c5641c6dd
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <kern_priv.h>
       
    20 #include <kernel.h>
       
    21 #include "d_timestamp.h"
       
    22 #include "d_timestamp_dev.h"
       
    23 #include "power_info.h"
       
    24 #include "power_config.h"
       
    25 
       
    26 // Name for PDD, will be LDD name and this suffix
       
    27 _LIT(KTimestampPddSuffix,".8500");
       
    28 
       
    29 
       
    30 class D8500_TimestampTestPddChannel : public DTimestampTestPddChannel
       
    31 	{
       
    32 public:
       
    33 	// Inherited from DTimestampTestPddChanel. These called by the LDD.
       
    34 	virtual void StartLPMEntryCheck();
       
    35     virtual TBool EndLPMEntryCheck();
       
    36     virtual void TestConfig(STimestampTestConfig& aInfo);
       
    37 private:
       
    38 	TUint iInitialIdleCount;
       
    39 	};
       
    40 
       
    41 /**
       
    42   Logical Device (factory class) for D8500_TimestampTestPddChannel
       
    43 */
       
    44 class D8500_TimestampTestPddFactory : public DPhysicalDevice
       
    45 	{
       
    46 public:
       
    47 	D8500_TimestampTestPddFactory();
       
    48 	//	Inherited from DLogicalDevice
       
    49 	virtual TInt Install();
       
    50 	virtual void GetCaps(TDes8& aDes) const;
       
    51     virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
       
    52 	virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
       
    53 private:
       
    54     TVersion iVersion;
       
    55 	};
       
    56 
       
    57 //
       
    58 // D8500_TimestampTestPddFactory
       
    59 //
       
    60 
       
    61 /**
       
    62   Standard export function for PDDs. This creates a DPhysicalDevice derived object,
       
    63   in this case, our D8500_TimestampTestPddFactory
       
    64 */
       
    65 DECLARE_STANDARD_PDD()
       
    66 	{
       
    67 	return new D8500_TimestampTestPddFactory();
       
    68 	}
       
    69 
       
    70 /**
       
    71  * constructor
       
    72  */
       
    73 D8500_TimestampTestPddFactory::D8500_TimestampTestPddFactory()
       
    74 	{
       
    75 	// Set version number for this device
       
    76 	iVersion=RTimestampTest::VersionRequired();
       
    77 	}
       
    78 
       
    79 /**
       
    80   Second stage constructor for DPhysicalDevice derived objects.
       
    81   This must at least set a name for the driver object.
       
    82 
       
    83   @return KErrNone or standard error code.
       
    84 */
       
    85 TInt D8500_TimestampTestPddFactory::Install()
       
    86     {
       
    87     TName name(RTimestampTest::Name());
       
    88     name.Append(KTimestampPddSuffix);
       
    89     return SetName(&name);
       
    90 	}
       
    91 
       
    92 /**
       
    93   Returns the drivers capabilities. This is not used by the Symbian OS device driver framework
       
    94   but may be useful for the LDD to use.
       
    95 
       
    96   @param aDes Descriptor to write capabilities information into
       
    97 */
       
    98 void D8500_TimestampTestPddFactory::GetCaps(TDes8& aDes) const
       
    99 	{
       
   100 	// Create a capabilities object
       
   101 	RTimestampTest::TCaps caps;
       
   102 	caps.iVersion = iVersion;
       
   103     // Write it back to user memory
       
   104 	Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(caps));
       
   105 	}
       
   106 
       
   107 /**
       
   108   Called by the kernel's device driver framework to create a Physical Channel.
       
   109   This is called in the context of the user thread (client) which requested the creation of a Logical Channel
       
   110   (E.g. through a call to RBusLogicalChannel::DoCreate)
       
   111   The thread is in a critical section.
       
   112 
       
   113   @param aChannel Set to point to the created Physical Channel
       
   114   @param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate
       
   115   @param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate
       
   116   @param aVer The version number of the Logical Channel which will use this Physical Channel 
       
   117 
       
   118   @return KErrNone or standard error code.
       
   119 */
       
   120 TInt D8500_TimestampTestPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer)
       
   121 	{
       
   122 	// Ignore the parameters we aren't interested in...
       
   123 	(void)aUnit;
       
   124 	(void)aInfo;
       
   125 	(void)aVer;
       
   126 
       
   127 	// Create a new physical channel
       
   128 	D8500_TimestampTestPddChannel* channel=new D8500_TimestampTestPddChannel;
       
   129     aChannel = channel;
       
   130     return (channel) ? KErrNone : KErrNoMemory;
       
   131 	}
       
   132 
       
   133 /**
       
   134   Called by the kernel's device driver framework to check if this PDD is suitable for use with a Logical Channel.
       
   135   This is called in the context of the user thread (client) which requested the creation of a Logical Channel
       
   136   (E.g. through a call to RBusLogicalChannel::DoCreate)
       
   137   The thread is in a critical section.
       
   138 
       
   139   @param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate
       
   140   @param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate
       
   141   @param aVer The version number of the Logical Channel which will use this Physical Channel 
       
   142 
       
   143   @return KErrNone or standard error code.
       
   144 */
       
   145 TInt D8500_TimestampTestPddFactory::Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer)
       
   146 	{
       
   147 	// Check version numbers
       
   148 	if (!Kern::QueryVersionSupported(iVersion,aVer))
       
   149 		return KErrNotSupported;
       
   150         
       
   151         // Ignore extra info, (this could be used for validation purposes) and unit
       
   152     (void)aInfo;
       
   153     (void) aUnit;    
       
   154     return KErrNone;
       
   155     }
       
   156 
       
   157 ////
       
   158 // Channel implementation
       
   159 
       
   160 
       
   161 /**
       
   162    Called before each cycle in the test. Takes a copy of current idle count in power controller
       
   163 */
       
   164 void  D8500_TimestampTestPddChannel::StartLPMEntryCheck()
       
   165     {
       
   166 #ifdef __SMP__    
       
   167     iInitialIdleCount = IdleRestoreCount();
       
   168 #endif
       
   169     }
       
   170 
       
   171 /**
       
   172    Called at the end of each cycle. Should return true if we have entered idle since call to
       
   173    StartLPMEntryCheck. This will be the case if the idle count has changed
       
   174 */
       
   175 TBool  D8500_TimestampTestPddChannel::EndLPMEntryCheck()
       
   176     {
       
   177     // should only really return true if a low power mode >= WFIITS has been entered. 
       
   178 #ifdef __SMP__     // we don't care about single core build in this test
       
   179     if (DEFAULT_STATE_WFIITS_ENABLE || DEFAULT_STATE_IDLE_ENABLE || 
       
   180         DEFAULT_STATE_SLEEP_ENABLE || DEFAULT_STATE_DEEPSLEEP_ENABLE)
       
   181         return (iInitialIdleCount!=IdleRestoreCount());
       
   182     else
       
   183         return ETrue;
       
   184 #else
       
   185     return ETrue;
       
   186 #endif
       
   187     }
       
   188 
       
   189 
       
   190 /**
       
   191    Called to allow baseport to override test parameters. For Navi defaults are fine
       
   192 */
       
   193 void D8500_TimestampTestPddChannel::TestConfig(STimestampTestConfig& aInfo) 
       
   194     {
       
   195     // default test config is fine for HREF
       
   196     // accebtable error up to 2%
       
   197     aInfo.iErrorPercent = 2;
       
   198     }