1997-05-01 01:48:27 +00:00
|
|
|
|
/* Simulator header for Cpu tools GENerated simulators.
|
1998-02-05 21:29:18 +00:00
|
|
|
|
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
|
1997-05-01 01:48:27 +00:00
|
|
|
|
Contributed by Cygnus Support.
|
|
|
|
|
|
|
|
|
|
This file is part of GDB, the GNU debugger.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
|
|
#ifndef CGEN_SIM_H
|
|
|
|
|
#define CGEN_SIM_H
|
|
|
|
|
|
1997-05-01 17:45:25 +00:00
|
|
|
|
/* Instruction field support macros. */
|
|
|
|
|
|
|
|
|
|
#define EXTRACT_SIGNED(val, total, start, length) \
|
|
|
|
|
(((((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1)) \
|
|
|
|
|
^ (1 << ((length) - 1))) \
|
|
|
|
|
- (1 << ((length) - 1)))
|
|
|
|
|
|
|
|
|
|
#define EXTRACT_UNSIGNED(val, total, start, length) \
|
|
|
|
|
(((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1))
|
|
|
|
|
|
|
|
|
|
/* Compute number of longs required to hold N bits. */
|
|
|
|
|
#define HOST_LONGS_FOR_BITS(n) \
|
|
|
|
|
(((n) + sizeof (long) * 8 - 1) / sizeof (long) * 8)
|
|
|
|
|
|
1998-07-01 23:47:50 +00:00
|
|
|
|
/* Forward decls. Defined in the machine generated files. */
|
1998-11-05 07:53:37 +00:00
|
|
|
|
|
|
|
|
|
/* This holds the contents of the extracted insn.
|
|
|
|
|
There are a few common entries (e.g. pc address), and then one big
|
|
|
|
|
union with an entry for each of the instruction formats. */
|
1998-02-05 21:29:18 +00:00
|
|
|
|
typedef struct argbuf ARGBUF;
|
1998-11-05 07:53:37 +00:00
|
|
|
|
|
|
|
|
|
/* This is one ARGBUF plus whatever else is needed for WITH_SCACHE support.
|
|
|
|
|
At present there is nothing else, but it also provides a level of
|
|
|
|
|
abstraction. */
|
1998-02-05 21:29:18 +00:00
|
|
|
|
typedef struct scache SCACHE;
|
1998-11-05 07:53:37 +00:00
|
|
|
|
|
|
|
|
|
/* This is a union with one entry for each instruction format.
|
|
|
|
|
Each entry contains all of the non-constant inputs of the instruction. */
|
1998-02-23 18:21:14 +00:00
|
|
|
|
typedef struct parexec PAREXEC;
|
1998-11-05 07:53:37 +00:00
|
|
|
|
|
|
|
|
|
/* An "Instruction DESCriptor".
|
|
|
|
|
This is the main handle on an instruction for the simulator. */
|
1998-07-01 23:47:50 +00:00
|
|
|
|
typedef struct idesc IDESC;
|
1998-11-05 07:53:37 +00:00
|
|
|
|
|
|
|
|
|
/* Engine support.
|
|
|
|
|
??? This is here because it's needed before eng.h (built by genmloop.sh)
|
|
|
|
|
which is needed before cgen-engine.h and cpu.h.
|
|
|
|
|
??? This depends on a cpu family specific type, PCADDR, but no machine
|
|
|
|
|
generated headers will have been included yet. sim/common currently
|
|
|
|
|
requires the typedef of sim_cia in sim-main.h between the inclusion of
|
|
|
|
|
sim-basics.h and sim-base.h so this is no different. */
|
1998-02-23 18:21:14 +00:00
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
#if WITH_SCACHE
|
1998-02-23 18:21:14 +00:00
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* instruction address
|
|
|
|
|
??? This was intended to be a struct of two elements in the WITH_SCACHE_PBB
|
|
|
|
|
case. The first element is the PCADDR, the second element is the SCACHE *.
|
|
|
|
|
Haven't found the time yet to make this work, but it is a nicer approach
|
|
|
|
|
than the current br_cache stuff. */
|
1998-02-23 18:21:14 +00:00
|
|
|
|
typedef PCADDR IADDR;
|
|
|
|
|
/* current instruction address */
|
|
|
|
|
typedef PCADDR CIA;
|
|
|
|
|
/* argument to semantic functions */
|
|
|
|
|
typedef SCACHE *SEM_ARG;
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* semantic code's version of pc */
|
|
|
|
|
#if WITH_SCACHE_PBB
|
|
|
|
|
typedef SCACHE *SEM_PC;
|
|
|
|
|
#else
|
|
|
|
|
typedef PCADDR SEM_PC;
|
|
|
|
|
#endif
|
1998-02-23 18:21:14 +00:00
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
#else /* ! WITH_SCACHE */
|
1998-02-23 18:21:14 +00:00
|
|
|
|
|
|
|
|
|
/* instruction address */
|
|
|
|
|
typedef PCADDR IADDR;
|
|
|
|
|
/* current instruction address */
|
|
|
|
|
typedef PCADDR CIA;
|
|
|
|
|
/* argument to semantic functions */
|
|
|
|
|
typedef ARGBUF *SEM_ARG;
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* semantic code's version of pc */
|
|
|
|
|
typedef PCADDR SEM_PC;
|
1998-02-23 18:21:14 +00:00
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
#endif /* ! WITH_SCACHE */
|
1997-05-01 01:48:27 +00:00
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* Additional opcode table support. */
|
|
|
|
|
|
|
|
|
|
/* Opcode table for virtual insns (only used by the simulator). */
|
|
|
|
|
extern const struct cgen_insn cgen_virtual_opcode_table[];
|
|
|
|
|
|
|
|
|
|
/* -ve of indices of virtual insns in cgen_virtual_opcode_table. */
|
|
|
|
|
typedef enum {
|
|
|
|
|
VIRTUAL_INSN_X_INVALID = 0,
|
|
|
|
|
VIRTUAL_INSN_X_BEFORE = -1, VIRTUAL_INSN_X_AFTER = -2,
|
|
|
|
|
VIRTUAL_INSN_X_BEGIN = -3,
|
|
|
|
|
VIRTUAL_INSN_X_CHAIN= -4, VIRTUAL_INSN_X_CTI_CHAIN = -5
|
|
|
|
|
} CGEN_INSN_VIRTUAL_TYPE;
|
|
|
|
|
|
|
|
|
|
/* Return non-zero if OPCODE is a virtual insn. */
|
|
|
|
|
#define CGEN_INSN_VIRTUAL_P(opcode) \
|
|
|
|
|
CGEN_INSN_ATTR ((opcode), CGEN_INSN_VIRTUAL)
|
1998-02-05 21:29:18 +00:00
|
|
|
|
|
|
|
|
|
/* GNU C's "computed goto" facility is used to speed things up where
|
|
|
|
|
possible. These macros provide a portable way to use them.
|
|
|
|
|
Nesting of these switch statements is done by providing an extra argument
|
|
|
|
|
that distinguishes them. `N' can be a number or symbol.
|
|
|
|
|
Variable `labels_##N' must be initialized with the labels of each case. */
|
1998-11-05 07:53:37 +00:00
|
|
|
|
|
1998-02-05 21:29:18 +00:00
|
|
|
|
#ifdef __GNUC__
|
|
|
|
|
#define SWITCH(N, X) goto *X;
|
|
|
|
|
#define CASE(N, X) case_##N##_##X
|
|
|
|
|
#define BREAK(N) goto end_switch_##N
|
|
|
|
|
#define DEFAULT(N) default_##N
|
|
|
|
|
#define ENDSWITCH(N) end_switch_##N:
|
|
|
|
|
#else
|
|
|
|
|
#define SWITCH(N, X) switch (X)
|
|
|
|
|
#define CASE(N, X) case X /* FIXME: old sem-switch had (@arch@_,X) here */
|
|
|
|
|
#define BREAK(N) break
|
|
|
|
|
#define DEFAULT(N) default
|
|
|
|
|
#define ENDSWITCH(N)
|
1997-05-01 01:48:27 +00:00
|
|
|
|
#endif
|
1998-02-05 21:29:18 +00:00
|
|
|
|
|
|
|
|
|
/* Simulator state. */
|
1997-05-01 01:48:27 +00:00
|
|
|
|
|
1998-02-05 21:29:18 +00:00
|
|
|
|
/* Records simulator descriptor so utilities like @cpu@_dump_regs can be
|
|
|
|
|
called from gdb. */
|
|
|
|
|
extern SIM_DESC current_state;
|
1997-05-01 01:48:27 +00:00
|
|
|
|
|
|
|
|
|
/* Simulator state. */
|
|
|
|
|
|
1998-02-05 21:29:18 +00:00
|
|
|
|
/* CGEN_STATE contains additional state information not present in
|
1997-05-01 01:48:27 +00:00
|
|
|
|
sim_state_base. */
|
|
|
|
|
|
|
|
|
|
typedef struct cgen_state {
|
1998-02-05 21:29:18 +00:00
|
|
|
|
/* FIXME: Moved to sim_state_base. */
|
1997-05-01 01:48:27 +00:00
|
|
|
|
/* argv, env */
|
|
|
|
|
char **argv;
|
1998-02-05 21:29:18 +00:00
|
|
|
|
#define STATE_ARGV(s) ((s) -> cgen_state.argv)
|
|
|
|
|
/* FIXME: Move to sim_state_base. */
|
1997-05-01 01:48:27 +00:00
|
|
|
|
char **envp;
|
1998-02-05 21:29:18 +00:00
|
|
|
|
#define STATE_ENVP(s) ((s) -> cgen_state.envp)
|
|
|
|
|
|
|
|
|
|
/* Non-zero if no tracing or profiling is selected. */
|
|
|
|
|
int run_fast_p;
|
|
|
|
|
#define STATE_RUN_FAST_P(sd) ((sd) -> cgen_state.run_fast_p)
|
1997-05-01 01:48:27 +00:00
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* Opcode table. */
|
|
|
|
|
CGEN_OPCODE_DESC opcode_table;
|
|
|
|
|
#define STATE_OPCODE_TABLE(sd) ((sd) -> cgen_state.opcode_table)
|
|
|
|
|
} CGEN_STATE;
|
1997-05-01 01:48:27 +00:00
|
|
|
|
|
|
|
|
|
/* Various utilities. */
|
|
|
|
|
|
1998-02-05 21:29:18 +00:00
|
|
|
|
/* Called after sim_post_argv_init to do any cgen initialization. */
|
1998-07-01 23:47:50 +00:00
|
|
|
|
extern void cgen_init (SIM_DESC);
|
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* Return the name of an insn. */
|
|
|
|
|
extern CPU_INSN_NAME_FN cgen_insn_name;
|
|
|
|
|
|
1998-07-01 23:47:50 +00:00
|
|
|
|
/* Return the maximum number of extra bytes required for a sim_cpu struct. */
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* ??? Ok, yes, this is less pretty than it should be. Give me a better
|
|
|
|
|
language [or suggest a better way]. */
|
1998-07-01 23:47:50 +00:00
|
|
|
|
extern int cgen_cpu_max_extra_bytes (void);
|
1997-05-01 01:48:27 +00:00
|
|
|
|
|
1998-07-01 23:47:50 +00:00
|
|
|
|
extern void
|
|
|
|
|
sim_disassemble_insn (SIM_CPU *, const CGEN_INSN *,
|
1998-02-05 21:29:18 +00:00
|
|
|
|
const struct argbuf *, PCADDR, char *);
|
1997-05-01 01:48:27 +00:00
|
|
|
|
|
1998-11-05 07:53:37 +00:00
|
|
|
|
/* Called to process an invalid instruction. */
|
|
|
|
|
extern void sim_engine_invalid_insn (SIM_CPU *, PCADDR);
|
|
|
|
|
|
1997-05-01 01:48:27 +00:00
|
|
|
|
#endif /* CGEN_SIM_H */
|