OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [common/] [sim-engine.h] - Diff between revs 834 and 842

Only display areas with differences | Details | Blame | View Log

Rev 834 Rev 842
/* Generic simulator halt/resume.
/* Generic simulator halt/resume.
   Copyright (C) 1997, 1998, 2007, 2008, 2009, 2010
   Copyright (C) 1997, 1998, 2007, 2008, 2009, 2010
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
   Contributed by Cygnus Support.
   Contributed by Cygnus Support.
 
 
This file is part of GDB, the GNU debugger.
This file is part of GDB, the GNU debugger.
 
 
This program is free software; you can redistribute it and/or modify
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
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
#ifndef SIM_ENGINE_H
#ifndef SIM_ENGINE_H
#define SIM_ENGINE_H
#define SIM_ENGINE_H
 
 
 
 
typedef struct _sim_engine sim_engine;
typedef struct _sim_engine sim_engine;
struct _sim_engine
struct _sim_engine
{
{
  void *jmpbuf;
  void *jmpbuf;
  sim_cpu *last_cpu;
  sim_cpu *last_cpu;
  sim_cpu *next_cpu;
  sim_cpu *next_cpu;
  int nr_cpus;
  int nr_cpus;
  enum sim_stop reason;
  enum sim_stop reason;
  sim_event *stepper;
  sim_event *stepper;
  int sigrc;
  int sigrc;
};
};
 
 
 
 
 
 
/* jmpval: 0 (initial use) start simulator
/* jmpval: 0 (initial use) start simulator
           1               halt simulator
           1               halt simulator
           2               restart simulator
           2               restart simulator
   This is required by the ISO C standard (the only time 0 is returned
   This is required by the ISO C standard (the only time 0 is returned
   is at the initial call to setjmp). */
   is at the initial call to setjmp). */
 
 
enum {
enum {
  sim_engine_start_jmpval,
  sim_engine_start_jmpval,
  sim_engine_halt_jmpval,
  sim_engine_halt_jmpval,
  sim_engine_restart_jmpval,
  sim_engine_restart_jmpval,
};
};
 
 
 
 
/* Get/set the run state of CPU to REASON/SIGRC.
/* Get/set the run state of CPU to REASON/SIGRC.
   REASON/SIGRC are the values returned by sim_stop_reason.  */
   REASON/SIGRC are the values returned by sim_stop_reason.  */
void sim_engine_get_run_state (SIM_DESC sd, enum sim_stop *reason, int *sigrc);
void sim_engine_get_run_state (SIM_DESC sd, enum sim_stop *reason, int *sigrc);
void sim_engine_set_run_state (SIM_DESC sd, enum sim_stop reason, int sigrc);
void sim_engine_set_run_state (SIM_DESC sd, enum sim_stop reason, int sigrc);
 
 
 
 
/* Halt the simulator *now* */
/* Halt the simulator *now* */
 
 
extern void sim_engine_halt
extern void sim_engine_halt
(SIM_DESC sd,
(SIM_DESC sd,
 sim_cpu *last_cpu, /* NULL -> in event-mgr */
 sim_cpu *last_cpu, /* NULL -> in event-mgr */
 sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
 sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
 sim_cia cia,
 sim_cia cia,
 enum sim_stop reason,
 enum sim_stop reason,
 int sigrc) __attribute__ ((noreturn));
 int sigrc) __attribute__ ((noreturn));
 
 
/* Halt hook - allow target specific operation when halting a
/* Halt hook - allow target specific operation when halting a
   simulator */
   simulator */
 
 
#if !defined (SIM_ENGINE_HALT_HOOK)
#if !defined (SIM_ENGINE_HALT_HOOK)
#define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) \
#define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) \
if ((LAST_CPU) != NULL) CIA_SET (LAST_CPU, CIA)
if ((LAST_CPU) != NULL) CIA_SET (LAST_CPU, CIA)
#endif
#endif
 
 
/* NB: If a port uses the SIM_CPU_EXCEPTION_* hooks, the default
/* NB: If a port uses the SIM_CPU_EXCEPTION_* hooks, the default
   SIM_ENGINE_HALT_HOOK and SIM_ENGINE_RESUME_HOOK must not be used.
   SIM_ENGINE_HALT_HOOK and SIM_ENGINE_RESUME_HOOK must not be used.
   They conflict in that the PC set by the HALT_HOOK may overwrite the
   They conflict in that the PC set by the HALT_HOOK may overwrite the
   proper one, as intended to be saved by the EXCEPTION_TRIGGER
   proper one, as intended to be saved by the EXCEPTION_TRIGGER
   hook. */
   hook. */
 
 
 
 
