m32r-sim.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /* collection of junk waiting time to sort out
  2. Copyright (C) 1996-2015 Free Software Foundation, Inc.
  3. Contributed by Cygnus Support.
  4. This file is part of GDB, the GNU debugger.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef M32R_SIM_H
  16. #define M32R_SIM_H
  17. /* GDB register numbers. */
  18. #define PSW_REGNUM 16
  19. #define CBR_REGNUM 17
  20. #define SPI_REGNUM 18
  21. #define SPU_REGNUM 19
  22. #define BPC_REGNUM 20
  23. #define PC_REGNUM 21
  24. #define ACCL_REGNUM 22
  25. #define ACCH_REGNUM 23
  26. #define ACC1L_REGNUM 24
  27. #define ACC1H_REGNUM 25
  28. #define BBPSW_REGNUM 26
  29. #define BBPC_REGNUM 27
  30. #define EVB_REGNUM 28
  31. extern int m32r_decode_gdb_ctrl_regnum (int);
  32. /* Cover macros for hardware accesses.
  33. FIXME: Eventually move to cgen. */
  34. #define GET_H_SM() ((CPU (h_psw) & 0x80) != 0)
  35. #ifndef GET_H_CR
  36. extern USI m32rbf_h_cr_get_handler (SIM_CPU *, UINT);
  37. extern void m32rbf_h_cr_set_handler (SIM_CPU *, UINT, USI);
  38. #define GET_H_CR(regno) \
  39. XCONCAT2 (WANT_CPU,_h_cr_get_handler) (current_cpu, (regno))
  40. #define SET_H_CR(regno, val) \
  41. XCONCAT2 (WANT_CPU,_h_cr_set_handler) (current_cpu, (regno), (val))
  42. #endif
  43. #ifndef GET_H_PSW
  44. extern UQI m32rbf_h_psw_get_handler (SIM_CPU *);
  45. extern void m32rbf_h_psw_set_handler (SIM_CPU *, UQI);
  46. #define GET_H_PSW() \
  47. XCONCAT2 (WANT_CPU,_h_psw_get_handler) (current_cpu)
  48. #define SET_H_PSW(val) \
  49. XCONCAT2 (WANT_CPU,_h_psw_set_handler) (current_cpu, (val))
  50. #endif
  51. #ifndef GET_H_ACCUM
  52. extern DI m32rbf_h_accum_get_handler (SIM_CPU *);
  53. extern void m32rbf_h_accum_set_handler (SIM_CPU *, DI);
  54. #define GET_H_ACCUM() \
  55. XCONCAT2 (WANT_CPU,_h_accum_get_handler) (current_cpu)
  56. #define SET_H_ACCUM(val) \
  57. XCONCAT2 (WANT_CPU,_h_accum_set_handler) (current_cpu, (val))
  58. #endif
  59. /* Misc. profile data. */
  60. typedef struct {
  61. /* nop insn slot filler count */
  62. unsigned int fillnop_count;
  63. /* number of parallel insns */
  64. unsigned int parallel_count;
  65. /* FIXME: generalize this to handle all insn lengths, move to common. */
  66. /* number of short insns, not including parallel ones */
  67. unsigned int short_count;
  68. /* number of long insns */
  69. unsigned int long_count;
  70. /* Working area for computing cycle counts. */
  71. unsigned long insn_cycles; /* FIXME: delete */
  72. unsigned long cti_stall;
  73. unsigned long load_stall;
  74. unsigned long biggest_cycles;
  75. /* Bitmask of registers loaded by previous insn. */
  76. unsigned int load_regs;
  77. /* Bitmask of registers loaded by current insn. */
  78. unsigned int load_regs_pending;
  79. } M32R_MISC_PROFILE;
  80. /* Initialize the working area. */
  81. void m32r_init_insn_cycles (SIM_CPU *, int);
  82. /* Update the totals for the insn. */
  83. void m32r_record_insn_cycles (SIM_CPU *, int);
  84. /* This is invoked by the nop pattern in the .cpu file. */
  85. #define PROFILE_COUNT_FILLNOPS(cpu, addr) \
  86. do { \
  87. if (PROFILE_INSN_P (cpu) \
  88. && (addr & 3) != 0) \
  89. ++ CPU_M32R_MISC_PROFILE (cpu)->fillnop_count; \
  90. } while (0)
  91. /* This is invoked by the execute section of mloop{,x}.in. */
  92. #define PROFILE_COUNT_PARINSNS(cpu) \
  93. do { \
  94. if (PROFILE_INSN_P (cpu)) \
  95. ++ CPU_M32R_MISC_PROFILE (cpu)->parallel_count; \
  96. } while (0)
  97. /* This is invoked by the execute section of mloop{,x}.in. */
  98. #define PROFILE_COUNT_SHORTINSNS(cpu) \
  99. do { \
  100. if (PROFILE_INSN_P (cpu)) \
  101. ++ CPU_M32R_MISC_PROFILE (cpu)->short_count; \
  102. } while (0)
  103. /* This is invoked by the execute section of mloop{,x}.in. */
  104. #define PROFILE_COUNT_LONGINSNS(cpu) \
  105. do { \
  106. if (PROFILE_INSN_P (cpu)) \
  107. ++ CPU_M32R_MISC_PROFILE (cpu)->long_count; \
  108. } while (0)
  109. #define GETTWI GETTSI
  110. #define SETTWI SETTSI
  111. /* Additional execution support. */
  112. /* Hardware/device support.
  113. ??? Will eventually want to move device stuff to config files. */
  114. /* Exception, Interrupt, and Trap addresses */
  115. #define EIT_SYSBREAK_ADDR 0x10
  116. #define EIT_RSVD_INSN_ADDR 0x20
  117. #define EIT_ADDR_EXCP_ADDR 0x30
  118. #define EIT_TRAP_BASE_ADDR 0x40
  119. #define EIT_EXTERN_ADDR 0x80
  120. #define EIT_RESET_ADDR 0x7ffffff0
  121. #define EIT_WAKEUP_ADDR 0x7ffffff0
  122. /* Special purpose traps. */
  123. #define TRAP_SYSCALL 0
  124. #define TRAP_BREAKPOINT 1
  125. /* Support for the MSPR register (Cache Purge Control Register)
  126. and the MCCR register (Cache Control Register) are needed in order for
  127. overlays to work correctly with the scache.
  128. MSPR no longer exists but is supported for upward compatibility with
  129. early overlay support. */
  130. /* Cache Purge Control (only exists on early versions of chips) */
  131. #define MSPR_ADDR 0xfffffff7
  132. #define MSPR_PURGE 1
  133. /* Lock Control Register (not supported) */
  134. #define MLCR_ADDR 0xfffffff7
  135. #define MLCR_LM 1
  136. /* Power Management Control Register (not supported) */
  137. #define MPMR_ADDR 0xfffffffb
  138. /* Cache Control Register */
  139. #define MCCR_ADDR 0xffffffff
  140. #define MCCR_CP 0x80
  141. /* not supported */
  142. #define MCCR_CM0 2
  143. #define MCCR_CM1 1
  144. /* Serial device addresses. */
  145. #ifdef M32R_EVA /* orig eva board, no longer supported */
  146. #define UART_INCHAR_ADDR 0xff102013
  147. #define UART_OUTCHAR_ADDR 0xff10200f
  148. #define UART_STATUS_ADDR 0xff102006
  149. /* Indicate ready bit is inverted. */
  150. #define UART_INPUT_READY0
  151. #else
  152. /* These are the values for the MSA2000 board.
  153. ??? Will eventually need to move this to a config file. */
  154. #define UART_INCHAR_ADDR 0xff004009
  155. #define UART_OUTCHAR_ADDR 0xff004007
  156. #define UART_STATUS_ADDR 0xff004002
  157. #endif
  158. #define UART_INPUT_READY 0x4
  159. #define UART_OUTPUT_READY 0x1
  160. /* Start address and length of all device support. */
  161. #define M32R_DEVICE_ADDR 0xff000000
  162. #define M32R_DEVICE_LEN 0x00ffffff
  163. /* sim_core_attach device argument. */
  164. extern device m32r_devices;
  165. /* FIXME: Temporary, until device support ready. */
  166. struct _device { int foo; };
  167. /* Handle the trap insn. */
  168. USI m32r_trap (SIM_CPU *, PCADDR, int);
  169. #endif /* M32R_SIM_H */