2019-01-01 07:01:51 +01:00
|
|
|
/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
|
2015-05-08 16:11:38 +02:00
|
|
|
|
|
|
|
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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2012-06-15 19:20:30 +02:00
|
|
|
#include "config.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
#include "ansidecl.h"
|
2002-06-09 17:45:54 +02:00
|
|
|
#include "gdb/callback.h"
|
|
|
|
#include "gdb/remote-sim.h"
|
2015-03-16 06:14:09 +01:00
|
|
|
#include <sim-config.h>
|
2015-03-17 22:02:38 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-01-03 06:36:13 +01:00
|
|
|
#if HOST_BYTE_ORDER == BIG_ENDIAN
|
2015-03-16 06:14:09 +01:00
|
|
|
#define HOST_BIG_ENDIAN
|
2015-04-03 22:35:48 +02:00
|
|
|
#define EBT 0
|
2015-03-16 06:14:09 +01:00
|
|
|
#else
|
|
|
|
#define HOST_LITTLE_ENDIAN
|
2015-04-03 22:35:48 +02:00
|
|
|
#define EBT 3
|
2015-03-16 06:14:09 +01:00
|
|
|
#endif
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#define I_ACC_EXC 1
|
|
|
|
|
|
|
|
/* Maximum events in event queue */
|
|
|
|
#define EVENT_MAX 256
|
|
|
|
|
|
|
|
/* Maximum # of floating point queue */
|
|
|
|
#define FPUQN 1
|
|
|
|
|
|
|
|
/* Maximum # of breakpoints */
|
|
|
|
#define BPT_MAX 256
|
|
|
|
|
|
|
|
struct histype {
|
|
|
|
unsigned addr;
|
|
|
|
unsigned time;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* type definitions */
|
|
|
|
|
|
|
|
typedef short int int16; /* 16-bit signed int */
|
|
|
|
typedef unsigned short int uint16; /* 16-bit unsigned int */
|
|
|
|
typedef int int32; /* 32-bit signed int */
|
|
|
|
typedef unsigned int uint32; /* 32-bit unsigned int */
|
|
|
|
typedef float float32; /* 32-bit float */
|
|
|
|
typedef double float64; /* 64-bit float */
|
|
|
|
|
2015-03-17 22:02:38 +01:00
|
|
|
typedef uint64_t uint64; /* 64-bit unsigned int */
|
|
|
|
typedef int64_t int64; /* 64-bit signed int */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
struct pstate {
|
|
|
|
|
|
|
|
float64 fd[16]; /* FPU registers */
|
2015-03-16 06:14:09 +01:00
|
|
|
#ifdef HOST_LITTLE_ENDIAN
|
1999-04-16 03:35:26 +02:00
|
|
|
float32 fs[32];
|
|
|
|
float32 *fdp;
|
|
|
|
#else
|
|
|
|
float32 *fs;
|
|
|
|
#endif
|
|
|
|
int32 *fsi;
|
|
|
|
uint32 fsr;
|
|
|
|
int32 fpstate;
|
|
|
|
uint32 fpq[FPUQN * 2];
|
|
|
|
uint32 fpqn;
|
|
|
|
uint32 ftime;
|
|
|
|
uint32 flrd;
|
|
|
|
uint32 frd;
|
|
|
|
uint32 frs1;
|
|
|
|
uint32 frs2;
|
|
|
|
uint32 fpu_pres; /* FPU present (0 = No, 1 = Yes) */
|
|
|
|
|
|
|
|
uint32 psr; /* IU registers */
|
|
|
|
uint32 tbr;
|
|
|
|
uint32 wim;
|
|
|
|
uint32 g[8];
|
|
|
|
uint32 r[128];
|
|
|
|
uint32 y;
|
|
|
|
uint32 asr17; /* Single vector trapping */
|
|
|
|
uint32 pc, npc;
|
|
|
|
|
|
|
|
|
|
|
|
uint32 trap; /* Current trap type */
|
|
|
|
uint32 annul; /* Instruction annul */
|
|
|
|
uint32 data; /* Loaded data */
|
|
|
|
uint32 inst; /* Current instruction */
|
|
|
|
uint32 asi; /* Current ASI */
|
|
|
|
uint32 err_mode; /* IU error mode */
|
|
|
|
uint32 breakpoint;
|
|
|
|
uint32 bptnum;
|
|
|
|
uint32 bphit;
|
|
|
|
uint32 bpts[BPT_MAX]; /* Breakpoints */
|
|
|
|
|
|
|
|
uint32 ltime; /* Load interlock time */
|
|
|
|
uint32 hold; /* IU hold cycles in current inst */
|
|
|
|
uint32 fhold; /* FPU hold cycles in current inst */
|
|
|
|
uint32 icnt; /* Instruction cycles in curr inst */
|
|
|
|
|
|
|
|
uint32 histlen; /* Trace history management */
|
|
|
|
uint32 histind;
|
|
|
|
struct histype *histbuf;
|
|
|
|
float32 freq; /* Simulated processor frequency */
|
|
|
|
|
|
|
|
|
2015-02-19 23:31:24 +01:00
|
|
|
double tottime;
|
2010-05-11 16:18:20 +02:00
|
|
|
uint64 ninst;
|
|
|
|
uint64 fholdt;
|
|
|
|
uint64 holdt;
|
|
|
|
uint64 icntt;
|
|
|
|
uint64 finst;
|
|
|
|
uint64 simstart;
|
2015-02-19 23:31:24 +01:00
|
|
|
double starttime;
|
2010-05-11 16:18:20 +02:00
|
|
|
uint64 tlimit; /* Simulation time limit */
|
|
|
|
uint64 pwdtime; /* Cycles in power-down mode */
|
|
|
|
uint64 nstore; /* Number of load instructions */
|
|
|
|
uint64 nload; /* Number of store instructions */
|
|
|
|
uint64 nannul; /* Number of annuled instructions */
|
|
|
|
uint64 nbranch; /* Number of branch instructions */
|
1999-04-16 03:35:26 +02:00
|
|
|
uint32 ildreg; /* Destination of last load instruction */
|
2010-05-11 16:18:20 +02:00
|
|
|
uint64 ildtime; /* Last time point for load dependency */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
int rett_err; /* IU in jmpl/restore error state (Rev.0) */
|
|
|
|
int jmpltime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct evcell {
|
|
|
|
void (*cfunc) ();
|
|
|
|
int32 arg;
|
2010-05-11 16:18:20 +02:00
|
|
|
uint64 time;
|
1999-04-16 03:35:26 +02:00
|
|
|
struct evcell *nxt;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct estate {
|
|
|
|
struct evcell eq;
|
|
|
|
struct evcell *freeq;
|
2010-05-11 16:18:20 +02:00
|
|
|
uint64 simtime;
|
1999-04-16 03:35:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct irqcell {
|
|
|
|
void (*callback) ();
|
|
|
|
int32 arg;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define OK 0
|
|
|
|
#define TIME_OUT 1
|
|
|
|
#define BPT_HIT 2
|
|
|
|
#define ERROR 3
|
|
|
|
#define CTRL_C 4
|
|
|
|
|
|
|
|
/* Prototypes */
|
|
|
|
|
|
|
|
/* erc32.c */
|
2014-01-05 05:43:21 +01:00
|
|
|
extern void init_sim (void);
|
|
|
|
extern void reset (void);
|
|
|
|
extern void error_mode (uint32 pc);
|
|
|
|
extern void sim_halt (void);
|
|
|
|
extern void exit_sim (void);
|
|
|
|
extern void init_stdio (void);
|
|
|
|
extern void restore_stdio (void);
|
2015-03-17 22:02:41 +01:00
|
|
|
extern int memory_iread (uint32 addr, uint32 *data, int32 *ws);
|
2014-01-05 05:43:21 +01:00
|
|
|
extern int memory_read (int32 asi, uint32 addr, uint32 *data,
|
|
|
|
int32 sz, int32 *ws);
|
|
|
|
extern int memory_write (int32 asi, uint32 addr, uint32 *data,
|
|
|
|
int32 sz, int32 *ws);
|
|
|
|
extern int sis_memory_write (uint32 addr,
|
|
|
|
const unsigned char *data, uint32 length);
|
|
|
|
extern int sis_memory_read (uint32 addr, char *data,
|
|
|
|
uint32 length);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* func.c */
|
2015-03-17 22:02:41 +01:00
|
|
|
extern struct pstate sregs;
|
2014-01-05 05:43:21 +01:00
|
|
|
extern void set_regi (struct pstate *sregs, int32 reg,
|
|
|
|
uint32 rval);
|
|
|
|
extern void get_regi (struct pstate *sregs, int32 reg, char *buf);
|
2015-03-17 22:02:42 +01:00
|
|
|
extern int exec_cmd (struct pstate *sregs, const char *cmd);
|
2014-01-05 05:43:21 +01:00
|
|
|
extern void reset_stat (struct pstate *sregs);
|
|
|
|
extern void show_stat (struct pstate *sregs);
|
|
|
|
extern void init_bpt (struct pstate *sregs);
|
|
|
|
extern void init_signals (void);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
struct disassemble_info;
|
2014-01-05 05:43:21 +01:00
|
|
|
extern void dis_mem (uint32 addr, uint32 len,
|
|
|
|
struct disassemble_info *info);
|
|
|
|
extern void event (void (*cfunc) (), int32 arg, uint64 delta);
|
|
|
|
extern void set_int (int32 level, void (*callback) (), int32 arg);
|
|
|
|
extern void advance_time (struct pstate *sregs);
|
|
|
|
extern uint32 now (void);
|
|
|
|
extern int wait_for_irq (void);
|
|
|
|
extern int check_bpt (struct pstate *sregs);
|
|
|
|
extern void reset_all (void);
|
|
|
|
extern void sys_reset (void);
|
|
|
|
extern void sys_halt (void);
|
2015-03-17 22:02:42 +01:00
|
|
|
extern int bfd_load (const char *fname);
|
2015-02-19 23:31:24 +01:00
|
|
|
extern double get_time (void);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* exec.c */
|
2014-01-05 05:43:21 +01:00
|
|
|
extern int dispatch_instruction (struct pstate *sregs);
|
|
|
|
extern int execute_trap (struct pstate *sregs);
|
|
|
|
extern int check_interrupts (struct pstate *sregs);
|
|
|
|
extern void init_regs (struct pstate *sregs);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* interf.c */
|
2014-01-05 05:43:21 +01:00
|
|
|
extern int run_sim (struct pstate *sregs,
|
|
|
|
uint64 icount, int dis);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* float.c */
|
2014-01-05 05:43:21 +01:00
|
|
|
extern int get_accex (void);
|
|
|
|
extern void clear_accex (void);
|
|
|
|
extern void set_fsr (uint32 fsr);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* help.c */
|
2014-01-05 05:43:21 +01:00
|
|
|
extern void usage (void);
|
|
|
|
extern void gen_help (void);
|