jump_label.h 956 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (c) 2010 Cavium Networks, Inc.
  7. */
  8. #ifndef _ASM_MIPS_JUMP_LABEL_H
  9. #define _ASM_MIPS_JUMP_LABEL_H
  10. #include <linux/types.h>
  11. #ifdef __KERNEL__
  12. #define JUMP_LABEL_NOP_SIZE 4
  13. #ifdef CONFIG_64BIT
  14. #define WORD_INSN ".dword"
  15. #else
  16. #define WORD_INSN ".word"
  17. #endif
  18. #define JUMP_LABEL(key, label) \
  19. do { \
  20. asm goto("1:\tnop\n\t" \
  21. "nop\n\t" \
  22. ".pushsection __jump_table, \"a\"\n\t" \
  23. WORD_INSN " 1b, %l[" #label "], %0\n\t" \
  24. ".popsection\n\t" \
  25. : : "i" (key) : : label); \
  26. } while (0)
  27. #endif /* __KERNEL__ */
  28. #ifdef CONFIG_64BIT
  29. typedef u64 jump_label_t;
  30. #else
  31. typedef u32 jump_label_t;
  32. #endif
  33. struct jump_entry {
  34. jump_label_t code;
  35. jump_label_t target;
  36. jump_label_t key;
  37. };
  38. #endif /* _ASM_MIPS_JUMP_LABEL_H */