⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sim-main.h

📁 这个是LINUX下的GDB调度工具的源码
💻 H
📖 第 1 页 / 共 3 页
字号:
/* MIPS Simulator definition.   Copyright (C) 1997, 1998, 2003 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 modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public License alongwith this program; if not, write to the Free Software Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */#ifndef SIM_MAIN_H#define SIM_MAIN_H/* This simulator doesn't cache the Current Instruction Address *//* #define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) *//* #define SIM_ENGINE_RESUME_HOOK(SD, LAST_CPU, CIA) */#define SIM_HAVE_BIENDIAN/* hobble some common features for moment */#define WITH_WATCHPOINTS 1#define WITH_MODULO_MEMORY 1#define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \mips_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), (TRANSFER), (ERROR))#include "sim-basics.h"typedef address_word sim_cia;#include "sim-base.h"#include "bfd.h"/* Deprecated macros and types for manipulating 64bit values.  Use   ../common/sim-bits.h and ../common/sim-endian.h macros instead. */typedef signed64 word64;typedef unsigned64 uword64;#define WORD64LO(t)     (unsigned int)((t)&0xFFFFFFFF)#define WORD64HI(t)     (unsigned int)(((uword64)(t))>>32)#define SET64LO(t)      (((uword64)(t))&0xFFFFFFFF)#define SET64HI(t)	(((uword64)(t))<<32)#define WORD64(h,l)     ((word64)((SET64HI(h)|SET64LO(l))))#define UWORD64(h,l)     (SET64HI(h)|SET64LO(l))/* Check if a value will fit within a halfword: */#define NOTHALFWORDVALUE(v) ((((((uword64)(v)>>16) == 0) && !((v) & ((unsigned)1 << 15))) || (((((uword64)(v)>>32) == 0xFFFFFFFF) && ((((uword64)(v)>>16) & 0xFFFF) == 0xFFFF)) && ((v) & ((unsigned)1 << 15)))) ? (1 == 0) : (1 == 1))/* Floating-point operations: */#include "sim-fpu.h"#include "cp1.h"/* FPU registers must be one of the following types. All other values   are reserved (and undefined). */typedef enum { fmt_single  = 0, fmt_double  = 1, fmt_word    = 4, fmt_long    = 5, fmt_ps      = 6, /* The following are well outside the normal acceptable format    range, and are used in the register status vector. */ fmt_unknown       = 0x10000000, fmt_uninterpreted = 0x20000000, fmt_uninterpreted_32 = 0x40000000, fmt_uninterpreted_64 = 0x80000000U,} FP_formats;/* For paired word (pw) operations, the opcode representation is fmt_word,   but register transfers (StoreFPR, ValueFPR, etc.) are done as fmt_long.  */#define fmt_pw fmt_long/* This should be the COC1 value at the start of the preceding   instruction: */#define PREVCOC1() ((STATE & simPCOC1) ? 1 : 0)#ifdef TARGET_ENABLE_FR/* FIXME: this should be enabled for all targets, but needs testing first. */#define SizeFGR() (((WITH_TARGET_FLOATING_POINT_BITSIZE) == 64) \   ? ((SR & status_FR) ? 64 : 32) \   : (WITH_TARGET_FLOATING_POINT_BITSIZE))#else#define SizeFGR() (WITH_TARGET_FLOATING_POINT_BITSIZE)#endif/* HI/LO register accesses *//* For some MIPS targets, the HI/LO registers have certain timing   restrictions in that, for instance, a read of a HI register must be   separated by at least three instructions from a preceeding read.   The struct below is used to record the last access by each of A MT,   MF or other OP instruction to a HI/LO register.  See mips.igen for   more details. */typedef struct _hilo_access {  signed64 timestamp;  address_word cia;} hilo_access;typedef struct _hilo_history {  hilo_access mt;  hilo_access mf;  hilo_access op;} hilo_history;/* Integer ALU operations: */#include "sim-alu.h"#define ALU32_END(ANS) \  if (ALU32_HAD_OVERFLOW) \    SignalExceptionIntegerOverflow (); \  (ANS) = (signed32) ALU32_OVERFLOW_RESULT#define ALU64_END(ANS) \  if (ALU64_HAD_OVERFLOW) \    SignalExceptionIntegerOverflow (); \  (ANS) = ALU64_OVERFLOW_RESULT;/* The following is probably not used for MIPS IV onwards: *//* Slots for delayed register updates. For the moment we just have a   fixed number of slots (rather than a more generic, dynamic   system). This keeps the simulator fast. However, we only allow   for the register update to be delayed for a single instruction   cycle. */#define PSLOTS (8) /* Maximum number of instruction cycles */typedef struct _pending_write_queue {  int in;  int out;  int total;  int slot_delay[PSLOTS];  int slot_size[PSLOTS];  int slot_bit[PSLOTS];  void *slot_dest[PSLOTS];  unsigned64 slot_value[PSLOTS];} pending_write_queue;#ifndef PENDING_TRACE#define PENDING_TRACE 0#endif#define PENDING_IN ((CPU)->pending.in)#define PENDING_OUT ((CPU)->pending.out)#define PENDING_TOTAL ((CPU)->pending.total)#define PENDING_SLOT_SIZE ((CPU)->pending.slot_size)#define PENDING_SLOT_BIT ((CPU)->pending.slot_bit)#define PENDING_SLOT_DELAY ((CPU)->pending.slot_delay)#define PENDING_SLOT_DEST ((CPU)->pending.slot_dest)#define PENDING_SLOT_VALUE ((CPU)->pending.slot_value)/* Invalidate the pending write queue, all pending writes are   discarded. */#define PENDING_INVALIDATE() \memset (&(CPU)->pending, 0, sizeof ((CPU)->pending))/* Schedule a write to DEST for N cycles time.  For 64 bit   destinations, schedule two writes.  For floating point registers,   the caller should schedule a write to both the dest register and   the FPR_STATE register.  When BIT is non-negative, only BIT of DEST   is updated. */#define PENDING_SCHED(DEST,VAL,DELAY,BIT)				\  do {									\    if (PENDING_SLOT_DEST[PENDING_IN] != NULL)				\      sim_engine_abort (SD, CPU, cia,					\		        "PENDING_SCHED - buffer overflow\n");		\    if (PENDING_TRACE)							\      sim_io_eprintf (SD, "PENDING_SCHED - 0x%lx - dest 0x%lx, val 0x%lx, bit %d, size %d, pending_in %d, pending_out %d, pending_total %d\n",			\		      (unsigned long) cia, (unsigned long) &(DEST),	\		      (unsigned long) (VAL), (BIT), (int) sizeof (DEST),\		      PENDING_IN, PENDING_OUT, PENDING_TOTAL);		\    PENDING_SLOT_DELAY[PENDING_IN] = (DELAY) + 1;			\    PENDING_SLOT_DEST[PENDING_IN] = &(DEST);				\    PENDING_SLOT_VALUE[PENDING_IN] = (VAL);				\    PENDING_SLOT_SIZE[PENDING_IN] = sizeof (DEST);			\    PENDING_SLOT_BIT[PENDING_IN] = (BIT);				\    PENDING_IN = (PENDING_IN + 1) % PSLOTS;                             \    PENDING_TOTAL += 1;			                                \  } while (0)#define PENDING_WRITE(DEST,VAL,DELAY) PENDING_SCHED(DEST,VAL,DELAY,-1)#define PENDING_BIT(DEST,VAL,DELAY,BIT) PENDING_SCHED(DEST,VAL,DELAY,BIT)#define PENDING_TICK() pending_tick (SD, CPU, cia)#define PENDING_FLUSH() abort () /* think about this one */#define PENDING_FP() abort () /* think about this one *//* For backward compatibility */#define PENDING_FILL(R,VAL) 						\do {									\  if ((R) >= FGR_BASE && (R) < FGR_BASE + NR_FGR)			\    {									\      PENDING_SCHED(FGR[(R) - FGR_BASE], VAL, 1, -1);			\      PENDING_SCHED(FPR_STATE[(R) - FGR_BASE], fmt_uninterpreted, 1, -1); \    }									\  else									\    PENDING_SCHED(GPR[(R)], VAL, 1, -1);				\} while (0)enum float_operation  {    FLOP_ADD,    FLOP_SUB,    FLOP_MUL,    FLOP_MADD,    FLOP_MSUB,   FLOP_MAX=10, FLOP_MIN,    FLOP_ABS,    FLOP_ITOF0=14, FLOP_FTOI0=18, FLOP_NEG=23  };/* The internal representation of an MDMX accumulator.    Note that 24 and 48 bit accumulator elements are represented in   32 or 64 bits.  Since the accumulators are 2's complement with   overflow suppressed, high-order bits can be ignored in most contexts.  */typedef signed32 signed24;typedef signed64 signed48;typedef union {   signed24  ob[8];  signed48  qh[4]; } MDMX_accumulator;/* Conventional system arguments.  */ #define SIM_STATE  sim_cpu *cpu, address_word cia#define SIM_ARGS   CPU, ciastruct _sim_cpu {  /* The following are internal simulator state variables: */#define CIA_GET(CPU) ((CPU)->registers[PCIDX] + 0)#define CIA_SET(CPU,CIA) ((CPU)->registers[PCIDX] = (CIA))  address_word dspc;  /* delay-slot PC */#define DSPC ((CPU)->dspc)#define DELAY_SLOT(TARGET) NIA = delayslot32 (SD_, (TARGET))#define NULLIFY_NEXT_INSTRUCTION() NIA = nullify_next_insn32 (SD_)  /* State of the simulator */  unsigned int state;  unsigned int dsstate;#define STATE ((CPU)->state)#define DSSTATE ((CPU)->dsstate)/* Flags in the "state" variable: */#define simHALTEX       (1 << 2)  /* 0 = run; 1 = halt on exception */#define simHALTIN       (1 << 3)  /* 0 = run; 1 = halt on interrupt */#define simTRACE        (1 << 8)  /* 0 = do nothing; 1 = trace address activity */#define simPCOC0        (1 << 17) /* COC[1] from current */#define simPCOC1        (1 << 18) /* COC[1] from previous */#define simDELAYSLOT    (1 << 24) /* 0 = do nothing; 1 = delay slot entry exists */#define simSKIPNEXT     (1 << 25) /* 0 = do nothing; 1 = skip instruction */#define simSIGINT	(1 << 28)  /* 0 = do nothing; 1 = SIGINT has occured */#define simJALDELAYSLOT	(1 << 29) /* 1 = in jal delay slot */#ifndef ENGINE_ISSUE_PREFIX_HOOK#define ENGINE_ISSUE_PREFIX_HOOK() \  { \    /* Perform any pending writes */ \    PENDING_TICK(); \    /* Set previous flag, depending on current: */ \    if (STATE & simPCOC0) \     STATE |= simPCOC1; \    else \     STATE &= ~simPCOC1; \    /* and update the current value: */ \    if (GETFCC(0)) \     STATE |= simPCOC0; \    else \     STATE &= ~simPCOC0; \  }#endif /* ENGINE_ISSUE_PREFIX_HOOK *//* This is nasty, since we have to rely on matching the register   numbers used by GDB. Unfortunately, depending on the MIPS target   GDB uses different register numbers. We cannot just include the   relevant "gdb/tm.h" link, since GDB may not be configured before   the sim world, and also the GDB header file requires too much other   state. */#ifndef TM_MIPS_H#define LAST_EMBED_REGNUM (89)#define NUM_REGS (LAST_EMBED_REGNUM + 1)#define FP0_REGNUM 38           /* Floating point register 0 (single float) */#define FCRCS_REGNUM 70         /* FP control/status */#define FCRIR_REGNUM 71         /* FP implementation/revision */#endif/* To keep this default simulator simple, and fast, we use a direct   vector of registers. The internal simulator engine then uses

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -