sl@0: // Copyright (c) 1997-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\common\arm\cdes16.cia sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "../common.h" sl@0: sl@0: #if defined(__DES16_MACHINE_CODED__) || defined(__EABI__) sl@0: sl@0: GLREF_C void Des16PanicBadDesType(); sl@0: GLREF_C void Des16PanicPosOutOfRange(); sl@0: sl@0: #endif sl@0: sl@0: #ifdef __DES16_MACHINE_CODED__ sl@0: sl@0: GLREF_C void Des16PanicLengthNegative(); sl@0: GLREF_C void Des16PanicMaxLengthNegative(); sl@0: GLREF_C void Des16PanicLengthOutOfRange(); sl@0: GLREF_C void Des16PanicDesOverflow(); sl@0: GLREF_C void Des16PanicDesIndexOutOfRange(); sl@0: sl@0: __NAKED__ EXPORT_C const TUint16 *TDesC16::Ptr() const sl@0: // sl@0: // Return a pointer to the buffer. sl@0: // sl@0: { sl@0: asm("ldr r1, [r0], #4 "); sl@0: asm("cmp r1, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r1, r1, r1, lsr #1 "); sl@0: asm("msr cpsr_flg, r1 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: #ifndef __EABI_CTORS__ sl@0: __NAKED__ EXPORT_C TPtrC16::TPtrC16() sl@0: // sl@0: // Default constructor sl@0: // sl@0: { sl@0: asm("mov r1, #0x10000000 "); // type=EPtrC, length=0 sl@0: asm("mov r2, #0 "); // ptr=NULL sl@0: asm("stmia r0, {r1,r2} "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16::TPtrC16(const TDesC16& /*aDes*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("ldr r2, [r1], #4 "); // r2 = type/length sl@0: asm("bic r3, r2, #0xF0000000"); // r3 = length sl@0: asm("orr r3, r3, #0x10000000"); // r3 = EPtrC + length sl@0: asm("cmp r2, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r2, r2, r2, lsr #1 "); sl@0: asm("msr cpsr_flg, r2 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr() sl@0: asm("str r3, [r0] "); sl@0: asm("str r1, [r0, #4] "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: __NAKED__ EXPORT_C TPtrC16::TPtrC16(const TUint16* /*aString*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("mov r2, r1 "); // save aString address sl@0: asm("1: "); sl@0: asm("ldrh r3, [r1], #2 "); sl@0: asm("cmp r3, #0 "); sl@0: asm("bne 1b "); // loop until we reach zero terminator sl@0: asm("rsb r1, r2, r1 "); // r1 = 2*length + 2 sl@0: asm("sub r1, r1, #2 "); // r1 = 2*length sl@0: asm("mov r1, r1, lsr #1 "); // r1 = length sl@0: asm("orr r1, r1, #0x10000000 "); // r1=EPtrC + length sl@0: asm("stmia r0, {r1, r2} "); // store type/length and ptr fields sl@0: __JUMP(,lr); sl@0: } sl@0: #endif sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16::TPtrC16(const TUint16* /*aBuf*/,TInt /*aLength*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("orrs r2, r2, #0x10000000 "); sl@0: asm("strpl r2, [r0] "); sl@0: asm("strpl r1, [r0, #4] "); sl@0: __JUMP(pl,lr); sl@0: asm("b " CSM_Z24Des16PanicLengthNegativev); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtr16::TPtr16(TUint16* /*aBuf*/,TInt /*aMaxLength*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("cmp r2, #0 "); sl@0: asm("movpl r3, r1 "); sl@0: asm("movpl r1, #0x20000000 "); // length=0, EPtr sl@0: asm("stmplia r0, {r1,r2,r3} "); sl@0: __JUMP(pl,lr); sl@0: asm("b " CSM_Z27Des16PanicMaxLengthNegativev); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtr16::TPtr16(TUint16* /*aBuf*/,TInt /*aLength*/,TInt /*aMaxLength*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("cmp r2, #0 "); // check length>=0 sl@0: asm("cmpge r3, r2 "); // if so, check maxlength>=length sl@0: asm("movge r12, r1 "); sl@0: asm("orrge r2, r2, #0x20000000 "); // r2 = length + EPtr sl@0: asm("stmgeia r0, {r2,r3,r12} "); sl@0: __JUMP(ge,lr); sl@0: asm("cmp r2, #0 "); sl@0: asm("bmi " CSM_Z24Des16PanicLengthNegativev); sl@0: asm("cmp r3, #0 "); sl@0: asm("bmi " CSM_Z27Des16PanicMaxLengthNegativev); sl@0: asm("b " CSM_Z26Des16PanicLengthOutOfRangev); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtr16::TPtr16(TBufCBase16& /*aLcb*/,TInt /*aMaxLength*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("mov r3, r1 "); sl@0: asm("ldr r1, [r3] "); sl@0: asm("bic r1, r1, #0xF0000000 "); // r1=aLcb.Length() sl@0: asm("cmp r1, r2 "); // check against maxlength sl@0: asm("orrle r1, r1, #0x40000000 "); // r1=aLcb.Length() + EBufCPtr sl@0: asm("stmleia r0, {r1,r2,r3} "); sl@0: __JUMP(le,lr); sl@0: asm("b " CSM_Z26Des16PanicLengthOutOfRangev); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TBufCBase16::TBufCBase16() sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("mov r1, #0 "); sl@0: asm("str r1, [r0] "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: __NAKED__ EXPORT_C TBufCBase16::TBufCBase16(const TUint16* /*aString*/,TInt /*aMaxLength*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("sub r3, r1, #2 "); // r3=aString address-2 sl@0: asm("1: "); sl@0: asm("ldrh r12, [r3, #2]! "); sl@0: asm("cmp r12, #0 "); sl@0: asm("bne 1b "); // loop until we reach zero terminator sl@0: asm("sub r3, r3, r1 "); // r3 = 2*length sl@0: asm("mov r3, r3, lsr #1 "); // r3 = length (+EBufC) sl@0: asm("cmp r3, r2 "); // check against max length sl@0: asm("bgt Des16PanicLengthOutOfRange__Fv "); sl@0: asm("stmfd sp!, {r0,lr} "); // save registers for function call sl@0: asm("str r3, [r0], #4 "); // save length/type field, r0->buffer sl@0: asm("add r2, r3, r3 "); // size=2*length into r2 for function call sl@0: asm("bl memmove "); // call memmove sl@0: __POPRET("r0,"); sl@0: } sl@0: #endif sl@0: sl@0: __NAKED__ EXPORT_C TBufCBase16::TBufCBase16(const TDesC16& /*aDes*/,TInt /*aMaxLength*/) sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: asm("ldr r3, [r1], #4 "); // r3 = type/length sl@0: asm("bic r12, r3, #0xF0000000"); // r12 = length sl@0: asm("cmp r12, r2 "); // compare with maxlength sl@0: asm("bgt " CSM_Z26Des16PanicLengthOutOfRangev); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr() sl@0: asm("stmfd sp!, {r0,lr} "); // save registers for function call sl@0: asm("str r12, [r0], #4 "); // store length/type, r0->buffer sl@0: asm("add r2, r12, r12 "); // size=2*length into r2 for function call sl@0: asm("bl memmove "); // call memmove sl@0: __POPRET("r0,"); sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: __NAKED__ EXPORT_C void TBufCBase16::Copy(const TUint16* /*aString*/,TInt /*aMaxLength*/) sl@0: // sl@0: // Copy from a string. sl@0: // sl@0: { sl@0: asm("sub r3, r1, #2 "); // r3=aString address-2 sl@0: asm("1: "); sl@0: asm("ldrh r12, [r3, #2]! "); sl@0: asm("cmp r12, #0 "); sl@0: asm("bne 1b "); // loop until we reach zero terminator sl@0: asm("sub r3, r3, r1 "); // r3 = 2*length sl@0: asm("mov r3, r3, lsr #1 "); // r3 = length (+EBufC) sl@0: asm("cmp r3, r2 "); // check against max length sl@0: asm("bgt Des16PanicLengthOutOfRange__Fv "); sl@0: asm("str r3, [r0], #4 "); // save length/type field, r0->buffer sl@0: asm("add r2, r3, r3 "); // size=2*length into r2 for function call sl@0: asm("b memmove "); // call memmove sl@0: } sl@0: #endif sl@0: sl@0: __NAKED__ EXPORT_C void TBufCBase16::Copy(const TDesC16& /*aDes*/,TInt /*aMaxLength*/) sl@0: // sl@0: // Copy from a descriptor. sl@0: // sl@0: { sl@0: asm("ldr r3, [r1], #4 "); // r3 = type/length sl@0: asm("bic r12, r3, #0xF0000000"); // r12 = length sl@0: asm("cmp r12, r2 "); // compare with maxlength sl@0: asm("bgt " CSM_Z21Des16PanicDesOverflowv); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr() sl@0: asm("str r12, [r0], #4 "); // store length/type, r0->buffer sl@0: asm("add r2, r12, r12 "); // size=2*length into r2 for function call sl@0: asm("b memmove "); // call memmove sl@0: } sl@0: sl@0: #ifndef __EABI_CTORS__ sl@0: __NAKED__ EXPORT_C TBufBase16::TBufBase16(TInt /*aMaxLength*/) sl@0: { sl@0: asm("mov r2, #0x30000000 "); // EBuf + zero length sl@0: asm("str r2, [r0] "); sl@0: asm("str r1, [r0, #4] "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TBufBase16::TBufBase16(TInt /*aLength*/, TInt /*aMaxLength*/) sl@0: { sl@0: asm("cmp r1, #0 "); // check length>=0 sl@0: asm("cmpge r2, r1 "); // if so, check maxlength>=length sl@0: asm("orrge r1, r1, #0x30000000 "); // r1=length + EBuf sl@0: asm("stmgeia r0, {r1,r2} "); // store length/type and maxlength fields sl@0: __JUMP(ge,lr); sl@0: asm("cmp r2, #0 "); sl@0: asm("bmi " CSM_Z27Des16PanicMaxLengthNegativev); sl@0: asm("b " CSM_Z26Des16PanicLengthOutOfRangev); sl@0: } sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: __NAKED__ EXPORT_C TBufBase16::TBufBase16(const TUint16* /*aString*/, TInt /*aMaxLength*/) sl@0: { sl@0: asm("mov r12, r1, lsr #1 "); // save aString pointer (lose bottom bit which should be 0) sl@0: asm("1: "); sl@0: asm("ldrh r3, [r1], #2 "); sl@0: asm("cmp r3, #0 "); sl@0: asm("bne 1b "); // loop until we reach zero terminator sl@0: asm("rsb r3, r12, r1, lsr #1 "); // r3 = length + 1 sl@0: asm("sub r3, r3, #1 "); // r3 = length sl@0: asm("cmp r3, r2 "); // compare to max length sl@0: asm("bgt Des16PanicLengthOutOfRange__Fv "); // length too big, so panic sl@0: asm("orr r1, r3, #0x30000000 "); // if length<=max, r1=EBuf + length sl@0: asm("stmfd sp!, {r0, lr} "); // save registers for function call sl@0: asm("stmia r0!, {r1, r2} "); // store type/length and max length fields, r0->buffer sl@0: asm("mov r2, r3, lsl #1 "); // r2=Size() sl@0: asm("mov r1, r12, lsl #1 "); // r1=aString sl@0: asm("bl memmove "); // call memmove sl@0: __POPRET("r0,"); sl@0: } sl@0: #endif sl@0: sl@0: __NAKED__ EXPORT_C TBufBase16::TBufBase16(const TDesC16& /*aDes*/, TInt /*aMaxLength*/) sl@0: { sl@0: asm("ldr r3, [r1], #4 "); // r3 = type/length sl@0: asm("bic r12, r3, #0xF0000000"); // r12 = length sl@0: asm("cmp r12, r2 "); // compare with maxlength sl@0: asm("bgt " CSM_Z26Des16PanicLengthOutOfRangev); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr() sl@0: asm("stmfd sp!, {r0,lr} "); // save registers for function call sl@0: asm("orr r3, r12, #0x30000000 "); // add EBuf type field sl@0: asm("str r3, [r0], #4 "); // store length/type, r0->max length sl@0: asm("str r2, [r0], #4 "); // store max length, r0->buffer sl@0: asm("mov r2, r12, lsl #1 "); // Size() into r2 for function call sl@0: asm("bl memmove "); // call memmove sl@0: __POPRET("r0,"); sl@0: } sl@0: #endif sl@0: sl@0: __NAKED__ EXPORT_C void TDes16::SetLength(TInt /*aLength*/) sl@0: // sl@0: // Set the length of the descriptor, checking the length is O.K. sl@0: // sl@0: { sl@0: asm("ldmia r0, {r2,r3} "); // r2=length/type, r3=maxlength sl@0: asm("cmp r1, r3 "); // check aLength against maxlength and for -ve values sl@0: asm("bhi " CSM_Z21Des16PanicDesOverflowv); sl@0: asm("and r2, r2, #0xF0000000 "); // r2=type field sl@0: asm("cmp r2, #0x40000000 "); // check for EBufCPtr sl@0: asm("orr r2, r2, r1 "); // r2=type + new length sl@0: asm("str r2, [r0] "); // store new length sl@0: __JUMP(ne,lr); sl@0: asm("ldr r2, [r0, #8] "); // r2=pointer to TBufCBase sl@0: asm("str r1, [r2] "); // update length of TBufCBase sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C void TDes16::SetMax() sl@0: // sl@0: // Set the length to MaxLength(). sl@0: // sl@0: { sl@0: asm("ldmia r0, {r1,r2} "); // r1=length/type, r2=maxlength sl@0: asm("and r1, r1, #0xF0000000 "); // r1=type field sl@0: asm("cmp r1, #0x40000000 "); // check for EBufCPtr sl@0: asm("orr r1, r1, r2 "); // r1=type field + maxlength sl@0: asm("str r1, [r0] "); // store new length sl@0: __JUMP(ne,lr); sl@0: asm("ldr r1, [r0, #8] "); // r1 = pointer to TBufCBase sl@0: asm("str r2, [r1] "); // update length of TBufCBase sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: __NAKED__ EXPORT_C void TDes16::Copy(const TUint16* /*aString*/) sl@0: // sl@0: // Copy a string to this descriptor. sl@0: // sl@0: { sl@0: asm("sub r2, r1, #2 "); // r2=aString-2 sl@0: asm("1: "); sl@0: asm("ldrh r3, [r2, #2]! "); sl@0: asm("cmp r3, #0 "); sl@0: asm("bne 1b "); // loop until zero terminator reached sl@0: asm("sub r2, r2, r1 "); // r2=2*length of string sl@0: asm("mov r2, r2, lsr #1 "); // r2=length of string sl@0: asm("ldmia r0, {r3,r12} "); // r3=type/length of this, r12=maxlength sl@0: asm("cmp r2, r12 "); // compare new length against maxlength sl@0: asm("bgt Des16PanicDesOverflow__Fv "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("and r3, r3, #0xF0000000 "); // r3=type of this sl@0: asm("orr r3, r3, r2 "); // r3=new type/length sl@0: asm("str r3, [r0], #4 "); // store it sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("streq r2, [r0], #4 "); // if EBufCPtr, update length of TBufCBase, r0=Ptr() sl@0: asm("add r2, r2, r2 "); // r2=size=2*length sl@0: asm("b memmove "); // call memmove sl@0: } sl@0: #endif sl@0: sl@0: __NAKED__ EXPORT_C void TDes16::Copy(const TUint16* /*aBuf*/,TInt /*aLength*/) sl@0: // sl@0: // Copy the aLength characters to the descriptor. sl@0: // sl@0: { sl@0: asm("ldmia r0, {r3,r12} "); // r3=type/length of this, r12=maxlength sl@0: asm("cmp r2, r12 "); // compare new length against maxlength sl@0: asm("bhi " CSM_Z21Des16PanicDesOverflowv); // Des16Panic if >MaxLength or -ve sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("and r3, r3, #0xF0000000 "); // r3=type of this sl@0: asm("orr r3, r3, r2 "); // r3=new type/length sl@0: asm("str r3, [r0], #4 "); // store it sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("streq r2, [r0], #4 "); // if EBufCPtr, update length of TBufCBase, r0=Ptr() sl@0: asm("add r2, r2, r2 "); // r2=size=2*length sl@0: asm("b memmove "); // call memmove sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C void TDes16::Copy(const TDesC16& /*aDes*/) sl@0: // sl@0: // Copy a descriptor to this descriptor. sl@0: // sl@0: { sl@0: asm("ldr r3, [r1], #4 "); // r3 = type/length of aDes sl@0: asm("bic r12, r3, #0xF0000000"); // r12 = aDes.length sl@0: asm("ldr r2, [r0, #4] "); // r2=this.maxlength sl@0: asm("cmp r12, r2 "); // compare with maxlength sl@0: asm("bgt " CSM_Z21Des16PanicDesOverflowv); sl@0: asm("ldr r2, [r0] "); // get type of this sl@0: asm("cmp r2, #0x50000000 "); // check both descriptor types sl@0: asm("cmpcc r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("and r2, r2, #0xF0000000 "); sl@0: asm("orr r2, r12, r2 "); // r2=new type/length of this sl@0: asm("str r2, [r0], #4 "); // store it sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr() sl@0: asm("eor r2, r2, r2, lsr #1 "); sl@0: asm("msr cpsr_flg, r2 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("streq r12, [r0], #4 "); // if EBufCPtr, update length of TBufCBase, r0=Ptr() sl@0: asm("add r2, r12, r12 "); // size=2*length into r2 for function call sl@0: asm("b memmove "); // call memmove sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtr16 TDes16::LeftTPtr(TInt /*aLength*/) const sl@0: // sl@0: // Extract the left portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aLength sl@0: // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr) sl@0: asm("ldr r3, [r1], #4 "); // r3=this.length/type sl@0: asm("cmp r2, #0 "); // check aLength>=0 sl@0: asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r2, r12 "); // else limit aLength to Length() sl@0: asm("movgt r2, r12 "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1=this.Ptr() sl@0: asm("mov r3, r1 "); // r3=this.Ptr() sl@0: asm("orr r1, r2, #0x20000000 "); // r1=aLength + EPtr sl@0: asm("stmia r0, {r1-r3} "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtr16 TDes16::RightTPtr(TInt /*aLength*/) const sl@0: // sl@0: // Extract the right portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aLength sl@0: // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr) sl@0: asm("ldr r3, [r1], #4 "); // r3=this.length/type sl@0: asm("cmp r2, #0 "); // check aLength>=0 sl@0: asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r2, r12 "); // else limit aLength to Length() sl@0: asm("movgt r2, r12 "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r0=this.Ptr() sl@0: asm("add r3, r1, r12, lsl #1 "); // r3=this.Ptr()+len*2 sl@0: asm("orr r1, r2, #0x20000000 "); // r1=aLength + EPtr sl@0: asm("sub r3, r3, r2, lsl #1 "); // r2=Ptr()+len*2-aLength*2 sl@0: asm("stmia r0, {r1-r3} "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtr16 TDes16::MidTPtr(TInt /*aPos*/) const sl@0: // sl@0: // Extract the middle portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aPos sl@0: // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr) sl@0: asm("ldr r3, [r1], #4 "); // r3=this.length/type sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r2, #0 "); // check aPos>=0 sl@0: asm("cmpge r12, r2 "); // if so check Length()>=aPos sl@0: asm("blt Des16PanicPosOutOfRange__Fv "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r0=this.Ptr() sl@0: asm("add r3, r1, r2, lsl #1 "); // r3=this.Ptr()+aPos*2 sl@0: asm("sub r2, r12, r2 "); // r2=len-aPos (=newMaxLen) sl@0: asm("orr r1, r2, #0x20000000 "); // r1=len-aPos + EPtr (=newLen/Type) sl@0: asm("stmia r0, {r1-r3} "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtr16 TDes16::MidTPtr(TInt /*aPos*/,TInt /*aLength*/) const sl@0: // sl@0: // Extract the middle portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aPos, r3=aLength sl@0: // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr) sl@0: asm("str r4, [sp, #-4]! "); // save r4 sl@0: asm("ldr r12, [r1], #4 "); // r12=this.length/type sl@0: asm("mov r4, r1 "); sl@0: asm("cmp r12, #0x50000000 "); // check valid descriptor type sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r12, r12, r12, lsr #1 "); sl@0: asm("msr cpsr_flg, r12 "); sl@0: asm("ldr r12, [r1, #-4] "); sl@0: asm("addcs r4, r4, #4 "); sl@0: asm("ldrle r4, [r4] "); sl@0: asm("bic r12, r12, #0xF0000000 "); // r12=Length() sl@0: asm("addeq r4, r4, #4 "); // r4=this.Ptr() sl@0: asm("cmp r2, #0 "); // check aPos>=0 sl@0: asm("subge r12, r12, r2 "); // if so, r12=Length()-aPos sl@0: asm("cmpge r12, r3 "); // and check Length()-aPos>=aLength sl@0: asm("orrge r1, r3, #0x20000000 "); // if so, r0 = aLength + EPtr sl@0: asm("addge r3, r4, r2, lsl #1 "); // and r2=this.Ptr()+aPos*2 sl@0: asm("bicge r2, r1, #0xF0000000 "); // and r1=aLength sl@0: asm("stmgeia r0, {r1-r3} "); sl@0: asm("ldrge r4, [sp], #4 "); sl@0: __JUMP(ge,lr); sl@0: asm("b Des16PanicPosOutOfRange__Fv "); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C const TUint16& TDesC16::AtC(TInt /*anIndex*/) const sl@0: // sl@0: // Return a reference to the character in the buffer. sl@0: // sl@0: { sl@0: asm("ldr r2, [r0], #4 "); // r2=length/type sl@0: asm("bic r3, r2, #0xF0000000 "); // r3=length sl@0: asm("cmp r2, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r2, r2, r2, lsr #1 "); sl@0: asm("msr cpsr_flg, r2 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("cmp r1, #0 "); // check index>=0 sl@0: asm("cmpge r3, r1 "); // if so, check Length()>index sl@0: asm("addgt r0, r0, r1, lsl #1 "); // return value = this.Ptr()+index*2 sl@0: __JUMP(gt,lr); sl@0: asm("b " CSM_Z28Des16PanicDesIndexOutOfRangev); sl@0: } sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: __NAKED__ EXPORT_C TInt TDesC16::Locate(TChar /*aChar*/) const sl@0: // sl@0: // Locate character aChar in the descriptor. sl@0: // sl@0: { sl@0: asm("ldr r2, [r0], #4 "); // r2=length/type sl@0: asm("cmp r2, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("bics r3, r2, #0xF0000000 "); // r3=length sl@0: asm("mvneq r0, #0 "); // if length=0, not found sl@0: __JUMP(eq,lr); sl@0: asm("eor r2, r2, r2, lsr #1 "); sl@0: asm("msr cpsr_flg, r2 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("add r3, r0, r3, lsl #1 "); // r3=ptr+length*2 (end of string pointer) sl@0: asm("add r12, r0, #2 "); // r12=ptr+2 sl@0: asm("1: "); sl@0: asm("ldrh r2, [r0], #2 "); // r2=*r0++ sl@0: asm("cmp r1, r2 "); // is r1=match char? sl@0: asm("cmpne r0, r3 "); // if not, is r0=r3 (end pointer) sl@0: asm("bne 1b "); sl@0: asm("cmp r1, r2 "); // did we find char? sl@0: asm("subeq r0, r0, r12 "); // if we did, return value = r0-ptr-2 sl@0: asm("moveq r0, r0, lsr #1 "); // divide by 2 to get index sl@0: asm("mvnne r0, #0 "); // else return value =-1 sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TInt TDesC16::LocateReverse(TChar /*aChar*/) const sl@0: // sl@0: // Locate character aChar in the descriptor in reverse. sl@0: // sl@0: { sl@0: asm("ldr r2, [r0], #4 "); // r2=length/type sl@0: asm("cmp r2, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("bics r3, r2, #0xF0000000 "); // r3=length sl@0: asm("mvneq r0, #0 "); // if length=0, not found sl@0: __JUMP(eq,lr); sl@0: asm("eor r2, r2, r2, lsr #1 "); sl@0: asm("msr cpsr_flg, r2 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("add r3, r0, r3, lsl #1 "); // r3=Ptr()+Length() sl@0: asm("1: "); sl@0: asm("ldrh r2, [r3, #-2]! "); // r2=*--r3 sl@0: asm("cmp r1, r2 "); // is r1=match char? sl@0: asm("cmpne r3, r0 "); // if not, have we reached beginning of string? sl@0: asm("bne 1b "); // loop if neither sl@0: asm("cmp r1, r2 "); // did we find match char? sl@0: asm("subeq r0, r3, r0 "); // if we did, return value = (r3-r0)/2 sl@0: asm("moveq r0, r0, lsr #1 "); sl@0: asm("mvnne r0, #0 "); // else return value =-1 sl@0: __JUMP(,lr); sl@0: } sl@0: #endif sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: __NAKED__ EXPORT_C TInt TDesC16::CompareF(const TDesC16& /*aDes*/) const sl@0: // sl@0: // Compare a descriptor to this descriptor folded. sl@0: // sl@0: { sl@0: asm("ldr r12, 1f "); sl@0: asm("b comparebody "); sl@0: asm("1: "); sl@0: asm(".word " CSM_ZN3Mem8CompareFEPKtiS0_i); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TInt TDesC16::CompareC(const TDesC16& /*aDes*/) const sl@0: // sl@0: // Compare a descriptor to this descriptor collated. sl@0: // sl@0: { sl@0: asm("ldr r12, 1f "); sl@0: asm("b comparebody "); sl@0: asm("1: "); sl@0: asm(".word " CSM_ZN3Mem8CompareCEPKtiS0_i); sl@0: } sl@0: #endif sl@0: sl@0: __NAKED__ EXPORT_C TInt TDesC16::Compare(const TDesC16& /*aDes*/) const sl@0: // sl@0: // Compare a descriptor to this descriptor. sl@0: // sl@0: { sl@0: asm("ldr r12, 1f "); sl@0: asm("comparebody: "); sl@0: asm("mov r2, r1 "); // r2=&aDes sl@0: asm("ldr r3, [r0], #4 "); // r3=this.length/type sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("bic r1, r3, #0xF0000000 "); // r1=this.Length() sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("ldr r3, [r2], #4 "); // r3=aDes.length/type sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("ldr r3, [r2, #-4] "); sl@0: asm("bic r3, r3, #0xF0000000 "); // r3=aDes.Length() sl@0: asm("addcs r2, r2, #4 "); sl@0: asm("ldrle r2, [r2] "); sl@0: asm("addeq r2, r2, #4 "); // r2=aDes.Ptr() sl@0: #ifdef __KERNEL_MODE__ sl@0: asm("add r1, r1, r1 "); sl@0: asm("add r3, r3, r3 "); sl@0: #endif sl@0: __JUMP(,r12); sl@0: sl@0: asm("1: "); sl@0: #ifdef __KERNEL_MODE__ sl@0: asm(".word memcompare "); sl@0: #else sl@0: asm(".word " CSM_ZN3Mem7CompareEPKtiS0_i); sl@0: #endif sl@0: } sl@0: #endif // __DES16_MACHINE_CODED__ sl@0: sl@0: sl@0: #if defined(__DES16_MACHINE_CODED__) && !defined(__EABI__) sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Left(TInt /*aLength*/) const sl@0: // sl@0: // Extract the left portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=this, r1=aLength sl@0: // Return TPtrC16 in r0,r1 sl@0: asm("ldr r3, [r0], #4 "); // r3=this.length/type sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r1, #0 "); // check aLength>=0 sl@0: asm("blt " CSM_Z23Des16PanicPosOutOfRangev); // if not, panic sl@0: asm("cmp r1, r12 "); // else limit aLength to Length() sl@0: asm("movgt r1, r12 "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("orr r2, r1, #0x10000000 "); // r2=aLength + EPtrC sl@0: asm("mov r1, r0 "); // r1=result ptr sl@0: asm("mov r0, r2 "); // r0=result type/length sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Right(TInt /*aLength*/) const sl@0: // sl@0: // Extract the right portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=this, r1=aLength sl@0: // Return TPtrC16 in r0,r1 sl@0: asm("ldr r3, [r0], #4 "); // r3=this.length/type sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r1, #0 "); // check aLength>=0 sl@0: asm("blt " CSM_Z23Des16PanicPosOutOfRangev); // if not, panic sl@0: asm("cmp r1, r12 "); // else limit aLength to Length() sl@0: asm("movgt r1, r12 "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("add r3, r0, r12, lsl #1 "); // r3=this.Ptr()+len*2 sl@0: asm("orr r0, r1, #0x10000000 "); // r0=aLength + EPtrC sl@0: asm("sub r1, r3, r1, lsl #1 "); // r1=Ptr()+len*2-aLength*2 sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/) const sl@0: // sl@0: // Extract the middle portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=this, r1=aPos sl@0: // Return TPtrC16 in r0,r1 sl@0: asm("ldr r3, [r0], #4 "); // r3=this.length/type sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r1, #0 "); // check aPos>=0 sl@0: asm("cmpge r12, r1 "); // if so check Length()>=aPos sl@0: asm("blt " CSM_Z23Des16PanicPosOutOfRangev); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("sub r2, r12, r1 "); // r2=len-aPos sl@0: asm("add r1, r0, r1, lsl #1 "); // r1=this.Ptr()+aPos*2 sl@0: asm("orr r0, r2, #0x10000000 "); // r0=result length + EPtrC sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/,TInt /*aLength*/) const sl@0: // sl@0: // Extract the middle portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=this, r1=aPos, r2=aLength sl@0: // Return TPtrC16 in r0,r1 sl@0: asm("ldr r12, [r0], #4 "); // r12=this.length/type sl@0: asm("cmp r12, #0x50000000 "); // check valid descriptor type sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("eor r12, r12, r12, lsr #1 "); sl@0: asm("msr cpsr_flg, r12 "); sl@0: asm("ldr r12, [r0, #-4] "); sl@0: asm("bic r12, r12, #0xF0000000 "); // r12=Length() sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=this.Ptr() sl@0: asm("cmp r1, #0 "); // check aPos>=0 sl@0: asm("subge r12, r12, r1 "); // if so, r12=Length()-aPos sl@0: asm("cmpge r12, r2 "); // and check Length()-aPos>=aLength sl@0: asm("addge r1, r0, r1, lsl #1 "); // if so, r1=Ptr()+aPos*2 sl@0: asm("orrge r0, r2, #0x10000000 "); // and r0 = aLength + EPtrC sl@0: __JUMP(ge,lr); sl@0: asm("b " CSM_Z23Des16PanicPosOutOfRangev); sl@0: } sl@0: #endif // defined(__DES16_MACHINE_CODED__) && !defined(__EABI__) sl@0: sl@0: sl@0: #ifdef __DES16_MACHINE_CODED__ sl@0: sl@0: // Here are the __EABI__ compliant versions of the above sl@0: #ifdef __EABI__ sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Left(TInt /*aLength*/) const sl@0: // sl@0: // Extract the left portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aLength sl@0: // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr) sl@0: asm("ldr r3, [r1], #4 "); // r3=this.length/type sl@0: asm("cmp r2, #0 "); // check aLength>=0 sl@0: asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r2, r12 "); // else limit aLength to Length() sl@0: asm("movgt r2, r12 "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1=this.Ptr() sl@0: asm("mov r3, r1"); // r3=this.Ptr() sl@0: asm("orr r1, r2, #0x10000000 "); // r1=aLength + EPtrC sl@0: asm("stmia r0, {r1,r3} "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Right(TInt /*aLength*/) const sl@0: // sl@0: // Extract the right portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aLength sl@0: // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr) sl@0: asm("ldr r3, [r1], #4 "); // r3=this.length/type sl@0: asm("cmp r2, #0 "); // check aLength>=0 sl@0: asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r2, r12 "); // else limit aLength to Length() sl@0: asm("movgt r2, r12 "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r1=this.Ptr() sl@0: asm("add r3, r1, r12, lsl #1 "); // r3=this.Ptr()+len*2 sl@0: asm("orr r1, r2, #0x10000000 "); // r1=aLength + EPtrC sl@0: asm("sub r3, r3, r2, lsl #1 "); // r2=Ptr()+len*2-aLength*2 sl@0: asm("stmia r0, {r1,r3} "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/) const sl@0: // sl@0: // Extract the middle portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aPos sl@0: // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr) sl@0: asm("ldr r3, [r1], #4 "); // r3=this.length/type sl@0: asm("bic r12, r3, #0xF0000000 "); // r12=this.Length() sl@0: asm("cmp r2, #0 "); // check aPos>=0 sl@0: asm("cmpge r12, r2 "); // if so check Length()>=aPos sl@0: asm("blt Des16PanicPosOutOfRange__Fv "); sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("addeq r1, r1, #4 "); // r3=this.Ptr() sl@0: asm("add r3, r1, r2, lsl #1 "); // r3=this.Ptr()+aPos*2 sl@0: asm("sub r2, r12, r2 "); // r2=len-aPos (=newMaxLen) sl@0: asm("orr r1, r2, #0x10000000 "); // r1=len-aPos + EPtrC (=newLen/Type) sl@0: asm("stmia r0, {r1,r3} "); sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/,TInt /*aLength*/) const sl@0: // sl@0: // Extract the middle portion of the descriptor. sl@0: // sl@0: { sl@0: // On entry r0=return store ptr, r1=this, r2=aPos, r3=aLength sl@0: // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr) sl@0: asm("ldr r12, [r1], #4 "); // r12=this.length/type sl@0: asm("cmp r12, #0x50000000 "); // check valid descriptor type sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("eor r12, r12, r12, lsr #1 "); sl@0: asm("msr cpsr_flg, r12 "); sl@0: asm("ldr r12, [r1, #-4] "); sl@0: asm("addcs r1, r1, #4 "); sl@0: asm("ldrle r1, [r1] "); sl@0: asm("bic r12, r12, #0xF0000000 "); // r12=Length() sl@0: asm("addeq r1, r1, #4 "); // r1=this.Ptr() sl@0: asm("cmp r2, #0 "); // check aPos>=0 sl@0: asm("subge r12, r12, r2 "); // if so, r12=Length()-aPos sl@0: asm("cmpge r12, r3 "); // and check Length()-aPos>=aLength sl@0: asm("addge r2, r1, r2, lsl #1 "); // if so r2=this.Ptr()+aPos*2 sl@0: asm("orrge r1, r3, #0x10000000 "); // and r1 = aLength + EPtrC sl@0: asm("stmgeia r0, {r1,r2} "); sl@0: __JUMP(ge,lr); sl@0: asm("b Des16PanicPosOutOfRange__Fv "); sl@0: } sl@0: #endif // __EABI__ sl@0: sl@0: sl@0: __NAKED__ EXPORT_C void TDes16::Zero() sl@0: // sl@0: // Zero the buffer. sl@0: // sl@0: { sl@0: asm("ldr r1, [r0] "); // r1=length/type sl@0: asm("and r1, r1, #0xF0000000 "); // r1=type field, zero length sl@0: asm("cmp r1, #0x40000000 "); // check for EBufCPtr sl@0: asm("str r1, [r0] "); // store zero length sl@0: __JUMP(ne,lr); sl@0: asm("ldr r2, [r0, #8] "); // r2 = pointer to TBufCBase sl@0: asm("mov r1, #0 "); sl@0: asm("str r1, [r2] "); // update length of TBufCBase sl@0: __JUMP(,lr); sl@0: } sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: #ifndef __KERNEL_MODE__ sl@0: __NAKED__ EXPORT_C void TDes16::ZeroTerminate() sl@0: // sl@0: // Zero terminate at Length(). sl@0: // sl@0: { sl@0: // Fall though to PtrZ below... sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C const TUint16* TDes16::PtrZ() sl@0: // sl@0: // Return a pointer to a 0 terminated string. sl@0: // sl@0: { sl@0: asm("ldmia r0, {r1,r2} "); // r1=length/type, r2=maxlength sl@0: asm("bic r3, r1, #0xF0000000 "); // r3=Length(); sl@0: asm("cmp r3, r2 "); // check Length()=0 sl@0: __JUMP(eq,lr); sl@0: asm("blt " CSM_Z24Des16PanicLengthNegativev); sl@0: asm("appendbody: "); sl@0: asm("ldmia r0, {r3,r12} "); // r3=type/length, r12=maxlength sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("bic r3, r3, #0xF0000000 "); // r3=Length() sl@0: asm("sub r12, r12, r3 "); // r12=MaxLength-Length sl@0: asm("cmp r2, r12 "); // check aLength<=(MaxLength-Length) sl@0: asm("bgt " CSM_Z21Des16PanicDesOverflowv); sl@0: asm("ldr r12, [r0] "); sl@0: asm("add r12, r12, r2 "); // new length/type field sl@0: asm("str r12, [r0], #4 "); // store it sl@0: asm("eor r12, r12, r12, lsr #1 "); sl@0: asm("msr cpsr_flg, r12 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("ldreq r12, [r0] "); // fetch length from TBufCBase sl@0: asm("addeq r12, r12, r2 "); // add aLength sl@0: asm("streq r12, [r0], #4 "); // update length of TBufCBase, r0=Ptr() sl@0: asm("add r0, r0, r3, lsl #1 "); // r0=Ptr()+Length()*2 sl@0: asm("add r2, r2, r2 "); // r2=aLength*2 sl@0: asm("b memmove "); // call memmove sl@0: } sl@0: sl@0: __NAKED__ EXPORT_C void TDes16::FillZ() sl@0: // sl@0: // Fill the descriptor with 0. sl@0: // sl@0: { sl@0: asm("ldr r2, [r0] "); // r2=length/type sl@0: asm("cmp r2, #0x50000000 "); sl@0: asm("bcs " CSM_Z20Des16PanicBadDesTypev); sl@0: asm("bic r1, r2, #0xF0000000 "); // r1=Length() sl@0: asm("eor r2, r2, r2, lsr #1 "); sl@0: asm("msr cpsr_flg, r2 "); sl@0: asm("add r0, r0, #4 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=Ptr() sl@0: asm("add r1, r1, r1 "); // r1=2*Length() sl@0: asm("b memclr "); // call memclr sl@0: } sl@0: sl@0: #ifdef __DES16_MACHINE_CODED_HWORD__ sl@0: __NAKED__ EXPORT_C void TDes16::Fill(TChar /*aChar*/) sl@0: // sl@0: // Fill the descriptor with aChar. sl@0: // sl@0: { sl@0: // on entry r0=this, r1=fill char sl@0: asm("ldr r3, [r0] "); // r3=length/type sl@0: asm("cmp r3, #0x50000000 "); sl@0: asm("bcs Des16PanicBadDesType__Fv "); sl@0: asm("bics r2, r3, #0xF0000000 "); // r2=Length() sl@0: __JUMP(eq,lr); // if length is zero, finished sl@0: asm("stmfd sp!, {r0,lr} "); // save registers for function call sl@0: asm("eor r3, r3, r3, lsr #1 "); sl@0: asm("msr cpsr_flg, r3 "); sl@0: asm("add r0, r0, #4 "); sl@0: asm("addcs r0, r0, #4 "); sl@0: asm("ldrle r0, [r0] "); sl@0: asm("addeq r0, r0, #4 "); // r0=Ptr() sl@0: asm("tst r0, #2 "); // check alignment of Ptr() sl@0: asm("strneh r1, [r0], #2 "); // if not aligned, fill first location sl@0: asm("subne r2, r2, #1 "); // and decrement length sl@0: asm("mov r1, r1, lsl #16 "); sl@0: asm("orr r1, r1, r1, lsr #16 "); // r1=fill char repeated sl@0: asm("mov r3, r1 "); sl@0: asm("mov r12, r1 "); sl@0: asm("mov r14, r1 "); // r1=r3=r12=r14=fill char repeated sl@0: asm("b 2f "); // branch to check for 16-char blocks sl@0: asm("1: "); sl@0: asm("stmia r0!, {r1,r3,r12,r14} "); // fill a block of 16 bytes sl@0: asm("stmia r0!, {r1,r3,r12,r14} "); // fill a block of 16 bytes sl@0: asm("2: "); sl@0: asm("subs r2, r2, #16 "); // check for more blocks of 16 sl@0: asm("bge 1b "); // loop if more sl@0: asm("add r2, r2, #16 "); // now r1=number of chars remaining, 0<=r1<16 sl@0: asm("mov r2, r2, lsl #28 "); // move into bits 28-31 sl@0: asm("msr cpsr_flg, r2 "); // and into NZCV flags sl@0: asm("stmmiia r0!, {r1,r3,r12,r14} "); // fill a block of 16 bytes if needed sl@0: asm("stmeqia r0!, {r1,r3} "); // fill a block of 8 bytes if needed sl@0: asm("stmcsia r0!, {r1} "); // fill a block of 4 bytes if needed sl@0: asm("strvsh r1, [r0], #2 "); // fill last char if needed sl@0: __POPRET("r0,"); sl@0: } sl@0: #endif sl@0: sl@0: #endif // __DES16_MACHINE_CODED__ sl@0: sl@0: sl@0: sl@0: