mips-tdep.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* Target-dependent header for the MIPS architecture, for GDB, the GNU Debugger.
  2. Copyright (C) 2002-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef MIPS_TDEP_H
  15. #define MIPS_TDEP_H
  16. #include "objfiles.h"
  17. #include "gdbarch.h"
  18. struct gdbarch;
  19. /* All the possible MIPS ABIs. */
  20. enum mips_abi
  21. {
  22. MIPS_ABI_UNKNOWN = 0,
  23. MIPS_ABI_N32,
  24. MIPS_ABI_O32,
  25. MIPS_ABI_N64,
  26. MIPS_ABI_O64,
  27. MIPS_ABI_EABI32,
  28. MIPS_ABI_EABI64,
  29. MIPS_ABI_LAST
  30. };
  31. /* Return the MIPS ABI associated with GDBARCH. */
  32. enum mips_abi mips_abi (struct gdbarch *gdbarch);
  33. /* Base and compressed MIPS ISA variations. */
  34. enum mips_isa
  35. {
  36. ISA_MIPS = -1, /* mips_compression_string depends on it. */
  37. ISA_MIPS16,
  38. ISA_MICROMIPS
  39. };
  40. /* Corresponding MSYMBOL_TARGET_FLAG aliases. */
  41. #define MSYMBOL_TARGET_FLAG_MIPS16 MSYMBOL_TARGET_FLAG_1
  42. #define MSYMBOL_TARGET_FLAG_MICROMIPS MSYMBOL_TARGET_FLAG_2
  43. /* Return the MIPS ISA's register size. Just a short cut to the BFD
  44. architecture's word size. */
  45. extern int mips_isa_regsize (struct gdbarch *gdbarch);
  46. /* Return the current index for various MIPS registers. */
  47. struct mips_regnum
  48. {
  49. int pc;
  50. int fp0;
  51. int fp_implementation_revision;
  52. int fp_control_status;
  53. int badvaddr; /* Bad vaddr for addressing exception. */
  54. int cause; /* Describes last exception. */
  55. int hi; /* Multiply/divide temp. */
  56. int lo; /* ... */
  57. int dspacc; /* SmartMIPS/DSP accumulators. */
  58. int dspctl; /* DSP control. */
  59. };
  60. extern const struct mips_regnum *mips_regnum (struct gdbarch *gdbarch);
  61. /* Some MIPS boards don't support floating point while others only
  62. support single-precision floating-point operations. */
  63. enum mips_fpu_type
  64. {
  65. MIPS_FPU_DOUBLE, /* Full double precision floating point. */
  66. MIPS_FPU_SINGLE, /* Single precision floating point (R4650). */
  67. MIPS_FPU_NONE /* No floating point. */
  68. };
  69. /* MIPS specific per-architecture information. */
  70. struct mips_gdbarch_tdep : gdbarch_tdep
  71. {
  72. /* from the elf header */
  73. int elf_flags = 0;
  74. /* mips options */
  75. enum mips_abi mips_abi {};
  76. enum mips_abi found_abi {};
  77. enum mips_isa mips_isa {};
  78. enum mips_fpu_type mips_fpu_type {};
  79. int mips_last_arg_regnum = 0;
  80. int mips_last_fp_arg_regnum = 0;
  81. int default_mask_address_p = 0;
  82. /* Is the target using 64-bit raw integer registers but only
  83. storing a left-aligned 32-bit value in each? */
  84. int mips64_transfers_32bit_regs_p = 0;
  85. /* Indexes for various registers. IRIX and embedded have
  86. different values. This contains the "public" fields. Don't
  87. add any that do not need to be public. */
  88. const struct mips_regnum *regnum = nullptr;
  89. /* Register names table for the current register set. */
  90. const char * const *mips_processor_reg_names = nullptr;
  91. /* The size of register data available from the target, if known.
  92. This doesn't quite obsolete the manual
  93. mips64_transfers_32bit_regs_p, since that is documented to force
  94. left alignment even for big endian (very strange). */
  95. int register_size_valid_p = 0;
  96. int register_size = 0;
  97. /* Return the expected next PC if FRAME is stopped at a syscall
  98. instruction. */
  99. CORE_ADDR (*syscall_next_pc) (struct frame_info *frame) = nullptr;
  100. };
  101. /* Register numbers of various important registers. */
  102. enum
  103. {
  104. MIPS_ZERO_REGNUM = 0, /* Read-only register, always 0. */
  105. MIPS_AT_REGNUM = 1,
  106. MIPS_V0_REGNUM = 2, /* Function integer return value. */
  107. MIPS_A0_REGNUM = 4, /* Loc of first arg during a subr call. */
  108. MIPS_S2_REGNUM = 18, /* Contains return address in MIPS16 thunks. */
  109. MIPS_T9_REGNUM = 25, /* Contains address of callee in PIC. */
  110. MIPS_GP_REGNUM = 28,
  111. MIPS_SP_REGNUM = 29,
  112. MIPS_RA_REGNUM = 31,
  113. MIPS_PS_REGNUM = 32, /* Contains processor status. */
  114. MIPS_EMBED_LO_REGNUM = 33,
  115. MIPS_EMBED_HI_REGNUM = 34,
  116. MIPS_EMBED_BADVADDR_REGNUM = 35,
  117. MIPS_EMBED_CAUSE_REGNUM = 36,
  118. MIPS_EMBED_PC_REGNUM = 37,
  119. MIPS_EMBED_FP0_REGNUM = 38,
  120. MIPS_UNUSED_REGNUM = 73, /* Never used, FIXME. */
  121. MIPS_FIRST_EMBED_REGNUM = 74, /* First CP0 register for embedded use. */
  122. MIPS_PRID_REGNUM = 89, /* Processor ID. */
  123. MIPS_LAST_EMBED_REGNUM = 89 /* Last one. */
  124. };
  125. /* Instruction sizes and other useful constants. */
  126. enum
  127. {
  128. MIPS_INSN16_SIZE = 2,
  129. MIPS_INSN32_SIZE = 4,
  130. /* The number of floating-point or integer registers. */
  131. MIPS_NUMREGS = 32
  132. };
  133. /* Single step based on where the current instruction will take us. */
  134. extern std::vector<CORE_ADDR> mips_software_single_step
  135. (struct regcache *regcache);
  136. /* Strip the ISA (compression) bit off from ADDR. */
  137. extern CORE_ADDR mips_unmake_compact_addr (CORE_ADDR addr);
  138. /* Tell if the program counter value in MEMADDR is in a standard
  139. MIPS function. */
  140. extern int mips_pc_is_mips (CORE_ADDR memaddr);
  141. /* Tell if the program counter value in MEMADDR is in a MIPS16
  142. function. */
  143. extern int mips_pc_is_mips16 (struct gdbarch *gdbarch, CORE_ADDR memaddr);
  144. /* Tell if the program counter value in MEMADDR is in a microMIPS
  145. function. */
  146. extern int mips_pc_is_micromips (struct gdbarch *gdbarch, CORE_ADDR memaddr);
  147. /* Return the currently configured (or set) saved register size. */
  148. extern unsigned int mips_abi_regsize (struct gdbarch *gdbarch);
  149. /* Make PC the address of the next instruction to execute. */
  150. extern void mips_write_pc (struct regcache *regcache, CORE_ADDR pc);
  151. /* Target descriptions which only indicate the size of general
  152. registers. */
  153. extern struct target_desc *mips_tdesc_gp32;
  154. extern struct target_desc *mips_tdesc_gp64;
  155. /* Return non-zero if PC is in a MIPS SVR4 lazy binding stub section. */
  156. static inline int
  157. in_mips_stubs_section (CORE_ADDR pc)
  158. {
  159. return pc_in_section (pc, ".MIPS.stubs");
  160. }
  161. #endif /* MIPS_TDEP_H */