📄 armdefs.h
字号:
/* armdefs.h -- ARMulator common definitions: ARM6 Instruction Emulator. Copyright (C) 1994 Advanced RISC Machines Ltd. 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 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <stdio.h>#include <stdlib.h>#define FALSE 0#define TRUE 1#define LOW 0#define HIGH 1#define LOWHIGH 1#define HIGHLOW 2#ifndef __STDC__typedef char *VoidStar;#endiftypedef unsigned long ARMword; /* must be 32 bits wide */typedef unsigned long long ARMdword; /* Must be at least 64 bits wide. */typedef struct ARMul_State ARMul_State;typedef unsigned ARMul_CPInits (ARMul_State * state);typedef unsigned ARMul_CPExits (ARMul_State * state);typedef unsigned ARMul_LDCs (ARMul_State * state, unsigned type, ARMword instr, ARMword value);typedef unsigned ARMul_STCs (ARMul_State * state, unsigned type, ARMword instr, ARMword * value);typedef unsigned ARMul_MRCs (ARMul_State * state, unsigned type, ARMword instr, ARMword * value);typedef unsigned ARMul_MCRs (ARMul_State * state, unsigned type, ARMword instr, ARMword value);typedef unsigned ARMul_CDPs (ARMul_State * state, unsigned type, ARMword instr);typedef unsigned ARMul_CPReads (ARMul_State * state, unsigned reg, ARMword * value);typedef unsigned ARMul_CPWrites (ARMul_State * state, unsigned reg, ARMword value);struct ARMul_State{ ARMword Emulate; /* to start and stop emulation */ unsigned EndCondition; /* reason for stopping */ unsigned ErrorCode; /* type of illegal instruction */ ARMword Reg[16]; /* the current register file */ ARMword RegBank[7][16]; /* all the registers */ /* 40 bit accumulator. We always keep this 64 bits wide, and move only 40 bits out of it in an MRA insn. */ ARMdword Accumulator; ARMword Cpsr; /* the current psr */ ARMword Spsr[7]; /* the exception psr's */ ARMword NFlag, ZFlag, CFlag, VFlag, IFFlags; /* dummy flags for speed */ ARMword SFlag;#ifdef MODET ARMword TFlag; /* Thumb state */#endif ARMword Bank; /* the current register bank */ ARMword Mode; /* the current mode */ ARMword instr, pc, temp; /* saved register state */ ARMword loaded, decoded; /* saved pipeline state */ unsigned long NumScycles, NumNcycles, NumIcycles, NumCcycles, NumFcycles; /* emulated cycles used */ unsigned long NumInstrs; /* the number of instructions executed */ unsigned NextInstr; unsigned VectorCatch; /* caught exception mask */ unsigned CallDebug; /* set to call the debugger */ unsigned CanWatch; /* set by memory interface if its willing to suffer the overhead of checking for watchpoints on each memory access */ unsigned MemReadDebug, MemWriteDebug; unsigned long StopHandle; unsigned char *MemDataPtr; /* admin data */ unsigned char *MemInPtr; /* the Data In bus */ unsigned char *MemOutPtr; /* the Data Out bus (which you may not need */ unsigned char *MemSparePtr; /* extra space */ ARMword MemSize; unsigned char *OSptr; /* OS Handle */ char *CommandLine; /* Command Line from ARMsd */ ARMul_CPInits *CPInit[16]; /* coprocessor initialisers */ ARMul_CPExits *CPExit[16]; /* coprocessor finalisers */ ARMul_LDCs *LDC[16]; /* LDC instruction */ ARMul_STCs *STC[16]; /* STC instruction */ ARMul_MRCs *MRC[16]; /* MRC instruction */ ARMul_MCRs *MCR[16]; /* MCR instruction */ ARMul_CDPs *CDP[16]; /* CDP instruction */ ARMul_CPReads *CPRead[16]; /* Read CP register */ ARMul_CPWrites *CPWrite[16]; /* Write CP register */ unsigned char *CPData[16]; /* Coprocessor data */ unsigned char const *CPRegWords[16]; /* map of coprocessor register sizes */ unsigned long LastTime; /* Value of last call to ARMul_Time() */ ARMword CP14R0_CCD; /* used to count 64 clock cycles with CP14 R0 bit 3 set */ unsigned EventSet; /* the number of events in the queue */ unsigned long Now; /* time to the nearest cycle */ struct EventNode **EventPtr; /* the event list */ unsigned Exception; /* enable the next four values */ unsigned Debug; /* show instructions as they are executed */ unsigned NresetSig; /* reset the processor */ unsigned NfiqSig; unsigned NirqSig; unsigned abortSig; unsigned NtransSig; unsigned bigendSig; unsigned prog32Sig; unsigned data32Sig; unsigned lateabtSig; ARMword Vector; /* synthesize aborts in cycle modes */ ARMword Aborted; /* sticky flag for aborts */ ARMword Reseted; /* sticky flag for Reset */ ARMword Inted, LastInted; /* sticky flags for interrupts */ ARMword Base; /* extra hand for base writeback */ ARMword AbortAddr; /* to keep track of Prefetch aborts */ const struct Dbg_HostosInterface *hostif; unsigned is_v4; /* Are we emulating a v4 architecture (or higher) ? */ unsigned is_v5; /* Are we emulating a v5 architecture ? */ unsigned is_v5e; /* Are we emulating a v5e architecture ? */ unsigned is_XScale; /* Are we emulating an XScale architecture ? */ unsigned is_iWMMXt; /* Are we emulating an iWMMXt co-processor ? */ unsigned is_ep9312; /* Are we emulating a Cirrus Maverick co-processor ? */ unsigned verbose; /* Print various messages like the banner */};#define ResetPin NresetSig#define FIQPin NfiqSig#define IRQPin NirqSig#define AbortPin abortSig#define TransPin NtransSig#define BigEndPin bigendSig#define Prog32Pin prog32Sig#define Data32Pin data32Sig#define LateAbortPin lateabtSig/***************************************************************************\* Properties of ARM we know about *\***************************************************************************//* The bitflags */#define ARM_Fix26_Prop 0x01#define ARM_Nexec_Prop 0x02#define ARM_Debug_Prop 0x10#define ARM_Isync_Prop ARM_Debug_Prop#define ARM_Lock_Prop 0x20#define ARM_v4_Prop 0x40#define ARM_v5_Prop 0x80#define ARM_v5e_Prop 0x100#define ARM_XScale_Prop 0x200#define ARM_ep9312_Prop 0x400#define ARM_iWMMXt_Prop 0x800/***************************************************************************\* Macros to extract instruction fields *\***************************************************************************/#define BIT(n) ( (ARMword)(instr>>(n))&1) /* bit n of instruction */#define BITS(m,n) ( (ARMword)(instr<<(31-(n))) >> ((31-(n))+(m)) ) /* bits m to n of instr */#define TOPBITS(n) (instr >> (n)) /* bits 31 to n of instr *//***************************************************************************\* The hardware vector addresses *\***************************************************************************/#define ARMResetV 0L#define ARMUndefinedInstrV 4L#define ARMSWIV 8L#define ARMPrefetchAbortV 12L#define ARMDataAbortV 16L#define ARMAddrExceptnV 20L#define ARMIRQV 24L#define ARMFIQV 28L#define ARMErrorV 32L /* This is an offset, not an address ! */#define ARMul_ResetV ARMResetV#define ARMul_UndefinedInstrV ARMUndefinedInstrV#define ARMul_SWIV ARMSWIV#define ARMul_PrefetchAbortV ARMPrefetchAbortV#define ARMul_DataAbortV ARMDataAbortV#define ARMul_AddrExceptnV ARMAddrExceptnV#define ARMul_IRQV ARMIRQV#define ARMul_FIQV ARMFIQV/***************************************************************************\* Mode and Bank Constants *\***************************************************************************/#define USER26MODE 0L#define FIQ26MODE 1L#define IRQ26MODE 2L#define SVC26MODE 3L#define USER32MODE 16L#define FIQ32MODE 17L#define IRQ32MODE 18L
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -