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\x86\cinit.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <x86_mem.h>
|
|
19 |
#include <e32uid.h>
|
|
20 |
|
|
21 |
TInt A::CreateVariant(const TAny* aFile, TInt aMode)
|
|
22 |
{
|
|
23 |
__KTRACE_OPT(KBOOT,Kern::Printf("A::CreateVariant aFile=%08x aMode=%08x", aFile, aMode));
|
|
24 |
const TRomImageHeader& img = *(const TRomImageHeader*)aFile;
|
|
25 |
TVariantInitialise2 f = (TVariantInitialise2)*((TLinAddr*)img.iExportDir); // ordinal 1
|
|
26 |
__KTRACE_OPT(KBOOT,Kern::Printf("Calling Initialise %08x", f));
|
|
27 |
X86::TheAsic = (Asic*)(*f)(0);
|
|
28 |
__KTRACE_OPT(KBOOT,Kern::Printf("Initialise returned %08x", X86::TheAsic));
|
|
29 |
if (!X86::TheAsic)
|
|
30 |
return KErrGeneral;
|
|
31 |
if (aMode)
|
|
32 |
{
|
|
33 |
TInt i;
|
|
34 |
for (i=0; i<31; ++i)
|
|
35 |
{
|
|
36 |
if (aMode & (1<<i))
|
|
37 |
{
|
|
38 |
__KTRACE_OPT(KBOOT,Kern::Printf("Calling VariantInitialise with %d", i+1));
|
|
39 |
TAny* p = (*f)(i+1);
|
|
40 |
K::VariantData[i] = p;
|
|
41 |
__KTRACE_OPT(KBOOT,Kern::Printf("VariantInitialise returns %08x", p));
|
|
42 |
}
|
|
43 |
}
|
|
44 |
}
|
|
45 |
return KErrNone;
|
|
46 |
}
|
|
47 |
|
|
48 |
void A::Init1()
|
|
49 |
{
|
|
50 |
__KTRACE_OPT(KBOOT,Kern::Printf("A::Init1()"));
|
|
51 |
|
|
52 |
// first phase ASIC/Variant initialisation
|
|
53 |
X86::TheAsic->Init1();
|
|
54 |
PP::NanoWaitCal=X86::TheAsic->NanoWaitCalibration();
|
|
55 |
X86_NanoWaitCal=PP::NanoWaitCal;
|
|
56 |
|
|
57 |
TMachineStartupType t=X86::TheAsic->StartupReason();
|
|
58 |
if (t==EStartupWarmReset || t==EStartupPowerFail || t==EStartupKernelFault)
|
|
59 |
{
|
|
60 |
if (!P::CheckSuperPageSignature())
|
|
61 |
t=EStartupColdReset;
|
|
62 |
}
|
|
63 |
TheSuperPage().iStartupReason=t;
|
|
64 |
switch (t)
|
|
65 |
{
|
|
66 |
case EStartupCold:
|
|
67 |
case EStartupColdReset:
|
|
68 |
case EStartupNewOs:
|
|
69 |
case EStartupSafeReset:
|
|
70 |
K::ColdStart=ETrue;
|
|
71 |
break;
|
|
72 |
|
|
73 |
case EStartupPowerFail:
|
|
74 |
case EStartupWarmReset:
|
|
75 |
case EStartupKernelFault:
|
|
76 |
K::ColdStart=EFalse;
|
|
77 |
break;
|
|
78 |
|
|
79 |
default:
|
|
80 |
PP::Panic(PP::EInvalidStartupReason);
|
|
81 |
}
|
|
82 |
|
|
83 |
// initialise the interrupt/exception handlers
|
|
84 |
// doesn't enable interrupts - NKern::Init() does that
|
|
85 |
X86::Init1Interrupts();
|
|
86 |
|
|
87 |
NTimerQ::Init1(X86::TheAsic->MsTickPeriod());
|
|
88 |
}
|
|
89 |
|
|
90 |
void A::Init2()
|
|
91 |
{
|
|
92 |
__KTRACE_OPT(KBOOT,Kern::Printf("A::Init2()"));
|
|
93 |
}
|
|
94 |
|
|
95 |
#ifdef __SMP__
|
|
96 |
void A::InitAPs()
|
|
97 |
{
|
|
98 |
__KTRACE_OPT(KBOOT, Kern::Printf("A::InitAPs()"));
|
|
99 |
TInt timeout = 500;
|
|
100 |
TInt i;
|
|
101 |
#ifdef KPANIC
|
|
102 |
if (TheSuperPage().iDebugMask[0] & ~KPANIC)
|
|
103 |
timeout = 30000;
|
|
104 |
#endif
|
|
105 |
SCpuBootData* pInfo = X86::CpuBootData;
|
|
106 |
memclr(pInfo, sizeof(X86::CpuBootData));
|
|
107 |
X86::TheAsic->GetCpuBootData(pInfo);
|
|
108 |
TInt a = 0;
|
|
109 |
for (i=1; i<KMaxCpus; ++i)
|
|
110 |
{
|
|
111 |
SCpuBootData& info = pInfo[i];
|
|
112 |
if (info.iPresent)
|
|
113 |
{
|
|
114 |
SX86APBootInfo binfo;
|
|
115 |
memclr(&binfo,sizeof(binfo));
|
|
116 |
binfo.iCpu = info.iAPICID;
|
|
117 |
M::GetAPBootInfo(i, &binfo);
|
|
118 |
K::InitAP(i, &binfo, timeout);
|
|
119 |
++a;
|
|
120 |
}
|
|
121 |
}
|
|
122 |
// check to see if it may be a dodgy laptop and try and init the second CPU
|
|
123 |
if ((a == 0) && (Kern::SuperPage().iDebugPort == KNullDebugPort))
|
|
124 |
{
|
|
125 |
__KTRACE_OPT(KBOOT, Kern::Printf("A::InitAPs() - assuming laptop and starting 2nd CPU"));
|
|
126 |
SX86APBootInfo binfo;
|
|
127 |
memclr(&binfo,sizeof(binfo));
|
|
128 |
binfo.iCpu = 1;
|
|
129 |
M::GetAPBootInfo(1, &binfo);
|
|
130 |
K::InitAP(1, &binfo, timeout);
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
void A::Init2AP()
|
|
135 |
{
|
|
136 |
__KTRACE_OPT(KBOOT,Kern::Printf("A::Init2AP()"));
|
|
137 |
X86::TheAsic->Init2AP();
|
|
138 |
}
|
|
139 |
#endif
|
|
140 |
|
|
141 |
GLREF_C void InitDummyMsgQ();
|
|
142 |
void A::Init3()
|
|
143 |
{
|
|
144 |
__KTRACE_OPT(KBOOT,Kern::Printf("A::Init3()"));
|
|
145 |
|
|
146 |
InitDummyMsgQ();
|
|
147 |
X86::TheAsic->Init3();
|
|
148 |
}
|
|
149 |
|
|
150 |
|