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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [cris/] [sim-main.h] - Diff between revs 816 and 834

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 834
/* Main header for the CRIS simulator, based on the m32r header.
/* Main header for the CRIS simulator, based on the m32r header.
   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
   Contributed by Axis Communications.
   Contributed by Axis Communications.
 
 
This file is part of the GNU simulators.
This file is part of the GNU simulators.
 
 
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/>.  */
 
 
/* All FIXME:s present in m32r apply here too; I just refuse to blindly
/* All FIXME:s present in m32r apply here too; I just refuse to blindly
   carry them over, as I don't know if they're really things that need
   carry them over, as I don't know if they're really things that need
   fixing.  */
   fixing.  */
 
 
#ifndef SIM_MAIN_H
#ifndef SIM_MAIN_H
#define SIM_MAIN_H
#define SIM_MAIN_H
 
 
#define USING_SIM_BASE_H
#define USING_SIM_BASE_H
 
 
struct _sim_cpu;
struct _sim_cpu;
typedef struct _sim_cpu SIM_CPU;
typedef struct _sim_cpu SIM_CPU;
 
 
#include "symcat.h"
#include "symcat.h"
#include "sim-basics.h"
#include "sim-basics.h"
#include "cgen-types.h"
#include "cgen-types.h"
#include "cris-desc.h"
#include "cris-desc.h"
#include "cris-opc.h"
#include "cris-opc.h"
#include "arch.h"
#include "arch.h"
 
 
/* These must be defined before sim-base.h.  */
/* These must be defined before sim-base.h.  */
typedef USI sim_cia;
typedef USI sim_cia;
 
 
#define CIA_GET(cpu)     CPU_PC_GET (cpu)
#define CIA_GET(cpu)     CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
 
 
#define SIM_ENGINE_HALT_HOOK(sd, cpu, cia) \
#define SIM_ENGINE_HALT_HOOK(sd, cpu, cia) \
do { \
do { \
  if (cpu) /* Null if ctrl-c.  */ \
  if (cpu) /* Null if ctrl-c.  */ \
    sim_pc_set ((cpu), (cia)); \
    sim_pc_set ((cpu), (cia)); \
} while (0)
} while (0)
#define SIM_ENGINE_RESTART_HOOK(sd, cpu, cia) \
#define SIM_ENGINE_RESTART_HOOK(sd, cpu, cia) \
do { \
do { \
  sim_pc_set ((cpu), (cia)); \
  sim_pc_set ((cpu), (cia)); \
} while (0)
} while (0)
 
 
#include "sim-base.h"
#include "sim-base.h"
#include "cgen-sim.h"
#include "cgen-sim.h"
#include "cris-sim.h"
#include "cris-sim.h"


