1997-04-03 02:37:44 +00:00
|
|
|
/* Simulator pseudo baseclass.
|
1998-03-27 04:25:45 +00:00
|
|
|
Copyright (C) 1997-1998 Free Software Foundation, Inc.
|
1997-04-03 02:37:44 +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. */
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
|
|
|
|
/* Simulator state pseudo baseclass.
|
|
|
|
|
1997-09-01 03:26:31 +00:00
|
|
|
Each simulator is required to have the file ``sim-main.h''. That
|
|
|
|
file includes ``sim-basics.h'', defines the base type ``sim_cia''
|
|
|
|
(the data type that contains complete current instruction address
|
|
|
|
information), include ``sim-base.h'':
|
1997-05-02 16:51:04 +00:00
|
|
|
|
|
|
|
#include "sim-basics.h"
|
|
|
|
typedef address_word sim_cia;
|
1998-02-27 18:39:22 +00:00
|
|
|
/-* If `sim_cia' is not an integral value (e.g. a struct), define
|
|
|
|
CIA_ADDR to return the integral value. *-/
|
|
|
|
/-* #define CIA_ADDR(cia) (...) *-/
|
1997-05-02 16:51:04 +00:00
|
|
|
#include "sim-base.h"
|
|
|
|
|
1998-02-27 18:39:22 +00:00
|
|
|
finally, two data types `struct _sim_cpu' and `struct sim_state'
|
1997-09-01 03:26:31 +00:00
|
|
|
are defined:
|
1997-05-02 16:51:04 +00:00
|
|
|
|
|
|
|
struct _sim_cpu {
|
|
|
|
... simulator specific members ...
|
|
|
|
sim_cpu_base base;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sim_state {
|
|
|
|
sim_cpu cpu[MAX_NR_PROCESSORS];
|
|
|
|
#if (WITH_SMP)
|
|
|
|
#define STATE_CPU(sd,n) (&(sd)->cpu[n])
|
|
|
|
#else
|
|
|
|
#define STATE_CPU(sd,n) (&(sd)->cpu[0])
|
|
|
|
#endif
|
|
|
|
... simulator specific members ...
|
|
|
|
sim_state_base base;
|
|
|
|
};
|
|
|
|
|
|
|
|
Note that `base' appears last. This makes `base.magic' appear last
|
|
|
|
in the entire struct and helps catch miscompilation errors. */
|
|
|
|
|
1997-04-03 02:37:44 +00:00
|
|
|
|
|
|
|
#ifndef SIM_BASE_H
|
|
|
|
#define SIM_BASE_H
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
/* Pre-declare certain types. */
|
|
|
|
|
|
|
|
/* typedef <target-dependant> sim_cia; */
|
|
|
|
#ifndef NULL_CIA
|
|
|
|
#define NULL_CIA ((sim_cia) 0)
|
|
|
|
#endif
|
1997-11-18 23:55:33 +00:00
|
|
|
/* Return the current instruction address as a number.
|
|
|
|
Some targets treat the current instruction address as a struct
|
|
|
|
(e.g. for delay slot handling). */
|
|
|
|
#ifndef CIA_ADDR
|
|
|
|
#define CIA_ADDR(cia) (cia)
|
|
|
|
#endif
|
1997-09-01 03:26:31 +00:00
|
|
|
#ifndef INVALID_INSTRUCTION_ADDRESS
|
|
|
|
#define INVALID_INSTRUCTION_ADDRESS ((address_word)0 - 1)
|
|
|
|
#endif
|
1997-11-18 23:55:33 +00:00
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
typedef struct _sim_cpu sim_cpu;
|
|
|
|
|
|
|
|
#include "sim-module.h"
|
1997-08-28 09:44:42 +00:00
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
#include "sim-trace.h"
|
|
|
|
#include "sim-core.h"
|
|
|
|
#include "sim-events.h"
|
1997-09-22 09:16:14 +00:00
|
|
|
#include "sim-profile.h"
|
|
|
|
#ifdef SIM_HAVE_MODEL
|
|
|
|
#include "sim-model.h"
|
|
|
|
#endif
|
1997-05-02 16:51:04 +00:00
|
|
|
#include "sim-io.h"
|
1997-08-28 09:44:42 +00:00
|
|
|
#include "sim-engine.h"
|
|
|
|
#include "sim-watch.h"
|
1997-09-04 03:47:39 +00:00
|
|
|
#include "sim-memopt.h"
|
1997-11-18 23:55:33 +00:00
|
|
|
#ifdef SIM_HAVE_BREAKPOINTS
|
|
|
|
#include "sim-break.h"
|
|
|
|
#endif
|
1997-05-02 16:51:04 +00:00
|
|
|
|
1997-04-03 02:37:44 +00:00
|
|
|
/* Global pointer to current state while sim_resume is running.
|
|
|
|
On a machine with lots of registers, it might be possible to reserve
|
|
|
|
one of them for current_state. However on a machine with few registers
|
|
|
|
current_state can't permanently live in one and indirecting through it
|
|
|
|
will be slower [in which case one can have sim_resume set globals from
|
|
|
|
current_state for faster access].
|
|
|
|
If CURRENT_STATE_REG is defined, it means current_state is living in
|
|
|
|
a global register. */
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
|
1997-04-03 02:37:44 +00:00
|
|
|
#ifdef CURRENT_STATE_REG
|
|
|
|
/* FIXME: wip */
|
|
|
|
#else
|
|
|
|
extern struct sim_state *current_state;
|
|
|
|
#endif
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
/* The simulator may provide different (and faster) definition. */
|
|
|
|
#ifndef CURRENT_STATE
|
|
|
|
#define CURRENT_STATE current_state
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
1997-05-02 16:51:04 +00:00
|
|
|
|
1997-04-03 02:37:44 +00:00
|
|
|
/* Simulator's argv[0]. */
|
|
|
|
const char *my_name;
|
|
|
|
#define STATE_MY_NAME(sd) ((sd)->base.my_name)
|
|
|
|
|
|
|
|
/* Who opened the simulator. */
|
|
|
|
SIM_OPEN_KIND open_kind;
|
|
|
|
#define STATE_OPEN_KIND(sd) ((sd)->base.open_kind)
|
|
|
|
|
|
|
|
/* The host callbacks. */
|
|
|
|
struct host_callback_struct *callback;
|
|
|
|
#define STATE_CALLBACK(sd) ((sd)->base.callback)
|
|
|
|
|
1998-03-09 21:04:28 +00:00
|
|
|
/* The type of simulation environment (user/operating). */
|
|
|
|
enum sim_environment environment;
|
|
|
|
#define STATE_ENVIRONMENT(sd) ((sd)->base.environment)
|
|
|
|
|
1997-04-03 02:37:44 +00:00
|
|
|
#if 0 /* FIXME: Not ready yet. */
|
|
|
|
/* Stuff defined in sim-config.h. */
|
|
|
|
struct sim_config config;
|
|
|
|
#define STATE_CONFIG(sd) ((sd)->base.config)
|
|
|
|
#endif
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
|
* Makefile.in (sim-options_h): Define.
(sim-{module,options,trace,profile,utils}.o): Clean up dependencies.
(sim-model.o): Add new rule.
(cgen-{scache,trace,utils}.o): Add new rules.
* aclocal.m4 (SIM_AC_OPTION_{SCACHE,DEFAULT_MODEL}): Add.
* cgen-scache.c (scache_print_profile): Change `sd' arg to `cpu'.
Indent output by 2 spaces.
* cgen-scache.h (scache_print_profile): Update.
* cgen-trace.c (trace_insn_fini): Indent output by 2 spaces.
Use trace_printf, not fprintf.
(trace_extract): Use trace_printf, not cgen_trace_printf.
* genmloop.sh (!FAST case): Increment `insn_count'.
* sim-base.h (sim_state_base): Only include scache_size if WITH_SCACHE.
(sim_cpu_base): Rename member `sd' to `state' to be consistent with
access macro's name.
* sim-core.c (sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
(sim_core_{install,uninstall}): New functions.
* sim-core.h (sim_core_{install,uninstall}): Declare.
(sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
* sim-model.h (models,machs,model_install): Declare.
* sim-module.c (modules): Add scache_install, model_install.
(sim_post_argv_init): Set cpu->state backlinks.
* sim-options.c (standard_options): Delete --simcache-size,--max-insns.
(standard_option_handler): Likewise.
* sim-profile.c (PROFILE_{HISTOGRAM,LABEL}_WIDTH): Move to
sim-profile.h.
(*): Assume ANSI C.
(profile_options): Delete --profile-simcache.
(profile_option_handler): Likewise.
(profile_print_insn): Change `sd' arg to `cpu'. Indent output 2
spaces.
(profile_print_{memory,model}): Likewise.
(profile_print_simcache): Delete.
(profile_print_speed): New function.
(profile_print): Rewrite.
* sim-profile.h (PROFILE_scache): Renamed from PROFILE_simcache.
(WITH_PROFILE_SCACHE_P): Renamed from WITH_PROFILE_SIMCACHE_P.
(PROFILE_DATA): Delete members simcache_{hits,misses}.
(PROFILE_COUNT_SIMCACHE_{HIT,MISS}): Delete.
(PROFILE_{CALLBACK,CPU_CALLBACK}): New types.
(profile_print): Update prototype.
1997-05-01 18:05:37 +00:00
|
|
|
/* List of installed module `init' handlers. */
|
1998-02-28 02:51:06 +00:00
|
|
|
struct module_list *modules;
|
|
|
|
#define STATE_MODULES(sd) ((sd)->base.modules)
|
* Makefile.in (sim-options_h): Define.
(sim-{module,options,trace,profile,utils}.o): Clean up dependencies.
(sim-model.o): Add new rule.
(cgen-{scache,trace,utils}.o): Add new rules.
* aclocal.m4 (SIM_AC_OPTION_{SCACHE,DEFAULT_MODEL}): Add.
* cgen-scache.c (scache_print_profile): Change `sd' arg to `cpu'.
Indent output by 2 spaces.
* cgen-scache.h (scache_print_profile): Update.
* cgen-trace.c (trace_insn_fini): Indent output by 2 spaces.
Use trace_printf, not fprintf.
(trace_extract): Use trace_printf, not cgen_trace_printf.
* genmloop.sh (!FAST case): Increment `insn_count'.
* sim-base.h (sim_state_base): Only include scache_size if WITH_SCACHE.
(sim_cpu_base): Rename member `sd' to `state' to be consistent with
access macro's name.
* sim-core.c (sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
(sim_core_{install,uninstall}): New functions.
* sim-core.h (sim_core_{install,uninstall}): Declare.
(sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
* sim-model.h (models,machs,model_install): Declare.
* sim-module.c (modules): Add scache_install, model_install.
(sim_post_argv_init): Set cpu->state backlinks.
* sim-options.c (standard_options): Delete --simcache-size,--max-insns.
(standard_option_handler): Likewise.
* sim-profile.c (PROFILE_{HISTOGRAM,LABEL}_WIDTH): Move to
sim-profile.h.
(*): Assume ANSI C.
(profile_options): Delete --profile-simcache.
(profile_option_handler): Likewise.
(profile_print_insn): Change `sd' arg to `cpu'. Indent output 2
spaces.
(profile_print_{memory,model}): Likewise.
(profile_print_simcache): Delete.
(profile_print_speed): New function.
(profile_print): Rewrite.
* sim-profile.h (PROFILE_scache): Renamed from PROFILE_simcache.
(WITH_PROFILE_SCACHE_P): Renamed from WITH_PROFILE_SIMCACHE_P.
(PROFILE_DATA): Delete members simcache_{hits,misses}.
(PROFILE_COUNT_SIMCACHE_{HIT,MISS}): Delete.
(PROFILE_{CALLBACK,CPU_CALLBACK}): New types.
(profile_print): Update prototype.
1997-05-01 18:05:37 +00:00
|
|
|
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
/* Supported options. */
|
|
|
|
struct option_list *options;
|
|
|
|
#define STATE_OPTIONS(sd) ((sd)->base.options)
|
|
|
|
|
|
|
|
/* Non-zero if -v specified. */
|
|
|
|
int verbose_p;
|
|
|
|
#define STATE_VERBOSE_P(sd) ((sd)->base.verbose_p)
|
|
|
|
|
1997-11-18 23:55:33 +00:00
|
|
|
/* Non cpu-specific trace data. See sim-trace.h. */
|
|
|
|
TRACE_DATA trace_data;
|
|
|
|
#define STATE_TRACE_DATA(sd) (& (sd)->base.trace_data)
|
|
|
|
|
1997-08-28 09:44:42 +00:00
|
|
|
/* If non NULL, the BFD architecture specified on the command line */
|
|
|
|
const struct bfd_arch_info *architecture;
|
|
|
|
#define STATE_ARCHITECTURE(sd) ((sd)->base.architecture)
|
|
|
|
|
|
|
|
/* If non NULL, the bfd target specified on the command line */
|
|
|
|
const char *target;
|
|
|
|
#define STATE_TARGET(sd) ((sd)->base.target)
|
|
|
|
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
/* In standalone simulator, this is the program's arguments passed
|
|
|
|
on the command line. */
|
|
|
|
char **prog_argv;
|
|
|
|
#define STATE_PROG_ARGV(sd) ((sd)->base.prog_argv)
|
|
|
|
|
|
|
|
/* The program's bfd. */
|
|
|
|
struct _bfd *prog_bfd;
|
|
|
|
#define STATE_PROG_BFD(sd) ((sd)->base.prog_bfd)
|
|
|
|
|
1998-03-27 04:25:45 +00:00
|
|
|
/* Symbol table for prog_bfd */
|
|
|
|
struct symbol_cache_entry **prog_syms;
|
|
|
|
#define STATE_PROG_SYMS(sd) ((sd)->base.prog_syms)
|
|
|
|
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
/* The program's text section. */
|
|
|
|
struct sec *text_section;
|
|
|
|
/* Starting and ending text section addresses from the bfd. */
|
|
|
|
SIM_ADDR text_start, text_end;
|
|
|
|
#define STATE_TEXT_SECTION(sd) ((sd)->base.text_section)
|
|
|
|
#define STATE_TEXT_START(sd) ((sd)->base.text_start)
|
|
|
|
#define STATE_TEXT_END(sd) ((sd)->base.text_end)
|
|
|
|
|
|
|
|
/* Start address, set when the program is loaded from the bfd. */
|
|
|
|
SIM_ADDR start_addr;
|
|
|
|
#define STATE_START_ADDR(sd) ((sd)->base.start_addr)
|
|
|
|
|
|
|
|
/* Size of the simulator's cache, if any.
|
|
|
|
This is not the target's cache. It is the cache the simulator uses
|
|
|
|
to process instructions. */
|
* Makefile.in (sim-options_h): Define.
(sim-{module,options,trace,profile,utils}.o): Clean up dependencies.
(sim-model.o): Add new rule.
(cgen-{scache,trace,utils}.o): Add new rules.
* aclocal.m4 (SIM_AC_OPTION_{SCACHE,DEFAULT_MODEL}): Add.
* cgen-scache.c (scache_print_profile): Change `sd' arg to `cpu'.
Indent output by 2 spaces.
* cgen-scache.h (scache_print_profile): Update.
* cgen-trace.c (trace_insn_fini): Indent output by 2 spaces.
Use trace_printf, not fprintf.
(trace_extract): Use trace_printf, not cgen_trace_printf.
* genmloop.sh (!FAST case): Increment `insn_count'.
* sim-base.h (sim_state_base): Only include scache_size if WITH_SCACHE.
(sim_cpu_base): Rename member `sd' to `state' to be consistent with
access macro's name.
* sim-core.c (sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
(sim_core_{install,uninstall}): New functions.
* sim-core.h (sim_core_{install,uninstall}): Declare.
(sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
* sim-model.h (models,machs,model_install): Declare.
* sim-module.c (modules): Add scache_install, model_install.
(sim_post_argv_init): Set cpu->state backlinks.
* sim-options.c (standard_options): Delete --simcache-size,--max-insns.
(standard_option_handler): Likewise.
* sim-profile.c (PROFILE_{HISTOGRAM,LABEL}_WIDTH): Move to
sim-profile.h.
(*): Assume ANSI C.
(profile_options): Delete --profile-simcache.
(profile_option_handler): Likewise.
(profile_print_insn): Change `sd' arg to `cpu'. Indent output 2
spaces.
(profile_print_{memory,model}): Likewise.
(profile_print_simcache): Delete.
(profile_print_speed): New function.
(profile_print): Rewrite.
* sim-profile.h (PROFILE_scache): Renamed from PROFILE_simcache.
(WITH_PROFILE_SCACHE_P): Renamed from WITH_PROFILE_SIMCACHE_P.
(PROFILE_DATA): Delete members simcache_{hits,misses}.
(PROFILE_COUNT_SIMCACHE_{HIT,MISS}): Delete.
(PROFILE_{CALLBACK,CPU_CALLBACK}): New types.
(profile_print): Update prototype.
1997-05-01 18:05:37 +00:00
|
|
|
unsigned int scache_size;
|
|
|
|
#define STATE_SCACHE_SIZE(sd) ((sd)->base.scache_size)
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
|
|
|
|
/* FIXME: Move to top level sim_state struct (as some struct)? */
|
|
|
|
#ifdef SIM_HAVE_FLATMEM
|
|
|
|
unsigned int mem_size;
|
|
|
|
#define STATE_MEM_SIZE(sd) ((sd)->base.mem_size)
|
1997-08-28 09:44:42 +00:00
|
|
|
unsigned int mem_base;
|
|
|
|
#define STATE_MEM_BASE(sd) ((sd)->base.mem_base)
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
unsigned char *memory;
|
|
|
|
#define STATE_MEMORY(sd) ((sd)->base.memory)
|
|
|
|
#endif
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
/* core memory bus */
|
|
|
|
#define STATE_CORE(sd) (&(sd)->base.core)
|
|
|
|
sim_core core;
|
|
|
|
|
1998-03-03 00:10:34 +00:00
|
|
|
/* Record of memory sections added via the memory-options interface. */
|
1997-09-04 03:47:39 +00:00
|
|
|
#define STATE_MEMOPT(sd) ((sd)->base.memopt)
|
|
|
|
sim_memopt *memopt;
|
|
|
|
|
1998-04-21 21:19:45 +00:00
|
|
|
/* start-sanitize-sky */
|
|
|
|
#ifdef TARGET_SKY
|
|
|
|
#ifdef SKY_FUNIT
|
|
|
|
/* Record of option for floating point implementation type. */
|
|
|
|
#define STATE_FP_TYPE_OPT(sd) ((sd)->base.fp_type_opt)
|
|
|
|
#define STATE_FP_TYPE_OPT_TARGET 0x80000000
|
|
|
|
int fp_type_opt;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/* end-sanitize-sky */
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
/* event handler */
|
|
|
|
#define STATE_EVENTS(sd) (&(sd)->base.events)
|
|
|
|
sim_events events;
|
|
|
|
|
1997-08-28 09:44:42 +00:00
|
|
|
/* generic halt/resume engine */
|
|
|
|
sim_engine engine;
|
|
|
|
#define STATE_ENGINE(sd) (&(sd)->base.engine)
|
|
|
|
|
|
|
|
/* generic watchpoint support */
|
|
|
|
sim_watchpoints watchpoints;
|
|
|
|
#define STATE_WATCHPOINTS(sd) (&(sd)->base.watchpoints)
|
|
|
|
|
1997-11-18 23:55:33 +00:00
|
|
|
/* Pointer to list of breakpoints */
|
|
|
|
struct sim_breakpoint *breakpoints;
|
|
|
|
#define STATE_BREAKPOINTS(sd) ((sd)->base.breakpoints)
|
|
|
|
|
1998-03-27 11:42:16 +00:00
|
|
|
/* start-sanitize-am30 */
|
|
|
|
#if WITH_HW
|
|
|
|
struct sim_hw *hw;
|
|
|
|
#define STATE_HW(sd) ((sd)->base.hw)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* end-sanitize-am30 */
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
/* Marker for those wanting to do sanity checks.
|
|
|
|
This should remain the last member of this struct to help catch
|
|
|
|
miscompilation errors. */
|
|
|
|
int magic;
|
|
|
|
#define SIM_MAGIC_NUMBER 0x4242
|
|
|
|
#define STATE_MAGIC(sd) ((sd)->base.magic)
|
|
|
|
} sim_state_base;
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
/* Pseudo baseclass for each cpu. */
|
|
|
|
|
|
|
|
typedef struct {
|
1997-05-02 16:51:04 +00:00
|
|
|
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
/* Backlink to main state struct. */
|
* Makefile.in (sim-options_h): Define.
(sim-{module,options,trace,profile,utils}.o): Clean up dependencies.
(sim-model.o): Add new rule.
(cgen-{scache,trace,utils}.o): Add new rules.
* aclocal.m4 (SIM_AC_OPTION_{SCACHE,DEFAULT_MODEL}): Add.
* cgen-scache.c (scache_print_profile): Change `sd' arg to `cpu'.
Indent output by 2 spaces.
* cgen-scache.h (scache_print_profile): Update.
* cgen-trace.c (trace_insn_fini): Indent output by 2 spaces.
Use trace_printf, not fprintf.
(trace_extract): Use trace_printf, not cgen_trace_printf.
* genmloop.sh (!FAST case): Increment `insn_count'.
* sim-base.h (sim_state_base): Only include scache_size if WITH_SCACHE.
(sim_cpu_base): Rename member `sd' to `state' to be consistent with
access macro's name.
* sim-core.c (sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
(sim_core_{install,uninstall}): New functions.
* sim-core.h (sim_core_{install,uninstall}): Declare.
(sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
* sim-model.h (models,machs,model_install): Declare.
* sim-module.c (modules): Add scache_install, model_install.
(sim_post_argv_init): Set cpu->state backlinks.
* sim-options.c (standard_options): Delete --simcache-size,--max-insns.
(standard_option_handler): Likewise.
* sim-profile.c (PROFILE_{HISTOGRAM,LABEL}_WIDTH): Move to
sim-profile.h.
(*): Assume ANSI C.
(profile_options): Delete --profile-simcache.
(profile_option_handler): Likewise.
(profile_print_insn): Change `sd' arg to `cpu'. Indent output 2
spaces.
(profile_print_{memory,model}): Likewise.
(profile_print_simcache): Delete.
(profile_print_speed): New function.
(profile_print): Rewrite.
* sim-profile.h (PROFILE_scache): Renamed from PROFILE_simcache.
(WITH_PROFILE_SCACHE_P): Renamed from WITH_PROFILE_SIMCACHE_P.
(PROFILE_DATA): Delete members simcache_{hits,misses}.
(PROFILE_COUNT_SIMCACHE_{HIT,MISS}): Delete.
(PROFILE_{CALLBACK,CPU_CALLBACK}): New types.
(profile_print): Update prototype.
1997-05-01 18:05:37 +00:00
|
|
|
SIM_DESC state;
|
|
|
|
#define CPU_STATE(cpu) ((cpu)->base.state)
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
|
1998-03-27 04:25:45 +00:00
|
|
|
/* Processor index within the SD_DESC */
|
|
|
|
int index;
|
|
|
|
#define CPU_INDEX(cpu) ((cpu)->base.index)
|
|
|
|
|
1998-02-27 18:39:22 +00:00
|
|
|
/* The name of the cpu. */
|
|
|
|
const char *name;
|
|
|
|
#define CPU_NAME(cpu) ((cpu)->base.name)
|
|
|
|
|
|
|
|
/* Options specific to this cpu. */
|
|
|
|
struct option_list *options;
|
|
|
|
#define CPU_OPTIONS(cpu) ((cpu)->base.options)
|
|
|
|
|
1997-05-05 13:21:04 +00:00
|
|
|
/* Processor specific core data */
|
|
|
|
sim_cpu_core core;
|
1997-08-28 09:44:42 +00:00
|
|
|
#define CPU_CORE(cpu) (& (cpu)->base.core)
|
1997-05-05 13:21:04 +00:00
|
|
|
|
* Makefile.in (sim-options_h): Define.
(sim-{module,options,trace,profile,utils}.o): Clean up dependencies.
(sim-model.o): Add new rule.
(cgen-{scache,trace,utils}.o): Add new rules.
* aclocal.m4 (SIM_AC_OPTION_{SCACHE,DEFAULT_MODEL}): Add.
* cgen-scache.c (scache_print_profile): Change `sd' arg to `cpu'.
Indent output by 2 spaces.
* cgen-scache.h (scache_print_profile): Update.
* cgen-trace.c (trace_insn_fini): Indent output by 2 spaces.
Use trace_printf, not fprintf.
(trace_extract): Use trace_printf, not cgen_trace_printf.
* genmloop.sh (!FAST case): Increment `insn_count'.
* sim-base.h (sim_state_base): Only include scache_size if WITH_SCACHE.
(sim_cpu_base): Rename member `sd' to `state' to be consistent with
access macro's name.
* sim-core.c (sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
(sim_core_{install,uninstall}): New functions.
* sim-core.h (sim_core_{install,uninstall}): Declare.
(sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
* sim-model.h (models,machs,model_install): Declare.
* sim-module.c (modules): Add scache_install, model_install.
(sim_post_argv_init): Set cpu->state backlinks.
* sim-options.c (standard_options): Delete --simcache-size,--max-insns.
(standard_option_handler): Likewise.
* sim-profile.c (PROFILE_{HISTOGRAM,LABEL}_WIDTH): Move to
sim-profile.h.
(*): Assume ANSI C.
(profile_options): Delete --profile-simcache.
(profile_option_handler): Likewise.
(profile_print_insn): Change `sd' arg to `cpu'. Indent output 2
spaces.
(profile_print_{memory,model}): Likewise.
(profile_print_simcache): Delete.
(profile_print_speed): New function.
(profile_print): Rewrite.
* sim-profile.h (PROFILE_scache): Renamed from PROFILE_simcache.
(WITH_PROFILE_SCACHE_P): Renamed from WITH_PROFILE_SIMCACHE_P.
(PROFILE_DATA): Delete members simcache_{hits,misses}.
(PROFILE_COUNT_SIMCACHE_{HIT,MISS}): Delete.
(PROFILE_{CALLBACK,CPU_CALLBACK}): New types.
(profile_print): Update prototype.
1997-05-01 18:05:37 +00:00
|
|
|
/* Trace data. See sim-trace.h. */
|
|
|
|
TRACE_DATA trace_data;
|
|
|
|
#define CPU_TRACE_DATA(cpu) (& (cpu)->base.trace_data)
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
|
|
|
|
/* Maximum number of debuggable entities.
|
|
|
|
This debugging is not intended for normal use.
|
|
|
|
It is only enabled when the simulator is configured with --with-debug
|
|
|
|
which shouldn't normally be specified. */
|
|
|
|
#ifndef MAX_DEBUG_VALUES
|
|
|
|
#define MAX_DEBUG_VALUES 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Boolean array of specified debugging flags. */
|
|
|
|
char debug_flags[MAX_DEBUG_VALUES];
|
|
|
|
#define CPU_DEBUG_FLAGS(cpu) ((cpu)->base.debug_flags)
|
|
|
|
/* Standard values. */
|
|
|
|
#define DEBUG_INSN_IDX 0
|
|
|
|
#define DEBUG_NEXT_IDX 2 /* simulator specific debug bits begin here */
|
|
|
|
|
|
|
|
/* Debugging output goes to this or stderr if NULL.
|
|
|
|
We can't store `stderr' here as stderr goes through a callback. */
|
|
|
|
FILE *debug_file;
|
1997-04-17 14:07:43 +00:00
|
|
|
#define CPU_DEBUG_FILE(cpu) ((cpu)->base.debug_file)
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
|
* Makefile.in (sim-options_h): Define.
(sim-{module,options,trace,profile,utils}.o): Clean up dependencies.
(sim-model.o): Add new rule.
(cgen-{scache,trace,utils}.o): Add new rules.
* aclocal.m4 (SIM_AC_OPTION_{SCACHE,DEFAULT_MODEL}): Add.
* cgen-scache.c (scache_print_profile): Change `sd' arg to `cpu'.
Indent output by 2 spaces.
* cgen-scache.h (scache_print_profile): Update.
* cgen-trace.c (trace_insn_fini): Indent output by 2 spaces.
Use trace_printf, not fprintf.
(trace_extract): Use trace_printf, not cgen_trace_printf.
* genmloop.sh (!FAST case): Increment `insn_count'.
* sim-base.h (sim_state_base): Only include scache_size if WITH_SCACHE.
(sim_cpu_base): Rename member `sd' to `state' to be consistent with
access macro's name.
* sim-core.c (sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
(sim_core_{install,uninstall}): New functions.
* sim-core.h (sim_core_{install,uninstall}): Declare.
(sim_core_init): Use EXTERN_SIM_CORE to define it.
Change return type to SIM_RC.
* sim-model.h (models,machs,model_install): Declare.
* sim-module.c (modules): Add scache_install, model_install.
(sim_post_argv_init): Set cpu->state backlinks.
* sim-options.c (standard_options): Delete --simcache-size,--max-insns.
(standard_option_handler): Likewise.
* sim-profile.c (PROFILE_{HISTOGRAM,LABEL}_WIDTH): Move to
sim-profile.h.
(*): Assume ANSI C.
(profile_options): Delete --profile-simcache.
(profile_option_handler): Likewise.
(profile_print_insn): Change `sd' arg to `cpu'. Indent output 2
spaces.
(profile_print_{memory,model}): Likewise.
(profile_print_simcache): Delete.
(profile_print_speed): New function.
(profile_print): Rewrite.
* sim-profile.h (PROFILE_scache): Renamed from PROFILE_simcache.
(WITH_PROFILE_SCACHE_P): Renamed from WITH_PROFILE_SIMCACHE_P.
(PROFILE_DATA): Delete members simcache_{hits,misses}.
(PROFILE_COUNT_SIMCACHE_{HIT,MISS}): Delete.
(PROFILE_{CALLBACK,CPU_CALLBACK}): New types.
(profile_print): Update prototype.
1997-05-01 18:05:37 +00:00
|
|
|
/* Profile data. See sim-profile.h. */
|
|
|
|
PROFILE_DATA profile_data;
|
|
|
|
#define CPU_PROFILE_DATA(cpu) (& (cpu)->base.profile_data)
|
1997-05-02 16:51:04 +00:00
|
|
|
|
1998-02-27 18:39:22 +00:00
|
|
|
#ifdef SIM_HAVE_MODEL
|
|
|
|
/* Machine tables for this cpu. See sim-model.h. */
|
|
|
|
const MACH *mach;
|
|
|
|
#define CPU_MACH(cpu) ((cpu)->base.mach)
|
|
|
|
/* The selected model. */
|
|
|
|
const MODEL *model;
|
|
|
|
#define CPU_MODEL(cpu) ((cpu)->base.model)
|
|
|
|
#endif
|
|
|
|
|
* Make-common.in (sim-options.o, sim-load.o): Add rules for.
(sim_main_headers): Add sim-trace.h.
* run.c (exec_bfd, target_byte_order): Delete.
(main): Pass -E <endian> to sim_open. Delete code to load sections,
call sim_load instead. Check return code of sim_create_inferior.
* sim-base.h (CURRENT_STATE): Define.
(sim_state_base): Make typedef. New members options, prog_argv,
prog_bfd, text_{section,start,end}, start_addr, simcache_size,
mem_size, memory [+ corresponding access macros].
(sim_cpu_base): New typedef.
* sim-trace.h: New file.
* sim-basics.h: #include it.
* sim-load.c: New file.
1997-04-17 09:37:02 +00:00
|
|
|
} sim_cpu_base;
|
1997-04-03 02:37:44 +00:00
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
|
1997-04-03 02:37:44 +00:00
|
|
|
/* Functions for allocating/freeing a sim_state. */
|
1997-09-01 03:26:31 +00:00
|
|
|
SIM_DESC sim_state_alloc PARAMS ((SIM_OPEN_KIND kind, host_callback *callback));
|
1997-04-03 02:37:44 +00:00
|
|
|
void sim_state_free PARAMS ((SIM_DESC));
|
|
|
|
|
1998-02-27 18:39:22 +00:00
|
|
|
/* Return a pointer to the cpu data for CPU_NAME, or NULL if not found. */
|
|
|
|
sim_cpu *sim_cpu_lookup (SIM_DESC sd, const char *cpu_name);
|
|
|
|
|
1997-05-02 16:51:04 +00:00
|
|
|
|
1997-04-03 02:37:44 +00:00
|
|
|
#endif /* SIM_BASE_H */
|