os/kernelhwsrv/kerneltest/e32test/earlyextension/earlyextension.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/earlyextension/earlyextension.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,57 @@
     1.4 +// Copyright (c) 2007-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 +// e32test\earlyextension\earlyextension.cpp
    1.18 +// This is to test the registration of early extension and will do the following
    1.19 +// - Constructing the static data in VariantInit0 (the main extension object)
    1.20 +// - In Init3 entrypoint allocating space in Kernel Heap to store the time stamp obtained
    1.21 +// calling Kern::SystemTime().
    1.22 +// - Supplying one exported function to allow reading the time stamp.
    1.23 +// 
    1.24 +//
    1.25 +
    1.26 +
    1.27 +#include <kernel/kernel.h>
    1.28 +#include "earlyextension.h"
    1.29 +
    1.30 +static TestEarlyExtension* EarlyExtension;
    1.31 +
    1.32 +/** Registering as early extension */
    1.33 +DECLARE_EXTENSION_WITH_PRIORITY(EARLY_EXTENSION_PRIORITY)
    1.34 +	{
    1.35 +	TestEarlyExtension* ee = new TestEarlyExtension;
    1.36 +	if(!ee)
    1.37 +		return KErrNoMemory;
    1.38 +	EarlyExtension=ee;
    1.39 +	EarlyExtension->iTime = new TTimeK; //Allocate memory for storing time stamp.
    1.40 +    if(!EarlyExtension->iTime)
    1.41 +		return KErrNoMemory;
    1.42 +	*EarlyExtension->iTime = Kern::SystemTime(); //Store time stamp
    1.43 +	// wait one tick to guarantee that system time will be different if called from the entry point of a following extension
    1.44 +	NKern::Sleep(1);
    1.45 +    return KErrNone;
    1.46 +	}
    1.47 +
    1.48 +/** This function allows to read the time stamp taken during the init3 entry point */
    1.49 +EXPORT_C void TestEarlyExtension::GetTimeStamp(TTimeK& aTime)
    1.50 +    {
    1.51 +    if(!EarlyExtension->iTime)
    1.52 +        {
    1.53 +        aTime = 0;
    1.54 +        return;
    1.55 +        }    
    1.56 +	aTime = *EarlyExtension->iTime;
    1.57 +	return;
    1.58 +	}
    1.59 +
    1.60 +