Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #ifndef D_RMD_STEPPING_INL
25 #define D_RMD_STEPPING_INL
30 // Returns 1 if the bit 'aNum' is set within aBitset, 0 otherwise
31 inline TUint32 DRMDStepping::IsBitSet(const TUint32 aBitset, const TUint8 aNum)
33 return (aBitset & (1 << aNum) );
39 // Count number of bits in aVal
40 inline TUint32 DRMDStepping::BitCount(const TUint32 aVal)
44 for(TInt i = 0; i < 32; i++)
55 // Thumb2 opcode decoding
57 // Special data instructions and branch and exchange.
59 // Returns Opcode as defined in ARM ARM DDI0406A, section A6.2.3
60 inline TUint16 DRMDStepping::t2opcode16special(const TUint16 aInst)
62 TUint8 aVal = (aInst & 0x03C0) >> 5;
68 // Thumb2 opcode decoding instructions
70 // Returns Opcode as defined in ARM ARM DDI0406A, section A6.2
71 // 16-bit Thumb instruction encoding
72 inline TUint16 DRMDStepping::t2opcode16(const TUint16 aInst)
74 TUint16 aVal = (aInst & 0xFC00) >> 9;
79 // ARM opcode decoding functions
80 inline TUint32 DRMDStepping::arm_opcode(const TUint32 aInst)
82 // #define ARM_OPCODE(x) (((TUint32)(x) & 0x0E000000) >> 25)
84 TUint32 aVal = ((aInst) & 0x0E000000) >> 25;
89 inline TUint32 DRMDStepping:: arm_rm(const TUint32 aInst)
91 //#define ARM_RM(x) ((TUint32)(x) & 0x0000000F) // bit 0- 4
93 TUint32 aVal = (aInst) & 0x0000000F;
98 inline TUint32 DRMDStepping:: arm_rs(const TUint32 aInst)
100 //#define ARM_RS(x) (((TUint32)(x) & 0x00000F00) >> 8) // bit 8-11
102 TUint32 aVal = ((aInst) & 0x00000F00) >> 8;
107 inline TUint32 DRMDStepping:: arm_rd(const TUint32 aInst)
109 //#define ARM_RD(x) (((TUint32)(x) & 0x0000F000) >> 12) // bit 12-15
111 TUint32 aVal = ((aInst) & 0x0000F000) >> 12;
116 inline TUint32 DRMDStepping:: arm_rn(const TUint32 aInst)
118 //#define ARM_RN(x) (((TUint32)(x) & 0x000F0000) >> 16) // bit 16-19
120 TUint32 aVal = ((aInst) & 0x000F0000) >> 16;
125 inline TUint32 DRMDStepping::arm_load(const TUint32 aInst)
127 //#define ARM_LOAD(x) (((TUint32)(x) & 0x00100000) >> 20) // bit 20
129 TUint32 aVal = ((aInst) & 0x00100000) >> 20;
134 // Data processing instruction defines
135 inline TUint32 DRMDStepping::arm_data_shift(const TUint32 aInst)
137 //#define ARM_DATA_SHIFT(x) (((TUint32)(x) & 0x00000060) >> 5) // bit 5- 6
139 TUint32 aVal = ((aInst) & 0x00000060) >> 5;
144 inline TUint32 DRMDStepping::arm_data_c(const TUint32 aInst)
146 //#define ARM_DATA_C(x) (((TUint32)(x) & 0x00000F80) >> 7) // bit 7-11
148 TUint32 aVal = ((aInst) & 0x00000F80) >> 7;
153 inline TUint32 DRMDStepping::arm_data_imm(const TUint32 aInst)
155 //#define ARM_DATA_IMM(x) ((TUint32)(x) & 0x000000FF) // bit 0-7
157 TUint32 aVal = (aInst) & 0x000000FF;
162 inline TUint32 DRMDStepping::arm_data_rot(const TUint32 aInst)
164 //#define ARM_DATA_ROT(x) (((TUint32)(x) & 0x00000F00) >> 8) // bit 8-11
166 TUint32 aVal = ((aInst) & 0x00000F00) >> 8;
171 // Single date transfer instruction defines
172 inline TUint32 DRMDStepping::arm_single_imm(const TUint32 aInst)
174 //#define ARM_SINGLE_IMM(x) ((TUint32)(x) & 0x00000FFF) // bit 0-11
176 TUint32 aVal = (aInst) & 0x00000FFF;
181 inline TUint32 DRMDStepping::arm_single_byte(const TUint32 aInst)
183 //#define ARM_SINGLE_BYTE(x) (((TUint32)(x) & 0x00400000) >> 22) // bit 22
185 TUint32 aVal = ((aInst) & 0x00400000) >> 22;
190 inline TUint32 DRMDStepping::arm_single_u(const TUint32 aInst)
192 //#define ARM_SINGLE_U(x) (((TUint32)(x) & 0x00800000) >> 23) // bit 23
194 TUint32 aVal = ((aInst) & 0x00800000) >> 23;
199 inline TUint32 DRMDStepping::arm_single_pre(const TUint32 aInst)
201 //#define ARM_SINGLE_PRE(x) (((TUint32)(x) & 0x01000000) >> 24) // bit 24
203 TUint32 aVal = ((aInst) & 0x01000000) >> 24;
208 // Block data transfer instruction defines
209 inline TUint32 DRMDStepping::arm_block_reglist(const TUint32 aInst)
211 //#define ARM_BLOCK_REGLIST(x) ((TUint32)(x) & 0x0000FFFF) // bit 0-15
213 TUint32 aVal = (aInst) & 0x0000FFFF;
218 inline TUint32 DRMDStepping::arm_block_u(const TUint32 aInst)
220 //#define ARM_BLOCK_U(x) (((TUint32)(x) & 0x00800000) >> 23) // bit 23
222 TUint32 aVal = ((aInst) & 0x00800000) >> 23;
227 inline TUint32 DRMDStepping::arm_block_pre(const TUint32 aInst)
229 //#define ARM_BLOCK_PRE(x) (((TUint32)(x) & 0x01000000) >> 24) // bit 24
231 TUint32 aVal = ((aInst) & 0x01000000) >> 24;
236 // Branch instruction defines
237 inline TUint32 DRMDStepping::arm_b_addr(const TUint32 aInst)
239 //#define ARM_B_ADDR(x) ((x & 0x00800000) ? ((TUint32)(x) & 0x00FFFFFF | 0xFF000000) : (TUint32)(x) & 0x00FFFFFF)
241 TUint32 aVal = ((aInst & 0x00800000) ? ((TUint32)(aInst) & 0x00FFFFFF | 0xFF000000) : (TUint32)(aInst) & 0x00FFFFFF);
246 inline TUint32 DRMDStepping::arm_instr_b_dest(const TUint32 aInst, TUint32& aAddress)
248 //#define ARM_INSTR_B_DEST(x,a) (ARM_B_ADDR(x) << 2) + ((TUint32)(a) + 8)
250 TUint32 aVal = (arm_b_addr(aInst) << 2) + ((TUint32)(aAddress) + 8);
255 inline TUint32 DRMDStepping::thumb_b_addr(const TUint32 aInst)
257 //#define THUMB_B_ADDR(x) ((x & 0x0400) ? ((((TUint32)(x) & 0x07FF)<<11) | (((TUint32)(x) & 0x07FF0000)>>16) | 0xFFC00000) :\
258 ((TUint32)(x) & 0x07FF)<<11) | (((TUint32)(x) & 0x07FF0000)>>16)
260 TUint32 aVal = ((((TUint32)(aInst) & 0x07FF)<<11) | ((TUint32)(aInst) & 0x07FF0000)>>16);
262 return ((aInst & 0x0400) ? (aVal | 0xFFC00000) : aVal);
265 inline TUint32 DRMDStepping::thumb_instr_b_dest(const TUint32 aInst, TUint32& aAddress)
267 //#define THUMB_INSTR_B_DEST(x,a) (THUMB_B_ADDR(x) << 1) + ((TUint32)(a) + 4)
269 TUint32 aVal = (thumb_b_addr(aInst) << 1) + ((TUint32)(aAddress) + 4);
274 inline TUint32 DRMDStepping::arm_carry_bit(void)
276 //#define ARM_CARRY_BIT 0x20000000 // bit 30
278 TUint32 aVal = 0x20000000;
283 // Thumb instruction bitmasks
284 inline TUint16 DRMDStepping::thumb_opcode(const TUint16 aInst)
286 // #define THUMB_OPCODE(x) (((TUint16)(x) & 0xF800) >> 11)
288 TUint16 aVal = ((aInst) & 0xF800) >> 11;
293 inline TUint16 DRMDStepping::thumb_inst_7_15(const TUint16 aInst)
295 // #define THUMB_INST_7_15(x) (((TUint16)(x) & 0xFF80) >> 7)
297 TUint16 aVal = ((aInst) & 0xFF80) >> 7;
302 inline TUint16 DRMDStepping::thumb_inst_8_15(const TUint16 aInst)
304 // #define THUMB_INST_8_15(x) (((TUint16)(x) & 0xFF00) >> 8)
306 TUint16 aVal = ((aInst) & 0xFF00) >> 8;
311 #endif // D_RMD_STEPPPING_INL
313 // End of file - d-rmd-stepping.inl