First public contribution.
1 // Copyright (c) 1998-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\memmodel\emul\win32\zrom.cpp
15 // Emulator implementation of the ROM related parts of the system
19 #include "plat_priv.h"
24 const char* KVariantDllName="ecust.dll";
26 TInt P::DefaultInitialTime()
29 // Not used on emulator
34 TInt P::InitSystemTime()
37 // Initialise system time
38 // Return the initial time in seconds from 00:00:00 01-01-2000
41 K::SetSystemTimeAndOffset(0, 0, 0, dummy, ETimeSetOffset|ETimeSetNoTimeUpdate);
43 __KTRACE_OPT(KBOOT,Kern::Printf("Use Host time to set system time"));
45 A::SystemTimeInSecondsFrom2000(seconds);
50 void P::CreateVariant()
52 __KTRACE_OPT(KBOOT,Kern::Printf("CreateVariant"));
53 HINSTANCE var = LoadLibraryA(KVariantDllName);
56 TLibraryEntry entryPoint=(TLibraryEntry)Emulator::GetProcAddress(var, "_E32Dll");
59 __KTRACE_OPT(KBOOT,Kern::Printf("Found variant"));
60 // Call the entry point (global constructors)
61 __KTRACE_OPT(KBOOT,Kern::Printf("Calling entrypoint %08x",entryPoint));
62 TInt r=entryPoint(KModuleEntryReasonVariantInit0);
63 __KTRACE_OPT(KBOOT,Kern::Printf("Entrypoint returned %d",r));
65 Kern::Fault("VariantEntry",r);
67 // Initialise and create the variant object
68 r=A::CreateVariant(var, r);
70 Kern::Fault("VariantInit",r);
71 __KTRACE_OPT(KBOOT,Kern::Printf("Variant installed"));
73 BTrace::Init0(); // we have to do this after variant has initialised the SuperPage
77 Kern::Fault("NoVariant",0);
81 TInt StartExtension(const char* aExtension)
85 if (*aExtension == '?')
87 ext = LoadLibraryA(++aExtension);
90 __KTRACE_OPT(KBOOT, Kern::Printf("Optional extension \"%s\" not found", aExtension));
96 ext = LoadLibraryA(aExtension);
100 mh = GetModuleHandleA(aExtension);
101 TLibraryEntry entryPoint=(TLibraryEntry)Emulator::GetProcAddress(ext, "_E32Dll");
104 TInt r=entryPoint(KModuleEntryReasonExtensionInit0);
107 __KTRACE_OPT(KBOOT,Kern::Printf("Extension %s already started", aExtension));
111 r=MM::RegisterModule(mh);
115 __KTRACE_OPT(KBOOT,Kern::Printf("Calling entrypoint of %s extension ", aExtension));
116 return entryPoint(KModuleEntryReasonExtensionInit1);
120 void P::StartExtensions()
122 HMODULE mh = GetModuleHandleA(KVariantDllName);
123 TInt r = MM::RegisterModule(mh);
124 const char* extension = NULL;
126 extension = Property::GetString("Extension");
132 const char* end = strchr(extension, ';');
135 strncpy(name, extension, end-extension);
136 name[end-extension] = '\0';
137 if (strchr(name, '.') == NULL)
138 strcat(name, ".dll");
139 r = StartExtension(name);
145 r = StartExtension(extension);
148 K::Fault(K::EStartExtensionsFailed);