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