navienginebsp/ne1_tb/test/timestamp/d_timestamp.cpp
changeset 0 5de814552237
equal deleted inserted replaced
-1:000000000000 0:5de814552237
       
     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 "ne1_tb_power.h"
       
    24 
       
    25 // Name for PDD, will be LDD name and this suffix
       
    26 _LIT(KTimestampPddSuffix,".NE1_TB");
       
    27 
       
    28 
       
    29 class DNE1_TimestampTestPddChannel : public DTimestampTestPddChannel
       
    30 	{
       
    31 public:
       
    32 	// Inherited from DTimestampTestPddChanel. These called by the LDD.
       
    33 	virtual void StartLPMEntryCheck();
       
    34     virtual TBool EndLPMEntryCheck();
       
    35     virtual void TestConfig(STimestampTestConfig& aInfo);
       
    36 private:
       
    37 	TUint iInitialIdleCount;
       
    38 	};
       
    39 
       
    40 /**
       
    41   Logical Device (factory class) for DNE1_TimestampTestPddChannel
       
    42 */
       
    43 class DNE1_TimestampTestPddFactory : public DPhysicalDevice
       
    44 	{
       
    45 public:
       
    46 	DNE1_TimestampTestPddFactory();
       
    47 	//	Inherited from DLogicalDevice
       
    48 	virtual TInt Install();
       
    49 	virtual void GetCaps(TDes8& aDes) const;
       
    50     virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
       
    51 	virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
       
    52 private:
       
    53     TVersion iVersion;
       
    54 	};
       
    55 
       
    56 //
       
    57 // DNE1_TimestampTestPddFactory
       
    58 //
       
    59 
       
    60 /**
       
    61   Standard export function for PDDs. This creates a DPhysicalDevice derived object,
       
    62   in this case, our DNE1_TimestampTestPddFactory
       
    63 */
       
    64 DECLARE_STANDARD_PDD()
       
    65 	{
       
    66 	return new DNE1_TimestampTestPddFactory();
       
    67 	}
       
    68 
       
    69 /**
       
    70  * constructor
       
    71  */
       
    72 DNE1_TimestampTestPddFactory::DNE1_TimestampTestPddFactory()
       
    73 	{
       
    74 	// Set version number for this device
       
    75 	iVersion=RTimestampTest::VersionRequired();
       
    76 	}
       
    77 
       
    78 /**
       
    79   Second stage constructor for DPhysicalDevice derived objects.
       
    80   This must at least set a name for the driver object.
       
    81 
       
    82   @return KErrNone or standard error code.
       
    83 */
       
    84 TInt DNE1_TimestampTestPddFactory::Install()
       
    85     {
       
    86     TName name(RTimestampTest::Name());
       
    87     name.Append(KTimestampPddSuffix);
       
    88     return SetName(&name);
       
    89 	}
       
    90 
       
    91 /**
       
    92   Returns the drivers capabilities. This is not used by the Symbian OS device driver framework
       
    93   but may be useful for the LDD to use.
       
    94 
       
    95   @param aDes Descriptor to write capabilities information into
       
    96 */
       
    97 void DNE1_TimestampTestPddFactory::GetCaps(TDes8& aDes) const
       
    98 	{
       
    99 	// Create a capabilities object
       
   100 	RTimestampTest::TCaps caps;
       
   101 	caps.iVersion = iVersion;
       
   102     // Write it back to user memory
       
   103 	Kern::InfoCopy(aDes,(TUint8*)&caps,sizeof(caps));
       
   104 	}
       
   105 
       
   106 /**
       
   107   Called by the kernel's device driver framework to create a Physical Channel.
       
   108   This is called in the context of the user thread (client) which requested the creation of a Logical Channel
       
   109   (E.g. through a call to RBusLogicalChannel::DoCreate)
       
   110   The thread is in a critical section.
       
   111 
       
   112   @param aChannel Set to point to the created Physical Channel
       
   113   @param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate
       
   114   @param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate
       
   115   @param aVer The version number of the Logical Channel which will use this Physical Channel 
       
   116 
       
   117   @return KErrNone or standard error code.
       
   118 */
       
   119 TInt DNE1_TimestampTestPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer)
       
   120 	{
       
   121 	// Ignore the parameters we aren't interested in...
       
   122 	(void)aUnit;
       
   123 	(void)aInfo;
       
   124 	(void)aVer;
       
   125 
       
   126 	// Create a new physical channel
       
   127 	DNE1_TimestampTestPddChannel* channel=new DNE1_TimestampTestPddChannel;
       
   128     aChannel = channel;
       
   129     return (channel) ? KErrNone : KErrNoMemory;
       
   130 	}
       
   131 
       
   132 /**
       
   133   Called by the kernel's device driver framework to check if this PDD is suitable for use with a Logical Channel.
       
   134   This is called in the context of the user thread (client) which requested the creation of a Logical Channel
       
   135   (E.g. through a call to RBusLogicalChannel::DoCreate)
       
   136   The thread is in a critical section.
       
   137 
       
   138   @param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate
       
   139   @param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate
       
   140   @param aVer The version number of the Logical Channel which will use this Physical Channel 
       
   141 
       
   142   @return KErrNone or standard error code.
       
   143 */
       
   144 TInt DNE1_TimestampTestPddFactory::Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer)
       
   145 	{
       
   146 	// Check version numbers
       
   147 	if (!Kern::QueryVersionSupported(iVersion,aVer))
       
   148 		return KErrNotSupported;
       
   149         
       
   150     (void)aInfo;
       
   151     (void) aUnit;    
       
   152     return KErrNone;
       
   153     }
       
   154 
       
   155 ////
       
   156 // Channel implementation
       
   157 
       
   158 
       
   159 /**
       
   160    Called before each cycle in the test. Takes a copy of current idle count in power controller
       
   161 */
       
   162 void  DNE1_TimestampTestPddChannel::StartLPMEntryCheck()
       
   163     {
       
   164     iInitialIdleCount = TNE1_TBPowerController::IdleCount();
       
   165     }
       
   166 
       
   167 /**
       
   168    Called at the end of each cycle. Should return true if we have entered idle since call to
       
   169    StartLPMEntryCheck. This will be the case if the idle count has changed
       
   170 */
       
   171 TBool  DNE1_TimestampTestPddChannel::EndLPMEntryCheck()
       
   172     {
       
   173     return (iInitialIdleCount!=TNE1_TBPowerController::IdleCount());
       
   174     }
       
   175 
       
   176 
       
   177 /**
       
   178    Called to allow baseport to override test parameters. For Navi defaults are fine
       
   179 */
       
   180 void DNE1_TimestampTestPddChannel::TestConfig(STimestampTestConfig& aInfo) 
       
   181     {
       
   182     }