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

📄 sim-main.h

📁 这个是LINUX下的GDB调度工具的源码
💻 H
📖 第 1 页 / 共 3 页
字号:
   manifests to access the correct slot. */  unsigned_word registers[LAST_EMBED_REGNUM + 1];  int register_widths[NUM_REGS];#define REGISTERS       ((CPU)->registers)#define GPR     (&REGISTERS[0])#define GPR_SET(N,VAL) (REGISTERS[(N)] = (VAL))#define LO      (REGISTERS[33])#define HI      (REGISTERS[34])#define PCIDX	37#define PC      (REGISTERS[PCIDX])#define CAUSE   (REGISTERS[36])#define SRIDX   (32)#define SR      (REGISTERS[SRIDX])      /* CPU status register */#define FCR0IDX  (71)#define FCR0    (REGISTERS[FCR0IDX])    /* really a 32bit register */#define FCR31IDX (70)#define FCR31   (REGISTERS[FCR31IDX])   /* really a 32bit register */#define FCSR    (FCR31)#define Debug	(REGISTERS[86])#define DEPC	(REGISTERS[87])#define EPC	(REGISTERS[88])  /* All internal state modified by signal_exception() that may need to be     rolled back for passing moment-of-exception image back to gdb. */  unsigned_word exc_trigger_registers[LAST_EMBED_REGNUM + 1];  unsigned_word exc_suspend_registers[LAST_EMBED_REGNUM + 1];  int exc_suspended;#define SIM_CPU_EXCEPTION_TRIGGER(SD,CPU,CIA) mips_cpu_exception_trigger(SD,CPU,CIA)#define SIM_CPU_EXCEPTION_SUSPEND(SD,CPU,EXC) mips_cpu_exception_suspend(SD,CPU,EXC)#define SIM_CPU_EXCEPTION_RESUME(SD,CPU,EXC) mips_cpu_exception_resume(SD,CPU,EXC)  unsigned_word c0_config_reg;#define C0_CONFIG ((CPU)->c0_config_reg)/* The following are pseudonyms for standard registers */#define ZERO    (REGISTERS[0])#define V0      (REGISTERS[2])#define A0      (REGISTERS[4])#define A1      (REGISTERS[5])#define A2      (REGISTERS[6])#define A3      (REGISTERS[7])#define T8IDX   24#define T8	(REGISTERS[T8IDX])#define SPIDX   29#define SP      (REGISTERS[SPIDX])#define RAIDX   31#define RA      (REGISTERS[RAIDX])  /* While space is allocated in the main registers arrray for some of     the COP0 registers, that space isn't sufficient.  Unknown COP0     registers overflow into the array below */#define NR_COP0_GPR	32  unsigned_word cop0_gpr[NR_COP0_GPR];#define COP0_GPR	((CPU)->cop0_gpr)#define COP0_BADVADDR	(COP0_GPR[8])  /* While space is allocated for the floating point registers in the     main registers array, they are stored separatly.  This is because     their size may not necessarily match the size of either the     general-purpose or system specific registers.  */#define NR_FGR    (32)#define FGR_BASE  FP0_REGNUM  fp_word fgr[NR_FGR];#define FGR       ((CPU)->fgr)  /* Keep the current format state for each register: */  FP_formats fpr_state[32];#define FPR_STATE ((CPU)->fpr_state)  pending_write_queue pending;  /* The MDMX accumulator (used only for MDMX ASE).  */  MDMX_accumulator acc; #define ACC             ((CPU)->acc)  /* LLBIT = Load-Linked bit. A bit of "virtual" state used by atomic     read-write instructions. It is set when a linked load occurs. It     is tested and cleared by the conditional store. It is cleared     (during other CPU operations) when a store to the location would     no longer be atomic. In particular, it is cleared by exception     return instructions. */  int llbit;#define LLBIT ((CPU)->llbit)/* The HIHISTORY and LOHISTORY timestamps are used to ensure that   corruptions caused by using the HI or LO register too close to a   following operation is spotted. See mips.igen for more details. */  hilo_history hi_history;#define HIHISTORY (&(CPU)->hi_history)  hilo_history lo_history;#define LOHISTORY (&(CPU)->lo_history)  sim_cpu_base base;};/* MIPS specific simulator watch config */void watch_options_install PARAMS ((SIM_DESC sd));struct swatch {  sim_event *pc;  sim_event *clock;  sim_event *cycles;};/* FIXME: At present much of the simulator is still static */struct sim_state {  struct swatch watch;  sim_cpu cpu[MAX_NR_PROCESSORS];#if (WITH_SMP)#define STATE_CPU(sd,n) (&(sd)->cpu[n])#else#define STATE_CPU(sd,n) (&(sd)->cpu[0])#endif  sim_state_base base;};/* Status information: *//* TODO : these should be the bitmasks for these bits within the   status register. At the moment the following are VR4300   bit-positions: */#define status_KSU_mask  (0x18)         /* mask for KSU bits */#define status_KSU_shift (3)            /* shift for field */#define ksu_kernel       (0x0)#define ksu_supervisor   (0x1)#define ksu_user         (0x2)#define ksu_unknown      (0x3)#define SR_KSU		 ((SR & status_KSU_mask) >> status_KSU_shift)#define status_IE	 (1 <<  0)      /* Interrupt enable */#define status_EIE	 (1 << 16)      /* Enable Interrupt Enable */#define status_EXL	 (1 <<  1)	/* Exception level */#define status_RE        (1 << 25)      /* Reverse Endian in user mode */#define status_FR        (1 << 26)      /* enables MIPS III additional FP registers */#define status_SR        (1 << 20)      /* soft reset or NMI */#define status_BEV       (1 << 22)      /* Location of general exception vectors */#define status_TS        (1 << 21)      /* TLB shutdown has occurred */#define status_ERL       (1 <<  2)      /* Error level */#define status_IM7       (1 << 15)      /* Timer Interrupt Mask */#define status_RP        (1 << 27)      /* Reduced Power mode *//* Specializations for TX39 family */#define status_IEc       (1 << 0)       /* Interrupt enable (current) */#define status_KUc       (1 << 1)       /* Kernel/User mode */#define status_IEp       (1 << 2)       /* Interrupt enable (previous) */#define status_KUp       (1 << 3)       /* Kernel/User mode */#define status_IEo       (1 << 4)       /* Interrupt enable (old) */#define status_KUo       (1 << 5)       /* Kernel/User mode */#define status_IM_mask   (0xff)         /* Interrupt mask */#define status_IM_shift  (8)#define status_NMI       (1 << 20)      /* NMI */#define status_NMI       (1 << 20)      /* NMI *//* Status bits used by MIPS32/MIPS64.  */#define status_UX        (1 <<  5)      /* 64-bit user addrs */#define status_SX        (1 <<  6)      /* 64-bit supervisor addrs */#define status_KX        (1 <<  7)      /* 64-bit kernel addrs */#define status_TS        (1 << 21)      /* TLB shutdown has occurred */#define status_PX        (1 << 23)      /* Enable 64 bit operations */#define status_MX        (1 << 24)      /* Enable MDMX resources */#define status_CU0       (1 << 28)      /* Coprocessor 0 usable */#define status_CU1       (1 << 29)      /* Coprocessor 1 usable */#define status_CU2       (1 << 30)      /* Coprocessor 2 usable */#define status_CU3       (1 << 31)      /* Coprocessor 3 usable *//* Bits reserved for implementations:  */#define status_SBX       (1 << 16)      /* Enable SiByte SB-1 extensions.  */#define cause_BD ((unsigned)1 << 31)    /* L1 Exception in branch delay slot */#define cause_BD2         (1 << 30)     /* L2 Exception in branch delay slot */#define cause_CE_mask     0x30000000	/* Coprocessor exception */#define cause_CE_shift    28#define cause_EXC2_mask   0x00070000#define cause_EXC2_shift  16#define cause_IP7 	  (1 << 15)	/* Interrupt pending */#define cause_SIOP        (1 << 12)     /* SIO pending */#define cause_IP3 	  (1 << 11)	/* Int 0 pending */#define cause_IP2 	  (1 << 10)	/* Int 1 pending */#define cause_EXC_mask  (0x1c)          /* Exception code */#define cause_EXC_shift (2)#define cause_SW0       (1 << 8)        /* Software interrupt 0 */#define cause_SW1       (1 << 9)        /* Software interrupt 1 */#define cause_IP_mask   (0x3f)          /* Interrupt pending field */#define cause_IP_shift  (10)#define cause_set_EXC(x)  CAUSE = (CAUSE & ~cause_EXC_mask)  | ((x << cause_EXC_shift)  & cause_EXC_mask)#define cause_set_EXC2(x) CAUSE = (CAUSE & ~cause_EXC2_mask) | ((x << cause_EXC2_shift) & cause_EXC2_mask)/* NOTE: We keep the following status flags as bit values (1 for true,   0 for false). This allows them to be used in binary boolean   operations without worrying about what exactly the non-zero true   value is. *//* UserMode */#ifdef SUBTARGET_R3900#define UserMode        ((SR & status_KUc) ? 1 : 0)#else#define UserMode	((((SR & status_KSU_mask) >> status_KSU_shift) == ksu_user) ? 1 : 0)#endif /* SUBTARGET_R3900 *//* BigEndianMem *//* Hardware configuration. Affects endianness of LoadMemory and   StoreMemory and the endianness of Kernel and Supervisor mode   execution. The value is 0 for little-endian; 1 for big-endian. */#define BigEndianMem    (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)/*(state & simBE) ? 1 : 0)*//* ReverseEndian *//* This mode is selected if in User mode with the RE bit being set in   SR (Status Register). It reverses the endianness of load and store   instructions. */#define ReverseEndian   (((SR & status_RE) && UserMode) ? 1 : 0)/* BigEndianCPU *//* The endianness for load and store instructions (0=little;1=big). In   User mode this endianness may be switched by setting the state_RE   bit in the SR register. Thus, BigEndianCPU may be computed as   (BigEndianMem EOR ReverseEndian). */#define BigEndianCPU    (BigEndianMem ^ ReverseEndian) /* Already bits *//* Exceptions: *//* NOTE: These numbers depend on the processor architecture being   simulated: */enum ExceptionCause {  Interrupt               = 0,  TLBModification         = 1,  TLBLoad                 = 2,  TLBStore                = 3,  AddressLoad             = 4,  AddressStore            = 5,  InstructionFetch        = 6,  DataReference           = 7,  SystemCall              = 8,  BreakPoint              = 9,  ReservedInstruction     = 10,  CoProcessorUnusable     = 11,  IntegerOverflow         = 12,    /* Arithmetic overflow (IDT monitor raises SIGFPE) */  Trap                    = 13,  FPE                     = 15,  DebugBreakPoint         = 16,    /* Impl. dep. in MIPS32/MIPS64.  */  MDMX                    = 22,  Watch                   = 23,  MCheck                  = 24,  CacheErr                = 30,  NMIReset                = 31,    /* Reserved in MIPS32/MIPS64.  *//* The following exception code is actually private to the simulator   world. It is *NOT* a processor feature, and is used to signal   run-time errors in the simulator. */  SimulatorFault      	  = 0xFFFFFFFF};#define TLB_REFILL  (0)#define TLB_INVALID (1)/* The following break instructions are reserved for use by the   simulator.  The first is used to halt the simulation.  The second   is used by gdb for break-points.  NOTE: Care must be taken, since    this value may be used in later revisions of the MIPS ISA. */#define HALT_INSTRUCTION_MASK   (0x03FFFFC0)#define HALT_INSTRUCTION        (0x03ff000d)#define HALT_INSTRUCTION2       (0x0000ffcd)#define BREAKPOINT_INSTRUCTION  (0x0005000d)#define BREAKPOINT_INSTRUCTION2 (0x0000014d)void interrupt_event (SIM_DESC sd, void *data);void signal_exception (SIM_DESC sd, sim_cpu *cpu, address_word cia, int exception, ...);#define SignalException(exc,instruction)     signal_exception (SD, CPU, cia, (exc), (instruction))#define SignalExceptionInterrupt(level)      signal_exception (SD, CPU, cia, Interrupt, level)#define SignalExceptionInstructionFetch()    signal_exception (SD, CPU, cia, InstructionFetch)#define SignalExceptionAddressStore()        signal_exception (SD, CPU, cia, AddressStore)#define SignalExceptionAddressLoad()         signal_exception (SD, CPU, cia, AddressLoad)#define SignalExceptionDataReference()       signal_exception (SD, CPU, cia, DataReference)#define SignalExceptionSimulatorFault(buf)   signal_exception (SD, CPU, cia, SimulatorFault, buf)#define SignalExceptionFPE()                 signal_exception (SD, CPU, cia, FPE)#define SignalExceptionIntegerOverflow()     signal_exception (SD, CPU, cia, IntegerOverflow)#define SignalExceptionCoProcessorUnusable(cop) signal_exception (SD, CPU, cia, CoProcessorUnusable)#define SignalExceptionNMIReset()            signal_exception (SD, CPU, cia, NMIReset)#define SignalExceptionTLBRefillStore()      signal_exception (SD, CPU, cia, TLBStore, TLB_REFILL)#define SignalExceptionTLBRefillLoad()       signal_exception (SD, CPU, cia, TLBLoad, TLB_REFILL)#define SignalExceptionTLBInvalidStore()     signal_exception (SD, CPU, cia, TLBStore, TLB_INVALID)#define SignalExceptionTLBInvalidLoad()      signal_exception (SD, CPU, cia, TLBLoad, TLB_INVALID)#define SignalExceptionTLBModification()     signal_exception (SD, CPU, cia, TLBModification)#define SignalExceptionMDMX()                signal_exception (SD, CPU, cia, MDMX)#define SignalExceptionWatch()               signal_exception (SD, CPU, cia, Watch)#define SignalExceptionMCheck()              signal_exception (SD, CPU, cia, MCheck)#define SignalExceptionCacheErr()            signal_exception (SD, CPU, cia, CacheErr)/* Co-processor accesses *//* XXX FIXME: For now, assume that FPU (cp1) is always usable.  */#define COP_Usable(coproc_num)		(coproc_num == 1)

⌨️ 快捷键说明

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