/* restart the simulator *now* */
/* restart the simulator *now* */
 
 
extern void sim_engine_restart
extern void sim_engine_restart
(SIM_DESC sd,
(SIM_DESC sd,
 sim_cpu *last_cpu, /* NULL -> in event-mgr */
 sim_cpu *last_cpu, /* NULL -> in event-mgr */
 sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
 sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
 sim_cia cia);
 sim_cia cia);
 
 
/* Restart hook - allow target specific operation when restarting a
/* Restart hook - allow target specific operation when restarting a
   simulator */
   simulator */
 
 
#if !defined (SIM_ENGINE_RESTART_HOOK)
#if !defined (SIM_ENGINE_RESTART_HOOK)
#define SIM_ENGINE_RESTART_HOOK(SD, LAST_CPU, CIA) SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA)
#define SIM_ENGINE_RESTART_HOOK(SD, LAST_CPU, CIA) SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA)
#endif
#endif
 
 
 
 
 
 
 
 
/* Abort the simulator *now*.
/* Abort the simulator *now*.
 
 
   This function is NULL safe.  It can be called when either of SD or
   This function is NULL safe.  It can be called when either of SD or
   CIA are NULL.
   CIA are NULL.
 
 
   This function is setjmp/longjmp safe.  It can be called when of
   This function is setjmp/longjmp safe.  It can be called when of
   the sim_engine setjmp/longjmp buffer has not been established.
   the sim_engine setjmp/longjmp buffer has not been established.
 
 
   Simulators that are using components such as sim-core but are not
   Simulators that are using components such as sim-core but are not
   yet using this sim-engine module should link in file sim-abort.o
   yet using this sim-engine module should link in file sim-abort.o
   which implements a non setjmp/longjmp version of
   which implements a non setjmp/longjmp version of
   sim_engine_abort. */
   sim_engine_abort. */
 
 
extern void sim_engine_abort
extern void sim_engine_abort
(SIM_DESC sd,
(SIM_DESC sd,
 sim_cpu *cpu,
 sim_cpu *cpu,
 sim_cia cia,
 sim_cia cia,
 const char *fmt,
 const char *fmt,
 ...) __attribute__ ((format (printf, 4, 5))) __attribute__ ((noreturn));
 ...) __attribute__ ((format (printf, 4, 5))) __attribute__ ((noreturn));
 
 
extern void sim_engine_vabort
extern void sim_engine_vabort
(SIM_DESC sd,
(SIM_DESC sd,
 sim_cpu *cpu,
 sim_cpu *cpu,
 sim_cia cia,
 sim_cia cia,
 const char *fmt,
 const char *fmt,
 va_list ap) __attribute__ ((noreturn));
 va_list ap) __attribute__ ((noreturn));
 
 
/* No abort hook - when possible this function exits using the
/* No abort hook - when possible this function exits using the
   engine_halt function (and SIM_ENGINE_HALT_HOOK). */
   engine_halt function (and SIM_ENGINE_HALT_HOOK). */
 
 
 
 
 
 
 
 
/* Called by the generic sim_resume to run the simulation within the
/* Called by the generic sim_resume to run the simulation within the
   above safty net.
   above safty net.
 
 
   An example implementation of sim_engine_run can be found in the
   An example implementation of sim_engine_run can be found in the
   file sim-run.c */
   file sim-run.c */
 
 
extern void sim_engine_run
extern void sim_engine_run
(SIM_DESC sd,
(SIM_DESC sd,
 int next_cpu_nr,
 int next_cpu_nr,
 int nr_cpus,
 int nr_cpus,
 int siggnal); /* most simulators ignore siggnal */
 int siggnal); /* most simulators ignore siggnal */
 
 
 
 
 
 
/* Determine the state of next/last cpu when the simulator was last
/* Determine the state of next/last cpu when the simulator was last
   halted - a value >= MAX_NR_PROCESSORS indicates that the
   halted - a value >= MAX_NR_PROCESSORS indicates that the
   event-queue was next/last. */
   event-queue was next/last. */
 
 
extern int sim_engine_next_cpu_nr (SIM_DESC sd);
extern int sim_engine_next_cpu_nr (SIM_DESC sd);
extern int sim_engine_last_cpu_nr (SIM_DESC sd);
extern int sim_engine_last_cpu_nr (SIM_DESC sd);
extern int sim_engine_nr_cpus (SIM_DESC sd);
extern int sim_engine_nr_cpus (SIM_DESC sd);
 
 
 
 
/* Establish the simulator engine */
/* Establish the simulator engine */
MODULE_INSTALL_FN sim_engine_install;
MODULE_INSTALL_FN sim_engine_install;
 
 
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.