os/kernelhwsrv/kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @internalComponent
sl@0
    21
 @released
sl@0
    22
*/
sl@0
    23
sl@0
    24
#ifndef D_RMD_STEPPING_INL
sl@0
    25
#define D_RMD_STEPPING_INL
sl@0
    26
sl@0
    27
//
sl@0
    28
// IsBitSet
sl@0
    29
//
sl@0
    30
// Returns 1 if the bit 'aNum' is set within aBitset, 0 otherwise
sl@0
    31
inline TUint32 DRMDStepping::IsBitSet(const TUint32 aBitset, const TUint8 aNum)
sl@0
    32
	{
sl@0
    33
	return (aBitset & (1 << aNum) );
sl@0
    34
	}
sl@0
    35
sl@0
    36
// 
sl@0
    37
// BitCount
sl@0
    38
//
sl@0
    39
// Count number of bits in aVal
sl@0
    40
inline TUint32 DRMDStepping::BitCount(const TUint32 aVal)
sl@0
    41
	{
sl@0
    42
	TUint32 num = 0;
sl@0
    43
sl@0
    44
	for(TInt i = 0; i < 32; i++)
sl@0
    45
		{
sl@0
    46
		if ((1 << i) & aVal)
sl@0
    47
			{
sl@0
    48
			num++;
sl@0
    49
			}
sl@0
    50
		}
sl@0
    51
	return num;
sl@0
    52
	}
sl@0
    53
sl@0
    54
//
sl@0
    55
// Thumb2 opcode decoding
sl@0
    56
//
sl@0
    57
// Special data instructions and branch and exchange.
sl@0
    58
//
sl@0
    59
// Returns Opcode as defined in ARM ARM DDI0406A, section A6.2.3
sl@0
    60
inline TUint16 DRMDStepping::t2opcode16special(const TUint16 aInst)
sl@0
    61
	{
sl@0
    62
	TUint8 aVal = (aInst & 0x03C0) >> 5;
sl@0
    63
sl@0
    64
	return aVal;
sl@0
    65
	}
sl@0
    66
sl@0
    67
sl@0
    68
// Thumb2 opcode decoding instructions
sl@0
    69
// 
sl@0
    70
// Returns Opcode as defined in ARM ARM DDI0406A, section A6.2
sl@0
    71
// 16-bit Thumb instruction encoding
sl@0
    72
inline TUint16 DRMDStepping::t2opcode16(const TUint16 aInst)
sl@0
    73
{
sl@0
    74
	TUint16 aVal = (aInst & 0xFC00) >> 9;
sl@0
    75
sl@0
    76
	return aVal;
sl@0
    77
}
sl@0
    78
sl@0
    79
// ARM opcode decoding functions
sl@0
    80
inline TUint32 DRMDStepping::arm_opcode(const TUint32 aInst)
sl@0
    81
{
sl@0
    82
// #define ARM_OPCODE(x)		(((TUint32)(x) & 0x0E000000) >> 25)
sl@0
    83
sl@0
    84
	TUint32 aVal = ((aInst) & 0x0E000000) >> 25;
sl@0
    85
sl@0
    86
	return aVal;
sl@0
    87
}
sl@0
    88
sl@0
    89
inline TUint32 DRMDStepping:: arm_rm(const TUint32 aInst)
sl@0
    90
{
sl@0
    91
//#define ARM_RM(x)				((TUint32)(x) & 0x0000000F)			// bit 0- 4
sl@0
    92
sl@0
    93
	TUint32 aVal = (aInst) & 0x0000000F;
sl@0
    94
sl@0
    95
	return aVal;
sl@0
    96
}
sl@0
    97
sl@0
    98
inline TUint32 DRMDStepping:: arm_rs(const TUint32 aInst)
sl@0
    99
{
sl@0
   100
//#define ARM_RS(x)				(((TUint32)(x) & 0x00000F00) >> 8)	// bit 8-11
sl@0
   101
sl@0
   102
	TUint32 aVal = ((aInst) & 0x00000F00) >> 8;
sl@0
   103
sl@0
   104
	return aVal;
sl@0
   105
}
sl@0
   106
