sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\euser\epoc\arm\uc_utl.cia
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32cia.h>
|
sl@0
|
19 |
#include <u32std.h>
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
#include <e32rom.h>
|
sl@0
|
22 |
#include <e32svr.h>
|
sl@0
|
23 |
#include <e32hashtab.h>
|
sl@0
|
24 |
#include <u32exec.h>
|
sl@0
|
25 |
#include "uc_std.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
#if defined(__MEM_MACHINE_CODED__)
|
sl@0
|
29 |
EXPORT_C __NAKED__ void Mem::Swap(TAny* /*aPtr1*/, TAny* /*aPtr2*/, TInt /*aLength*/)
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
Swaps a number of bytes of data between two specified locations.
|
sl@0
|
32 |
|
sl@0
|
33 |
The source and target areas can overlap.
|
sl@0
|
34 |
|
sl@0
|
35 |
@param aPtr1 A pointer to the first location taking part in the swap.
|
sl@0
|
36 |
@param aPtr2 A pointer to second location taking part in the swap.
|
sl@0
|
37 |
@param aLength The number of bytes to be swapped between the two locations.
|
sl@0
|
38 |
This value must not be negative.
|
sl@0
|
39 |
|
sl@0
|
40 |
@panic USER 94 In debug builds only, if aLength is negative.
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
{
|
sl@0
|
43 |
|
sl@0
|
44 |
asm(" cmp r0,r1");
|
sl@0
|
45 |
asm(" cmpne r2,#0");
|
sl@0
|
46 |
__JUMP(eq,lr);
|
sl@0
|
47 |
//
|
sl@0
|
48 |
// Test for same alignment, if more than 16 bytes to swap
|
sl@0
|
49 |
//
|
sl@0
|
50 |
asm(" and r3,r0,#3");
|
sl@0
|
51 |
asm(" and ip,r1,#3");
|
sl@0
|
52 |
asm(" cmp r2,#16");
|
sl@0
|
53 |
asm(" addlt r3,r3,#4");
|
sl@0
|
54 |
asm(" cmp r3,ip");
|
sl@0
|
55 |
asm(" beq same_aligned_swap");
|
sl@0
|
56 |
|
sl@0
|
57 |
asm(" stmfd sp!,{r4,lr}");
|
sl@0
|
58 |
|
sl@0
|
59 |
asm("swap_loop:");
|
sl@0
|
60 |
|
sl@0
|
61 |
asm(" ldrb r3,[r0]");
|
sl@0
|
62 |
asm(" ldrb r4,[r1]");
|
sl@0
|
63 |
asm(" strb r3,[r1],#1");
|
sl@0
|
64 |
asm(" strb r4,[r0],#1");
|
sl@0
|
65 |
asm(" subs r2,r2,#1");
|
sl@0
|
66 |
asm("beq swap_exit1 ");
|
sl@0
|
67 |
|
sl@0
|
68 |
asm(" ldrb r3,[r0]");
|
sl@0
|
69 |
asm(" ldrb r4,[r1]");
|
sl@0
|
70 |
asm(" strb r3,[r1],#1");
|
sl@0
|
71 |
asm(" strb r4,[r0],#1");
|
sl@0
|
72 |
asm(" subs r2,r2,#1");
|
sl@0
|
73 |
asm("beq swap_exit1 ");
|
sl@0
|
74 |
|
sl@0
|
75 |
asm(" ldrb r3,[r0]");
|
sl@0
|
76 |
asm(" ldrb r4,[r1]");
|
sl@0
|
77 |
asm(" strb r3,[r1],#1");
|
sl@0
|
78 |
asm(" strb r4,[r0],#1");
|
sl@0
|
79 |
asm(" subs r2,r2,#1");
|
sl@0
|
80 |
asm("beq swap_exit1 ");
|
sl@0
|
81 |
|
sl@0
|
82 |
asm(" ldrb r3,[r0]");
|
sl@0
|
83 |
asm(" ldrb r4,[r1]");
|
sl@0
|
84 |
asm(" strb r3,[r1],#1");
|
sl@0
|
85 |
asm(" strb r4,[r0],#1");
|
sl@0
|
86 |
asm(" subs r2,r2,#1");
|
sl@0
|
87 |
asm(" bne swap_loop");
|
sl@0
|
88 |
asm("swap_exit1: ");
|
sl@0
|
89 |
__POPRET("r4,");
|
sl@0
|
90 |
|
sl@0
|
91 |
asm("same_aligned_swap:");
|
sl@0
|
92 |
|
sl@0
|
93 |
asm(" stmfd sp!,{r4-r10,lr}");
|
sl@0
|
94 |
//
|
sl@0
|
95 |
// r3 contains the byte offset from word alignment, 0,1,2 or 3
|
sl@0
|
96 |
// subtract 1 to get -1,0,1 or 2, and if -1 make it 3
|
sl@0
|
97 |
// that gives us 0,1,2 or 3 if the alignment is 3,2,1 or 0 respectively
|
sl@0
|
98 |
// We can use that to jump directly to the appropriate place for
|
sl@0
|
99 |
// swapping the relevent number of bytes to achieve word alignment
|
sl@0
|
100 |
// r4 is set to 3-r3 to correct the length for the number of bytes
|
sl@0
|
101 |
// swapped
|
sl@0
|
102 |
//
|
sl@0
|
103 |
asm(" subs r3,r3,#1");
|
sl@0
|
104 |
asm(" movmi r3,#3");
|
sl@0
|
105 |
asm(" rsb r4,r3,#3");
|
sl@0
|
106 |
asm(" sub r2,r2,r4");
|
sl@0
|
107 |
asm(" add pc,pc,r3,asl #4");
|
sl@0
|
108 |
asm(" nop "); // never executed
|
sl@0
|
109 |
//
|
sl@0
|
110 |
// Jumps here if 3 bytes to swap before word aligned
|
sl@0
|
111 |
//
|
sl@0
|
112 |
asm(" ldrb r4,[r0]");
|
sl@0
|
113 |
asm(" ldrb ip,[r1]");
|
sl@0
|
114 |
asm(" strb r4,[r1],#1");
|
sl@0
|
115 |
asm(" strb ip,[r0],#1");
|
sl@0
|
116 |
//
|
sl@0
|
117 |
// Jumps here if 2 bytes to swap before word aligned
|
sl@0
|
118 |
//
|
sl@0
|
119 |
asm(" ldrb r4,[r0]");
|
sl@0
|
120 |
asm(" ldrb ip,[r1]");
|
sl@0
|
121 |
asm(" strb r4,[r1],#1");
|
sl@0
|
122 |
asm(" strb ip,[r0],#1");
|
sl@0
|
123 |
//
|
sl@0
|
124 |
// Jumps here if 1 byte to swap before word aligned
|
sl@0
|
125 |
//
|
sl@0
|
126 |
asm(" ldrb r4,[r0]");
|
sl@0
|
127 |
asm(" ldrb ip,[r1]");
|
sl@0
|
128 |
asm(" strb r4,[r1],#1");
|
sl@0
|
129 |
asm(" strb ip,[r0],#1");
|
sl@0
|
130 |
//
|
sl@0
|
131 |
// We are now word aligned. Fast swapping, here we come...
|
sl@0
|
132 |
//
|
sl@0
|
133 |
asm("word_aligned_swap:");
|
sl@0
|
134 |
asm(" movs ip,r2,lsr #6"); // Number of 64 blocks to swap
|
sl@0
|
135 |
asm(" beq its_smaller_swap");
|
sl@0
|
136 |
|
sl@0
|
137 |
asm("swap_64_bytes:");
|
sl@0
|
138 |
asm(" ldmia r1,{r3-r6}");
|
sl@0
|
139 |
asm(" ldmia r0,{r7-r10}");
|
sl@0
|
140 |
asm(" stmia r1!,{r7-r10}");
|
sl@0
|
141 |
asm(" stmia r0!,{r3-r6}");
|
sl@0
|
142 |
asm(" ldmia r1,{r3-r6}");
|
sl@0
|
143 |
asm(" ldmia r0,{r7-r10}");
|
sl@0
|
144 |
asm(" stmia r1!,{r7-r10}");
|
sl@0
|
145 |
asm(" stmia r0!,{r3-r6}");
|
sl@0
|
146 |
asm(" ldmia r1,{r3-r6}");
|
sl@0
|
147 |
asm(" ldmia r0,{r7-r10}");
|
sl@0
|
148 |
asm(" stmia r1!,{r7-r10}");
|
sl@0
|
149 |
asm(" stmia r0!,{r3-r6}");
|
sl@0
|
150 |
asm(" ldmia r1,{r3-r6}");
|
sl@0
|
151 |
asm(" ldmia r0,{r7-r10}");
|
sl@0
|
152 |
asm(" stmia r1!,{r7-r10}");
|
sl@0
|
153 |
asm(" stmia r0!,{r3-r6}");
|
sl@0
|
154 |
asm(" subs ip,ip,#1");
|
sl@0
|
155 |
asm(" bne swap_64_bytes");
|
sl@0
|
156 |
//
|
sl@0
|
157 |
// Less than 64 bytes to go...
|
sl@0
|
158 |
//
|
sl@0
|
159 |
asm("its_smaller_swap:");
|
sl@0
|
160 |
asm(" ands r2,r2,#63");
|
sl@0
|
161 |
asm("beq swap_exit2 ");
|
sl@0
|
162 |
asm(" cmp r2,#4");
|
sl@0
|
163 |
asm(" blt finish_swap");
|
sl@0
|
164 |
asm("final_swap_loop:");
|
sl@0
|
165 |
asm(" ldr r3,[r1]");
|
sl@0
|
166 |
asm(" ldr ip,[r0]");
|
sl@0
|
167 |
asm(" str r3,[r0],#4");
|
sl@0
|
168 |
asm(" str ip,[r1],#4");
|
sl@0
|
169 |
asm(" subs r2,r2,#4");
|
sl@0
|
170 |
asm(" cmp r2,#4");
|
sl@0
|
171 |
asm(" bge final_swap_loop");
|
sl@0
|
172 |
//
|
sl@0
|
173 |
// Less than 4 bytes to go...
|
sl@0
|
174 |
//
|
sl@0
|
175 |
asm("finish_swap:");
|
sl@0
|
176 |
asm(" tst r2,#2");
|
sl@0
|
177 |
asm(" ldrneb r3,[r0]");
|
sl@0
|
178 |
asm(" ldrneb ip,[r1]");
|
sl@0
|
179 |
asm(" strneb r3,[r1],#1");
|
sl@0
|
180 |
asm(" strneb ip,[r0],#1");
|
sl@0
|
181 |
asm(" ldrneb r3,[r0]");
|
sl@0
|
182 |
asm(" ldrneb ip,[r1]");
|
sl@0
|
183 |
asm(" strneb r3,[r1],#1");
|
sl@0
|
184 |
asm(" strneb ip,[r0],#1");
|
sl@0
|
185 |
|
sl@0
|
186 |
asm(" tst r2,#1");
|
sl@0
|
187 |
asm(" ldrneb r3,[r0]");
|
sl@0
|
188 |
asm(" ldrneb ip,[r1]");
|
sl@0
|
189 |
asm(" strneb r3,[r1],#1");
|
sl@0
|
190 |
asm(" strneb ip,[r0],#1");
|
sl@0
|
191 |
|
sl@0
|
192 |
asm("swap_exit2: ");
|
sl@0
|
193 |
__POPRET("r4-r10,");
|
sl@0
|
194 |
}
|
sl@0
|
195 |
#endif
|
sl@0
|
196 |
|
sl@0
|
197 |
#ifdef __REGIONS_MACHINE_CODED__
|
sl@0
|
198 |
|
sl@0
|
199 |
__NAKED__ GLDEF_C void AllocAnotherRect( TRegion * /*aRegion*/ )
|
sl@0
|
200 |
{
|
sl@0
|
201 |
// Returns with Z flag set to indicate error
|
sl@0
|
202 |
|
sl@0
|
203 |
asm("ldr r1, [r0, #4] "); // r1=iError
|
sl@0
|
204 |
asm("cmp r1, #0 ");
|
sl@0
|
205 |
asm("bne return_error ");
|
sl@0
|
206 |
asm("ldr r1, [r0, #8] "); // r1=iAllocedRects
|
sl@0
|
207 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
208 |
asm("tst r1, #0x40000000 "); // test ERRegionBuf
|
sl@0
|
209 |
asm("beq allocanother1 "); // don't branch if TRegionFix
|
sl@0
|
210 |
asm("cmn r1, r12 "); // test if iCount==-iAllocedRects
|
sl@0
|
211 |
__JUMP(ne,lr);
|
sl@0
|
212 |
asm("b " CSM_ZN7TRegion10ForceErrorEv); // if so, ForceError()
|
sl@0
|
213 |
asm("allocanother1: ");
|
sl@0
|
214 |
asm("cmp r1, #0 ");
|
sl@0
|
215 |
asm("bpl allocanother3 "); // branch if RRegion, continue if RRegionBuf
|
sl@0
|
216 |
asm("orr r2, r1, #0x40000000 "); // r2=iAllocedRects|ERRegionBuf
|
sl@0
|
217 |
asm("cmn r2, r12 "); // check if iCount==(-(iAllocedRects|ERRegionBuf))
|
sl@0
|
218 |
__JUMP(ne,lr);
|
sl@0
|
219 |
asm("ldr r2, [r0, #12] "); // r2=iGranularity
|
sl@0
|
220 |
asm("add r1, r12, r2 "); // iAllocedRects=iCount+iGranularity - change into RRegion
|
sl@0
|
221 |
asm("str r1, [r0, #8] ");
|
sl@0
|
222 |
asm("stmfd sp!, {r0,r1,r12,lr} "); // save registers used in function call
|
sl@0
|
223 |
asm("mov r0, r1, lsl #4 "); // number of bytes to allocate
|
sl@0
|
224 |
asm("bl " CSM_ZN4User5AllocEi); // User::Alloc
|
sl@0
|
225 |
asm("movs r2, r0 "); // returned pointer into r2
|
sl@0
|
226 |
asm("ldmfd sp!, {r0,r1,r12,lr} "); // restore registers
|
sl@0
|
227 |
asm("add r3, r0, #20 "); // r3=address of first rectangle
|
sl@0
|
228 |
asm("str r2, [r0, #16] "); // iRectangleList=returned pointer
|
sl@0
|
229 |
asm("beq " CSM_ZN7TRegion10ForceErrorEv); // if pointer null, ForceError()
|
sl@0
|
230 |
asm("cmp r12, #0 ");
|
sl@0
|
231 |
asm("beq return_success ");
|
sl@0
|
232 |
asm("stmfd sp!, {r4,r5} ");
|
sl@0
|
233 |
asm("allocanother2: ");
|
sl@0
|
234 |
asm("ldmia r3!, {r0,r1,r4,r5} "); // copy data to new area
|
sl@0
|
235 |
asm("subs r12, r12, #1 ");
|
sl@0
|
236 |
asm("stmia r2!, {r0,r1,r4,r5} ");
|
sl@0
|
237 |
asm("bne allocanother2 ");
|
sl@0
|
238 |
asm("ldmfd sp!, {r4,r5} ");
|
sl@0
|
239 |
asm("return_success: ");
|
sl@0
|
240 |
asm("movs r0, #1 "); // clear Z flag to indicate success
|
sl@0
|
241 |
__JUMP(,lr);
|
sl@0
|
242 |
asm("allocanother3: "); // come here if RRegion
|
sl@0
|
243 |
asm("cmp r1, r12 "); // check if iCount==iAllocedRects
|
sl@0
|
244 |
__JUMP(ne,lr);
|
sl@0
|
245 |
asm("ldr r2, [r0, #12] "); // r2 = iGranularity
|
sl@0
|
246 |
asm("add r1, r1, r2 "); // iAllocedRects+=iGranularity
|
sl@0
|
247 |
asm("str r1, [r0, #8] ");
|
sl@0
|
248 |
asm("stmfd sp!, {r0,lr} "); // preserve r0,lr across function call
|
sl@0
|
249 |
asm("ldr r0, [r0, #16] "); // r0=address of current cell
|
sl@0
|
250 |
asm("mov r1, r1, lsl #4 "); // r1=number of bytes to allocate
|
sl@0
|
251 |
asm("mov r2, #0 ");
|
sl@0
|
252 |
asm("bl " CSM_ZN4User7ReAllocEPvii); // User::ReAlloc
|
sl@0
|
253 |
asm("movs r2, r0 "); // returned pointer into r2
|
sl@0
|
254 |
asm("ldmfd sp!, {r0,lr} "); // restore r0,lr
|
sl@0
|
255 |
asm("strne r2, [r0, #16] "); // if returned ptr not null, iRectangleList=returned ptr
|
sl@0
|
256 |
__JUMP(ne,lr);
|
sl@0
|
257 |
asm("b " CSM_ZN7TRegion10ForceErrorEv); // else ForceError()
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
|
sl@0
|
261 |
__NAKED__ EXPORT_C void TRegion::ForceError()
|
sl@0
|
262 |
{
|
sl@0
|
263 |
// Returns with Z flag set to indicate error
|
sl@0
|
264 |
|
sl@0
|
265 |
asm("stmfd sp!, {r0,lr} ");
|
sl@0
|
266 |
asm("bl " CSM_ZN7TRegion5ClearEv); // Clear()
|
sl@0
|
267 |
asm("ldmfd sp!, {r0,lr} "); // restore r0,lr
|
sl@0
|
268 |
asm("mov r1, #1 ");
|
sl@0
|
269 |
asm("str r1, [r0, #4] "); // iError=ETrue
|
sl@0
|
270 |
asm("return_error: ");
|
sl@0
|
271 |
asm("movs r0, #0 "); // set Z flag to indicate error
|
sl@0
|
272 |
__JUMP(,lr);
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
|
sl@0
|
276 |
|
sl@0
|
277 |
__NAKED__ EXPORT_C TRect TRegion::BoundingRect() const
|
sl@0
|
278 |
/**
|
sl@0
|
279 |
Gets the minimal rectangle that bounds the entire region.
|
sl@0
|
280 |
|
sl@0
|
281 |
@return The region's minimal bounding rectangle.
|
sl@0
|
282 |
*/
|
sl@0
|
283 |
{
|
sl@0
|
284 |
asm("ldr r2, [r1] "); // r2=iCount
|
sl@0
|
285 |
asm("cmp r2, #0 "); // list empty?
|
sl@0
|
286 |
asm("beq boundingrect0 "); // branch if empty
|
sl@0
|
287 |
asm("ldr r3, [r1, #8] "); // if not empty, r3 points to first rectangle
|
sl@0
|
288 |
asm("stmfd sp!, {r4-r8,lr} ");
|
sl@0
|
289 |
asm("cmn r3, r3 ");
|
sl@0
|
290 |
asm("ldrcc r3, [r1, #16] "); // if RRegion
|
sl@0
|
291 |
asm("addcs r3, r1, #20 "); // RRegionBuf
|
sl@0
|
292 |
asm("submi r3, r3, #8 "); // TRegionFix
|
sl@0
|
293 |
asm("ldmia r3!, {r4-r7} "); // if not empty bounds = first rectangle
|
sl@0
|
294 |
asm("b boundingrect2 "); // if not empty go and check rest of list
|
sl@0
|
295 |
asm("boundingrect1: ");
|
sl@0
|
296 |
asm("ldmia r3!, {r1,r8,r12,lr} "); // fetch next rectangle
|
sl@0
|
297 |
asm("cmp r1, r4 "); // if next.iTl.iX<bounds.iTl.iX
|
sl@0
|
298 |
asm("movlt r4, r1 "); // bounds.iTl.iX=next.iTl.iX
|
sl@0
|
299 |
asm("cmp r8, r5 "); // if next.iTl.iY<bounds.iTl.iY
|
sl@0
|
300 |
asm("movlt r5, r8 "); // bounds.iTl.iY=next.iTl.iY
|
sl@0
|
301 |
asm("cmp r12, r6 "); // if next.iBr.iX>bounds.iBr.iX
|
sl@0
|
302 |
asm("movgt r6, r12 "); // bounds.iBr.iX=next.iBr.iX
|
sl@0
|
303 |
asm("cmp lr, r7 "); // if next.iBr.iY>bounds.iBr.iY
|
sl@0
|
304 |
asm("movgt r7, lr "); // bounds.iBr.iY=next.iBr.iY
|
sl@0
|
305 |
asm("boundingrect2: ");
|
sl@0
|
306 |
asm("subs r2, r2, #1 "); // decrement count
|
sl@0
|
307 |
asm("bne boundingrect1 "); // repeat for all rectangles
|
sl@0
|
308 |
asm("stmia r0, {r4-r7} "); // store result
|
sl@0
|
309 |
__POPRET("r4-r8,");
|
sl@0
|
310 |
|
sl@0
|
311 |
asm("boundingrect0: ");
|
sl@0
|
312 |
asm("mov r1, #0 "); // if list empty, bounds = 0,0,0,0
|
sl@0
|
313 |
asm("mov r3, #0 ");
|
sl@0
|
314 |
asm("mov r12, #0 ");
|
sl@0
|
315 |
asm("stmia r0, {r1,r2,r3,r12} "); // store result
|
sl@0
|
316 |
__JUMP(,lr);
|
sl@0
|
317 |
}
|
sl@0
|
318 |
|
sl@0
|
319 |
|
sl@0
|
320 |
|
sl@0
|
321 |
|
sl@0
|
322 |
__NAKED__ EXPORT_C TBool TRegion::IsContainedBy(const TRect & /*aRect*/) const
|
sl@0
|
323 |
/**
|
sl@0
|
324 |
Tests whether the region is fully enclosed within the specified rectangle.
|
sl@0
|
325 |
|
sl@0
|
326 |
@param aRect The specified rectangle.
|
sl@0
|
327 |
|
sl@0
|
328 |
@return True, if the region is fully enclosed within the rectangle (their sides
|
sl@0
|
329 |
may touch); false, otherwise.
|
sl@0
|
330 |
*/
|
sl@0
|
331 |
{
|
sl@0
|
332 |
asm("ldr r12, [r0, #8] "); // r12 points to first rectangle
|
sl@0
|
333 |
asm("stmfd sp!, {r4-r7,lr} ");
|
sl@0
|
334 |
asm("cmn r12, r12 ");
|
sl@0
|
335 |
asm("ldrcc r12, [r0, #16] "); // if RRegion
|
sl@0
|
336 |
asm("addcs r12, r0, #20 "); // RRegionBuf
|
sl@0
|
337 |
asm("submi r12, r12, #8 "); // TRegionFix
|
sl@0
|
338 |
|
sl@0
|
339 |
asm("ldr r0, [r0] "); // r0=iCount
|
sl@0
|
340 |
asm("ldmia r1, {r4-r7} "); // aRect coordinates into r4-r7
|
sl@0
|
341 |
|
sl@0
|
342 |
asm("subs r0, r0, #1 "); // decrement it
|
sl@0
|
343 |
asm("bmi iscontainedby2 "); // if iCount was zero, return TRUE
|
sl@0
|
344 |
|
sl@0
|
345 |
asm("iscontainedby1: ");
|
sl@0
|
346 |
asm("ldmia r12!, {r1,r2,r3,lr} "); // coordinates of next rectangle
|
sl@0
|
347 |
asm("cmp r1, r4 "); // compare next.iTl.iX with aRect.iTl.iX
|
sl@0
|
348 |
asm("cmpge r2, r5 "); // if >=, compare next.iTl.iY with aRect.iTl.iY
|
sl@0
|
349 |
asm("cmpge r6, r3 "); // if >=, compare aRect.Br.iX with next.iBr.iX
|
sl@0
|
350 |
asm("cmpge r7, lr "); // if >=, compare aRect.Br.iY with next.iBr.iY
|
sl@0
|
351 |
asm("subges r0, r0, #1 "); // if >=, next is contained in aRect, so iterate
|
sl@0
|
352 |
asm("bge iscontainedby1 "); // will drop through if r0<0 or if next exceeds aRect
|
sl@0
|
353 |
asm("iscontainedby2: ");
|
sl@0
|
354 |
asm("mov r0, r0, lsr #31 "); // return 1 if r0<0, 0 if r0>=0
|
sl@0
|
355 |
__POPRET("r4-r7,");
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
|
sl@0
|
359 |
|
sl@0
|
360 |
|
sl@0
|
361 |
__NAKED__ EXPORT_C void TRegion::Copy(const TRegion & /*aRegion*/)
|
sl@0
|
362 |
/**
|
sl@0
|
363 |
Copies another region to this region.
|
sl@0
|
364 |
|
sl@0
|
365 |
The state of the specified region's error flag is also copied.
|
sl@0
|
366 |
|
sl@0
|
367 |
@param aRegion The region to be copied.
|
sl@0
|
368 |
*/
|
sl@0
|
369 |
{
|
sl@0
|
370 |
asm("ldr r2, [r1, #4] "); // r2 = aRegion.iError
|
sl@0
|
371 |
asm("cmp r2, #0 ");
|
sl@0
|
372 |
asm("bne " CSM_ZN7TRegion10ForceErrorEv); // if (aRegion.iError) ForceError();
|
sl@0
|
373 |
asm("ldr r2, [r1] "); // r1 = aRegion.iCount
|
sl@0
|
374 |
asm("cmp r2, #0 ");
|
sl@0
|
375 |
asm("beq " CSM_ZN7TRegion5ClearEv); // region to copy is empty so simply clear our buffer
|
sl@0
|
376 |
asm("stmfd sp!, {r0,r1,r4,r5,r6,lr} "); // preserve r0,r1,lr across function calls
|
sl@0
|
377 |
asm("mov r4, r1 ");
|
sl@0
|
378 |
asm("mov r5, r0 ");
|
sl@0
|
379 |
asm("ldr r2, [r0, #4] "); // r2 = iError
|
sl@0
|
380 |
asm("cmp r2, #0 ");
|
sl@0
|
381 |
asm("blne " CSM_ZN7TRegion5ClearEv); // if (iError) Clear();
|
sl@0
|
382 |
asm("mov r0, r5 ");
|
sl@0
|
383 |
asm("ldr r1, [r4] "); // r1 = aRegion.iCount, r0 = this
|
sl@0
|
384 |
asm("bl " CSM_ZN7TRegion11SetListSizeEi); // SetListSize(aRegion.iCount);
|
sl@0
|
385 |
asm("cmp r0, #0 ");
|
sl@0
|
386 |
asm("beq copyregion_end ");
|
sl@0
|
387 |
asm("ldr r3, [r4] "); // r3 = aRegion.iCount
|
sl@0
|
388 |
asm("cmp r3, #0 ");
|
sl@0
|
389 |
asm("str r3, [r5] "); // iCount=aRegion.iCount
|
sl@0
|
390 |
asm("beq copyregion_end ");
|
sl@0
|
391 |
asm("ldr r0, [r5, #8] "); // r0 points to first rectangle
|
sl@0
|
392 |
asm("cmn r0, r0 ");
|
sl@0
|
393 |
asm("ldrcc r0, [r5, #16] "); // if RRegion
|
sl@0
|
394 |
asm("addcs r0, r5, #20 "); // RRegionBuf
|
sl@0
|
395 |
asm("submi r0, r0, #8 "); // TRegionFix
|
sl@0
|
396 |
asm("ldr r1, [r4, #8] "); // r1 points to first rectangle
|
sl@0
|
397 |
asm("cmn r1, r1 ");
|
sl@0
|
398 |
asm("ldrcc r1, [r4, #16] "); // if RRegion
|
sl@0
|
399 |
asm("addcs r1, r4, #20 "); // RRegionBuf
|
sl@0
|
400 |
asm("submi r1, r1, #8 "); // TRegionFix
|
sl@0
|
401 |
asm("copyregion1: ");
|
sl@0
|
402 |
asm("ldmia r1!, {r2,r4,r5,r12} "); // copy aRegion.iRectangleList to iRectangleList
|
sl@0
|
403 |
asm("subs r3, r3, #1 ");
|
sl@0
|
404 |
asm("stmia r0!, {r2,r4,r5,r12} ");
|
sl@0
|
405 |
asm("bne copyregion1 ");
|
sl@0
|
406 |
|
sl@0
|
407 |
asm("copyregion_end: ");
|
sl@0
|
408 |
__POPRET("r0,r1,r4,r5,r6,");
|
sl@0
|
409 |
}
|
sl@0
|
410 |
|
sl@0
|
411 |
|
sl@0
|
412 |
|
sl@0
|
413 |
|
sl@0
|
414 |
__NAKED__ EXPORT_C void TRegion::Offset(const TPoint & /*anOffset*/)
|
sl@0
|
415 |
/**
|
sl@0
|
416 |
Moves the region by adding a TPoint offset to the co-ordinates of its corners.
|
sl@0
|
417 |
|
sl@0
|
418 |
The size of the region is not changed.
|
sl@0
|
419 |
|
sl@0
|
420 |
@param aOffset The offset by which the region is moved. The region is moved
|
sl@0
|
421 |
horizontally by aOffset.iX pixels and vertically by aOffset.iY pixels.
|
sl@0
|
422 |
*/
|
sl@0
|
423 |
{
|
sl@0
|
424 |
asm("ldmia r1, {r1,r2} "); // r1=anOffset.iX, r2=anOffset.iY
|
sl@0
|
425 |
// fall through...
|
sl@0
|
426 |
}
|
sl@0
|
427 |
|
sl@0
|
428 |
|
sl@0
|
429 |
|
sl@0
|
430 |
|
sl@0
|
431 |
__NAKED__ EXPORT_C void TRegion::Offset(TInt /*xOffset*/,TInt /*yOffset*/)
|
sl@0
|
432 |
/**
|
sl@0
|
433 |
Moves the region by adding X and Y offsets to the co-ordinates of its corners.
|
sl@0
|
434 |
|
sl@0
|
435 |
The size of the region is not changed.
|
sl@0
|
436 |
|
sl@0
|
437 |
@param aXoffset The number of pixels by which to move the region horizontally.
|
sl@0
|
438 |
If negative, the region moves leftwards.
|
sl@0
|
439 |
@param aYoffset The number of pixels by which to move the region vertically.
|
sl@0
|
440 |
If negative, the region moves upwards.
|
sl@0
|
441 |
*/
|
sl@0
|
442 |
{
|
sl@0
|
443 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
444 |
asm("cmp r12, #0 ");
|
sl@0
|
445 |
__JUMP(eq,lr);
|
sl@0
|
446 |
asm("ldr r3, [r0, #8] "); // r0 points to first rectangle
|
sl@0
|
447 |
asm("cmn r3, r3 ");
|
sl@0
|
448 |
asm("ldrcc r0, [r0, #16] "); // if RRegion
|
sl@0
|
449 |
asm("addcs r0, r0, #20 "); // RRegionBuf
|
sl@0
|
450 |
asm("submi r0, r0, #8 "); // TRegionFix
|
sl@0
|
451 |
asm("stmfd sp!, {r4,r5,lr} ");
|
sl@0
|
452 |
asm("offsetregion2: ");
|
sl@0
|
453 |
asm("ldmia r0, {r3-r5,lr} "); // r3-r5,lr = next rectangle coordinates
|
sl@0
|
454 |
asm("subs r12, r12, #1 ");
|
sl@0
|
455 |
asm("add r3, r3, r1 "); // Tl.iX += anOffset.iX
|
sl@0
|
456 |
asm("add r4, r4, r2 "); // Tl.iY += anOffset.iY
|
sl@0
|
457 |
asm("add r5, r5, r1 "); // Br.iX += anOffset.iX
|
sl@0
|
458 |
asm("add lr, lr, r2 "); // Br.iY += anOffset.iY
|
sl@0
|
459 |
asm("stmia r0!, {r3-r5,lr} "); // store new coordinates
|
sl@0
|
460 |
asm("bne offsetregion2 ");
|
sl@0
|
461 |
__POPRET("r4,r5,");
|
sl@0
|
462 |
}
|
sl@0
|
463 |
|
sl@0
|
464 |
|
sl@0
|
465 |
|
sl@0
|
466 |
|
sl@0
|
467 |
__NAKED__ EXPORT_C TBool TRegion::Contains(const TPoint & /*aPoint*/) const
|
sl@0
|
468 |
/**
|
sl@0
|
469 |
Tests whether a point is located within the region.
|
sl@0
|
470 |
|
sl@0
|
471 |
If the point is located on the top or left hand side of any rectangle in the
|
sl@0
|
472 |
region, it is considered to be within that rectangle and within the region.
|
sl@0
|
473 |
|
sl@0
|
474 |
If the point is located on the right hand side or bottom of a rectangle, it
|
sl@0
|
475 |
is considered to be outside that rectangle, and may be outside the region.
|
sl@0
|
476 |
|
sl@0
|
477 |
@param aPoint The specified point.
|
sl@0
|
478 |
|
sl@0
|
479 |
@return True, if the point is within the region; false, otherwise.
|
sl@0
|
480 |
*/
|
sl@0
|
481 |
{
|
sl@0
|
482 |
asm("ldr r12, [r0] "); // r12 = iCount
|
sl@0
|
483 |
asm("stmfd sp!, {r4,r5,lr} ");
|
sl@0
|
484 |
asm("cmp r12, #0 ");
|
sl@0
|
485 |
asm("beq contains0 "); // if iCount=0, return FALSE
|
sl@0
|
486 |
asm("ldr r3, [r0, #8] "); // r0 points to first rectangle
|
sl@0
|
487 |
asm("cmn r3, r3 ");
|
sl@0
|
488 |
asm("ldrcc r0, [r0, #16] "); // if RRegion
|
sl@0
|
489 |
asm("addcs r0, r0, #20 "); // RRegionBuf
|
sl@0
|
490 |
asm("submi r0, r0, #8 "); // TRegionFix
|
sl@0
|
491 |
asm("ldmia r1, {r1, r2} "); // r1=aPoint.iX, r2=aPoint.iY
|
sl@0
|
492 |
asm("contains1: ");
|
sl@0
|
493 |
asm("ldmia r0!, {r3-r5,lr} "); // coordinates of next rectangle into r3-r5,lr
|
sl@0
|
494 |
asm("cmp r3, r1 "); // compare next.iTl.iX with aPoint.iX
|
sl@0
|
495 |
asm("cmple r4, r2 "); // if <=, compare next.iTl.iY with aPoint.iY
|
sl@0
|
496 |
asm("bgt contains2 "); // if >, aPoint is not contained in rectangle, so iterate
|
sl@0
|
497 |
asm("cmp r1, r5 "); // compare aPoint.iX with next.iBr.iX
|
sl@0
|
498 |
asm("cmplt r2, lr "); // if <, compare aPoint.iY with next.iBr.iY
|
sl@0
|
499 |
asm("contains2: ");
|
sl@0
|
500 |
asm("subges r12, r12, #1 "); // if >=, aPoint is not contained in rect, so iterate
|
sl@0
|
501 |
asm("bgt contains1 ");
|
sl@0
|
502 |
asm("cmp r12, #0 ");
|
sl@0
|
503 |
asm("movne r0, #1 "); // if r12 non-zero, return TRUE else FALSE
|
sl@0
|
504 |
asm("contains0: ");
|
sl@0
|
505 |
asm("moveq r0, #0 ");
|
sl@0
|
506 |
__POPRET("r4,r5,");
|
sl@0
|
507 |
}
|
sl@0
|
508 |
|
sl@0
|
509 |
|
sl@0
|
510 |
|
sl@0
|
511 |
|
sl@0
|
512 |
__NAKED__ EXPORT_C TBool TRegion::Intersects(const TRect &/*aRect*/) const
|
sl@0
|
513 |
/**
|
sl@0
|
514 |
Tests whether where there is any intersection between this region and the specified rectangle.
|
sl@0
|
515 |
|
sl@0
|
516 |
@param aRect The specified rectangle.
|
sl@0
|
517 |
|
sl@0
|
518 |
@return True, if there is an intersection; false, otherwise.
|
sl@0
|
519 |
*/
|
sl@0
|
520 |
{
|
sl@0
|
521 |
asm("ldr r12, [r0] "); // r12 = iCount
|
sl@0
|
522 |
asm("stmfd sp!, {r4-r7,lr} ");
|
sl@0
|
523 |
asm("cmp r12, #0 ");
|
sl@0
|
524 |
asm("beq intersects0 "); // if iCount=0, return FALSE
|
sl@0
|
525 |
asm("ldr lr, [r0, #8] "); // r0 points to first rectangle
|
sl@0
|
526 |
asm("ldmia r1, {r1-r4} "); // (load aRect into r1 - r4)
|
sl@0
|
527 |
asm("cmn lr, lr ");
|
sl@0
|
528 |
asm("ldrcc r0, [r0, #16] "); // if RRegion
|
sl@0
|
529 |
asm("addcs r0, r0, #20 "); // RRegionBuf
|
sl@0
|
530 |
asm("submi r0, r0, #8 "); // TRegionFix
|
sl@0
|
531 |
asm("cmp r1, r3 "); // check if aRect is empty
|
sl@0
|
532 |
asm("cmplt r2, r4 ");
|
sl@0
|
533 |
asm("bge intersects0 ");
|
sl@0
|
534 |
|
sl@0
|
535 |
asm("intersects1: ");
|
sl@0
|
536 |
asm("ldmia r0!, {r5-r7,lr} "); // coordinates of next rectangle into r5-r7,lr
|
sl@0
|
537 |
asm("cmp r1, r7 "); // check if they intersect
|
sl@0
|
538 |
asm("cmplt r2, lr ");
|
sl@0
|
539 |
asm("cmplt r5, r3 ");
|
sl@0
|
540 |
asm("cmplt r6, r4 ");
|
sl@0
|
541 |
asm("subges r12, r12, #1 "); // if not then decrement and loop
|
sl@0
|
542 |
asm("bgt intersects1 ");
|
sl@0
|
543 |
|
sl@0
|
544 |
asm("intersects0: ");
|
sl@0
|
545 |
asm("movge r0, #0 ");
|
sl@0
|
546 |
asm("movlt r0, #1 ");
|
sl@0
|
547 |
__POPRET("r4-r7,");
|
sl@0
|
548 |
}
|
sl@0
|
549 |
|
sl@0
|
550 |
|
sl@0
|
551 |
|
sl@0
|
552 |
|
sl@0
|
553 |
__NAKED__ void TRegion::DeleteRect(TRect * /*aRect*/)
|
sl@0
|
554 |
//
|
sl@0
|
555 |
// Delete a specific rectangle in the list.
|
sl@0
|
556 |
//
|
sl@0
|
557 |
{
|
sl@0
|
558 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
559 |
asm("ldr r3, [r0, #8] "); // r0 points to first rectangle
|
sl@0
|
560 |
asm("subs r12, r12, #1 "); // decrement it
|
sl@0
|
561 |
asm("str r12, [r0] "); // iCount--;
|
sl@0
|
562 |
asm("cmn r3, r3 ");
|
sl@0
|
563 |
asm("ldrcc r0, [r0, #16] "); // if RRegion
|
sl@0
|
564 |
asm("addcs r0, r0, #20 "); // RRegionBuf
|
sl@0
|
565 |
asm("submi r0, r0, #8 "); // TRegionFix
|
sl@0
|
566 |
asm("sub r2, r1, r0 "); // r2=offset of aRect from iRectangleList
|
sl@0
|
567 |
asm("subs r12, r12, r2, lsr #4 "); // r12 now equals number of rectangles requiring moving
|
sl@0
|
568 |
__JUMP(eq,lr);
|
sl@0
|
569 |
asm("add r0, r1, #16 "); // r0 = aRect+1
|
sl@0
|
570 |
asm("stmfd sp!, {r4,lr} ");
|
sl@0
|
571 |
asm("deleterect1: ");
|
sl@0
|
572 |
asm("ldmia r0!, {r2-r4,lr} "); // move rectangles following aRect back by one place
|
sl@0
|
573 |
asm("subs r12, r12, #1 ");
|
sl@0
|
574 |
asm("stmia r1!, {r2-r4,lr} ");
|
sl@0
|
575 |
asm("bne deleterect1 ");
|
sl@0
|
576 |
__POPRET("r4,");
|
sl@0
|
577 |
}
|
sl@0
|
578 |
|
sl@0
|
579 |
|
sl@0
|
580 |
|
sl@0
|
581 |
|
sl@0
|
582 |
__NAKED__ EXPORT_C void TRegion::ClipRect(const TRect & /*aRect*/)
|
sl@0
|
583 |
/**
|
sl@0
|
584 |
Clips the region to the specified rectangle.
|
sl@0
|
585 |
|
sl@0
|
586 |
The resulting region is the area of overlap between the region and the rectangle.
|
sl@0
|
587 |
If there is no overlap, all rectangles within this region are deleted and
|
sl@0
|
588 |
the resulting region is empty.
|
sl@0
|
589 |
|
sl@0
|
590 |
@param aRect The rectangle to which this region is to be clipped.
|
sl@0
|
591 |
*/
|
sl@0
|
592 |
// Can not fail.
|
sl@0
|
593 |
{
|
sl@0
|
594 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
595 |
asm("cmp r12, #0 ");
|
sl@0
|
596 |
__JUMP(eq,lr);
|
sl@0
|
597 |
asm("stmfd sp!, {r4-r10,lr} ");
|
sl@0
|
598 |
asm("ldmia r1, {r2-r5} "); // get coordinates of aRect into r2-r5
|
sl@0
|
599 |
asm("ldr r1, [r0, #8] "); // r1 points to first rectangle
|
sl@0
|
600 |
asm("cmn r1, r1 ");
|
sl@0
|
601 |
asm("ldrcc r1, [r0, #16] "); // if RRegion
|
sl@0
|
602 |
asm("addcs r1, r0, #20 "); // RRegionBuf
|
sl@0
|
603 |
asm("submi r1, r1, #8 "); // TRegionFix
|
sl@0
|
604 |
|
sl@0
|
605 |
asm("cliprect1: ");
|
sl@0
|
606 |
asm("ldmia r1!, {r6-r9} "); // next rectangle coordinates into r6-r9
|
sl@0
|
607 |
asm("cmp r6, r2 "); // clip the rectangle to aRect
|
sl@0
|
608 |
asm("movlt r6, r2 ");
|
sl@0
|
609 |
asm("strlt r2, [r1, #-16] ");
|
sl@0
|
610 |
asm("cmp r7, r3 ");
|
sl@0
|
611 |
asm("movlt r7, r3 ");
|
sl@0
|
612 |
asm("strlt r3, [r1, #-12] ");
|
sl@0
|
613 |
asm("cmp r8, r4 ");
|
sl@0
|
614 |
asm("movgt r8, r4 ");
|
sl@0
|
615 |
asm("strgt r4, [r1, #-8] ");
|
sl@0
|
616 |
asm("cmp r9, r5 ");
|
sl@0
|
617 |
asm("movgt r9, r5 ");
|
sl@0
|
618 |
asm("strgt r5, [r1, #-4] ");
|
sl@0
|
619 |
asm("cmp r6, r8 "); // check if clipped rect is empty
|
sl@0
|
620 |
asm("cmplt r7, r9 "); // empty if r6>=r8 or r7>=r9
|
sl@0
|
621 |
asm("bge cliprect_delete "); // if empty, branch to other loop to delete rect
|
sl@0
|
622 |
asm("subs r12, r12, #1 "); // decrement loop counter
|
sl@0
|
623 |
asm("bne cliprect1 "); // loop if any more rectangles to do
|
sl@0
|
624 |
__POPRET("r4-r10,");
|
sl@0
|
625 |
|
sl@0
|
626 |
asm("cliprect_delete: "); // (enter loop here)
|
sl@0
|
627 |
asm("ldr lr, [r0] "); // lr=iCount, updateed if we delete rects
|
sl@0
|
628 |
asm("sub r10, r1, #16 "); // r1 -> next rect, r10 -> previous deleted rect
|
sl@0
|
629 |
asm("subs r12, r12, #1 "); // decrement loop counter
|
sl@0
|
630 |
asm("beq cliprect_move_end ");
|
sl@0
|
631 |
asm("cliprect_move: ");
|
sl@0
|
632 |
asm("ldmia r1!, {r6-r9} "); // next rectangle coordinates into r6-r9
|
sl@0
|
633 |
asm("cmp r6, r2 "); // clip the rectangle to aRect
|
sl@0
|
634 |
asm("movlt r6, r2 ");
|
sl@0
|
635 |
asm("cmp r7, r3 ");
|
sl@0
|
636 |
asm("movlt r7, r3 ");
|
sl@0
|
637 |
asm("cmp r8, r4 ");
|
sl@0
|
638 |
asm("movgt r8, r4 ");
|
sl@0
|
639 |
asm("cmp r9, r5 ");
|
sl@0
|
640 |
asm("movgt r9, r5 ");
|
sl@0
|
641 |
asm("cmp r6, r8 "); // check if clipped rect is empty
|
sl@0
|
642 |
asm("cmplt r7, r9 "); // empty if r6>=r8 or r7>=r9
|
sl@0
|
643 |
asm("stmltia r10!, {r6-r9} "); // if non-empty then store the rect
|
sl@0
|
644 |
asm("subge lr, lr, #1 "); // else decrement rect count
|
sl@0
|
645 |
asm("subs r12, r12, #1 "); // decrement loop counter
|
sl@0
|
646 |
asm("bne cliprect_move "); // loop if any more rectangles to do
|
sl@0
|
647 |
asm("cliprect_move_end: ");
|
sl@0
|
648 |
asm("sub lr, lr, #1 "); // decrement count for first deleted rect
|
sl@0
|
649 |
asm("str lr, [r0] "); // store updated iCount
|
sl@0
|
650 |
__POPRET("r4-r10,");
|
sl@0
|
651 |
}
|
sl@0
|
652 |
|
sl@0
|
653 |
|
sl@0
|
654 |
|
sl@0
|
655 |
|
sl@0
|
656 |
__NAKED__ EXPORT_C void TRegion::SubRect(const TRect& /*aRect*/,TRegion* /*aSubtractedRegion*/)
|
sl@0
|
657 |
/**
|
sl@0
|
658 |
Removes a rectangle from this region.
|
sl@0
|
659 |
|
sl@0
|
660 |
If there is no intersection between the rectangle and this region, then this
|
sl@0
|
661 |
region is unaffected.
|
sl@0
|
662 |
|
sl@0
|
663 |
@param aRect The rectangular area to be removed from this region.
|
sl@0
|
664 |
@param aSubtractedRegion A pointer to a region. If this is supplied, the
|
sl@0
|
665 |
removed rectangle is added to it. By default this
|
sl@0
|
666 |
pointer is NULL.
|
sl@0
|
667 |
*/
|
sl@0
|
668 |
{
|
sl@0
|
669 |
asm("ldr r12, [r0] "); // r12=iCount=limit
|
sl@0
|
670 |
asm("cmp r12, #0 ");
|
sl@0
|
671 |
__JUMP(eq,lr);
|
sl@0
|
672 |
asm("stmfd sp!, {r3-r11,lr} ");
|
sl@0
|
673 |
asm("ldmia r1, {r4-r7} "); // r4-r7 = coordinates of aRect
|
sl@0
|
674 |
asm("cmp r4, r6 "); // check if aRect is empty i.e. (r4>=r6 || r5>=r7)
|
sl@0
|
675 |
asm("cmplt r5, r7 ");
|
sl@0
|
676 |
asm("bge subrect_end "); // if aRect is empty nothing to do
|
sl@0
|
677 |
|
sl@0
|
678 |
asm("mov r3, #0 "); // r3=index
|
sl@0
|
679 |
asm("subrect1: ");
|
sl@0
|
680 |
asm("ldr lr, [r0, #8] "); // lr points to first rectangle
|
sl@0
|
681 |
asm("cmn lr, lr ");
|
sl@0
|
682 |
asm("ldrcc lr, [r0, #16] "); // if RRegion
|
sl@0
|
683 |
asm("addcs lr, r0, #20 "); // RRegionBuf
|
sl@0
|
684 |
asm("submi lr, lr, #8 "); // TRegionFix
|
sl@0
|
685 |
asm("add lr, lr, r3, lsl #4 "); // lr=iRectangleList+index
|
sl@0
|
686 |
// asm("ldmia r1, {r4-r7} "); // r4-r7 = coordinates of aRect
|
sl@0
|
687 |
asm("ldmia lr, {r8-r11} "); // r8-r11 = coordinates of next rectangle in region
|
sl@0
|
688 |
asm("cmp r10, r4 "); // compare next.iBr.iX with aRect.iTl.iX
|
sl@0
|
689 |
asm("cmpgt r11, r5 "); // if >, compare next.iBr.iY with aRect.iTl.iY
|
sl@0
|
690 |
asm("cmpgt r6, r8 "); // if >, compare aRect.iBr.iX with next.iTl.iX
|
sl@0
|
691 |
asm("cmpgt r7, r9 "); // if >, compare aRect.iBr.iY with next.iTl.iY
|
sl@0
|
692 |
asm("addle r3, r3, #1 "); // if empty intersection, increment index
|
sl@0
|
693 |
asm("ble subrect2 "); // if <=, next and aRect have empty intersection, so skip
|
sl@0
|
694 |
asm("add r4, lr, #16 "); // r4 = source pointer for copy, lr = dest
|
sl@0
|
695 |
asm("ldr r5, [r0] "); // r5 = iCount
|
sl@0
|
696 |
asm("sub r5, r5, #1 "); // decrement iCount
|
sl@0
|
697 |
asm("str r5, [r0] ");
|
sl@0
|
698 |
asm("sub r12, r12, #1 "); // decrement limit
|
sl@0
|
699 |
asm("subs r5, r5, r3 "); // loop count for copy = iCount-index
|
sl@0
|
700 |
asm("beq subrect4 "); // if loop count zero, skip the copy
|
sl@0
|
701 |
asm("stmfd sp!, {r8,r9} "); // preserve r8,r9
|
sl@0
|
702 |
asm("subrect3: ");
|
sl@0
|
703 |
asm("ldmia r4!, {r6-r9} "); // remove the current rectangle
|
sl@0
|
704 |
asm("stmia lr!, {r6-r9} ");
|
sl@0
|
705 |
asm("subs r5, r5, #1 ");
|
sl@0
|
706 |
asm("bne subrect3 ");
|
sl@0
|
707 |
asm("ldmfd sp!, {r8-r9} "); // restore r8,r9
|
sl@0
|
708 |
asm("subrect4: ");
|
sl@0
|
709 |
asm("ldmia r1, {r4-r7} "); // restore coordinates of aRect into r4-r7
|
sl@0
|
710 |
asm("cmp r7, r11 "); // compare aRect.iBr.iY with rect.iBr.iY
|
sl@0
|
711 |
asm("movgt r7, r11 "); // r7=inter.iBr.iY
|
sl@0
|
712 |
asm("bllt subrectapp1 "); // if <, append 1st subrectangle
|
sl@0
|
713 |
asm("cmp r5, r9 "); // compare aRect.iTl.iY with rect.iTl.iY
|
sl@0
|
714 |
asm("movlt r5, r9 "); // r5=inter.iTl.iY
|
sl@0
|
715 |
asm("blgt subrectapp2 "); // if >, append 2nd subrectangle
|
sl@0
|
716 |
asm("cmp r6, r10 "); // compare aRect.iBr.iX with rect.iBr.iX
|
sl@0
|
717 |
asm("movgt r6, r10 "); // r6=inter.iBr.iX
|
sl@0
|
718 |
asm("bllt subrectapp3 "); // if <, append 3rd subrectangle
|
sl@0
|
719 |
asm("cmp r4, r8 "); // compare aRect.iTl.iX with rect.iTl.iX
|
sl@0
|
720 |
asm("movlt r4, r8 "); // r4=inter.iTl.iX
|
sl@0
|
721 |
asm("blgt subrectapp4 "); // if >, append 4th subrectangle
|
sl@0
|
722 |
asm("ldr lr, [r0, #4] "); // lr=iError
|
sl@0
|
723 |
asm("cmp lr, #0 "); // check for an error
|
sl@0
|
724 |
asm("bne subrect_end ");
|
sl@0
|
725 |
asm("cmp r2, #0 "); // check if aSubtractedRegion!=NULL
|
sl@0
|
726 |
asm("blne subrectadd "); // if non-null, add inter to aSubtractedRegion
|
sl@0
|
727 |
asm("subrect2: ");
|
sl@0
|
728 |
asm("cmp r3, r12 "); // compare index to limit
|
sl@0
|
729 |
asm("ldmltia r1, {r4-r7} "); // if index<limit, r4-r7 = coordinates of aRect
|
sl@0
|
730 |
asm("blt subrect1 "); // if index<limit, loop again
|
sl@0
|
731 |
|
sl@0
|
732 |
asm("subrect_end: ");
|
sl@0
|
733 |
__POPRET("r3-r11,");
|
sl@0
|
734 |
|
sl@0
|
735 |
// AppendRect(TRect(rect.iTl.iX,inter.iBr.iY,rect.iBr.iX,rect.iBr.iY))
|
sl@0
|
736 |
asm("subrectapp1: ");
|
sl@0
|
737 |
asm("stmfd sp!, {r0-r3,r12,lr} "); // preserve registers across function call
|
sl@0
|
738 |
asm("bl " CSM_Z16AllocAnotherRectP7TRegion);
|
sl@0
|
739 |
asm("ldmfd sp!, {r0-r3} ");
|
sl@0
|
740 |
asm("beq subrectapp1_end "); // exit if error
|
sl@0
|
741 |
|
sl@0
|
742 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
743 |
asm("ldr lr, [r0, #8] "); // lr points to first rectangle
|
sl@0
|
744 |
asm("cmn lr, lr ");
|
sl@0
|
745 |
asm("ldrcc lr, [r0, #16] "); // if RRegion
|
sl@0
|
746 |
asm("addcs lr, r0, #20 "); // RRegionBuf
|
sl@0
|
747 |
asm("submi lr, lr, #8 "); // TRegionFix
|
sl@0
|
748 |
asm("add lr, lr, r12, lsl #4 "); // lr=&(iRectangleList[iCount])
|
sl@0
|
749 |
asm("add r12, r12, #1 "); // increment iCount
|
sl@0
|
750 |
asm("str r12, [r0] "); //
|
sl@0
|
751 |
asm("stmia lr!, {r8} "); // append rectangle - rect.iTl.iX
|
sl@0
|
752 |
asm("stmia lr!, {r7,r10,r11} "); // inter.iBr.iY, rect.iBr.iX, rect.iBr.iY
|
sl@0
|
753 |
asm("subrectapp1_end: ");
|
sl@0
|
754 |
__POPRET("r12,");
|
sl@0
|
755 |
|
sl@0
|
756 |
// AppendRect(TRect(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,inter.iTl.iY))
|
sl@0
|
757 |
asm("subrectapp2: ");
|
sl@0
|
758 |
asm("stmfd sp!, {r0-r3,r12,lr} "); // preserve registers across function call
|
sl@0
|
759 |
asm("bl " CSM_Z16AllocAnotherRectP7TRegion);
|
sl@0
|
760 |
asm("ldmfd sp!, {r0-r3} ");
|
sl@0
|
761 |
asm("beq subrectapp1_end "); // exit if error
|
sl@0
|
762 |
|
sl@0
|
763 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
764 |
asm("ldr lr, [r0, #8] "); // lr points to first rectangle
|
sl@0
|
765 |
asm("cmn lr, lr ");
|
sl@0
|
766 |
asm("ldrcc lr, [r0, #16] "); // if RRegion
|
sl@0
|
767 |
asm("addcs lr, r0, #20 "); // RRegionBuf
|
sl@0
|
768 |
asm("submi lr, lr, #8 "); // TRegionFix
|
sl@0
|
769 |
asm("add lr, lr, r12, lsl #4 "); // lr=&(iRectangleList[iCount])
|
sl@0
|
770 |
asm("add r12, r12, #1 "); // increment iCount
|
sl@0
|
771 |
asm("str r12, [r0] "); //
|
sl@0
|
772 |
asm("stmia lr!, {r8,r9,r10} "); // append rectangle - rect.iTl.iX,rect.iTl.iY,rect.iBr.iX
|
sl@0
|
773 |
asm("stmia lr!, {r5} "); // inter.iTl.iY
|
sl@0
|
774 |
__POPRET("r12,");
|
sl@0
|
775 |
|
sl@0
|
776 |
// AppendRect(TRect(inter.iBr.iX,inter.iTl.iY,rect.iBr.iX,inter.iBr.iY))
|
sl@0
|
777 |
asm("subrectapp3: ");
|
sl@0
|
778 |
asm("stmfd sp!, {r0-r3,r12,lr} "); // preserve registers across function call
|
sl@0
|
779 |
asm("bl " CSM_Z16AllocAnotherRectP7TRegion);
|
sl@0
|
780 |
asm("ldmfd sp!, {r0-r3} ");
|
sl@0
|
781 |
asm("beq subrectapp1_end "); // exit if error
|
sl@0
|
782 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
783 |
asm("ldr lr, [r0, #8] "); // lr points to first rectangle
|
sl@0
|
784 |
asm("cmn lr, lr ");
|
sl@0
|
785 |
asm("ldrcc lr, [r0, #16] "); // if RRegion
|
sl@0
|
786 |
asm("addcs lr, r0, #20 "); // RRegionBuf
|
sl@0
|
787 |
asm("submi lr, lr, #8 "); // TRegionFix
|
sl@0
|
788 |
asm("add lr, lr, r12, lsl #4 "); // lr=&(iRectangleList[iCount])
|
sl@0
|
789 |
asm("add r12, r12, #1 "); // increment iCount
|
sl@0
|
790 |
asm("str r12, [r0] "); //
|
sl@0
|
791 |
asm("stmia lr!, {r6} "); // append rectangle - inter.iBr.iX
|
sl@0
|
792 |
asm("stmia lr!, {r5,r10} "); // inter.iTl.iY, rect.iBr.iX
|
sl@0
|
793 |
asm("stmia lr!, {r7} "); // inter.iBr.iY
|
sl@0
|
794 |
__POPRET("r12,");
|
sl@0
|
795 |
|
sl@0
|
796 |
// AppendRect(TRect(rect.iTl.iX,inter.iTl.iY,inter.iTl.iX,inter.iBr.iY))
|
sl@0
|
797 |
asm("subrectapp4: ");
|
sl@0
|
798 |
asm("stmfd sp!, {r0-r3,r12,lr} "); // preserve registers across function call
|
sl@0
|
799 |
asm("bl " CSM_Z16AllocAnotherRectP7TRegion);
|
sl@0
|
800 |
asm("ldmfd sp!, {r0-r3} ");
|
sl@0
|
801 |
asm("beq subrectapp1_end "); // exit if error
|
sl@0
|
802 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
803 |
asm("ldr lr, [r0, #8] "); // lr points to first rectangle
|
sl@0
|
804 |
asm("cmn lr, lr ");
|
sl@0
|
805 |
asm("ldrcc lr, [r0, #16] "); // if RRegion
|
sl@0
|
806 |
asm("addcs lr, r0, #20 "); // RRegionBuf
|
sl@0
|
807 |
asm("submi lr, lr, #8 "); // TRegionFix
|
sl@0
|
808 |
asm("add lr, lr, r12, lsl #4 "); // lr=&(iRectangleList[iCount])
|
sl@0
|
809 |
asm("add r12, r12, #1 "); // increment iCount
|
sl@0
|
810 |
asm("str r12, [r0] "); //
|
sl@0
|
811 |
asm("stmia lr!, {r8} "); // append rectangle - rect.iTl.iX
|
sl@0
|
812 |
asm("stmia lr!, {r5} "); // inter.iTl.iY
|
sl@0
|
813 |
asm("stmia lr!, {r4,r7} "); // inter.iTl.iX, inter.iBr.iY
|
sl@0
|
814 |
__POPRET("r12,");
|
sl@0
|
815 |
|
sl@0
|
816 |
// aSubtractedRegion->AddRect(inter)
|
sl@0
|
817 |
asm("subrectadd: ");
|
sl@0
|
818 |
asm("stmfd sp!, {r0-r7,r12,lr} "); // preserve registers and put inter onto stack
|
sl@0
|
819 |
asm("mov r0, r2 "); // this = aSubtractedRegion
|
sl@0
|
820 |
asm("add r1, sp, #16 "); // inter is 16 bytes above sp
|
sl@0
|
821 |
asm("bl " CSM_ZN7TRegion7AddRectERK5TRect); // call TRegion::AddRect
|
sl@0
|
822 |
__POPRET("r0-r7,r12,");
|
sl@0
|
823 |
}
|
sl@0
|
824 |
|
sl@0
|
825 |
|
sl@0
|
826 |
|
sl@0
|
827 |
|
sl@0
|
828 |
__NAKED__ EXPORT_C void TRegion::Intersection(const TRegion& /*aRegion1*/,const TRegion& /*aRegion2*/)
|
sl@0
|
829 |
/**
|
sl@0
|
830 |
Replaces this region with the area of intersection between two specified regions.
|
sl@0
|
831 |
|
sl@0
|
832 |
Notes:
|
sl@0
|
833 |
|
sl@0
|
834 |
1. If the error flag of either of the two specified regions is set, then this
|
sl@0
|
835 |
region is cleared and its error flag is set. This frees up allocated memory.
|
sl@0
|
836 |
|
sl@0
|
837 |
2. If this region's error flag is already set, then the function has no effect.
|
sl@0
|
838 |
|
sl@0
|
839 |
@param aRegion1 The first region.
|
sl@0
|
840 |
@param aRegion2 The second region.
|
sl@0
|
841 |
*/
|
sl@0
|
842 |
{
|
sl@0
|
843 |
// r0=this, r1=&aRegion1, r2=&aRegion2
|
sl@0
|
844 |
asm("ldr r3, [r1, #4] "); // r3=aRegion1.iError
|
sl@0
|
845 |
asm("ldr r12, [r2, #4] "); // r12=aRegion2.iError
|
sl@0
|
846 |
asm("orrs r3, r3, r12 ");
|
sl@0
|
847 |
asm("bne " CSM_ZN7TRegion10ForceErrorEv); // if either set, ForceError()
|
sl@0
|
848 |
asm("str r3, [r0] "); // iCount=0
|
sl@0
|
849 |
asm("ldr r3, [r1] "); // r3=aRegion1.iCount
|
sl@0
|
850 |
asm("ldr r12, [r2] "); // r12=aRegion2.iCount
|
sl@0
|
851 |
asm("cmp r3, #0 ");
|
sl@0
|
852 |
asm("cmpne r12, #0 ");
|
sl@0
|
853 |
__JUMP(eq,lr);
|
sl@0
|
854 |
asm("stmfd sp!, {r3-r11,lr} ");
|
sl@0
|
855 |
asm("ldr lr, [r1, #8] "); // r1 points to first rectangle of aRegion1 = pRect1
|
sl@0
|
856 |
asm("cmn lr, lr ");
|
sl@0
|
857 |
asm("ldrcc r1, [r1, #16] "); // if RRegion
|
sl@0
|
858 |
asm("addcs r1, r1, #20 "); // RRegionBuf
|
sl@0
|
859 |
asm("submi r1, r1, #8 "); // TRegionFix
|
sl@0
|
860 |
asm("intersection1: ");
|
sl@0
|
861 |
asm("ldr lr, [r2, #8] "); // lr points to first rectangle of aRegion2
|
sl@0
|
862 |
asm("cmn lr, lr ");
|
sl@0
|
863 |
asm("ldrcc lr, [r2, #16] "); // if RRegion
|
sl@0
|
864 |
asm("addcs lr, r2, #20 "); // RRegionBuf
|
sl@0
|
865 |
asm("submi lr, lr, #8 "); // TRegionFix
|
sl@0
|
866 |
asm("ldr r12, [r2] "); // r12=aRegion2.iCount
|
sl@0
|
867 |
asm("intersection2: ");
|
sl@0
|
868 |
asm("ldmia r1, {r4-r7} "); // r4-r7 = *pRect1
|
sl@0
|
869 |
asm("ldmia lr!, {r8-r11} "); // r8-r11 = *pRect2++
|
sl@0
|
870 |
asm("cmp r6, r8 "); // compare pRect1->iBr.iX with pRect2->iTl.iX
|
sl@0
|
871 |
asm("cmpgt r7, r9 "); // if >, compare pRect1->iBr.iY with pRect2->iTl.iY
|
sl@0
|
872 |
asm("cmpgt r10, r4 "); // if >, compare pRect2->iBr.iX with pRect1->iTl.iX
|
sl@0
|
873 |
asm("cmpgt r11, r5 "); // if >, compare pRect2->iBr.iY with pRect1->iTl.iY
|
sl@0
|
874 |
asm("ble intersection3 "); // if <=, rectangles have empty intersection, so iterate
|
sl@0
|
875 |
asm("cmp r4, r8 "); // compute intersection and place in r8-r11
|
sl@0
|
876 |
asm("movgt r8, r4 ");
|
sl@0
|
877 |
asm("cmp r5, r9 ");
|
sl@0
|
878 |
asm("movgt r9, r5 ");
|
sl@0
|
879 |
asm("cmp r6, r10 ");
|
sl@0
|
880 |
asm("movlt r10, r6 ");
|
sl@0
|
881 |
asm("cmp r7, r11 ");
|
sl@0
|
882 |
asm("movlt r11, r7 ");
|
sl@0
|
883 |
asm("stmfd sp!, {r0-r3,r12,lr} "); // preserve registers across function call
|
sl@0
|
884 |
asm("bl " CSM_Z16AllocAnotherRectP7TRegion);
|
sl@0
|
885 |
asm("ldmfd sp!, {r0-r3} ");
|
sl@0
|
886 |
asm("ldmeqfd sp!, {r12,lr} "); // exit if error
|
sl@0
|
887 |
asm("beq intersection_end ");
|
sl@0
|
888 |
|
sl@0
|
889 |
asm("ldr r12, [r0] "); // r12=iCount
|
sl@0
|
890 |
asm("ldr lr, [r0, #8] "); // lr points to first rectangle
|
sl@0
|
891 |
asm("cmn lr, lr ");
|
sl@0
|
892 |
asm("ldrcc lr, [r0, #16] "); // if RRegion
|
sl@0
|
893 |
asm("addcs lr, r0, #20 "); // RRegionBuf
|
sl@0
|
894 |
asm("submi lr, lr, #8 "); // TRegionFix
|
sl@0
|
895 |
asm("add lr, lr, r12, lsl #4 "); // lr=&(iRectangleList[iCount])
|
sl@0
|
896 |
asm("add r12, r12, #1 "); // increment iCount
|
sl@0
|
897 |
asm("str r12, [r0] "); //
|
sl@0
|
898 |
asm("stmia lr!, {r8-r11} "); // append intersection of rectangles
|
sl@0
|
899 |
asm("ldmfd sp!, {r12,lr} "); // restore registers
|
sl@0
|
900 |
asm("intersection3: ");
|
sl@0
|
901 |
asm("subs r12, r12, #1 ");
|
sl@0
|
902 |
asm("bne intersection2 "); // loop for all values of pRect2
|
sl@0
|
903 |
asm("add r1, r1, #16 "); // increment pRect1
|
sl@0
|
904 |
asm("subs r3, r3, #1 ");
|
sl@0
|
905 |
asm("bne intersection1 "); // loop for all values of pRect1
|
sl@0
|
906 |
|
sl@0
|
907 |
asm("intersection_end: ");
|
sl@0
|
908 |
__POPRET("r3-r11,");
|
sl@0
|
909 |
}
|
sl@0
|
910 |
|
sl@0
|
911 |
#endif
|
sl@0
|
912 |
|
sl@0
|
913 |
|
sl@0
|
914 |
|
sl@0
|
915 |
|
sl@0
|
916 |
#ifdef __COBJECT_MACHINE_CODED__
|
sl@0
|
917 |
__NAKED__ EXPORT_C CObject *CObjectIx::At(TInt /*aHandle*/,TInt /*aUniqueID*/)
|
sl@0
|
918 |
/**
|
sl@0
|
919 |
Gets a pointer to the reference counting object with the specified handle
|
sl@0
|
920 |
number and matching unique ID.
|
sl@0
|
921 |
|
sl@0
|
922 |
@param aHandle The handle number of the reference counting object.
|
sl@0
|
923 |
@param aUniqueID The unique ID.
|
sl@0
|
924 |
|
sl@0
|
925 |
@return A pointer to the reference counting object. If there is no matching
|
sl@0
|
926 |
object, then this is NULL.
|
sl@0
|
927 |
*/
|
sl@0
|
928 |
{
|
sl@0
|
929 |
// r0=this, r1=aHandle, r2=aUniqueID
|
sl@0
|
930 |
asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iHighWaterMark)); // r3=iHighWaterMark
|
sl@0
|
931 |
asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iObjects)); // r0=iObjects
|
sl@0
|
932 |
asm("mov r12, r1, lsl #17 "); // r12=r1<<17 = index(aHandle)<<17
|
sl@0
|
933 |
asm("cmp r3, r12, lsr #17 "); // compare iHighWaterMark with index(aHandle)
|
sl@0
|
934 |
asm("movle r0, #0 "); // if hwm<=index, return NULL
|
sl@0
|
935 |
__JUMP(le,lr);
|
sl@0
|
936 |
asm("add r0, r0, r12, lsr #14 "); // r0=iObjects+index(Handle)=pS
|
sl@0
|
937 |
asm("ldr r3, [r0] "); // r3=pS->uniqueID:pS->instance
|
sl@0
|
938 |
asm("mov r1, r1, lsl #2 "); // r1=instance(Handle)<<18
|
sl@0
|
939 |
asm("mov r1, r1, lsr #18 "); // r1=instance(Handle)
|
sl@0
|
940 |
asm("orr r1, r1, r2, lsl #16 "); // r1=aUniqueID:instance(Handle)
|
sl@0
|
941 |
asm("cmp r1, r3 "); // check uniqueID and instance
|
sl@0
|
942 |
asm("movne r0, #0 "); // if wrong, return 0
|
sl@0
|
943 |
asm("ldreq r0, [r0, #4] "); // else return pointer to CObject
|
sl@0
|
944 |
__JUMP(,lr);
|
sl@0
|
945 |
}
|
sl@0
|
946 |
|
sl@0
|
947 |
|
sl@0
|
948 |
|
sl@0
|
949 |
|
sl@0
|
950 |
__NAKED__ EXPORT_C CObject *CObjectIx::At(TInt aHandle)
|
sl@0
|
951 |
/**
|
sl@0
|
952 |
Gets a pointer to the reference counting object with the specified
|
sl@0
|
953 |
handle number.
|
sl@0
|
954 |
|
sl@0
|
955 |
@param aHandle The handle number of the reference counting object.
|
sl@0
|
956 |
|
sl@0
|
957 |
@return A pointer to the reference counting object. If there is no matching
|
sl@0
|
958 |
object, then this is NULL.
|
sl@0
|
959 |
*/
|
sl@0
|
960 |
{
|
sl@0
|
961 |
// r0=this, r1=aHandle
|
sl@0
|
962 |
asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iHighWaterMark)); // r3=iHighWaterMark
|
sl@0
|
963 |
asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iObjects)); // r0=iObjects
|
sl@0
|
964 |
asm("mov r12, r1, lsl #17 "); // r12=r1<<17 = index(aHandle)<<17
|
sl@0
|
965 |
asm("cmp r3, r12, lsr #17 "); // compare iHighWaterMark with index(aHandle)
|
sl@0
|
966 |
asm("movle r0, #0 "); // if hwm<=index, return NULL
|
sl@0
|
967 |
__JUMP(le,lr);
|
sl@0
|
968 |
asm("add r0, r0, r12, lsr #14 "); // r0=iObjects+index(Handle)=pS
|
sl@0
|
969 |
asm("ldr r3, [r0] "); // r3=pS->uniqueID:pS->instance
|
sl@0
|
970 |
asm("ldr r2, __instanceMask ");
|
sl@0
|
971 |
asm("and r1, r1, r2 "); // r1=instance(Handle)<<16
|
sl@0
|
972 |
asm("cmp r1, r3, lsl #16 "); // check instance
|
sl@0
|
973 |
asm("movne r0, #0 "); // if wrong, return 0
|
sl@0
|
974 |
asm("ldreq r0, [r0, #4] "); // else return pointer to CObject
|
sl@0
|
975 |
__JUMP(,lr);
|
sl@0
|
976 |
asm("__instanceMask: ");
|
sl@0
|
977 |
asm(".word 0x3FFF0000 ");
|
sl@0
|
978 |
}
|
sl@0
|
979 |
|
sl@0
|
980 |
|
sl@0
|
981 |
|
sl@0
|
982 |
|
sl@0
|
983 |
GLREF_C void PanicCObjectIxIndexOutOfRange(void);
|
sl@0
|
984 |
|
sl@0
|
985 |
|
sl@0
|
986 |
|
sl@0
|
987 |
|
sl@0
|
988 |
__NAKED__ EXPORT_C CObject* CObjectIx::operator[](TInt /*anIndex*/)
|
sl@0
|
989 |
/**
|
sl@0
|
990 |
Gets a pointer to a reference counting object located at the specified offset
|
sl@0
|
991 |
within the object index.
|
sl@0
|
992 |
|
sl@0
|
993 |
@param anIndex The offset of the reference counting object within the object
|
sl@0
|
994 |
index. Offset is relative to zero.
|
sl@0
|
995 |
|
sl@0
|
996 |
@return A pointer to the reference counting object.
|
sl@0
|
997 |
|
sl@0
|
998 |
@panic E32USER-CBase 21 if the value of anIndex is negative or is greater than
|
sl@0
|
999 |
or equal to the total number of objects held by
|
sl@0
|
1000 |
the index.
|
sl@0
|
1001 |
*/
|
sl@0
|
1002 |
{
|
sl@0
|
1003 |
// r0=this, r1=anIndex
|
sl@0
|
1004 |
asm("cmp r1, #0 "); // check anIndex>=0
|
sl@0
|
1005 |
asm("ldrge r3, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iHighWaterMark)); // if so, r3=iHighWaterMark
|
sl@0
|
1006 |
asm("cmpge r3, r1 "); // and compare iHighWaterMark to anIndex
|
sl@0
|
1007 |
asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iObjects)); // if OK, r0=iObjects
|
sl@0
|
1008 |
asm("addgt r0, r0, r1, lsl #3 "); // r0=iObjects+anIndex
|
sl@0
|
1009 |
asm("ldrgt r0, [r0, #4] "); // r0=pointer to CObject
|
sl@0
|
1010 |
#ifdef __CPU_ARMV6
|
sl@0
|
1011 |
asm("ble 1f ");
|
sl@0
|
1012 |
__JUMP(,lr);
|
sl@0
|
1013 |
#else
|
sl@0
|
1014 |
__JUMP(gt,lr);
|
sl@0
|
1015 |
#endif
|
sl@0
|
1016 |
asm("1: ");
|
sl@0
|
1017 |
asm("b " CSM_Z29PanicCObjectIxIndexOutOfRangev); // if anIndex<0 or iCount<=anIndex, panic
|
sl@0
|
1018 |
}
|
sl@0
|
1019 |
|
sl@0
|
1020 |
|
sl@0
|
1021 |
|
sl@0
|
1022 |
|
sl@0
|
1023 |
GLREF_C void PanicCObjectConIndexOutOfRange(void);
|
sl@0
|
1024 |
GLREF_C void PanicCObjectConFindBadHandle(void);
|
sl@0
|
1025 |
GLREF_C void PanicCObjectConFindIndexOutOfRange(void);
|
sl@0
|
1026 |
|
sl@0
|
1027 |
|
sl@0
|
1028 |
|
sl@0
|
1029 |
|
sl@0
|
1030 |
__NAKED__ EXPORT_C CObject *CObjectCon::operator[](TInt /*anIndex*/)
|
sl@0
|
1031 |
/**
|
sl@0
|
1032 |
Gets a pointer to the reference counting object located at the specified offset
|
sl@0
|
1033 |
within the object container.
|
sl@0
|
1034 |
|
sl@0
|
1035 |
@param anIndex The offset of the reference counting object within the object
|
sl@0
|
1036 |
container. Offset is relative to zero.
|
sl@0
|
1037 |
|
sl@0
|
1038 |
@return A pointer to the owning reference counting object.
|
sl@0
|
1039 |
|
sl@0
|
1040 |
@panic E32USER-CBase 21 if anIndex is negative or is greater than or equal to
|
sl@0
|
1041 |
the total number of objects held by the container.
|
sl@0
|
1042 |
*/
|
sl@0
|
1043 |
{
|
sl@0
|
1044 |
// r0=this, r1=anIndex
|
sl@0
|
1045 |
asm("cmp r1, #0 ");
|
sl@0
|
1046 |
asm("ldrge r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iCount));
|
sl@0
|
1047 |
asm("cmpge r2, r1 ");
|
sl@0
|
1048 |
asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iObjects));
|
sl@0
|
1049 |
asm("ldrgt r0, [r0, r1, lsl #2] ");
|
sl@0
|
1050 |
#ifdef __CPU_ARMV6
|
sl@0
|
1051 |
asm("ble 1f ");
|
sl@0
|
1052 |
__JUMP(,lr);
|
sl@0
|
1053 |
#else
|
sl@0
|
1054 |
__JUMP(gt,lr);
|
sl@0
|
1055 |
#endif
|
sl@0
|
1056 |
asm("1: ");
|
sl@0
|
1057 |
asm("b " CSM_Z30PanicCObjectConIndexOutOfRangev);
|
sl@0
|
1058 |
}
|
sl@0
|
1059 |
|
sl@0
|
1060 |
|
sl@0
|
1061 |
|
sl@0
|
1062 |
|
sl@0
|
1063 |
__NAKED__ EXPORT_C CObject *CObjectCon::At(TInt /*aFindHandle*/) const
|
sl@0
|
1064 |
/**
|
sl@0
|
1065 |
Gets a pointer to the reference counting object with the specified find-handle
|
sl@0
|
1066 |
number.
|
sl@0
|
1067 |
|
sl@0
|
1068 |
A find-handle number is an integer which uniquely identifies a reference
|
sl@0
|
1069 |
counting object with respect to its object container.
|
sl@0
|
1070 |
|
sl@0
|
1071 |
@param aFindHandle The find-handle number of the reference counting object.
|
sl@0
|
1072 |
The unique Id part of this number must be the same as the
|
sl@0
|
1073 |
unique Id of this container.
|
sl@0
|
1074 |
The index part of the find-handle number must be
|
sl@0
|
1075 |
a valid index.
|
sl@0
|
1076 |
|
sl@0
|
1077 |
@return A pointer to the reference counting object.
|
sl@0
|
1078 |
|
sl@0
|
1079 |
@panic E32User-CBase 38 if the unique Id part of aFindHandle is not the same as
|
sl@0
|
1080 |
the unique Id of this container.
|
sl@0
|
1081 |
@panic E32User-CBase 39 if the index part of aFindHandle is negative or greater
|
sl@0
|
1082 |
than or equal to the total number of reference counting
|
sl@0
|
1083 |
objects held by this object container.
|
sl@0
|
1084 |
*/
|
sl@0
|
1085 |
{
|
sl@0
|
1086 |
// r0=this, r1=aFindHandle
|
sl@0
|
1087 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iUniqueID));
|
sl@0
|
1088 |
asm("cmp r2, r1, lsr #16 ");
|
sl@0
|
1089 |
asm("ldreq r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iCount));
|
sl@0
|
1090 |
asm("bne " CSM_Z28PanicCObjectConFindBadHandlev);
|
sl@0
|
1091 |
asm("mov r1, r1, lsl #17 ");
|
sl@0
|
1092 |
asm("cmp r2, r1, lsr #17 ");
|
sl@0
|
1093 |
asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iObjects));
|
sl@0
|
1094 |
asm("ble " CSM_Z34PanicCObjectConFindIndexOutOfRangev);
|
sl@0
|
1095 |
asm("ldr r0, [r0, r1, lsr #15] ");
|
sl@0
|
1096 |
__JUMP(,lr);
|
sl@0
|
1097 |
}
|
sl@0
|
1098 |
|
sl@0
|
1099 |
|
sl@0
|
1100 |
|
sl@0
|
1101 |
|
sl@0
|
1102 |
__NAKED__ EXPORT_C CObject *CObjectCon::AtL(TInt /*aFindHandle*/) const
|
sl@0
|
1103 |
/**
|
sl@0
|
1104 |
Gets a pointer to the reference counting object with the specified find-handle
|
sl@0
|
1105 |
number, and leaves on error.
|
sl@0
|
1106 |
|
sl@0
|
1107 |
A find-handle number is an integer which uniquely identifies a reference
|
sl@0
|
1108 |
counting object with respect to its object container.
|
sl@0
|
1109 |
|
sl@0
|
1110 |
@param aFindHandle The find-handle number of the reference counting object.
|
sl@0
|
1111 |
The unique Id part of this number must be the same as
|
sl@0
|
1112 |
the unique Id of this container.
|
sl@0
|
1113 |
The index part of the find-handle number must be
|
sl@0
|
1114 |
a valid index.
|
sl@0
|
1115 |
|
sl@0
|
1116 |
@return A pointer to the reference counting object.
|
sl@0
|
1117 |
|
sl@0
|
1118 |
@leave KErrBadHandle if the unique Id part of aFindHandle is not the same as
|
sl@0
|
1119 |
the unique Id of this container.
|
sl@0
|
1120 |
@leave KErrArgument if the index part of aFindHandle is negative or greater
|
sl@0
|
1121 |
than or equal to the total number of reference counting
|
sl@0
|
1122 |
objects held by this object container.
|
sl@0
|
1123 |
*/
|
sl@0
|
1124 |
{
|
sl@0
|
1125 |
// r0=this, r1=aFindHandle
|
sl@0
|
1126 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iUniqueID));
|
sl@0
|
1127 |
asm("cmp r2, r1, lsr #16 ");
|
sl@0
|
1128 |
asm("ldreq r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iCount));
|
sl@0
|
1129 |
asm("bne 1f ");
|
sl@0
|
1130 |
asm("mov r1, r1, lsl #17 ");
|
sl@0
|
1131 |
asm("cmp r2, r1, lsr #17 ");
|
sl@0
|
1132 |
asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iObjects));
|
sl@0
|
1133 |
asm("ble 2f ");
|
sl@0
|
1134 |
asm("ldr r0, [r0, r1, lsr #15] ");
|
sl@0
|
1135 |
__JUMP(,lr);
|
sl@0
|
1136 |
// User::Leave tail called, so no annotations required since
|
sl@0
|
1137 |
// current frame is reused by User::Leave
|
sl@0
|
1138 |
asm("1: ");
|
sl@0
|
1139 |
asm("mvn r0, #7 "); // KErrBadHandle
|
sl@0
|
1140 |
asm("b " CSM_ZN4User5LeaveEi);
|
sl@0
|
1141 |
asm("2: ");
|
sl@0
|
1142 |
asm("mvn r0, #5 "); // KErrArgument
|
sl@0
|
1143 |
asm("b " CSM_ZN4User5LeaveEi);
|
sl@0
|
1144 |
}
|
sl@0
|
1145 |
#endif
|
sl@0
|
1146 |
|
sl@0
|
1147 |
#ifdef __CACTIVESCHEDULER_MACHINE_CODED__
|
sl@0
|
1148 |
extern "C" void PanicStrayEvent();
|
sl@0
|
1149 |
|
sl@0
|
1150 |
/**
|
sl@0
|
1151 |
@internalComponent
|
sl@0
|
1152 |
|
sl@0
|
1153 |
The inner active scheduler loop. This repeatedly waits for a signal and then
|
sl@0
|
1154 |
dispatches the highest priority ready active object. The loop terminates either
|
sl@0
|
1155 |
if one of the RunL()s stops the current active scheduler level or leaves.
|
sl@0
|
1156 |
|
sl@0
|
1157 |
Stop when aLoop becomes 'Inactive'
|
sl@0
|
1158 |
*/
|
sl@0
|
1159 |
__NAKED__ void CActiveScheduler::DoRunL(TLoopOwner* const volatile& aLoop, CActive* volatile & aCurrentObj, TCleanupBundle* aCleanupBundlePtr)
|
sl@0
|
1160 |
{
|
sl@0
|
1161 |
asm("stmfd sp!, {r4-r8,lr} ");
|
sl@0
|
1162 |
__EH_FRAME_PUSH2(r4-r8,lr)
|
sl@0
|
1163 |
|
sl@0
|
1164 |
#ifdef _DEBUG
|
sl@0
|
1165 |
// need to copy aCleanupBundlePtr to somewhere else before it's clobbered by the next line.
|
sl@0
|
1166 |
asm("mov r8, r3 "); // r8 = &aCleanupBundlePtr
|
sl@0
|
1167 |
#endif
|
sl@0
|
1168 |
|
sl@0
|
1169 |
asm("ldr r3, [r0, #%a0]" : : "i" (_CBASE_VPTR_OFFSET_)); // r3 = vptr
|
sl@0
|
1170 |
asm("add r4, r0, #%a0" : : "i" _FOFF(CActiveScheduler,iActiveQ)); // r4 = &iActiveQ
|
sl@0
|
1171 |
asm("mov r5, r1 "); // r5 = &aLoop
|
sl@0
|
1172 |
asm("mov r7, r2 "); // r7 = &aCurrentObj
|
sl@0
|
1173 |
asm("ldr r6, [r3, #%a0]" : : "i" (_CACTIVESCHEDULER_WAIT_OFFSET_)); // r6 = &WaitForAnyRequest()
|
sl@0
|
1174 |
|
sl@0
|
1175 |
asm("active_scheduler_loop: ");
|
sl@0
|
1176 |
asm("ldr r1, [r5] "); // r1 = aLoop
|
sl@0
|
1177 |
asm("adr lr, 1f "); // return address
|
sl@0
|
1178 |
asm("sub r0, r4, #%a0 " : : "i" _FOFF(CActiveScheduler,iActiveQ)); // this
|
sl@0
|
1179 |
asm("cmp r1, #0 ");
|
sl@0
|
1180 |
__JUMP(ne, r6); // call WaitForAnyRequest() if still active
|
sl@0
|
1181 |
__POPRET("r4-r8,"); // else return
|
sl@0
|
1182 |
|
sl@0
|
1183 |
// get here when WaitForAnyRequest() returns
|
sl@0
|
1184 |
asm("1: ");
|
sl@0
|
1185 |
asm("ldr r14, [r4, #0] "); // r14->first active object
|
sl@0
|
1186 |
|
sl@0
|
1187 |
asm("2: ");
|
sl@0
|
1188 |
asm("cmp r14, r4 "); // end of queue?
|
sl@0
|
1189 |
asm("sub r0, r14, #%a0" : : "i" _FOFF(CActive,iLink)); // r0->CActive
|
sl@0
|
1190 |
asm("ldmneda r14, {r2, r12, r14} "); // r2=iStatus, r12=iStatus.iFlags (old iActive), r14 = next object
|
sl@0
|
1191 |
asm("beq PanicStrayEvent "); // if end of queue, panic
|
sl@0
|
1192 |
#ifdef _DEBUG
|
sl@0
|
1193 |
asm("ands r3, r12, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending))); // only active bit and request-pending bit
|
sl@0
|
1194 |
asm("cmpne r3, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending))); // active bit == request pending bit
|
sl@0
|
1195 |
asm("bne PanicStrayEvent "); // if active bit != request pending bit, panic
|
sl@0
|
1196 |
#endif
|
sl@0
|
1197 |
asm("cmp r2, #%a0" : : "i" ((TInt)KRequestPending)); // test if iStatus!=KRequestPending
|
sl@0
|
1198 |
asm("andnes r3, r12, #%a0" : : "i" ((TInt)TRequestStatus::EActive)); // if so, test iActive
|
sl@0
|
1199 |
asm("beq 2b "); // if not active or still pending, do next CActive
|
sl@0
|
1200 |
|
sl@0
|
1201 |
// have an active object to run
|
sl@0
|
1202 |
#ifdef __SMP__
|
sl@0
|
1203 |
__DATA_MEMORY_BARRIER_Z__(r3); // acquire semantics
|
sl@0
|
1204 |
#endif
|
sl@0
|
1205 |
asm("ldr r3, [r0, #%a0]" : : "i" (_CBASE_VPTR_OFFSET_)); // r3=CActive->vptr
|
sl@0
|
1206 |
asm("bic r12, r12, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending)));
|
sl@0
|
1207 |
asm("ldr r3, [r3, #%a0]" : : "i" (_CACTIVE_RUNL_OFFSET_)); // r3 = &CActive::RunL()
|
sl@0
|
1208 |
asm("str r12, [r0, #%a0]" : : "i" (_FOFF(CActive,iStatus)+_FOFF(TRequestStatus,iFlags))); // iActive=EFalse
|
sl@0
|
1209 |
asm("str r0, [r7] "); // save active object in aCurrentObj in case RunL leaves
|
sl@0
|
1210 |
#ifdef _DEBUG
|
sl@0
|
1211 |
__JUMPL(3); // call RunL() (and continue)
|
sl@0
|
1212 |
#else
|
sl@0
|
1213 |
asm("adr lr, active_scheduler_loop "); // set lr (return address) to label, active_scheduler_loop
|
sl@0
|
1214 |
__JUMP(,r3); // call RunL() (and loop)
|
sl@0
|
1215 |
#endif
|
sl@0
|
1216 |
|
sl@0
|
1217 |
|
sl@0
|
1218 |
#ifdef _DEBUG
|
sl@0
|
1219 |
//check whether there's a cleanup stack installed:
|
sl@0
|
1220 |
|
sl@0
|
1221 |
asm("cmp r8, #0"); // check CleanupBundle* == NULL
|
sl@0
|
1222 |
asm("beq active_scheduler_loop "); // If r8 == NULL, branch to label, active_scheduler_loop
|
sl@0
|
1223 |
asm("ldr r0, [r8, #%a0]" : : "i" _FOFF(TCleanupBundle,iCleanupPtr)); // r0 = CCleanup* (load the CCleanup*)
|
sl@0
|
1224 |
|
sl@0
|
1225 |
//there is a cleanupstack installed:
|
sl@0
|
1226 |
asm("add r1, r8, #%a0" : : "i" _FOFF(TCleanupBundle,iDummyInt)); // r1 = iDummyInt* (load the TInt*)
|
sl@0
|
1227 |
asm("adr lr, active_scheduler_loop "); // set lr (return address) to label, active_scheduler_loop
|
sl@0
|
1228 |
asm("b " CSM_ZN8CCleanup5CheckEPv); // call CCleanup::Check(iDummyInt*)
|
sl@0
|
1229 |
#endif
|
sl@0
|
1230 |
|
sl@0
|
1231 |
}
|
sl@0
|
1232 |
#endif
|
sl@0
|
1233 |
|
sl@0
|
1234 |
|
sl@0
|
1235 |
#ifdef __CSERVER_MACHINE_CODED__
|
sl@0
|
1236 |
__NAKED__ EXPORT_C void CServer2::RunL()
|
sl@0
|
1237 |
{
|
sl@0
|
1238 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(CServer2,iMessage.iFunction)); // r2=Message().Function()
|
sl@0
|
1239 |
asm("stmfd sp!, {r4, lr}"); // save regs
|
sl@0
|
1240 |
__EH_FRAME_PUSH2(r4,lr)
|
sl@0
|
1241 |
asm("cmp r2, #0"); // check for Connect/Disconnect message
|
sl@0
|
1242 |
asm("bmi server2_con_dis");
|
sl@0
|
1243 |
|
sl@0
|
1244 |
// Service the message
|
sl@0
|
1245 |
asm("mov r4, r0 "); // r4=this
|
sl@0
|
1246 |
asm("ldr r0, [r4, #%a0]" : : "i" _FOFF(CServer2,iMessage.iSessionPtr)); // r0=session
|
sl@0
|
1247 |
asm("add r1, r4, #%a0" : : "i" (_FOFF(CServer2,iMessage))); // r1=&iServer.Message()
|
sl@0
|
1248 |
asm("cmp r0, #0"); // Check for NULL session
|
sl@0
|
1249 |
asm("ldrne r12, [r0, #%a0]" : : "i" (_CBASE_VPTR_OFFSET_)); // r12=CSession2::vptr
|
sl@0
|
1250 |
#ifdef __SUPPORT_THUMB_INTERWORKING
|
sl@0
|
1251 |
asm("ldrne r3, [r12, #%a0]" : : "i" (_CSESSION2_SERVICEL_OFFSET_)); // call CSession2::ServiceL(iMessage)
|
sl@0
|
1252 |
asm("adr lr, server2_run_postamble ");
|
sl@0
|
1253 |
asm("bxne r3 ");
|
sl@0
|
1254 |
#else
|
sl@0
|
1255 |
asm("adr lr, server2_run_postamble ");
|
sl@0
|
1256 |
asm("ldrne pc, [r12, #%a0]" : : "i" (_CSESSION2_SERVICEL_OFFSET_)); // call CSession2::ServiceL(iMessage)
|
sl@0
|
1257 |
#endif
|
sl@0
|
1258 |
asm("mov r0, r1");
|
sl@0
|
1259 |
asm("b " CSM_ZN8CServer212NotConnectedERK9RMessage2); // NULL session ptr means not connected
|
sl@0
|
1260 |
|
sl@0
|
1261 |
// Do this after processing any message
|
sl@0
|
1262 |
asm("server2_run_postamble: ");
|
sl@0
|
1263 |
asm("ldr r2, [r4, #%a0]" : : "i" (_FOFF(CServer2,iStatus)+_FOFF(TRequestStatus,iFlags))); // r2=iStatus.iFlags (old iActive)
|
sl@0
|
1264 |
asm("mov r0, #0x80000001 "); // r0=KRequestPending
|
sl@0
|
1265 |
asm("ands r1, r2, #%a0" : : "i" ((TInt)TRequestStatus::EActive));
|
sl@0
|
1266 |
asm("bne server2_run_end "); // if already active, finished
|
sl@0
|
1267 |
asm("orr r2, r2, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending)));
|
sl@0
|
1268 |
asm("add r1, r4, #%a0" : : "i" _FOFF(CActive,iStatus)); // r1->iStatus
|
sl@0
|
1269 |
asm("stmia r1, {r0,r2} "); // set iStatus=KRequestPending, set active bit, set request pending bit
|
sl@0
|
1270 |
asm("add r2, r4, #%a0" : : "i" _FOFF(CServer2,iMessage)); // r2->iServer.Message()
|
sl@0
|
1271 |
asm("ldr r0, [r4, #%a0]" : : "i" _FOFF(CServer2,iServer)); // r0=iServer.iHandle
|
sl@0
|
1272 |
asm("bl " CSM_ZN4Exec13ServerReceiveEiR14TRequestStatusPv);// call Exec::ServerReceive
|
sl@0
|
1273 |
asm("server2_run_end: ");
|
sl@0
|
1274 |
__POPRET("r4,");
|
sl@0
|
1275 |
|
sl@0
|
1276 |
// Deal with Connect and Disconnect messages
|
sl@0
|
1277 |
asm("server2_con_dis:");
|
sl@0
|
1278 |
asm("mov r4, r0 "); // r4=this
|
sl@0
|
1279 |
asm("add r1, r0, #%a0" : : "i" _FOFF(CServer2,iMessage)); // r1=&iServer.Message()
|
sl@0
|
1280 |
asm("adr lr, server2_run_postamble "); // return address for after any processing
|
sl@0
|
1281 |
asm("cmp r2, #%a0" : : "i" (RMessage2::EConnect));
|
sl@0
|
1282 |
asm("beq " CSM_ZN8CServer27ConnectERK9RMessage2); // Do Connect()
|
sl@0
|
1283 |
asm("cmp r2, #%a0" : : "i" (RMessage2::EDisConnect));
|
sl@0
|
1284 |
asm("beq " CSM_ZN8CServer210DisconnectERK9RMessage2); // Do Disconnect()
|
sl@0
|
1285 |
asm("mov r0, r1");
|
sl@0
|
1286 |
asm("b " CSM_ZN8CServer210BadMessageERK9RMessage2); // Bad message
|
sl@0
|
1287 |
}
|
sl@0
|
1288 |
#endif
|
sl@0
|
1289 |
|
sl@0
|
1290 |
EXPORT_C __NAKED__ void RFastLock::Wait()
|
sl@0
|
1291 |
{
|
sl@0
|
1292 |
asm("1: ");
|
sl@0
|
1293 |
asm("add r0, r0, #4 "); // point to iCount
|
sl@0
|
1294 |
|
sl@0
|
1295 |
#ifdef __CPU_ARM_HAS_LDREX_STREX
|
sl@0
|
1296 |
asm("2: ");
|
sl@0
|
1297 |
LDREX( 2, 0); // read
|
sl@0
|
1298 |
asm("subs r1, r2, #1 "); // decrement
|
sl@0
|
1299 |
STREX( 3, 1, 0); // write
|
sl@0
|
1300 |
asm("teq r3, #0 "); // success?
|
sl@0
|
1301 |
asm("bne 2b "); // no!
|
sl@0
|
1302 |
asm("sub r0, r0, #4 "); // r0 = this
|
sl@0
|
1303 |
asm("bcs " CSM_ZN10RSemaphore4WaitEv); // if no borrow from decrement wait on semaphore
|
sl@0
|
1304 |
#ifdef __SMP__
|
sl@0
|
1305 |
__DATA_MEMORY_BARRIER__(r3); // no need to wait, but still need acquire barrier
|
sl@0
|
1306 |
#endif
|
sl@0
|
1307 |
__JUMP(, lr );
|
sl@0
|
1308 |
#else
|
sl@0
|
1309 |
asm("mov r1, #1 "); // 'looking' value
|
sl@0
|
1310 |
asm("swp r1, r1, [r0] "); // write looking value, read original
|
sl@0
|
1311 |
asm("subs r1, r1, #1 "); // decrement count
|
sl@0
|
1312 |
asm("strlt r1, [r0] "); // if it becomes negative, no-one was looking
|
sl@0
|
1313 |
__JUMP(cc, lr); // if borrow, was originally zero so we are finished
|
sl@0
|
1314 |
asm("sub r0, r0, #4 "); // r0=this
|
sl@0
|
1315 |
asm("blt " CSM_ZN10RSemaphore4WaitEv); // lock held so wait on semaphore
|
sl@0
|
1316 |
asm("stmfd sp!, {r0,lr} "); // otherwise save registers
|
sl@0
|
1317 |
asm("mov r0, #1000 "); // someone was looking, so wait 1ms and try again
|
sl@0
|
1318 |
asm("bl " CSM_ZN4User12AfterHighResE27TTimeIntervalMicroSeconds32);
|
sl@0
|
1319 |
asm("ldmfd sp!, {r0,lr} ");
|
sl@0
|
1320 |
asm("b 1b ");
|
sl@0
|
1321 |
#endif
|
sl@0
|
1322 |
}
|
sl@0
|
1323 |
|
sl@0
|
1324 |
EXPORT_C __NAKED__ void RFastLock::Signal()
|
sl@0
|
1325 |
{
|
sl@0
|
1326 |
asm("1: ");
|
sl@0
|
1327 |
asm("add r0, r0, #4 "); // point to iCount
|
sl@0
|
1328 |
|
sl@0
|
1329 |
#ifdef __CPU_ARM_HAS_LDREX_STREX
|
sl@0
|
1330 |
#ifdef __SMP__
|
sl@0
|
1331 |
__DATA_MEMORY_BARRIER_Z__(r3); // need release barrier
|
sl@0
|
1332 |
#endif
|
sl@0
|
1333 |
asm("2: ");
|
sl@0
|
1334 |
LDREX( 2, 0); // read
|
sl@0
|
1335 |
asm("adds r1, r2, #1 "); // increment
|
sl@0
|
1336 |
STREX( 3, 1, 0); // write
|
sl@0
|
1337 |
asm("teq r3, #0 "); // success?
|
sl@0
|
1338 |
asm("bne 2b "); // no!
|
sl@0
|
1339 |
asm("sub r0, r0, #4 "); // r0 = this
|
sl@0
|
1340 |
asm("bcc " CSM_ZN10RSemaphore6SignalEv); // if no carry from increment, signal semaphore
|
sl@0
|
1341 |
__JUMP(, lr );
|
sl@0
|
1342 |
#else
|
sl@0
|
1343 |
asm("mov r1, #1 "); // 'looking' value
|
sl@0
|
1344 |
asm("swp r1, r1, [r0] "); // write looking value, read original
|
sl@0
|
1345 |
asm("adds r1, r1, #1 "); // increment count
|
sl@0
|
1346 |
asm("strle r1, [r0] "); // if still <=0, no-one was looking
|
sl@0
|
1347 |
__JUMP(eq, lr); // if it's now zero, no-one is waiting so we are finished
|
sl@0
|
1348 |
asm("sub r0, r0, #4 "); // r0=this
|
sl@0
|
1349 |
asm("blt " CSM_ZN10RSemaphore6SignalEv); // someone is waiting so signal semaphore
|
sl@0
|
1350 |
asm("stmfd sp!, {r0,lr} "); // otherwise save registers
|
sl@0
|
1351 |
asm("mov r0, #1000 "); // someone was looking, so wait 1ms and try again
|
sl@0
|
1352 |
asm("bl " CSM_ZN4User12AfterHighResE27TTimeIntervalMicroSeconds32);
|
sl@0
|
1353 |
asm("ldmfd sp!, {r0,lr} ");
|
sl@0
|
1354 |
asm("b 1b ");
|
sl@0
|
1355 |
#endif
|
sl@0
|
1356 |
}
|
sl@0
|
1357 |
|
sl@0
|
1358 |
|
sl@0
|
1359 |
// Entry point stub to allow EKA1 binaries to be executed under EKA2
|
sl@0
|
1360 |
// Only called when process is first loaded
|
sl@0
|
1361 |
|
sl@0
|
1362 |
extern "C" TLinAddr GetEka1ExeEntryPoint();
|
sl@0
|
1363 |
|
sl@0
|
1364 |
__NAKED__ TInt E32Loader::V7ExeEntryStub()
|
sl@0
|
1365 |
{
|
sl@0
|
1366 |
// Process entry point
|
sl@0
|
1367 |
// R4 = entry reason
|
sl@0
|
1368 |
// SP points to information block
|
sl@0
|
1369 |
asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonProcessInit) );
|
sl@0
|
1370 |
asm("bne " CSM_ZN4User9InvariantEv ); // invalid entry reason
|
sl@0
|
1371 |
asm("bl GetEka1ExeEntryPoint "); // load the entry stub and return its address
|
sl@0
|
1372 |
__JUMP(,r0); // jump to the entry stub with R4, SP unchanged
|
sl@0
|
1373 |
}
|
sl@0
|
1374 |
|
sl@0
|
1375 |
__NAKED__ TInt E32Loader::V7DllEntryStub(TInt)
|
sl@0
|
1376 |
{
|
sl@0
|
1377 |
|
sl@0
|
1378 |
__JUMP(,lr);
|
sl@0
|
1379 |
}
|
sl@0
|
1380 |
|
sl@0
|
1381 |
|
sl@0
|
1382 |
// Hash an 8 bit string at aPtr, length aLen bytes.
|
sl@0
|
1383 |
__NAKED__ TUint32 DefaultStringHash(const TUint8* /*aPtr*/, TInt /*aLen*/)
|
sl@0
|
1384 |
{
|
sl@0
|
1385 |
asm("ldr r3, one_over_phi ");
|
sl@0
|
1386 |
asm("subs r1, r1, #4 ");
|
sl@0
|
1387 |
asm("mov r2, r0 ");
|
sl@0
|
1388 |
asm("mov r0, #0 ");
|
sl@0
|
1389 |
asm("blo 1f ");
|
sl@0
|
1390 |
asm("ands r12, r2, #3 ");
|
sl@0
|
1391 |
asm("bne hash_unal ");
|
sl@0
|
1392 |
asm("2: ");
|
sl@0
|
1393 |
asm("ldr r12, [r2], #4 ");
|
sl@0
|
1394 |
asm("subs r1, r1, #4 ");
|
sl@0
|
1395 |
asm("eor r0, r0, r12 ");
|
sl@0
|
1396 |
asm("umull r0, r12, r3, r0 ");
|
sl@0
|
1397 |
asm("bcs 2b ");
|
sl@0
|
1398 |
asm("1: ");
|
sl@0
|
1399 |
asm("adds r1, r1, #4 ");
|
sl@0
|
1400 |
__JUMP(eq,lr);
|
sl@0
|
1401 |
asm("4: ");
|
sl@0
|
1402 |
asm("ldrb r12, [r2], #1 ");
|
sl@0
|
1403 |
asm("cmp r1, #2 ");
|
sl@0
|
1404 |
asm("eor r0, r0, r12 ");
|
sl@0
|
1405 |
asm("ldrcsb r12, [r2], #1 ");
|
sl@0
|
1406 |
asm("eorcs r0, r0, r12, lsl #8 ");
|
sl@0
|
1407 |
asm("ldrhib r12, [r2], #1 ");
|
sl@0
|
1408 |
asm("eorhi r0, r0, r12, lsl #16 ");
|
sl@0
|
1409 |
asm("umull r0, r12, r3, r0 ");
|
sl@0
|
1410 |
__JUMP(,lr);
|
sl@0
|
1411 |
|
sl@0
|
1412 |
asm("hash_unal: ");
|
sl@0
|
1413 |
asm("bic r2, r2, #3 ");
|
sl@0
|
1414 |
asm("stmfd sp!, {r4,r5,lr} ");
|
sl@0
|
1415 |
asm("mov r12, r12, lsl #3 ");
|
sl@0
|
1416 |
asm("rsb r14, r12, #32 ");
|
sl@0
|
1417 |
asm("ldr r4, [r2], #4 ");
|
sl@0
|
1418 |
asm("3: ");
|
sl@0
|
1419 |
asm("eor r0, r0, r4, lsr r12 ");
|
sl@0
|
1420 |
asm("ldr r4, [r2], #4 ");
|
sl@0
|
1421 |
asm("subs r1, r1, #4 ");
|
sl@0
|
1422 |
asm("eor r0, r0, r4, lsl r14 ");
|
sl@0
|
1423 |
asm("umull r0, r5, r3, r0 ");
|
sl@0
|
1424 |
asm("bcs 3b ");
|
sl@0
|
1425 |
asm("adds r1, r1, #4 ");
|
sl@0
|
1426 |
asm("ldmfd sp!, {r4,r5,lr} ");
|
sl@0
|
1427 |
asm("subne r2, r2, #4 ");
|
sl@0
|
1428 |
asm("addne r2, r2, r12, lsr #3 ");
|
sl@0
|
1429 |
asm("bne 4b ");
|
sl@0
|
1430 |
__JUMP(,lr);
|
sl@0
|
1431 |
}
|
sl@0
|
1432 |
|
sl@0
|
1433 |
// Hash a 16 bit string at aPtr, length aLen bytes.
|
sl@0
|
1434 |
__NAKED__ TUint32 DefaultWStringHash(const TUint16* /*aPtr*/, TInt /*aLen*/)
|
sl@0
|
1435 |
{
|
sl@0
|
1436 |
asm("str lr, [sp, #-4]! ");
|
sl@0
|
1437 |
asm("ldr r3, one_over_phi ");
|
sl@0
|
1438 |
asm("subs r1, r1, #8 ");
|
sl@0
|
1439 |
asm("mov r2, r0 ");
|
sl@0
|
1440 |
asm("mov r0, #0 ");
|
sl@0
|
1441 |
asm("blo 1f ");
|
sl@0
|
1442 |
asm("ands r12, r2, #3 ");
|
sl@0
|
1443 |
asm("bne whash_unal ");
|
sl@0
|
1444 |
asm("2: ");
|
sl@0
|
1445 |
asm("ldmia r2!, {r12,r14} ");
|
sl@0
|
1446 |
asm("subs r1, r1, #8 ");
|
sl@0
|
1447 |
asm("eor r0, r0, r12 ");
|
sl@0
|
1448 |
asm("eor r0, r0, r14, ror #24 ");
|
sl@0
|
1449 |
asm("umull r0, r12, r3, r0 ");
|
sl@0
|
1450 |
asm("bcs 2b ");
|
sl@0
|
1451 |
asm("1: ");
|
sl@0
|
1452 |
asm("adds r1, r1, #8 ");
|
sl@0
|
1453 |
asm("beq 8f ");
|
sl@0
|
1454 |
asm("4: ");
|
sl@0
|
1455 |
asm("ldrh r12, [r2], #2 ");
|
sl@0
|
1456 |
asm("cmp r1, #4 ");
|
sl@0
|
1457 |
asm("eor r0, r0, r12 ");
|
sl@0
|
1458 |
asm("ldrcsh r12, [r2], #2 ");
|
sl@0
|
1459 |
asm("eorcs r0, r0, r12, lsl #16 ");
|
sl@0
|
1460 |
asm("ldrhih r12, [r2], #2 ");
|
sl@0
|
1461 |
asm("eorhi r0, r0, r12, ror #24 ");
|
sl@0
|
1462 |
asm("umull r0, r12, r3, r0 ");
|
sl@0
|
1463 |
asm("8: ");
|
sl@0
|
1464 |
__POPRET("");
|
sl@0
|
1465 |
|
sl@0
|
1466 |
asm("whash_unal: ");
|
sl@0
|
1467 |
asm("add r2, r2, #2 "); // r2 must be 2 mod 4
|
sl@0
|
1468 |
asm("ldr r14, [r2, #-4] ");
|
sl@0
|
1469 |
asm("3: ");
|
sl@0
|
1470 |
asm("eor r0, r0, r14, lsr #16 "); // char 0 goes into bytes 0,1
|
sl@0
|
1471 |
asm("ldmia r2!, {r12,r14} ");
|
sl@0
|
1472 |
asm("subs r1, r1, #8 ");
|
sl@0
|
1473 |
asm("eor r0, r0, r12, lsl #16 "); // char 1 goes into bytes 2,3
|
sl@0
|
1474 |
asm("mov r12, r12, lsr #16 ");
|
sl@0
|
1475 |
asm("orr r12, r12, r14, lsl #16 "); // r12 = char3:char2
|
sl@0
|
1476 |
asm("eor r0, r0, r12, ror #24 "); // char 2 into bytes 1,2 ; char 3 into bytes 3,0
|
sl@0
|
1477 |
asm("umull r0, r12, r3, r0 ");
|
sl@0
|
1478 |
asm("bcs 3b ");
|
sl@0
|
1479 |
asm("adds r1, r1, #8 ");
|
sl@0
|
1480 |
asm("subne r2, r2, #2 ");
|
sl@0
|
1481 |
asm("bne 4b ");
|
sl@0
|
1482 |
__POPRET("");
|
sl@0
|
1483 |
}
|
sl@0
|
1484 |
|
sl@0
|
1485 |
|
sl@0
|
1486 |
/**
|
sl@0
|
1487 |
@publishedAll
|
sl@0
|
1488 |
@released
|
sl@0
|
1489 |
|
sl@0
|
1490 |
Calculate a 32 bit hash from a 32 bit integer.
|
sl@0
|
1491 |
|
sl@0
|
1492 |
@param aInt The integer to be hashed.
|
sl@0
|
1493 |
@return The calculated 32 bit hash value.
|
sl@0
|
1494 |
*/
|
sl@0
|
1495 |
EXPORT_C __NAKED__ TUint32 DefaultHash::Integer(const TInt& /*aInt*/)
|
sl@0
|
1496 |
{
|
sl@0
|
1497 |
asm("ldr r0, [r0] ");
|
sl@0
|
1498 |
asm("ldr r1, one_over_phi ");
|
sl@0
|
1499 |
asm("umull r0, r2, r1, r0 ");
|
sl@0
|
1500 |
__JUMP(,lr);
|
sl@0
|
1501 |
asm("one_over_phi: ");
|
sl@0
|
1502 |
asm(".word 0x9e3779b9 ");
|
sl@0
|
1503 |
}
|
sl@0
|
1504 |
|
sl@0
|
1505 |
|
sl@0
|
1506 |
#ifdef __USERSIDE_THREAD_DATA__
|
sl@0
|
1507 |
|
sl@0
|
1508 |
/**
|
sl@0
|
1509 |
@internalComponent
|
sl@0
|
1510 |
|
sl@0
|
1511 |
Get a pointer to the thread local user data stored in the thread ID register.
|
sl@0
|
1512 |
*/
|
sl@0
|
1513 |
__NAKED__ TLocalThreadData* LocalThreadData()
|
sl@0
|
1514 |
{
|
sl@0
|
1515 |
GET_RWRW_TID(,r0);
|
sl@0
|
1516 |
__JUMP(,lr);
|
sl@0
|
1517 |
}
|
sl@0
|
1518 |
|
sl@0
|
1519 |
#endif
|