/* Model support.
   Copyright (C) 1997 Free Software Foundation, Inc.
   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.  */

/* This file is intended to be included by sim-basics.h.  */

#ifndef SIM_MODEL_H
#define SIM_MODEL_H

/* Function unit and instruction timing support.
   ??? This is obviously insufficiently general.
   It's useful but it needs elaborating upon.  */

typedef struct {
  unsigned char name; /* actually a UNIT_TYPE enum */
  unsigned char issue;
  unsigned char done;
  unsigned char unused; /* fill out to power of 2 so indexing is faster */
} UNIT;

#ifndef MAX_UNITS
#define MAX_UNITS 1
#endif

#ifndef MAX_MODELS
#define MAX_MODELS 1
#endif

/* ??? Temporary.  MAX_INSNS should always be defined.  */
#ifndef MAX_INSNS
#define MAX_INSNS 1
#endif

typedef struct {
  UNIT units[MAX_UNITS];
} INSN_TIMING;

extern INSN_TIMING insn_timing[MAX_MODELS][MAX_INSNS];

/* Architecture, machine, and model support.

   Nomenclature:
   architecture = one of sparc, mips, sh, etc.
   in the sparc architecture, machine = one of v6, v7, v8, sparclite, etc.
   in the v8 machine, model = one of supersparc, etc.
*/

typedef struct {
  const char *name;
#define MACH_NAME(m) ((m)->name)
  int word_bitsize;
#define MACH_WORD_BITSIZE(m) ((m)->word_bitsize)
  int addr_bitsize;
#define MACH_ADDR_BITSIZE(m) ((m)->addr_bitsize)
} MACH;

typedef struct {
  const char *name;
#define MODEL_NAME(m) ((m)->name)
  const MACH *mach;
#define MODEL_MACH(m) ((m)->mach)
  /* Pointer to timing table for this model.  */
  const INSN_TIMING *timing;
#define MODEL_TIMING(m) ((m)->timing)
} MODEL;

/* Tables of supported machines and models.  */
extern const MODEL models[];
extern const MACH machs[];

/* Model install handler.  */
extern MODULE_INSTALL_FN model_install;

#endif /* SIM_MODEL_H */
