sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\earlyextension\earlyextension.cpp
|
sl@0
|
15 |
// This is to test the registration of early extension and will do the following
|
sl@0
|
16 |
// - Constructing the static data in VariantInit0 (the main extension object)
|
sl@0
|
17 |
// - In Init3 entrypoint allocating space in Kernel Heap to store the time stamp obtained
|
sl@0
|
18 |
// calling Kern::SystemTime().
|
sl@0
|
19 |
// - Supplying one exported function to allow reading the time stamp.
|
sl@0
|
20 |
//
|
sl@0
|
21 |
//
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <kernel/kernel.h>
|
sl@0
|
25 |
#include "earlyextension.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
static TestEarlyExtension* EarlyExtension;
|
sl@0
|
28 |
|
sl@0
|
29 |
/** Registering as early extension */
|
sl@0
|
30 |
DECLARE_EXTENSION_WITH_PRIORITY(EARLY_EXTENSION_PRIORITY)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
TestEarlyExtension* ee = new TestEarlyExtension;
|
sl@0
|
33 |
if(!ee)
|
sl@0
|
34 |
return KErrNoMemory;
|
sl@0
|
35 |
EarlyExtension=ee;
|
sl@0
|
36 |
EarlyExtension->iTime = new TTimeK; //Allocate memory for storing time stamp.
|
sl@0
|
37 |
if(!EarlyExtension->iTime)
|
sl@0
|
38 |
return KErrNoMemory;
|
sl@0
|
39 |
*EarlyExtension->iTime = Kern::SystemTime(); //Store time stamp
|
sl@0
|
40 |
// wait one tick to guarantee that system time will be different if called from the entry point of a following extension
|
sl@0
|
41 |
NKern::Sleep(1);
|
sl@0
|
42 |
return KErrNone;
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
/** This function allows to read the time stamp taken during the init3 entry point */
|
sl@0
|
46 |
EXPORT_C void TestEarlyExtension::GetTimeStamp(TTimeK& aTime)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
if(!EarlyExtension->iTime)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
aTime = 0;
|
sl@0
|
51 |
return;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
aTime = *EarlyExtension->iTime;
|
sl@0
|
54 |
return;
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
|