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