0001
0002
0003
0004
0005
0006 #ifndef __ASM_ARM_OPCODES_H
0007 #define __ASM_ARM_OPCODES_H
0008
0009 #ifndef __ASSEMBLY__
0010 #include <linux/linkage.h>
0011 extern asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr);
0012 #endif
0013
0014 #define ARM_OPCODE_CONDTEST_FAIL 0
0015 #define ARM_OPCODE_CONDTEST_PASS 1
0016 #define ARM_OPCODE_CONDTEST_UNCOND 2
0017
0018
0019
0020
0021
0022
0023
0024 #define ___asm_opcode_swab32(x) ( \
0025 (((x) << 24) & 0xFF000000) \
0026 | (((x) << 8) & 0x00FF0000) \
0027 | (((x) >> 8) & 0x0000FF00) \
0028 | (((x) >> 24) & 0x000000FF) \
0029 )
0030 #define ___asm_opcode_swab16(x) ( \
0031 (((x) << 8) & 0xFF00) \
0032 | (((x) >> 8) & 0x00FF) \
0033 )
0034 #define ___asm_opcode_swahb32(x) ( \
0035 (((x) << 8) & 0xFF00FF00) \
0036 | (((x) >> 8) & 0x00FF00FF) \
0037 )
0038 #define ___asm_opcode_swahw32(x) ( \
0039 (((x) << 16) & 0xFFFF0000) \
0040 | (((x) >> 16) & 0x0000FFFF) \
0041 )
0042 #define ___asm_opcode_identity32(x) ((x) & 0xFFFFFFFF)
0043 #define ___asm_opcode_identity16(x) ((x) & 0xFFFF)
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 #ifdef __ASSEMBLY__
0075
0076 #define ___opcode_swab32(x) ___asm_opcode_swab32(x)
0077 #define ___opcode_swab16(x) ___asm_opcode_swab16(x)
0078 #define ___opcode_swahb32(x) ___asm_opcode_swahb32(x)
0079 #define ___opcode_swahw32(x) ___asm_opcode_swahw32(x)
0080 #define ___opcode_identity32(x) ___asm_opcode_identity32(x)
0081 #define ___opcode_identity16(x) ___asm_opcode_identity16(x)
0082
0083 #else
0084
0085 #include <linux/types.h>
0086 #include <linux/swab.h>
0087
0088 #define ___opcode_swab32(x) swab32(x)
0089 #define ___opcode_swab16(x) swab16(x)
0090 #define ___opcode_swahb32(x) swahb32(x)
0091 #define ___opcode_swahw32(x) swahw32(x)
0092 #define ___opcode_identity32(x) ((u32)(x))
0093 #define ___opcode_identity16(x) ((u16)(x))
0094
0095 #endif
0096
0097
0098 #ifdef CONFIG_CPU_ENDIAN_BE8
0099
0100 #define __opcode_to_mem_arm(x) ___opcode_swab32(x)
0101 #define __opcode_to_mem_thumb16(x) ___opcode_swab16(x)
0102 #define __opcode_to_mem_thumb32(x) ___opcode_swahb32(x)
0103 #define ___asm_opcode_to_mem_arm(x) ___asm_opcode_swab32(x)
0104 #define ___asm_opcode_to_mem_thumb16(x) ___asm_opcode_swab16(x)
0105 #define ___asm_opcode_to_mem_thumb32(x) ___asm_opcode_swahb32(x)
0106
0107 #else
0108
0109 #define __opcode_to_mem_arm(x) ___opcode_identity32(x)
0110 #define __opcode_to_mem_thumb16(x) ___opcode_identity16(x)
0111 #define ___asm_opcode_to_mem_arm(x) ___asm_opcode_identity32(x)
0112 #define ___asm_opcode_to_mem_thumb16(x) ___asm_opcode_identity16(x)
0113 #ifdef CONFIG_CPU_ENDIAN_BE32
0114 #ifndef __ASSEMBLY__
0115
0116
0117
0118
0119
0120
0121 extern __u32 __opcode_to_mem_thumb32(__u32);
0122 #endif
0123 #else
0124 #define __opcode_to_mem_thumb32(x) ___opcode_swahw32(x)
0125 #define ___asm_opcode_to_mem_thumb32(x) ___asm_opcode_swahw32(x)
0126 #endif
0127
0128 #endif
0129
0130 #define __mem_to_opcode_arm(x) __opcode_to_mem_arm(x)
0131 #define __mem_to_opcode_thumb16(x) __opcode_to_mem_thumb16(x)
0132 #ifndef CONFIG_CPU_ENDIAN_BE32
0133 #define __mem_to_opcode_thumb32(x) __opcode_to_mem_thumb32(x)
0134 #endif
0135
0136
0137
0138
0139 #define __opcode_is_thumb32(x) ( \
0140 ((x) & 0xF8000000) == 0xE8000000 \
0141 || ((x) & 0xF0000000) == 0xF0000000 \
0142 )
0143 #define __opcode_is_thumb16(x) ( \
0144 ((x) & 0xFFFF0000) == 0 \
0145 && !(((x) & 0xF800) == 0xE800 || ((x) & 0xF000) == 0xF000) \
0146 )
0147
0148
0149 #define __opcode_thumb32_first(x) (___opcode_identity16((x) >> 16))
0150 #define __opcode_thumb32_second(x) (___opcode_identity16(x))
0151 #define __opcode_thumb32_compose(first, second) ( \
0152 (___opcode_identity32(___opcode_identity16(first)) << 16) \
0153 | ___opcode_identity32(___opcode_identity16(second)) \
0154 )
0155 #define ___asm_opcode_thumb32_first(x) (___asm_opcode_identity16((x) >> 16))
0156 #define ___asm_opcode_thumb32_second(x) (___asm_opcode_identity16(x))
0157 #define ___asm_opcode_thumb32_compose(first, second) ( \
0158 (___asm_opcode_identity32(___asm_opcode_identity16(first)) << 16) \
0159 | ___asm_opcode_identity32(___asm_opcode_identity16(second)) \
0160 )
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202 #include <linux/stringify.h>
0203
0204 #define __inst_arm(x) ___inst_arm(___asm_opcode_to_mem_arm(x))
0205 #define __inst_thumb32(x) ___inst_thumb32( \
0206 ___asm_opcode_to_mem_thumb16(___asm_opcode_thumb32_first(x)), \
0207 ___asm_opcode_to_mem_thumb16(___asm_opcode_thumb32_second(x)) \
0208 )
0209 #define __inst_thumb16(x) ___inst_thumb16(___asm_opcode_to_mem_thumb16(x))
0210
0211 #ifdef CONFIG_THUMB2_KERNEL
0212 #define __inst_arm_thumb16(arm_opcode, thumb_opcode) \
0213 __inst_thumb16(thumb_opcode)
0214 #define __inst_arm_thumb32(arm_opcode, thumb_opcode) \
0215 __inst_thumb32(thumb_opcode)
0216 #else
0217 #define __inst_arm_thumb16(arm_opcode, thumb_opcode) __inst_arm(arm_opcode)
0218 #define __inst_arm_thumb32(arm_opcode, thumb_opcode) __inst_arm(arm_opcode)
0219 #endif
0220
0221
0222 #ifdef __ASSEMBLY__
0223 #define ___inst_arm(x) .long x
0224 #define ___inst_thumb16(x) .short x
0225 #define ___inst_thumb32(first, second) .short first, second
0226 #else
0227 #define ___inst_arm(x) ".long " __stringify(x) "\n\t"
0228 #define ___inst_thumb16(x) ".short " __stringify(x) "\n\t"
0229 #define ___inst_thumb32(first, second) \
0230 ".short " __stringify(first) ", " __stringify(second) "\n\t"
0231 #endif
0232
0233 #endif