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 4 | 56f325a607ea |
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\ncutils.cia |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32cia.h> |
|
19 |
#include <arm.h> |
|
20 |
#include <arm_gic.h> |
|
21 |
||
22 |
extern TSpinLock BTraceLock; |
|
23 |
||
24 |
extern "C" { |
|
25 |
extern TUint32 CrashStateOut; |
|
26 |
extern SFullArmRegSet DefaultRegSet; |
|
27 |
} |
|
28 |
||
29 |
//#define __DBG_MON_FAULT__ |
|
30 |
//#define __RAM_LOADED_CODE__ |
|
31 |
//#define __EARLY_DEBUG__ |
|
32 |
||
33 |
#ifdef _DEBUG |
|
34 |
#define ASM_KILL_LINK(rp,rs) asm("mov "#rs", #0xdf ");\ |
|
35 |
asm("orr "#rs", "#rs", "#rs", lsl #8 ");\ |
|
36 |
asm("orr "#rs", "#rs", "#rs", lsl #16 ");\ |
|
37 |
asm("str "#rs", ["#rp"] ");\ |
|
38 |
asm("str "#rs", ["#rp", #4] "); |
|
39 |
#else |
|
40 |
#define ASM_KILL_LINK(rp,rs) |
|
41 |
#endif |
|
42 |
||
43 |
#ifdef __PRI_LIST_MACHINE_CODED__ |
|
44 |
/** Return the priority of the highest priority item present on a priority list. |
|
45 |
||
46 |
@return The highest priority present or -1 if the list is empty. |
|
47 |
*/ |
|
48 |
EXPORT_C __NAKED__ TInt TPriListBase::HighestPriority() |
|
49 |
{ |
|
50 |
asm("ldr r2, [r0, #4] "); // r2=iPresent MSW |
|
51 |
asm("ldr r1, [r0, #0] "); // r1=iPresent LSW |
|
52 |
CLZ(0,2); // r0=31-MSB(r2) |
|
53 |
asm("subs r0, r0, #32 "); // r0=-1-MSB(r2), 0 if r2=0 |
|
54 |
CLZcc(CC_EQ,0,1); // if r2=0, r0=31-MSB(r1) |
|
55 |
asm("rsb r0, r0, #31 "); // r0=highest priority |
|
56 |
__JUMP(,lr); |
|
57 |
} |
|
58 |
||
59 |
/** Find the highest priority item present on a priority list. |
|
60 |
If multiple items at the same priority are present, return the first to be |
|
61 |
added in chronological order. |
|
62 |
||
63 |
@return a pointer to the item or NULL if the list is empty. |
|
64 |
*/ |
|
65 |
EXPORT_C __NAKED__ TPriListLink* TPriListBase::First() |
|
66 |
{ |
|
67 |
asm("ldr r2, [r0, #4] "); // r2=iPresent MSW |
|
68 |
asm("ldr r1, [r0], #8 "); // r1=iPresent LSW, r0=&iQueue[0] |
|
69 |
CLZ(3,2); // r3=31-MSB(r2) |
|
70 |
asm("subs r3, r3, #32 "); // r3=-1-MSB(r2), 0 if r2=0 |
|
71 |
CLZcc(CC_EQ,3,1); // if r2=0, r3=31-MSB(r1) |
|
72 |
asm("rsbs r3, r3, #31 "); // r3=highest priority |
|
73 |
asm("ldrpl r0, [r0, r3, lsl #2] "); // if r3>=0 list is nonempty, r0->first entry |
|
74 |
asm("movmi r0, #0 "); // if r3<0 list empty, return NULL |
|
75 |
__JUMP(,lr); |
|
76 |
} |
|
77 |
||
78 |
/** Add an item to a priority list. |
|
79 |
||
80 |
@param aLink = a pointer to the item - must not be NULL |
|
81 |
*/ |
|
82 |
EXPORT_C __NAKED__ void TPriListBase::Add(TPriListLink* /*aLink*/) |
|
83 |
{ |
|
84 |
asm("ldrb r2, [r1, #8]" ); // r2=priority of aLink |
|
85 |
asm("add ip, r0, #8 "); // ip=&iQueue[0] |
|
86 |
asm("ldr r3, [ip, r2, lsl #2]! "); // r3->first entry at this priority |
|
87 |
asm("cmp r3, #0 "); // is this first entry at this priority? |
|
88 |
asm("bne pri_list_add_1 "); // branch if not |
|
89 |
asm("str r1, [ip] "); // if queue originally empty, iQueue[pri]=aThread |
|
90 |
asm("ldrb ip, [r0, r2, lsr #3]! "); // ip=relevant byte of present mask, r0->same |
|
91 |
asm("and r2, r2, #7 "); |
|
92 |
asm("mov r3, #1 "); |
|
93 |
asm("str r1, [r1, #0] "); // aThread->next=aThread |
|
94 |
asm("orr ip, ip, r3, lsl r2 "); // ip |= 1<<(pri&7) |
|
95 |
asm("str r1, [r1, #4] "); // aThread->iPrev=aThread |
|
96 |
asm("strb ip, [r0] "); // update relevant byte of present mask |
|
97 |
__JUMP(,lr); |
|
98 |
asm("pri_list_add_1: "); |
|
99 |
asm("ldr ip, [r3, #4] "); // if nonempty, ip=last |
|
100 |
asm("str r1, [r3, #4] "); // first->prev=aThread |
|
101 |
asm("stmia r1, {r3,ip} "); // aThread->next=r3=first, aThread->prev=ip=last |
|
102 |
asm("str r1, [ip, #0] "); // last->next=aThread |
|
103 |
__JUMP(,lr); |
|
104 |
} |
|
105 |
||
106 |
||
107 |
/** Removes an item from a priority list. |
|
108 |
||
109 |
@param aLink A pointer to the item - this must not be NULL. |
|
110 |
*/ |
|
111 |
EXPORT_C __NAKED__ void TPriListBase::Remove(TPriListLink* /*aLink*/) |
|
112 |
{ |
|
113 |
asm("ldmia r1, {r2,r3} "); // r2=aLink->iNext, r3=aLink->iPrev |
|
114 |
ASM_KILL_LINK(r1,r12); |
|
115 |
asm("subs r12, r1, r2 "); // check if more threads at this priority, r12=0 if not |
|
116 |
asm("bne 1f "); // branch if there are more at same priority |
|
117 |
asm("ldrb r2, [r1, #%a0]" : : "i" _FOFF(NThread, iPriority)); // r2=thread priority |
|
118 |
asm("add r1, r0, #%a0" : : "i" _FOFF(TPriListBase, iQueue)); // r1->iQueue[0] |
|
119 |
asm("str r12, [r1, r2, lsl #2] "); // iQueue[priority]=NULL |
|
120 |
asm("ldrb r1, [r0, r2, lsr #3] "); // r1=relevant byte in present mask |
|
121 |
asm("and r3, r2, #7 "); // r3=priority & 7 |
|
122 |
asm("mov r12, #1 "); |
|
123 |
asm("bic r1, r1, r12, lsl r3 "); // clear bit in present mask |
|
124 |
asm("strb r1, [r0, r2, lsr #3] "); // update relevant byte in present mask |
|
125 |
__JUMP(,lr); |
|
126 |
asm("1: "); // get here if there are other threads at same priority |
|
127 |
asm("ldrb r12, [r1, #%a0]" : : "i" _FOFF(NThread, iPriority)); // r12=thread priority |
|
128 |
asm("add r0, r0, #%a0" : : "i" _FOFF(TPriListBase, iQueue)); // r0=&iQueue[0] |
|
129 |
asm("str r3, [r2, #4] "); // next->prev=prev |
|
130 |
asm("ldr r12, [r0, r12, lsl #2]! "); // r12=iQueue[priority], r0=&iQueue[priority] |
|
131 |
asm("str r2, [r3, #0] "); // and prev->next=next |
|
132 |
asm("cmp r12, r1 "); // if aThread was first... |
|
133 |
asm("streq r2, [r0, #0] "); // iQueue[priority]=aThread->next |
|
134 |
__JUMP(,lr); // finished |
|
135 |
} |
|
136 |
||
137 |
||
138 |
/** Change the priority of an item on a priority list |
|
139 |
||
140 |
@param aLink = pointer to the item to act on - must not be NULL |
|
141 |
@param aNewPriority = new priority for the item |
|
142 |
*/ |
|
143 |
EXPORT_C __NAKED__ void TPriListBase::ChangePriority(TPriListLink* /*aLink*/, TInt /*aNewPriority*/) |
|
144 |
{ |
|
145 |
asm("ldrb r3, [r1, #8] "); // r3=old priority |
|
146 |
asm("stmfd sp!, {r4-r6,lr} "); |
|
147 |
asm("cmp r3, r2 "); |
|
148 |
asm("ldmeqfd sp!, {r4-r6,pc} "); // if old priority=new, finished |
|
149 |
asm("ldmia r1, {r4,r12} "); // r4=next, r12=prev |
|
150 |
asm("ldmia r0!, {r6,lr} "); // lr:r6=present mask, r0=&iQueue[0] |
|
151 |
asm("subs r5, r4, r1 "); // check if aLink is only one at that priority, r5=0 if it is |
|
152 |
asm("beq change_pri_1 "); // branch if it is |
|
153 |
asm("ldr r5, [r0, r3, lsl #2] "); // r5=iQueue[old priority] |
|
154 |
asm("str r4, [r12, #0] "); // prev->next=next |
|
155 |
asm("str r12, [r4, #4] "); // next->prev=prev |
|
156 |
asm("cmp r5, r1 "); // was aLink first? |
|
157 |
asm("streq r4, [r0, r3, lsl #2] "); // if it was, iQueue[old priority]=aLink->next |
|
158 |
asm("b change_pri_2 "); |
|
159 |
asm("change_pri_1: "); |
|
160 |
asm("str r5, [r0, r3, lsl #2] "); // if empty, set iQueue[old priority]=NULL |
|
161 |
asm("mov r12, #0x80000000 "); |
|
162 |
asm("rsbs r3, r3, #31 "); // r3=31-priority |
|
163 |
asm("bicmi lr, lr, r12, ror r3 "); // if pri>31, clear bit is MS word |
|
164 |
asm("bicpl r6, r6, r12, ror r3 "); // if pri<=31, clear bit in LS word |
|
165 |
asm("change_pri_2: "); |
|
166 |
asm("ldr r4, [r0, r2, lsl #2] "); // r4=iQueue[new priority] |
|
167 |
asm("strb r2, [r1, #8] "); // store new priority |
|
168 |
asm("cmp r4, #0 "); // new priority queue empty? |
|
169 |
asm("bne change_pri_3 "); // branch if not |
|
170 |
asm("str r1, [r0, r2, lsl #2] "); // if new priority queue was empty, iQueue[new p]=aLink |
|
171 |
asm("mov r12, #0x80000000 "); |
|
172 |
asm("str r1, [r1, #0] "); // aLink->next=aLink |
|
173 |
asm("rsbs r2, r2, #31 "); // r2=31-priority |
|
174 |
asm("str r1, [r1, #4] "); // aLink->prev=aLink |
|
175 |
asm("orrmi lr, lr, r12, ror r2 "); // if pri>31, set bit is MS word |
|
176 |
asm("orrpl r6, r6, r12, ror r2 "); // if pri<=31, set bit in LS word |
|
177 |
asm("stmdb r0!, {r6,lr} "); // store present mask and restore r0 |
|
178 |
asm("ldmfd sp!, {r4-r6,pc} "); |
|
179 |
asm("change_pri_3: "); |
|
180 |
asm("ldr r12, [r4, #4] "); // r12->last link at this priority |
|
181 |
asm("str r1, [r4, #4] "); // first->prev=aLink |
|
182 |
asm("str r1, [r12, #0] "); // old last->next=aLink |
|
183 |
asm("stmia r1, {r4,r12} "); // aLink->next=r3=first, aLink->prev=r12=old last |
|
184 |
asm("stmdb r0!, {r6,lr} "); // store present mask and restore r0 |
|
185 |
asm("ldmfd sp!, {r4-r6,pc} "); |
|
186 |
} |
|
187 |
#endif |
|
188 |
||
189 |
__NAKED__ void initialiseState(TInt /*aCpu*/, TSubScheduler* /*aSS*/) |
|
190 |
{ |
|
191 |
SET_RWNO_TID(,r1); |
|
192 |
__ASM_CLI_MODE(MODE_ABT); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
193 |
asm("str sp, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iAbtStackTop)); |
0 | 194 |
asm("mvn r3, #0 "); |
195 |
asm("str r3, [sp, #%a0]" : : "i" _FOFF(SFullArmRegSet, iExcCode)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
196 |
asm("str r3, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iIrqNestCount)); |
0 | 197 |
__ASM_CLI_MODE(MODE_UND); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
198 |
asm("str sp, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iUndStackTop)); |
0 | 199 |
__ASM_CLI_MODE(MODE_FIQ); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
200 |
asm("str sp, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iFiqStackTop)); |
0 | 201 |
__ASM_CLI_MODE(MODE_IRQ); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
202 |
asm("str sp, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iIrqStackTop)); |
0 | 203 |
__ASM_CLI_MODE(MODE_SVC); |
204 |
asm("ldr r2, __TheScheduler "); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
205 |
asm("ldr r3, [r2, #%a0]" : : "i" _FOFF(TScheduler, iSX.iScuAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
206 |
asm("str r3, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iScuAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
207 |
asm("ldr r3, [r2, #%a0]" : : "i" _FOFF(TScheduler, iSX.iGicDistAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
208 |
asm("str r3, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iGicDistAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
209 |
asm("ldr r3, [r2, #%a0]" : : "i" _FOFF(TScheduler, iSX.iGicCpuIfcAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
210 |
asm("str r3, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iGicCpuIfcAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
211 |
asm("ldr r3, [r2, #%a0]" : : "i" _FOFF(TScheduler, iSX.iLocalTimerAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
212 |
asm("str r3, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iLocalTimerAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
213 |
asm("ldr r3, [r2, #%a0]" : : "i" _FOFF(TScheduler, iSX.iGlobalTimerAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
214 |
asm("str r3, [r1, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iGlobalTimerAddr)); |
0 | 215 |
asm("mov r3, #0 "); |
216 |
SET_RWRO_TID(,r3); |
|
217 |
SET_RWRW_TID(,r3); |
|
218 |
||
219 |
__JUMP(,lr); |
|
220 |
||
221 |
asm("__TheScheduler: "); |
|
222 |
asm(".word TheScheduler "); |
|
223 |
} |
|
224 |
||
225 |
__NAKED__ TUint32 __mpid() |
|
226 |
{ |
|
227 |
asm("mrc p15, 0, r0, c0, c0, 5 "); |
|
228 |
__JUMP(,lr); |
|
229 |
} |
|
230 |
||
231 |
/** @internalTechnology |
|
232 |
||
233 |
Called to indicate that the system has crashed and all CPUs should be |
|
234 |
halted and should dump their registers. |
|
235 |
||
236 |
*/ |
|
237 |
__NAKED__ void NKern::NotifyCrash(const TAny* /*a0*/, TInt /*a1*/) |
|
238 |
{ |
|
239 |
asm("stmfd sp!, {r0-r1} "); // save parameters |
|
240 |
GET_RWNO_TID(,r0); |
|
241 |
asm("cmp r0, #0 "); |
|
242 |
asm("ldreq r0, __SS0 "); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
243 |
asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iRegs)); |
0 | 244 |
asm("cmp r0, #0 "); |
245 |
asm("ldreq r0, __DefaultRegs "); |
|
246 |
asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet, iExcCode)); |
|
247 |
asm("cmp r1, #0 "); // context already saved? |
|
248 |
asm("bge state_already_saved "); // skip if so |
|
249 |
asm("mov r1, lr "); |
|
250 |
asm("bl " CSM_ZN3Arm9SaveStateER14SFullArmRegSet ); |
|
251 |
asm("str r1, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet, iN.iR15)); |
|
252 |
asm("ldmia sp!, {r2-r3} "); // original R0,R1 |
|
253 |
asm("stmia r0, {r2-r3} "); // save original R0,R1 |
|
254 |
asm("add r1, r0, #%a0" : : "i" _FOFF(SFullArmRegSet, iExcCode)); |
|
255 |
asm("mov r4, r0 "); // save pointer to i_Regs |
|
256 |
asm("stmib r1, {r2-r3} "); // save a0, a1 in iCrashArgs |
|
257 |
asm("mov r1, #13 "); // r1 = regnum |
|
258 |
asm("mrs r2, cpsr "); // r2 = mode |
|
259 |
asm("bl " CSM_ZN3Arm3RegER14SFullArmRegSetim ); // r0 = pointer to exception mode R13 |
|
260 |
asm("str sp, [r0] "); // save correct original value for exception mode R13 |
|
261 |
asm("b state_save_complete "); |
|
262 |
||
263 |
asm("state_already_saved: "); |
|
264 |
asm("ldmia sp!, {r2-r3} "); // original R0,R1 |
|
265 |
asm("add r1, r0, #%a0" : : "i" _FOFF(SFullArmRegSet, iExcCode)); |
|
266 |
asm("ldr r4, [r1, #4]! "); |
|
267 |
asm("cmp r4, #0 "); |
|
268 |
asm("stmeqia r1, {r2-r3} "); // save a0, a1 in iCrashArgs, provided iCrashArgs not already set |
|
269 |
asm("mov r4, r0 "); // save pointer to i_Regs |
|
270 |
asm("state_save_complete: "); |
|
271 |
||
272 |
__ASM_CLI_MODE(MODE_FIQ); // mode_fiq, interrupts off |
|
273 |
GET_RWNO_TID(,r0); |
|
274 |
asm("ldr r1, __CrashState "); |
|
275 |
asm("cmp r0, #0 "); |
|
276 |
asm("moveq r2, #1 "); |
|
277 |
asm("streq r2, [r1] "); |
|
278 |
asm("beq skip_other_cores "); // If subscheduler not yet set, don't bother with other cores |
|
279 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iCpuMask)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
280 |
asm("ldr r5, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iGicCpuIfcAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
281 |
// asm("ldr r4, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iRegs)); |
0 | 282 |
asm("bic sp, sp, #4 "); // align stack to multiple of 8 |
283 |
||
284 |
__DATA_MEMORY_BARRIER_Z__(r6); |
|
285 |
asm("1: "); |
|
286 |
LDREX(3,1); |
|
287 |
asm("orr r5, r3, r2 "); |
|
288 |
STREX(12,5,1); // set bit in CrashState for this CPU |
|
289 |
asm("cmp r12, #0 "); |
|
290 |
asm("bne 1b "); |
|
291 |
__DATA_MEMORY_BARRIER__(r6); |
|
292 |
asm("cmp r3, #0 "); // were we first to crash? |
|
293 |
asm("beq first_to_crash "); // branch if so |
|
294 |
||
295 |
// we weren't first to crash, so wait here for a crash IPI |
|
296 |
// disable all interrupts except for CRASH_IPI |
|
297 |
GET_RWNO_TID(,r0); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
298 |
asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iGicCpuIfcAddr)); |
0 | 299 |
asm("mov r1, #0 "); |
300 |
asm("1: "); |
|
301 |
asm("add r1, r1, #1 "); |
|
302 |
asm("str r1, [r0, #%a0]" : : "i" _FOFF(GicCpuIfc, iPriMask)); |
|
303 |
__DATA_SYNC_BARRIER__(r6); |
|
304 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(GicCpuIfc, iPriMask)); |
|
305 |
asm("cmp r2, #0 "); |
|
306 |
asm("beq 1b "); // loop until priority mask is nonzero |
|
307 |
||
308 |
asm("2: "); |
|
309 |
__ASM_STI_MODE(MODE_ABT); |
|
310 |
ARM_WFE; |
|
311 |
asm("b 2b "); // loop until we get a CRASH_IPI |
|
312 |
||
313 |
// This CPU was first to crash |
|
314 |
asm("first_to_crash: "); |
|
315 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iScheduler)); |
|
316 |
asm("ldr r7, __CrashStateOut "); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
317 |
asm("ldr r3, [r2, #%a0]" : : "i" _FOFF(TScheduler, iIpiAcceptCpus)); |
0 | 318 |
asm("str r3, [r7] "); // mask of CPUs pending |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
319 |
asm("ldr r5, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iGicDistAddr)); |
0 | 320 |
asm("ldr r1, __CrashIPIWord "); |
321 |
__DATA_SYNC_BARRIER_Z__(r6); |
|
322 |
asm("str r1, [r5, #%a0]" : : "i" _FOFF(GicDistributor, iSoftIrq)); // send CRASH_IPI to all other CPUs |
|
323 |
__DATA_SYNC_BARRIER__(r6); |
|
324 |
||
325 |
asm("skip_other_cores: "); |
|
326 |
asm("mov r0, #0 "); |
|
327 |
asm("mov r1, #0 "); |
|
328 |
asm("mov r2, #0 "); |
|
329 |
asm("bl NKCrashHandler "); // call NKCrashHandler(0,0,0) |
|
330 |
||
331 |
__DATA_SYNC_BARRIER__(r6); |
|
332 |
GET_RWNO_TID(,r0); |
|
333 |
asm("cmp r0, #0 "); |
|
334 |
asm("beq skip_other_cores2 "); // If subscheduler not yet set, don't bother with other cores |
|
335 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iCpuMask)); |
|
336 |
asm("7: "); |
|
337 |
LDREX(1,7); |
|
338 |
asm("bic r1, r1, r2 "); |
|
339 |
STREX(3,1,7); // atomic { CrashStateOut &= ~iCpuMask; } |
|
340 |
asm("cmp r3, #0 "); |
|
341 |
asm("bne 7b "); |
|
342 |
asm("1: "); |
|
343 |
asm("ldr r1, [r7] "); |
|
344 |
asm("cmp r1, #0 "); // wait for all CPUs to acknowledge |
|
345 |
asm("beq 2f "); |
|
346 |
asm("adds r6, r6, #1 "); |
|
347 |
asm("bne 1b "); // if not ACKed after 2^32 iterations give up waiting |
|
348 |
asm("2: "); |
|
349 |
__DATA_MEMORY_BARRIER_Z__(r0); |
|
350 |
||
351 |
asm("skip_other_cores2: "); |
|
352 |
asm("mov r0, #1 "); |
|
353 |
asm("ldr r1, [r4, #%a0] " : : "i" _FOFF(SFullArmRegSet,iN.iR0)); // original R0 = a0 parameter |
|
354 |
asm("ldr r2, [r4, #%a0] " : : "i" _FOFF(SFullArmRegSet,iN.iR1)); // original R1 = a1 parameter |
|
355 |
asm("bl NKCrashHandler "); // call NKCrashHandler(1,a0,a1) - shouldn't return |
|
356 |
||
357 |
// shouldn't get back here |
|
358 |
__ASM_CRASH(); |
|
359 |
||
360 |
asm("__CrashState: "); |
|
361 |
asm(".word %a0" : : "i" ((TInt)&CrashState)); |
|
362 |
asm("__CrashStateOut: "); |
|
363 |
asm(".word CrashStateOut "); |
|
364 |
asm("__CrashIPIWord: "); |
|
365 |
asm(".word %a0" : : "i" ( (TInt)GIC_IPI_OTHERS(CRASH_IPI_VECTOR) )); |
|
366 |
asm("__SS0: "); |
|
367 |
asm(".word %a0" : : "i" ((TInt)&TheSubSchedulers[0])); |
|
368 |
asm("__DefaultRegs: "); |
|
369 |
asm(".word %a0" : : "i" ((TInt)&DefaultRegSet)); |
|
370 |
} |
|
371 |
||
372 |
||
373 |
#ifdef __USE_BTRACE_LOCK__ |
|
374 |
#define __ASM_ACQUIRE_BTRACE_LOCK(regs) \ |
|
375 |
asm("stmfd sp!, " regs); \ |
|
376 |
asm("ldr r0, __BTraceLock "); \ |
|
377 |
asm("bl " CSM_ZN9TSpinLock11LockIrqSaveEv ); \ |
|
378 |
asm("mov r4, r0 "); \ |
|
379 |
asm("ldmfd sp!, " regs) |
|
380 |
||
381 |
#define __ASM_RELEASE_BTRACE_LOCK() \ |
|
382 |
asm("stmfd sp!, {r0-r1} "); \ |
|
383 |
asm("ldr r0, __BTraceLock "); \ |
|
384 |
asm("mov r1, r4 "); \ |
|
385 |
asm("bl " CSM_ZN9TSpinLock16UnlockIrqRestoreEi ); \ |
|
386 |
asm("ldmfd sp!, {r0-r1} ") |
|
387 |
||
388 |
#else |
|
389 |
#define __ASM_ACQUIRE_BTRACE_LOCK(regs) |
|
390 |
#define __ASM_RELEASE_BTRACE_LOCK() |
|
391 |
#endif |
|
392 |
||
393 |
||
394 |
__NAKED__ EXPORT_C TBool BTrace::Out(TUint32 a0, TUint32 a1, TUint32 a2, TUint32 a3) |
|
395 |
{ |
|
396 |
asm("stmdb sp!, {r2,r3,r4,lr}"); |
|
397 |
__ASM_ACQUIRE_BTRACE_LOCK("{r0-r1}"); |
|
398 |
asm("ldr r12, __BTraceData"); |
|
399 |
asm("and r2, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
400 |
asm("mov r3, r1"); // r3 = a1 (ready for call to handler) |
|
401 |
asm("ldrb r2, [r12, r2, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
402 |
asm("ldr r12, [r12, #%a0]" : : "i" _FOFF(SBTraceData,iHandler)); |
|
403 |
asm("adr lr, 9f"); |
|
404 |
asm("cmp r2, #0"); |
|
405 |
asm("moveq r0, #0"); |
|
406 |
__JUMP(ne, r12); |
|
407 |
asm("9: "); |
|
408 |
__ASM_RELEASE_BTRACE_LOCK(); |
|
409 |
__POPRET("r2,r3,r4,"); |
|
410 |
} |
|
411 |
||
412 |
__NAKED__ EXPORT_C TBool BTrace::OutN(TUint32 a0, TUint32 a1, TUint32 a2, const TAny* aData, TInt aDataSize) |
|
413 |
{ |
|
414 |
asm("stmdb sp!, {r2,r3,r4,lr}"); |
|
415 |
__ASM_ACQUIRE_BTRACE_LOCK("{r0-r3}"); |
|
416 |
asm("ldr r12, __BTraceData"); |
|
417 |
asm("and r2, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
418 |
asm("ldr r14, [sp, #16]"); // r14 = aDataSize |
|
419 |
asm("ldrb r2, [r12, r2, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
420 |
asm("ldr r12, [r12, #%a0]" : : "i" _FOFF(SBTraceData,iHandler)); |
|
421 |
asm("cmp r2, #0"); |
|
422 |
asm("moveq r0, #0"); |
|
423 |
asm("beq 0f "); |
|
424 |
||
425 |
asm("cmp r14, #%a0" : : "i" ((TInt)KMaxBTraceDataArray)); |
|
426 |
asm("movhi r14, #%a0" : : "i" ((TInt)KMaxBTraceDataArray)); |
|
427 |
asm("orrhi r0, r0, #%a0" : : "i" ((TInt)(BTrace::ERecordTruncated<<(BTrace::EFlagsIndex*8)))); |
|
428 |
asm("add r0, r0, r14"); |
|
429 |
asm("subs r14, r14, #1"); |
|
430 |
asm("ldrhs r2, [r3]"); // get first word of aData is aDataSize!=0 |
|
431 |
asm("mov r3, r1"); // r3 = a1 (ready for call to handler) |
|
432 |
asm("cmp r14, #4"); |
|
433 |
asm("strlo r2, [sp, #4]"); // replace aData with first word if aDataSize is 1-4 |
|
434 |
||
435 |
asm("mov lr, pc"); |
|
436 |
__JUMP(, r12); |
|
437 |
asm("0: "); |
|
438 |
__ASM_RELEASE_BTRACE_LOCK(); |
|
439 |
__POPRET("r2,r3,r4,"); |
|
440 |
} |
|
441 |
||
442 |
__NAKED__ EXPORT_C TBool BTrace::OutX(TUint32 a0, TUint32 a1, TUint32 a2, TUint32 a3) |
|
443 |
{ |
|
444 |
asm("stmdb sp!, {r2,r3,r4,lr}"); |
|
445 |
__ASM_ACQUIRE_BTRACE_LOCK("{r0-r1}"); |
|
446 |
asm("ldr r12, __BTraceData"); |
|
447 |
asm("and r2, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
448 |
asm("mov r3, r1"); // r3 = a1 (ready for call to handler) |
|
449 |
asm("ldrb r2, [r12, r2, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
450 |
asm("mrs r14, cpsr "); |
|
451 |
asm("ldr r12, [r12, #%a0]" : : "i" _FOFF(SBTraceData,iHandler)); |
|
452 |
asm("cmp r2, #0"); // check category filter |
|
453 |
asm("moveq r0, #0"); |
|
454 |
asm("beq 0f "); // if category disabled, exit now |
|
455 |
__ASM_CLI(); |
|
456 |
asm("and r2, r14, #0x0f "); |
|
457 |
asm("cmp r2, #3 "); |
|
458 |
asm("movhi r2, #2 "); // r2 = context ID = 1 for FIQ, 2 for IRQ/ABT/UND/SYS |
|
459 |
asm("bne 1f "); |
|
460 |
GET_RWNO_TID(,r1); |
|
461 |
asm("movs r2, r1 "); // r2 = context ID = 0 for early boot, no threads |
|
462 |
asm("beq 1f "); |
|
463 |
asm("ldrb r2, [r1, #%a0]" : : "i" _FOFF(TSubScheduler,iInIDFC)); |
|
464 |
asm("cmp r2, #0 "); |
|
465 |
asm("ldreq r2, [r1, #%a0]" : : "i" _FOFF(TSubScheduler,iCurrentThread)); |
|
466 |
asm("movne r2, #3 "); // r2 = context ID = 3 for IDFC = NThread pointer for thread |
|
467 |
asm("1: "); |
|
468 |
asm("msr cpsr, r14 "); |
|
469 |
asm("mov lr, pc"); |
|
470 |
__JUMP(, r12); |
|
471 |
asm("0: "); |
|
472 |
__ASM_RELEASE_BTRACE_LOCK(); |
|
473 |
__POPRET("r2,r3,r4,"); |
|
474 |
} |
|
475 |
||
476 |
__NAKED__ EXPORT_C TBool BTrace::OutNX(TUint32 a0, TUint32 a1, TUint32 a2, const TAny* aData, TInt aDataSize) |
|
477 |
{ |
|
478 |
asm("stmdb sp!, {r2,r3,r4,lr}"); |
|
479 |
__ASM_ACQUIRE_BTRACE_LOCK("{r0-r3}"); |
|
480 |
asm("ldr r12, __BTraceData"); |
|
481 |
asm("and r2, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
482 |
asm("ldr r14, [sp, #16]"); // r14 = aDataSize |
|
483 |
asm("ldrb r2, [r12, r2, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
484 |
asm("ldr r12, [r12, #%a0]" : : "i" _FOFF(SBTraceData,iHandler)); |
|
485 |
asm("cmp r2, #0"); // check category filter |
|
486 |
asm("moveq r0, #0"); |
|
487 |
asm("beq 0f "); // if category disabled, exit now |
|
488 |
||
489 |
asm("cmp r14, #%a0" : : "i" ((TInt)KMaxBTraceDataArray)); |
|
490 |
asm("movhi r14, #%a0" : : "i" ((TInt)KMaxBTraceDataArray)); |
|
491 |
asm("orrhi r0, r0, #%a0" : : "i" ((TInt)(BTrace::ERecordTruncated<<(BTrace::EFlagsIndex*8)))); |
|
492 |
asm("add r0, r0, r14"); |
|
493 |
asm("subs r14, r14, #1"); |
|
494 |
asm("ldrhs r2, [r3]"); // get first word of aData is aDataSize!=0 |
|
495 |
asm("mov r3, r1"); // r3 = a1 (ready for call to handler) |
|
496 |
asm("cmp r14, #4"); |
|
497 |
asm("strlo r2, [sp, #4]"); // replace aData with first word if aDataSize is 1-4 |
|
498 |
||
499 |
asm("mrs r14, cpsr "); |
|
500 |
__ASM_CLI(); |
|
501 |
asm("and r2, r14, #0x0f "); |
|
502 |
asm("cmp r2, #3 "); |
|
503 |
asm("movhi r2, #2 "); // r2 = context ID = 1 for FIQ, 2 for IRQ/ABT/UND/SYS |
|
504 |
asm("bne 1f "); |
|
505 |
GET_RWNO_TID(,r1); |
|
506 |
asm("movs r2, r1 "); // r2 = context ID = 0 for early boot, no threads |
|
507 |
asm("beq 1f "); |
|
508 |
asm("ldrb r2, [r1, #%a0]" : : "i" _FOFF(TSubScheduler,iInIDFC)); |
|
509 |
asm("cmp r2, #0 "); |
|
510 |
asm("ldreq r2, [r1, #%a0]" : : "i" _FOFF(TSubScheduler,iCurrentThread)); |
|
511 |
asm("movne r2, #3 "); // r2 = context ID = 3 for IDFC = NThread pointer for thread |
|
512 |
asm("1: "); |
|
513 |
asm("msr cpsr, r14 "); |
|
514 |
||
515 |
asm("mov lr, pc"); |
|
516 |
__JUMP(, r12); |
|
517 |
asm("0: "); |
|
518 |
__ASM_RELEASE_BTRACE_LOCK(); |
|
519 |
__POPRET("r2,r3,r4,"); |
|
520 |
} |
|
521 |
||
522 |
__NAKED__ EXPORT_C TBool BTrace::OutBig(TUint32 a0, TUint32 a1, const TAny* aData, TInt aDataSize) |
|
523 |
{ |
|
524 |
asm("stmdb sp!, {r4,lr}"); |
|
525 |
asm("ldr r12, __BTraceData"); |
|
526 |
asm("str lr, [sp, #-4]! "); // PC |
|
527 |
asm("and r14, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
528 |
asm("ldrb r14, [r12, r14, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
529 |
asm("cmp r14, #0"); // check category filter |
|
530 |
asm("addeq sp, sp, #4 "); |
|
531 |
asm("moveq r0, #0 "); |
|
532 |
asm("beq 0f "); // if category disabled, exit now |
|
533 |
||
534 |
asm("mrs r14, cpsr "); |
|
535 |
__ASM_CLI(); |
|
536 |
asm("and r12, r14, #0x0f "); |
|
537 |
asm("cmp r12, #3 "); |
|
538 |
asm("movhi r12, #2 "); // r12 = context ID = 1 for FIQ, 2 for IRQ/ABT/UND/SYS |
|
539 |
asm("bne 1f "); |
|
540 |
GET_RWNO_TID(,r12); |
|
541 |
asm("cmp r12, #0 "); // r2 = context ID = 0 for early boot, no threads |
|
542 |
asm("beq 1f "); |
|
543 |
asm("ldrb r12, [r12, #%a0]" : : "i" _FOFF(TSubScheduler,iInIDFC)); |
|
544 |
asm("cmp r12, #0 "); |
|
545 |
GET_RWNO_TID(eq,r12); |
|
546 |
asm("ldreq r12, [r12, #%a0]" : : "i" _FOFF(TSubScheduler,iCurrentThread)); |
|
547 |
asm("movne r12, #3 "); // r12 = context ID = 3 for IDFC = NThread pointer for thread |
|
548 |
asm("1: "); |
|
549 |
asm("msr cpsr, r14 "); |
|
550 |
asm("str r12, [sp, #-4]! "); // context ID |
|
551 |
asm("bl " CSM_ZN6BTrace8DoOutBigEmmPKvimm); |
|
552 |
asm("add sp, sp, #8"); |
|
553 |
asm("0: "); |
|
554 |
__POPRET("r4,"); |
|
555 |
||
556 |
asm("__BTraceLock: "); |
|
557 |
asm(".word %a0" : : "i" ((TInt)&BTraceLock)); |
|
558 |
asm("__BTraceData: "); |
|
559 |
asm(".word BTraceData "); |
|
560 |
} |
|
561 |
||
562 |
||
563 |
__NAKED__ EXPORT_C TBool BTrace::OutFiltered(TUint32 a0, TUint32 a1, TUint32 a2, TUint32 a3) |
|
564 |
{ |
|
565 |
// fall through to OutFilteredX... |
|
566 |
} |
|
567 |
||
568 |
__NAKED__ EXPORT_C TBool BTrace::OutFilteredX(TUint32 a0, TUint32 a1, TUint32 a2, TUint32 a3) |
|
569 |
{ |
|
570 |
asm("stmdb sp!, {r2,r3,r4,lr}"); |
|
571 |
asm("ldr r12, __BTraceData"); |
|
572 |
asm("and r2, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
573 |
asm("mov r3, r1"); // r3 = a1 (ready for call to handler) |
|
574 |
asm("ldrb r2, [r12, r2, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
575 |
asm("cmp r2, #0"); |
|
576 |
asm("moveq r0, #0"); |
|
577 |
asm("beq 9f "); |
|
578 |
||
579 |
// r0=header, r1=a1=secondary filter UID, r2=unused, r3=a1, r12->SBTraceData |
|
580 |
// if trace enabled return r0,r1,r3 unmodified, r2=context value r12->handler, Z=0 |
|
581 |
// if trace disabled return r0=0 Z=1 |
|
582 |
asm("bl btrace_check_filter2 "); |
|
583 |
asm("beq 9f "); |
|
584 |
__ASM_ACQUIRE_BTRACE_LOCK("{r0,r2,r3,r12}"); |
|
585 |
asm("adr lr, 1f "); |
|
586 |
__JUMP(, r12); |
|
587 |
asm("1: "); |
|
588 |
__ASM_RELEASE_BTRACE_LOCK(); |
|
589 |
asm("9: "); |
|
590 |
__POPRET("r2,r3,r4,"); |
|
591 |
||
592 |
asm("btrace_check_filter2: "); |
|
593 |
asm("stmfd sp!, {r0,r1,r3,r4,r12,lr} "); |
|
594 |
asm("mov r0, r12 "); |
|
595 |
asm("bl CheckFilter2__11SBTraceDataUl "); |
|
596 |
asm("cmp r0, #0 "); |
|
597 |
asm("beq 0f "); |
|
598 |
asm("mrs r14, cpsr "); |
|
599 |
__ASM_CLI(); |
|
600 |
asm("and r2, r14, #0x0f "); |
|
601 |
asm("cmp r2, #3 "); |
|
602 |
asm("movhi r2, #2 "); // r2 = context ID = 1 for FIQ, 2 for IRQ/ABT/UND/SYS |
|
603 |
asm("bne 1f "); |
|
604 |
GET_RWNO_TID(,r4); |
|
605 |
asm("movs r2, r4 "); // r2 = context ID = 0 for early boot, no threads |
|
606 |
asm("beq 1f "); |
|
607 |
asm("ldrb r2, [r4, #%a0]" : : "i" _FOFF(TSubScheduler,iInIDFC)); |
|
608 |
asm("cmp r2, #0 "); |
|
609 |
asm("ldreq r2, [r4, #%a0]" : : "i" _FOFF(TSubScheduler,iCurrentThread)); |
|
610 |
asm("movne r2, #3 "); // r2 = context ID = 3 for IDFC = NThread pointer for thread |
|
611 |
asm("1: "); |
|
612 |
asm("msr cpsr, r14 "); |
|
613 |
asm("0: "); |
|
614 |
asm("ldmfd sp!, {r0,r1,r3,r4,r12,lr} "); |
|
615 |
asm("moveq r0, #0 "); |
|
616 |
asm("ldrne r12, [r12, #%a0]" : : "i" _FOFF(SBTraceData,iHandler)); |
|
617 |
__JUMP(,lr); |
|
618 |
} |
|
619 |
||
620 |
__NAKED__ EXPORT_C TBool BTrace::OutFilteredN(TUint32 a0, TUint32 a1, TUint32 a2, const TAny* aData, TInt aDataSize) |
|
621 |
{ |
|
622 |
// fall through to OutFilteredNX... |
|
623 |
} |
|
624 |
||
625 |
__NAKED__ EXPORT_C TBool BTrace::OutFilteredNX(TUint32 a0, TUint32 a1, TUint32 a2, const TAny* aData, TInt aDataSize) |
|
626 |
{ |
|
627 |
asm("stmdb sp!, {r2,r3,r4,lr}"); |
|
628 |
asm("ldr r12, __BTraceData"); |
|
629 |
asm("and r2, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
630 |
asm("ldrb r2, [r12, r2, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
631 |
asm("cmp r2, #0"); |
|
632 |
asm("moveq r0, #0"); |
|
633 |
asm("beq 9f "); |
|
634 |
||
635 |
// r0=header, r1=a1=secondary filter UID, r2=unused, r3=aData, r12->SBTraceData |
|
636 |
// if trace enabled return r0,r1,r3 unmodified, r2=context value r12->handler, Z=0 |
|
637 |
// if trace disabled return r0=0 Z=1 |
|
638 |
asm("bl btrace_check_filter2 "); |
|
639 |
asm("beq 9f "); |
|
640 |
||
641 |
__ASM_ACQUIRE_BTRACE_LOCK("{r0-r3,r11,r12}"); |
|
642 |
asm("ldr r14, [sp, #16] "); // r14 = aDataSize |
|
643 |
asm("cmp r14, #%a0" : : "i" ((TInt)KMaxBTraceDataArray)); |
|
644 |
asm("movhi r14, #%a0" : : "i" ((TInt)KMaxBTraceDataArray)); |
|
645 |
asm("orrhi r0, r0, #%a0" : : "i" ((TInt)(BTrace::ERecordTruncated<<(BTrace::EFlagsIndex*8)))); |
|
646 |
asm("add r0, r0, r14 "); |
|
647 |
asm("subs r14, r14, #1 "); |
|
648 |
asm("ldrhs r3, [r3] "); // get first word of aData if aDataSize!=0 |
|
649 |
asm("cmp r14, #4 "); |
|
650 |
asm("strlo r3, [sp, #4] "); // replace aData with first word if aDataSize is 1-4 |
|
651 |
asm("mov r3, r1 "); // r3 = a1 (ready for call to handler) |
|
652 |
asm("adr lr, 1f "); |
|
653 |
__JUMP(, r12); |
|
654 |
asm("1: "); |
|
655 |
__ASM_RELEASE_BTRACE_LOCK(); |
|
656 |
asm("9: "); |
|
657 |
__POPRET("r2,r3,r4,"); |
|
658 |
} |
|
659 |
||
660 |
__NAKED__ EXPORT_C TBool BTrace::OutFilteredBig(TUint32 a0, TUint32 a1, const TAny* aData, TInt aDataSize) |
|
661 |
{ |
|
662 |
asm("stmdb sp!, {r4,lr} "); |
|
663 |
asm("ldr r12, __BTraceData "); |
|
664 |
asm("stmfd sp!, {r2,lr} "); // save aData, PC |
|
665 |
asm("and r14, r0, #%a0" : : "i" ((TInt)(0xff<<(BTrace::ECategoryIndex*8)))); |
|
666 |
asm("ldrb r14, [r12, r14, lsr #%a0]" : : "i" ((TInt)(BTrace::ECategoryIndex*8))); |
|
667 |
asm("cmp r14, #0 "); // check category filter |
|
668 |
asm("blne btrace_check_filter2 "); // if enabled, check secondary filter |
|
669 |
asm("addeq sp, sp, #8 "); |
|
670 |
asm("moveq r0, #0 "); |
|
671 |
asm("beq 9f "); // if category or secondary filter disabled, exit now |
|
672 |
asm("mov r12, r2 "); |
|
673 |
asm("ldr r2, [sp, #0] "); // restore aData into r2 |
|
674 |
asm("str r12, [sp, #0] "); // Context ID |
|
675 |
asm("bl " CSM_ZN6BTrace8DoOutBigEmmPKvimm); |
|
676 |
asm("add sp, sp, #8 "); |
|
677 |
asm("9: "); |
|
678 |
__POPRET("r4,"); |
|
679 |
} |
|
680 |
||
681 |
||
682 |
/******************************************************************************/ |
|
683 |
||
684 |
/** Save all the ARM registers |
|
685 |
||
686 |
@internalTechnology |
|
687 |
*/ |
|
688 |
__NAKED__ void Arm::SaveState(SFullArmRegSet&) |
|
689 |
{ |
|
690 |
asm("stmia r0, {r0-r14}^ "); // save R0-R7, R8_usr-R14_usr |
|
691 |
asm("str lr, [r0, #60]! "); // save R15 |
|
692 |
asm("mrs r1, cpsr "); |
|
693 |
asm("str r1, [r0, #4]! "); // save CPSR |
|
694 |
asm("bic r2, r1, #0x1f "); |
|
695 |
asm("orr r2, r2, #0xd3 "); // mode_svc, all interrupts off |
|
696 |
asm("msr cpsr, r2 "); |
|
697 |
asm("stmib r0!, {r13,r14} "); // save R13_svc, R14_svc |
|
698 |
asm("mrs r3, spsr "); |
|
699 |
asm("str r3, [r0, #4]! "); // save SPSR_svc |
|
700 |
asm("bic r2, r1, #0x1f "); |
|
701 |
asm("orr r2, r2, #0xd7 "); // mode_abt, all interrupts off |
|
702 |
asm("msr cpsr, r2 "); |
|
703 |
asm("stmib r0!, {r13,r14} "); // save R13_abt, R14_abt |
|
704 |
asm("mrs r3, spsr "); |
|
705 |
asm("str r3, [r0, #4]! "); // save SPSR_abt |
|
706 |
asm("bic r2, r1, #0x1f "); |
|
707 |
asm("orr r2, r2, #0xdb "); // mode_und, all interrupts off |
|
708 |
asm("msr cpsr, r2 "); |
|
709 |
asm("stmib r0!, {r13,r14} "); // save R13_und, R14_und |
|
710 |
asm("mrs r3, spsr "); |
|
711 |
asm("str r3, [r0, #4]! "); // save SPSR_und |
|
712 |
asm("bic r2, r1, #0x1f "); |
|
713 |
asm("orr r2, r2, #0xd2 "); // mode_irq, all interrupts off |
|
714 |
asm("msr cpsr, r2 "); |
|
715 |
asm("stmib r0!, {r13,r14} "); // save R13_irq, R14_irq |
|
716 |
asm("mrs r3, spsr "); |
|
717 |
asm("str r3, [r0, #4]! "); // save SPSR_irq |
|
718 |
asm("bic r2, r1, #0x1f "); |
|
719 |
asm("orr r2, r2, #0xd1 "); // mode_fiq, all interrupts off |
|
720 |
asm("msr cpsr, r2 "); |
|
721 |
asm("stmib r0!, {r8-r14} "); // save R8_fiq ... R14_fiq |
|
722 |
asm("mrs r3, spsr "); |
|
723 |
asm("str r3, [r0, #4]! "); // save SPSR_fiq |
|
724 |
asm("bic r2, r1, #0x1f "); |
|
725 |
asm("orr r2, r2, #0xd3 "); // mode_svc, all interrupts off |
|
726 |
asm("msr cpsr, r2 "); |
|
727 |
||
728 |
asm("mov r4, #0 "); |
|
729 |
asm("mov r5, #0 "); |
|
730 |
asm("mov r6, #0 "); |
|
731 |
asm("mov r7, #0 "); |
|
732 |
asm("mov r8, #0 "); |
|
733 |
asm("mov r9, #0 "); |
|
734 |
asm("mov r10, #0 "); |
|
735 |
asm("mov r11, #0 "); |
|
736 |
||
737 |
// monitor mode - skip for now |
|
738 |
asm("mov r3, #0 "); |
|
739 |
asm("stmib r0!, {r4-r6} "); // R13_mon, R14_mon, SPSR_mon |
|
740 |
||
741 |
// zero spare words |
|
742 |
asm("mov r3, #0 "); |
|
743 |
asm("stmib r0!, {r4-r11} "); |
|
744 |
asm("add r0, r0, #4 "); // r0 = &a.iA |
|
745 |
||
746 |
#ifdef __CPU_ARMV7 |
|
747 |
asm("mrc p14, 6, r3, c1, c0, 0 "); |
|
748 |
#else |
|
749 |
asm("mov r3, #0 "); |
|
750 |
#endif |
|
751 |
asm("str r3, [r0], #4 "); // TEEHBR |
|
752 |
#ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG |
|
753 |
GET_CAR(,r3); |
|
754 |
#else |
|
755 |
asm("mov r3, #0 "); |
|
756 |
#endif |
|
757 |
asm("str r3, [r0], #4 "); // CPACR |
|
758 |
||
759 |
// skip SCR, SDER, NSACR, PMCR, MVBAR for now |
|
760 |
asm("mov r3, #0 "); |
|
761 |
asm("stmia r0!, {r4-r8} "); // SCR, SDER, NSACR, PMCR, MVBAR |
|
762 |
||
763 |
// zero spare words |
|
764 |
asm("mov r3, #0 "); |
|
765 |
asm("stmia r0!, {r3-r11} "); // r0 = &a.iB[0] |
|
766 |
||
767 |
// just fill in iB[0] |
|
768 |
#ifdef __CPU_HAS_MMU |
|
769 |
asm("mrc p15, 0, r3, c1, c0, 0 "); |
|
770 |
asm("str r3, [r0], #4 "); // SCTLR |
|
771 |
#ifdef __CPU_HAS_ACTLR |
|
772 |
asm("mrc p15, 0, r3, c1, c0, 1 "); |
|
773 |
#else |
|
774 |
asm("mov r3, #0 "); |
|
775 |
#endif |
|
776 |
asm("str r3, [r0], #4 "); // ACTLR |
|
777 |
asm("mrc p15, 0, r3, c2, c0, 0 "); |
|
778 |
asm("str r3, [r0], #4 "); // TTBR0 |
|
779 |
#ifdef __CPU_HAS_TTBR1 |
|
780 |
asm("mrc p15, 0, r2, c2, c0, 1 "); |
|
781 |
asm("mrc p15, 0, r3, c2, c0, 2 "); |
|
782 |
#else |
|
783 |
asm("mov r2, #0 "); |
|
784 |
asm("mov r3, #0 "); |
|
785 |
#endif |
|
786 |
asm("stmia r0!, {r2,r3} "); // TTBR1, TTBCR |
|
787 |
asm("mrc p15, 0, r3, c3, c0, 0 "); |
|
788 |
asm("str r3, [r0], #4 "); // DACR |
|
789 |
#ifdef __CPU_MEMORY_TYPE_REMAPPING |
|
790 |
asm("mrc p15, 0, r2, c10, c2, 0 "); |
|
791 |
asm("mrc p15, 0, r3, c10, c2, 1 "); |
|
792 |
#else |
|
793 |
asm("mov r2, #0 "); |
|
794 |
asm("mov r3, #0 "); |
|
795 |
#endif |
|
796 |
asm("stmia r0!, {r2,r3} "); // PRRR, NMRR |
|
797 |
#ifdef __CPU_ARMV7 |
|
798 |
asm("mrc p15, 0, r3, c12, c0, 0 "); |
|
799 |
#else |
|
800 |
asm("mov r3, #0 "); |
|
801 |
#endif |
|
802 |
asm("str r3, [r0], #4 "); // VBAR |
|
803 |
#if defined(__CPU_SA1) || defined(__CPU_ARM920T) || defined(__CPU_ARM925T) || defined(__CPU_ARMV5T) || defined(__CPU_ARMV6) || defined(__CPU_ARMV7) |
|
804 |
asm("mrc p15, 0, r3, c13, c0, 0 "); |
|
805 |
#else |
|
806 |
asm("mov r3, #0 "); |
|
807 |
#endif |
|
808 |
asm("str r3, [r0], #4 "); // FCSEIDR |
|
809 |
#if defined(__CPU_ARMV6) || defined(__CPU_ARMV7) |
|
810 |
asm("mrc p15, 0, r3, c13, c0, 1 "); |
|
811 |
#else |
|
812 |
asm("mov r3, #0 "); |
|
813 |
#endif |
|
814 |
asm("str r3, [r0], #4 "); // CONTEXTIDR |
|
815 |
#ifdef __CPU_HAS_CP15_THREAD_ID_REG |
|
816 |
GET_RWRW_TID(,r2); |
|
817 |
GET_RWRO_TID(,r3); |
|
818 |
GET_RWNO_TID(,r12); |
|
819 |
#else |
|
820 |
asm("mov r2, #0 "); |
|
821 |
asm("mov r3, #0 "); |
|
822 |
asm("mov r12, #0 "); |
|
823 |
#endif |
|
824 |
asm("stmia r0!, {r2,r3,r12} "); // RWRWTID, RWROTID, RWNOTID |
|
825 |
asm("mrc p15, 0, r2, c5, c0, 0 "); // DFSR |
|
826 |
#ifdef __CPU_ARM_HAS_SPLIT_FSR |
|
827 |
asm("mrc p15, 0, r3, c5, c0, 1 "); // IFSR |
|
828 |
#else |
|
829 |
asm("mov r3, #0 "); |
|
830 |
#endif |
|
831 |
asm("stmia r0!, {r2,r3} "); // DFSR, IFSR |
|
832 |
#ifdef __CPU_ARMV7 |
|
833 |
asm("mrc p15, 0, r2, c5, c1, 0 "); // ADFSR |
|
834 |
asm("mrc p15, 0, r3, c5, c1, 1 "); // AIFSR |
|
835 |
#else |
|
836 |
asm("mov r2, #0 "); |
|
837 |
asm("mov r3, #0 "); |
|
838 |
#endif |
|
839 |
asm("stmia r0!, {r2,r3} "); // ADFSR, AIFSR |
|
840 |
asm("mrc p15, 0, r2, c6, c0, 0 "); // DFAR |
|
841 |
#ifdef __CPU_ARM_HAS_CP15_IFAR |
|
842 |
asm("mrc p15, 0, r3, c6, c0, 2 "); // IFAR |
|
843 |
#else |
|
844 |
asm("mov r3, #0 "); |
|
845 |
#endif |
|
846 |
asm("stmia r0!, {r2,r3} "); // DFAR, IFAR |
|
847 |
||
848 |
// zero spare words |
|
849 |
asm("stmia r0!, {r4-r7} "); |
|
850 |
asm("stmia r0!, {r4-r11} "); |
|
851 |
#else // __CPU_HAS_MMU |
|
852 |
asm("stmia r0!, {r4-r11} "); // no MMU so zero fill |
|
853 |
asm("stmia r0!, {r4-r11} "); // no MMU so zero fill |
|
854 |
asm("stmia r0!, {r4-r11} "); // no MMU so zero fill |
|
855 |
asm("stmia r0!, {r4-r11} "); // no MMU so zero fill |
|
856 |
#endif // __CPU_HAS_MMU |
|
857 |
||
858 |
// zero iB[1] |
|
859 |
asm("stmia r0!, {r4-r11} "); |
|
860 |
asm("stmia r0!, {r4-r11} "); |
|
861 |
asm("stmia r0!, {r4-r11} "); |
|
862 |
asm("stmia r0!, {r4-r11} "); // r0 = &a.iMore[0] |
|
863 |
asm("add r1, r0, #62*8 "); // r1 = &a.iExcCode |
|
864 |
||
865 |
// Save VFP state |
|
866 |
// Save order: |
|
867 |
// FPEXC FPSCR |
|
868 |
// VFPv2 ONLY: FPINST FPINST2 |
|
869 |
// D0-D3 D4-D7 D8-D11 D12-D15 |
|
870 |
// VFPv3 ONLY: D16-D19 D20-D23 D24-D27 D28-D31 |
|
871 |
#ifdef __CPU_HAS_VFP |
|
872 |
GET_CAR(,r2); |
|
873 |
asm("bic r2, r2, #0x00f00000 "); |
|
874 |
#ifdef __VFP_V3 |
|
875 |
asm("bic r2, r2, #0xc0000000 "); // mask off ASEDIS, D32DIS |
|
876 |
#endif |
|
877 |
asm("orr r2, r2, #0x00500000 "); // enable privileged access to CP10, CP11 |
|
878 |
SET_CAR(,r2); |
|
879 |
VFP_FMRX(,2,VFP_XREG_FPEXC); // r2=FPEXC |
|
880 |
asm("orr r3, r2, #%a0" : : "i" ((TInt)VFP_FPEXC_EN)); |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
881 |
asm("bic r3, r3, #%a0" : : "i" ((TInt)VFP_FPEXC_EX)); |
0 | 882 |
VFP_FMXR(,VFP_XREG_FPEXC,3); // enable VFP |
883 |
__DATA_SYNC_BARRIER__(r4); |
|
884 |
__INST_SYNC_BARRIER__(r4); |
|
885 |
VFP_FMRX(,3,VFP_XREG_FPSCR); // r3=FPSCR |
|
886 |
asm("stmia r0!, {r2,r3} "); // |
|
887 |
#ifdef __VFP_V3 |
|
888 |
VFP_FSTMIADW(CC_AL,0,0,16); // save D0 - D15 |
|
889 |
VFP_FMRX(,3,VFP_XREG_MVFR0); |
|
890 |
asm("tst r3, #%a0" : : "i" ((TInt)VFP_MVFR0_ASIMD32)); // check to see if all 32 Advanced SIMD registers are present |
|
891 |
VFP_FSTMIADW(CC_NE,0,16,16); // if so then save D15 - D31 (don't need to check CPACR.D32DIS as it is cleared above) |
|
892 |
#else |
|
893 |
VFP_FMRX(,2,VFP_XREG_FPINST); |
|
894 |
VFP_FMRX(,3,VFP_XREG_FPINST2); |
|
895 |
asm("stmia r0!, {r2,r3} "); // FPINST, FPINST2 |
|
896 |
VFP_FSTMIADW(CC_AL,0,0,16); // save D0 - D15 |
|
897 |
#endif |
|
898 |
#endif // __CPU_HAS_VFP |
|
899 |
asm("1: "); |
|
900 |
asm("cmp r0, r1 "); |
|
901 |
asm("strlo r4, [r0], #4 "); // clear up to end of iMore[61] |
|
902 |
asm("blo 1b "); |
|
903 |
asm("mov r1, #%a0" : : "i" ((TInt)KMaxTInt)); |
|
904 |
asm("stmia r0!, {r1,r5-r7} "); // iExcCode=KMaxTInt, iCrashArgs[0...2]=0 |
|
905 |
asm("sub r0, r0, #1024 "); // r0 = &a |
|
906 |
#ifdef __CPU_HAS_VFP |
|
907 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iMore[0])); |
|
908 |
VFP_FMXR(,VFP_XREG_FPEXC,2); // restore FPEXC |
|
909 |
__DATA_SYNC_BARRIER__(r4); |
|
910 |
__INST_SYNC_BARRIER__(r4); |
|
911 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iA.iCPACR)); |
|
912 |
SET_CAR(,r2); // restore CPACR |
|
913 |
#endif |
|
914 |
asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iFlags)); |
|
915 |
asm("orr r1, r1, #0xC0 "); // interrupts off |
|
916 |
asm("msr cpsr, r1 "); // restore CPSR with interrupts off |
|
917 |
asm("ldmia r0, {r0-r11} "); // restore R4-R11 |
|
918 |
__JUMP(,lr); |
|
919 |
} |
|
920 |
||
921 |
||
922 |
/** Update the saved ARM registers with information from an exception |
|
923 |
||
924 |
@internalTechnology |
|
925 |
*/ |
|
926 |
__NAKED__ void Arm::UpdateState(SFullArmRegSet&, TArmExcInfo&) |
|
927 |
{ |
|
928 |
asm("ldr r2, [r1, #%a0]" : : "i" _FOFF(TArmExcInfo, iExcCode)); |
|
929 |
asm("cmp r2, #%a0 " : : "i" ((TInt)EArmExceptionPrefetchAbort)); |
|
930 |
asm("ldmia r1!, {r2,r3,r12} "); |
|
931 |
asm("streq r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iB[0].iIFAR)); |
|
932 |
asm("strne r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iB[0].iDFAR)); |
|
933 |
asm("streq r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iB[0].iIFSR)); |
|
934 |
asm("strne r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iB[0].iDFSR)); |
|
935 |
asm("str r12, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iSpsrSvc)); |
|
936 |
asm("add r1, r1, #4 "); |
|
937 |
asm("ldmia r1!, {r2,r3,r12} "); |
|
938 |
asm("str r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR13Svc)); |
|
939 |
asm("str r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR14Svc)); |
|
940 |
asm("str r12, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR0)); |
|
941 |
asm("ldmia r1!, {r2,r3,r12} "); |
|
942 |
asm("str r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR1)); |
|
943 |
asm("str r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR2)); |
|
944 |
asm("str r12, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR3)); |
|
945 |
asm("ldmia r1!, {r2,r3,r12} "); |
|
946 |
asm("str r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR4)); |
|
947 |
asm("str r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR5)); |
|
948 |
asm("str r12, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR6)); |
|
949 |
asm("ldmia r1!, {r2,r3,r12} "); |
|
950 |
asm("str r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR7)); |
|
951 |
asm("str r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR8)); |
|
952 |
asm("str r12, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR9)); |
|
953 |
asm("ldmia r1!, {r2,r3,r12} "); |
|
954 |
asm("str r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR10)); |
|
955 |
asm("str r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR11)); |
|
956 |
asm("str r12, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR12)); |
|
957 |
asm("ldmia r1!, {r2,r3,r12} "); |
|
958 |
asm("str r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR13)); |
|
959 |
asm("str r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR14)); |
|
960 |
asm("str r12, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iExcCode)); |
|
961 |
asm("ldmia r1!, {r2,r3} "); |
|
962 |
asm("str r2, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iR15)); |
|
963 |
asm("str r3, [r0, #%a0]" : : "i" _FOFF(SFullArmRegSet,iN.iFlags)); |
|
964 |
__JUMP(,lr); |
|
965 |
} |
|
966 |
||
967 |
||
968 |
/** Get a pointer to a stored integer register, accounting for registers which |
|
969 |
are banked across modes. |
|
970 |
||
971 |
@param a Pointer to saved register block |
|
972 |
@param aRegNum Number of register required, 0-15 or -1 (indicates SPSR) |
|
973 |
@param aMode Bottom 5 bits indicate which processor mode |
|
974 |
Other bits of aMode are ignored |
|
975 |
@return Pointer to the required saved register value |
|
976 |
||
977 |
@internalTechnology |
|
978 |
*/ |
|
979 |
__NAKED__ TArmReg* Arm::Reg(SFullArmRegSet& /*a*/, TInt /*aRegNum*/, TArmReg /*aMode*/) |
|
980 |
{ |
|
981 |
asm("cmp r1, #8 "); // register number < 8 ? |
|
982 |
asm("addlo r0, r0, r1, lsl #2 "); // register R0-R7 are not banked |
|
983 |
asm("blo 0f "); |
|
984 |
asm("cmp r1, #15 "); // register number = 15 ? |
|
985 |
asm("addeq r0, r0, r1, lsl #2 "); // register R15 not banked |
|
986 |
asm("movgt r0, #0 "); // no registers > 15 |
|
987 |
asm("bge 0f "); |
|
988 |
asm("cmn r1, #1 "); |
|
989 |
asm("movlt r0, #0 "); // no registers < -1 |
|
990 |
asm("blt 0f "); |
|
991 |
asm("and r12, r2, #0x1F "); |
|
992 |
asm("cmp r12, #0x11 "); // mode_fiq? |
|
993 |
asm("beq 1f "); // skip if it is |
|
994 |
asm("cmp r1, #13 "); |
|
995 |
asm("addlo r0, r0, r1, lsl #2 "); // register R8-R12 are only banked in mode_fiq |
|
996 |
asm("blo 0f "); |
|
997 |
asm("cmp r12, #0x10 "); // mode_usr ? |
|
998 |
asm("cmpne r12, #0x1F "); // if not, mode_sys ? |
|
999 |
asm("bne 2f "); // skip if neither |
|
1000 |
asm("cmp r1, #16 "); |
|
1001 |
asm("addlo r0, r0, r1, lsl #2 "); // handle R13_usr, R14_usr |
|
1002 |
asm("movhs r0, #0 "); // no SPSR in mode_usr or mode_sys |
|
1003 |
asm("blo 0f "); |
|
1004 |
asm("1: "); // mode_fiq, regnum = 8-12 |
|
1005 |
asm("2: "); // exception mode, regnum not 0-12 or 15 |
|
1006 |
asm("cmn r1, #1 "); // regnum = -1 ? |
|
1007 |
asm("moveq r1, #15 "); // if so, change to 15 |
|
1008 |
asm("sub r1, r1, #13 "); |
|
1009 |
asm("add r0, r0, r1, lsl #2 "); // add 0 for R13, 4 for R14, 8 for SPSR |
|
1010 |
asm("cmp r12, #0x16 "); |
|
1011 |
asm("addeq r0, r0, #12 "); // if mon, add offset from R13Fiq to R13Mon |
|
1012 |
asm("cmpne r12, #0x11 "); |
|
1013 |
asm("addeq r0, r0, #32 "); // if valid but not svc/abt/und/irq, add offset from R13Irq to R13Fiq |
|
1014 |
asm("cmpne r12, #0x12 "); |
|
1015 |
asm("addeq r0, r0, #12 "); // if valid but not svc/abt/und, add offset from R13Und to R13Irq |
|
1016 |
asm("cmpne r12, #0x1b "); |
|
1017 |
asm("addeq r0, r0, #12 "); // if valid but not svc/abt, add offset from R13Abt to R13Und |
|
1018 |
asm("cmpne r12, #0x17 "); |
|
1019 |
asm("addeq r0, r0, #12 "); // if valid but not svc, add offset from R13Svc to R13Abt |
|
1020 |
asm("cmpne r12, #0x13 "); |
|
1021 |
asm("addeq r0, r0, #%a0" : : "i" _FOFF(SFullArmRegSet, iN.iR13Svc)); // if valid mode add offset to R13Svc |
|
1022 |
asm("movne r0, #0 "); |
|
1023 |
asm("0: "); |
|
1024 |
__JUMP(,lr); |
|
1025 |
} |
|
1026 |
||
1027 |
||
1028 |
/** Restore all the ARM registers |
|
1029 |
||
1030 |
@internalTechnology |
|
1031 |
*/ |
|
1032 |
__NAKED__ void Arm::RestoreState(SFullArmRegSet&) |
|
1033 |
{ |
|
1034 |
} |
|
1035 |
||
1036 |
__NAKED__ EXPORT_C TBool BTrace::OutFilteredPcFormatBig(TUint32 a0, TUint32 aModuleUid, TUint32 aPc, TUint16 aFormatId, const TAny* aData, TInt aDataSize) |
|
1037 |
{ |
|
1038 |
asm("mov r0, #0"); //Kernel side not implemented yet |
|
1039 |
} |
|
1040 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1041 |
#ifdef __CPU_ARM_HAS_WFE_SEV |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1042 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1043 |
extern "C" __NAKED__ void __arm_wfe() |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1044 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1045 |
ARM_WFE; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1046 |
__JUMP(, lr); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1047 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1048 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1049 |
extern "C" __NAKED__ void __arm_sev() |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1050 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1051 |
ARM_SEV; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1052 |
__JUMP(, lr); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1053 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1054 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1055 |
#endif |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1056 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1057 |
// Called by a CPU which has completed its detach sequence and should now be powered off |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1058 |
// Doesn't return - just waits for power to be removed |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1059 |
// CPU will come back up via the reset vector when it next wakes up. |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1060 |
// NOTE: On entry the CPU caches are disabled and the CPU does not participate in coherency |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1061 |
// SO BE VERY CAREFUL |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1062 |
extern "C" __NAKED__ void DetachComplete() |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1063 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1064 |
GET_RWNO_TID(,r0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1065 |
asm("ldr r1, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iUncached)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1066 |
asm("ldr r2, [r1, #%a0]" : : "i" _FOFF(SPerCpuUncached, iDetachCompleteCpus)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1067 |
asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(TSubScheduler, iSSX.iGicDistAddr)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1068 |
__DATA_SYNC_BARRIER_Z__(r12); // need DSB before sending any IPI |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1069 |
asm("mov r2, r2, lsl #16 "); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1070 |
asm("orr r2, r2, #%a0" : : "i" ((TInt)INDIRECT_POWERDOWN_IPI_VECTOR)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1071 |
asm("str r2, [r3, #%a0]" : : "i" _FOFF(GicDistributor, iSoftIrq)); // trigger IPIs |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1072 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1073 |
asm("wait_forever: "); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1074 |
__DATA_SYNC_BARRIER__(r12); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1075 |
ARM_WFE; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1076 |
__DATA_SYNC_BARRIER__(r12); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1077 |
asm("ldr r2, [r1, #%a0]" : : "i" _FOFF(SPerCpuUncached, iPowerOnReq)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1078 |
__DATA_SYNC_BARRIER__(r12); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1079 |
asm("cmp r2, #0xF000000F "); // for 'fake' power down |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1080 |
asm("bne wait_forever "); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1081 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1082 |
asm("0: "); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1083 |
__JUMP(,lr); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1084 |
} |
0 | 1085 |
|
1086 |
||
1087 |
||
1088 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1089 |