crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianInstructionLib/Arm/Instructions/Arm/DataTransfer/Arm_LDM.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 SymbianUtils.BasicTypes;
       
    21 using SymbianStructuresLib.Arm.Registers;
       
    22 using SymbianStructuresLib.Arm.Instructions;
       
    23 using SymbianInstructionLib.Arm.Instructions.Common;
       
    24 
       
    25 namespace SymbianInstructionLib.Arm.Instructions.Arm.DataTransfer
       
    26 {
       
    27     [ArmRefAttribute( "A4.1.20 LDM(1) + A5.4.1 Encoding", "LDM{<cond>}<addressing_mode> <Rn>{!}, <registers>" )]
       
    28     public class Arm_LDM : Arm_LoadOrStoreMultiple_GP
       
    29     {
       
    30         #region Enumerations
       
    31         public enum TType
       
    32         {
       
    33             ETypeNotSupported = -1,
       
    34             ETypeNonEmptyGP = 0,
       
    35             ETypeUserModeWhenInPrivilaged,
       
    36             ETypeGPAndPCAndUpdateCPSR
       
    37         }
       
    38         #endregion
       
    39 
       
    40         #region Constructors
       
    41         public Arm_LDM()
       
    42         {
       
    43             //  4    3                  4               16 bits
       
    44             // ---------------------------------------------------
       
    45             // cond 100 P U S W L       Rn          register list
       
    46             // 1110 100 0 1 0 1 1     1101         1000111111110000
       
    47             //
       
    48             // P  = indicates that the word addressed by Rn is included in the range of memory
       
    49             //      locations accessed, lying at the top (U==0) or bottom (U==1) of that range.
       
    50             //
       
    51             // U  = Indicates that the transfer is made upwards (U==1) or downwards (U==0) from 
       
    52             //      the base register.
       
    53             //
       
    54             // S  = For LDMs that load the PC, the S bit indicates that the CPSR is loaded 
       
    55             //      from the SPSR.
       
    56             //
       
    57             // W  = Indicates that the base register is updated after the transfer. The base 
       
    58             //      register is incremented (U==1) or decremented (U==0) by four times the 
       
    59             //      number of registers in the register list.
       
    60             //
       
    61             // L  = Distinguishes between Load (L==1) and Store (L==0) instructions.
       
    62             //
       
    63             // Rn = Specifies the base register used by <addressing_mode>. Using R15 as 
       
    64             //      the base register <Rn> gives an UNPREDICTABLE result.
       
    65             // 
       
    66             // This mask translates to "LDM's that load PC from SP"
       
    67             //        1110 100 01011 1101    1000111111110000
       
    68             base.SetMask( "####" + "100" + "##" + "##1" + "####" + "######## ########" );
       
    69         }
       
    70         #endregion
       
    71 
       
    72         #region From ArmInstruction
       
    73         public override bool Matches( uint aOpCode )
       
    74         {
       
    75             bool match = base.Matches( aOpCode );
       
    76             if ( match )
       
    77             {
       
    78                 TType type = StaticInternalType( aOpCode );
       
    79                 match = ( type != TType.ETypeNotSupported );
       
    80             }
       
    81             return match;
       
    82         }
       
    83         #endregion
       
    84 
       
    85         #region From Arm_LoadOrStore
       
    86         public override TArmDataTransferType DataTransferType
       
    87         {
       
    88             get { return TArmDataTransferType.ELoad; }
       
    89         }
       
    90         #endregion
       
    91 
       
    92         #region Properties
       
    93         public TType Type
       
    94         {
       
    95             get { return iType; }
       
    96         }
       
    97         #endregion
       
    98 
       
    99         #region From ArmBaseInstruction
       
   100         protected override void OnRawValueAssigned()
       
   101         {
       
   102             base.OnRawValueAssigned();
       
   103             iType = InternalType;
       
   104         }
       
   105         #endregion
       
   106 
       
   107         #region Internal methods
       
   108         private new SymBit SBit // Hide
       
   109         {
       
   110             get { return SymBit.EClear; }
       
   111         }
       
   112 
       
   113         private TType InternalType
       
   114         {
       
   115             get
       
   116             {
       
   117                 uint raw = base.AIRawValue;
       
   118                 TType ret = StaticInternalType( raw );
       
   119                 return ret;
       
   120             }
       
   121         }
       
   122 
       
   123         private static TType StaticInternalType( uint aRaw )
       
   124         {
       
   125             TType ret = TType.ETypeNotSupported;
       
   126             //
       
   127             if ( KLDM1.IsMatch( aRaw ) )
       
   128             {
       
   129                 ret = TType.ETypeNonEmptyGP;
       
   130             }
       
   131             else if ( KLDM2.IsMatch( aRaw ) )
       
   132             {
       
   133                 ret = TType.ETypeUserModeWhenInPrivilaged;
       
   134             }
       
   135             else if ( KLDM3.IsMatch( aRaw ) )
       
   136             {
       
   137                 ret = TType.ETypeGPAndPCAndUpdateCPSR;
       
   138             }
       
   139             //
       
   140             return ret;
       
   141         }
       
   142         #endregion
       
   143 
       
   144         #region Data members
       
   145         private TType iType = TType.ETypeNotSupported;
       
   146         private static readonly SymMask KLDM1 = new SymMask( "####" + "100" + "##" + "0#1" + "####" + "######## ########" );
       
   147         private static readonly SymMask KLDM2 = new SymMask( "####" + "100" + "##" + "101" + "####" + "0####### ########" );
       
   148         private static readonly SymMask KLDM3 = new SymMask( "####" + "100" + "##" + "1#1" + "####" + "1####### ########" );
       
   149         #endregion
       
   150     }
       
   151 }
       
   152