struct cris_sim_mmapped_page {
struct cris_sim_mmapped_page {
  USI addr;
  USI addr;
  struct cris_sim_mmapped_page *prev;
  struct cris_sim_mmapped_page *prev;
};
};
 
 
struct cris_thread_info {
struct cris_thread_info {
  /* Identifier for this thread.  */
  /* Identifier for this thread.  */
  unsigned int threadid;
  unsigned int threadid;
 
 
  /* Identifier for parent thread.  */
  /* Identifier for parent thread.  */
  unsigned int parent_threadid;
  unsigned int parent_threadid;
 
 
  /* Signal to send to parent at exit.  */
  /* Signal to send to parent at exit.  */
  int exitsig;
  int exitsig;
 
 
  /* Exit status.  */
  /* Exit status.  */
  int exitval;
  int exitval;
 
 
  /* Only as storage to return the "set" value to the "get" method.
  /* Only as storage to return the "set" value to the "get" method.
     I'm not sure whether this is useful per-thread.  */
     I'm not sure whether this is useful per-thread.  */
  USI priority;
  USI priority;
 
 
  struct
  struct
  {
  {
    USI altstack;
    USI altstack;
    USI options;
    USI options;
 
 
    char action;
    char action;
    char pending;
    char pending;
    char blocked;
    char blocked;
    char blocked_suspendsave;
    char blocked_suspendsave;
    /* The handler stub unblocks the signal, so we don't need a separate
    /* The handler stub unblocks the signal, so we don't need a separate
       "temporary save" for that.  */
       "temporary save" for that.  */
  } sigdata[64];
  } sigdata[64];
 
 
  /* Register context, swapped with _sim_cpu.cpu_data.  */
  /* Register context, swapped with _sim_cpu.cpu_data.  */
  void *cpu_context;
  void *cpu_context;
 
 
  /* Similar, temporary copy for the state at a signal call.   */
  /* Similar, temporary copy for the state at a signal call.   */
  void *cpu_context_atsignal;
  void *cpu_context_atsignal;
 
 
  /* The number of the reading and writing ends of a pipe if waiting for
  /* The number of the reading and writing ends of a pipe if waiting for
     the reader, else 0.  */
     the reader, else 0.  */
  int pipe_read_fd;
  int pipe_read_fd;
  int pipe_write_fd;
  int pipe_write_fd;
 
 
  /* System time at last context switch when this thread ran.  */
  /* System time at last context switch when this thread ran.  */
  USI last_execution;
  USI last_execution;
 
 
  /* Nonzero if we just executed a syscall.  */
  /* Nonzero if we just executed a syscall.  */
  char at_syscall;
  char at_syscall;
 
 
  /* Nonzero if any of sigaction[0..64].pending is true.  */
  /* Nonzero if any of sigaction[0..64].pending is true.  */
  char sigpending;
  char sigpending;
 
 
  /* Nonzero if in (rt_)sigsuspend call.  Cleared at every sighandler
  /* Nonzero if in (rt_)sigsuspend call.  Cleared at every sighandler
     call.  */
     call.  */
  char sigsuspended;
  char sigsuspended;
};
};
 
 
typedef int (*cris_interrupt_delivery_fn) (SIM_CPU *,
typedef int (*cris_interrupt_delivery_fn) (SIM_CPU *,
                                           enum cris_interrupt_type,
                                           enum cris_interrupt_type,
                                           unsigned int);
                                           unsigned int);
 
 
