/* * Assembler opcode byteswap helpers. * These are only intended for use by this header: don't use them directly, * because they will be suboptimal in most cases.
*/ #define ___asm_opcode_swab32(x) ( \
(((x) << 24) & 0xFF000000) \
| (((x) << 8) & 0x00FF0000) \
| (((x) >> 8) & 0x0000FF00) \
| (((x) >> 24) & 0x000000FF) \
) #define ___asm_opcode_swab16(x) ( \
(((x) << 8) & 0xFF00) \
| (((x) >> 8) & 0x00FF) \
) #define ___asm_opcode_swahb32(x) ( \
(((x) << 8) & 0xFF00FF00) \
| (((x) >> 8) & 0x00FF00FF) \
) #define ___asm_opcode_swahw32(x) ( \
(((x) << 16) & 0xFFFF0000) \
| (((x) >> 16) & 0x0000FFFF) \
) #define ___asm_opcode_identity32(x) ((x) & 0xFFFFFFFF) #define ___asm_opcode_identity16(x) ((x) & 0xFFFF)
/* * Opcode byteswap helpers * * These macros help with converting instructions between a canonical integer * format and in-memory representation, in an endianness-agnostic manner. * * __mem_to_opcode_*() convert from in-memory representation to canonical form. * __opcode_to_mem_*() convert from canonical form to in-memory representation. * * * Canonical instruction representation: * * ARM: 0xKKLLMMNN * Thumb 16-bit: 0x0000KKLL, where KK < 0xE8 * Thumb 32-bit: 0xKKLLMMNN, where KK >= 0xE8 * * There is no way to distinguish an ARM instruction in canonical representation * from a Thumb instruction (just as these cannot be distinguished in memory). * Where this distinction is important, it needs to be tracked separately. * * Note that values in the range 0x0000E800..0xE7FFFFFF intentionally do not * represent any valid Thumb-2 instruction. For this range, * __opcode_is_thumb32() and __opcode_is_thumb16() will both be false. * * The ___asm variants are intended only for use by this header, in situations * involving inline assembler. For .S files, the normal __opcode_*() macros * should do the right thing.
*/ #ifdef __ASSEMBLY__
#define __opcode_to_mem_arm(x) ___opcode_identity32(x) #define __opcode_to_mem_thumb16(x) ___opcode_identity16(x) #define ___asm_opcode_to_mem_arm(x) ___asm_opcode_identity32(x) #define ___asm_opcode_to_mem_thumb16(x) ___asm_opcode_identity16(x) #ifdef CONFIG_CPU_ENDIAN_BE32 #ifndef __ASSEMBLY__ /* * On BE32 systems, using 32-bit accesses to store Thumb instructions will not * work in all cases, due to alignment constraints. For now, a correct * version is not provided for BE32, but the prototype needs to be there * to compile patch.c.
*/ extern __u32 __opcode_to_mem_thumb32(__u32); #endif #else #define __opcode_to_mem_thumb32(x) ___opcode_swahw32(x) #define ___asm_opcode_to_mem_thumb32(x) ___asm_opcode_swahw32(x) #endif
/* * Opcode injection helpers * * In rare cases it is necessary to assemble an opcode which the * assembler does not support directly, or which would normally be * rejected because of the CFLAGS or AFLAGS used to build the affected * file. * * Before using these macros, consider carefully whether it is feasible * instead to change the build flags for your file, or whether it really * makes sense to support old assembler versions when building that * particular kernel feature. * * The macros defined here should only be used where there is no viable * alternative. * * * __inst_arm(x): emit the specified ARM opcode * __inst_thumb16(x): emit the specified 16-bit Thumb opcode * __inst_thumb32(x): emit the specified 32-bit Thumb opcode * * __inst_arm_thumb16(arm, thumb): emit either the specified arm or * 16-bit Thumb opcode, depending on whether an ARM or Thumb-2 * kernel is being built * * __inst_arm_thumb32(arm, thumb): emit either the specified arm or * 32-bit Thumb opcode, depending on whether an ARM or Thumb-2 * kernel is being built * * * Note that using these macros directly is poor practice. Instead, you * should use them to define human-readable wrapper macros to encode the * instructions that you care about. In code which might run on ARMv7 or * above, you can usually use the __inst_arm_thumb{16,32} macros to * specify the ARM and Thumb alternatives at the same time. This ensures * that the correct opcode gets emitted depending on the instruction set * used for the kernel build. * * Look at opcodes-virt.h for an example of how to use these macros.
*/ #include <linux/stringify.h>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.