18 #include <arm.h> |
18 #include <arm.h> |
19 #include <arm_gic.h> |
19 #include <arm_gic.h> |
20 #include <arm_scu.h> |
20 #include <arm_scu.h> |
21 #include <arm_tmr.h> |
21 #include <arm_tmr.h> |
22 |
22 |
|
23 extern "C" { |
|
24 extern SVariantInterfaceBlock* VIB; |
|
25 } |
23 |
26 |
24 struct SAPBootPage : public SFullArmRegSet |
27 struct SAPBootPage : public SFullArmRegSet |
25 { |
28 { |
26 volatile T_UintPtr iAPBootPtr[KMaxCpus]; |
29 volatile T_UintPtr iAPBootPtr[KMaxCpus]; |
27 volatile T_UintPtr iBootFlags; |
30 volatile T_UintPtr iBootFlags; |
28 volatile T_UintPtr iBootFlags2; |
31 volatile T_UintPtr iBootFlags2; |
29 volatile T_UintPtr iBootFlags3; |
32 volatile T_UintPtr iBootFlags3; |
30 volatile T_UintPtr iBootFlags4; |
33 volatile T_UintPtr iBootFlags4; |
31 volatile TUint64 iBPTimestamp; |
34 volatile TUint64 iBPTimestamp; |
32 volatile TUint64 iAPTimestamp; |
35 volatile TUint64 iAPTimestamp; |
33 |
|
34 TUint32 i_SAPBootPage_Spare[624]; |
|
35 |
|
36 UPerCpuUncached iPerCpu[KMaxCpus]; |
|
37 }; |
36 }; |
38 |
|
39 __ASSERT_COMPILE(sizeof(SAPBootPage)==4096); |
|
40 |
|
41 |
37 |
42 extern "C" void _ApEntry(); |
38 extern "C" void _ApEntry(); |
43 extern "C" void KickCpu(volatile T_UintPtr* aPtr, T_UintPtr aRegsPhys); |
39 extern "C" void KickCpu(volatile T_UintPtr* aPtr, T_UintPtr aRegsPhys); |
44 extern void DumpFullRegSet(SFullArmRegSet& a); |
40 extern void DumpFullRegSet(SFullArmRegSet& a); |
45 |
41 |
102 |
98 |
103 __KTRACE_OPT(KBOOT,DEBUGPRINT("BootFlag=%08x %08x %08x %08x n=%d", b, n, pB[1], pB[2], pB[3])); |
99 __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)); |
100 __KTRACE_OPT(KBOOT,DEBUGPRINT("SCU: iCtrl=%08x iConfig=%08x iCpuStat=%08x", SCU.iCtrl, SCU.iConfig, SCU.iCpuStatus)); |
105 if (n==0) |
101 if (n==0) |
106 return KErrTimedOut; |
102 return KErrTimedOut; |
107 |
103 NKern::DisableAllInterrupts(); |
108 #if defined(__NKERN_TIMESTAMP_USE_LOCAL_TIMER__) |
104 arm_dsb(); |
109 #error Use of local timer for NKern::Timestamp() no longer supported |
105 while (bootPage.iBootFlags2==0) |
110 #endif |
106 {} |
111 |
107 arm_dsb(); |
|
108 bootPage.iBootFlags2 = 2; |
|
109 arm_dsb(); |
|
110 bootPage.iBPTimestamp = NKern::Timestamp(); |
|
111 arm_dsb(); |
|
112 while (bootPage.iBootFlags2==2) |
|
113 {} |
|
114 arm_dsb(); |
|
115 NKern::EnableAllInterrupts(); |
112 return KErrNone; |
116 return KErrNone; |
113 } |
117 } |
114 |
118 |
115 void InitTimestamp(TSubScheduler* aSS, SNThreadCreateInfo& aInfo) |
119 void InitAPTimestamp(SNThreadCreateInfo& aInfo) |
116 { |
120 { |
117 NThread* t = (NThread*)aSS->iCurrentThread; |
121 volatile SArmAPBootInfo& a = *(volatile SArmAPBootInfo*)aInfo.iParameterBlock; |
118 t->iActiveState = 1; |
122 volatile SAPBootPage& bootPage = *(volatile SAPBootPage*)a.iAPBootLin; |
119 if (aSS->iCpuNum == 0) |
123 NKern::DisableAllInterrupts(); |
120 { |
124 bootPage.iBootFlags2 = 1; |
121 aSS->iLastTimestamp.i64 = 0; |
125 arm_dsb(); |
122 t->iLastActivationTime.i64 = 0; |
126 while (bootPage.iBootFlags2==1) |
123 return; |
127 {} |
124 } |
128 arm_dsb(); |
125 TUint64 ts = 0; |
129 bootPage.iAPTimestamp = NKern::Timestamp(); |
126 #if defined(__NKERN_TIMESTAMP_USE_LOCAL_TIMER__) |
130 arm_dsb(); |
127 #error Use of local timer for NKern::Timestamp() no longer supported |
131 TUint64 bpt = bootPage.iBPTimestamp; |
128 #endif |
132 TUint64 apt = bootPage.iAPTimestamp; |
129 ts = NKern::Timestamp(); |
133 TUint64 delta = bpt - apt; |
130 aSS->iLastTimestamp.i64 = ts; |
134 SubScheduler().iLastTimestamp64 += delta; |
131 t->iLastActivationTime.i64 = ts; |
135 __KTRACE_OPT(KBOOT,DEBUGPRINT("APT=0x%lx BPT=0x%lx Delta=0x%lx", apt, bpt, delta)); |
|
136 arm_dsb(); |
|
137 bootPage.iBootFlags2 = 3; |
|
138 NKern::EnableAllInterrupts(); |
132 } |
139 } |
133 |
140 |