sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\epoc\arm\uc_utl.cia sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "uc_std.h" sl@0: sl@0: sl@0: #if defined(__MEM_MACHINE_CODED__) sl@0: EXPORT_C __NAKED__ void Mem::Swap(TAny* /*aPtr1*/, TAny* /*aPtr2*/, TInt /*aLength*/) sl@0: /** sl@0: Swaps a number of bytes of data between two specified locations. sl@0: sl@0: The source and target areas can overlap. sl@0: sl@0: @param aPtr1 A pointer to the first location taking part in the swap. sl@0: @param aPtr2 A pointer to second location taking part in the swap. sl@0: @param aLength The number of bytes to be swapped between the two locations. sl@0: This value must not be negative. sl@0: sl@0: @panic USER 94 In debug builds only, if aLength is negative. sl@0: */ sl@0: { sl@0: sl@0: asm(" cmp r0,r1"); sl@0: asm(" cmpne r2,#0"); sl@0: __JUMP(eq,lr); sl@0: // sl@0: // Test for same alignment, if more than 16 bytes to swap sl@0: // sl@0: asm(" and r3,r0,#3"); sl@0: asm(" and ip,r1,#3"); sl@0: asm(" cmp r2,#16"); sl@0: asm(" addlt r3,r3,#4"); sl@0: asm(" cmp r3,ip"); sl@0: asm(" beq same_aligned_swap"); sl@0: sl@0: asm(" stmfd sp!,{r4,lr}"); sl@0: sl@0: asm("swap_loop:"); sl@0: sl@0: asm(" ldrb r3,[r0]"); sl@0: asm(" ldrb r4,[r1]"); sl@0: asm(" strb r3,[r1],#1"); sl@0: asm(" strb r4,[r0],#1"); sl@0: asm(" subs r2,r2,#1"); sl@0: asm("beq swap_exit1 "); sl@0: sl@0: asm(" ldrb r3,[r0]"); sl@0: asm(" ldrb r4,[r1]"); sl@0: asm(" strb r3,[r1],#1"); sl@0: asm(" strb r4,[r0],#1"); sl@0: asm(" subs r2,r2,#1"); sl@0: asm("beq swap_exit1 "); sl@0: sl@0: asm(" ldrb r3,[r0]"); sl@0: asm(" ldrb r4,[r1]"); sl@0: asm(" strb r3,[r1],#1"); sl@0: asm(" strb r4,[r0],#1"); sl@0: asm(" subs r2,r2,#1"); sl@0: asm("beq swap_exit1 "); sl@0: sl@0: asm(" ldrb r3,[r0]"); sl@0: asm(" ldrb r4,[r1]"); sl@0: asm(" strb r3,[r1],#1"); sl@0: asm(" strb r4,[r0],#1"); sl@0: asm(" subs r2,r2,#1"); sl@0: asm(" bne swap_loop"); sl@0: asm("swap_exit1: "); sl@0: __POPRET("r4,"); sl@0: sl@0: asm("same_aligned_swap:"); sl@0: sl@0: asm(" stmfd sp!,{r4-r10,lr}"); sl@0: // sl@0: // r3 contains the byte offset from word alignment, 0,1,2 or 3 sl@0: // subtract 1 to get -1,0,1 or 2, and if -1 make it 3 sl@0: // that gives us 0,1,2 or 3 if the alignment is 3,2,1 or 0 respectively sl@0: // We can use that to jump directly to the appropriate place for sl@0: // swapping the relevent number of bytes to achieve word alignment sl@0: // r4 is set to 3-r3 to correct the length for the number of bytes sl@0: // swapped sl@0: // sl@0: asm(" subs r3,r3,#1"); sl@0: asm(" movmi r3,#3"); sl@0: asm(" rsb r4,r3,#3"); sl@0: asm(" sub r2,r2,r4"); sl@0: asm(" add pc,pc,r3,asl #4"); sl@0: asm(" nop "); // never executed sl@0: // sl@0: // Jumps here if 3 bytes to swap before word aligned sl@0: // sl@0: asm(" ldrb r4,[r0]"); sl@0: asm(" ldrb ip,[r1]"); sl@0: asm(" strb r4,[r1],#1"); sl@0: asm(" strb ip,[r0],#1"); sl@0: // sl@0: // Jumps here if 2 bytes to swap before word aligned sl@0: // sl@0: asm(" ldrb r4,[r0]"); sl@0: asm(" ldrb ip,[r1]"); sl@0: asm(" strb r4,[r1],#1"); sl@0: asm(" strb ip,[r0],#1"); sl@0: // sl@0: // Jumps here if 1 byte to swap before word aligned sl@0: // sl@0: asm(" ldrb r4,[r0]"); sl@0: asm(" ldrb ip,[r1]"); sl@0: asm(" strb r4,[r1],#1"); sl@0: asm(" strb ip,[r0],#1"); sl@0: // sl@0: // We are now word aligned. Fast swapping, here we come... sl@0: // sl@0: asm("word_aligned_swap:"); sl@0: asm(" movs ip,r2,lsr #6"); // Number of 64 blocks to swap sl@0: asm(" beq its_smaller_swap"); sl@0: sl@0: asm("swap_64_bytes:"); sl@0: asm(" ldmia r1,{r3-r6}"); sl@0: asm(" ldmia r0,{r7-r10}"); sl@0: asm(" stmia r1!,{r7-r10}"); sl@0: asm(" stmia r0!,{r3-r6}"); sl@0: asm(" ldmia r1,{r3-r6}"); sl@0: asm(" ldmia r0,{r7-r10}"); sl@0: asm(" stmia r1!,{r7-r10}"); sl@0: asm(" stmia r0!,{r3-r6}"); sl@0: asm(" ldmia r1,{r3-r6}"); sl@0: asm(" ldmia r0,{r7-r10}"); sl@0: asm(" stmia r1!,{r7-r10}"); sl@0: asm(" stmia r0!,{r3-r6}"); sl@0: asm(" ldmia r1,{r3-r6}"); sl@0: asm(" ldmia r0,{r7-r10}"); sl@0: asm(" stmia r1!,{r7-r10}"); sl@0: asm(" stmia r0!,{r3-r6}"); sl@0: asm(" subs ip,ip,#1"); sl@0: asm(" bne swap_64_bytes"); sl@0: // sl@0: // Less than 64 bytes to go... sl@0: // sl@0: asm("its_smaller_swap:"); sl@0: asm(" ands r2,r2,#63"); sl@0: asm("beq swap_exit2 "); sl@0: asm(" cmp r2,#4"); sl@0: asm(" blt finish_swap"); sl@0: asm("final_swap_loop:"); sl@0: asm(" ldr r3,[r1]"); sl@0: asm(" ldr ip,[r0]"); sl@0: asm(" str r3,[r0],#4"); sl@0: asm(" str ip,[r1],#4"); sl@0: asm(" subs r2,r2,#4"); sl@0: asm(" cmp r2,#4"); sl@0: asm(" bge final_swap_loop"); sl@0: // sl@0: // Less than 4 bytes to go... sl@0: // sl@0: asm("finish_swap:"); sl@0: asm(" tst r2,#2"); sl@0: asm(" ldrneb r3,[r0]"); sl@0: asm(" ldrneb ip,[r1]"); sl@0: asm(" strneb r3,[r1],#1"); sl@0: asm(" strneb ip,[r0],#1"); sl@0: asm(" ldrneb r3,[r0]"); sl@0: asm(" ldrneb ip,[r1]"); sl@0: asm(" strneb r3,[r1],#1"); sl@0: asm(" strneb ip,[r0],#1"); sl@0: sl@0: asm(" tst r2,#1"); sl@0: asm(" ldrneb r3,[r0]"); sl@0: asm(" ldrneb ip,[r1]"); sl@0: asm(" strneb r3,[r1],#1"); sl@0: asm(" strneb ip,[r0],#1"); sl@0: sl@0: asm("swap_exit2: "); sl@0: __POPRET("r4-r10,"); sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __REGIONS_MACHINE_CODED__ sl@0: sl@0: __NAKED__ GLDEF_C void AllocAnotherRect( TRegion * /*aRegion*/ ) sl@0: { sl@0: // Returns with Z flag set to indicate error sl@0: sl@0: asm("ldr r1, [r0, #4] "); // r1=iError sl@0: asm("cmp r1, #0 "); sl@0: asm("bne return_error "); sl@0: asm("ldr r1, [r0, #8] "); // r1=iAllocedRects sl@0: asm("ldr r12, [r0] "); // r12=iCount sl@0: asm("tst r1, #0x40000000 "); // test ERRegionBuf sl@0: asm("beq allocanother1 "); // don't branch if TRegionFix sl@0: asm("cmn r1, r12 "); // test if iCount==-iAllocedRects sl@0: __JUMP(ne,lr); sl@0: asm("b " CSM_ZN7TRegion10ForceErrorEv); // if so, ForceError() sl@0: asm("allocanother1: "); sl@0: asm("cmp r1, #0 "); sl@0: asm("bpl allocanother3 "); // branch if RRegion, continue if RRegionBuf sl@0: asm("orr r2, r1, #0x40000000 "); // r2=iAllocedRects|ERRegionBuf sl@0: asm("cmn r2, r12 "); // check if iCount==(-(iAllocedRects|ERRegionBuf)) sl@0: __JUMP(ne,lr); sl@0: asm("ldr r2, [r0, #12] "); // r2=iGranularity sl@0: asm("add r1, r12, r2 "); // iAllocedRects=iCount+iGranularity - change into RRegion sl@0: asm("str r1, [r0, #8] "); sl@0: asm("stmfd sp!, {r0,r1,r12,lr} "); // save registers used in function call sl@0: asm("mov r0, r1, lsl #4 "); // number of bytes to allocate sl@0: asm("bl " CSM_ZN4User5AllocEi); // User::Alloc sl@0: asm("movs r2, r0 "); // returned pointer into r2 sl@0: asm("ldmfd sp!, {r0,r1,r12,lr} "); // restore registers sl@0: asm("add r3, r0, #20 "); // r3=address of first rectangle sl@0: asm("str r2, [r0, #16] "); // iRectangleList=returned pointer sl@0: asm("beq " CSM_ZN7TRegion10ForceErrorEv); // if pointer null, ForceError() sl@0: asm("cmp r12, #0 "); sl@0: asm("beq return_success "); sl@0: asm("stmfd sp!, {r4,r5} "); sl@0: asm("allocanother2: "); sl@0: asm("ldmia r3!, {r0,r1,r4,r5} "); // copy data to new area sl@0: asm("subs r12, r12, #1 "); sl@0: asm("stmia r2!, {r0,r1,r4,r5} "); sl@0: asm("bne allocanother2 "); sl@0: asm("ldmfd sp!, {r4,r5} "); sl@0: asm("return_success: "); sl@0: asm("movs r0, #1 "); // clear Z flag to indicate success sl@0: __JUMP(,lr); sl@0: asm("allocanother3: "); // come here if RRegion sl@0: asm("cmp r1, r12 "); // check if iCount==iAllocedRects sl@0: __JUMP(ne,lr); sl@0: asm("ldr r2, [r0, #12] "); // r2 = iGranularity sl@0: asm("add r1, r1, r2 "); // iAllocedRects+=iGranularity sl@0: asm("str r1, [r0, #8] "); sl@0: asm("stmfd sp!, {r0,lr} "); // preserve r0,lr across function call sl@0: asm("ldr r0, [r0, #16] "); // r0=address of current cell sl@0: asm("mov r1, r1, lsl #4 "); // r1=number of bytes to allocate sl@0: asm("mov r2, #0 "); sl@0: asm("bl " CSM_ZN4User7ReAllocEPvii); // User::ReAlloc sl@0: asm("movs r2, r0 "); // returned pointer into r2 sl@0: asm("ldmfd sp!, {r0,lr} "); // restore r0,lr sl@0: asm("strne r2, [r0, #16] "); // if returned ptr not null, iRectangleList=returned ptr sl@0: __JUMP(ne,lr); sl@0: asm("b " CSM_ZN7TRegion10ForceErrorEv); // else ForceError() sl@0: } sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TRegion::ForceError() sl@0: { sl@0: // Returns with Z flag set to indicate error sl@0: sl@0: asm("stmfd sp!, {r0,lr} "); sl@0: asm("bl " CSM_ZN7TRegion5ClearEv); // Clear() sl@0: asm("ldmfd sp!, {r0,lr} "); // restore r0,lr sl@0: asm("mov r1, #1 "); sl@0: asm("str r1, [r0, #4] "); // iError=ETrue sl@0: asm("return_error: "); sl@0: asm("movs r0, #0 "); // set Z flag to indicate error sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C TRect TRegion::BoundingRect() const sl@0: /** sl@0: Gets the minimal rectangle that bounds the entire region. sl@0: sl@0: @return The region's minimal bounding rectangle. sl@0: */ sl@0: { sl@0: asm("ldr r2, [r1] "); // r2=iCount sl@0: asm("cmp r2, #0 "); // list empty? sl@0: asm("beq boundingrect0 "); // branch if empty sl@0: asm("ldr r3, [r1, #8] "); // if not empty, r3 points to first rectangle sl@0: asm("stmfd sp!, {r4-r8,lr} "); sl@0: asm("cmn r3, r3 "); sl@0: asm("ldrcc r3, [r1, #16] "); // if RRegion sl@0: asm("addcs r3, r1, #20 "); // RRegionBuf sl@0: asm("submi r3, r3, #8 "); // TRegionFix sl@0: asm("ldmia r3!, {r4-r7} "); // if not empty bounds = first rectangle sl@0: asm("b boundingrect2 "); // if not empty go and check rest of list sl@0: asm("boundingrect1: "); sl@0: asm("ldmia r3!, {r1,r8,r12,lr} "); // fetch next rectangle sl@0: asm("cmp r1, r4 "); // if next.iTl.iXbounds.iBr.iX sl@0: asm("movgt r6, r12 "); // bounds.iBr.iX=next.iBr.iX sl@0: asm("cmp lr, r7 "); // if next.iBr.iY>bounds.iBr.iY sl@0: asm("movgt r7, lr "); // bounds.iBr.iY=next.iBr.iY sl@0: asm("boundingrect2: "); sl@0: asm("subs r2, r2, #1 "); // decrement count sl@0: asm("bne boundingrect1 "); // repeat for all rectangles sl@0: asm("stmia r0, {r4-r7} "); // store result sl@0: __POPRET("r4-r8,"); sl@0: sl@0: asm("boundingrect0: "); sl@0: asm("mov r1, #0 "); // if list empty, bounds = 0,0,0,0 sl@0: asm("mov r3, #0 "); sl@0: asm("mov r12, #0 "); sl@0: asm("stmia r0, {r1,r2,r3,r12} "); // store result sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C TBool TRegion::IsContainedBy(const TRect & /*aRect*/) const sl@0: /** sl@0: Tests whether the region is fully enclosed within the specified rectangle. sl@0: sl@0: @param aRect The specified rectangle. sl@0: sl@0: @return True, if the region is fully enclosed within the rectangle (their sides sl@0: may touch); false, otherwise. sl@0: */ sl@0: { sl@0: asm("ldr r12, [r0, #8] "); // r12 points to first rectangle sl@0: asm("stmfd sp!, {r4-r7,lr} "); sl@0: asm("cmn r12, r12 "); sl@0: asm("ldrcc r12, [r0, #16] "); // if RRegion sl@0: asm("addcs r12, r0, #20 "); // RRegionBuf sl@0: asm("submi r12, r12, #8 "); // TRegionFix sl@0: sl@0: asm("ldr r0, [r0] "); // r0=iCount sl@0: asm("ldmia r1, {r4-r7} "); // aRect coordinates into r4-r7 sl@0: sl@0: asm("subs r0, r0, #1 "); // decrement it sl@0: asm("bmi iscontainedby2 "); // if iCount was zero, return TRUE sl@0: sl@0: asm("iscontainedby1: "); sl@0: asm("ldmia r12!, {r1,r2,r3,lr} "); // coordinates of next rectangle sl@0: asm("cmp r1, r4 "); // compare next.iTl.iX with aRect.iTl.iX sl@0: asm("cmpge r2, r5 "); // if >=, compare next.iTl.iY with aRect.iTl.iY sl@0: asm("cmpge r6, r3 "); // if >=, compare aRect.Br.iX with next.iBr.iX sl@0: asm("cmpge r7, lr "); // if >=, compare aRect.Br.iY with next.iBr.iY sl@0: asm("subges r0, r0, #1 "); // if >=, next is contained in aRect, so iterate sl@0: asm("bge iscontainedby1 "); // will drop through if r0<0 or if next exceeds aRect sl@0: asm("iscontainedby2: "); sl@0: asm("mov r0, r0, lsr #31 "); // return 1 if r0<0, 0 if r0>=0 sl@0: __POPRET("r4-r7,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TRegion::Copy(const TRegion & /*aRegion*/) sl@0: /** sl@0: Copies another region to this region. sl@0: sl@0: The state of the specified region's error flag is also copied. sl@0: sl@0: @param aRegion The region to be copied. sl@0: */ sl@0: { sl@0: asm("ldr r2, [r1, #4] "); // r2 = aRegion.iError sl@0: asm("cmp r2, #0 "); sl@0: asm("bne " CSM_ZN7TRegion10ForceErrorEv); // if (aRegion.iError) ForceError(); sl@0: asm("ldr r2, [r1] "); // r1 = aRegion.iCount sl@0: asm("cmp r2, #0 "); sl@0: asm("beq " CSM_ZN7TRegion5ClearEv); // region to copy is empty so simply clear our buffer sl@0: asm("stmfd sp!, {r0,r1,r4,r5,r6,lr} "); // preserve r0,r1,lr across function calls sl@0: asm("mov r4, r1 "); sl@0: asm("mov r5, r0 "); sl@0: asm("ldr r2, [r0, #4] "); // r2 = iError sl@0: asm("cmp r2, #0 "); sl@0: asm("blne " CSM_ZN7TRegion5ClearEv); // if (iError) Clear(); sl@0: asm("mov r0, r5 "); sl@0: asm("ldr r1, [r4] "); // r1 = aRegion.iCount, r0 = this sl@0: asm("bl " CSM_ZN7TRegion11SetListSizeEi); // SetListSize(aRegion.iCount); sl@0: asm("cmp r0, #0 "); sl@0: asm("beq copyregion_end "); sl@0: asm("ldr r3, [r4] "); // r3 = aRegion.iCount sl@0: asm("cmp r3, #0 "); sl@0: asm("str r3, [r5] "); // iCount=aRegion.iCount sl@0: asm("beq copyregion_end "); sl@0: asm("ldr r0, [r5, #8] "); // r0 points to first rectangle sl@0: asm("cmn r0, r0 "); sl@0: asm("ldrcc r0, [r5, #16] "); // if RRegion sl@0: asm("addcs r0, r5, #20 "); // RRegionBuf sl@0: asm("submi r0, r0, #8 "); // TRegionFix sl@0: asm("ldr r1, [r4, #8] "); // r1 points to first rectangle sl@0: asm("cmn r1, r1 "); sl@0: asm("ldrcc r1, [r4, #16] "); // if RRegion sl@0: asm("addcs r1, r4, #20 "); // RRegionBuf sl@0: asm("submi r1, r1, #8 "); // TRegionFix sl@0: asm("copyregion1: "); sl@0: asm("ldmia r1!, {r2,r4,r5,r12} "); // copy aRegion.iRectangleList to iRectangleList sl@0: asm("subs r3, r3, #1 "); sl@0: asm("stmia r0!, {r2,r4,r5,r12} "); sl@0: asm("bne copyregion1 "); sl@0: sl@0: asm("copyregion_end: "); sl@0: __POPRET("r0,r1,r4,r5,r6,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TRegion::Offset(const TPoint & /*anOffset*/) sl@0: /** sl@0: Moves the region by adding a TPoint offset to the co-ordinates of its corners. sl@0: sl@0: The size of the region is not changed. sl@0: sl@0: @param aOffset The offset by which the region is moved. The region is moved sl@0: horizontally by aOffset.iX pixels and vertically by aOffset.iY pixels. sl@0: */ sl@0: { sl@0: asm("ldmia r1, {r1,r2} "); // r1=anOffset.iX, r2=anOffset.iY sl@0: // fall through... sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TRegion::Offset(TInt /*xOffset*/,TInt /*yOffset*/) sl@0: /** sl@0: Moves the region by adding X and Y offsets to the co-ordinates of its corners. sl@0: sl@0: The size of the region is not changed. sl@0: sl@0: @param aXoffset The number of pixels by which to move the region horizontally. sl@0: If negative, the region moves leftwards. sl@0: @param aYoffset The number of pixels by which to move the region vertically. sl@0: If negative, the region moves upwards. sl@0: */ sl@0: { sl@0: asm("ldr r12, [r0] "); // r12=iCount sl@0: asm("cmp r12, #0 "); sl@0: __JUMP(eq,lr); sl@0: asm("ldr r3, [r0, #8] "); // r0 points to first rectangle sl@0: asm("cmn r3, r3 "); sl@0: asm("ldrcc r0, [r0, #16] "); // if RRegion sl@0: asm("addcs r0, r0, #20 "); // RRegionBuf sl@0: asm("submi r0, r0, #8 "); // TRegionFix sl@0: asm("stmfd sp!, {r4,r5,lr} "); sl@0: asm("offsetregion2: "); sl@0: asm("ldmia r0, {r3-r5,lr} "); // r3-r5,lr = next rectangle coordinates sl@0: asm("subs r12, r12, #1 "); sl@0: asm("add r3, r3, r1 "); // Tl.iX += anOffset.iX sl@0: asm("add r4, r4, r2 "); // Tl.iY += anOffset.iY sl@0: asm("add r5, r5, r1 "); // Br.iX += anOffset.iX sl@0: asm("add lr, lr, r2 "); // Br.iY += anOffset.iY sl@0: asm("stmia r0!, {r3-r5,lr} "); // store new coordinates sl@0: asm("bne offsetregion2 "); sl@0: __POPRET("r4,r5,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C TBool TRegion::Contains(const TPoint & /*aPoint*/) const sl@0: /** sl@0: Tests whether a point is located within the region. sl@0: sl@0: If the point is located on the top or left hand side of any rectangle in the sl@0: region, it is considered to be within that rectangle and within the region. sl@0: sl@0: If the point is located on the right hand side or bottom of a rectangle, it sl@0: is considered to be outside that rectangle, and may be outside the region. sl@0: sl@0: @param aPoint The specified point. sl@0: sl@0: @return True, if the point is within the region; false, otherwise. sl@0: */ sl@0: { sl@0: asm("ldr r12, [r0] "); // r12 = iCount sl@0: asm("stmfd sp!, {r4,r5,lr} "); sl@0: asm("cmp r12, #0 "); sl@0: asm("beq contains0 "); // if iCount=0, return FALSE sl@0: asm("ldr r3, [r0, #8] "); // r0 points to first rectangle sl@0: asm("cmn r3, r3 "); sl@0: asm("ldrcc r0, [r0, #16] "); // if RRegion sl@0: asm("addcs r0, r0, #20 "); // RRegionBuf sl@0: asm("submi r0, r0, #8 "); // TRegionFix sl@0: asm("ldmia r1, {r1, r2} "); // r1=aPoint.iX, r2=aPoint.iY sl@0: asm("contains1: "); sl@0: asm("ldmia r0!, {r3-r5,lr} "); // coordinates of next rectangle into r3-r5,lr sl@0: asm("cmp r3, r1 "); // compare next.iTl.iX with aPoint.iX sl@0: asm("cmple r4, r2 "); // if <=, compare next.iTl.iY with aPoint.iY sl@0: asm("bgt contains2 "); // if >, aPoint is not contained in rectangle, so iterate sl@0: asm("cmp r1, r5 "); // compare aPoint.iX with next.iBr.iX sl@0: asm("cmplt r2, lr "); // if <, compare aPoint.iY with next.iBr.iY sl@0: asm("contains2: "); sl@0: asm("subges r12, r12, #1 "); // if >=, aPoint is not contained in rect, so iterate sl@0: asm("bgt contains1 "); sl@0: asm("cmp r12, #0 "); sl@0: asm("movne r0, #1 "); // if r12 non-zero, return TRUE else FALSE sl@0: asm("contains0: "); sl@0: asm("moveq r0, #0 "); sl@0: __POPRET("r4,r5,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C TBool TRegion::Intersects(const TRect &/*aRect*/) const sl@0: /** sl@0: Tests whether where there is any intersection between this region and the specified rectangle. sl@0: sl@0: @param aRect The specified rectangle. sl@0: sl@0: @return True, if there is an intersection; false, otherwise. sl@0: */ sl@0: { sl@0: asm("ldr r12, [r0] "); // r12 = iCount sl@0: asm("stmfd sp!, {r4-r7,lr} "); sl@0: asm("cmp r12, #0 "); sl@0: asm("beq intersects0 "); // if iCount=0, return FALSE sl@0: asm("ldr lr, [r0, #8] "); // r0 points to first rectangle sl@0: asm("ldmia r1, {r1-r4} "); // (load aRect into r1 - r4) sl@0: asm("cmn lr, lr "); sl@0: asm("ldrcc r0, [r0, #16] "); // if RRegion sl@0: asm("addcs r0, r0, #20 "); // RRegionBuf sl@0: asm("submi r0, r0, #8 "); // TRegionFix sl@0: asm("cmp r1, r3 "); // check if aRect is empty sl@0: asm("cmplt r2, r4 "); sl@0: asm("bge intersects0 "); sl@0: sl@0: asm("intersects1: "); sl@0: asm("ldmia r0!, {r5-r7,lr} "); // coordinates of next rectangle into r5-r7,lr sl@0: asm("cmp r1, r7 "); // check if they intersect sl@0: asm("cmplt r2, lr "); sl@0: asm("cmplt r5, r3 "); sl@0: asm("cmplt r6, r4 "); sl@0: asm("subges r12, r12, #1 "); // if not then decrement and loop sl@0: asm("bgt intersects1 "); sl@0: sl@0: asm("intersects0: "); sl@0: asm("movge r0, #0 "); sl@0: asm("movlt r0, #1 "); sl@0: __POPRET("r4-r7,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ void TRegion::DeleteRect(TRect * /*aRect*/) sl@0: // sl@0: // Delete a specific rectangle in the list. sl@0: // sl@0: { sl@0: asm("ldr r12, [r0] "); // r12=iCount sl@0: asm("ldr r3, [r0, #8] "); // r0 points to first rectangle sl@0: asm("subs r12, r12, #1 "); // decrement it sl@0: asm("str r12, [r0] "); // iCount--; sl@0: asm("cmn r3, r3 "); sl@0: asm("ldrcc r0, [r0, #16] "); // if RRegion sl@0: asm("addcs r0, r0, #20 "); // RRegionBuf sl@0: asm("submi r0, r0, #8 "); // TRegionFix sl@0: asm("sub r2, r1, r0 "); // r2=offset of aRect from iRectangleList sl@0: asm("subs r12, r12, r2, lsr #4 "); // r12 now equals number of rectangles requiring moving sl@0: __JUMP(eq,lr); sl@0: asm("add r0, r1, #16 "); // r0 = aRect+1 sl@0: asm("stmfd sp!, {r4,lr} "); sl@0: asm("deleterect1: "); sl@0: asm("ldmia r0!, {r2-r4,lr} "); // move rectangles following aRect back by one place sl@0: asm("subs r12, r12, #1 "); sl@0: asm("stmia r1!, {r2-r4,lr} "); sl@0: asm("bne deleterect1 "); sl@0: __POPRET("r4,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TRegion::ClipRect(const TRect & /*aRect*/) sl@0: /** sl@0: Clips the region to the specified rectangle. sl@0: sl@0: The resulting region is the area of overlap between the region and the rectangle. sl@0: If there is no overlap, all rectangles within this region are deleted and sl@0: the resulting region is empty. sl@0: sl@0: @param aRect The rectangle to which this region is to be clipped. sl@0: */ sl@0: // Can not fail. sl@0: { sl@0: asm("ldr r12, [r0] "); // r12=iCount sl@0: asm("cmp r12, #0 "); sl@0: __JUMP(eq,lr); sl@0: asm("stmfd sp!, {r4-r10,lr} "); sl@0: asm("ldmia r1, {r2-r5} "); // get coordinates of aRect into r2-r5 sl@0: asm("ldr r1, [r0, #8] "); // r1 points to first rectangle sl@0: asm("cmn r1, r1 "); sl@0: asm("ldrcc r1, [r0, #16] "); // if RRegion sl@0: asm("addcs r1, r0, #20 "); // RRegionBuf sl@0: asm("submi r1, r1, #8 "); // TRegionFix sl@0: sl@0: asm("cliprect1: "); sl@0: asm("ldmia r1!, {r6-r9} "); // next rectangle coordinates into r6-r9 sl@0: asm("cmp r6, r2 "); // clip the rectangle to aRect sl@0: asm("movlt r6, r2 "); sl@0: asm("strlt r2, [r1, #-16] "); sl@0: asm("cmp r7, r3 "); sl@0: asm("movlt r7, r3 "); sl@0: asm("strlt r3, [r1, #-12] "); sl@0: asm("cmp r8, r4 "); sl@0: asm("movgt r8, r4 "); sl@0: asm("strgt r4, [r1, #-8] "); sl@0: asm("cmp r9, r5 "); sl@0: asm("movgt r9, r5 "); sl@0: asm("strgt r5, [r1, #-4] "); sl@0: asm("cmp r6, r8 "); // check if clipped rect is empty sl@0: asm("cmplt r7, r9 "); // empty if r6>=r8 or r7>=r9 sl@0: asm("bge cliprect_delete "); // if empty, branch to other loop to delete rect sl@0: asm("subs r12, r12, #1 "); // decrement loop counter sl@0: asm("bne cliprect1 "); // loop if any more rectangles to do sl@0: __POPRET("r4-r10,"); sl@0: sl@0: asm("cliprect_delete: "); // (enter loop here) sl@0: asm("ldr lr, [r0] "); // lr=iCount, updateed if we delete rects sl@0: asm("sub r10, r1, #16 "); // r1 -> next rect, r10 -> previous deleted rect sl@0: asm("subs r12, r12, #1 "); // decrement loop counter sl@0: asm("beq cliprect_move_end "); sl@0: asm("cliprect_move: "); sl@0: asm("ldmia r1!, {r6-r9} "); // next rectangle coordinates into r6-r9 sl@0: asm("cmp r6, r2 "); // clip the rectangle to aRect sl@0: asm("movlt r6, r2 "); sl@0: asm("cmp r7, r3 "); sl@0: asm("movlt r7, r3 "); sl@0: asm("cmp r8, r4 "); sl@0: asm("movgt r8, r4 "); sl@0: asm("cmp r9, r5 "); sl@0: asm("movgt r9, r5 "); sl@0: asm("cmp r6, r8 "); // check if clipped rect is empty sl@0: asm("cmplt r7, r9 "); // empty if r6>=r8 or r7>=r9 sl@0: asm("stmltia r10!, {r6-r9} "); // if non-empty then store the rect sl@0: asm("subge lr, lr, #1 "); // else decrement rect count sl@0: asm("subs r12, r12, #1 "); // decrement loop counter sl@0: asm("bne cliprect_move "); // loop if any more rectangles to do sl@0: asm("cliprect_move_end: "); sl@0: asm("sub lr, lr, #1 "); // decrement count for first deleted rect sl@0: asm("str lr, [r0] "); // store updated iCount sl@0: __POPRET("r4-r10,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TRegion::SubRect(const TRect& /*aRect*/,TRegion* /*aSubtractedRegion*/) sl@0: /** sl@0: Removes a rectangle from this region. sl@0: sl@0: If there is no intersection between the rectangle and this region, then this sl@0: region is unaffected. sl@0: sl@0: @param aRect The rectangular area to be removed from this region. sl@0: @param aSubtractedRegion A pointer to a region. If this is supplied, the sl@0: removed rectangle is added to it. By default this sl@0: pointer is NULL. sl@0: */ sl@0: { sl@0: asm("ldr r12, [r0] "); // r12=iCount=limit sl@0: asm("cmp r12, #0 "); sl@0: __JUMP(eq,lr); sl@0: asm("stmfd sp!, {r3-r11,lr} "); sl@0: asm("ldmia r1, {r4-r7} "); // r4-r7 = coordinates of aRect sl@0: asm("cmp r4, r6 "); // check if aRect is empty i.e. (r4>=r6 || r5>=r7) sl@0: asm("cmplt r5, r7 "); sl@0: asm("bge subrect_end "); // if aRect is empty nothing to do sl@0: sl@0: asm("mov r3, #0 "); // r3=index sl@0: asm("subrect1: "); sl@0: asm("ldr lr, [r0, #8] "); // lr points to first rectangle sl@0: asm("cmn lr, lr "); sl@0: asm("ldrcc lr, [r0, #16] "); // if RRegion sl@0: asm("addcs lr, r0, #20 "); // RRegionBuf sl@0: asm("submi lr, lr, #8 "); // TRegionFix sl@0: asm("add lr, lr, r3, lsl #4 "); // lr=iRectangleList+index sl@0: // asm("ldmia r1, {r4-r7} "); // r4-r7 = coordinates of aRect sl@0: asm("ldmia lr, {r8-r11} "); // r8-r11 = coordinates of next rectangle in region sl@0: asm("cmp r10, r4 "); // compare next.iBr.iX with aRect.iTl.iX sl@0: asm("cmpgt r11, r5 "); // if >, compare next.iBr.iY with aRect.iTl.iY sl@0: asm("cmpgt r6, r8 "); // if >, compare aRect.iBr.iX with next.iTl.iX sl@0: asm("cmpgt r7, r9 "); // if >, compare aRect.iBr.iY with next.iTl.iY sl@0: asm("addle r3, r3, #1 "); // if empty intersection, increment index sl@0: asm("ble subrect2 "); // if <=, next and aRect have empty intersection, so skip sl@0: asm("add r4, lr, #16 "); // r4 = source pointer for copy, lr = dest sl@0: asm("ldr r5, [r0] "); // r5 = iCount sl@0: asm("sub r5, r5, #1 "); // decrement iCount sl@0: asm("str r5, [r0] "); sl@0: asm("sub r12, r12, #1 "); // decrement limit sl@0: asm("subs r5, r5, r3 "); // loop count for copy = iCount-index sl@0: asm("beq subrect4 "); // if loop count zero, skip the copy sl@0: asm("stmfd sp!, {r8,r9} "); // preserve r8,r9 sl@0: asm("subrect3: "); sl@0: asm("ldmia r4!, {r6-r9} "); // remove the current rectangle sl@0: asm("stmia lr!, {r6-r9} "); sl@0: asm("subs r5, r5, #1 "); sl@0: asm("bne subrect3 "); sl@0: asm("ldmfd sp!, {r8-r9} "); // restore r8,r9 sl@0: asm("subrect4: "); sl@0: asm("ldmia r1, {r4-r7} "); // restore coordinates of aRect into r4-r7 sl@0: asm("cmp r7, r11 "); // compare aRect.iBr.iY with rect.iBr.iY sl@0: asm("movgt r7, r11 "); // r7=inter.iBr.iY sl@0: asm("bllt subrectapp1 "); // if <, append 1st subrectangle sl@0: asm("cmp r5, r9 "); // compare aRect.iTl.iY with rect.iTl.iY sl@0: asm("movlt r5, r9 "); // r5=inter.iTl.iY sl@0: asm("blgt subrectapp2 "); // if >, append 2nd subrectangle sl@0: asm("cmp r6, r10 "); // compare aRect.iBr.iX with rect.iBr.iX sl@0: asm("movgt r6, r10 "); // r6=inter.iBr.iX sl@0: asm("bllt subrectapp3 "); // if <, append 3rd subrectangle sl@0: asm("cmp r4, r8 "); // compare aRect.iTl.iX with rect.iTl.iX sl@0: asm("movlt r4, r8 "); // r4=inter.iTl.iX sl@0: asm("blgt subrectapp4 "); // if >, append 4th subrectangle sl@0: asm("ldr lr, [r0, #4] "); // lr=iError sl@0: asm("cmp lr, #0 "); // check for an error sl@0: asm("bne subrect_end "); sl@0: asm("cmp r2, #0 "); // check if aSubtractedRegion!=NULL sl@0: asm("blne subrectadd "); // if non-null, add inter to aSubtractedRegion sl@0: asm("subrect2: "); sl@0: asm("cmp r3, r12 "); // compare index to limit sl@0: asm("ldmltia r1, {r4-r7} "); // if indexAddRect(inter) sl@0: asm("subrectadd: "); sl@0: asm("stmfd sp!, {r0-r7,r12,lr} "); // preserve registers and put inter onto stack sl@0: asm("mov r0, r2 "); // this = aSubtractedRegion sl@0: asm("add r1, sp, #16 "); // inter is 16 bytes above sp sl@0: asm("bl " CSM_ZN7TRegion7AddRectERK5TRect); // call TRegion::AddRect sl@0: __POPRET("r0-r7,r12,"); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TRegion::Intersection(const TRegion& /*aRegion1*/,const TRegion& /*aRegion2*/) sl@0: /** sl@0: Replaces this region with the area of intersection between two specified regions. sl@0: sl@0: Notes: sl@0: sl@0: 1. If the error flag of either of the two specified regions is set, then this sl@0: region is cleared and its error flag is set. This frees up allocated memory. sl@0: sl@0: 2. If this region's error flag is already set, then the function has no effect. sl@0: sl@0: @param aRegion1 The first region. sl@0: @param aRegion2 The second region. sl@0: */ sl@0: { sl@0: // r0=this, r1=&aRegion1, r2=&aRegion2 sl@0: asm("ldr r3, [r1, #4] "); // r3=aRegion1.iError sl@0: asm("ldr r12, [r2, #4] "); // r12=aRegion2.iError sl@0: asm("orrs r3, r3, r12 "); sl@0: asm("bne " CSM_ZN7TRegion10ForceErrorEv); // if either set, ForceError() sl@0: asm("str r3, [r0] "); // iCount=0 sl@0: asm("ldr r3, [r1] "); // r3=aRegion1.iCount sl@0: asm("ldr r12, [r2] "); // r12=aRegion2.iCount sl@0: asm("cmp r3, #0 "); sl@0: asm("cmpne r12, #0 "); sl@0: __JUMP(eq,lr); sl@0: asm("stmfd sp!, {r3-r11,lr} "); sl@0: asm("ldr lr, [r1, #8] "); // r1 points to first rectangle of aRegion1 = pRect1 sl@0: asm("cmn lr, lr "); sl@0: asm("ldrcc r1, [r1, #16] "); // if RRegion sl@0: asm("addcs r1, r1, #20 "); // RRegionBuf sl@0: asm("submi r1, r1, #8 "); // TRegionFix sl@0: asm("intersection1: "); sl@0: asm("ldr lr, [r2, #8] "); // lr points to first rectangle of aRegion2 sl@0: asm("cmn lr, lr "); sl@0: asm("ldrcc lr, [r2, #16] "); // if RRegion sl@0: asm("addcs lr, r2, #20 "); // RRegionBuf sl@0: asm("submi lr, lr, #8 "); // TRegionFix sl@0: asm("ldr r12, [r2] "); // r12=aRegion2.iCount sl@0: asm("intersection2: "); sl@0: asm("ldmia r1, {r4-r7} "); // r4-r7 = *pRect1 sl@0: asm("ldmia lr!, {r8-r11} "); // r8-r11 = *pRect2++ sl@0: asm("cmp r6, r8 "); // compare pRect1->iBr.iX with pRect2->iTl.iX sl@0: asm("cmpgt r7, r9 "); // if >, compare pRect1->iBr.iY with pRect2->iTl.iY sl@0: asm("cmpgt r10, r4 "); // if >, compare pRect2->iBr.iX with pRect1->iTl.iX sl@0: asm("cmpgt r11, r5 "); // if >, compare pRect2->iBr.iY with pRect1->iTl.iY sl@0: asm("ble intersection3 "); // if <=, rectangles have empty intersection, so iterate sl@0: asm("cmp r4, r8 "); // compute intersection and place in r8-r11 sl@0: asm("movgt r8, r4 "); sl@0: asm("cmp r5, r9 "); sl@0: asm("movgt r9, r5 "); sl@0: asm("cmp r6, r10 "); sl@0: asm("movlt r10, r6 "); sl@0: asm("cmp r7, r11 "); sl@0: asm("movlt r11, r7 "); sl@0: asm("stmfd sp!, {r0-r3,r12,lr} "); // preserve registers across function call sl@0: asm("bl " CSM_Z16AllocAnotherRectP7TRegion); sl@0: asm("ldmfd sp!, {r0-r3} "); sl@0: asm("ldmeqfd sp!, {r12,lr} "); // exit if error sl@0: asm("beq intersection_end "); sl@0: sl@0: asm("ldr r12, [r0] "); // r12=iCount sl@0: asm("ldr lr, [r0, #8] "); // lr points to first rectangle sl@0: asm("cmn lr, lr "); sl@0: asm("ldrcc lr, [r0, #16] "); // if RRegion sl@0: asm("addcs lr, r0, #20 "); // RRegionBuf sl@0: asm("submi lr, lr, #8 "); // TRegionFix sl@0: asm("add lr, lr, r12, lsl #4 "); // lr=&(iRectangleList[iCount]) sl@0: asm("add r12, r12, #1 "); // increment iCount sl@0: asm("str r12, [r0] "); // sl@0: asm("stmia lr!, {r8-r11} "); // append intersection of rectangles sl@0: asm("ldmfd sp!, {r12,lr} "); // restore registers sl@0: asm("intersection3: "); sl@0: asm("subs r12, r12, #1 "); sl@0: asm("bne intersection2 "); // loop for all values of pRect2 sl@0: asm("add r1, r1, #16 "); // increment pRect1 sl@0: asm("subs r3, r3, #1 "); sl@0: asm("bne intersection1 "); // loop for all values of pRect1 sl@0: sl@0: asm("intersection_end: "); sl@0: __POPRET("r3-r11,"); sl@0: } sl@0: sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: #ifdef __COBJECT_MACHINE_CODED__ sl@0: __NAKED__ EXPORT_C CObject *CObjectIx::At(TInt /*aHandle*/,TInt /*aUniqueID*/) sl@0: /** sl@0: Gets a pointer to the reference counting object with the specified handle sl@0: number and matching unique ID. sl@0: sl@0: @param aHandle The handle number of the reference counting object. sl@0: @param aUniqueID The unique ID. sl@0: sl@0: @return A pointer to the reference counting object. If there is no matching sl@0: object, then this is NULL. sl@0: */ sl@0: { sl@0: // r0=this, r1=aHandle, r2=aUniqueID sl@0: asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iHighWaterMark)); // r3=iHighWaterMark sl@0: asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iObjects)); // r0=iObjects sl@0: asm("mov r12, r1, lsl #17 "); // r12=r1<<17 = index(aHandle)<<17 sl@0: asm("cmp r3, r12, lsr #17 "); // compare iHighWaterMark with index(aHandle) sl@0: asm("movle r0, #0 "); // if hwm<=index, return NULL sl@0: __JUMP(le,lr); sl@0: asm("add r0, r0, r12, lsr #14 "); // r0=iObjects+index(Handle)=pS sl@0: asm("ldr r3, [r0] "); // r3=pS->uniqueID:pS->instance sl@0: asm("mov r1, r1, lsl #2 "); // r1=instance(Handle)<<18 sl@0: asm("mov r1, r1, lsr #18 "); // r1=instance(Handle) sl@0: asm("orr r1, r1, r2, lsl #16 "); // r1=aUniqueID:instance(Handle) sl@0: asm("cmp r1, r3 "); // check uniqueID and instance sl@0: asm("movne r0, #0 "); // if wrong, return 0 sl@0: asm("ldreq r0, [r0, #4] "); // else return pointer to CObject sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C CObject *CObjectIx::At(TInt aHandle) sl@0: /** sl@0: Gets a pointer to the reference counting object with the specified sl@0: handle number. sl@0: sl@0: @param aHandle The handle number of the reference counting object. sl@0: sl@0: @return A pointer to the reference counting object. If there is no matching sl@0: object, then this is NULL. sl@0: */ sl@0: { sl@0: // r0=this, r1=aHandle sl@0: asm("ldr r3, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iHighWaterMark)); // r3=iHighWaterMark sl@0: asm("ldr r0, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iObjects)); // r0=iObjects sl@0: asm("mov r12, r1, lsl #17 "); // r12=r1<<17 = index(aHandle)<<17 sl@0: asm("cmp r3, r12, lsr #17 "); // compare iHighWaterMark with index(aHandle) sl@0: asm("movle r0, #0 "); // if hwm<=index, return NULL sl@0: __JUMP(le,lr); sl@0: asm("add r0, r0, r12, lsr #14 "); // r0=iObjects+index(Handle)=pS sl@0: asm("ldr r3, [r0] "); // r3=pS->uniqueID:pS->instance sl@0: asm("ldr r2, __instanceMask "); sl@0: asm("and r1, r1, r2 "); // r1=instance(Handle)<<16 sl@0: asm("cmp r1, r3, lsl #16 "); // check instance sl@0: asm("movne r0, #0 "); // if wrong, return 0 sl@0: asm("ldreq r0, [r0, #4] "); // else return pointer to CObject sl@0: __JUMP(,lr); sl@0: asm("__instanceMask: "); sl@0: asm(".word 0x3FFF0000 "); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: GLREF_C void PanicCObjectIxIndexOutOfRange(void); sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C CObject* CObjectIx::operator[](TInt /*anIndex*/) sl@0: /** sl@0: Gets a pointer to a reference counting object located at the specified offset sl@0: within the object index. sl@0: sl@0: @param anIndex The offset of the reference counting object within the object sl@0: index. Offset is relative to zero. sl@0: sl@0: @return A pointer to the reference counting object. sl@0: sl@0: @panic E32USER-CBase 21 if the value of anIndex is negative or is greater than sl@0: or equal to the total number of objects held by sl@0: the index. sl@0: */ sl@0: { sl@0: // r0=this, r1=anIndex sl@0: asm("cmp r1, #0 "); // check anIndex>=0 sl@0: asm("ldrge r3, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iHighWaterMark)); // if so, r3=iHighWaterMark sl@0: asm("cmpge r3, r1 "); // and compare iHighWaterMark to anIndex sl@0: asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectIx,iObjects)); // if OK, r0=iObjects sl@0: asm("addgt r0, r0, r1, lsl #3 "); // r0=iObjects+anIndex sl@0: asm("ldrgt r0, [r0, #4] "); // r0=pointer to CObject sl@0: #ifdef __CPU_ARMV6 sl@0: asm("ble 1f "); sl@0: __JUMP(,lr); sl@0: #else sl@0: __JUMP(gt,lr); sl@0: #endif sl@0: asm("1: "); sl@0: asm("b " CSM_Z29PanicCObjectIxIndexOutOfRangev); // if anIndex<0 or iCount<=anIndex, panic sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: GLREF_C void PanicCObjectConIndexOutOfRange(void); sl@0: GLREF_C void PanicCObjectConFindBadHandle(void); sl@0: GLREF_C void PanicCObjectConFindIndexOutOfRange(void); sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C CObject *CObjectCon::operator[](TInt /*anIndex*/) sl@0: /** sl@0: Gets a pointer to the reference counting object located at the specified offset sl@0: within the object container. sl@0: sl@0: @param anIndex The offset of the reference counting object within the object sl@0: container. Offset is relative to zero. sl@0: sl@0: @return A pointer to the owning reference counting object. sl@0: sl@0: @panic E32USER-CBase 21 if anIndex is negative or is greater than or equal to sl@0: the total number of objects held by the container. sl@0: */ sl@0: { sl@0: // r0=this, r1=anIndex sl@0: asm("cmp r1, #0 "); sl@0: asm("ldrge r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iCount)); sl@0: asm("cmpge r2, r1 "); sl@0: asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iObjects)); sl@0: asm("ldrgt r0, [r0, r1, lsl #2] "); sl@0: #ifdef __CPU_ARMV6 sl@0: asm("ble 1f "); sl@0: __JUMP(,lr); sl@0: #else sl@0: __JUMP(gt,lr); sl@0: #endif sl@0: asm("1: "); sl@0: asm("b " CSM_Z30PanicCObjectConIndexOutOfRangev); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C CObject *CObjectCon::At(TInt /*aFindHandle*/) const sl@0: /** sl@0: Gets a pointer to the reference counting object with the specified find-handle sl@0: number. sl@0: sl@0: A find-handle number is an integer which uniquely identifies a reference sl@0: counting object with respect to its object container. sl@0: sl@0: @param aFindHandle The find-handle number of the reference counting object. sl@0: The unique Id part of this number must be the same as the sl@0: unique Id of this container. sl@0: The index part of the find-handle number must be sl@0: a valid index. sl@0: sl@0: @return A pointer to the reference counting object. sl@0: sl@0: @panic E32User-CBase 38 if the unique Id part of aFindHandle is not the same as sl@0: the unique Id of this container. sl@0: @panic E32User-CBase 39 if the index part of aFindHandle is negative or greater sl@0: than or equal to the total number of reference counting sl@0: objects held by this object container. sl@0: */ sl@0: { sl@0: // r0=this, r1=aFindHandle sl@0: asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iUniqueID)); sl@0: asm("cmp r2, r1, lsr #16 "); sl@0: asm("ldreq r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iCount)); sl@0: asm("bne " CSM_Z28PanicCObjectConFindBadHandlev); sl@0: asm("mov r1, r1, lsl #17 "); sl@0: asm("cmp r2, r1, lsr #17 "); sl@0: asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iObjects)); sl@0: asm("ble " CSM_Z34PanicCObjectConFindIndexOutOfRangev); sl@0: asm("ldr r0, [r0, r1, lsr #15] "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __NAKED__ EXPORT_C CObject *CObjectCon::AtL(TInt /*aFindHandle*/) const sl@0: /** sl@0: Gets a pointer to the reference counting object with the specified find-handle sl@0: number, and leaves on error. sl@0: sl@0: A find-handle number is an integer which uniquely identifies a reference sl@0: counting object with respect to its object container. sl@0: sl@0: @param aFindHandle The find-handle number of the reference counting object. sl@0: The unique Id part of this number must be the same as sl@0: the unique Id of this container. sl@0: The index part of the find-handle number must be sl@0: a valid index. sl@0: sl@0: @return A pointer to the reference counting object. sl@0: sl@0: @leave KErrBadHandle if the unique Id part of aFindHandle is not the same as sl@0: the unique Id of this container. sl@0: @leave KErrArgument if the index part of aFindHandle is negative or greater sl@0: than or equal to the total number of reference counting sl@0: objects held by this object container. sl@0: */ sl@0: { sl@0: // r0=this, r1=aFindHandle sl@0: asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iUniqueID)); sl@0: asm("cmp r2, r1, lsr #16 "); sl@0: asm("ldreq r2, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iCount)); sl@0: asm("bne 1f "); sl@0: asm("mov r1, r1, lsl #17 "); sl@0: asm("cmp r2, r1, lsr #17 "); sl@0: asm("ldrgt r0, [r0, #%a0]" : : "i" _FOFF(CObjectCon,iObjects)); sl@0: asm("ble 2f "); sl@0: asm("ldr r0, [r0, r1, lsr #15] "); sl@0: __JUMP(,lr); sl@0: // User::Leave tail called, so no annotations required since sl@0: // current frame is reused by User::Leave sl@0: asm("1: "); sl@0: asm("mvn r0, #7 "); // KErrBadHandle sl@0: asm("b " CSM_ZN4User5LeaveEi); sl@0: asm("2: "); sl@0: asm("mvn r0, #5 "); // KErrArgument sl@0: asm("b " CSM_ZN4User5LeaveEi); sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __CACTIVESCHEDULER_MACHINE_CODED__ sl@0: extern "C" void PanicStrayEvent(); sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: The inner active scheduler loop. This repeatedly waits for a signal and then sl@0: dispatches the highest priority ready active object. The loop terminates either sl@0: if one of the RunL()s stops the current active scheduler level or leaves. sl@0: sl@0: Stop when aLoop becomes 'Inactive' sl@0: */ sl@0: __NAKED__ void CActiveScheduler::DoRunL(TLoopOwner* const volatile& aLoop, CActive* volatile & aCurrentObj, TCleanupBundle* aCleanupBundlePtr) sl@0: { sl@0: asm("stmfd sp!, {r4-r8,lr} "); sl@0: __EH_FRAME_PUSH2(r4-r8,lr) sl@0: sl@0: #ifdef _DEBUG sl@0: // need to copy aCleanupBundlePtr to somewhere else before it's clobbered by the next line. sl@0: asm("mov r8, r3 "); // r8 = &aCleanupBundlePtr sl@0: #endif sl@0: sl@0: asm("ldr r3, [r0, #%a0]" : : "i" (_CBASE_VPTR_OFFSET_)); // r3 = vptr sl@0: asm("add r4, r0, #%a0" : : "i" _FOFF(CActiveScheduler,iActiveQ)); // r4 = &iActiveQ sl@0: asm("mov r5, r1 "); // r5 = &aLoop sl@0: asm("mov r7, r2 "); // r7 = &aCurrentObj sl@0: asm("ldr r6, [r3, #%a0]" : : "i" (_CACTIVESCHEDULER_WAIT_OFFSET_)); // r6 = &WaitForAnyRequest() sl@0: sl@0: asm("active_scheduler_loop: "); sl@0: asm("ldr r1, [r5] "); // r1 = aLoop sl@0: asm("adr lr, 1f "); // return address sl@0: asm("sub r0, r4, #%a0 " : : "i" _FOFF(CActiveScheduler,iActiveQ)); // this sl@0: asm("cmp r1, #0 "); sl@0: __JUMP(ne, r6); // call WaitForAnyRequest() if still active sl@0: __POPRET("r4-r8,"); // else return sl@0: sl@0: // get here when WaitForAnyRequest() returns sl@0: asm("1: "); sl@0: asm("ldr r14, [r4, #0] "); // r14->first active object sl@0: sl@0: asm("2: "); sl@0: asm("cmp r14, r4 "); // end of queue? sl@0: asm("sub r0, r14, #%a0" : : "i" _FOFF(CActive,iLink)); // r0->CActive sl@0: asm("ldmneda r14, {r2, r12, r14} "); // r2=iStatus, r12=iStatus.iFlags (old iActive), r14 = next object sl@0: asm("beq PanicStrayEvent "); // if end of queue, panic sl@0: #ifdef _DEBUG sl@0: asm("ands r3, r12, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending))); // only active bit and request-pending bit sl@0: asm("cmpne r3, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending))); // active bit == request pending bit sl@0: asm("bne PanicStrayEvent "); // if active bit != request pending bit, panic sl@0: #endif sl@0: asm("cmp r2, #%a0" : : "i" ((TInt)KRequestPending)); // test if iStatus!=KRequestPending sl@0: asm("andnes r3, r12, #%a0" : : "i" ((TInt)TRequestStatus::EActive)); // if so, test iActive sl@0: asm("beq 2b "); // if not active or still pending, do next CActive sl@0: sl@0: // have an active object to run sl@0: #ifdef __SMP__ sl@0: __DATA_MEMORY_BARRIER_Z__(r3); // acquire semantics sl@0: #endif sl@0: asm("ldr r3, [r0, #%a0]" : : "i" (_CBASE_VPTR_OFFSET_)); // r3=CActive->vptr sl@0: asm("bic r12, r12, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending))); sl@0: asm("ldr r3, [r3, #%a0]" : : "i" (_CACTIVE_RUNL_OFFSET_)); // r3 = &CActive::RunL() sl@0: asm("str r12, [r0, #%a0]" : : "i" (_FOFF(CActive,iStatus)+_FOFF(TRequestStatus,iFlags))); // iActive=EFalse sl@0: asm("str r0, [r7] "); // save active object in aCurrentObj in case RunL leaves sl@0: #ifdef _DEBUG sl@0: __JUMPL(3); // call RunL() (and continue) sl@0: #else sl@0: asm("adr lr, active_scheduler_loop "); // set lr (return address) to label, active_scheduler_loop sl@0: __JUMP(,r3); // call RunL() (and loop) sl@0: #endif sl@0: sl@0: sl@0: #ifdef _DEBUG sl@0: //check whether there's a cleanup stack installed: sl@0: sl@0: asm("cmp r8, #0"); // check CleanupBundle* == NULL sl@0: asm("beq active_scheduler_loop "); // If r8 == NULL, branch to label, active_scheduler_loop sl@0: asm("ldr r0, [r8, #%a0]" : : "i" _FOFF(TCleanupBundle,iCleanupPtr)); // r0 = CCleanup* (load the CCleanup*) sl@0: sl@0: //there is a cleanupstack installed: sl@0: asm("add r1, r8, #%a0" : : "i" _FOFF(TCleanupBundle,iDummyInt)); // r1 = iDummyInt* (load the TInt*) sl@0: asm("adr lr, active_scheduler_loop "); // set lr (return address) to label, active_scheduler_loop sl@0: asm("b " CSM_ZN8CCleanup5CheckEPv); // call CCleanup::Check(iDummyInt*) sl@0: #endif sl@0: sl@0: } sl@0: #endif sl@0: sl@0: sl@0: #ifdef __CSERVER_MACHINE_CODED__ sl@0: __NAKED__ EXPORT_C void CServer2::RunL() sl@0: { sl@0: asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(CServer2,iMessage.iFunction)); // r2=Message().Function() sl@0: asm("stmfd sp!, {r4, lr}"); // save regs sl@0: __EH_FRAME_PUSH2(r4,lr) sl@0: asm("cmp r2, #0"); // check for Connect/Disconnect message sl@0: asm("bmi server2_con_dis"); sl@0: sl@0: // Service the message sl@0: asm("mov r4, r0 "); // r4=this sl@0: asm("ldr r0, [r4, #%a0]" : : "i" _FOFF(CServer2,iMessage.iSessionPtr)); // r0=session sl@0: asm("add r1, r4, #%a0" : : "i" (_FOFF(CServer2,iMessage))); // r1=&iServer.Message() sl@0: asm("cmp r0, #0"); // Check for NULL session sl@0: asm("ldrne r12, [r0, #%a0]" : : "i" (_CBASE_VPTR_OFFSET_)); // r12=CSession2::vptr sl@0: #ifdef __SUPPORT_THUMB_INTERWORKING sl@0: asm("ldrne r3, [r12, #%a0]" : : "i" (_CSESSION2_SERVICEL_OFFSET_)); // call CSession2::ServiceL(iMessage) sl@0: asm("adr lr, server2_run_postamble "); sl@0: asm("bxne r3 "); sl@0: #else sl@0: asm("adr lr, server2_run_postamble "); sl@0: asm("ldrne pc, [r12, #%a0]" : : "i" (_CSESSION2_SERVICEL_OFFSET_)); // call CSession2::ServiceL(iMessage) sl@0: #endif sl@0: asm("mov r0, r1"); sl@0: asm("b " CSM_ZN8CServer212NotConnectedERK9RMessage2); // NULL session ptr means not connected sl@0: sl@0: // Do this after processing any message sl@0: asm("server2_run_postamble: "); sl@0: asm("ldr r2, [r4, #%a0]" : : "i" (_FOFF(CServer2,iStatus)+_FOFF(TRequestStatus,iFlags))); // r2=iStatus.iFlags (old iActive) sl@0: asm("mov r0, #0x80000001 "); // r0=KRequestPending sl@0: asm("ands r1, r2, #%a0" : : "i" ((TInt)TRequestStatus::EActive)); sl@0: asm("bne server2_run_end "); // if already active, finished sl@0: asm("orr r2, r2, #%a0" : : "i" ((TInt)(TRequestStatus::EActive|TRequestStatus::ERequestPending))); sl@0: asm("add r1, r4, #%a0" : : "i" _FOFF(CActive,iStatus)); // r1->iStatus sl@0: asm("stmia r1, {r0,r2} "); // set iStatus=KRequestPending, set active bit, set request pending bit sl@0: asm("add r2, r4, #%a0" : : "i" _FOFF(CServer2,iMessage)); // r2->iServer.Message() sl@0: asm("ldr r0, [r4, #%a0]" : : "i" _FOFF(CServer2,iServer)); // r0=iServer.iHandle sl@0: asm("bl " CSM_ZN4Exec13ServerReceiveEiR14TRequestStatusPv);// call Exec::ServerReceive sl@0: asm("server2_run_end: "); sl@0: __POPRET("r4,"); sl@0: sl@0: // Deal with Connect and Disconnect messages sl@0: asm("server2_con_dis:"); sl@0: asm("mov r4, r0 "); // r4=this sl@0: asm("add r1, r0, #%a0" : : "i" _FOFF(CServer2,iMessage)); // r1=&iServer.Message() sl@0: asm("adr lr, server2_run_postamble "); // return address for after any processing sl@0: asm("cmp r2, #%a0" : : "i" (RMessage2::EConnect)); sl@0: asm("beq " CSM_ZN8CServer27ConnectERK9RMessage2); // Do Connect() sl@0: asm("cmp r2, #%a0" : : "i" (RMessage2::EDisConnect)); sl@0: asm("beq " CSM_ZN8CServer210DisconnectERK9RMessage2); // Do Disconnect() sl@0: asm("mov r0, r1"); sl@0: asm("b " CSM_ZN8CServer210BadMessageERK9RMessage2); // Bad message sl@0: } sl@0: #endif sl@0: sl@0: EXPORT_C __NAKED__ void RFastLock::Wait() sl@0: { sl@0: asm("1: "); sl@0: asm("add r0, r0, #4 "); // point to iCount sl@0: sl@0: #ifdef __CPU_ARM_HAS_LDREX_STREX sl@0: asm("2: "); sl@0: LDREX( 2, 0); // read sl@0: asm("subs r1, r2, #1 "); // decrement sl@0: STREX( 3, 1, 0); // write sl@0: asm("teq r3, #0 "); // success? sl@0: asm("bne 2b "); // no! sl@0: asm("sub r0, r0, #4 "); // r0 = this sl@0: asm("bcs " CSM_ZN10RSemaphore4WaitEv); // if no borrow from decrement wait on semaphore sl@0: #ifdef __SMP__ sl@0: __DATA_MEMORY_BARRIER__(r3); // no need to wait, but still need acquire barrier sl@0: #endif sl@0: __JUMP(, lr ); sl@0: #else sl@0: asm("mov r1, #1 "); // 'looking' value sl@0: asm("swp r1, r1, [r0] "); // write looking value, read original sl@0: asm("subs r1, r1, #1 "); // decrement count sl@0: asm("strlt r1, [r0] "); // if it becomes negative, no-one was looking sl@0: __JUMP(cc, lr); // if borrow, was originally zero so we are finished sl@0: asm("sub r0, r0, #4 "); // r0=this sl@0: asm("blt " CSM_ZN10RSemaphore4WaitEv); // lock held so wait on semaphore sl@0: asm("stmfd sp!, {r0,lr} "); // otherwise save registers sl@0: asm("mov r0, #1000 "); // someone was looking, so wait 1ms and try again sl@0: asm("bl " CSM_ZN4User12AfterHighResE27TTimeIntervalMicroSeconds32); sl@0: asm("ldmfd sp!, {r0,lr} "); sl@0: asm("b 1b "); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C __NAKED__ void RFastLock::Signal() sl@0: { sl@0: asm("1: "); sl@0: asm("add r0, r0, #4 "); // point to iCount sl@0: sl@0: #ifdef __CPU_ARM_HAS_LDREX_STREX sl@0: #ifdef __SMP__ sl@0: __DATA_MEMORY_BARRIER_Z__(r3); // need release barrier sl@0: #endif sl@0: asm("2: "); sl@0: LDREX( 2, 0); // read sl@0: asm("adds r1, r2, #1 "); // increment sl@0: STREX( 3, 1, 0); // write sl@0: asm("teq r3, #0 "); // success? sl@0: asm("bne 2b "); // no! sl@0: asm("sub r0, r0, #4 "); // r0 = this sl@0: asm("bcc " CSM_ZN10RSemaphore6SignalEv); // if no carry from increment, signal semaphore sl@0: __JUMP(, lr ); sl@0: #else sl@0: asm("mov r1, #1 "); // 'looking' value sl@0: asm("swp r1, r1, [r0] "); // write looking value, read original sl@0: asm("adds r1, r1, #1 "); // increment count sl@0: asm("strle r1, [r0] "); // if still <=0, no-one was looking sl@0: __JUMP(eq, lr); // if it's now zero, no-one is waiting so we are finished sl@0: asm("sub r0, r0, #4 "); // r0=this sl@0: asm("blt " CSM_ZN10RSemaphore6SignalEv); // someone is waiting so signal semaphore sl@0: asm("stmfd sp!, {r0,lr} "); // otherwise save registers sl@0: asm("mov r0, #1000 "); // someone was looking, so wait 1ms and try again sl@0: asm("bl " CSM_ZN4User12AfterHighResE27TTimeIntervalMicroSeconds32); sl@0: asm("ldmfd sp!, {r0,lr} "); sl@0: asm("b 1b "); sl@0: #endif sl@0: } sl@0: sl@0: sl@0: // Entry point stub to allow EKA1 binaries to be executed under EKA2 sl@0: // Only called when process is first loaded sl@0: sl@0: extern "C" TLinAddr GetEka1ExeEntryPoint(); sl@0: sl@0: __NAKED__ TInt E32Loader::V7ExeEntryStub() sl@0: { sl@0: // Process entry point sl@0: // R4 = entry reason sl@0: // SP points to information block sl@0: asm("cmp r4, #%a0" : : "i" ((TInt)KModuleEntryReasonProcessInit) ); sl@0: asm("bne " CSM_ZN4User9InvariantEv ); // invalid entry reason sl@0: asm("bl GetEka1ExeEntryPoint "); // load the entry stub and return its address sl@0: __JUMP(,r0); // jump to the entry stub with R4, SP unchanged sl@0: } sl@0: sl@0: __NAKED__ TInt E32Loader::V7DllEntryStub(TInt) sl@0: { sl@0: sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: sl@0: // Hash an 8 bit string at aPtr, length aLen bytes. sl@0: __NAKED__ TUint32 DefaultStringHash(const TUint8* /*aPtr*/, TInt /*aLen*/) sl@0: { sl@0: asm("ldr r3, one_over_phi "); sl@0: asm("subs r1, r1, #4 "); sl@0: asm("mov r2, r0 "); sl@0: asm("mov r0, #0 "); sl@0: asm("blo 1f "); sl@0: asm("ands r12, r2, #3 "); sl@0: asm("bne hash_unal "); sl@0: asm("2: "); sl@0: asm("ldr r12, [r2], #4 "); sl@0: asm("subs r1, r1, #4 "); sl@0: asm("eor r0, r0, r12 "); sl@0: asm("umull r0, r12, r3, r0 "); sl@0: asm("bcs 2b "); sl@0: asm("1: "); sl@0: asm("adds r1, r1, #4 "); sl@0: __JUMP(eq,lr); sl@0: asm("4: "); sl@0: asm("ldrb r12, [r2], #1 "); sl@0: asm("cmp r1, #2 "); sl@0: asm("eor r0, r0, r12 "); sl@0: asm("ldrcsb r12, [r2], #1 "); sl@0: asm("eorcs r0, r0, r12, lsl #8 "); sl@0: asm("ldrhib r12, [r2], #1 "); sl@0: asm("eorhi r0, r0, r12, lsl #16 "); sl@0: asm("umull r0, r12, r3, r0 "); sl@0: __JUMP(,lr); sl@0: sl@0: asm("hash_unal: "); sl@0: asm("bic r2, r2, #3 "); sl@0: asm("stmfd sp!, {r4,r5,lr} "); sl@0: asm("mov r12, r12, lsl #3 "); sl@0: asm("rsb r14, r12, #32 "); sl@0: asm("ldr r4, [r2], #4 "); sl@0: asm("3: "); sl@0: asm("eor r0, r0, r4, lsr r12 "); sl@0: asm("ldr r4, [r2], #4 "); sl@0: asm("subs r1, r1, #4 "); sl@0: asm("eor r0, r0, r4, lsl r14 "); sl@0: asm("umull r0, r5, r3, r0 "); sl@0: asm("bcs 3b "); sl@0: asm("adds r1, r1, #4 "); sl@0: asm("ldmfd sp!, {r4,r5,lr} "); sl@0: asm("subne r2, r2, #4 "); sl@0: asm("addne r2, r2, r12, lsr #3 "); sl@0: asm("bne 4b "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: // Hash a 16 bit string at aPtr, length aLen bytes. sl@0: __NAKED__ TUint32 DefaultWStringHash(const TUint16* /*aPtr*/, TInt /*aLen*/) sl@0: { sl@0: asm("str lr, [sp, #-4]! "); sl@0: asm("ldr r3, one_over_phi "); sl@0: asm("subs r1, r1, #8 "); sl@0: asm("mov r2, r0 "); sl@0: asm("mov r0, #0 "); sl@0: asm("blo 1f "); sl@0: asm("ands r12, r2, #3 "); sl@0: asm("bne whash_unal "); sl@0: asm("2: "); sl@0: asm("ldmia r2!, {r12,r14} "); sl@0: asm("subs r1, r1, #8 "); sl@0: asm("eor r0, r0, r12 "); sl@0: asm("eor r0, r0, r14, ror #24 "); sl@0: asm("umull r0, r12, r3, r0 "); sl@0: asm("bcs 2b "); sl@0: asm("1: "); sl@0: asm("adds r1, r1, #8 "); sl@0: asm("beq 8f "); sl@0: asm("4: "); sl@0: asm("ldrh r12, [r2], #2 "); sl@0: asm("cmp r1, #4 "); sl@0: asm("eor r0, r0, r12 "); sl@0: asm("ldrcsh r12, [r2], #2 "); sl@0: asm("eorcs r0, r0, r12, lsl #16 "); sl@0: asm("ldrhih r12, [r2], #2 "); sl@0: asm("eorhi r0, r0, r12, ror #24 "); sl@0: asm("umull r0, r12, r3, r0 "); sl@0: asm("8: "); sl@0: __POPRET(""); sl@0: sl@0: asm("whash_unal: "); sl@0: asm("add r2, r2, #2 "); // r2 must be 2 mod 4 sl@0: asm("ldr r14, [r2, #-4] "); sl@0: asm("3: "); sl@0: asm("eor r0, r0, r14, lsr #16 "); // char 0 goes into bytes 0,1 sl@0: asm("ldmia r2!, {r12,r14} "); sl@0: asm("subs r1, r1, #8 "); sl@0: asm("eor r0, r0, r12, lsl #16 "); // char 1 goes into bytes 2,3 sl@0: asm("mov r12, r12, lsr #16 "); sl@0: asm("orr r12, r12, r14, lsl #16 "); // r12 = char3:char2 sl@0: asm("eor r0, r0, r12, ror #24 "); // char 2 into bytes 1,2 ; char 3 into bytes 3,0 sl@0: asm("umull r0, r12, r3, r0 "); sl@0: asm("bcs 3b "); sl@0: asm("adds r1, r1, #8 "); sl@0: asm("subne r2, r2, #2 "); sl@0: asm("bne 4b "); sl@0: __POPRET(""); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Calculate a 32 bit hash from a 32 bit integer. sl@0: sl@0: @param aInt The integer to be hashed. sl@0: @return The calculated 32 bit hash value. sl@0: */ sl@0: EXPORT_C __NAKED__ TUint32 DefaultHash::Integer(const TInt& /*aInt*/) sl@0: { sl@0: asm("ldr r0, [r0] "); sl@0: asm("ldr r1, one_over_phi "); sl@0: asm("umull r0, r2, r1, r0 "); sl@0: __JUMP(,lr); sl@0: asm("one_over_phi: "); sl@0: asm(".word 0x9e3779b9 "); sl@0: } sl@0: sl@0: sl@0: #ifdef __USERSIDE_THREAD_DATA__ sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: Get a pointer to the thread local user data stored in the thread ID register. sl@0: */ sl@0: __NAKED__ TLocalThreadData* LocalThreadData() sl@0: { sl@0: GET_RWRW_TID(,r0); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: #endif