sl@0
   107
inline TUint32 DRMDStepping:: arm_rd(const TUint32 aInst)
sl@0
   108
{
sl@0
   109
//#define ARM_RD(x)				(((TUint32)(x) & 0x0000F000) >> 12)	// bit 12-15
sl@0
   110
sl@0
   111
	TUint32 aVal = ((aInst) & 0x0000F000) >> 12;
sl@0
   112
sl@0
   113
	return aVal;
sl@0
   114
}
sl@0
   115
sl@0
   116
inline TUint32 DRMDStepping:: arm_rn(const TUint32 aInst)
sl@0
   117
{
sl@0
   118
//#define ARM_RN(x)				(((TUint32)(x) & 0x000F0000) >> 16)	// bit 16-19
sl@0
   119
sl@0
   120
	TUint32 aVal = ((aInst) & 0x000F0000) >> 16;
sl@0
   121
sl@0
   122
	return aVal;
sl@0
   123
}
sl@0
   124
sl@0
   125
inline TUint32 DRMDStepping::arm_load(const TUint32 aInst)
sl@0
   126
{
sl@0
   127
//#define ARM_LOAD(x)				(((TUint32)(x) & 0x00100000) >> 20)	// bit 20
sl@0
   128
sl@0
   129
	TUint32 aVal = ((aInst) & 0x00100000) >> 20;
sl@0
   130
sl@0
   131
	return aVal;
sl@0
   132
}
sl@0
   133
sl@0
   134
// Data processing instruction defines
sl@0
   135
inline TUint32 DRMDStepping::arm_data_shift(const TUint32 aInst)
sl@0
   136
{
sl@0
   137
//#define ARM_DATA_SHIFT(x)		(((TUint32)(x) & 0x00000060) >> 5) 	// bit 5- 6
sl@0
   138
	
sl@0
   139
	TUint32 aVal = ((aInst) & 0x00000060) >> 5;
sl@0
   140
sl@0
   141
	return aVal;
sl@0
   142
}
sl@0
   143
sl@0
   144
inline TUint32 DRMDStepping::arm_data_c(const TUint32 aInst)
sl@0
   145
{
sl@0
   146
//#define ARM_DATA_C(x)			(((TUint32)(x) & 0x00000F80) >> 7) 	// bit 7-11
sl@0
   147
sl@0
   148
	TUint32 aVal = ((aInst) & 0x00000F80) >> 7;
sl@0
   149
sl@0
   150
	return aVal;
sl@0
   151
}
sl@0
   152
sl@0
   153
inline TUint32 DRMDStepping::arm_data_imm(const TUint32 aInst)
sl@0
   154
{
sl@0
   155
//#define ARM_DATA_IMM(x)			((TUint32)(x) & 0x000000FF)			// bit 0-7
sl@0
   156
sl@0
   157
	TUint32 aVal = (aInst) & 0x000000FF;
sl@0
   158
sl@0
   159
	return aVal;
sl@0
   160
}
sl@0
   161
sl@0
   162
inline TUint32 DRMDStepping::arm_data_rot(const TUint32 aInst)
sl@0
   163
{
sl@0
   164
//#define ARM_DATA_ROT(x)			(((TUint32)(x) & 0x00000F00) >> 8) 	// bit 8-11
sl@0
   165
sl@0
   166
	TUint32 aVal = ((aInst) & 0x00000F00) >> 8;
sl@0
   167
sl@0
   168
	return aVal;
sl@0
   169
}
sl@0
   170
sl@0
   171
// Single date transfer instruction defines
sl@0
   172