struct _sim_cpu {
struct _sim_cpu {
  /* sim/common cpu base.  */
  /* sim/common cpu base.  */
  sim_cpu_base base;
  sim_cpu_base base;
 
 
  /* Static parts of cgen.  */
  /* Static parts of cgen.  */
  CGEN_CPU cgen_cpu;
  CGEN_CPU cgen_cpu;
 
 
  CRIS_MISC_PROFILE cris_misc_profile;
  CRIS_MISC_PROFILE cris_misc_profile;
#define CPU_CRIS_MISC_PROFILE(cpu) (& (cpu)->cris_misc_profile)
#define CPU_CRIS_MISC_PROFILE(cpu) (& (cpu)->cris_misc_profile)
 
 
  /* Copy of previous data; only valid when emitting trace-data after
  /* Copy of previous data; only valid when emitting trace-data after
     each insn.  */
     each insn.  */
  CRIS_MISC_PROFILE cris_prev_misc_profile;
  CRIS_MISC_PROFILE cris_prev_misc_profile;
#define CPU_CRIS_PREV_MISC_PROFILE(cpu) (& (cpu)->cris_prev_misc_profile)
#define CPU_CRIS_PREV_MISC_PROFILE(cpu) (& (cpu)->cris_prev_misc_profile)
 
 
#if WITH_HW
#if WITH_HW
  cris_interrupt_delivery_fn deliver_interrupt;
  cris_interrupt_delivery_fn deliver_interrupt;
#define CPU_CRIS_DELIVER_INTERRUPT(cpu) (cpu->deliver_interrupt)
#define CPU_CRIS_DELIVER_INTERRUPT(cpu) (cpu->deliver_interrupt)
#endif
#endif
 
 
  /* Simulator environment data.  */
  /* Simulator environment data.  */
  USI endmem;
  USI endmem;
  USI endbrk;
  USI endbrk;
  USI stack_low;
  USI stack_low;
  struct cris_sim_mmapped_page *highest_mmapped_page;
  struct cris_sim_mmapped_page *highest_mmapped_page;
 
 
  /* Number of syscalls performed or in progress, counting once extra
  /* Number of syscalls performed or in progress, counting once extra
     for every time a blocked thread (internally, when threading) polls
     for every time a blocked thread (internally, when threading) polls
     the (pipe) blockage.  By default, this is also a time counter: to
     the (pipe) blockage.  By default, this is also a time counter: to
     minimize performance noise from minor compiler changes,
     minimize performance noise from minor compiler changes,
     instructions take no time and syscalls always take 1ms.  */
     instructions take no time and syscalls always take 1ms.  */
  USI syscalls;
  USI syscalls;
 
 
  /* Number of execution contexts minus one.  */
  /* Number of execution contexts minus one.  */
  int m1threads;
  int m1threads;
 
 
  /* Current thread number; index into thread_data when m1threads != 0.  */
  /* Current thread number; index into thread_data when m1threads != 0.  */
  int threadno;
  int threadno;
 
 
  /* When a new thread is created, it gets a unique number, which we
  /* When a new thread is created, it gets a unique number, which we
     count here.  */
     count here.  */
  int max_threadid;
  int max_threadid;
 
 
  /* Thread-specific info, for simulator thread support, created at
  /* Thread-specific info, for simulator thread support, created at
     "clone" call.  Vector of [threads+1] when m1threads > 0.  */
     "clone" call.  Vector of [threads+1] when m1threads > 0.  */
  struct cris_thread_info *thread_data;
  struct cris_thread_info *thread_data;
 
 
  /* "If CLONE_SIGHAND is set, the calling process and the child pro-
  /* "If CLONE_SIGHAND is set, the calling process and the child pro-
     cesses share the same table of signal handlers." ... "However, the
     cesses share the same table of signal handlers." ... "However, the
     calling process and child processes still have distinct signal
     calling process and child processes still have distinct signal
     masks and sets of pending signals."  See struct cris_thread_info
     masks and sets of pending signals."  See struct cris_thread_info
     for sigmasks and sigpendings. */
     for sigmasks and sigpendings. */
  USI sighandler[64];
  USI sighandler[64];
 
 
  /* This is a hack to implement just the parts of fcntl F_GETFL that
  /* This is a hack to implement just the parts of fcntl F_GETFL that
     are used in open+fdopen calls for the standard scenario: for such
     are used in open+fdopen calls for the standard scenario: for such
     a call we check that the last syscall was open, we check that the
     a call we check that the last syscall was open, we check that the
     passed fd is the same returned then, and so we return the same
     passed fd is the same returned then, and so we return the same
     flags passed to open.  This way, we avoid complicating the
     flags passed to open.  This way, we avoid complicating the
     generic sim callback machinery by introducing fcntl
     generic sim callback machinery by introducing fcntl
     mechanisms.  */
     mechanisms.  */
  USI last_syscall;
  USI last_syscall;
  USI last_open_fd;
  USI last_open_fd;
  USI last_open_flags;
  USI last_open_flags;
 
 
  /* Function for initializing CPU thread context, which varies in size
  /* Function for initializing CPU thread context, which varies in size
     with each CPU model.  They should be in some constant parts or
     with each CPU model.  They should be in some constant parts or
     initialized in *_init_cpu, but we can't modify that for now.  */
     initialized in *_init_cpu, but we can't modify that for now.  */
  void* (*make_thread_cpu_data) (SIM_CPU *, void *);
  void* (*make_thread_cpu_data) (SIM_CPU *, void *);
  size_t thread_cpu_data_size;
  size_t thread_cpu_data_size;
 
 
  /* The register differs, so we dispatch to a CPU-specific function.  */
  /* The register differs, so we dispatch to a CPU-specific function.  */
  void (*set_target_thread_data) (SIM_CPU *, USI);
  void (*set_target_thread_data) (SIM_CPU *, USI);
 
 
  /* CPU-model specific parts go here.
  /* CPU-model specific parts go here.
     Note that in files that don't need to access these pieces WANT_CPU_FOO
     Note that in files that don't need to access these pieces WANT_CPU_FOO
     won't be defined and thus these parts won't appear.  This is ok in the
     won't be defined and thus these parts won't appear.  This is ok in the
     sense that things work.  It is a source of bugs though.
     sense that things work.  It is a source of bugs though.
     One has to of course be careful to not take the size of this
     One has to of course be careful to not take the size of this
     struct and no structure members accessed in non-cpu specific files can
     struct and no structure members accessed in non-cpu specific files can
     go after here.  */
     go after here.  */
#if defined (WANT_CPU_CRISV0F)
#if defined (WANT_CPU_CRISV0F)
  CRISV0F_CPU_DATA cpu_data;
  CRISV0F_CPU_DATA cpu_data;
#elif defined (WANT_CPU_CRISV3F)
#elif defined (WANT_CPU_CRISV3F)
  CRISV3F_CPU_DATA cpu_data;
  CRISV3F_CPU_DATA cpu_data;
#elif defined (WANT_CPU_CRISV8F)
#elif defined (WANT_CPU_CRISV8F)
  CRISV8F_CPU_DATA cpu_data;
  CRISV8F_CPU_DATA cpu_data;
#elif defined (WANT_CPU_CRISV10F)
#elif defined (WANT_CPU_CRISV10F)
  CRISV10F_CPU_DATA cpu_data;
  CRISV10F_CPU_DATA cpu_data;
#elif defined (WANT_CPU_CRISV32F)
#elif defined (WANT_CPU_CRISV32F)
  CRISV32F_CPU_DATA cpu_data;
  CRISV32F_CPU_DATA cpu_data;
#else
#else
  /* Let's assume all cpu_data have the same alignment requirements, so
  /* Let's assume all cpu_data have the same alignment requirements, so
     they all are laid out at the same address.  Since we can't get the
     they all are laid out at the same address.  Since we can't get the
     exact definition, we also assume that it has no higher alignment
     exact definition, we also assume that it has no higher alignment
     requirements than a vector of, say, 16 pointers.  (A single member
     requirements than a vector of, say, 16 pointers.  (A single member
     is often special-cased, and possibly two as well so we don't want
     is often special-cased, and possibly two as well so we don't want
     that).  */
     that).  */
  union { void *dummy[16]; } cpu_data_placeholder;
  union { void *dummy[16]; } cpu_data_placeholder;
#endif
#endif
};
};


/* The sim_state struct.  */
/* The sim_state struct.  */
 
 
struct sim_state {
struct sim_state {
  sim_cpu *cpu;
  sim_cpu *cpu;
#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
 
 
  CGEN_STATE cgen_state;
  CGEN_STATE cgen_state;
 
 
  sim_state_base base;
  sim_state_base base;
};
};


/* Misc.  */
/* Misc.  */
 
 
/* Catch address exceptions.  */
/* Catch address exceptions.  */
extern SIM_CORE_SIGNAL_FN cris_core_signal;
extern SIM_CORE_SIGNAL_FN cris_core_signal;
#define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
#define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
cris_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
cris_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
                  (TRANSFER), (ERROR))
                  (TRANSFER), (ERROR))
 
 
/* Default memory size.  */
/* Default memory size.  */
#define CRIS_DEFAULT_MEM_SIZE 0x800000 /* 8M */
#define CRIS_DEFAULT_MEM_SIZE 0x800000 /* 8M */
 
 
extern device cris_devices;
extern device cris_devices;
 
 
#endif /* SIM_MAIN_H */
#endif /* SIM_MAIN_H */
 
 

powered by: WebSVN 2.1.0

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