module.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_MODULE_H
  3. #define _ASM_MODULE_H
  4. #include <linux/list.h>
  5. #include <linux/elf.h>
  6. #include <asm/extable.h>
  7. struct mod_arch_specific {
  8. /* Data Bus Error exception tables */
  9. struct list_head dbe_list;
  10. const struct exception_table_entry *dbe_start;
  11. const struct exception_table_entry *dbe_end;
  12. struct mips_hi16 *r_mips_hi16_list;
  13. };
  14. typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */
  15. typedef struct {
  16. Elf64_Addr r_offset; /* Address of relocation. */
  17. Elf64_Word r_sym; /* Symbol index. */
  18. Elf64_Byte r_ssym; /* Special symbol. */
  19. Elf64_Byte r_type3; /* Third relocation. */
  20. Elf64_Byte r_type2; /* Second relocation. */
  21. Elf64_Byte r_type; /* First relocation. */
  22. } Elf64_Mips_Rel;
  23. typedef struct {
  24. Elf64_Addr r_offset; /* Address of relocation. */
  25. Elf64_Word r_sym; /* Symbol index. */
  26. Elf64_Byte r_ssym; /* Special symbol. */
  27. Elf64_Byte r_type3; /* Third relocation. */
  28. Elf64_Byte r_type2; /* Second relocation. */
  29. Elf64_Byte r_type; /* First relocation. */
  30. Elf64_Sxword r_addend; /* Addend. */
  31. } Elf64_Mips_Rela;
  32. #ifdef CONFIG_32BIT
  33. #define Elf_Shdr Elf32_Shdr
  34. #define Elf_Sym Elf32_Sym
  35. #define Elf_Ehdr Elf32_Ehdr
  36. #define Elf_Addr Elf32_Addr
  37. #define Elf_Rel Elf32_Rel
  38. #define Elf_Rela Elf32_Rela
  39. #define ELF_R_TYPE(X) ELF32_R_TYPE(X)
  40. #define ELF_R_SYM(X) ELF32_R_SYM(X)
  41. #define Elf_Mips_Rel Elf32_Rel
  42. #define Elf_Mips_Rela Elf32_Rela
  43. #define ELF_MIPS_R_SYM(rel) ELF32_R_SYM((rel).r_info)
  44. #define ELF_MIPS_R_TYPE(rel) ELF32_R_TYPE((rel).r_info)
  45. #endif
  46. #ifdef CONFIG_64BIT
  47. #define Elf_Shdr Elf64_Shdr
  48. #define Elf_Sym Elf64_Sym
  49. #define Elf_Ehdr Elf64_Ehdr
  50. #define Elf_Addr Elf64_Addr
  51. #define Elf_Rel Elf64_Rel
  52. #define Elf_Rela Elf64_Rela
  53. #define ELF_R_TYPE(X) ELF64_R_TYPE(X)
  54. #define ELF_R_SYM(X) ELF64_R_SYM(X)
  55. #define Elf_Mips_Rel Elf64_Mips_Rel
  56. #define Elf_Mips_Rela Elf64_Mips_Rela
  57. #define ELF_MIPS_R_SYM(rel) ((rel).r_sym)
  58. #define ELF_MIPS_R_TYPE(rel) ((rel).r_type)
  59. #endif
  60. #ifdef CONFIG_MODULES
  61. /* Given an address, look for it in the exception tables. */
  62. const struct exception_table_entry*search_module_dbetables(unsigned long addr);
  63. #else
  64. /* Given an address, look for it in the exception tables. */
  65. static inline const struct exception_table_entry *
  66. search_module_dbetables(unsigned long addr)
  67. {
  68. return NULL;
  69. }
  70. #endif
  71. #ifdef CONFIG_CPU_BMIPS
  72. #define MODULE_PROC_FAMILY "BMIPS "
  73. #elif defined CONFIG_CPU_MIPS32_R1
  74. #define MODULE_PROC_FAMILY "MIPS32_R1 "
  75. #elif defined CONFIG_CPU_MIPS32_R2
  76. #define MODULE_PROC_FAMILY "MIPS32_R2 "
  77. #elif defined CONFIG_CPU_MIPS32_R6
  78. #define MODULE_PROC_FAMILY "MIPS32_R6 "
  79. #elif defined CONFIG_CPU_MIPS64_R1
  80. #define MODULE_PROC_FAMILY "MIPS64_R1 "
  81. #elif defined CONFIG_CPU_MIPS64_R2
  82. #define MODULE_PROC_FAMILY "MIPS64_R2 "
  83. #elif defined CONFIG_CPU_MIPS64_R6
  84. #define MODULE_PROC_FAMILY "MIPS64_R6 "
  85. #elif defined CONFIG_CPU_R3000
  86. #define MODULE_PROC_FAMILY "R3000 "
  87. #elif defined CONFIG_CPU_TX39XX
  88. #define MODULE_PROC_FAMILY "TX39XX "
  89. #elif defined CONFIG_CPU_VR41XX
  90. #define MODULE_PROC_FAMILY "VR41XX "
  91. #elif defined CONFIG_CPU_R4300
  92. #define MODULE_PROC_FAMILY "R4300 "
  93. #elif defined CONFIG_CPU_R4X00
  94. #define MODULE_PROC_FAMILY "R4X00 "
  95. #elif defined CONFIG_CPU_TX49XX
  96. #define MODULE_PROC_FAMILY "TX49XX "
  97. #elif defined CONFIG_CPU_R5000
  98. #define MODULE_PROC_FAMILY "R5000 "
  99. #elif defined CONFIG_CPU_R5432
  100. #define MODULE_PROC_FAMILY "R5432 "
  101. #elif defined CONFIG_CPU_R5500
  102. #define MODULE_PROC_FAMILY "R5500 "
  103. #elif defined CONFIG_CPU_NEVADA
  104. #define MODULE_PROC_FAMILY "NEVADA "
  105. #elif defined CONFIG_CPU_R8000
  106. #define MODULE_PROC_FAMILY "R8000 "
  107. #elif defined CONFIG_CPU_R10000
  108. #define MODULE_PROC_FAMILY "R10000 "
  109. #elif defined CONFIG_CPU_RM7000
  110. #define MODULE_PROC_FAMILY "RM7000 "
  111. #elif defined CONFIG_CPU_SB1
  112. #define MODULE_PROC_FAMILY "SB1 "
  113. #elif defined CONFIG_CPU_LOONGSON1
  114. #define MODULE_PROC_FAMILY "LOONGSON1 "
  115. #elif defined CONFIG_CPU_LOONGSON2
  116. #define MODULE_PROC_FAMILY "LOONGSON2 "
  117. #elif defined CONFIG_CPU_LOONGSON3
  118. #define MODULE_PROC_FAMILY "LOONGSON3 "
  119. #elif defined CONFIG_CPU_CAVIUM_OCTEON
  120. #define MODULE_PROC_FAMILY "OCTEON "
  121. #elif defined CONFIG_CPU_XLR
  122. #define MODULE_PROC_FAMILY "XLR "
  123. #elif defined CONFIG_CPU_XLP
  124. #define MODULE_PROC_FAMILY "XLP "
  125. #else
  126. #error MODULE_PROC_FAMILY undefined for your processor configuration
  127. #endif
  128. #ifdef CONFIG_32BIT
  129. #define MODULE_KERNEL_TYPE "32BIT "
  130. #elif defined CONFIG_64BIT
  131. #define MODULE_KERNEL_TYPE "64BIT "
  132. #endif
  133. #define MODULE_ARCH_VERMAGIC \
  134. MODULE_PROC_FAMILY MODULE_KERNEL_TYPE
  135. #endif /* _ASM_MODULE_H */