crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianStackLib/Plugins/Accurate/CPU/ArmCpu.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     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 using System;
       
    18 using System.Collections.Generic;
       
    19 using System.Text;
       
    20 using SymbianStackAlgorithmAccurate.Instructions;
       
    21 using SymbianStructuresLib.Arm.Registers;
       
    22 using SymbianStructuresLib.Arm;
       
    23 
       
    24 namespace SymbianStackAlgorithmAccurate.CPU
       
    25 {
       
    26     public class ArmCpu
       
    27     {
       
    28         #region Constructors
       
    29         public ArmCpu()
       
    30         {
       
    31         }
       
    32         #endregion
       
    33 
       
    34         #region API
       
    35         #endregion
       
    36 
       
    37         #region Properties
       
    38         public ArmRegisterCollection Registers
       
    39         {
       
    40             get { return iRegisters; }
       
    41             set
       
    42             { 
       
    43                 // Copy the registers, don't take a reference to the supplied ones..
       
    44                 // Otherwise we cannot invoke stack walking twice since we blatted
       
    45                 // the original (external) copy.
       
    46                 ArmRegisterCollection regs = new ArmRegisterCollection( value );
       
    47                 iRegisters = regs;
       
    48             }
       
    49         }
       
    50 
       
    51         public ArmRegister SP
       
    52         {
       
    53             get
       
    54             {
       
    55                 ArmRegister ret = Registers[ TArmRegisterType.EArmReg_SP ];
       
    56                 return ret;
       
    57             }
       
    58         }
       
    59 
       
    60         public ArmRegister LR
       
    61         {
       
    62             get
       
    63             {
       
    64                 ArmRegister ret = Registers[ TArmRegisterType.EArmReg_LR ];
       
    65                 return ret;
       
    66             }
       
    67         }
       
    68 
       
    69         public ArmRegister PC
       
    70         {
       
    71             get
       
    72             {
       
    73                 ArmRegister ret = Registers[ TArmRegisterType.EArmReg_PC ];
       
    74                 return ret;
       
    75             }
       
    76         }
       
    77 
       
    78         public ArmRegister CPSR
       
    79         {
       
    80             get
       
    81             {
       
    82                 ArmRegister ret = Registers[ TArmRegisterType.EArmReg_CPSR ];
       
    83                 return ret;
       
    84             }
       
    85         }
       
    86 
       
    87         public TArmInstructionSet CurrentProcessorMode
       
    88         {
       
    89             get
       
    90             {
       
    91                 TArmInstructionSet ret = TArmInstructionSet.EARM;
       
    92                 ArmRegister cpsr = CPSR;
       
    93                 //
       
    94                 if ( ( cpsr.Value & 0x20 ) != 0 )
       
    95                 {
       
    96                     ret = TArmInstructionSet.ETHUMB;
       
    97                 }
       
    98                 //
       
    99                 return ret;
       
   100             }
       
   101             set
       
   102             {
       
   103                 if ( value == TArmInstructionSet.EARM )
       
   104                 {
       
   105                     // Clear CPSR Thumb bit
       
   106                     CPSR.Value &= 0xFFFFFFDF;
       
   107                 }
       
   108                 else if ( value == TArmInstructionSet.ETHUMB )
       
   109                 {
       
   110                     // Set CPSR Thumb bit
       
   111                     CPSR.Value |= 0x00000020;
       
   112                 }
       
   113             }
       
   114         }
       
   115 
       
   116         public ArmRegister this[ TArmRegisterType aType ]
       
   117         {
       
   118             get { return iRegisters[ aType ]; }
       
   119         }
       
   120         #endregion
       
   121 
       
   122         #region Data members
       
   123         private ArmRegisterCollection iRegisters = new ArmRegisterCollection();
       
   124         #endregion
       
   125     }
       
   126 }