1a5a4af3bSchristos /* collection of junk waiting time to sort out 2*8b657b07Schristos Copyright (C) 1996-2023 Free Software Foundation, Inc. 3a5a4af3bSchristos Contributed by Cygnus Support. 4a5a4af3bSchristos 5a5a4af3bSchristos This file is part of GDB, the GNU debugger. 6a5a4af3bSchristos 7a5a4af3bSchristos This program is free software; you can redistribute it and/or modify 8a5a4af3bSchristos it under the terms of the GNU General Public License as published by 9a5a4af3bSchristos the Free Software Foundation; either version 3 of the License, or 10a5a4af3bSchristos (at your option) any later version. 11a5a4af3bSchristos 12a5a4af3bSchristos This program is distributed in the hope that it will be useful, 13a5a4af3bSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 14a5a4af3bSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15a5a4af3bSchristos GNU General Public License for more details. 16a5a4af3bSchristos 17a5a4af3bSchristos You should have received a copy of the GNU General Public License 18a5a4af3bSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19a5a4af3bSchristos 20a5a4af3bSchristos #ifndef M32R_SIM_H 21a5a4af3bSchristos #define M32R_SIM_H 22a5a4af3bSchristos 23a5a4af3bSchristos /* GDB register numbers. */ 24a5a4af3bSchristos #define PSW_REGNUM 16 25a5a4af3bSchristos #define CBR_REGNUM 17 26a5a4af3bSchristos #define SPI_REGNUM 18 27a5a4af3bSchristos #define SPU_REGNUM 19 28a5a4af3bSchristos #define BPC_REGNUM 20 29a5a4af3bSchristos #define PC_REGNUM 21 30a5a4af3bSchristos #define ACCL_REGNUM 22 31a5a4af3bSchristos #define ACCH_REGNUM 23 32a5a4af3bSchristos #define ACC1L_REGNUM 24 33a5a4af3bSchristos #define ACC1H_REGNUM 25 34a5a4af3bSchristos #define BBPSW_REGNUM 26 35a5a4af3bSchristos #define BBPC_REGNUM 27 36a5a4af3bSchristos #define EVB_REGNUM 28 37a5a4af3bSchristos 38a5a4af3bSchristos extern int m32r_decode_gdb_ctrl_regnum (int); 39a5a4af3bSchristos 40a5a4af3bSchristos /* Cover macros for hardware accesses. 41a5a4af3bSchristos FIXME: Eventually move to cgen. */ 42a5a4af3bSchristos #define GET_H_SM() ((CPU (h_psw) & 0x80) != 0) 43a5a4af3bSchristos 44a5a4af3bSchristos #ifndef GET_H_CR 45a5a4af3bSchristos extern USI m32rbf_h_cr_get_handler (SIM_CPU *, UINT); 46a5a4af3bSchristos extern void m32rbf_h_cr_set_handler (SIM_CPU *, UINT, USI); 47a5a4af3bSchristos 48a5a4af3bSchristos #define GET_H_CR(regno) \ 49a5a4af3bSchristos XCONCAT2 (WANT_CPU,_h_cr_get_handler) (current_cpu, (regno)) 50a5a4af3bSchristos #define SET_H_CR(regno, val) \ 51a5a4af3bSchristos XCONCAT2 (WANT_CPU,_h_cr_set_handler) (current_cpu, (regno), (val)) 52a5a4af3bSchristos #endif 53a5a4af3bSchristos 54a5a4af3bSchristos #ifndef GET_H_PSW 55a5a4af3bSchristos extern UQI m32rbf_h_psw_get_handler (SIM_CPU *); 56a5a4af3bSchristos extern void m32rbf_h_psw_set_handler (SIM_CPU *, UQI); 57a5a4af3bSchristos 58a5a4af3bSchristos #define GET_H_PSW() \ 59a5a4af3bSchristos XCONCAT2 (WANT_CPU,_h_psw_get_handler) (current_cpu) 60a5a4af3bSchristos #define SET_H_PSW(val) \ 61a5a4af3bSchristos XCONCAT2 (WANT_CPU,_h_psw_set_handler) (current_cpu, (val)) 62a5a4af3bSchristos #endif 63a5a4af3bSchristos 64*8b657b07Schristos /* FIXME: These prototypes are necessary because the cgen generated 65*8b657b07Schristos cpu.h, cpux.h and cpu2.h headers do not provide them, and functions 66*8b657b07Schristos which take or return parameters that are larger than an int must be 67*8b657b07Schristos prototyed in order for them to work correctly. 68*8b657b07Schristos 69*8b657b07Schristos The correct solution is to fix the code in cgen/sim.scm to generate 70*8b657b07Schristos prototypes for each of the functions it generates. */ 71a5a4af3bSchristos extern DI m32rbf_h_accum_get_handler (SIM_CPU *); 72a5a4af3bSchristos extern void m32rbf_h_accum_set_handler (SIM_CPU *, DI); 73*8b657b07Schristos extern DI m32r2f_h_accums_get_handler (SIM_CPU *, UINT); 74*8b657b07Schristos extern void m32r2f_h_accums_set_handler (SIM_CPU *, UINT, DI); 75a5a4af3bSchristos 76*8b657b07Schristos #ifndef GET_H_ACCUM 77a5a4af3bSchristos #define GET_H_ACCUM() \ 78a5a4af3bSchristos XCONCAT2 (WANT_CPU,_h_accum_get_handler) (current_cpu) 79a5a4af3bSchristos #define SET_H_ACCUM(val) \ 80a5a4af3bSchristos XCONCAT2 (WANT_CPU,_h_accum_set_handler) (current_cpu, (val)) 81a5a4af3bSchristos #endif 82a5a4af3bSchristos 83a5a4af3bSchristos /* Misc. profile data. */ 84a5a4af3bSchristos 85a5a4af3bSchristos typedef struct { 86a5a4af3bSchristos /* nop insn slot filler count */ 87a5a4af3bSchristos unsigned int fillnop_count; 88a5a4af3bSchristos /* number of parallel insns */ 89a5a4af3bSchristos unsigned int parallel_count; 90a5a4af3bSchristos 91a5a4af3bSchristos /* FIXME: generalize this to handle all insn lengths, move to common. */ 92a5a4af3bSchristos /* number of short insns, not including parallel ones */ 93a5a4af3bSchristos unsigned int short_count; 94a5a4af3bSchristos /* number of long insns */ 95a5a4af3bSchristos unsigned int long_count; 96a5a4af3bSchristos 97a5a4af3bSchristos /* Working area for computing cycle counts. */ 98a5a4af3bSchristos unsigned long insn_cycles; /* FIXME: delete */ 99a5a4af3bSchristos unsigned long cti_stall; 100a5a4af3bSchristos unsigned long load_stall; 101a5a4af3bSchristos unsigned long biggest_cycles; 102a5a4af3bSchristos 103a5a4af3bSchristos /* Bitmask of registers loaded by previous insn. */ 104a5a4af3bSchristos unsigned int load_regs; 105a5a4af3bSchristos /* Bitmask of registers loaded by current insn. */ 106a5a4af3bSchristos unsigned int load_regs_pending; 107a5a4af3bSchristos } M32R_MISC_PROFILE; 108a5a4af3bSchristos 109a5a4af3bSchristos /* Initialize the working area. */ 110a5a4af3bSchristos void m32r_init_insn_cycles (SIM_CPU *, int); 111a5a4af3bSchristos /* Update the totals for the insn. */ 112a5a4af3bSchristos void m32r_record_insn_cycles (SIM_CPU *, int); 113a5a4af3bSchristos 114a5a4af3bSchristos /* This is invoked by the nop pattern in the .cpu file. */ 115a5a4af3bSchristos #define PROFILE_COUNT_FILLNOPS(cpu, addr) \ 116a5a4af3bSchristos do { \ 117a5a4af3bSchristos if (PROFILE_INSN_P (cpu) \ 118a5a4af3bSchristos && (addr & 3) != 0) \ 119a5a4af3bSchristos ++ CPU_M32R_MISC_PROFILE (cpu)->fillnop_count; \ 120a5a4af3bSchristos } while (0) 121a5a4af3bSchristos 122a5a4af3bSchristos /* This is invoked by the execute section of mloop{,x}.in. */ 123a5a4af3bSchristos #define PROFILE_COUNT_PARINSNS(cpu) \ 124a5a4af3bSchristos do { \ 125a5a4af3bSchristos if (PROFILE_INSN_P (cpu)) \ 126a5a4af3bSchristos ++ CPU_M32R_MISC_PROFILE (cpu)->parallel_count; \ 127a5a4af3bSchristos } while (0) 128a5a4af3bSchristos 129a5a4af3bSchristos /* This is invoked by the execute section of mloop{,x}.in. */ 130a5a4af3bSchristos #define PROFILE_COUNT_SHORTINSNS(cpu) \ 131a5a4af3bSchristos do { \ 132a5a4af3bSchristos if (PROFILE_INSN_P (cpu)) \ 133a5a4af3bSchristos ++ CPU_M32R_MISC_PROFILE (cpu)->short_count; \ 134a5a4af3bSchristos } while (0) 135a5a4af3bSchristos 136a5a4af3bSchristos /* This is invoked by the execute section of mloop{,x}.in. */ 137a5a4af3bSchristos #define PROFILE_COUNT_LONGINSNS(cpu) \ 138a5a4af3bSchristos do { \ 139a5a4af3bSchristos if (PROFILE_INSN_P (cpu)) \ 140a5a4af3bSchristos ++ CPU_M32R_MISC_PROFILE (cpu)->long_count; \ 141a5a4af3bSchristos } while (0) 142a5a4af3bSchristos 143a5a4af3bSchristos #define GETTWI GETTSI 144a5a4af3bSchristos #define SETTWI SETTSI 145a5a4af3bSchristos 146a5a4af3bSchristos /* Additional execution support. */ 147a5a4af3bSchristos 148a5a4af3bSchristos 149a5a4af3bSchristos /* Hardware/device support. 150a5a4af3bSchristos ??? Will eventually want to move device stuff to config files. */ 151a5a4af3bSchristos 152a5a4af3bSchristos /* Exception, Interrupt, and Trap addresses */ 153a5a4af3bSchristos #define EIT_SYSBREAK_ADDR 0x10 154a5a4af3bSchristos #define EIT_RSVD_INSN_ADDR 0x20 155a5a4af3bSchristos #define EIT_ADDR_EXCP_ADDR 0x30 156a5a4af3bSchristos #define EIT_TRAP_BASE_ADDR 0x40 157a5a4af3bSchristos #define EIT_EXTERN_ADDR 0x80 158a5a4af3bSchristos #define EIT_RESET_ADDR 0x7ffffff0 159a5a4af3bSchristos #define EIT_WAKEUP_ADDR 0x7ffffff0 160a5a4af3bSchristos 161a5a4af3bSchristos /* Special purpose traps. */ 162a5a4af3bSchristos #define TRAP_SYSCALL 0 163a5a4af3bSchristos #define TRAP_BREAKPOINT 1 164a5a4af3bSchristos 165a5a4af3bSchristos /* Handle the trap insn. */ 166a5a4af3bSchristos USI m32r_trap (SIM_CPU *, PCADDR, int); 167a5a4af3bSchristos 168a5a4af3bSchristos #endif /* M32R_SIM_H */ 169