This commit includes necessary header files and creates duplicated
declarations from other header files.
Duplicated declarations are necessary on M32R because, despite that some
m32rbf functions are used by m32rx and m32r2, we cannot include two or more
CPU header files: "cpu.h", "cpux.h" and "cpu2.h".
---
sim/m32r/m32r2.c | 5 +++++
sim/m32r/m32rx.c | 5 +++++
sim/m32r/sim-if.c | 4 ++++
sim/m32r/traps.c | 15 +++++++++++++++
4 files changed, 29 insertions(+)
On 20 Oct 2022 09:32, Tsukasa OI wrote:
> This commit includes necessary header files and creates duplicated
> declarations from other header files.
>
> Duplicated declarations are necessary on M32R because, despite that some
> m32rbf functions are used by m32rx and m32r2, we cannot include two or more
> CPU header files: "cpu.h", "cpux.h" and "cpu2.h".
move/duplicate prototypes in a common header (e.g. m32r-sim.h) that both places
will include, never put them into a C file itself. as written, there is no
protection keeping the prototypes in sync.
-mike
@@ -26,6 +26,11 @@
#include "sim-main.h"
#include "cgen-mem.h"
#include "cgen-ops.h"
+#include "decode.h"
+
+/* From cpu.h. */
+extern CPUREG_FETCH_FN m32rbf_fetch_register;
+extern CPUREG_STORE_FN m32rbf_store_register;
/* The contents of BUF are in target byte order. */
@@ -26,6 +26,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sim-main.h"
#include "cgen-mem.h"
#include "cgen-ops.h"
+#include "decode.h"
+
+/* From cpu.h. */
+extern CPUREG_FETCH_FN m32rbf_fetch_register;
+extern CPUREG_STORE_FN m32rbf_store_register;
/* The contents of BUF are in target byte order. */
@@ -25,6 +25,7 @@
#include "sim/callback.h"
#include "sim-main.h"
+#include "sim-hw.h"
#include "sim-options.h"
#include "libiberty.h"
#include "bfd.h"
@@ -33,6 +34,9 @@
#define M32R_DEFAULT_MEM_SIZE 0x2000000 /* 32M */
+/* From cpu.h. */
+void m32rbf_h_cr_set (SIM_CPU *, UINT, USI);
+
static void free_state (SIM_DESC);
static void print_m32r_misc_cpu (SIM_CPU *cpu, int verbose);
@@ -55,6 +55,21 @@
#include <linux/unistd.h>
#endif
+/* From cpu.h, cpux.h and cpu2.h. */
+SI m32rbf_h_gr_get (SIM_CPU *, UINT);
+void m32rbf_h_gr_set (SIM_CPU *, UINT, SI);
+USI m32rbf_h_cr_get (SIM_CPU *, UINT);
+void m32rbf_h_cr_set (SIM_CPU *, UINT, USI);
+UQI m32rbf_h_psw_get (SIM_CPU *);
+void m32rbf_h_psw_set (SIM_CPU *, UQI);
+void m32rbf_h_bpsw_set (SIM_CPU *, UQI);
+UQI m32rxf_h_psw_get (SIM_CPU *);
+void m32rxf_h_psw_set (SIM_CPU *, UQI);
+void m32rxf_h_bpsw_set (SIM_CPU *, UQI);
+UQI m32r2f_h_psw_get (SIM_CPU *);
+void m32r2f_h_psw_set (SIM_CPU *, UQI);
+void m32r2f_h_bpsw_set (SIM_CPU *, UQI);
+
#define TRAP_LINUX_SYSCALL 2
#define TRAP_FLUSH_CACHE 12
/* The semantic code invokes this for invalid (unrecognized) instructions. */