0
|
1 |
// Copyright (c) 1996-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 |
// e32\kernel\exstart.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "plat_priv.h"
|
|
19 |
#include <e32uid.h>
|
|
20 |
|
|
21 |
enum TStartFault
|
|
22 |
{
|
|
23 |
EIniCreateSecondary1=0,
|
|
24 |
EIniCreateSecondary2=1,
|
|
25 |
EIniCreateSecondary3=2,
|
|
26 |
};
|
|
27 |
|
|
28 |
void Fault(TStartFault aFault)
|
|
29 |
{
|
|
30 |
Kern::Fault("EXSTART",aFault);
|
|
31 |
}
|
|
32 |
|
|
33 |
void StartSecondary(TAny*);
|
|
34 |
GLDEF_D TDfc StartSecondaryDfc(&StartSecondary, NULL, Kern::SvMsgQue(), 0);
|
|
35 |
|
|
36 |
#ifdef __EPOC32__
|
|
37 |
|
|
38 |
_LIT(KSecondaryFullPathName,"z:\\sys\\bin\\efile.exe");
|
|
39 |
|
|
40 |
TInt SecondaryInfo(TProcessCreateInfo& aInfo)
|
|
41 |
//
|
|
42 |
// Provide loader information for the secondary process from the ROM
|
|
43 |
//
|
|
44 |
{
|
|
45 |
TRomEntry *pE=(TRomEntry*)Epoc::RomHeader().iSecondaryFile;
|
|
46 |
TRomImageHeader& secondary=*(TRomImageHeader*)pE->iAddressLin;
|
|
47 |
Epoc::RomProcessInfo(aInfo, secondary);
|
|
48 |
aInfo.iFileName=KSecondaryFullPathName;
|
|
49 |
aInfo.iRootNameOffset=11;
|
|
50 |
aInfo.iRootNameLength=9;
|
|
51 |
aInfo.iExtOffset=16;
|
|
52 |
return KErrNone;
|
|
53 |
}
|
|
54 |
|
|
55 |
#else
|
|
56 |
|
|
57 |
#include <property.h>
|
|
58 |
#include <emulator.h>
|
|
59 |
|
|
60 |
_LIT(KSecondaryFullPathName,"EFile.exe");
|
|
61 |
|
|
62 |
TInt SecondaryInfo(TProcessCreateInfo& aInfo)
|
|
63 |
//
|
|
64 |
// Provide loader information for the secondary process
|
|
65 |
// We know this is efile.exe, so interrogate this image file
|
|
66 |
//
|
|
67 |
{
|
|
68 |
memclr(&aInfo.iUids, sizeof(TProcessCreateInfo)-sizeof(aInfo.iFileName));
|
|
69 |
aInfo.iFileName=KSecondaryFullPathName;
|
|
70 |
aInfo.iRootNameOffset=0;
|
|
71 |
aInfo.iRootNameLength=9;
|
|
72 |
aInfo.iExtOffset=5;
|
|
73 |
|
|
74 |
//TFileName name;
|
|
75 |
TUint16 wName[KMaxFileName];
|
|
76 |
TUint16 wFileName[KMaxFileName];
|
|
77 |
TUint8* ptr8=(TUint8*)aInfo.iFileName.Ptr();
|
|
78 |
for(int i=0;i<aInfo.iFileName.Length();i++)
|
|
79 |
wFileName[i] = (TUint16)*ptr8++;
|
|
80 |
TPtrC ptrFile((TUint8*)wFileName,aInfo.iFileName.Length()<<1);
|
|
81 |
TPtr ptrName((TUint8*)wName,KMaxFileName<<1);
|
|
82 |
Property::MapFilename(ptrName, ptrFile);
|
|
83 |
|
|
84 |
//Property::MapFilename(name, aInfo.iFileName);
|
|
85 |
wName[ptrName.Length()>>1] = '\0';
|
|
86 |
Emulator::RImageFile pefile;
|
|
87 |
|
|
88 |
TInt r = pefile.Open((LPCTSTR)wName);
|
|
89 |
if (r == KErrNone)
|
|
90 |
{
|
|
91 |
pefile.GetInfo(aInfo);
|
|
92 |
pefile.Close();
|
|
93 |
}
|
|
94 |
return r;
|
|
95 |
}
|
|
96 |
|
|
97 |
#endif
|
|
98 |
|
|
99 |
void StartSecondary(TAny*)
|
|
100 |
{
|
|
101 |
//
|
|
102 |
// First we need to setup the creation info for the secondary process.
|
|
103 |
//
|
|
104 |
__KTRACE_OPT(KBOOT,Kern::Printf("Starting secondary"));
|
|
105 |
|
|
106 |
TProcessCreateInfo info;
|
|
107 |
TInt r = SecondaryInfo(info);
|
|
108 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EIniCreateSecondary2));
|
|
109 |
|
|
110 |
__KTRACE_OPT(KBOOT, Kern::Printf("FS entrypoint %08x",info.iFileEntryPoint));
|
|
111 |
__KTRACE_OPT(KBOOT, Kern::Printf("FS data size %08x",info.iDataSize));
|
|
112 |
__KTRACE_OPT(KBOOT, Kern::Printf("FS bss size %08x",info.iBssSize));
|
|
113 |
|
|
114 |
DProcess* pP=NULL;
|
|
115 |
HBuf* cmd=NULL;
|
|
116 |
r=Kern::ProcessCreate(pP, info, cmd, NULL);
|
|
117 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EIniCreateSecondary3));
|
|
118 |
__KTRACE_OPT(KBOOT,Kern::Printf("Secondary created"));
|
|
119 |
|
|
120 |
pP->Loaded(info);
|
|
121 |
|
|
122 |
pP->iFlags = KProcessFlagSystemPermanent|KProcessFlagSystemCritical;
|
|
123 |
pP->FirstThread()->iFlags |= KThreadFlagSystemPermanent;
|
|
124 |
|
|
125 |
// Start the secondary
|
|
126 |
NKern::LockSystem();
|
|
127 |
pP->Resume();
|
|
128 |
NKern::UnlockSystem();
|
|
129 |
__KTRACE_OPT(KBOOT,Kern::Printf("Resumed secondary"));
|
|
130 |
}
|
|
131 |
|
|
132 |
DECLARE_STANDARD_EXTENSION()
|
|
133 |
{
|
|
134 |
__KTRACE_OPT(KBOOT,Kern::Printf("Launching secondary"));
|
|
135 |
StartSecondaryDfc.Enque();
|
|
136 |
return KErrNone;
|
|
137 |
}
|
|
138 |
|