piprofiler/plugins/GeneralsPlugin/src/GeneralsSampler.cia
changeset 22 a009639409f5
equal deleted inserted replaced
17:67c6ff54ec25 22:a009639409f5
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <platform.h>
       
    20 
       
    21 #include "GeneralsDriver.h"
       
    22 #include <kern_priv.h>		//temporary
       
    23 
       
    24 #ifdef __SMP__
       
    25 #include <e32cia.h>
       
    26 #include <arm.h>
       
    27 #include <arm_gic.h>
       
    28 #include <arm_tmr.h>
       
    29 #endif
       
    30 
       
    31 #if defined(__GCC32__)
       
    32 // CIA symbol macros for Gcc98r2
       
    33 #define CSM__ZN5NKern14CurrentContextEv " CurrentContext__5NKern"
       
    34 #elif defined(__ARMCC__)
       
    35 // CIA symbol macros for RVCT
       
    36 #define CSM__ZN5NKern14CurrentContextEv " __cpp(NKern::CurrentContext)"
       
    37 #else
       
    38 // CIA symbol macros for EABI assemblers
       
    39 #define CSM__ZN5NKern14CurrentContextEv " _ZN5NKern14CurrentContextEv"
       
    40 #endif
       
    41 
       
    42 #ifdef __WINS__
       
    43 __NAKED__ TUint* IntStackPtr()
       
    44 {
       
    45 	return 0;
       
    46 }
       
    47 
       
    48 __NAKED__ TUint32 SPSR()
       
    49 {
       
    50 	return 0;
       
    51 }
       
    52 __NAKED__ void UsrModLr(TUint32* a)
       
    53 {
       
    54 	*a = 0;
       
    55 }
       
    56 #else
       
    57 
       
    58 __NAKED__ TUint* IntStackPtr()
       
    59 {
       
    60 #ifdef __SMP__
       
    61     asm("stmfd sp!, {r0-r12,lr} ");
       
    62 #endif
       
    63 	asm("mrs r1, cpsr ");           // copy current program status register (cpsr) to R1 
       
    64 	asm("bic r3, r1, #0x1f ");      // compare to 0x1f, i.e. make sure that spsr is available? 
       
    65 #ifdef __SMP__
       
    66 	__ASM_CLI_MODE(MODE_IRQ);       // disable all interrupts and set to irq mode (we are in NTimer interrupt)
       
    67 #else
       
    68 	asm("orr r3, r3, #0xd2 ");		// mode_irq, all interrupts off
       
    69 	asm("msr cpsr, r3 ");           // write result on R3 back to cpsr, irqs disabled 
       
    70 #endif
       
    71 	asm("mov r0, sp ");				// read stack pointer to R0, mode r0=sp_irq
       
    72 	asm("msr cpsr, r1 ");			// restore interrupts
       
    73 #ifdef __SMP__
       
    74     asm("ldmfd sp!, {r0-r12,pc} ");
       
    75 #endif
       
    76 	__JUMP(,lr);
       
    77 }
       
    78 
       
    79 __NAKED__ TUint32 SPSR()
       
    80 {
       
    81 	asm("mrs r0, spsr ");
       
    82 	__JUMP(,lr);
       
    83 }
       
    84 __NAKED__ void UsrModLr(TUint32*)
       
    85 {
       
    86 	// r0 = address to store
       
    87 	asm ("stmia r0,{lr}^");
       
    88 	__JUMP(,lr);
       
    89 }
       
    90 
       
    91 #endif