summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2015-02-01 00:28:29 -0500
committerGravatar bunnei2015-02-01 00:28:29 -0500
commita4b1e8ce5239793814a19905ef912c10d3869e49 (patch)
treec80ea3a4035a20810fb5914f3bfc99f392376939
parentMerge pull request #522 from lioncash/adios (diff)
parentarm: Clean up ARMul_State (diff)
downloadyuzu-a4b1e8ce5239793814a19905ef912c10d3869e49.tar.gz
yuzu-a4b1e8ce5239793814a19905ef912c10d3869e49.tar.xz
yuzu-a4b1e8ce5239793814a19905ef912c10d3869e49.zip
Merge pull request #524 from lioncash/state
arm: Clean up ARMul_State
-rw-r--r--src/core/arm/dyncom/arm_dyncom.cpp9
-rw-r--r--src/core/arm/interpreter/arminit.cpp29
-rw-r--r--src/core/arm/skyeye_common/armdefs.h181
-rw-r--r--src/core/core.h1
-rw-r--r--src/core/hle/kernel/thread.cpp2
5 files changed, 84 insertions, 138 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp
index 01ffbcc87..f6628ca33 100644
--- a/src/core/arm/dyncom/arm_dyncom.cpp
+++ b/src/core/arm/dyncom/arm_dyncom.cpp
@@ -36,9 +36,8 @@ ARM_DynCom::ARM_DynCom() {
36 state->NextInstr = RESUME; // NOTE: This will be overwritten by LoadContext 36 state->NextInstr = RESUME; // NOTE: This will be overwritten by LoadContext
37 state->Emulate = 3; 37 state->Emulate = 3;
38 38
39 state->pc = state->Reg[15] = 0x00000000; 39 state->Reg[15] = 0x00000000;
40 state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack 40 state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack
41 state->servaddr = 0xFFFF0000;
42 state->NirqSig = HIGH; 41 state->NirqSig = HIGH;
43 42
44 VFPInit(state.get()); // Initialize the VFP 43 VFPInit(state.get()); // Initialize the VFP
@@ -50,7 +49,7 @@ ARM_DynCom::~ARM_DynCom() {
50} 49}
51 50
52void ARM_DynCom::SetPC(u32 pc) { 51void ARM_DynCom::SetPC(u32 pc) {
53 state->pc = state->Reg[15] = pc; 52 state->Reg[15] = pc;
54} 53}
55 54
56u32 ARM_DynCom::GetPC() const { 55u32 ARM_DynCom::GetPC() const {
@@ -106,7 +105,6 @@ void ARM_DynCom::SaveContext(Core::ThreadContext& ctx) {
106 ctx.fpscr = state->VFP[1]; 105 ctx.fpscr = state->VFP[1];
107 ctx.fpexc = state->VFP[2]; 106 ctx.fpexc = state->VFP[2];
108 107
109 ctx.reg_15 = state->Reg[15];
110 ctx.mode = state->NextInstr; 108 ctx.mode = state->NextInstr;
111} 109}
112 110
@@ -116,13 +114,12 @@ void ARM_DynCom::LoadContext(const Core::ThreadContext& ctx) {
116 114
117 state->Reg[13] = ctx.sp; 115 state->Reg[13] = ctx.sp;
118 state->Reg[14] = ctx.lr; 116 state->Reg[14] = ctx.lr;
119 state->pc = ctx.pc; 117 state->Reg[15] = ctx.pc;
120 state->Cpsr = ctx.cpsr; 118 state->Cpsr = ctx.cpsr;
121 119
122 state->VFP[1] = ctx.fpscr; 120 state->VFP[1] = ctx.fpscr;
123 state->VFP[2] = ctx.fpexc; 121 state->VFP[2] = ctx.fpexc;
124 122
125 state->Reg[15] = ctx.reg_15;
126 state->NextInstr = ctx.mode; 123 state->NextInstr = ctx.mode;
127} 124}
128 125
diff --git a/src/core/arm/interpreter/arminit.cpp b/src/core/arm/interpreter/arminit.cpp
index a0e041fa0..a52d14960 100644
--- a/src/core/arm/interpreter/arminit.cpp
+++ b/src/core/arm/interpreter/arminit.cpp
@@ -95,12 +95,6 @@ ARMul_State* ARMul_NewState(ARMul_State* state)
95 state->lateabtSig = HIGH; 95 state->lateabtSig = HIGH;
96 state->bigendSig = LOW; 96 state->bigendSig = LOW;
97 97
98 //chy:2003-08-19
99 state->CP14R0_CCD = -1;
100
101 memset(&state->exclusive_tag_array[0], 0xFF, sizeof(state->exclusive_tag_array[0]) * 128);
102 state->exclusive_access_state = 0;
103
104 return state; 98 return state;
105} 99}
106 100
@@ -118,15 +112,15 @@ void ARMul_SelectProcessor(ARMul_State* state, unsigned properties)
118 state->data32Sig = HIGH; 112 state->data32Sig = HIGH;
119 } 113 }
120 114
121 state->is_v4 = (properties & (ARM_v4_Prop | ARM_v5_Prop)) ? HIGH : LOW; 115 state->is_v4 = (properties & (ARM_v4_Prop | ARM_v5_Prop)) != 0;
122 state->is_v5 = (properties & ARM_v5_Prop) ? HIGH : LOW; 116 state->is_v5 = (properties & ARM_v5_Prop) != 0;
123 state->is_v5e = (properties & ARM_v5e_Prop) ? HIGH : LOW; 117 state->is_v5e = (properties & ARM_v5e_Prop) != 0;
124 state->is_XScale = (properties & ARM_XScale_Prop) ? HIGH : LOW; 118 state->is_XScale = (properties & ARM_XScale_Prop) != 0;
125 state->is_iWMMXt = (properties & ARM_iWMMXt_Prop) ? HIGH : LOW; 119 state->is_iWMMXt = (properties & ARM_iWMMXt_Prop) != 0;
126 state->is_v6 = (properties & ARM_v6_Prop) ? HIGH : LOW; 120 state->is_v6 = (properties & ARM_v6_Prop) != 0;
127 state->is_ep9312 = (properties & ARM_ep9312_Prop) ? HIGH : LOW; 121 state->is_ep9312 = (properties & ARM_ep9312_Prop) != 0;
128 state->is_pxa27x = (properties & ARM_PXA27X_Prop) ? HIGH : LOW; 122 state->is_pxa27x = (properties & ARM_PXA27X_Prop) != 0;
129 state->is_v7 = (properties & ARM_v7_Prop) ? HIGH : LOW; 123 state->is_v7 = (properties & ARM_v7_Prop) != 0;
130 124
131 /* Only initialse the coprocessor support once we 125 /* Only initialse the coprocessor support once we
132 know what kind of chip we are dealing with. */ 126 know what kind of chip we are dealing with. */
@@ -164,9 +158,4 @@ void ARMul_Reset(ARMul_State* state)
164 state->AbortAddr = 1; 158 state->AbortAddr = 1;
165 159
166 state->NumInstrs = 0; 160 state->NumInstrs = 0;
167 state->NumNcycles = 0;
168 state->NumScycles = 0;
169 state->NumIcycles = 0;
170 state->NumCcycles = 0;
171 state->NumFcycles = 0;
172} 161}
diff --git a/src/core/arm/skyeye_common/armdefs.h b/src/core/arm/skyeye_common/armdefs.h
index be54ce71b..778868783 100644
--- a/src/core/arm/skyeye_common/armdefs.h
+++ b/src/core/arm/skyeye_common/armdefs.h
@@ -74,88 +74,69 @@ typedef unsigned ARMul_CPWrites(ARMul_State* state, unsigned reg, ARMword value)
74#define VFP_REG_NUM 64 74#define VFP_REG_NUM 64
75struct ARMul_State 75struct ARMul_State
76{ 76{
77 ARMword Emulate; /* to start and stop emulation */ 77 ARMword Emulate; // To start and stop emulation
78 unsigned EndCondition; /* reason for stopping */ 78 unsigned EndCondition; // Reason for stopping
79 unsigned ErrorCode; /* type of illegal instruction */ 79 unsigned ErrorCode; // Type of illegal instruction
80 80
81 /* Order of the following register should not be modified */ 81 // Order of the following register should not be modified
82 ARMword Reg[16]; /* the current register file */ 82 ARMword Reg[16]; // The current register file
83 ARMword Cpsr; /* the current psr */ 83 ARMword Cpsr; // The current PSR
84 ARMword Spsr_copy; 84 ARMword Spsr_copy;
85 ARMword phys_pc; 85 ARMword phys_pc;
86 ARMword Reg_usr[2]; 86 ARMword Reg_usr[2];
87 ARMword Reg_svc[2]; /* R13_SVC R14_SVC */ 87 ARMword Reg_svc[2]; // R13_SVC R14_SVC
88 ARMword Reg_abort[2]; /* R13_ABORT R14_ABORT */ 88 ARMword Reg_abort[2]; // R13_ABORT R14_ABORT
89 ARMword Reg_undef[2]; /* R13 UNDEF R14 UNDEF */ 89 ARMword Reg_undef[2]; // R13 UNDEF R14 UNDEF
90 ARMword Reg_irq[2]; /* R13_IRQ R14_IRQ */ 90 ARMword Reg_irq[2]; // R13_IRQ R14_IRQ
91 ARMword Reg_firq[7]; /* R8---R14 FIRQ */ 91 ARMword Reg_firq[7]; // R8---R14 FIRQ
92 ARMword Spsr[7]; /* the exception psr's */ 92 ARMword Spsr[7]; // The exception psr's
93 ARMword Mode; /* the current mode */ 93 ARMword Mode; // The current mode
94 ARMword Bank; /* the current register bank */ 94 ARMword Bank; // The current register bank
95 ARMword exclusive_tag; /* the address for which the local monitor is in exclusive access mode */ 95 ARMword exclusive_tag; // The address for which the local monitor is in exclusive access mode
96 ARMword exclusive_state; 96 ARMword exclusive_state;
97 ARMword exclusive_result; 97 ARMword exclusive_result;
98 ARMword CP15[VFP_BASE - CP15_BASE]; 98 ARMword CP15[VFP_BASE - CP15_BASE];
99 ARMword VFP[3]; /* FPSID, FPSCR, and FPEXC */ 99 ARMword VFP[3]; // FPSID, FPSCR, and FPEXC
100 /* VFPv2 and VFPv3-D16 has 16 doubleword registers (D0-D16 or S0-S31). 100 // VFPv2 and VFPv3-D16 has 16 doubleword registers (D0-D16 or S0-S31).
101 VFPv3-D32/ASIMD may have up to 32 doubleword registers (D0-D31), 101 // VFPv3-D32/ASIMD may have up to 32 doubleword registers (D0-D31),
102 and only 32 singleword registers are accessible (S0-S31). */ 102 // and only 32 singleword registers are accessible (S0-S31).
103 ARMword ExtReg[VFP_REG_NUM]; 103 ARMword ExtReg[VFP_REG_NUM];
104 /* ---- End of the ordered registers ---- */ 104 /* ---- End of the ordered registers ---- */
105 105
106 ARMword RegBank[7][16]; /* all the registers */ 106 ARMword RegBank[7][16]; // all the registers
107 //chy:2003-08-19, used in arm xscale 107
108 /* 40 bit accumulator. We always keep this 64 bits wide, 108 ARMword NFlag, ZFlag, CFlag, VFlag, IFFlags; // Dummy flags for speed
109 and move only 40 bits out of it in an MRA insn. */
110 ARMdword Accumulator;
111
112 ARMword NFlag, ZFlag, CFlag, VFlag, IFFlags; /* dummy flags for speed */
113 unsigned long long int icounter, debug_icounter, kernel_icounter;
114 unsigned int shifter_carry_out; 109 unsigned int shifter_carry_out;
115 110
116 /* add armv6 flags dyf:2010-08-09 */ 111 // Add armv6 flags dyf:2010-08-09
117 ARMword GEFlag, EFlag, AFlag, QFlag; 112 ARMword GEFlag, EFlag, AFlag, QFlag;
118 //chy:2003-08-19, used in arm v5e|xscale 113
119 ARMword SFlag;
120#ifdef MODET 114#ifdef MODET
121 ARMword TFlag; /* Thumb state */ 115 ARMword TFlag; // Thumb state
122#endif 116#endif
123 ARMword instr, pc, temp; /* saved register state */
124 ARMword loaded, decoded; /* saved pipeline state */
125 //chy 2006-04-12 for ICE breakpoint
126 ARMword loaded_addr, decoded_addr; /* saved pipeline state addr*/
127 unsigned int NumScycles, NumNcycles, NumIcycles, NumCcycles, NumFcycles; /* emulated cycles used */
128 unsigned long long NumInstrs; /* the number of instructions executed */
129 unsigned NumInstrsToExecute;
130 117
131 ARMword currentexaddr; 118 unsigned long long NumInstrs; // The number of instructions executed
132 ARMword currentexval; 119 unsigned NumInstrsToExecute;
133 ARMword currentexvald;
134 ARMword servaddr;
135 120
136 unsigned NextInstr; 121 unsigned NextInstr;
137 unsigned VectorCatch; /* caught exception mask */ 122 unsigned VectorCatch; // Caught exception mask
138 unsigned CallDebug; /* set to call the debugger */ 123
139 unsigned CanWatch; /* set by memory interface if its willing to suffer the 124 ARMul_CPInits* CPInit[16]; // Coprocessor initialisers
140 overhead of checking for watchpoints on each memory 125 ARMul_CPExits* CPExit[16]; // Coprocessor finalisers
141 access */ 126 ARMul_LDCs* LDC[16]; // LDC instruction
142 127 ARMul_STCs* STC[16]; // STC instruction
143 ARMul_CPInits *CPInit[16]; /* coprocessor initialisers */ 128 ARMul_MRCs* MRC[16]; // MRC instruction
144 ARMul_CPExits *CPExit[16]; /* coprocessor finalisers */ 129 ARMul_MCRs* MCR[16]; // MCR instruction
145 ARMul_LDCs *LDC[16]; /* LDC instruction */ 130 ARMul_MRRCs* MRRC[16]; // MRRC instruction
146 ARMul_STCs *STC[16]; /* STC instruction */ 131 ARMul_MCRRs* MCRR[16]; // MCRR instruction
147 ARMul_MRCs *MRC[16]; /* MRC instruction */ 132 ARMul_CDPs* CDP[16]; // CDP instruction
148 ARMul_MCRs *MCR[16]; /* MCR instruction */ 133 ARMul_CPReads* CPRead[16]; // Read CP register
149 ARMul_MRRCs *MRRC[16]; /* MRRC instruction */ 134 ARMul_CPWrites* CPWrite[16]; // Write CP register
150 ARMul_MCRRs *MCRR[16]; /* MCRR instruction */ 135 unsigned char* CPData[16]; // Coprocessor data
151 ARMul_CDPs *CDP[16]; /* CDP instruction */ 136 unsigned char const* CPRegWords[16]; // Map of coprocessor register sizes
152 ARMul_CPReads *CPRead[16]; /* Read CP register */ 137
153 ARMul_CPWrites *CPWrite[16]; /* Write CP register */ 138 unsigned Debug; // Show instructions as they are executed
154 unsigned char *CPData[16]; /* Coprocessor data */ 139 unsigned NresetSig; // Reset the processor
155 unsigned char const *CPRegWords[16]; /* map of coprocessor register sizes */
156
157 unsigned Debug; /* show instructions as they are executed */
158 unsigned NresetSig; /* reset the processor */
159 unsigned NfiqSig; 140 unsigned NfiqSig;
160 unsigned NirqSig; 141 unsigned NirqSig;
161 142
@@ -199,54 +180,34 @@ So, if lateabtSig=1, then it means Late Abort Model(Base Updated Abort Model)
199*/ 180*/
200 unsigned lateabtSig; 181 unsigned lateabtSig;
201 182
202 ARMword Vector; /* synthesize aborts in cycle modes */ 183 ARMword Vector; // Synthesize aborts in cycle modes
203 ARMword Aborted; /* sticky flag for aborts */ 184 ARMword Aborted; // Sticky flag for aborts
204 ARMword Reseted; /* sticky flag for Reset */ 185 ARMword Reseted; // Sticky flag for Reset
205 ARMword Inted, LastInted; /* sticky flags for interrupts */ 186 ARMword Inted, LastInted; // Sticky flags for interrupts
206 ARMword Base; /* extra hand for base writeback */ 187 ARMword Base; // Extra hand for base writeback
207 ARMword AbortAddr; /* to keep track of Prefetch aborts */ 188 ARMword AbortAddr; // To keep track of Prefetch aborts
208 189
209 int verbose; /* non-zero means print various messages like the banner */ 190 // For differentiating ARM core emulaiton.
210 191 bool is_v4; // Are we emulating a v4 architecture (or higher)?
211 int mmu_inited; 192 bool is_v5; // Are we emulating a v5 architecture?
212 193 bool is_v5e; // Are we emulating a v5e architecture?
213 //chy: 2003-08-11, for different arm core type 194 bool is_v6; // Are we emulating a v6 architecture?
214 unsigned is_v4; /* Are we emulating a v4 architecture (or higher) ? */ 195 bool is_v7; // Are we emulating a v7 architecture?
215 unsigned is_v5; /* Are we emulating a v5 architecture ? */ 196 bool is_XScale; // Are we emulating an XScale architecture?
216 unsigned is_v5e; /* Are we emulating a v5e architecture ? */ 197 bool is_iWMMXt; // Are we emulating an iWMMXt co-processor?
217 unsigned is_v6; /* Are we emulating a v6 architecture ? */ 198 bool is_ep9312; // Are we emulating a Cirrus Maverick co-processor?
218 unsigned is_v7; /* Are we emulating a v7 architecture ? */ 199 bool is_pxa27x; // Are we emulating a Intel PXA27x co-processor?
219 unsigned is_XScale; /* Are we emulating an XScale architecture ? */ 200
220 unsigned is_iWMMXt; /* Are we emulating an iWMMXt co-processor ? */ 201 // ARM_ARM A2-18
221 unsigned is_ep9312; /* Are we emulating a Cirrus Maverick co-processor ? */ 202 // 0 Base Restored Abort Model, 1 the Early Abort Model, 2 Base Updated Abort Model
222 unsigned is_pxa27x; /* Are we emulating a Intel PXA27x co-processor ? */ 203 int abort_model;
223 204
224 //chy: seems only used in xscale's CP14 205 // Added by ksh in 2005-10-1
225 ARMword CP14R0_CCD; /* used to count 64 clock cycles with CP14 R0 bit 3 set */ 206 cpu_config_t* cpu;
226
227 //teawater add for arm2x86 2005.07.05-------------------------------------------
228 //arm_arm A2-18
229 int abort_model; //0 Base Restored Abort Model, 1 the Early Abort Model, 2 Base Updated Abort Model
230
231 /*added by ksh in 2005-10-1*/
232 cpu_config_t *cpu;
233
234 /* added LPC remap function */
235 int vector_remap_flag;
236 u32 vector_remap_addr;
237 u32 vector_remap_size;
238
239 u32 step;
240 u32 cycle;
241
242 /* monitored memory for exclusice access */
243 ARMword exclusive_tag_array[128];
244 /* 1 means exclusive access and 0 means open access */
245 ARMword exclusive_access_state;
246 207
247 u32 CurrInstr; 208 u32 CurrInstr;
248 u32 last_pc; /* the last pc executed */ 209 u32 last_pc; // The last PC executed
249 u32 last_instr; /* the last inst executed */ 210 u32 last_instr; // The last instruction executed
250 u32 WriteAddr[17]; 211 u32 WriteAddr[17];
251 u32 WriteData[17]; 212 u32 WriteData[17];
252 u32 WritePc[17]; 213 u32 WritePc[17];
diff --git a/src/core/core.h b/src/core/core.h
index 8504bb2d9..5e132cb5a 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -23,7 +23,6 @@ struct ThreadContext {
23 u32 fpexc; 23 u32 fpexc;
24 24
25 // These are not part of native ThreadContext, but needed by emu 25 // These are not part of native ThreadContext, but needed by emu
26 u32 reg_15;
27 u32 mode; 26 u32 mode;
28}; 27};
29 28
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 03b492c75..56950ebd4 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -50,7 +50,7 @@ static void ResetThread(Thread* t, u32 arg, s32 lowest_priority) {
50 memset(&t->context, 0, sizeof(Core::ThreadContext)); 50 memset(&t->context, 0, sizeof(Core::ThreadContext));
51 51
52 t->context.cpu_registers[0] = arg; 52 t->context.cpu_registers[0] = arg;
53 t->context.pc = t->context.reg_15 = t->entry_point; 53 t->context.pc = t->entry_point;
54 t->context.sp = t->stack_top; 54 t->context.sp = t->stack_top;
55 t->context.cpsr = 0x1F; // Usermode 55 t->context.cpsr = 0x1F; // Usermode
56 56