inline TUint32 DRMDStepping::arm_single_imm(const TUint32 aInst)
sl@0
   173
{
sl@0
   174
//#define ARM_SINGLE_IMM(x)		((TUint32)(x) & 0x00000FFF)			// bit 0-11
sl@0
   175
sl@0
   176
	TUint32 aVal = (aInst) & 0x00000FFF;
sl@0
   177
sl@0
   178
	return aVal;
sl@0
   179
}
sl@0
   180
sl@0
   181
inline TUint32 DRMDStepping::arm_single_byte(const TUint32 aInst)
sl@0
   182
{
sl@0
   183
//#define ARM_SINGLE_BYTE(x)		(((TUint32)(x) & 0x00400000) >> 22)	// bit 22
sl@0
   184
sl@0
   185
	TUint32 aVal = ((aInst) & 0x00400000) >> 22;
sl@0
   186
sl@0
   187
	return aVal;
sl@0
   188
}
sl@0
   189
sl@0
   190
inline TUint32 DRMDStepping::arm_single_u(const TUint32 aInst)
sl@0
   191
{
sl@0
   192
//#define ARM_SINGLE_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
sl@0
   193
sl@0
   194
	TUint32 aVal = ((aInst) & 0x00800000) >> 23;
sl@0
   195
sl@0
   196
	return aVal;
sl@0
   197
}
sl@0
   198
sl@0
   199
inline TUint32 DRMDStepping::arm_single_pre(const TUint32 aInst)
sl@0
   200
{
sl@0
   201
//#define ARM_SINGLE_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
sl@0
   202
sl@0
   203
	TUint32 aVal = ((aInst) & 0x01000000) >> 24;
sl@0
   204
sl@0
   205
	return aVal;
sl@0
   206
}
sl@0
   207
sl@0
   208
// Block data transfer instruction defines
sl@0
   209
inline TUint32 DRMDStepping::arm_block_reglist(const TUint32 aInst)
sl@0
   210
{
sl@0
   211
//#define ARM_BLOCK_REGLIST(x)	((TUint32)(x) & 0x0000FFFF)		// bit 0-15
sl@0
   212
sl@0
   213
	TUint32 aVal = (aInst) & 0x0000FFFF;
sl@0
   214
sl@0
   215
	return aVal;
sl@0
   216
}
sl@0
   217
sl@0
   218
inline TUint32 DRMDStepping::arm_block_u(const TUint32 aInst)
sl@0
   219
{
sl@0
   220
//#define ARM_BLOCK_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
sl@0
   221
sl@0
   222
	TUint32 aVal = ((aInst) & 0x00800000) >> 23;
sl@0
   223
sl@0
   224
	return aVal;
sl@0
   225
}
sl@0
   226
sl@0
   227
inline TUint32 DRMDStepping::arm_block_pre(const TUint32 aInst)
sl@0
   228
{
sl@0
   229
//#define ARM_BLOCK_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
sl@0
   230
sl@0
   231
	TUint32 aVal = ((aInst) & 0x01000000) >> 24;
sl@0
   232
sl@0
   233
	return aVal;
sl@0
   234
}
sl@0
   235
sl@0
   236
// Branch instruction defines
sl@0
   237
inline TUint32 DRMDStepping::arm_b_addr(const TUint32 aInst)
sl@0
   238
{
sl@0
   239
//#define ARM_B_ADDR(x)			((x & 0x00800000) ? ((TUint32)(x) & 0x00FFFFFF | 0xFF000000) : (TUint32)(x) & 0x00FFFFFF)
sl@0
   240
sl@0
   241
	TUint32 aVal = ((aInst & 0x00800000) ? ((TUint32)(aInst) & 0x00FFFFFF | 0xFF000000) : (TUint32)(aInst) & 0x00FFFFFF);
sl@0
   242
sl@0
   243
	return aVal;
sl@0
   244
}
sl@0
   245
sl@0
   246
inline TUint32 DRMDStepping::arm_instr_b_dest(const TUint32 aInst, TUint32& aAddress)
sl@0
   247
{
sl@0
   248
//#define ARM_INSTR_B_DEST(x,a)	(ARM_B_ADDR(x) << 2) + ((TUint32)(a) + 8)
sl@0
   249
sl@0
   250
	TUint32 aVal = (arm_b_addr(aInst) << 2) + ((TUint32)(aAddress) + 8);
sl@0
   251
sl@0
   252
	return aVal;
sl@0
   253
}
sl@0
   254
sl@0
   255
inline TUint32 DRMDStepping::thumb_b_addr(const TUint32 aInst)
sl@0
   256
{
sl@0
   257
//#define THUMB_B_ADDR(x) ((x & 0x0400) ? ((((TUint32)(x) & 0x07FF)<<11) | (((TUint32)(x) & 0x07FF0000)>>16) | 0xFFC00000) :\
sl@0
   258
                                            ((TUint32)(x) & 0x07FF)<<11) | (((TUint32)(x) & 0x07FF0000)>>16)
sl@0
   259
sl@0
   260
	TUint32 aVal = ((((TUint32)(aInst) & 0x07FF)<<11) | ((TUint32)(aInst) & 0x07FF0000)>>16);
sl@0
   261
sl@0
   262
	return ((aInst & 0x0400) ? (aVal | 0xFFC00000) : aVal);
sl@0
   263
}
sl@0
   264
sl@0
   265
inline TUint32 DRMDStepping::thumb_instr_b_dest(const TUint32 aInst, TUint32& aAddress)
sl@0
   266
{
sl@0
   267
//#define THUMB_INSTR_B_DEST(x,a)	(THUMB_B_ADDR(x) << 1) + ((TUint32)(a) + 4)
sl@0
   268
sl@0
   269
	TUint32 aVal = (thumb_b_addr(aInst) << 1) + ((TUint32)(aAddress) + 4);
sl@0
   270
sl@0
   271
	return aVal;
sl@0
   272
}
sl@0
   273
sl@0
   274
inline TUint32 DRMDStepping::arm_carry_bit(void)
sl@0
   275
{
sl@0
   276
//#define ARM_CARRY_BIT			0x20000000	// bit 30
sl@0
   277
sl@0
   278
	TUint32 aVal = 0x20000000;
sl@0
   279
sl@0
   280
	return aVal;
sl@0
   281
}
sl@0
   282
sl@0
   283
// Thumb instruction bitmasks
sl@0
   284
inline TUint16 DRMDStepping::thumb_opcode(const TUint16 aInst)
sl@0
   285
{
sl@0
   286
//	#define THUMB_OPCODE(x)		(((TUint16)(x) & 0xF800) >> 11)
sl@0
   287
sl@0
   288
	TUint16 aVal = ((aInst) & 0xF800) >> 11;
sl@0
   289
sl@0
   290
	return aVal;
sl@0
   291
}
sl@0
   292
sl@0
   293
inline TUint16 DRMDStepping::thumb_inst_7_15(const TUint16 aInst)
sl@0
   294
{
sl@0
   295
//	#define THUMB_INST_7_15(x)	(((TUint16)(x) & 0xFF80) >> 7)
sl@0
   296
sl@0
   297
	TUint16 aVal = ((aInst) & 0xFF80) >> 7;
sl@0
   298
sl@0
   299
	return aVal;
sl@0
   300
}
sl@0
   301
sl@0
   302
inline TUint16 DRMDStepping::thumb_inst_8_15(const TUint16 aInst)
sl@0
   303
{
sl@0
   304
//	#define THUMB_INST_8_15(x)	(((TUint16)(x) & 0xFF00) >> 8)
sl@0
   305
sl@0
   306
	TUint16 aVal = ((aInst) & 0xFF00) >> 8;
sl@0
   307
sl@0
   308
	return aVal;
sl@0
   309
}
sl@0
   310
sl@0
   311
#endif	// D_RMD_STEPPPING_INL
sl@0
   312
sl@0
   313
// End of file - d-rmd-stepping.inl