0
|
1 |
// Copyright (c) 2006-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\nkernsa\init.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <nktest/nkutils.h>
|
|
19 |
|
|
20 |
extern "C" {
|
|
21 |
TLinAddr RomHeaderAddress;
|
|
22 |
TLinAddr SuperPageAddress;
|
|
23 |
TBool InitialThreadDefined;
|
|
24 |
}
|
|
25 |
|
|
26 |
NThread* InitialThread;
|
|
27 |
TDfcQue* TimerDfcQ;
|
|
28 |
TDfcQue* CleanupDfcQ;
|
|
29 |
NThread* MainThread;
|
|
30 |
|
|
31 |
#ifdef __SMP__
|
|
32 |
const char* NullNames[KMaxCpus] =
|
|
33 |
{
|
|
34 |
"Null0",
|
|
35 |
"Null1",
|
|
36 |
"Null2",
|
|
37 |
"Null3",
|
|
38 |
"Null4",
|
|
39 |
"Null5",
|
|
40 |
"Null6",
|
|
41 |
"Null7"
|
|
42 |
};
|
|
43 |
#endif
|
|
44 |
|
|
45 |
extern "C" void StartSystemTimer();
|
|
46 |
extern "C" void Hw_Init1();
|
|
47 |
extern "C" void Hw_InitAPs();
|
|
48 |
extern "C" void Hw_Init3();
|
|
49 |
extern "C" TLinAddr __initial_stack_base();
|
|
50 |
extern "C" TInt __initial_stack_size();
|
|
51 |
|
|
52 |
extern void Main(TAny*);
|
|
53 |
|
|
54 |
extern "C" void KernelMain()
|
|
55 |
{
|
|
56 |
KPrintf("KernelMain()");
|
|
57 |
__CHECKPOINT();
|
|
58 |
|
|
59 |
Hw_Init1();
|
|
60 |
NTimerQ::Init1(__timer_period());
|
|
61 |
SetupMemoryAllocator();
|
|
62 |
|
|
63 |
InitialThread = new NThread;
|
|
64 |
__KTRACE_OPT(KTHREAD,DEBUGPRINT("Initial thread at %08x", InitialThread));
|
|
65 |
SNThreadCreateInfo info;
|
|
66 |
|
|
67 |
info.iFunction = 0;
|
|
68 |
info.iStackBase = (TAny*)__initial_stack_base();
|
|
69 |
info.iStackSize = __initial_stack_size();
|
|
70 |
info.iPriority = 0;
|
|
71 |
info.iTimeslice = -1;
|
|
72 |
info.iAttributes = 0;
|
|
73 |
info.iHandlers = 0;
|
|
74 |
info.iFastExecTable = 0;
|
|
75 |
info.iSlowExecTable = 0;
|
|
76 |
info.iParameterBlock = 0;
|
|
77 |
info.iParameterBlockSize = 0;
|
|
78 |
#ifdef __SMP__
|
|
79 |
info.iCpuAffinity = 0;
|
|
80 |
info.iGroup = 0;
|
|
81 |
#endif
|
|
82 |
|
|
83 |
NKern::Init(InitialThread, info);
|
|
84 |
#ifdef __SMP__
|
|
85 |
InitialThread->iNThreadBaseSpare8 = (TUint32)NullNames[NKern::CurrentCpu()];
|
|
86 |
#else
|
|
87 |
InitialThread->iSpare8 = (TUint32)"Null";
|
|
88 |
#endif
|
|
89 |
InitialThreadDefined = ETrue;
|
|
90 |
|
|
91 |
KPrintf("NKern::CurrentThread() = %08x", NKern::CurrentThread());
|
|
92 |
KPrintf("TR=%x",__cpu_id());
|
|
93 |
|
|
94 |
#ifdef __SMP__
|
|
95 |
Hw_InitAPs();
|
|
96 |
#endif
|
|
97 |
|
|
98 |
CleanupDfcQ = CreateDfcQ("Cleanup", 17, KCpuAffinityAny);
|
|
99 |
TimerDfcQ = CreateDfcQ("Timer", 48);
|
|
100 |
NTimerQ::Init3(TimerDfcQ);
|
|
101 |
Hw_Init3();
|
|
102 |
|
|
103 |
init_fast_counter();
|
|
104 |
|
|
105 |
MainThread = CreateThread("Main", &Main, 16, 0, 0, ETrue, KTimeslice);
|
|
106 |
|
|
107 |
KPrintf("spinning ...");
|
|
108 |
FOREVER
|
|
109 |
{
|
|
110 |
NKern::Idle();
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
#ifdef __SMP__
|
|
115 |
extern "C" void ApMainGeneric(volatile SAPBootInfo* aInfo)
|
|
116 |
{
|
|
117 |
NThread* t = (NThread*)aInfo->iArgs[0];
|
|
118 |
__KTRACE_OPT(KTHREAD,DEBUGPRINT("Initial thread at %08x", t));
|
|
119 |
SNThreadCreateInfo info;
|
|
120 |
|
|
121 |
info.iFunction = 0;
|
|
122 |
info.iStackBase = (TAny*)aInfo->iInitStackBase;
|
|
123 |
info.iStackSize = aInfo->iInitStackSize;
|
|
124 |
info.iPriority = 0;
|
|
125 |
info.iTimeslice = -1;
|
|
126 |
info.iAttributes = 0;
|
|
127 |
info.iHandlers = 0;
|
|
128 |
info.iFastExecTable = 0;
|
|
129 |
info.iSlowExecTable = 0;
|
|
130 |
info.iParameterBlock = (const TUint32*)aInfo;
|
|
131 |
info.iParameterBlockSize = 0;
|
|
132 |
info.iCpuAffinity = 0; // nanokernel substitutes with correct CPU number
|
|
133 |
info.iGroup = 0;
|
|
134 |
|
|
135 |
NKern::Init(t, info);
|
|
136 |
t->iNThreadBaseSpare8 = (TUint32)NullNames[NKern::CurrentCpu()];
|
|
137 |
|
|
138 |
KPrintf("NKern::CurrentThread() = %08x\n", NKern::CurrentThread());
|
|
139 |
|
|
140 |
__e32_atomic_store_ord32(&aInfo->iArgs[1], 1);
|
|
141 |
|
|
142 |
__KTRACE_OPT(KBOOT,DEBUGPRINT("AP status=%08x", __cpu_status_reg()));
|
|
143 |
KPrintf("AP TR=%x",__cpu_id());
|
|
144 |
|
|
145 |
FOREVER
|
|
146 |
{
|
|
147 |
NKern::Idle();
|
|
148 |
}
|
|
149 |
}
|
|
150 |
#endif
|
|
151 |
|
|
152 |
TBool BTrace::IsSupported(TUint aCategory)
|
|
153 |
{
|
|
154 |
if(aCategory>255)
|
|
155 |
return EFalse;
|
|
156 |
return ETrue;
|
|
157 |
}
|
|
158 |
|