author | William Roberts <williamr@symbian.org> |
Mon, 28 Jun 2010 11:25:30 +0100 | |
branch | GCC_SURGE |
changeset 184 | 0e2270015475 |
parent 90 | 947f0dc9f7a8 |
child 177 | a232af6b0b1f |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2008-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\nkernsmp\arm\nccpu.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <arm.h> |
|
19 |
#include <arm_gic.h> |
|
20 |
#include <arm_scu.h> |
|
21 |
#include <arm_tmr.h> |
|
22 |
||
23 |
extern "C" { |
|
24 |
extern SVariantInterfaceBlock* VIB; |
|
25 |
} |
|
26 |
||
27 |
struct SAPBootPage : public SFullArmRegSet |
|
28 |
{ |
|
29 |
volatile T_UintPtr iAPBootPtr[KMaxCpus]; |
|
30 |
volatile T_UintPtr iBootFlags; |
|
31 |
volatile T_UintPtr iBootFlags2; |
|
32 |
volatile T_UintPtr iBootFlags3; |
|
33 |
volatile T_UintPtr iBootFlags4; |
|
34 |
volatile TUint64 iBPTimestamp; |
|
35 |
volatile TUint64 iAPTimestamp; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
37 |
TUint32 i_SAPBootPage_Spare[624]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
38 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
39 |
UPerCpuUncached iPerCpu[KMaxCpus]; |
0 | 40 |
}; |
41 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
__ASSERT_COMPILE(sizeof(SAPBootPage)==4096); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
|
0 | 45 |
extern "C" void _ApEntry(); |
46 |
extern "C" void KickCpu(volatile T_UintPtr* aPtr, T_UintPtr aRegsPhys); |
|
47 |
extern void DumpFullRegSet(SFullArmRegSet& a); |
|
48 |
||
49 |
TInt NKern::BootAP(volatile SAPBootInfo* aInfo) |
|
50 |
{ |
|
51 |
volatile SArmAPBootInfo& a = *(volatile SArmAPBootInfo*)aInfo; |
|
52 |
__KTRACE_OPT(KBOOT,DEBUGPRINT("NKern::BootAP %d %08x+%x", a.iCpu, a.iInitStackBase, a.iInitStackSize)); |
|
53 |
||
54 |
T_UintPtr bp_phys = a.iAPBootPhys; |
|
55 |
T_UintPtr BootFlagsPhys = bp_phys + (T_UintPtr)_FOFF(SAPBootPage,iBootFlags); |
|
56 |
volatile SAPBootPage& bootPage = *(volatile SAPBootPage*)a.iAPBootLin; |
|
57 |
Arm::SaveState((SFullArmRegSet&)bootPage); |
|
58 |
NKern::EnableAllInterrupts(); // Arm::SaveState() disables interrupts |
|
59 |
||
60 |
TLinAddr BootFlagsLin = (TLinAddr)&bootPage.iBootFlags; |
|
61 |
TLinAddr init_sp = a.iInitStackBase + a.iInitStackSize; |
|
62 |
||
63 |
volatile T_UintPtr* pB = (volatile T_UintPtr*)BootFlagsLin; |
|
64 |
*pB = 0; |
|
65 |
pB[1] = 0; |
|
66 |
pB[2] = 0; |
|
67 |
pB[3] = 0; |
|
68 |
||
69 |
__KTRACE_OPT(KBOOT,DEBUGPRINT("BootFlagsPhys=%08x BootFlagsLin=%08x RegsPhys=%08x RegsLin=%08x", |
|
70 |
BootFlagsPhys, BootFlagsLin, bp_phys, &bootPage)); |
|
71 |
__KTRACE_OPT(KBOOT,DEBUGPRINT("SCU: iCtrl=%08x iConfig=%08x iCpuStat=%08x", SCU.iCtrl, SCU.iConfig, SCU.iCpuStatus)); |
|
72 |
||
73 |
bootPage.iN.iR13Abt = a.iInitR13Abt; |
|
74 |
bootPage.iN.iR13Und = a.iInitR13Und; |
|
75 |
bootPage.iN.iR13Irq = a.iInitR13Irq; |
|
76 |
bootPage.iN.iR13Fiq = a.iInitR13Fiq; |
|
77 |
bootPage.iN.iR13Svc = init_sp; |
|
78 |
bootPage.iN.iFlags = 0x1D3; |
|
79 |
bootPage.iN.iR1 = (TUint32)a.iAPBootPageDirPhys; |
|
80 |
bootPage.iN.iR2 = TUint32(a.iAPBootCodeLin) - TUint32(a.iAPBootCodePhys); |
|
81 |
bootPage.iN.iR3 = (TUint32)a.iAPBootLin; |
|
82 |
bootPage.iN.iR4 = (TUint32)aInfo; |
|
83 |
bootPage.iN.iR5 = BootFlagsPhys; |
|
84 |
bootPage.iN.iR6 = BootFlagsLin; |
|
85 |
bootPage.iN.iR7 = a.iInitStackSize; |
|
86 |
bootPage.iN.iR15 = (TLinAddr)&_ApEntry; |
|
87 |
bootPage.iB[0].iRWRWTID = 0; |
|
88 |
bootPage.iB[0].iRWROTID = 0; |
|
89 |
bootPage.iB[0].iRWNOTID = 0; |
|
90 |
||
91 |
__KTRACE_OPT(KBOOT,DumpFullRegSet((SFullArmRegSet&)bootPage)); |
|
92 |
||
93 |
arm_dsb(); // ensure writes to uncached memory visible |
|
94 |
||
95 |
KickCpu(&bootPage.iAPBootPtr[a.iCpu], bp_phys); |
|
96 |
||
97 |
TUint32 n = TUint32(VIB->iMaxCpuClock >> 3); |
|
98 |
n = -n; |
|
99 |
TUint32 b = 0; |
|
100 |
do { |
|
101 |
++n; |
|
102 |
b = *pB; |
|
103 |
} while(b!=init_sp && n!=0); |
|
104 |
arm_dsb(); |
|
105 |
||
106 |
__KTRACE_OPT(KBOOT,DEBUGPRINT("BootFlag=%08x %08x %08x %08x n=%d", b, n, pB[1], pB[2], pB[3])); |
|
107 |
__KTRACE_OPT(KBOOT,DEBUGPRINT("SCU: iCtrl=%08x iConfig=%08x iCpuStat=%08x", SCU.iCtrl, SCU.iConfig, SCU.iCpuStatus)); |
|
108 |
if (n==0) |
|
109 |
return KErrTimedOut; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
#if defined(__NKERN_TIMESTAMP_USE_LOCAL_TIMER__) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
#error Use of local timer for NKern::Timestamp() no longer supported |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
#endif |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
|
0 | 115 |
return KErrNone; |
116 |
} |
|
117 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
void InitTimestamp(TSubScheduler* aSS, SNThreadCreateInfo& aInfo) |
0 | 119 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
NThread* t = (NThread*)aSS->iCurrentThread; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
t->iActiveState = 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
if (aSS->iCpuNum == 0) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
aSS->iLastTimestamp.i64 = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
t->iLastActivationTime.i64 = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
return; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
TUint64 ts = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
#if defined(__NKERN_TIMESTAMP_USE_LOCAL_TIMER__) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
#error Use of local timer for NKern::Timestamp() no longer supported |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
#endif |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
ts = NKern::Timestamp(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
aSS->iLastTimestamp.i64 = ts; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
t->iLastActivationTime.i64 = ts; |
0 | 135 |
} |
136 |