registers.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /* This file is part of the program psim.
  2. Copyright 1994, 1997, 2003 Andrew Cagney
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _REGISTERS_H_
  15. #define _REGISTERS_H_
  16. /*
  17. * The PowerPC registers
  18. *
  19. */
  20. /* FIXME:
  21. For the moment use macro's to determine if the E500 or Altivec
  22. registers should be included. IGEN should instead of a :register:
  23. field to facilitate the specification and generation of per ISA
  24. registers. */
  25. #ifdef WITH_E500
  26. #include "e500_registers.h"
  27. #endif
  28. #if WITH_ALTIVEC
  29. #include "altivec_registers.h"
  30. #endif
  31. /**
  32. ** General Purpose Registers
  33. **/
  34. typedef signed_word gpreg;
  35. /**
  36. ** Floating Point Registers
  37. **/
  38. typedef uint64_t fpreg;
  39. /**
  40. ** The condition register
  41. **
  42. **/
  43. typedef uint32_t creg;
  44. /* The following sub bits are defined for the condition register */
  45. enum {
  46. cr_i_negative = BIT4(0),
  47. cr_i_positive = BIT4(1),
  48. cr_i_zero = BIT4(2),
  49. cr_i_summary_overflow = BIT4(3),
  50. #if 0
  51. /* cr0 - integer status */
  52. cr0_i_summary_overflow_bit = 3,
  53. cr0_i_negative = BIT32(0),
  54. cr0_i_positive = BIT32(1),
  55. cr0_i_zero = BIT32(2),
  56. cr0_i_summary_overflow = BIT32(3),
  57. cr0_i_mask = MASK32(0,3),
  58. #endif
  59. /* cr1 - floating-point status */
  60. cr1_i_floating_point_exception_summary_bit = 4,
  61. cr1_i_floating_point_enabled_exception_summary_bit = 5,
  62. cr1_i_floating_point_invalid_operation_exception_summary_bit = 6,
  63. cr1_i_floating_point_overflow_exception_bit = 7,
  64. cr1_i_floating_point_exception_summary = BIT32(4),
  65. cr1_i_floating_point_enabled_exception_summary = BIT32(5),
  66. cr1_i_floating_point_invalid_operation_exception_summary = BIT32(6),
  67. cr1_i_floating_point_overflow_exception = BIT32(7),
  68. cr1_i_mask = MASK32(4,7),
  69. };
  70. /* Condition register 1 contains the result of floating point arithmetic */
  71. enum {
  72. cr_fp_exception = BIT4(0),
  73. cr_fp_enabled_exception = BIT4(1),
  74. cr_fp_invalid_exception = BIT4(2),
  75. cr_fp_overflow_exception = BIT4(3),
  76. };
  77. /**
  78. ** Floating-Point Status and Control Register
  79. **/
  80. typedef uint32_t fpscreg;
  81. enum {
  82. fpscr_fx_bit = 0,
  83. fpscr_fx = BIT32(0),
  84. fpscr_fex_bit = 1,
  85. fpscr_fex = BIT32(1),
  86. fpscr_vx_bit = 2,
  87. fpscr_vx = BIT32(2),
  88. fpscr_ox_bit = 3,
  89. fpscr_ox = BIT32(3),
  90. fpscr_ux = BIT32(4),
  91. fpscr_zx = BIT32(5),
  92. fpscr_xx = BIT32(6),
  93. fpscr_vxsnan = BIT32(7), /* SNAN */
  94. fpscr_vxisi = BIT32(8), /* INF - INF */
  95. fpscr_vxidi = BIT32(9), /* INF / INF */
  96. fpscr_vxzdz = BIT32(10), /* 0 / 0 */
  97. fpscr_vximz = BIT32(11), /* INF * 0 */
  98. fpscr_vxvc = BIT32(12),
  99. fpscr_fr = BIT32(13),
  100. fpscr_fi = BIT32(14),
  101. fpscr_fprf = MASK32(15, 19),
  102. fpscr_c = BIT32(15),
  103. fpscr_fpcc_bit = 16, /* well sort of */
  104. fpscr_fpcc = MASK32(16, 19),
  105. fpscr_fl = BIT32(16),
  106. fpscr_fg = BIT32(17),
  107. fpscr_fe = BIT32(18),
  108. fpscr_fu = BIT32(19),
  109. fpscr_rf_quiet_nan = fpscr_c | fpscr_fu,
  110. fpscr_rf_neg_infinity = fpscr_fl | fpscr_fu,
  111. fpscr_rf_neg_normal_number = fpscr_fl,
  112. fpscr_rf_neg_denormalized_number = fpscr_c | fpscr_fl,
  113. fpscr_rf_neg_zero = fpscr_c | fpscr_fe,
  114. fpscr_rf_pos_zero = fpscr_fe,
  115. fpscr_rf_pos_denormalized_number = fpscr_c | fpscr_fg,
  116. fpscr_rf_pos_normal_number = fpscr_fg,
  117. fpscr_rf_pos_infinity = fpscr_fg | fpscr_fu,
  118. fpscr_reserved_20 = BIT32(20),
  119. fpscr_vxsoft = BIT32(21),
  120. fpscr_vxsqrt = BIT32(22),
  121. fpscr_vxcvi = BIT32(23),
  122. fpscr_ve = BIT32(24),
  123. fpscr_oe = BIT32(25),
  124. fpscr_ue = BIT32(26),
  125. fpscr_ze = BIT32(27),
  126. fpscr_xe = BIT32(28),
  127. fpscr_ni = BIT32(29),
  128. fpscr_rn = MASK32(30, 31),
  129. fpscr_rn_round_to_nearest = 0,
  130. fpscr_rn_round_towards_zero = MASK32(31,31),
  131. fpscr_rn_round_towards_pos_infinity = MASK32(30,30),
  132. fpscr_rn_round_towards_neg_infinity = MASK32(30,31),
  133. fpscr_vx_bits = (fpscr_vxsnan | fpscr_vxisi | fpscr_vxidi
  134. | fpscr_vxzdz | fpscr_vximz | fpscr_vxvc
  135. | fpscr_vxsoft | fpscr_vxsqrt | fpscr_vxcvi),
  136. };
  137. /**
  138. ** XER Register
  139. **/
  140. typedef uint32_t xereg;
  141. enum {
  142. xer_summary_overflow = BIT32(0), xer_summary_overflow_bit = 0,
  143. xer_carry = BIT32(2), xer_carry_bit = 2,
  144. xer_overflow = BIT32(1),
  145. xer_reserved_3_24 = MASK32(3,24),
  146. xer_byte_count_mask = MASK32(25,31)
  147. };
  148. /**
  149. ** SPR's
  150. **/
  151. #include "spreg.h"
  152. /**
  153. ** Segment Registers
  154. **/
  155. typedef uint32_t sreg;
  156. enum {
  157. nr_of_srs = 16
  158. };
  159. /**
  160. ** Machine state register
  161. **/
  162. typedef unsigned_word msreg; /* 32 or 64 bits */
  163. enum {
  164. #if (WITH_TARGET_WORD_BITSIZE == 64)
  165. msr_64bit_mode = BIT(0),
  166. #endif
  167. #if (WITH_TARGET_WORD_BITSIZE == 32)
  168. msr_64bit_mode = 0,
  169. #endif
  170. msr_power_management_enable = BIT(45),
  171. msr_tempoary_gpr_remapping = BIT(46), /* 603 specific */
  172. msr_interrupt_little_endian_mode = BIT(47),
  173. msr_external_interrupt_enable = BIT(48),
  174. msr_problem_state = BIT(49),
  175. msr_floating_point_available = BIT(50),
  176. msr_machine_check_enable = BIT(51),
  177. msr_floating_point_exception_mode_0 = BIT(52),
  178. msr_single_step_trace_enable = BIT(53),
  179. msr_branch_trace_enable = BIT(54),
  180. msr_floating_point_exception_mode_1 = BIT(55),
  181. msr_interrupt_prefix = BIT(57),
  182. msr_instruction_relocate = BIT(58),
  183. msr_data_relocate = BIT(59),
  184. msr_recoverable_interrupt = BIT(62),
  185. msr_little_endian_mode = BIT(63)
  186. };
  187. enum {
  188. srr1_hash_table_or_ibat_miss = BIT(33),
  189. srr1_direct_store_error_exception = BIT(35),
  190. srr1_protection_violation = BIT(36),
  191. srr1_segment_table_miss = BIT(42),
  192. srr1_floating_point_enabled = BIT(43),
  193. srr1_illegal_instruction = BIT(44),
  194. srr1_priviliged_instruction = BIT(45),
  195. srr1_trap = BIT(46),
  196. srr1_subsequent_instruction = BIT(47)
  197. };
  198. /**
  199. ** storage interrupt registers
  200. **/
  201. typedef enum {
  202. dsisr_direct_store_error_exception = BIT32(0),
  203. dsisr_hash_table_or_dbat_miss = BIT32(1),
  204. dsisr_protection_violation = BIT32(4),
  205. dsisr_earwax_violation = BIT32(5),
  206. dsisr_store_operation = BIT32(6),
  207. dsisr_segment_table_miss = BIT32(10),
  208. dsisr_earwax_disabled = BIT32(11)
  209. } dsisr_status;
  210. /**
  211. ** And the registers proper
  212. **/
  213. typedef struct _registers {
  214. gpreg gpr[32];
  215. fpreg fpr[32];
  216. creg cr;
  217. fpscreg fpscr;
  218. /* Machine state register */
  219. msreg msr;
  220. /* Spr's */
  221. spreg spr[nr_of_sprs];
  222. /* Segment Registers */
  223. sreg sr[nr_of_srs];
  224. #if WITH_ALTIVEC
  225. struct altivec_regs altivec;
  226. #endif
  227. #if WITH_E500
  228. struct e500_regs e500;
  229. #endif
  230. } registers;
  231. /* dump out all the registers */
  232. INLINE_REGISTERS\
  233. (void) registers_dump
  234. (registers *regs);
  235. /* return information on a register based on name */
  236. typedef enum {
  237. reg_invalid,
  238. reg_gpr, reg_fpr, reg_spr, reg_msr,
  239. reg_cr, reg_fpscr, reg_pc, reg_sr,
  240. reg_insns, reg_stalls, reg_cycles,
  241. #ifdef WITH_ALTIVEC
  242. reg_vr, reg_vscr,
  243. #endif
  244. #ifdef WITH_E500
  245. reg_acc, reg_gprh, reg_evr,
  246. #endif
  247. nr_register_types
  248. } register_types;
  249. typedef struct {
  250. register_types type;
  251. int index;
  252. int size;
  253. } register_descriptions;
  254. INLINE_REGISTERS\
  255. (register_descriptions) register_description
  256. (const char reg[]);
  257. /* Special purpose registers by their more common names */
  258. #define SPREG(N) cpu_registers(processor)->spr[N]
  259. #define XER SPREG(spr_xer)
  260. #define LR SPREG(spr_lr)
  261. #define CTR SPREG(spr_ctr)
  262. #define SRR0 SPREG(spr_srr0)
  263. #define SRR1 SPREG(spr_srr1)
  264. #define DAR SPREG(spr_dar)
  265. #define DSISR SPREG(spr_dsisr)
  266. /* general purpose registers - indexed access */
  267. #define GPR(N) cpu_registers(processor)->gpr[N]
  268. /* segment registers */
  269. #define SEGREG(N) cpu_registers(processor)->sr[N]
  270. /* condition register */
  271. #define CR cpu_registers(processor)->cr
  272. /* machine status register */
  273. #define MSR cpu_registers(processor)->msr
  274. /* floating-point status condition register */
  275. #define FPSCR cpu_registers(processor)->fpscr
  276. #endif /* _REGISTERS_H_ */