alternative-asm.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef __ASM_ALTERNATIVE_ASM_H
  2. #define __ASM_ALTERNATIVE_ASM_H
  3. #ifdef __ASSEMBLY__
  4. .macro altinstruction_entry orig_offset alt_offset feature orig_len alt_len
  5. .word \orig_offset - .
  6. .word \alt_offset - .
  7. .hword \feature
  8. .byte \orig_len
  9. .byte \alt_len
  10. .endm
  11. .macro alternative_insn insn1 insn2 cap
  12. 661: \insn1
  13. 662: .pushsection .altinstructions, "a"
  14. altinstruction_entry 661b, 663f, \cap, 662b-661b, 664f-663f
  15. .popsection
  16. .pushsection .altinstr_replacement, "ax"
  17. 663: \insn2
  18. 664: .popsection
  19. .if ((664b-663b) != (662b-661b))
  20. .error "Alternatives instruction length mismatch"
  21. .endif
  22. .endm
  23. .macro user_alternative_insn l insn1 insn2 cap
  24. 661 : \insn1
  25. 662 : .pushsection .altinstructions, "a"
  26. altinstruction_entry 661b, 663f, \cap, 662b-661b, 664f-663f
  27. .popsection
  28. .pushsection .altinstr_replacement, "ax"
  29. 663 : \insn2
  30. 664 : .popsection
  31. .if ((664b-663b) != (662b-661b))
  32. .error "Alternatives instruction length mismatch"
  33. .endif
  34. .pushsection __ex_table, "a"
  35. .align 3
  36. .quad 661b, \l
  37. .popsection
  38. .endm
  39. #endif /* __ASSEMBLY__ */
  40. #endif /* __ASM_ALTERNATIVE_ASM_H */