summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/arm/dyncom/arm_dyncom.cpp11
-rw-r--r--src/core/arm/dyncom/arm_dyncom_interpreter.cpp365
-rw-r--r--src/core/arm/dyncom/arm_dyncom_run.cpp93
-rw-r--r--src/core/arm/dyncom/arm_dyncom_run.h21
-rw-r--r--src/core/arm/skyeye_common/arminit.cpp100
-rw-r--r--src/core/arm/skyeye_common/armmmu.h104
-rw-r--r--src/core/arm/skyeye_common/armstate.cpp657
-rw-r--r--src/core/arm/skyeye_common/armstate.h209
-rw-r--r--src/core/arm/skyeye_common/armsupp.cpp430
-rw-r--r--src/core/arm/skyeye_common/armsupp.h8
-rw-r--r--src/core/arm/skyeye_common/vfp/vfpinstr.cpp126
12 files changed, 1023 insertions, 1105 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index ba9af2a1f..6cc60fd58 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -4,9 +4,8 @@ set(SRCS
4 arm/dyncom/arm_dyncom.cpp 4 arm/dyncom/arm_dyncom.cpp
5 arm/dyncom/arm_dyncom_dec.cpp 5 arm/dyncom/arm_dyncom_dec.cpp
6 arm/dyncom/arm_dyncom_interpreter.cpp 6 arm/dyncom/arm_dyncom_interpreter.cpp
7 arm/dyncom/arm_dyncom_run.cpp
8 arm/dyncom/arm_dyncom_thumb.cpp 7 arm/dyncom/arm_dyncom_thumb.cpp
9 arm/skyeye_common/arminit.cpp 8 arm/skyeye_common/armstate.cpp
10 arm/skyeye_common/armsupp.cpp 9 arm/skyeye_common/armsupp.cpp
11 arm/skyeye_common/vfp/vfp.cpp 10 arm/skyeye_common/vfp/vfp.cpp
12 arm/skyeye_common/vfp/vfpdouble.cpp 11 arm/skyeye_common/vfp/vfpdouble.cpp
@@ -133,7 +132,6 @@ set(HEADERS
133 arm/dyncom/arm_dyncom_thumb.h 132 arm/dyncom/arm_dyncom_thumb.h
134 arm/skyeye_common/arm_regformat.h 133 arm/skyeye_common/arm_regformat.h
135 arm/skyeye_common/armstate.h 134 arm/skyeye_common/armstate.h
136 arm/skyeye_common/armmmu.h
137 arm/skyeye_common/armsupp.h 135 arm/skyeye_common/armsupp.h
138 arm/skyeye_common/vfp/asm_vfp.h 136 arm/skyeye_common/vfp/asm_vfp.h
139 arm/skyeye_common/vfp/vfp.h 137 arm/skyeye_common/vfp/vfp.h
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp
index a51a3acf8..9228a49ab 100644
--- a/src/core/arm/dyncom/arm_dyncom.cpp
+++ b/src/core/arm/dyncom/arm_dyncom.cpp
@@ -18,16 +18,7 @@
18#include "core/core_timing.h" 18#include "core/core_timing.h"
19 19
20ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) { 20ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) {
21 state = Common::make_unique<ARMul_State>(); 21 state = Common::make_unique<ARMul_State>(initial_mode);
22
23 // Reset the core to initial state
24 ARMul_Reset(state.get());
25
26 // Switch to the desired privilege mode.
27 switch_mode(state.get(), initial_mode);
28
29 state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack
30 state->Reg[15] = 0x00000000;
31} 22}
32 23
33ARM_DynCom::~ARM_DynCom() { 24ARM_DynCom::~ARM_DynCom() {
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
index fd5e13295..cf09acb4e 100644
--- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
+++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
@@ -17,7 +17,6 @@
17#include "core/arm/dyncom/arm_dyncom_interpreter.h" 17#include "core/arm/dyncom/arm_dyncom_interpreter.h"
18#include "core/arm/dyncom/arm_dyncom_thumb.h" 18#include "core/arm/dyncom/arm_dyncom_thumb.h"
19#include "core/arm/dyncom/arm_dyncom_run.h" 19#include "core/arm/dyncom/arm_dyncom_run.h"
20#include "core/arm/skyeye_common/armmmu.h"
21#include "core/arm/skyeye_common/armstate.h" 20#include "core/arm/skyeye_common/armstate.h"
22#include "core/arm/skyeye_common/armsupp.h" 21#include "core/arm/skyeye_common/armsupp.h"
23#include "core/arm/skyeye_common/vfp/vfp.h" 22#include "core/arm/skyeye_common/vfp/vfp.h"
@@ -3964,7 +3963,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3964 if (inst_cream->S && (inst_cream->Rd == 15)) { 3963 if (inst_cream->S && (inst_cream->Rd == 15)) {
3965 if (CurrentModeHasSPSR) { 3964 if (CurrentModeHasSPSR) {
3966 cpu->Cpsr = cpu->Spsr_copy; 3965 cpu->Cpsr = cpu->Spsr_copy;
3967 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 3966 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
3968 LOAD_NZCVT; 3967 LOAD_NZCVT;
3969 } 3968 }
3970 } else if (inst_cream->S) { 3969 } else if (inst_cream->S) {
@@ -3978,7 +3977,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3978 goto DISPATCH; 3977 goto DISPATCH;
3979 } 3978 }
3980 } 3979 }
3981 cpu->Reg[15] += GET_INST_SIZE(cpu); 3980 cpu->Reg[15] += cpu->GetInstructionSize();
3982 INC_PC(sizeof(adc_inst)); 3981 INC_PC(sizeof(adc_inst));
3983 FETCH_INST; 3982 FETCH_INST;
3984 GOTO_NEXT_INST; 3983 GOTO_NEXT_INST;
@@ -3990,7 +3989,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3990 3989
3991 u32 rn_val = RN; 3990 u32 rn_val = RN;
3992 if (inst_cream->Rn == 15) 3991 if (inst_cream->Rn == 15)
3993 rn_val += 2 * GET_INST_SIZE(cpu); 3992 rn_val += 2 * cpu->GetInstructionSize();
3994 3993
3995 bool carry; 3994 bool carry;
3996 bool overflow; 3995 bool overflow;
@@ -3999,7 +3998,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
3999 if (inst_cream->S && (inst_cream->Rd == 15)) { 3998 if (inst_cream->S && (inst_cream->Rd == 15)) {
4000 if (CurrentModeHasSPSR) { 3999 if (CurrentModeHasSPSR) {
4001 cpu->Cpsr = cpu->Spsr_copy; 4000 cpu->Cpsr = cpu->Spsr_copy;
4002 switch_mode(cpu, cpu->Cpsr & 0x1f); 4001 cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F);
4003 LOAD_NZCVT; 4002 LOAD_NZCVT;
4004 } 4003 }
4005 } else if (inst_cream->S) { 4004 } else if (inst_cream->S) {
@@ -4013,7 +4012,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4013 goto DISPATCH; 4012 goto DISPATCH;
4014 } 4013 }
4015 } 4014 }
4016 cpu->Reg[15] += GET_INST_SIZE(cpu); 4015 cpu->Reg[15] += cpu->GetInstructionSize();
4017 INC_PC(sizeof(add_inst)); 4016 INC_PC(sizeof(add_inst));
4018 FETCH_INST; 4017 FETCH_INST;
4019 GOTO_NEXT_INST; 4018 GOTO_NEXT_INST;
@@ -4028,7 +4027,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4028 if (inst_cream->S && (inst_cream->Rd == 15)) { 4027 if (inst_cream->S && (inst_cream->Rd == 15)) {
4029 if (CurrentModeHasSPSR) { 4028 if (CurrentModeHasSPSR) {
4030 cpu->Cpsr = cpu->Spsr_copy; 4029 cpu->Cpsr = cpu->Spsr_copy;
4031 switch_mode(cpu, cpu->Cpsr & 0x1f); 4030 cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F);
4032 LOAD_NZCVT; 4031 LOAD_NZCVT;
4033 } 4032 }
4034 } else if (inst_cream->S) { 4033 } else if (inst_cream->S) {
@@ -4041,7 +4040,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4041 goto DISPATCH; 4040 goto DISPATCH;
4042 } 4041 }
4043 } 4042 }
4044 cpu->Reg[15] += GET_INST_SIZE(cpu); 4043 cpu->Reg[15] += cpu->GetInstructionSize();
4045 INC_PC(sizeof(and_inst)); 4044 INC_PC(sizeof(and_inst));
4046 FETCH_INST; 4045 FETCH_INST;
4047 GOTO_NEXT_INST; 4046 GOTO_NEXT_INST;
@@ -4057,7 +4056,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4057 INC_PC(sizeof(bbl_inst)); 4056 INC_PC(sizeof(bbl_inst));
4058 goto DISPATCH; 4057 goto DISPATCH;
4059 } 4058 }
4060 cpu->Reg[15] += GET_INST_SIZE(cpu); 4059 cpu->Reg[15] += cpu->GetInstructionSize();
4061 INC_PC(sizeof(bbl_inst)); 4060 INC_PC(sizeof(bbl_inst));
4062 goto DISPATCH; 4061 goto DISPATCH;
4063 } 4062 }
@@ -4067,14 +4066,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4067 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { 4066 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
4068 u32 lop = RN; 4067 u32 lop = RN;
4069 if (inst_cream->Rn == 15) { 4068 if (inst_cream->Rn == 15) {
4070 lop += 2 * GET_INST_SIZE(cpu); 4069 lop += 2 * cpu->GetInstructionSize();
4071 } 4070 }
4072 u32 rop = SHIFTER_OPERAND; 4071 u32 rop = SHIFTER_OPERAND;
4073 RD = lop & (~rop); 4072 RD = lop & (~rop);
4074 if ((inst_cream->S) && (inst_cream->Rd == 15)) { 4073 if ((inst_cream->S) && (inst_cream->Rd == 15)) {
4075 if (CurrentModeHasSPSR) { 4074 if (CurrentModeHasSPSR) {
4076 cpu->Cpsr = cpu->Spsr_copy; 4075 cpu->Cpsr = cpu->Spsr_copy;
4077 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 4076 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
4078 LOAD_NZCVT; 4077 LOAD_NZCVT;
4079 } 4078 }
4080 } else if (inst_cream->S) { 4079 } else if (inst_cream->S) {
@@ -4087,7 +4086,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4087 goto DISPATCH; 4086 goto DISPATCH;
4088 } 4087 }
4089 } 4088 }
4090 cpu->Reg[15] += GET_INST_SIZE(cpu); 4089 cpu->Reg[15] += cpu->GetInstructionSize();
4091 INC_PC(sizeof(bic_inst)); 4090 INC_PC(sizeof(bic_inst));
4092 FETCH_INST; 4091 FETCH_INST;
4093 GOTO_NEXT_INST; 4092 GOTO_NEXT_INST;
@@ -4098,7 +4097,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4098 bkpt_inst* const inst_cream = (bkpt_inst*)inst_base->component; 4097 bkpt_inst* const inst_cream = (bkpt_inst*)inst_base->component;
4099 LOG_DEBUG(Core_ARM11, "Breakpoint instruction hit. Immediate: 0x%08X", inst_cream->imm); 4098 LOG_DEBUG(Core_ARM11, "Breakpoint instruction hit. Immediate: 0x%08X", inst_cream->imm);
4100 } 4099 }
4101 cpu->Reg[15] += GET_INST_SIZE(cpu); 4100 cpu->Reg[15] += cpu->GetInstructionSize();
4102 INC_PC(sizeof(bkpt_inst)); 4101 INC_PC(sizeof(bkpt_inst));
4103 FETCH_INST; 4102 FETCH_INST;
4104 GOTO_NEXT_INST; 4103 GOTO_NEXT_INST;
@@ -4109,13 +4108,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4109 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { 4108 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
4110 unsigned int inst = inst_cream->inst; 4109 unsigned int inst = inst_cream->inst;
4111 if (BITS(inst, 20, 27) == 0x12 && BITS(inst, 4, 7) == 0x3) { 4110 if (BITS(inst, 20, 27) == 0x12 && BITS(inst, 4, 7) == 0x3) {
4112 cpu->Reg[14] = (cpu->Reg[15] + GET_INST_SIZE(cpu)); 4111 cpu->Reg[14] = (cpu->Reg[15] + cpu->GetInstructionSize());
4113 if(cpu->TFlag) 4112 if(cpu->TFlag)
4114 cpu->Reg[14] |= 0x1; 4113 cpu->Reg[14] |= 0x1;
4115 cpu->Reg[15] = cpu->Reg[inst_cream->val.Rm] & 0xfffffffe; 4114 cpu->Reg[15] = cpu->Reg[inst_cream->val.Rm] & 0xfffffffe;
4116 cpu->TFlag = cpu->Reg[inst_cream->val.Rm] & 0x1; 4115 cpu->TFlag = cpu->Reg[inst_cream->val.Rm] & 0x1;
4117 } else { 4116 } else {
4118 cpu->Reg[14] = (cpu->Reg[15] + GET_INST_SIZE(cpu)); 4117 cpu->Reg[14] = (cpu->Reg[15] + cpu->GetInstructionSize());
4119 cpu->TFlag = 0x1; 4118 cpu->TFlag = 0x1;
4120 int signed_int = inst_cream->val.signed_immed_24; 4119 int signed_int = inst_cream->val.signed_immed_24;
4121 signed_int = (signed_int & 0x800000) ? (0x3F000000 | signed_int) : signed_int; 4120 signed_int = (signed_int & 0x800000) ? (0x3F000000 | signed_int) : signed_int;
@@ -4125,7 +4124,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4125 INC_PC(sizeof(blx_inst)); 4124 INC_PC(sizeof(blx_inst));
4126 goto DISPATCH; 4125 goto DISPATCH;
4127 } 4126 }
4128 cpu->Reg[15] += GET_INST_SIZE(cpu); 4127 cpu->Reg[15] += cpu->GetInstructionSize();
4129 INC_PC(sizeof(blx_inst)); 4128 INC_PC(sizeof(blx_inst));
4130 goto DISPATCH; 4129 goto DISPATCH;
4131 } 4130 }
@@ -4147,7 +4146,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4147 u32 address = RM; 4146 u32 address = RM;
4148 4147
4149 if (inst_cream->Rm == 15) 4148 if (inst_cream->Rm == 15)
4150 address += 2 * GET_INST_SIZE(cpu); 4149 address += 2 * cpu->GetInstructionSize();
4151 4150
4152 cpu->TFlag = address & 1; 4151 cpu->TFlag = address & 1;
4153 cpu->Reg[15] = address & 0xfffffffe; 4152 cpu->Reg[15] = address & 0xfffffffe;
@@ -4155,7 +4154,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4155 goto DISPATCH; 4154 goto DISPATCH;
4156 } 4155 }
4157 4156
4158 cpu->Reg[15] += GET_INST_SIZE(cpu); 4157 cpu->Reg[15] += cpu->GetInstructionSize();
4159 INC_PC(sizeof(bx_inst)); 4158 INC_PC(sizeof(bx_inst));
4160 goto DISPATCH; 4159 goto DISPATCH;
4161 } 4160 }
@@ -4167,7 +4166,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4167 cpu->NumInstrsToExecute = 0; 4166 cpu->NumInstrsToExecute = 0;
4168 return num_instrs; 4167 return num_instrs;
4169 } 4168 }
4170 cpu->Reg[15] += GET_INST_SIZE(cpu); 4169 cpu->Reg[15] += cpu->GetInstructionSize();
4171 INC_PC(sizeof(cdp_inst)); 4170 INC_PC(sizeof(cdp_inst));
4172 FETCH_INST; 4171 FETCH_INST;
4173 GOTO_NEXT_INST; 4172 GOTO_NEXT_INST;
@@ -4178,7 +4177,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4178 remove_exclusive(cpu, 0); 4177 remove_exclusive(cpu, 0);
4179 cpu->exclusive_state = 0; 4178 cpu->exclusive_state = 0;
4180 4179
4181 cpu->Reg[15] += GET_INST_SIZE(cpu); 4180 cpu->Reg[15] += cpu->GetInstructionSize();
4182 INC_PC(sizeof(clrex_inst)); 4181 INC_PC(sizeof(clrex_inst));
4183 FETCH_INST; 4182 FETCH_INST;
4184 GOTO_NEXT_INST; 4183 GOTO_NEXT_INST;
@@ -4189,7 +4188,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4189 clz_inst* inst_cream = (clz_inst*)inst_base->component; 4188 clz_inst* inst_cream = (clz_inst*)inst_base->component;
4190 RD = clz(RM); 4189 RD = clz(RM);
4191 } 4190 }
4192 cpu->Reg[15] += GET_INST_SIZE(cpu); 4191 cpu->Reg[15] += cpu->GetInstructionSize();
4193 INC_PC(sizeof(clz_inst)); 4192 INC_PC(sizeof(clz_inst));
4194 FETCH_INST; 4193 FETCH_INST;
4195 GOTO_NEXT_INST; 4194 GOTO_NEXT_INST;
@@ -4208,7 +4207,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4208 cpu->CFlag = carry; 4207 cpu->CFlag = carry;
4209 cpu->VFlag = overflow; 4208 cpu->VFlag = overflow;
4210 } 4209 }
4211 cpu->Reg[15] += GET_INST_SIZE(cpu); 4210 cpu->Reg[15] += cpu->GetInstructionSize();
4212 INC_PC(sizeof(cmn_inst)); 4211 INC_PC(sizeof(cmn_inst));
4213 FETCH_INST; 4212 FETCH_INST;
4214 GOTO_NEXT_INST; 4213 GOTO_NEXT_INST;
@@ -4220,7 +4219,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4220 4219
4221 u32 rn_val = RN; 4220 u32 rn_val = RN;
4222 if (inst_cream->Rn == 15) 4221 if (inst_cream->Rn == 15)
4223 rn_val += 2 * GET_INST_SIZE(cpu); 4222 rn_val += 2 * cpu->GetInstructionSize();
4224 4223
4225 bool carry; 4224 bool carry;
4226 bool overflow; 4225 bool overflow;
@@ -4231,7 +4230,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4231 cpu->CFlag = carry; 4230 cpu->CFlag = carry;
4232 cpu->VFlag = overflow; 4231 cpu->VFlag = overflow;
4233 } 4232 }
4234 cpu->Reg[15] += GET_INST_SIZE(cpu); 4233 cpu->Reg[15] += cpu->GetInstructionSize();
4235 INC_PC(sizeof(cmp_inst)); 4234 INC_PC(sizeof(cmp_inst));
4236 FETCH_INST; 4235 FETCH_INST;
4237 GOTO_NEXT_INST; 4236 GOTO_NEXT_INST;
@@ -4241,7 +4240,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4241 cps_inst *inst_cream = (cps_inst *)inst_base->component; 4240 cps_inst *inst_cream = (cps_inst *)inst_base->component;
4242 uint32_t aif_val = 0; 4241 uint32_t aif_val = 0;
4243 uint32_t aif_mask = 0; 4242 uint32_t aif_mask = 0;
4244 if (InAPrivilegedMode(cpu)) { 4243 if (cpu->InAPrivilegedMode()) {
4245 if (inst_cream->imod1) { 4244 if (inst_cream->imod1) {
4246 if (inst_cream->A) { 4245 if (inst_cream->A) {
4247 aif_val |= (inst_cream->imod0 << 8); 4246 aif_val |= (inst_cream->imod0 << 8);
@@ -4260,10 +4259,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4260 } 4259 }
4261 if (inst_cream->mmod) { 4260 if (inst_cream->mmod) {
4262 cpu->Cpsr = (cpu->Cpsr & 0xffffffe0) | inst_cream->mode; 4261 cpu->Cpsr = (cpu->Cpsr & 0xffffffe0) | inst_cream->mode;
4263 switch_mode(cpu, inst_cream->mode); 4262 cpu->ChangePrivilegeMode(inst_cream->mode);
4264 } 4263 }
4265 } 4264 }
4266 cpu->Reg[15] += GET_INST_SIZE(cpu); 4265 cpu->Reg[15] += cpu->GetInstructionSize();
4267 INC_PC(sizeof(cps_inst)); 4266 INC_PC(sizeof(cps_inst));
4268 FETCH_INST; 4267 FETCH_INST;
4269 GOTO_NEXT_INST; 4268 GOTO_NEXT_INST;
@@ -4279,7 +4278,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4279 goto DISPATCH; 4278 goto DISPATCH;
4280 } 4279 }
4281 } 4280 }
4282 cpu->Reg[15] += GET_INST_SIZE(cpu); 4281 cpu->Reg[15] += cpu->GetInstructionSize();
4283 INC_PC(sizeof(mov_inst)); 4282 INC_PC(sizeof(mov_inst));
4284 FETCH_INST; 4283 FETCH_INST;
4285 GOTO_NEXT_INST; 4284 GOTO_NEXT_INST;
@@ -4291,14 +4290,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4291 4290
4292 u32 lop = RN; 4291 u32 lop = RN;
4293 if (inst_cream->Rn == 15) { 4292 if (inst_cream->Rn == 15) {
4294 lop += 2 * GET_INST_SIZE(cpu); 4293 lop += 2 * cpu->GetInstructionSize();
4295 } 4294 }
4296 u32 rop = SHIFTER_OPERAND; 4295 u32 rop = SHIFTER_OPERAND;
4297 RD = lop ^ rop; 4296 RD = lop ^ rop;
4298 if (inst_cream->S && (inst_cream->Rd == 15)) { 4297 if (inst_cream->S && (inst_cream->Rd == 15)) {
4299 if (CurrentModeHasSPSR) { 4298 if (CurrentModeHasSPSR) {
4300 cpu->Cpsr = cpu->Spsr_copy; 4299 cpu->Cpsr = cpu->Spsr_copy;
4301 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 4300 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
4302 LOAD_NZCVT; 4301 LOAD_NZCVT;
4303 } 4302 }
4304 } else if (inst_cream->S) { 4303 } else if (inst_cream->S) {
@@ -4311,7 +4310,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4311 goto DISPATCH; 4310 goto DISPATCH;
4312 } 4311 }
4313 } 4312 }
4314 cpu->Reg[15] += GET_INST_SIZE(cpu); 4313 cpu->Reg[15] += cpu->GetInstructionSize();
4315 INC_PC(sizeof(eor_inst)); 4314 INC_PC(sizeof(eor_inst));
4316 FETCH_INST; 4315 FETCH_INST;
4317 GOTO_NEXT_INST; 4316 GOTO_NEXT_INST;
@@ -4320,7 +4319,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4320 { 4319 {
4321 // Instruction not implemented 4320 // Instruction not implemented
4322 //LOG_CRITICAL(Core_ARM11, "unimplemented instruction"); 4321 //LOG_CRITICAL(Core_ARM11, "unimplemented instruction");
4323 cpu->Reg[15] += GET_INST_SIZE(cpu); 4322 cpu->Reg[15] += cpu->GetInstructionSize();
4324 INC_PC(sizeof(ldc_inst)); 4323 INC_PC(sizeof(ldc_inst));
4325 FETCH_INST; 4324 FETCH_INST;
4326 GOTO_NEXT_INST; 4325 GOTO_NEXT_INST;
@@ -4335,30 +4334,30 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4335 if (BIT(inst, 22) && !BIT(inst, 15)) { 4334 if (BIT(inst, 22) && !BIT(inst, 15)) {
4336 for (int i = 0; i < 13; i++) { 4335 for (int i = 0; i < 13; i++) {
4337 if(BIT(inst, i)) { 4336 if(BIT(inst, i)) {
4338 cpu->Reg[i] = ReadMemory32(cpu, addr); 4337 cpu->Reg[i] = cpu->ReadMemory32(addr);
4339 addr += 4; 4338 addr += 4;
4340 } 4339 }
4341 } 4340 }
4342 if (BIT(inst, 13)) { 4341 if (BIT(inst, 13)) {
4343 if (cpu->Mode == USER32MODE) 4342 if (cpu->Mode == USER32MODE)
4344 cpu->Reg[13] = ReadMemory32(cpu, addr); 4343 cpu->Reg[13] = cpu->ReadMemory32(addr);
4345 else 4344 else
4346 cpu->Reg_usr[0] = ReadMemory32(cpu, addr); 4345 cpu->Reg_usr[0] = cpu->ReadMemory32(addr);
4347 4346
4348 addr += 4; 4347 addr += 4;
4349 } 4348 }
4350 if (BIT(inst, 14)) { 4349 if (BIT(inst, 14)) {
4351 if (cpu->Mode == USER32MODE) 4350 if (cpu->Mode == USER32MODE)
4352 cpu->Reg[14] = ReadMemory32(cpu, addr); 4351 cpu->Reg[14] = cpu->ReadMemory32(addr);
4353 else 4352 else
4354 cpu->Reg_usr[1] = ReadMemory32(cpu, addr); 4353 cpu->Reg_usr[1] = cpu->ReadMemory32(addr);
4355 4354
4356 addr += 4; 4355 addr += 4;
4357 } 4356 }
4358 } else if (!BIT(inst, 22)) { 4357 } else if (!BIT(inst, 22)) {
4359 for(int i = 0; i < 16; i++ ){ 4358 for(int i = 0; i < 16; i++ ){
4360 if(BIT(inst, i)){ 4359 if(BIT(inst, i)){
4361 unsigned int ret = ReadMemory32(cpu, addr); 4360 unsigned int ret = cpu->ReadMemory32(addr);
4362 4361
4363 // For armv5t, should enter thumb when bits[0] is non-zero. 4362 // For armv5t, should enter thumb when bits[0] is non-zero.
4364 if(i == 15){ 4363 if(i == 15){
@@ -4373,18 +4372,18 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4373 } else if (BIT(inst, 22) && BIT(inst, 15)) { 4372 } else if (BIT(inst, 22) && BIT(inst, 15)) {
4374 for(int i = 0; i < 15; i++ ){ 4373 for(int i = 0; i < 15; i++ ){
4375 if(BIT(inst, i)){ 4374 if(BIT(inst, i)){
4376 cpu->Reg[i] = ReadMemory32(cpu, addr); 4375 cpu->Reg[i] = cpu->ReadMemory32(addr);
4377 addr += 4; 4376 addr += 4;
4378 } 4377 }
4379 } 4378 }
4380 4379
4381 if (CurrentModeHasSPSR) { 4380 if (CurrentModeHasSPSR) {
4382 cpu->Cpsr = cpu->Spsr_copy; 4381 cpu->Cpsr = cpu->Spsr_copy;
4383 switch_mode(cpu, cpu->Cpsr & 0x1f); 4382 cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F);
4384 LOAD_NZCVT; 4383 LOAD_NZCVT;
4385 } 4384 }
4386 4385
4387 cpu->Reg[15] = ReadMemory32(cpu, addr); 4386 cpu->Reg[15] = cpu->ReadMemory32(addr);
4388 } 4387 }
4389 4388
4390 if (BIT(inst, 15)) { 4389 if (BIT(inst, 15)) {
@@ -4392,7 +4391,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4392 goto DISPATCH; 4391 goto DISPATCH;
4393 } 4392 }
4394 } 4393 }
4395 cpu->Reg[15] += GET_INST_SIZE(cpu); 4394 cpu->Reg[15] += cpu->GetInstructionSize();
4396 INC_PC(sizeof(ldst_inst)); 4395 INC_PC(sizeof(ldst_inst));
4397 FETCH_INST; 4396 FETCH_INST;
4398 GOTO_NEXT_INST; 4397 GOTO_NEXT_INST;
@@ -4410,7 +4409,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4410 } 4409 }
4411 RD = operand2; 4410 RD = operand2;
4412 } 4411 }
4413 cpu->Reg[15] += GET_INST_SIZE(cpu); 4412 cpu->Reg[15] += cpu->GetInstructionSize();
4414 INC_PC(sizeof(sxth_inst)); 4413 INC_PC(sizeof(sxth_inst));
4415 FETCH_INST; 4414 FETCH_INST;
4416 GOTO_NEXT_INST; 4415 GOTO_NEXT_INST;
@@ -4420,7 +4419,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4420 ldst_inst *inst_cream = (ldst_inst *)inst_base->component; 4419 ldst_inst *inst_cream = (ldst_inst *)inst_base->component;
4421 inst_cream->get_addr(cpu, inst_cream->inst, addr); 4420 inst_cream->get_addr(cpu, inst_cream->inst, addr);
4422 4421
4423 unsigned int value = ReadMemory32(cpu, addr); 4422 unsigned int value = cpu->ReadMemory32(addr);
4424 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; 4423 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
4425 4424
4426 if (BITS(inst_cream->inst, 12, 15) == 15) { 4425 if (BITS(inst_cream->inst, 12, 15) == 15) {
@@ -4431,7 +4430,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4431 goto DISPATCH; 4430 goto DISPATCH;
4432 } 4431 }
4433 4432
4434 cpu->Reg[15] += GET_INST_SIZE(cpu); 4433 cpu->Reg[15] += cpu->GetInstructionSize();
4435 INC_PC(sizeof(ldst_inst)); 4434 INC_PC(sizeof(ldst_inst));
4436 FETCH_INST; 4435 FETCH_INST;
4437 GOTO_NEXT_INST; 4436 GOTO_NEXT_INST;
@@ -4442,7 +4441,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4442 ldst_inst *inst_cream = (ldst_inst *)inst_base->component; 4441 ldst_inst *inst_cream = (ldst_inst *)inst_base->component;
4443 inst_cream->get_addr(cpu, inst_cream->inst, addr); 4442 inst_cream->get_addr(cpu, inst_cream->inst, addr);
4444 4443
4445 unsigned int value = ReadMemory32(cpu, addr); 4444 unsigned int value = cpu->ReadMemory32(addr);
4446 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; 4445 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
4447 4446
4448 if (BITS(inst_cream->inst, 12, 15) == 15) { 4447 if (BITS(inst_cream->inst, 12, 15) == 15) {
@@ -4453,7 +4452,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4453 goto DISPATCH; 4452 goto DISPATCH;
4454 } 4453 }
4455 } 4454 }
4456 cpu->Reg[15] += GET_INST_SIZE(cpu); 4455 cpu->Reg[15] += cpu->GetInstructionSize();
4457 INC_PC(sizeof(ldst_inst)); 4456 INC_PC(sizeof(ldst_inst));
4458 FETCH_INST; 4457 FETCH_INST;
4459 GOTO_NEXT_INST; 4458 GOTO_NEXT_INST;
@@ -4464,7 +4463,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4464 uxth_inst* inst_cream = (uxth_inst*)inst_base->component; 4463 uxth_inst* inst_cream = (uxth_inst*)inst_base->component;
4465 RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xffff; 4464 RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xffff;
4466 } 4465 }
4467 cpu->Reg[15] += GET_INST_SIZE(cpu); 4466 cpu->Reg[15] += cpu->GetInstructionSize();
4468 INC_PC(sizeof(uxth_inst)); 4467 INC_PC(sizeof(uxth_inst));
4469 FETCH_INST; 4468 FETCH_INST;
4470 GOTO_NEXT_INST; 4469 GOTO_NEXT_INST;
@@ -4477,7 +4476,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4477 4476
4478 RD = RN + operand2; 4477 RD = RN + operand2;
4479 } 4478 }
4480 cpu->Reg[15] += GET_INST_SIZE(cpu); 4479 cpu->Reg[15] += cpu->GetInstructionSize();
4481 INC_PC(sizeof(uxtah_inst)); 4480 INC_PC(sizeof(uxtah_inst));
4482 FETCH_INST; 4481 FETCH_INST;
4483 GOTO_NEXT_INST; 4482 GOTO_NEXT_INST;
@@ -4495,7 +4494,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4495 goto DISPATCH; 4494 goto DISPATCH;
4496 } 4495 }
4497 } 4496 }
4498 cpu->Reg[15] += GET_INST_SIZE(cpu); 4497 cpu->Reg[15] += cpu->GetInstructionSize();
4499 INC_PC(sizeof(ldst_inst)); 4498 INC_PC(sizeof(ldst_inst));
4500 FETCH_INST; 4499 FETCH_INST;
4501 GOTO_NEXT_INST; 4500 GOTO_NEXT_INST;
@@ -4513,7 +4512,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4513 goto DISPATCH; 4512 goto DISPATCH;
4514 } 4513 }
4515 } 4514 }
4516 cpu->Reg[15] += GET_INST_SIZE(cpu); 4515 cpu->Reg[15] += cpu->GetInstructionSize();
4517 INC_PC(sizeof(ldst_inst)); 4516 INC_PC(sizeof(ldst_inst));
4518 FETCH_INST; 4517 FETCH_INST;
4519 GOTO_NEXT_INST; 4518 GOTO_NEXT_INST;
@@ -4527,8 +4526,8 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4527 4526
4528 // The 3DS doesn't have LPAE (Large Physical Access Extension), so it 4527 // The 3DS doesn't have LPAE (Large Physical Access Extension), so it
4529 // wouldn't do this as a single read. 4528 // wouldn't do this as a single read.
4530 cpu->Reg[BITS(inst_cream->inst, 12, 15) + 0] = ReadMemory32(cpu, addr); 4529 cpu->Reg[BITS(inst_cream->inst, 12, 15) + 0] = cpu->ReadMemory32(addr);
4531 cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1] = ReadMemory32(cpu, addr + 4); 4530 cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1] = cpu->ReadMemory32(addr + 4);
4532 4531
4533 // No dispatch since this operation should not modify R15 4532 // No dispatch since this operation should not modify R15
4534 } 4533 }
@@ -4547,13 +4546,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4547 add_exclusive_addr(cpu, read_addr); 4546 add_exclusive_addr(cpu, read_addr);
4548 cpu->exclusive_state = 1; 4547 cpu->exclusive_state = 1;
4549 4548
4550 RD = ReadMemory32(cpu, read_addr); 4549 RD = cpu->ReadMemory32(read_addr);
4551 if (inst_cream->Rd == 15) { 4550 if (inst_cream->Rd == 15) {
4552 INC_PC(sizeof(generic_arm_inst)); 4551 INC_PC(sizeof(generic_arm_inst));
4553 goto DISPATCH; 4552 goto DISPATCH;
4554 } 4553 }
4555 } 4554 }
4556 cpu->Reg[15] += GET_INST_SIZE(cpu); 4555 cpu->Reg[15] += cpu->GetInstructionSize();
4557 INC_PC(sizeof(generic_arm_inst)); 4556 INC_PC(sizeof(generic_arm_inst));
4558 FETCH_INST; 4557 FETCH_INST;
4559 GOTO_NEXT_INST; 4558 GOTO_NEXT_INST;
@@ -4573,7 +4572,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4573 goto DISPATCH; 4572 goto DISPATCH;
4574 } 4573 }
4575 } 4574 }
4576 cpu->Reg[15] += GET_INST_SIZE(cpu); 4575 cpu->Reg[15] += cpu->GetInstructionSize();
4577 INC_PC(sizeof(generic_arm_inst)); 4576 INC_PC(sizeof(generic_arm_inst));
4578 FETCH_INST; 4577 FETCH_INST;
4579 GOTO_NEXT_INST; 4578 GOTO_NEXT_INST;
@@ -4587,13 +4586,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4587 add_exclusive_addr(cpu, read_addr); 4586 add_exclusive_addr(cpu, read_addr);
4588 cpu->exclusive_state = 1; 4587 cpu->exclusive_state = 1;
4589 4588
4590 RD = ReadMemory16(cpu, read_addr); 4589 RD = cpu->ReadMemory16(read_addr);
4591 if (inst_cream->Rd == 15) { 4590 if (inst_cream->Rd == 15) {
4592 INC_PC(sizeof(generic_arm_inst)); 4591 INC_PC(sizeof(generic_arm_inst));
4593 goto DISPATCH; 4592 goto DISPATCH;
4594 } 4593 }
4595 } 4594 }
4596 cpu->Reg[15] += GET_INST_SIZE(cpu); 4595 cpu->Reg[15] += cpu->GetInstructionSize();
4597 INC_PC(sizeof(generic_arm_inst)); 4596 INC_PC(sizeof(generic_arm_inst));
4598 FETCH_INST; 4597 FETCH_INST;
4599 GOTO_NEXT_INST; 4598 GOTO_NEXT_INST;
@@ -4607,15 +4606,15 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4607 add_exclusive_addr(cpu, read_addr); 4606 add_exclusive_addr(cpu, read_addr);
4608 cpu->exclusive_state = 1; 4607 cpu->exclusive_state = 1;
4609 4608
4610 RD = ReadMemory32(cpu, read_addr); 4609 RD = cpu->ReadMemory32(read_addr);
4611 RD2 = ReadMemory32(cpu, read_addr + 4); 4610 RD2 = cpu->ReadMemory32(read_addr + 4);
4612 4611
4613 if (inst_cream->Rd == 15) { 4612 if (inst_cream->Rd == 15) {
4614 INC_PC(sizeof(generic_arm_inst)); 4613 INC_PC(sizeof(generic_arm_inst));
4615 goto DISPATCH; 4614 goto DISPATCH;
4616 } 4615 }
4617 } 4616 }
4618 cpu->Reg[15] += GET_INST_SIZE(cpu); 4617 cpu->Reg[15] += cpu->GetInstructionSize();
4619 INC_PC(sizeof(generic_arm_inst)); 4618 INC_PC(sizeof(generic_arm_inst));
4620 FETCH_INST; 4619 FETCH_INST;
4621 GOTO_NEXT_INST; 4620 GOTO_NEXT_INST;
@@ -4626,13 +4625,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4626 ldst_inst* inst_cream = (ldst_inst*)inst_base->component; 4625 ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
4627 inst_cream->get_addr(cpu, inst_cream->inst, addr); 4626 inst_cream->get_addr(cpu, inst_cream->inst, addr);
4628 4627
4629 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = ReadMemory16(cpu, addr); 4628 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = cpu->ReadMemory16(addr);
4630 if (BITS(inst_cream->inst, 12, 15) == 15) { 4629 if (BITS(inst_cream->inst, 12, 15) == 15) {
4631 INC_PC(sizeof(ldst_inst)); 4630 INC_PC(sizeof(ldst_inst));
4632 goto DISPATCH; 4631 goto DISPATCH;
4633 } 4632 }
4634 } 4633 }
4635 cpu->Reg[15] += GET_INST_SIZE(cpu); 4634 cpu->Reg[15] += cpu->GetInstructionSize();
4636 INC_PC(sizeof(ldst_inst)); 4635 INC_PC(sizeof(ldst_inst));
4637 FETCH_INST; 4636 FETCH_INST;
4638 GOTO_NEXT_INST; 4637 GOTO_NEXT_INST;
@@ -4652,7 +4651,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4652 goto DISPATCH; 4651 goto DISPATCH;
4653 } 4652 }
4654 } 4653 }
4655 cpu->Reg[15] += GET_INST_SIZE(cpu); 4654 cpu->Reg[15] += cpu->GetInstructionSize();
4656 INC_PC(sizeof(ldst_inst)); 4655 INC_PC(sizeof(ldst_inst));
4657 FETCH_INST; 4656 FETCH_INST;
4658 GOTO_NEXT_INST; 4657 GOTO_NEXT_INST;
@@ -4663,7 +4662,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4663 ldst_inst* inst_cream = (ldst_inst*)inst_base->component; 4662 ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
4664 inst_cream->get_addr(cpu, inst_cream->inst, addr); 4663 inst_cream->get_addr(cpu, inst_cream->inst, addr);
4665 4664
4666 unsigned int value = ReadMemory16(cpu, addr); 4665 unsigned int value = cpu->ReadMemory16(addr);
4667 if (BIT(value, 15)) { 4666 if (BIT(value, 15)) {
4668 value |= 0xffff0000; 4667 value |= 0xffff0000;
4669 } 4668 }
@@ -4673,7 +4672,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4673 goto DISPATCH; 4672 goto DISPATCH;
4674 } 4673 }
4675 } 4674 }
4676 cpu->Reg[15] += GET_INST_SIZE(cpu); 4675 cpu->Reg[15] += cpu->GetInstructionSize();
4677 INC_PC(sizeof(ldst_inst)); 4676 INC_PC(sizeof(ldst_inst));
4678 FETCH_INST; 4677 FETCH_INST;
4679 GOTO_NEXT_INST; 4678 GOTO_NEXT_INST;
@@ -4684,7 +4683,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4684 ldst_inst* inst_cream = (ldst_inst*)inst_base->component; 4683 ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
4685 inst_cream->get_addr(cpu, inst_cream->inst, addr); 4684 inst_cream->get_addr(cpu, inst_cream->inst, addr);
4686 4685
4687 unsigned int value = ReadMemory32(cpu, addr); 4686 unsigned int value = cpu->ReadMemory32(addr);
4688 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; 4687 cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
4689 4688
4690 if (BITS(inst_cream->inst, 12, 15) == 15) { 4689 if (BITS(inst_cream->inst, 12, 15) == 15) {
@@ -4692,7 +4691,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4692 goto DISPATCH; 4691 goto DISPATCH;
4693 } 4692 }
4694 } 4693 }
4695 cpu->Reg[15] += GET_INST_SIZE(cpu); 4694 cpu->Reg[15] += cpu->GetInstructionSize();
4696 INC_PC(sizeof(ldst_inst)); 4695 INC_PC(sizeof(ldst_inst));
4697 FETCH_INST; 4696 FETCH_INST;
4698 GOTO_NEXT_INST; 4697 GOTO_NEXT_INST;
@@ -4707,10 +4706,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4707 DEBUG_MSG; 4706 DEBUG_MSG;
4708 } else { 4707 } else {
4709 if (inst_cream->cp_num == 15) 4708 if (inst_cream->cp_num == 15)
4710 WriteCP15Register(cpu, RD, CRn, OPCODE_1, CRm, OPCODE_2); 4709 cpu->WriteCP15Register(RD, CRn, OPCODE_1, CRm, OPCODE_2);
4711 } 4710 }
4712 } 4711 }
4713 cpu->Reg[15] += GET_INST_SIZE(cpu); 4712 cpu->Reg[15] += cpu->GetInstructionSize();
4714 INC_PC(sizeof(mcr_inst)); 4713 INC_PC(sizeof(mcr_inst));
4715 FETCH_INST; 4714 FETCH_INST;
4716 GOTO_NEXT_INST; 4715 GOTO_NEXT_INST;
@@ -4727,7 +4726,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4727 inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2); 4726 inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2);
4728 } 4727 }
4729 4728
4730 cpu->Reg[15] += GET_INST_SIZE(cpu); 4729 cpu->Reg[15] += cpu->GetInstructionSize();
4731 INC_PC(sizeof(mcrr_inst)); 4730 INC_PC(sizeof(mcrr_inst));
4732 FETCH_INST; 4731 FETCH_INST;
4733 GOTO_NEXT_INST; 4732 GOTO_NEXT_INST;
@@ -4752,7 +4751,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4752 goto DISPATCH; 4751 goto DISPATCH;
4753 } 4752 }
4754 } 4753 }
4755 cpu->Reg[15] += GET_INST_SIZE(cpu); 4754 cpu->Reg[15] += cpu->GetInstructionSize();
4756 INC_PC(sizeof(mla_inst)); 4755 INC_PC(sizeof(mla_inst));
4757 FETCH_INST; 4756 FETCH_INST;
4758 GOTO_NEXT_INST; 4757 GOTO_NEXT_INST;
@@ -4766,7 +4765,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4766 if (inst_cream->S && (inst_cream->Rd == 15)) { 4765 if (inst_cream->S && (inst_cream->Rd == 15)) {
4767 if (CurrentModeHasSPSR) { 4766 if (CurrentModeHasSPSR) {
4768 cpu->Cpsr = cpu->Spsr_copy; 4767 cpu->Cpsr = cpu->Spsr_copy;
4769 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 4768 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
4770 LOAD_NZCVT; 4769 LOAD_NZCVT;
4771 } 4770 }
4772 } else if (inst_cream->S) { 4771 } else if (inst_cream->S) {
@@ -4779,7 +4778,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4779 goto DISPATCH; 4778 goto DISPATCH;
4780 } 4779 }
4781 } 4780 }
4782 cpu->Reg[15] += GET_INST_SIZE(cpu); 4781 cpu->Reg[15] += cpu->GetInstructionSize();
4783 INC_PC(sizeof(mov_inst)); 4782 INC_PC(sizeof(mov_inst));
4784 FETCH_INST; 4783 FETCH_INST;
4785 GOTO_NEXT_INST; 4784 GOTO_NEXT_INST;
@@ -4800,10 +4799,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4800 goto END; 4799 goto END;
4801 } else { 4800 } else {
4802 if (inst_cream->cp_num == 15) 4801 if (inst_cream->cp_num == 15)
4803 RD = ReadCP15Register(cpu, CRn, OPCODE_1, CRm, OPCODE_2); 4802 RD = cpu->ReadCP15Register(CRn, OPCODE_1, CRm, OPCODE_2);
4804 } 4803 }
4805 } 4804 }
4806 cpu->Reg[15] += GET_INST_SIZE(cpu); 4805 cpu->Reg[15] += cpu->GetInstructionSize();
4807 INC_PC(sizeof(mrc_inst)); 4806 INC_PC(sizeof(mrc_inst));
4808 FETCH_INST; 4807 FETCH_INST;
4809 GOTO_NEXT_INST; 4808 GOTO_NEXT_INST;
@@ -4820,7 +4819,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4820 inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2); 4819 inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2);
4821 } 4820 }
4822 4821
4823 cpu->Reg[15] += GET_INST_SIZE(cpu); 4822 cpu->Reg[15] += cpu->GetInstructionSize();
4824 INC_PC(sizeof(mcrr_inst)); 4823 INC_PC(sizeof(mcrr_inst));
4825 FETCH_INST; 4824 FETCH_INST;
4826 GOTO_NEXT_INST; 4825 GOTO_NEXT_INST;
@@ -4838,7 +4837,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4838 RD = cpu->Cpsr; 4837 RD = cpu->Cpsr;
4839 } 4838 }
4840 } 4839 }
4841 cpu->Reg[15] += GET_INST_SIZE(cpu); 4840 cpu->Reg[15] += cpu->GetInstructionSize();
4842 INC_PC(sizeof(mrs_inst)); 4841 INC_PC(sizeof(mrs_inst));
4843 FETCH_INST; 4842 FETCH_INST;
4844 GOTO_NEXT_INST; 4843 GOTO_NEXT_INST;
@@ -4861,7 +4860,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4861 | (BIT(inst, 18) ? 0xff0000 : 0) | (BIT(inst, 19) ? 0xff000000 : 0); 4860 | (BIT(inst, 18) ? 0xff0000 : 0) | (BIT(inst, 19) ? 0xff000000 : 0);
4862 uint32_t mask = 0; 4861 uint32_t mask = 0;
4863 if (!inst_cream->R) { 4862 if (!inst_cream->R) {
4864 if (InAPrivilegedMode(cpu)) { 4863 if (cpu->InAPrivilegedMode()) {
4865 if ((operand & StateMask) != 0) { 4864 if ((operand & StateMask) != 0) {
4866 /// UNPREDICTABLE 4865 /// UNPREDICTABLE
4867 DEBUG_MSG; 4866 DEBUG_MSG;
@@ -4873,7 +4872,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4873 SAVE_NZCVT; 4872 SAVE_NZCVT;
4874 4873
4875 cpu->Cpsr = (cpu->Cpsr & ~mask) | (operand & mask); 4874 cpu->Cpsr = (cpu->Cpsr & ~mask) | (operand & mask);
4876 switch_mode(cpu, cpu->Cpsr & 0x1f); 4875 cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F);
4877 LOAD_NZCVT; 4876 LOAD_NZCVT;
4878 } else { 4877 } else {
4879 if (CurrentModeHasSPSR) { 4878 if (CurrentModeHasSPSR) {
@@ -4882,7 +4881,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4882 } 4881 }
4883 } 4882 }
4884 } 4883 }
4885 cpu->Reg[15] += GET_INST_SIZE(cpu); 4884 cpu->Reg[15] += cpu->GetInstructionSize();
4886 INC_PC(sizeof(msr_inst)); 4885 INC_PC(sizeof(msr_inst));
4887 FETCH_INST; 4886 FETCH_INST;
4888 GOTO_NEXT_INST; 4887 GOTO_NEXT_INST;
@@ -4904,7 +4903,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4904 goto DISPATCH; 4903 goto DISPATCH;
4905 } 4904 }
4906 } 4905 }
4907 cpu->Reg[15] += GET_INST_SIZE(cpu); 4906 cpu->Reg[15] += cpu->GetInstructionSize();
4908 INC_PC(sizeof(mul_inst)); 4907 INC_PC(sizeof(mul_inst));
4909 FETCH_INST; 4908 FETCH_INST;
4910 GOTO_NEXT_INST; 4909 GOTO_NEXT_INST;
@@ -4919,7 +4918,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4919 if (inst_cream->S && (inst_cream->Rd == 15)) { 4918 if (inst_cream->S && (inst_cream->Rd == 15)) {
4920 if (CurrentModeHasSPSR) { 4919 if (CurrentModeHasSPSR) {
4921 cpu->Cpsr = cpu->Spsr_copy; 4920 cpu->Cpsr = cpu->Spsr_copy;
4922 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 4921 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
4923 LOAD_NZCVT; 4922 LOAD_NZCVT;
4924 } 4923 }
4925 } else if (inst_cream->S) { 4924 } else if (inst_cream->S) {
@@ -4932,7 +4931,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4932 goto DISPATCH; 4931 goto DISPATCH;
4933 } 4932 }
4934 } 4933 }
4935 cpu->Reg[15] += GET_INST_SIZE(cpu); 4934 cpu->Reg[15] += cpu->GetInstructionSize();
4936 INC_PC(sizeof(mvn_inst)); 4935 INC_PC(sizeof(mvn_inst));
4937 FETCH_INST; 4936 FETCH_INST;
4938 GOTO_NEXT_INST; 4937 GOTO_NEXT_INST;
@@ -4949,7 +4948,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4949 if (inst_cream->S && (inst_cream->Rd == 15)) { 4948 if (inst_cream->S && (inst_cream->Rd == 15)) {
4950 if (CurrentModeHasSPSR) { 4949 if (CurrentModeHasSPSR) {
4951 cpu->Cpsr = cpu->Spsr_copy; 4950 cpu->Cpsr = cpu->Spsr_copy;
4952 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 4951 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
4953 LOAD_NZCVT; 4952 LOAD_NZCVT;
4954 } 4953 }
4955 } else if (inst_cream->S) { 4954 } else if (inst_cream->S) {
@@ -4962,7 +4961,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4962 goto DISPATCH; 4961 goto DISPATCH;
4963 } 4962 }
4964 } 4963 }
4965 cpu->Reg[15] += GET_INST_SIZE(cpu); 4964 cpu->Reg[15] += cpu->GetInstructionSize();
4966 INC_PC(sizeof(orr_inst)); 4965 INC_PC(sizeof(orr_inst));
4967 FETCH_INST; 4966 FETCH_INST;
4968 GOTO_NEXT_INST; 4967 GOTO_NEXT_INST;
@@ -4970,7 +4969,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4970 4969
4971 NOP_INST: 4970 NOP_INST:
4972 { 4971 {
4973 cpu->Reg[15] += GET_INST_SIZE(cpu); 4972 cpu->Reg[15] += cpu->GetInstructionSize();
4974 INC_PC_STUB; 4973 INC_PC_STUB;
4975 FETCH_INST; 4974 FETCH_INST;
4976 GOTO_NEXT_INST; 4975 GOTO_NEXT_INST;
@@ -4982,7 +4981,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4982 pkh_inst *inst_cream = (pkh_inst *)inst_base->component; 4981 pkh_inst *inst_cream = (pkh_inst *)inst_base->component;
4983 RD = (RN & 0xFFFF) | ((RM << inst_cream->imm) & 0xFFFF0000); 4982 RD = (RN & 0xFFFF) | ((RM << inst_cream->imm) & 0xFFFF0000);
4984 } 4983 }
4985 cpu->Reg[15] += GET_INST_SIZE(cpu); 4984 cpu->Reg[15] += cpu->GetInstructionSize();
4986 INC_PC(sizeof(pkh_inst)); 4985 INC_PC(sizeof(pkh_inst));
4987 FETCH_INST; 4986 FETCH_INST;
4988 GOTO_NEXT_INST; 4987 GOTO_NEXT_INST;
@@ -4995,7 +4994,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
4995 int shift_imm = inst_cream->imm ? inst_cream->imm : 31; 4994 int shift_imm = inst_cream->imm ? inst_cream->imm : 31;
4996 RD = ((static_cast<s32>(RM) >> shift_imm) & 0xFFFF) | (RN & 0xFFFF0000); 4995 RD = ((static_cast<s32>(RM) >> shift_imm) & 0xFFFF) | (RN & 0xFFFF0000);
4997 } 4996 }
4998 cpu->Reg[15] += GET_INST_SIZE(cpu); 4997 cpu->Reg[15] += cpu->GetInstructionSize();
4999 INC_PC(sizeof(pkh_inst)); 4998 INC_PC(sizeof(pkh_inst));
5000 FETCH_INST; 4999 FETCH_INST;
5001 GOTO_NEXT_INST; 5000 GOTO_NEXT_INST;
@@ -5005,7 +5004,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5005 { 5004 {
5006 // Not implemented. PLD is a hint instruction, so it's optional. 5005 // Not implemented. PLD is a hint instruction, so it's optional.
5007 5006
5008 cpu->Reg[15] += GET_INST_SIZE(cpu); 5007 cpu->Reg[15] += cpu->GetInstructionSize();
5009 INC_PC(sizeof(pld_inst)); 5008 INC_PC(sizeof(pld_inst));
5010 FETCH_INST; 5009 FETCH_INST;
5011 GOTO_NEXT_INST; 5010 GOTO_NEXT_INST;
@@ -5078,7 +5077,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5078 RD = result; 5077 RD = result;
5079 } 5078 }
5080 5079
5081 cpu->Reg[15] += GET_INST_SIZE(cpu); 5080 cpu->Reg[15] += cpu->GetInstructionSize();
5082 INC_PC(sizeof(generic_arm_inst)); 5081 INC_PC(sizeof(generic_arm_inst));
5083 FETCH_INST; 5082 FETCH_INST;
5084 GOTO_NEXT_INST; 5083 GOTO_NEXT_INST;
@@ -5140,7 +5139,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5140 RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16); 5139 RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16);
5141 } 5140 }
5142 5141
5143 cpu->Reg[15] += GET_INST_SIZE(cpu); 5142 cpu->Reg[15] += cpu->GetInstructionSize();
5144 INC_PC(sizeof(generic_arm_inst)); 5143 INC_PC(sizeof(generic_arm_inst));
5145 FETCH_INST; 5144 FETCH_INST;
5146 GOTO_NEXT_INST; 5145 GOTO_NEXT_INST;
@@ -5173,7 +5172,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5173 } 5172 }
5174 } 5173 }
5175 5174
5176 cpu->Reg[15] += GET_INST_SIZE(cpu); 5175 cpu->Reg[15] += cpu->GetInstructionSize();
5177 INC_PC(sizeof(rev_inst)); 5176 INC_PC(sizeof(rev_inst));
5178 FETCH_INST; 5177 FETCH_INST;
5179 GOTO_NEXT_INST; 5178 GOTO_NEXT_INST;
@@ -5187,8 +5186,8 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5187 u32 address = 0; 5186 u32 address = 0;
5188 inst_cream->get_addr(cpu, inst_cream->inst, address); 5187 inst_cream->get_addr(cpu, inst_cream->inst, address);
5189 5188
5190 cpu->Cpsr = ReadMemory32(cpu, address); 5189 cpu->Cpsr = cpu->ReadMemory32(address);
5191 cpu->Reg[15] = ReadMemory32(cpu, address + 4); 5190 cpu->Reg[15] = cpu->ReadMemory32(address + 4);
5192 5191
5193 INC_PC(sizeof(ldst_inst)); 5192 INC_PC(sizeof(ldst_inst));
5194 goto DISPATCH; 5193 goto DISPATCH;
@@ -5201,7 +5200,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5201 5200
5202 u32 rn_val = RN; 5201 u32 rn_val = RN;
5203 if (inst_cream->Rn == 15) 5202 if (inst_cream->Rn == 15)
5204 rn_val += 2 * GET_INST_SIZE(cpu); 5203 rn_val += 2 * cpu->GetInstructionSize();
5205 5204
5206 bool carry; 5205 bool carry;
5207 bool overflow; 5206 bool overflow;
@@ -5210,7 +5209,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5210 if (inst_cream->S && (inst_cream->Rd == 15)) { 5209 if (inst_cream->S && (inst_cream->Rd == 15)) {
5211 if (CurrentModeHasSPSR) { 5210 if (CurrentModeHasSPSR) {
5212 cpu->Cpsr = cpu->Spsr_copy; 5211 cpu->Cpsr = cpu->Spsr_copy;
5213 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 5212 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
5214 LOAD_NZCVT; 5213 LOAD_NZCVT;
5215 } 5214 }
5216 } else if (inst_cream->S) { 5215 } else if (inst_cream->S) {
@@ -5224,7 +5223,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5224 goto DISPATCH; 5223 goto DISPATCH;
5225 } 5224 }
5226 } 5225 }
5227 cpu->Reg[15] += GET_INST_SIZE(cpu); 5226 cpu->Reg[15] += cpu->GetInstructionSize();
5228 INC_PC(sizeof(rsb_inst)); 5227 INC_PC(sizeof(rsb_inst));
5229 FETCH_INST; 5228 FETCH_INST;
5230 GOTO_NEXT_INST; 5229 GOTO_NEXT_INST;
@@ -5241,7 +5240,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5241 if (inst_cream->S && (inst_cream->Rd == 15)) { 5240 if (inst_cream->S && (inst_cream->Rd == 15)) {
5242 if (CurrentModeHasSPSR) { 5241 if (CurrentModeHasSPSR) {
5243 cpu->Cpsr = cpu->Spsr_copy; 5242 cpu->Cpsr = cpu->Spsr_copy;
5244 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 5243 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
5245 LOAD_NZCVT; 5244 LOAD_NZCVT;
5246 } 5245 }
5247 } else if (inst_cream->S) { 5246 } else if (inst_cream->S) {
@@ -5255,7 +5254,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5255 goto DISPATCH; 5254 goto DISPATCH;
5256 } 5255 }
5257 } 5256 }
5258 cpu->Reg[15] += GET_INST_SIZE(cpu); 5257 cpu->Reg[15] += cpu->GetInstructionSize();
5259 INC_PC(sizeof(rsc_inst)); 5258 INC_PC(sizeof(rsc_inst));
5260 FETCH_INST; 5259 FETCH_INST;
5261 GOTO_NEXT_INST; 5260 GOTO_NEXT_INST;
@@ -5363,7 +5362,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5363 } 5362 }
5364 } 5363 }
5365 5364
5366 cpu->Reg[15] += GET_INST_SIZE(cpu); 5365 cpu->Reg[15] += cpu->GetInstructionSize();
5367 INC_PC(sizeof(generic_arm_inst)); 5366 INC_PC(sizeof(generic_arm_inst));
5368 FETCH_INST; 5367 FETCH_INST;
5369 GOTO_NEXT_INST; 5368 GOTO_NEXT_INST;
@@ -5381,7 +5380,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5381 if (inst_cream->S && (inst_cream->Rd == 15)) { 5380 if (inst_cream->S && (inst_cream->Rd == 15)) {
5382 if (CurrentModeHasSPSR) { 5381 if (CurrentModeHasSPSR) {
5383 cpu->Cpsr = cpu->Spsr_copy; 5382 cpu->Cpsr = cpu->Spsr_copy;
5384 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 5383 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
5385 LOAD_NZCVT; 5384 LOAD_NZCVT;
5386 } 5385 }
5387 } else if (inst_cream->S) { 5386 } else if (inst_cream->S) {
@@ -5395,7 +5394,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5395 goto DISPATCH; 5394 goto DISPATCH;
5396 } 5395 }
5397 } 5396 }
5398 cpu->Reg[15] += GET_INST_SIZE(cpu); 5397 cpu->Reg[15] += cpu->GetInstructionSize();
5399 INC_PC(sizeof(sbc_inst)); 5398 INC_PC(sizeof(sbc_inst));
5400 FETCH_INST; 5399 FETCH_INST;
5401 GOTO_NEXT_INST; 5400 GOTO_NEXT_INST;
@@ -5434,7 +5433,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5434 RD = result; 5433 RD = result;
5435 } 5434 }
5436 5435
5437 cpu->Reg[15] += GET_INST_SIZE(cpu); 5436 cpu->Reg[15] += cpu->GetInstructionSize();
5438 INC_PC(sizeof(generic_arm_inst)); 5437 INC_PC(sizeof(generic_arm_inst));
5439 FETCH_INST; 5438 FETCH_INST;
5440 GOTO_NEXT_INST; 5439 GOTO_NEXT_INST;
@@ -5453,7 +5452,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5453 5452
5454 LOG_WARNING(Core_ARM11, "SETEND %s executed", big_endian ? "BE" : "LE"); 5453 LOG_WARNING(Core_ARM11, "SETEND %s executed", big_endian ? "BE" : "LE");
5455 5454
5456 cpu->Reg[15] += GET_INST_SIZE(cpu); 5455 cpu->Reg[15] += cpu->GetInstructionSize();
5457 INC_PC(sizeof(setend_inst)); 5456 INC_PC(sizeof(setend_inst));
5458 FETCH_INST; 5457 FETCH_INST;
5459 GOTO_NEXT_INST; 5458 GOTO_NEXT_INST;
@@ -5466,7 +5465,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5466 LOG_TRACE(Core_ARM11, "SEV executed."); 5465 LOG_TRACE(Core_ARM11, "SEV executed.");
5467 } 5466 }
5468 5467
5469 cpu->Reg[15] += GET_INST_SIZE(cpu); 5468 cpu->Reg[15] += cpu->GetInstructionSize();
5470 INC_PC_STUB; 5469 INC_PC_STUB;
5471 FETCH_INST; 5470 FETCH_INST;
5472 GOTO_NEXT_INST; 5471 GOTO_NEXT_INST;
@@ -5538,7 +5537,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5538 } 5537 }
5539 } 5538 }
5540 5539
5541 cpu->Reg[15] += GET_INST_SIZE(cpu); 5540 cpu->Reg[15] += cpu->GetInstructionSize();
5542 INC_PC(sizeof(generic_arm_inst)); 5541 INC_PC(sizeof(generic_arm_inst));
5543 FETCH_INST; 5542 FETCH_INST;
5544 GOTO_NEXT_INST; 5543 GOTO_NEXT_INST;
@@ -5563,7 +5562,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5563 if (AddOverflow(operand1 * operand2, RN, RD)) 5562 if (AddOverflow(operand1 * operand2, RN, RD))
5564 cpu->Cpsr |= (1 << 27); 5563 cpu->Cpsr |= (1 << 27);
5565 } 5564 }
5566 cpu->Reg[15] += GET_INST_SIZE(cpu); 5565 cpu->Reg[15] += cpu->GetInstructionSize();
5567 INC_PC(sizeof(smla_inst)); 5566 INC_PC(sizeof(smla_inst));
5568 FETCH_INST; 5567 FETCH_INST;
5569 GOTO_NEXT_INST; 5568 GOTO_NEXT_INST;
@@ -5619,7 +5618,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5619 } 5618 }
5620 } 5619 }
5621 5620
5622 cpu->Reg[15] += GET_INST_SIZE(cpu); 5621 cpu->Reg[15] += cpu->GetInstructionSize();
5623 INC_PC(sizeof(smlad_inst)); 5622 INC_PC(sizeof(smlad_inst));
5624 FETCH_INST; 5623 FETCH_INST;
5625 GOTO_NEXT_INST; 5624 GOTO_NEXT_INST;
@@ -5648,7 +5647,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5648 cpu->ZFlag = (RDHI == 0 && RDLO == 0); 5647 cpu->ZFlag = (RDHI == 0 && RDLO == 0);
5649 } 5648 }
5650 } 5649 }
5651 cpu->Reg[15] += GET_INST_SIZE(cpu); 5650 cpu->Reg[15] += cpu->GetInstructionSize();
5652 INC_PC(sizeof(umlal_inst)); 5651 INC_PC(sizeof(umlal_inst));
5653 FETCH_INST; 5652 FETCH_INST;
5654 GOTO_NEXT_INST; 5653 GOTO_NEXT_INST;
@@ -5678,7 +5677,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5678 RDHI = ((dest >> 32) & 0xFFFFFFFF); 5677 RDHI = ((dest >> 32) & 0xFFFFFFFF);
5679 } 5678 }
5680 5679
5681 cpu->Reg[15] += GET_INST_SIZE(cpu); 5680 cpu->Reg[15] += cpu->GetInstructionSize();
5682 INC_PC(sizeof(smlalxy_inst)); 5681 INC_PC(sizeof(smlalxy_inst));
5683 FETCH_INST; 5682 FETCH_INST;
5684 GOTO_NEXT_INST; 5683 GOTO_NEXT_INST;
@@ -5703,7 +5702,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5703 cpu->Cpsr |= (1 << 27); 5702 cpu->Cpsr |= (1 << 27);
5704 } 5703 }
5705 5704
5706 cpu->Reg[15] += GET_INST_SIZE(cpu); 5705 cpu->Reg[15] += cpu->GetInstructionSize();
5707 INC_PC(sizeof(smlad_inst)); 5706 INC_PC(sizeof(smlad_inst));
5708 FETCH_INST; 5707 FETCH_INST;
5709 GOTO_NEXT_INST; 5708 GOTO_NEXT_INST;
@@ -5741,7 +5740,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5741 RDHI = ((result >> 32) & 0xFFFFFFFF); 5740 RDHI = ((result >> 32) & 0xFFFFFFFF);
5742 } 5741 }
5743 5742
5744 cpu->Reg[15] += GET_INST_SIZE(cpu); 5743 cpu->Reg[15] += cpu->GetInstructionSize();
5745 INC_PC(sizeof(smlald_inst)); 5744 INC_PC(sizeof(smlald_inst));
5746 FETCH_INST; 5745 FETCH_INST;
5747 GOTO_NEXT_INST; 5746 GOTO_NEXT_INST;
@@ -5777,7 +5776,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5777 RD = ((result >> 32) & 0xFFFFFFFF); 5776 RD = ((result >> 32) & 0xFFFFFFFF);
5778 } 5777 }
5779 5778
5780 cpu->Reg[15] += GET_INST_SIZE(cpu); 5779 cpu->Reg[15] += cpu->GetInstructionSize();
5781 INC_PC(sizeof(smlad_inst)); 5780 INC_PC(sizeof(smlad_inst));
5782 FETCH_INST; 5781 FETCH_INST;
5783 GOTO_NEXT_INST; 5782 GOTO_NEXT_INST;
@@ -5799,7 +5798,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5799 operand2 = (BIT(RS, 31)) ? (BITS(RS, 16, 31) | 0xffff0000) : BITS(RS, 16, 31); 5798 operand2 = (BIT(RS, 31)) ? (BITS(RS, 16, 31) | 0xffff0000) : BITS(RS, 16, 31);
5800 RD = operand1 * operand2; 5799 RD = operand1 * operand2;
5801 } 5800 }
5802 cpu->Reg[15] += GET_INST_SIZE(cpu); 5801 cpu->Reg[15] += cpu->GetInstructionSize();
5803 INC_PC(sizeof(smul_inst)); 5802 INC_PC(sizeof(smul_inst));
5804 FETCH_INST; 5803 FETCH_INST;
5805 GOTO_NEXT_INST; 5804 GOTO_NEXT_INST;
@@ -5825,7 +5824,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5825 cpu->ZFlag = (RDHI == 0 && RDLO == 0); 5824 cpu->ZFlag = (RDHI == 0 && RDLO == 0);
5826 } 5825 }
5827 } 5826 }
5828 cpu->Reg[15] += GET_INST_SIZE(cpu); 5827 cpu->Reg[15] += cpu->GetInstructionSize();
5829 INC_PC(sizeof(umull_inst)); 5828 INC_PC(sizeof(umull_inst));
5830 FETCH_INST; 5829 FETCH_INST;
5831 GOTO_NEXT_INST; 5830 GOTO_NEXT_INST;
@@ -5841,7 +5840,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5841 s64 result = (s64)rm * (s64)(s32)RN; 5840 s64 result = (s64)rm * (s64)(s32)RN;
5842 RD = BITS(result, 16, 47); 5841 RD = BITS(result, 16, 47);
5843 } 5842 }
5844 cpu->Reg[15] += GET_INST_SIZE(cpu); 5843 cpu->Reg[15] += cpu->GetInstructionSize();
5845 INC_PC(sizeof(smlad_inst)); 5844 INC_PC(sizeof(smlad_inst));
5846 FETCH_INST; 5845 FETCH_INST;
5847 GOTO_NEXT_INST; 5846 GOTO_NEXT_INST;
@@ -5855,10 +5854,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5855 u32 address = 0; 5854 u32 address = 0;
5856 inst_cream->get_addr(cpu, inst_cream->inst, address); 5855 inst_cream->get_addr(cpu, inst_cream->inst, address);
5857 5856
5858 WriteMemory32(cpu, address + 0, cpu->Reg[14]); 5857 cpu->WriteMemory32(address + 0, cpu->Reg[14]);
5859 WriteMemory32(cpu, address + 4, cpu->Spsr_copy); 5858 cpu->WriteMemory32(address + 4, cpu->Spsr_copy);
5860 5859
5861 cpu->Reg[15] += GET_INST_SIZE(cpu); 5860 cpu->Reg[15] += cpu->GetInstructionSize();
5862 INC_PC(sizeof(ldst_inst)); 5861 INC_PC(sizeof(ldst_inst));
5863 FETCH_INST; 5862 FETCH_INST;
5864 GOTO_NEXT_INST; 5863 GOTO_NEXT_INST;
@@ -5891,7 +5890,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5891 RD = rn_val; 5890 RD = rn_val;
5892 } 5891 }
5893 5892
5894 cpu->Reg[15] += GET_INST_SIZE(cpu); 5893 cpu->Reg[15] += cpu->GetInstructionSize();
5895 INC_PC(sizeof(ssat_inst)); 5894 INC_PC(sizeof(ssat_inst));
5896 FETCH_INST; 5895 FETCH_INST;
5897 GOTO_NEXT_INST; 5896 GOTO_NEXT_INST;
@@ -5913,7 +5912,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5913 cpu->Cpsr |= (1 << 27); 5912 cpu->Cpsr |= (1 << 27);
5914 } 5913 }
5915 5914
5916 cpu->Reg[15] += GET_INST_SIZE(cpu); 5915 cpu->Reg[15] += cpu->GetInstructionSize();
5917 INC_PC(sizeof(ssat_inst)); 5916 INC_PC(sizeof(ssat_inst));
5918 FETCH_INST; 5917 FETCH_INST;
5919 GOTO_NEXT_INST; 5918 GOTO_NEXT_INST;
@@ -5923,7 +5922,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5923 { 5922 {
5924 // Instruction not implemented 5923 // Instruction not implemented
5925 //LOG_CRITICAL(Core_ARM11, "unimplemented instruction"); 5924 //LOG_CRITICAL(Core_ARM11, "unimplemented instruction");
5926 cpu->Reg[15] += GET_INST_SIZE(cpu); 5925 cpu->Reg[15] += cpu->GetInstructionSize();
5927 INC_PC(sizeof(stc_inst)); 5926 INC_PC(sizeof(stc_inst));
5928 FETCH_INST; 5927 FETCH_INST;
5929 GOTO_NEXT_INST; 5928 GOTO_NEXT_INST;
@@ -5941,36 +5940,36 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5941 if (BIT(inst_cream->inst, 22) == 1) { 5940 if (BIT(inst_cream->inst, 22) == 1) {
5942 for (int i = 0; i < 13; i++) { 5941 for (int i = 0; i < 13; i++) {
5943 if (BIT(inst_cream->inst, i)) { 5942 if (BIT(inst_cream->inst, i)) {
5944 WriteMemory32(cpu, addr, cpu->Reg[i]); 5943 cpu->WriteMemory32(addr, cpu->Reg[i]);
5945 addr += 4; 5944 addr += 4;
5946 } 5945 }
5947 } 5946 }
5948 if (BIT(inst_cream->inst, 13)) { 5947 if (BIT(inst_cream->inst, 13)) {
5949 if (cpu->Mode == USER32MODE) 5948 if (cpu->Mode == USER32MODE)
5950 WriteMemory32(cpu, addr, cpu->Reg[13]); 5949 cpu->WriteMemory32(addr, cpu->Reg[13]);
5951 else 5950 else
5952 WriteMemory32(cpu, addr, cpu->Reg_usr[0]); 5951 cpu->WriteMemory32(addr, cpu->Reg_usr[0]);
5953 5952
5954 addr += 4; 5953 addr += 4;
5955 } 5954 }
5956 if (BIT(inst_cream->inst, 14)) { 5955 if (BIT(inst_cream->inst, 14)) {
5957 if (cpu->Mode == USER32MODE) 5956 if (cpu->Mode == USER32MODE)
5958 WriteMemory32(cpu, addr, cpu->Reg[14]); 5957 cpu->WriteMemory32(addr, cpu->Reg[14]);
5959 else 5958 else
5960 WriteMemory32(cpu, addr, cpu->Reg_usr[1]); 5959 cpu->WriteMemory32(addr, cpu->Reg_usr[1]);
5961 5960
5962 addr += 4; 5961 addr += 4;
5963 } 5962 }
5964 if (BIT(inst_cream->inst, 15)) { 5963 if (BIT(inst_cream->inst, 15)) {
5965 WriteMemory32(cpu, addr, cpu->Reg_usr[1] + 8); 5964 cpu->WriteMemory32(addr, cpu->Reg_usr[1] + 8);
5966 } 5965 }
5967 } else { 5966 } else {
5968 for (int i = 0; i < 15; i++) { 5967 for (int i = 0; i < 15; i++) {
5969 if (BIT(inst_cream->inst, i)) { 5968 if (BIT(inst_cream->inst, i)) {
5970 if (i == Rn) 5969 if (i == Rn)
5971 WriteMemory32(cpu, addr, old_RN); 5970 cpu->WriteMemory32(addr, old_RN);
5972 else 5971 else
5973 WriteMemory32(cpu, addr, cpu->Reg[i]); 5972 cpu->WriteMemory32(addr, cpu->Reg[i]);
5974 5973
5975 addr += 4; 5974 addr += 4;
5976 } 5975 }
@@ -5978,10 +5977,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5978 5977
5979 // Check PC reg 5978 // Check PC reg
5980 if (BIT(inst_cream->inst, 15)) 5979 if (BIT(inst_cream->inst, 15))
5981 WriteMemory32(cpu, addr, cpu->Reg_usr[1] + 8); 5980 cpu->WriteMemory32(addr, cpu->Reg_usr[1] + 8);
5982 } 5981 }
5983 } 5982 }
5984 cpu->Reg[15] += GET_INST_SIZE(cpu); 5983 cpu->Reg[15] += cpu->GetInstructionSize();
5985 INC_PC(sizeof(ldst_inst)); 5984 INC_PC(sizeof(ldst_inst));
5986 FETCH_INST; 5985 FETCH_INST;
5987 GOTO_NEXT_INST; 5986 GOTO_NEXT_INST;
@@ -5999,7 +5998,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
5999 } 5998 }
6000 RD = operand2; 5999 RD = operand2;
6001 } 6000 }
6002 cpu->Reg[15] += GET_INST_SIZE(cpu); 6001 cpu->Reg[15] += cpu->GetInstructionSize();
6003 INC_PC(sizeof(sxtb_inst)); 6002 INC_PC(sizeof(sxtb_inst));
6004 FETCH_INST; 6003 FETCH_INST;
6005 GOTO_NEXT_INST; 6004 GOTO_NEXT_INST;
@@ -6011,9 +6010,9 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6011 inst_cream->get_addr(cpu, inst_cream->inst, addr); 6010 inst_cream->get_addr(cpu, inst_cream->inst, addr);
6012 6011
6013 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)]; 6012 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)];
6014 WriteMemory32(cpu, addr, value); 6013 cpu->WriteMemory32(addr, value);
6015 } 6014 }
6016 cpu->Reg[15] += GET_INST_SIZE(cpu); 6015 cpu->Reg[15] += cpu->GetInstructionSize();
6017 INC_PC(sizeof(ldst_inst)); 6016 INC_PC(sizeof(ldst_inst));
6018 FETCH_INST; 6017 FETCH_INST;
6019 GOTO_NEXT_INST; 6018 GOTO_NEXT_INST;
@@ -6024,7 +6023,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6024 uxtb_inst* inst_cream = (uxtb_inst*)inst_base->component; 6023 uxtb_inst* inst_cream = (uxtb_inst*)inst_base->component;
6025 RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff; 6024 RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff;
6026 } 6025 }
6027 cpu->Reg[15] += GET_INST_SIZE(cpu); 6026 cpu->Reg[15] += cpu->GetInstructionSize();
6028 INC_PC(sizeof(uxtb_inst)); 6027 INC_PC(sizeof(uxtb_inst));
6029 FETCH_INST; 6028 FETCH_INST;
6030 GOTO_NEXT_INST; 6029 GOTO_NEXT_INST;
@@ -6037,7 +6036,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6037 unsigned int operand2 = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff; 6036 unsigned int operand2 = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff;
6038 RD = RN + operand2; 6037 RD = RN + operand2;
6039 } 6038 }
6040 cpu->Reg[15] += GET_INST_SIZE(cpu); 6039 cpu->Reg[15] += cpu->GetInstructionSize();
6041 INC_PC(sizeof(uxtab_inst)); 6040 INC_PC(sizeof(uxtab_inst));
6042 FETCH_INST; 6041 FETCH_INST;
6043 GOTO_NEXT_INST; 6042 GOTO_NEXT_INST;
@@ -6050,7 +6049,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6050 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff; 6049 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff;
6051 Memory::Write8(addr, value); 6050 Memory::Write8(addr, value);
6052 } 6051 }
6053 cpu->Reg[15] += GET_INST_SIZE(cpu); 6052 cpu->Reg[15] += cpu->GetInstructionSize();
6054 INC_PC(sizeof(ldst_inst)); 6053 INC_PC(sizeof(ldst_inst));
6055 FETCH_INST; 6054 FETCH_INST;
6056 GOTO_NEXT_INST; 6055 GOTO_NEXT_INST;
@@ -6063,7 +6062,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6063 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff; 6062 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff;
6064 Memory::Write8(addr, value); 6063 Memory::Write8(addr, value);
6065 } 6064 }
6066 cpu->Reg[15] += GET_INST_SIZE(cpu); 6065 cpu->Reg[15] += cpu->GetInstructionSize();
6067 INC_PC(sizeof(ldst_inst)); 6066 INC_PC(sizeof(ldst_inst));
6068 FETCH_INST; 6067 FETCH_INST;
6069 GOTO_NEXT_INST; 6068 GOTO_NEXT_INST;
@@ -6076,10 +6075,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6076 6075
6077 // The 3DS doesn't have the Large Physical Access Extension (LPAE) 6076 // The 3DS doesn't have the Large Physical Access Extension (LPAE)
6078 // so STRD wouldn't store these as a single write. 6077 // so STRD wouldn't store these as a single write.
6079 WriteMemory32(cpu, addr + 0, cpu->Reg[BITS(inst_cream->inst, 12, 15)]); 6078 cpu->WriteMemory32(addr + 0, cpu->Reg[BITS(inst_cream->inst, 12, 15)]);
6080 WriteMemory32(cpu, addr + 4, cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1]); 6079 cpu->WriteMemory32(addr + 4, cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1]);
6081 } 6080 }
6082 cpu->Reg[15] += GET_INST_SIZE(cpu); 6081 cpu->Reg[15] += cpu->GetInstructionSize();
6083 INC_PC(sizeof(ldst_inst)); 6082 INC_PC(sizeof(ldst_inst));
6084 FETCH_INST; 6083 FETCH_INST;
6085 GOTO_NEXT_INST; 6084 GOTO_NEXT_INST;
@@ -6094,14 +6093,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6094 remove_exclusive(cpu, write_addr); 6093 remove_exclusive(cpu, write_addr);
6095 cpu->exclusive_state = 0; 6094 cpu->exclusive_state = 0;
6096 6095
6097 WriteMemory32(cpu, write_addr, RM); 6096 cpu->WriteMemory32(write_addr, RM);
6098 RD = 0; 6097 RD = 0;
6099 } else { 6098 } else {
6100 // Failed to write due to mutex access 6099 // Failed to write due to mutex access
6101 RD = 1; 6100 RD = 1;
6102 } 6101 }
6103 } 6102 }
6104 cpu->Reg[15] += GET_INST_SIZE(cpu); 6103 cpu->Reg[15] += cpu->GetInstructionSize();
6105 INC_PC(sizeof(generic_arm_inst)); 6104 INC_PC(sizeof(generic_arm_inst));
6106 FETCH_INST; 6105 FETCH_INST;
6107 GOTO_NEXT_INST; 6106 GOTO_NEXT_INST;
@@ -6123,7 +6122,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6123 RD = 1; 6122 RD = 1;
6124 } 6123 }
6125 } 6124 }
6126 cpu->Reg[15] += GET_INST_SIZE(cpu); 6125 cpu->Reg[15] += cpu->GetInstructionSize();
6127 INC_PC(sizeof(generic_arm_inst)); 6126 INC_PC(sizeof(generic_arm_inst));
6128 FETCH_INST; 6127 FETCH_INST;
6129 GOTO_NEXT_INST; 6128 GOTO_NEXT_INST;
@@ -6142,12 +6141,12 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6142 const u32 rt2 = cpu->Reg[inst_cream->Rm + 1]; 6141 const u32 rt2 = cpu->Reg[inst_cream->Rm + 1];
6143 u64 value; 6142 u64 value;
6144 6143
6145 if (InBigEndianMode(cpu)) 6144 if (cpu->InBigEndianMode())
6146 value = (((u64)rt << 32) | rt2); 6145 value = (((u64)rt << 32) | rt2);
6147 else 6146 else
6148 value = (((u64)rt2 << 32) | rt); 6147 value = (((u64)rt2 << 32) | rt);
6149 6148
6150 WriteMemory64(cpu, write_addr, value); 6149 cpu->WriteMemory64(write_addr, value);
6151 RD = 0; 6150 RD = 0;
6152 } 6151 }
6153 else { 6152 else {
@@ -6155,7 +6154,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6155 RD = 1; 6154 RD = 1;
6156 } 6155 }
6157 } 6156 }
6158 cpu->Reg[15] += GET_INST_SIZE(cpu); 6157 cpu->Reg[15] += cpu->GetInstructionSize();
6159 INC_PC(sizeof(generic_arm_inst)); 6158 INC_PC(sizeof(generic_arm_inst));
6160 FETCH_INST; 6159 FETCH_INST;
6161 GOTO_NEXT_INST; 6160 GOTO_NEXT_INST;
@@ -6170,14 +6169,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6170 remove_exclusive(cpu, write_addr); 6169 remove_exclusive(cpu, write_addr);
6171 cpu->exclusive_state = 0; 6170 cpu->exclusive_state = 0;
6172 6171
6173 WriteMemory16(cpu, write_addr, RM); 6172 cpu->WriteMemory16(write_addr, RM);
6174 RD = 0; 6173 RD = 0;
6175 } else { 6174 } else {
6176 // Failed to write due to mutex access 6175 // Failed to write due to mutex access
6177 RD = 1; 6176 RD = 1;
6178 } 6177 }
6179 } 6178 }
6180 cpu->Reg[15] += GET_INST_SIZE(cpu); 6179 cpu->Reg[15] += cpu->GetInstructionSize();
6181 INC_PC(sizeof(generic_arm_inst)); 6180 INC_PC(sizeof(generic_arm_inst));
6182 FETCH_INST; 6181 FETCH_INST;
6183 GOTO_NEXT_INST; 6182 GOTO_NEXT_INST;
@@ -6189,9 +6188,9 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6189 inst_cream->get_addr(cpu, inst_cream->inst, addr); 6188 inst_cream->get_addr(cpu, inst_cream->inst, addr);
6190 6189
6191 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xffff; 6190 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xffff;
6192 WriteMemory16(cpu, addr, value); 6191 cpu->WriteMemory16(addr, value);
6193 } 6192 }
6194 cpu->Reg[15] += GET_INST_SIZE(cpu); 6193 cpu->Reg[15] += cpu->GetInstructionSize();
6195 INC_PC(sizeof(ldst_inst)); 6194 INC_PC(sizeof(ldst_inst));
6196 FETCH_INST; 6195 FETCH_INST;
6197 GOTO_NEXT_INST; 6196 GOTO_NEXT_INST;
@@ -6203,9 +6202,9 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6203 inst_cream->get_addr(cpu, inst_cream->inst, addr); 6202 inst_cream->get_addr(cpu, inst_cream->inst, addr);
6204 6203
6205 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)]; 6204 unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)];
6206 WriteMemory32(cpu, addr, value); 6205 cpu->WriteMemory32(addr, value);
6207 } 6206 }
6208 cpu->Reg[15] += GET_INST_SIZE(cpu); 6207 cpu->Reg[15] += cpu->GetInstructionSize();
6209 INC_PC(sizeof(ldst_inst)); 6208 INC_PC(sizeof(ldst_inst));
6210 FETCH_INST; 6209 FETCH_INST;
6211 GOTO_NEXT_INST; 6210 GOTO_NEXT_INST;
@@ -6226,7 +6225,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6226 if (inst_cream->S && (inst_cream->Rd == 15)) { 6225 if (inst_cream->S && (inst_cream->Rd == 15)) {
6227 if (CurrentModeHasSPSR) { 6226 if (CurrentModeHasSPSR) {
6228 cpu->Cpsr = cpu->Spsr_copy; 6227 cpu->Cpsr = cpu->Spsr_copy;
6229 switch_mode(cpu, cpu->Spsr_copy & 0x1f); 6228 cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F);
6230 LOAD_NZCVT; 6229 LOAD_NZCVT;
6231 } 6230 }
6232 } else if (inst_cream->S) { 6231 } else if (inst_cream->S) {
@@ -6240,7 +6239,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6240 goto DISPATCH; 6239 goto DISPATCH;
6241 } 6240 }
6242 } 6241 }
6243 cpu->Reg[15] += GET_INST_SIZE(cpu); 6242 cpu->Reg[15] += cpu->GetInstructionSize();
6244 INC_PC(sizeof(sub_inst)); 6243 INC_PC(sizeof(sub_inst));
6245 FETCH_INST; 6244 FETCH_INST;
6246 GOTO_NEXT_INST; 6245 GOTO_NEXT_INST;
@@ -6252,7 +6251,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6252 SVC::CallSVC(inst_cream->num & 0xFFFF); 6251 SVC::CallSVC(inst_cream->num & 0xFFFF);
6253 } 6252 }
6254 6253
6255 cpu->Reg[15] += GET_INST_SIZE(cpu); 6254 cpu->Reg[15] += cpu->GetInstructionSize();
6256 INC_PC(sizeof(swi_inst)); 6255 INC_PC(sizeof(swi_inst));
6257 FETCH_INST; 6256 FETCH_INST;
6258 GOTO_NEXT_INST; 6257 GOTO_NEXT_INST;
@@ -6263,12 +6262,12 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6263 swp_inst* inst_cream = (swp_inst*)inst_base->component; 6262 swp_inst* inst_cream = (swp_inst*)inst_base->component;
6264 6263
6265 addr = RN; 6264 addr = RN;
6266 unsigned int value = ReadMemory32(cpu, addr); 6265 unsigned int value = cpu->ReadMemory32(addr);
6267 WriteMemory32(cpu, addr, RM); 6266 cpu->WriteMemory32(addr, RM);
6268 6267
6269 RD = value; 6268 RD = value;
6270 } 6269 }
6271 cpu->Reg[15] += GET_INST_SIZE(cpu); 6270 cpu->Reg[15] += cpu->GetInstructionSize();
6272 INC_PC(sizeof(swp_inst)); 6271 INC_PC(sizeof(swp_inst));
6273 FETCH_INST; 6272 FETCH_INST;
6274 GOTO_NEXT_INST; 6273 GOTO_NEXT_INST;
@@ -6282,7 +6281,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6282 Memory::Write8(addr, (RM & 0xFF)); 6281 Memory::Write8(addr, (RM & 0xFF));
6283 RD = value; 6282 RD = value;
6284 } 6283 }
6285 cpu->Reg[15] += GET_INST_SIZE(cpu); 6284 cpu->Reg[15] += cpu->GetInstructionSize();
6286 INC_PC(sizeof(swp_inst)); 6285 INC_PC(sizeof(swp_inst));
6287 FETCH_INST; 6286 FETCH_INST;
6288 GOTO_NEXT_INST; 6287 GOTO_NEXT_INST;
@@ -6298,7 +6297,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6298 operand2 = (0x80 & operand2)? (0xFFFFFF00 | operand2):operand2; 6297 operand2 = (0x80 & operand2)? (0xFFFFFF00 | operand2):operand2;
6299 RD = RN + operand2; 6298 RD = RN + operand2;
6300 } 6299 }
6301 cpu->Reg[15] += GET_INST_SIZE(cpu); 6300 cpu->Reg[15] += cpu->GetInstructionSize();
6302 INC_PC(sizeof(uxtab_inst)); 6301 INC_PC(sizeof(uxtab_inst));
6303 FETCH_INST; 6302 FETCH_INST;
6304 GOTO_NEXT_INST; 6303 GOTO_NEXT_INST;
@@ -6331,7 +6330,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6331 } 6330 }
6332 } 6331 }
6333 6332
6334 cpu->Reg[15] += GET_INST_SIZE(cpu); 6333 cpu->Reg[15] += cpu->GetInstructionSize();
6335 INC_PC(sizeof(sxtab_inst)); 6334 INC_PC(sizeof(sxtab_inst));
6336 FETCH_INST; 6335 FETCH_INST;
6337 GOTO_NEXT_INST; 6336 GOTO_NEXT_INST;
@@ -6347,7 +6346,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6347 operand2 = (0x8000 & operand2) ? (0xFFFF0000 | operand2) : operand2; 6346 operand2 = (0x8000 & operand2) ? (0xFFFF0000 | operand2) : operand2;
6348 RD = RN + operand2; 6347 RD = RN + operand2;
6349 } 6348 }
6350 cpu->Reg[15] += GET_INST_SIZE(cpu); 6349 cpu->Reg[15] += cpu->GetInstructionSize();
6351 INC_PC(sizeof(sxtah_inst)); 6350 INC_PC(sizeof(sxtah_inst));
6352 FETCH_INST; 6351 FETCH_INST;
6353 GOTO_NEXT_INST; 6352 GOTO_NEXT_INST;
@@ -6362,7 +6361,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6362 u32 rop = SHIFTER_OPERAND; 6361 u32 rop = SHIFTER_OPERAND;
6363 6362
6364 if (inst_cream->Rn == 15) 6363 if (inst_cream->Rn == 15)
6365 lop += GET_INST_SIZE(cpu) * 2; 6364 lop += cpu->GetInstructionSize() * 2;
6366 6365
6367 u32 result = lop ^ rop; 6366 u32 result = lop ^ rop;
6368 6367
@@ -6370,7 +6369,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6370 UPDATE_ZFLAG(result); 6369 UPDATE_ZFLAG(result);
6371 UPDATE_CFLAG_WITH_SC; 6370 UPDATE_CFLAG_WITH_SC;
6372 } 6371 }
6373 cpu->Reg[15] += GET_INST_SIZE(cpu); 6372 cpu->Reg[15] += cpu->GetInstructionSize();
6374 INC_PC(sizeof(teq_inst)); 6373 INC_PC(sizeof(teq_inst));
6375 FETCH_INST; 6374 FETCH_INST;
6376 GOTO_NEXT_INST; 6375 GOTO_NEXT_INST;
@@ -6384,7 +6383,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6384 u32 rop = SHIFTER_OPERAND; 6383 u32 rop = SHIFTER_OPERAND;
6385 6384
6386 if (inst_cream->Rn == 15) 6385 if (inst_cream->Rn == 15)
6387 lop += GET_INST_SIZE(cpu) * 2; 6386 lop += cpu->GetInstructionSize() * 2;
6388 6387
6389 u32 result = lop & rop; 6388 u32 result = lop & rop;
6390 6389
@@ -6392,7 +6391,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6392 UPDATE_ZFLAG(result); 6391 UPDATE_ZFLAG(result);
6393 UPDATE_CFLAG_WITH_SC; 6392 UPDATE_CFLAG_WITH_SC;
6394 } 6393 }
6395 cpu->Reg[15] += GET_INST_SIZE(cpu); 6394 cpu->Reg[15] += cpu->GetInstructionSize();
6396 INC_PC(sizeof(tst_inst)); 6395 INC_PC(sizeof(tst_inst));
6397 FETCH_INST; 6396 FETCH_INST;
6398 GOTO_NEXT_INST; 6397 GOTO_NEXT_INST;
@@ -6563,7 +6562,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6563 RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16); 6562 RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16);
6564 } 6563 }
6565 6564
6566 cpu->Reg[15] += GET_INST_SIZE(cpu); 6565 cpu->Reg[15] += cpu->GetInstructionSize();
6567 INC_PC(sizeof(generic_arm_inst)); 6566 INC_PC(sizeof(generic_arm_inst));
6568 FETCH_INST; 6567 FETCH_INST;
6569 GOTO_NEXT_INST; 6568 GOTO_NEXT_INST;
@@ -6643,7 +6642,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6643 } 6642 }
6644 } 6643 }
6645 6644
6646 cpu->Reg[15] += GET_INST_SIZE(cpu); 6645 cpu->Reg[15] += cpu->GetInstructionSize();
6647 INC_PC(sizeof(generic_arm_inst)); 6646 INC_PC(sizeof(generic_arm_inst));
6648 FETCH_INST; 6647 FETCH_INST;
6649 GOTO_NEXT_INST; 6648 GOTO_NEXT_INST;
@@ -6662,7 +6661,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6662 RDLO = (result & 0xFFFFFFFF); 6661 RDLO = (result & 0xFFFFFFFF);
6663 RDHI = ((result >> 32) & 0xFFFFFFFF); 6662 RDHI = ((result >> 32) & 0xFFFFFFFF);
6664 } 6663 }
6665 cpu->Reg[15] += GET_INST_SIZE(cpu); 6664 cpu->Reg[15] += cpu->GetInstructionSize();
6666 INC_PC(sizeof(umaal_inst)); 6665 INC_PC(sizeof(umaal_inst));
6667 FETCH_INST; 6666 FETCH_INST;
6668 GOTO_NEXT_INST; 6667 GOTO_NEXT_INST;
@@ -6685,7 +6684,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6685 cpu->ZFlag = (RDHI == 0 && RDLO == 0); 6684 cpu->ZFlag = (RDHI == 0 && RDLO == 0);
6686 } 6685 }
6687 } 6686 }
6688 cpu->Reg[15] += GET_INST_SIZE(cpu); 6687 cpu->Reg[15] += cpu->GetInstructionSize();
6689 INC_PC(sizeof(umlal_inst)); 6688 INC_PC(sizeof(umlal_inst));
6690 FETCH_INST; 6689 FETCH_INST;
6691 GOTO_NEXT_INST; 6690 GOTO_NEXT_INST;
@@ -6705,7 +6704,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6705 cpu->ZFlag = (RDHI == 0 && RDLO == 0); 6704 cpu->ZFlag = (RDHI == 0 && RDLO == 0);
6706 } 6705 }
6707 } 6706 }
6708 cpu->Reg[15] += GET_INST_SIZE(cpu); 6707 cpu->Reg[15] += cpu->GetInstructionSize();
6709 INC_PC(sizeof(umull_inst)); 6708 INC_PC(sizeof(umull_inst));
6710 FETCH_INST; 6709 FETCH_INST;
6711 GOTO_NEXT_INST; 6710 GOTO_NEXT_INST;
@@ -6733,7 +6732,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6733 { 6732 {
6734 bl_1_thumb* inst_cream = (bl_1_thumb*)inst_base->component; 6733 bl_1_thumb* inst_cream = (bl_1_thumb*)inst_base->component;
6735 cpu->Reg[14] = cpu->Reg[15] + 4 + inst_cream->imm; 6734 cpu->Reg[14] = cpu->Reg[15] + 4 + inst_cream->imm;
6736 cpu->Reg[15] += GET_INST_SIZE(cpu); 6735 cpu->Reg[15] += cpu->GetInstructionSize();
6737 INC_PC(sizeof(bl_1_thumb)); 6736 INC_PC(sizeof(bl_1_thumb));
6738 FETCH_INST; 6737 FETCH_INST;
6739 GOTO_NEXT_INST; 6738 GOTO_NEXT_INST;
@@ -6814,7 +6813,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6814 RD = ((lo_val & 0xFFFF) | hi_val << 16); 6813 RD = ((lo_val & 0xFFFF) | hi_val << 16);
6815 } 6814 }
6816 6815
6817 cpu->Reg[15] += GET_INST_SIZE(cpu); 6816 cpu->Reg[15] += cpu->GetInstructionSize();
6818 INC_PC(sizeof(generic_arm_inst)); 6817 INC_PC(sizeof(generic_arm_inst));
6819 FETCH_INST; 6818 FETCH_INST;
6820 GOTO_NEXT_INST; 6819 GOTO_NEXT_INST;
@@ -6844,7 +6843,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6844 RD = finalDif; 6843 RD = finalDif;
6845 } 6844 }
6846 6845
6847 cpu->Reg[15] += GET_INST_SIZE(cpu); 6846 cpu->Reg[15] += cpu->GetInstructionSize();
6848 INC_PC(sizeof(generic_arm_inst)); 6847 INC_PC(sizeof(generic_arm_inst));
6849 FETCH_INST; 6848 FETCH_INST;
6850 GOTO_NEXT_INST; 6849 GOTO_NEXT_INST;
@@ -6877,7 +6876,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6877 RD = rn_val; 6876 RD = rn_val;
6878 } 6877 }
6879 6878
6880 cpu->Reg[15] += GET_INST_SIZE(cpu); 6879 cpu->Reg[15] += cpu->GetInstructionSize();
6881 INC_PC(sizeof(ssat_inst)); 6880 INC_PC(sizeof(ssat_inst));
6882 FETCH_INST; 6881 FETCH_INST;
6883 GOTO_NEXT_INST; 6882 GOTO_NEXT_INST;
@@ -6899,7 +6898,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6899 cpu->Cpsr |= (1 << 27); 6898 cpu->Cpsr |= (1 << 27);
6900 } 6899 }
6901 6900
6902 cpu->Reg[15] += GET_INST_SIZE(cpu); 6901 cpu->Reg[15] += cpu->GetInstructionSize();
6903 INC_PC(sizeof(ssat_inst)); 6902 INC_PC(sizeof(ssat_inst));
6904 FETCH_INST; 6903 FETCH_INST;
6905 GOTO_NEXT_INST; 6904 GOTO_NEXT_INST;
@@ -6930,7 +6929,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6930 } 6929 }
6931 } 6930 }
6932 6931
6933 cpu->Reg[15] += GET_INST_SIZE(cpu); 6932 cpu->Reg[15] += cpu->GetInstructionSize();
6934 INC_PC(sizeof(uxtab_inst)); 6933 INC_PC(sizeof(uxtab_inst));
6935 FETCH_INST; 6934 FETCH_INST;
6936 GOTO_NEXT_INST; 6935 GOTO_NEXT_INST;
@@ -6943,7 +6942,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6943 LOG_TRACE(Core_ARM11, "WFE executed."); 6942 LOG_TRACE(Core_ARM11, "WFE executed.");
6944 } 6943 }
6945 6944
6946 cpu->Reg[15] += GET_INST_SIZE(cpu); 6945 cpu->Reg[15] += cpu->GetInstructionSize();
6947 INC_PC_STUB; 6946 INC_PC_STUB;
6948 FETCH_INST; 6947 FETCH_INST;
6949 GOTO_NEXT_INST; 6948 GOTO_NEXT_INST;
@@ -6956,7 +6955,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6956 LOG_TRACE(Core_ARM11, "WFI executed."); 6955 LOG_TRACE(Core_ARM11, "WFI executed.");
6957 } 6956 }
6958 6957
6959 cpu->Reg[15] += GET_INST_SIZE(cpu); 6958 cpu->Reg[15] += cpu->GetInstructionSize();
6960 INC_PC_STUB; 6959 INC_PC_STUB;
6961 FETCH_INST; 6960 FETCH_INST;
6962 GOTO_NEXT_INST; 6961 GOTO_NEXT_INST;
@@ -6969,7 +6968,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
6969 LOG_TRACE(Core_ARM11, "YIELD executed."); 6968 LOG_TRACE(Core_ARM11, "YIELD executed.");
6970 } 6969 }
6971 6970
6972 cpu->Reg[15] += GET_INST_SIZE(cpu); 6971 cpu->Reg[15] += cpu->GetInstructionSize();
6973 INC_PC_STUB; 6972 INC_PC_STUB;
6974 FETCH_INST; 6973 FETCH_INST;
6975 GOTO_NEXT_INST; 6974 GOTO_NEXT_INST;
diff --git a/src/core/arm/dyncom/arm_dyncom_run.cpp b/src/core/arm/dyncom/arm_dyncom_run.cpp
deleted file mode 100644
index 4c6acba98..000000000
--- a/src/core/arm/dyncom/arm_dyncom_run.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
1// Copyright 2012 Michael Kang, 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/arm/dyncom/arm_dyncom_run.h"
6#include "core/arm/skyeye_common/armstate.h"
7
8void switch_mode(ARMul_State* core, uint32_t mode) {
9 if (core->Mode == mode)
10 return;
11
12 if (mode != USERBANK) {
13 switch (core->Mode) {
14 case SYSTEM32MODE: // Shares registers with user mode
15 case USER32MODE:
16 core->Reg_usr[0] = core->Reg[13];
17 core->Reg_usr[1] = core->Reg[14];
18 break;
19 case IRQ32MODE:
20 core->Reg_irq[0] = core->Reg[13];
21 core->Reg_irq[1] = core->Reg[14];
22 core->Spsr[IRQBANK] = core->Spsr_copy;
23 break;
24 case SVC32MODE:
25 core->Reg_svc[0] = core->Reg[13];
26 core->Reg_svc[1] = core->Reg[14];
27 core->Spsr[SVCBANK] = core->Spsr_copy;
28 break;
29 case ABORT32MODE:
30 core->Reg_abort[0] = core->Reg[13];
31 core->Reg_abort[1] = core->Reg[14];
32 core->Spsr[ABORTBANK] = core->Spsr_copy;
33 break;
34 case UNDEF32MODE:
35 core->Reg_undef[0] = core->Reg[13];
36 core->Reg_undef[1] = core->Reg[14];
37 core->Spsr[UNDEFBANK] = core->Spsr_copy;
38 break;
39 case FIQ32MODE:
40 core->Reg_firq[0] = core->Reg[13];
41 core->Reg_firq[1] = core->Reg[14];
42 core->Spsr[FIQBANK] = core->Spsr_copy;
43 break;
44 }
45
46 switch (mode) {
47 case USER32MODE:
48 core->Reg[13] = core->Reg_usr[0];
49 core->Reg[14] = core->Reg_usr[1];
50 core->Bank = USERBANK;
51 break;
52 case IRQ32MODE:
53 core->Reg[13] = core->Reg_irq[0];
54 core->Reg[14] = core->Reg_irq[1];
55 core->Spsr_copy = core->Spsr[IRQBANK];
56 core->Bank = IRQBANK;
57 break;
58 case SVC32MODE:
59 core->Reg[13] = core->Reg_svc[0];
60 core->Reg[14] = core->Reg_svc[1];
61 core->Spsr_copy = core->Spsr[SVCBANK];
62 core->Bank = SVCBANK;
63 break;
64 case ABORT32MODE:
65 core->Reg[13] = core->Reg_abort[0];
66 core->Reg[14] = core->Reg_abort[1];
67 core->Spsr_copy = core->Spsr[ABORTBANK];
68 core->Bank = ABORTBANK;
69 break;
70 case UNDEF32MODE:
71 core->Reg[13] = core->Reg_undef[0];
72 core->Reg[14] = core->Reg_undef[1];
73 core->Spsr_copy = core->Spsr[UNDEFBANK];
74 core->Bank = UNDEFBANK;
75 break;
76 case FIQ32MODE:
77 core->Reg[13] = core->Reg_firq[0];
78 core->Reg[14] = core->Reg_firq[1];
79 core->Spsr_copy = core->Spsr[FIQBANK];
80 core->Bank = FIQBANK;
81 break;
82 case SYSTEM32MODE: // Shares registers with user mode.
83 core->Reg[13] = core->Reg_usr[0];
84 core->Reg[14] = core->Reg_usr[1];
85 core->Bank = SYSTEMBANK;
86 break;
87 }
88
89 // Set the mode bits in the APSR
90 core->Cpsr = (core->Cpsr & ~core->Mode) | mode;
91 core->Mode = mode;
92 }
93}
diff --git a/src/core/arm/dyncom/arm_dyncom_run.h b/src/core/arm/dyncom/arm_dyncom_run.h
index ef18455bc..13bef17fc 100644
--- a/src/core/arm/dyncom/arm_dyncom_run.h
+++ b/src/core/arm/dyncom/arm_dyncom_run.h
@@ -20,38 +20,29 @@
20 20
21#include "core/arm/skyeye_common/armstate.h" 21#include "core/arm/skyeye_common/armstate.h"
22 22
23void switch_mode(ARMul_State* core, uint32_t mode);
24
25// Note that for the 3DS, a Thumb instruction will only ever be
26// two bytes in size. Thus we don't need to worry about ThumbEE
27// or Thumb-2 where instructions can be 4 bytes in length.
28static inline u32 GET_INST_SIZE(ARMul_State* core) {
29 return core->TFlag? 2 : 4;
30}
31
32/** 23/**
33 * Checks if the PC is being read, and if so, word-aligns it. 24 * Checks if the PC is being read, and if so, word-aligns it.
34 * Used with address calculations. 25 * Used with address calculations.
35 * 26 *
36 * @param core The ARM CPU state instance. 27 * @param cpu The ARM CPU state instance.
37 * @param Rn The register being read. 28 * @param Rn The register being read.
38 * 29 *
39 * @return If the PC is being read, then the word-aligned PC value is returned. 30 * @return If the PC is being read, then the word-aligned PC value is returned.
40 * If the PC is not being read, then the value stored in the register is returned. 31 * If the PC is not being read, then the value stored in the register is returned.
41 */ 32 */
42static inline u32 CHECK_READ_REG15_WA(ARMul_State* core, int Rn) { 33static inline u32 CHECK_READ_REG15_WA(ARMul_State* cpu, int Rn) {
43 return (Rn == 15) ? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; 34 return (Rn == 15) ? ((cpu->Reg[15] & ~0x3) + cpu->GetInstructionSize() * 2) : cpu->Reg[Rn];
44} 35}
45 36
46/** 37/**
47 * Reads the PC. Used for data processing operations that use the PC. 38 * Reads the PC. Used for data processing operations that use the PC.
48 * 39 *
49 * @param core The ARM CPU state instance. 40 * @param cpu The ARM CPU state instance.
50 * @param Rn The register being read. 41 * @param Rn The register being read.
51 * 42 *
52 * @return If the PC is being read, then the incremented PC value is returned. 43 * @return If the PC is being read, then the incremented PC value is returned.
53 * If the PC is not being read, then the values stored in the register is returned. 44 * If the PC is not being read, then the values stored in the register is returned.
54 */ 45 */
55static inline u32 CHECK_READ_REG15(ARMul_State* core, int Rn) { 46static inline u32 CHECK_READ_REG15(ARMul_State* cpu, int Rn) {
56 return (Rn == 15) ? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; 47 return (Rn == 15) ? ((cpu->Reg[15] & ~0x1) + cpu->GetInstructionSize() * 2) : cpu->Reg[Rn];
57} 48}
diff --git a/src/core/arm/skyeye_common/arminit.cpp b/src/core/arm/skyeye_common/arminit.cpp
deleted file mode 100644
index b7c508d75..000000000
--- a/src/core/arm/skyeye_common/arminit.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
1/* arminit.c -- ARMulator initialization: ARM6 Instruction Emulator.
2 Copyright (C) 1994 Advanced RISC Machines Ltd.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18#include <cstring>
19#include "core/arm/skyeye_common/armstate.h"
20#include "core/arm/skyeye_common/vfp/vfp.h"
21
22// Resets certain MPCore CP15 values to their ARM-defined reset values.
23static void ResetMPCoreCP15Registers(ARMul_State* cpu)
24{
25 // c0
26 cpu->CP15[CP15_MAIN_ID] = 0x410FB024;
27 cpu->CP15[CP15_TLB_TYPE] = 0x00000800;
28 cpu->CP15[CP15_PROCESSOR_FEATURE_0] = 0x00000111;
29 cpu->CP15[CP15_PROCESSOR_FEATURE_1] = 0x00000001;
30 cpu->CP15[CP15_DEBUG_FEATURE_0] = 0x00000002;
31 cpu->CP15[CP15_MEMORY_MODEL_FEATURE_0] = 0x01100103;
32 cpu->CP15[CP15_MEMORY_MODEL_FEATURE_1] = 0x10020302;
33 cpu->CP15[CP15_MEMORY_MODEL_FEATURE_2] = 0x01222000;
34 cpu->CP15[CP15_MEMORY_MODEL_FEATURE_3] = 0x00000000;
35 cpu->CP15[CP15_ISA_FEATURE_0] = 0x00100011;
36 cpu->CP15[CP15_ISA_FEATURE_1] = 0x12002111;
37 cpu->CP15[CP15_ISA_FEATURE_2] = 0x11221011;
38 cpu->CP15[CP15_ISA_FEATURE_3] = 0x01102131;
39 cpu->CP15[CP15_ISA_FEATURE_4] = 0x00000141;
40
41 // c1
42 cpu->CP15[CP15_CONTROL] = 0x00054078;
43 cpu->CP15[CP15_AUXILIARY_CONTROL] = 0x0000000F;
44 cpu->CP15[CP15_COPROCESSOR_ACCESS_CONTROL] = 0x00000000;
45
46 // c2
47 cpu->CP15[CP15_TRANSLATION_BASE_TABLE_0] = 0x00000000;
48 cpu->CP15[CP15_TRANSLATION_BASE_TABLE_1] = 0x00000000;
49 cpu->CP15[CP15_TRANSLATION_BASE_CONTROL] = 0x00000000;
50
51 // c3
52 cpu->CP15[CP15_DOMAIN_ACCESS_CONTROL] = 0x00000000;
53
54 // c7
55 cpu->CP15[CP15_PHYS_ADDRESS] = 0x00000000;
56
57 // c9
58 cpu->CP15[CP15_DATA_CACHE_LOCKDOWN] = 0xFFFFFFF0;
59
60 // c10
61 cpu->CP15[CP15_TLB_LOCKDOWN] = 0x00000000;
62 cpu->CP15[CP15_PRIMARY_REGION_REMAP] = 0x00098AA4;
63 cpu->CP15[CP15_NORMAL_REGION_REMAP] = 0x44E048E0;
64
65 // c13
66 cpu->CP15[CP15_PID] = 0x00000000;
67 cpu->CP15[CP15_CONTEXT_ID] = 0x00000000;
68 cpu->CP15[CP15_THREAD_UPRW] = 0x00000000;
69 cpu->CP15[CP15_THREAD_URO] = 0x00000000;
70 cpu->CP15[CP15_THREAD_PRW] = 0x00000000;
71
72 // c15
73 cpu->CP15[CP15_PERFORMANCE_MONITOR_CONTROL] = 0x00000000;
74 cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_VIRT_ADDRESS] = 0x00000000;
75 cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_PHYS_ADDRESS] = 0x00000000;
76 cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_ATTRIBUTE] = 0x00000000;
77 cpu->CP15[CP15_TLB_DEBUG_CONTROL] = 0x00000000;
78}
79
80// Performs a reset
81void ARMul_Reset(ARMul_State* state)
82{
83 VFPInit(state);
84
85 state->Reg[15] = 0;
86 state->Cpsr = INTBITS | SVC32MODE;
87 state->Mode = SVC32MODE;
88 state->Bank = SVCBANK;
89
90 ResetMPCoreCP15Registers(state);
91
92 state->NresetSig = HIGH;
93 state->NfiqSig = HIGH;
94 state->NirqSig = HIGH;
95 state->NtransSig = (state->Mode & 3) ? HIGH : LOW;
96 state->abortSig = LOW;
97
98 state->NumInstrs = 0;
99 state->Emulate = RUN;
100}
diff --git a/src/core/arm/skyeye_common/armmmu.h b/src/core/arm/skyeye_common/armmmu.h
deleted file mode 100644
index 5423588c0..000000000
--- a/src/core/arm/skyeye_common/armmmu.h
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 armmmu.c - Memory Management Unit emulation.
3 ARMulator extensions for the ARM7100 family.
4 Copyright (C) 1999 Ben Williamson
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21#pragma once
22
23#include "common/swap.h"
24
25#include "core/memory.h"
26#include "core/arm/skyeye_common/armstate.h"
27#include "core/arm/skyeye_common/armsupp.h"
28
29// Register numbers in the MMU
30enum
31{
32 MMU_ID = 0,
33 MMU_CONTROL = 1,
34 MMU_TRANSLATION_TABLE_BASE = 2,
35 MMU_DOMAIN_ACCESS_CONTROL = 3,
36 MMU_FAULT_STATUS = 5,
37 MMU_FAULT_ADDRESS = 6,
38 MMU_CACHE_OPS = 7,
39 MMU_TLB_OPS = 8,
40 MMU_CACHE_LOCKDOWN = 9,
41 MMU_TLB_LOCKDOWN = 10,
42 MMU_PID = 13,
43
44 // MMU_V4
45 MMU_V4_CACHE_OPS = 7,
46 MMU_V4_TLB_OPS = 8,
47
48 // MMU_V3
49 MMU_V3_FLUSH_TLB = 5,
50 MMU_V3_FLUSH_TLB_ENTRY = 6,
51 MMU_V3_FLUSH_CACHE = 7,
52};
53
54// Reads data in big/little endian format based on the
55// state of the E (endian) bit in the emulated CPU's APSR.
56inline u16 ReadMemory16(ARMul_State* cpu, u32 address) {
57 u16 data = Memory::Read16(address);
58
59 if (InBigEndianMode(cpu))
60 data = Common::swap16(data);
61
62 return data;
63}
64
65inline u32 ReadMemory32(ARMul_State* cpu, u32 address) {
66 u32 data = Memory::Read32(address);
67
68 if (InBigEndianMode(cpu))
69 data = Common::swap32(data);
70
71 return data;
72}
73
74inline u64 ReadMemory64(ARMul_State* cpu, u32 address) {
75 u64 data = Memory::Read64(address);
76
77 if (InBigEndianMode(cpu))
78 data = Common::swap64(data);
79
80 return data;
81}
82
83// Writes data in big/little endian format based on the
84// state of the E (endian) bit in the emulated CPU's APSR.
85inline void WriteMemory16(ARMul_State* cpu, u32 address, u16 data) {
86 if (InBigEndianMode(cpu))
87 data = Common::swap16(data);
88
89 Memory::Write16(address, data);
90}
91
92inline void WriteMemory32(ARMul_State* cpu, u32 address, u32 data) {
93 if (InBigEndianMode(cpu))
94 data = Common::swap32(data);
95
96 Memory::Write32(address, data);
97}
98
99inline void WriteMemory64(ARMul_State* cpu, u32 address, u64 data) {
100 if (InBigEndianMode(cpu))
101 data = Common::swap64(data);
102
103 Memory::Write64(address, data);
104}
diff --git a/src/core/arm/skyeye_common/armstate.cpp b/src/core/arm/skyeye_common/armstate.cpp
new file mode 100644
index 000000000..ccb2eb0eb
--- /dev/null
+++ b/src/core/arm/skyeye_common/armstate.cpp
@@ -0,0 +1,657 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/swap.h"
6#include "common/logging/log.h"
7#include "core/mem_map.h"
8#include "core/memory.h"
9#include "core/arm/skyeye_common/armstate.h"
10#include "core/arm/skyeye_common/vfp/vfp.h"
11
12ARMul_State::ARMul_State(PrivilegeMode initial_mode)
13{
14 Reset();
15 ChangePrivilegeMode(initial_mode);
16}
17
18void ARMul_State::ChangePrivilegeMode(u32 new_mode)
19{
20 if (Mode == new_mode)
21 return;
22
23 if (new_mode != USERBANK) {
24 switch (Mode) {
25 case SYSTEM32MODE: // Shares registers with user mode
26 case USER32MODE:
27 Reg_usr[0] = Reg[13];
28 Reg_usr[1] = Reg[14];
29 break;
30 case IRQ32MODE:
31 Reg_irq[0] = Reg[13];
32 Reg_irq[1] = Reg[14];
33 Spsr[IRQBANK] = Spsr_copy;
34 break;
35 case SVC32MODE:
36 Reg_svc[0] = Reg[13];
37 Reg_svc[1] = Reg[14];
38 Spsr[SVCBANK] = Spsr_copy;
39 break;
40 case ABORT32MODE:
41 Reg_abort[0] = Reg[13];
42 Reg_abort[1] = Reg[14];
43 Spsr[ABORTBANK] = Spsr_copy;
44 break;
45 case UNDEF32MODE:
46 Reg_undef[0] = Reg[13];
47 Reg_undef[1] = Reg[14];
48 Spsr[UNDEFBANK] = Spsr_copy;
49 break;
50 case FIQ32MODE:
51 Reg_firq[0] = Reg[13];
52 Reg_firq[1] = Reg[14];
53 Spsr[FIQBANK] = Spsr_copy;
54 break;
55 }
56
57 switch (new_mode) {
58 case USER32MODE:
59 Reg[13] = Reg_usr[0];
60 Reg[14] = Reg_usr[1];
61 Bank = USERBANK;
62 break;
63 case IRQ32MODE:
64 Reg[13] = Reg_irq[0];
65 Reg[14] = Reg_irq[1];
66 Spsr_copy = Spsr[IRQBANK];
67 Bank = IRQBANK;
68 break;
69 case SVC32MODE:
70 Reg[13] = Reg_svc[0];
71 Reg[14] = Reg_svc[1];
72 Spsr_copy = Spsr[SVCBANK];
73 Bank = SVCBANK;
74 break;
75 case ABORT32MODE:
76 Reg[13] = Reg_abort[0];
77 Reg[14] = Reg_abort[1];
78 Spsr_copy = Spsr[ABORTBANK];
79 Bank = ABORTBANK;
80 break;
81 case UNDEF32MODE:
82 Reg[13] = Reg_undef[0];
83 Reg[14] = Reg_undef[1];
84 Spsr_copy = Spsr[UNDEFBANK];
85 Bank = UNDEFBANK;
86 break;
87 case FIQ32MODE:
88 Reg[13] = Reg_firq[0];
89 Reg[14] = Reg_firq[1];
90 Spsr_copy = Spsr[FIQBANK];
91 Bank = FIQBANK;
92 break;
93 case SYSTEM32MODE: // Shares registers with user mode.
94 Reg[13] = Reg_usr[0];
95 Reg[14] = Reg_usr[1];
96 Bank = SYSTEMBANK;
97 break;
98 }
99
100 // Set the mode bits in the APSR
101 Cpsr = (Cpsr & ~Mode) | new_mode;
102 Mode = new_mode;
103 }
104}
105
106// Performs a reset
107void ARMul_State::Reset()
108{
109 VFPInit(this);
110
111 // Set stack pointer to the top of the stack
112 Reg[13] = 0x10000000;
113 Reg[15] = 0;
114
115 Cpsr = INTBITS | SVC32MODE;
116 Mode = SVC32MODE;
117 Bank = SVCBANK;
118
119 ResetMPCoreCP15Registers();
120
121 NresetSig = HIGH;
122 NfiqSig = HIGH;
123 NirqSig = HIGH;
124 NtransSig = (Mode & 3) ? HIGH : LOW;
125 abortSig = LOW;
126
127 NumInstrs = 0;
128 Emulate = RUN;
129}
130
131// Resets certain MPCore CP15 values to their ARM-defined reset values.
132void ARMul_State::ResetMPCoreCP15Registers()
133{
134 // c0
135 CP15[CP15_MAIN_ID] = 0x410FB024;
136 CP15[CP15_TLB_TYPE] = 0x00000800;
137 CP15[CP15_PROCESSOR_FEATURE_0] = 0x00000111;
138 CP15[CP15_PROCESSOR_FEATURE_1] = 0x00000001;
139 CP15[CP15_DEBUG_FEATURE_0] = 0x00000002;
140 CP15[CP15_MEMORY_MODEL_FEATURE_0] = 0x01100103;
141 CP15[CP15_MEMORY_MODEL_FEATURE_1] = 0x10020302;
142 CP15[CP15_MEMORY_MODEL_FEATURE_2] = 0x01222000;
143 CP15[CP15_MEMORY_MODEL_FEATURE_3] = 0x00000000;
144 CP15[CP15_ISA_FEATURE_0] = 0x00100011;
145 CP15[CP15_ISA_FEATURE_1] = 0x12002111;
146 CP15[CP15_ISA_FEATURE_2] = 0x11221011;
147 CP15[CP15_ISA_FEATURE_3] = 0x01102131;
148 CP15[CP15_ISA_FEATURE_4] = 0x00000141;
149
150 // c1
151 CP15[CP15_CONTROL] = 0x00054078;
152 CP15[CP15_AUXILIARY_CONTROL] = 0x0000000F;
153 CP15[CP15_COPROCESSOR_ACCESS_CONTROL] = 0x00000000;
154
155 // c2
156 CP15[CP15_TRANSLATION_BASE_TABLE_0] = 0x00000000;
157 CP15[CP15_TRANSLATION_BASE_TABLE_1] = 0x00000000;
158 CP15[CP15_TRANSLATION_BASE_CONTROL] = 0x00000000;
159
160 // c3
161 CP15[CP15_DOMAIN_ACCESS_CONTROL] = 0x00000000;
162
163 // c7
164 CP15[CP15_PHYS_ADDRESS] = 0x00000000;
165
166 // c9
167 CP15[CP15_DATA_CACHE_LOCKDOWN] = 0xFFFFFFF0;
168
169 // c10
170 CP15[CP15_TLB_LOCKDOWN] = 0x00000000;
171 CP15[CP15_PRIMARY_REGION_REMAP] = 0x00098AA4;
172 CP15[CP15_NORMAL_REGION_REMAP] = 0x44E048E0;
173
174 // c13
175 CP15[CP15_PID] = 0x00000000;
176 CP15[CP15_CONTEXT_ID] = 0x00000000;
177 CP15[CP15_THREAD_UPRW] = 0x00000000;
178 CP15[CP15_THREAD_URO] = 0x00000000;
179 CP15[CP15_THREAD_PRW] = 0x00000000;
180
181 // c15
182 CP15[CP15_PERFORMANCE_MONITOR_CONTROL] = 0x00000000;
183 CP15[CP15_MAIN_TLB_LOCKDOWN_VIRT_ADDRESS] = 0x00000000;
184 CP15[CP15_MAIN_TLB_LOCKDOWN_PHYS_ADDRESS] = 0x00000000;
185 CP15[CP15_MAIN_TLB_LOCKDOWN_ATTRIBUTE] = 0x00000000;
186 CP15[CP15_TLB_DEBUG_CONTROL] = 0x00000000;
187}
188
189u16 ARMul_State::ReadMemory16(u32 address) const
190{
191 u16 data = Memory::Read16(address);
192
193 if (InBigEndianMode())
194 data = Common::swap16(data);
195
196 return data;
197}
198
199u32 ARMul_State::ReadMemory32(u32 address) const
200{
201 u32 data = Memory::Read32(address);
202
203 if (InBigEndianMode())
204 data = Common::swap32(data);
205
206 return data;
207}
208
209u64 ARMul_State::ReadMemory64(u32 address) const
210{
211 u64 data = Memory::Read64(address);
212
213 if (InBigEndianMode())
214 data = Common::swap64(data);
215
216 return data;
217}
218
219void ARMul_State::WriteMemory16(u32 address, u16 data)
220{
221 if (InBigEndianMode())
222 data = Common::swap16(data);
223
224 Memory::Write16(address, data);
225}
226
227void ARMul_State::WriteMemory32(u32 address, u32 data)
228{
229 if (InBigEndianMode())
230 data = Common::swap32(data);
231
232 Memory::Write32(address, data);
233}
234
235void ARMul_State::WriteMemory64(u32 address, u64 data)
236{
237 if (InBigEndianMode())
238 data = Common::swap64(data);
239
240 Memory::Write64(address, data);
241}
242
243
244// Reads from the CP15 registers. Used with implementation of the MRC instruction.
245// Note that since the 3DS does not have the hypervisor extensions, these registers
246// are not implemented.
247u32 ARMul_State::ReadCP15Register(u32 crn, u32 opcode_1, u32 crm, u32 opcode_2) const
248{
249 // Unprivileged registers
250 if (crn == 13 && opcode_1 == 0 && crm == 0)
251 {
252 if (opcode_2 == 2)
253 return CP15[CP15_THREAD_UPRW];
254
255 if (opcode_2 == 3)
256 return CP15[CP15_THREAD_URO];
257 }
258
259 if (InAPrivilegedMode())
260 {
261 if (crn == 0 && opcode_1 == 0)
262 {
263 if (crm == 0)
264 {
265 if (opcode_2 == 0)
266 return CP15[CP15_MAIN_ID];
267
268 if (opcode_2 == 1)
269 return CP15[CP15_CACHE_TYPE];
270
271 if (opcode_2 == 3)
272 return CP15[CP15_TLB_TYPE];
273
274 if (opcode_2 == 5)
275 return CP15[CP15_CPU_ID];
276 }
277 else if (crm == 1)
278 {
279 if (opcode_2 == 0)
280 return CP15[CP15_PROCESSOR_FEATURE_0];
281
282 if (opcode_2 == 1)
283 return CP15[CP15_PROCESSOR_FEATURE_1];
284
285 if (opcode_2 == 2)
286 return CP15[CP15_DEBUG_FEATURE_0];
287
288 if (opcode_2 == 4)
289 return CP15[CP15_MEMORY_MODEL_FEATURE_0];
290
291 if (opcode_2 == 5)
292 return CP15[CP15_MEMORY_MODEL_FEATURE_1];
293
294 if (opcode_2 == 6)
295 return CP15[CP15_MEMORY_MODEL_FEATURE_2];
296
297 if (opcode_2 == 7)
298 return CP15[CP15_MEMORY_MODEL_FEATURE_3];
299 }
300 else if (crm == 2)
301 {
302 if (opcode_2 == 0)
303 return CP15[CP15_ISA_FEATURE_0];
304
305 if (opcode_2 == 1)
306 return CP15[CP15_ISA_FEATURE_1];
307
308 if (opcode_2 == 2)
309 return CP15[CP15_ISA_FEATURE_2];
310
311 if (opcode_2 == 3)
312 return CP15[CP15_ISA_FEATURE_3];
313
314 if (opcode_2 == 4)
315 return CP15[CP15_ISA_FEATURE_4];
316 }
317 }
318
319 if (crn == 1 && opcode_1 == 0 && crm == 0)
320 {
321 if (opcode_2 == 0)
322 return CP15[CP15_CONTROL];
323
324 if (opcode_2 == 1)
325 return CP15[CP15_AUXILIARY_CONTROL];
326
327 if (opcode_2 == 2)
328 return CP15[CP15_COPROCESSOR_ACCESS_CONTROL];
329 }
330
331 if (crn == 2 && opcode_1 == 0 && crm == 0)
332 {
333 if (opcode_2 == 0)
334 return CP15[CP15_TRANSLATION_BASE_TABLE_0];
335
336 if (opcode_2 == 1)
337 return CP15[CP15_TRANSLATION_BASE_TABLE_1];
338
339 if (opcode_2 == 2)
340 return CP15[CP15_TRANSLATION_BASE_CONTROL];
341 }
342
343 if (crn == 3 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
344 return CP15[CP15_DOMAIN_ACCESS_CONTROL];
345
346 if (crn == 5 && opcode_1 == 0 && crm == 0)
347 {
348 if (opcode_2 == 0)
349 return CP15[CP15_FAULT_STATUS];
350
351 if (opcode_2 == 1)
352 return CP15[CP15_INSTR_FAULT_STATUS];
353 }
354
355 if (crn == 6 && opcode_1 == 0 && crm == 0)
356 {
357 if (opcode_2 == 0)
358 return CP15[CP15_FAULT_ADDRESS];
359
360 if (opcode_2 == 1)
361 return CP15[CP15_WFAR];
362 }
363
364 if (crn == 7 && opcode_1 == 0 && crm == 4 && opcode_2 == 0)
365 return CP15[CP15_PHYS_ADDRESS];
366
367 if (crn == 9 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
368 return CP15[CP15_DATA_CACHE_LOCKDOWN];
369
370 if (crn == 10 && opcode_1 == 0)
371 {
372 if (crm == 0 && opcode_2 == 0)
373 return CP15[CP15_TLB_LOCKDOWN];
374
375 if (crm == 2)
376 {
377 if (opcode_2 == 0)
378 return CP15[CP15_PRIMARY_REGION_REMAP];
379
380 if (opcode_2 == 1)
381 return CP15[CP15_NORMAL_REGION_REMAP];
382 }
383 }
384
385 if (crn == 13 && crm == 0)
386 {
387 if (opcode_2 == 0)
388 return CP15[CP15_PID];
389
390 if (opcode_2 == 1)
391 return CP15[CP15_CONTEXT_ID];
392
393 if (opcode_2 == 4)
394 return CP15[CP15_THREAD_PRW];
395 }
396
397 if (crn == 15)
398 {
399 if (opcode_1 == 0 && crm == 12)
400 {
401 if (opcode_2 == 0)
402 return CP15[CP15_PERFORMANCE_MONITOR_CONTROL];
403
404 if (opcode_2 == 1)
405 return CP15[CP15_CYCLE_COUNTER];
406
407 if (opcode_2 == 2)
408 return CP15[CP15_COUNT_0];
409
410 if (opcode_2 == 3)
411 return CP15[CP15_COUNT_1];
412 }
413
414 if (opcode_1 == 5 && opcode_2 == 2)
415 {
416 if (crm == 5)
417 return CP15[CP15_MAIN_TLB_LOCKDOWN_VIRT_ADDRESS];
418
419 if (crm == 6)
420 return CP15[CP15_MAIN_TLB_LOCKDOWN_PHYS_ADDRESS];
421
422 if (crm == 7)
423 return CP15[CP15_MAIN_TLB_LOCKDOWN_ATTRIBUTE];
424 }
425
426 if (opcode_1 == 7 && crm == 1 && opcode_2 == 0)
427 return CP15[CP15_TLB_DEBUG_CONTROL];
428 }
429 }
430
431 LOG_ERROR(Core_ARM11, "MRC CRn=%u, CRm=%u, OP1=%u OP2=%u is not implemented. Returning zero.", crn, crm, opcode_1, opcode_2);
432 return 0;
433}
434
435// Write to the CP15 registers. Used with implementation of the MCR instruction.
436// Note that since the 3DS does not have the hypervisor extensions, these registers
437// are not implemented.
438void ARMul_State::WriteCP15Register(u32 value, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2)
439{
440 if (InAPrivilegedMode())
441 {
442 if (crn == 1 && opcode_1 == 0 && crm == 0)
443 {
444 if (opcode_2 == 0)
445 CP15[CP15_CONTROL] = value;
446 else if (opcode_2 == 1)
447 CP15[CP15_AUXILIARY_CONTROL] = value;
448 else if (opcode_2 == 2)
449 CP15[CP15_COPROCESSOR_ACCESS_CONTROL] = value;
450 }
451 else if (crn == 2 && opcode_1 == 0 && crm == 0)
452 {
453 if (opcode_2 == 0)
454 CP15[CP15_TRANSLATION_BASE_TABLE_0] = value;
455 else if (opcode_2 == 1)
456 CP15[CP15_TRANSLATION_BASE_TABLE_1] = value;
457 else if (opcode_2 == 2)
458 CP15[CP15_TRANSLATION_BASE_CONTROL] = value;
459 }
460 else if (crn == 3 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
461 {
462 CP15[CP15_DOMAIN_ACCESS_CONTROL] = value;
463 }
464 else if (crn == 5 && opcode_1 == 0 && crm == 0)
465 {
466 if (opcode_2 == 0)
467 CP15[CP15_FAULT_STATUS] = value;
468 else if (opcode_2 == 1)
469 CP15[CP15_INSTR_FAULT_STATUS] = value;
470 }
471 else if (crn == 6 && opcode_1 == 0 && crm == 0)
472 {
473 if (opcode_2 == 0)
474 CP15[CP15_FAULT_ADDRESS] = value;
475 else if (opcode_2 == 1)
476 CP15[CP15_WFAR] = value;
477 }
478 else if (crn == 7 && opcode_1 == 0)
479 {
480 if (crm == 0 && opcode_2 == 4)
481 {
482 CP15[CP15_WAIT_FOR_INTERRUPT] = value;
483 }
484 else if (crm == 4 && opcode_2 == 0)
485 {
486 // NOTE: Not entirely accurate. This should do permission checks.
487 CP15[CP15_PHYS_ADDRESS] = Memory::VirtualToPhysicalAddress(value);
488 }
489 else if (crm == 5)
490 {
491 if (opcode_2 == 0)
492 CP15[CP15_INVALIDATE_INSTR_CACHE] = value;
493 else if (opcode_2 == 1)
494 CP15[CP15_INVALIDATE_INSTR_CACHE_USING_MVA] = value;
495 else if (opcode_2 == 2)
496 CP15[CP15_INVALIDATE_INSTR_CACHE_USING_INDEX] = value;
497 else if (opcode_2 == 6)
498 CP15[CP15_FLUSH_BRANCH_TARGET_CACHE] = value;
499 else if (opcode_2 == 7)
500 CP15[CP15_FLUSH_BRANCH_TARGET_CACHE_ENTRY] = value;
501 }
502 else if (crm == 6)
503 {
504 if (opcode_2 == 0)
505 CP15[CP15_INVALIDATE_DATA_CACHE] = value;
506 else if (opcode_2 == 1)
507 CP15[CP15_INVALIDATE_DATA_CACHE_LINE_USING_MVA] = value;
508 else if (opcode_2 == 2)
509 CP15[CP15_INVALIDATE_DATA_CACHE_LINE_USING_INDEX] = value;
510 }
511 else if (crm == 7 && opcode_2 == 0)
512 {
513 CP15[CP15_INVALIDATE_DATA_AND_INSTR_CACHE] = value;
514 }
515 else if (crm == 10)
516 {
517 if (opcode_2 == 0)
518 CP15[CP15_CLEAN_DATA_CACHE] = value;
519 else if (opcode_2 == 1)
520 CP15[CP15_CLEAN_DATA_CACHE_LINE_USING_MVA] = value;
521 else if (opcode_2 == 2)
522 CP15[CP15_CLEAN_DATA_CACHE_LINE_USING_INDEX] = value;
523 }
524 else if (crm == 14)
525 {
526 if (opcode_2 == 0)
527 CP15[CP15_CLEAN_AND_INVALIDATE_DATA_CACHE] = value;
528 else if (opcode_2 == 1)
529 CP15[CP15_CLEAN_AND_INVALIDATE_DATA_CACHE_LINE_USING_MVA] = value;
530 else if (opcode_2 == 2)
531 CP15[CP15_CLEAN_AND_INVALIDATE_DATA_CACHE_LINE_USING_INDEX] = value;
532 }
533 }
534 else if (crn == 8 && opcode_1 == 0)
535 {
536 if (crm == 5)
537 {
538 if (opcode_2 == 0)
539 CP15[CP15_INVALIDATE_ITLB] = value;
540 else if (opcode_2 == 1)
541 CP15[CP15_INVALIDATE_ITLB_SINGLE_ENTRY] = value;
542 else if (opcode_2 == 2)
543 CP15[CP15_INVALIDATE_ITLB_ENTRY_ON_ASID_MATCH] = value;
544 else if (opcode_2 == 3)
545 CP15[CP15_INVALIDATE_ITLB_ENTRY_ON_MVA] = value;
546 }
547 else if (crm == 6)
548 {
549 if (opcode_2 == 0)
550 CP15[CP15_INVALIDATE_DTLB] = value;
551 else if (opcode_2 == 1)
552 CP15[CP15_INVALIDATE_DTLB_SINGLE_ENTRY] = value;
553 else if (opcode_2 == 2)
554 CP15[CP15_INVALIDATE_DTLB_ENTRY_ON_ASID_MATCH] = value;
555 else if (opcode_2 == 3)
556 CP15[CP15_INVALIDATE_DTLB_ENTRY_ON_MVA] = value;
557 }
558 else if (crm == 7)
559 {
560 if (opcode_2 == 0)
561 CP15[CP15_INVALIDATE_UTLB] = value;
562 else if (opcode_2 == 1)
563 CP15[CP15_INVALIDATE_UTLB_SINGLE_ENTRY] = value;
564 else if (opcode_2 == 2)
565 CP15[CP15_INVALIDATE_UTLB_ENTRY_ON_ASID_MATCH] = value;
566 else if (opcode_2 == 3)
567 CP15[CP15_INVALIDATE_UTLB_ENTRY_ON_MVA] = value;
568 }
569 }
570 else if (crn == 9 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
571 {
572 CP15[CP15_DATA_CACHE_LOCKDOWN] = value;
573 }
574 else if (crn == 10 && opcode_1 == 0)
575 {
576 if (crm == 0 && opcode_2 == 0)
577 {
578 CP15[CP15_TLB_LOCKDOWN] = value;
579 }
580 else if (crm == 2)
581 {
582 if (opcode_2 == 0)
583 CP15[CP15_PRIMARY_REGION_REMAP] = value;
584 else if (opcode_2 == 1)
585 CP15[CP15_NORMAL_REGION_REMAP] = value;
586 }
587 }
588 else if (crn == 13 && opcode_1 == 0 && crm == 0)
589 {
590 if (opcode_2 == 0)
591 CP15[CP15_PID] = value;
592 else if (opcode_2 == 1)
593 CP15[CP15_CONTEXT_ID] = value;
594 else if (opcode_2 == 3)
595 CP15[CP15_THREAD_URO] = value;
596 else if (opcode_2 == 4)
597 CP15[CP15_THREAD_PRW] = value;
598 }
599 else if (crn == 15)
600 {
601 if (opcode_1 == 0 && crm == 12)
602 {
603 if (opcode_2 == 0)
604 CP15[CP15_PERFORMANCE_MONITOR_CONTROL] = value;
605 else if (opcode_2 == 1)
606 CP15[CP15_CYCLE_COUNTER] = value;
607 else if (opcode_2 == 2)
608 CP15[CP15_COUNT_0] = value;
609 else if (opcode_2 == 3)
610 CP15[CP15_COUNT_1] = value;
611 }
612 else if (opcode_1 == 5)
613 {
614 if (crm == 4)
615 {
616 if (opcode_2 == 2)
617 CP15[CP15_READ_MAIN_TLB_LOCKDOWN_ENTRY] = value;
618 else if (opcode_2 == 4)
619 CP15[CP15_WRITE_MAIN_TLB_LOCKDOWN_ENTRY] = value;
620 }
621 else if (crm == 5 && opcode_2 == 2)
622 {
623 CP15[CP15_MAIN_TLB_LOCKDOWN_VIRT_ADDRESS] = value;
624 }
625 else if (crm == 6 && opcode_2 == 2)
626 {
627 CP15[CP15_MAIN_TLB_LOCKDOWN_PHYS_ADDRESS] = value;
628 }
629 else if (crm == 7 && opcode_2 == 2)
630 {
631 CP15[CP15_MAIN_TLB_LOCKDOWN_ATTRIBUTE] = value;
632 }
633 }
634 else if (opcode_1 == 7 && crm == 1 && opcode_2 == 0)
635 {
636 CP15[CP15_TLB_DEBUG_CONTROL] = value;
637 }
638 }
639 }
640
641 // Unprivileged registers
642 if (crn == 7 && opcode_1 == 0 && crm == 5 && opcode_2 == 4)
643 {
644 CP15[CP15_FLUSH_PREFETCH_BUFFER] = value;
645 }
646 else if (crn == 7 && opcode_1 == 0 && crm == 10)
647 {
648 if (opcode_2 == 4)
649 CP15[CP15_DATA_SYNC_BARRIER] = value;
650 else if (opcode_2 == 5)
651 CP15[CP15_DATA_MEMORY_BARRIER] = value;
652 }
653 else if (crn == 13 && opcode_1 == 0 && crm == 0 && opcode_2 == 2)
654 {
655 CP15[CP15_THREAD_UPRW] = value;
656 }
657}
diff --git a/src/core/arm/skyeye_common/armstate.h b/src/core/arm/skyeye_common/armstate.h
index 3ba0ba5cd..041e65ccc 100644
--- a/src/core/arm/skyeye_common/armstate.h
+++ b/src/core/arm/skyeye_common/armstate.h
@@ -37,67 +37,30 @@ enum {
37 INSTCACHE = 2, 37 INSTCACHE = 2,
38}; 38};
39 39
40#define VFP_REG_NUM 64 40// ARM privilege modes
41struct ARMul_State 41enum PrivilegeMode {
42{ 42 USER32MODE = 16,
43 u32 Emulate; // To start and stop emulation 43 FIQ32MODE = 17,
44 44 IRQ32MODE = 18,
45 // Order of the following register should not be modified 45 SVC32MODE = 19,
46 u32 Reg[16]; // The current register file 46 ABORT32MODE = 23,
47 u32 Cpsr; // The current PSR 47 UNDEF32MODE = 27,
48 u32 Spsr_copy; 48 SYSTEM32MODE = 31
49 u32 phys_pc;
50 u32 Reg_usr[2];
51 u32 Reg_svc[2]; // R13_SVC R14_SVC
52 u32 Reg_abort[2]; // R13_ABORT R14_ABORT
53 u32 Reg_undef[2]; // R13 UNDEF R14 UNDEF
54 u32 Reg_irq[2]; // R13_IRQ R14_IRQ
55 u32 Reg_firq[7]; // R8---R14 FIRQ
56 u32 Spsr[7]; // The exception psr's
57 u32 Mode; // The current mode
58 u32 Bank; // The current register bank
59 u32 exclusive_tag; // The address for which the local monitor is in exclusive access mode
60 u32 exclusive_state;
61 u32 exclusive_result;
62 u32 CP15[CP15_REGISTER_COUNT];
63
64 // FPSID, FPSCR, and FPEXC
65 u32 VFP[VFP_SYSTEM_REGISTER_COUNT];
66 // VFPv2 and VFPv3-D16 has 16 doubleword registers (D0-D16 or S0-S31).
67 // VFPv3-D32/ASIMD may have up to 32 doubleword registers (D0-D31),
68 // and only 32 singleword registers are accessible (S0-S31).
69 u32 ExtReg[VFP_REG_NUM];
70 /* ---- End of the ordered registers ---- */
71
72 u32 NFlag, ZFlag, CFlag, VFlag, IFFlags; // Dummy flags for speed
73 unsigned int shifter_carry_out;
74
75 // Add armv6 flags dyf:2010-08-09
76 u32 GEFlag, EFlag, AFlag, QFlag;
77
78 u32 TFlag; // Thumb state
79
80 unsigned long long NumInstrs; // The number of instructions executed
81 unsigned NumInstrsToExecute;
82
83 unsigned NresetSig; // Reset the processor
84 unsigned NfiqSig;
85 unsigned NirqSig;
86
87 unsigned abortSig;
88 unsigned NtransSig;
89 unsigned bigendSig;
90 unsigned syscallSig;
91
92 // TODO(bunnei): Move this cache to a better place - it should be per codeset (likely per
93 // process for our purposes), not per ARMul_State (which tracks CPU core state).
94 std::unordered_map<u32, int> instruction_cache;
95}; 49};
96 50
97/***************************************************************************\ 51// ARM privilege mode register banks
98* The hardware vector addresses * 52enum {
99\***************************************************************************/ 53 USERBANK = 0,
54 FIQBANK = 1,
55 IRQBANK = 2,
56 SVCBANK = 3,
57 ABORTBANK = 4,
58 UNDEFBANK = 5,
59 DUMMYBANK = 6,
60 SYSTEMBANK = 7
61};
100 62
63// Hardware vector addresses
101enum { 64enum {
102 ARMResetV = 0, 65 ARMResetV = 0,
103 ARMUndefinedInstrV = 4, 66 ARMUndefinedInstrV = 4,
@@ -119,40 +82,7 @@ enum {
119 ARMul_FIQV = ARMFIQV 82 ARMul_FIQV = ARMFIQV
120}; 83};
121 84
122/***************************************************************************\ 85// Coprocessor status values
123* Mode and Bank Constants *
124\***************************************************************************/
125
126enum PrivilegeMode {
127 USER32MODE = 16,
128 FIQ32MODE = 17,
129 IRQ32MODE = 18,
130 SVC32MODE = 19,
131 ABORT32MODE = 23,
132 UNDEF32MODE = 27,
133 SYSTEM32MODE = 31
134};
135
136enum {
137 USERBANK = 0,
138 FIQBANK = 1,
139 IRQBANK = 2,
140 SVCBANK = 3,
141 ABORTBANK = 4,
142 UNDEFBANK = 5,
143 DUMMYBANK = 6,
144 SYSTEMBANK = 7
145};
146
147/***************************************************************************\
148* Definitions of things in the emulator *
149\***************************************************************************/
150void ARMul_Reset(ARMul_State* state);
151
152/***************************************************************************\
153* Definitions of things in the co-processor interface *
154\***************************************************************************/
155
156enum { 86enum {
157 ARMul_FIRST = 0, 87 ARMul_FIRST = 0,
158 ARMul_TRANSFER = 1, 88 ARMul_TRANSFER = 1,
@@ -164,10 +94,7 @@ enum {
164 ARMul_INC = 3 94 ARMul_INC = 3
165}; 95};
166 96
167/***************************************************************************\ 97// Instruction condition codes
168* Definitions of things in the host environment *
169\***************************************************************************/
170
171enum ConditionCode { 98enum ConditionCode {
172 EQ = 0, 99 EQ = 0,
173 NE = 1, 100 NE = 1,
@@ -213,3 +140,93 @@ enum {
213 ONCE = 2, // Execute just one iteration 140 ONCE = 2, // Execute just one iteration
214 RUN = 3 // Continuous execution 141 RUN = 3 // Continuous execution
215}; 142};
143
144#define VFP_REG_NUM 64
145struct ARMul_State final
146{
147public:
148 explicit ARMul_State(PrivilegeMode initial_mode);
149
150 void ChangePrivilegeMode(u32 new_mode);
151 void Reset();
152
153 // Reads/writes data in big/little endian format based on the
154 // state of the E (endian) bit in the APSR.
155 u16 ReadMemory16(u32 address) const;
156 u32 ReadMemory32(u32 address) const;
157 u64 ReadMemory64(u32 address) const;
158 void WriteMemory16(u32 address, u16 data);
159 void WriteMemory32(u32 address, u32 data);
160 void WriteMemory64(u32 address, u64 data);
161
162 u32 ReadCP15Register(u32 crn, u32 opcode_1, u32 crm, u32 opcode_2) const;
163 void WriteCP15Register(u32 value, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2);
164
165 // Whether or not the given CPU is in big endian mode (E bit is set)
166 bool InBigEndianMode() const {
167 return (Cpsr & (1 << 9)) != 0;
168 }
169 // Whether or not the given CPU is in a mode other than user mode.
170 bool InAPrivilegedMode() const {
171 return (Mode != USER32MODE);
172 }
173 // Note that for the 3DS, a Thumb instruction will only ever be
174 // two bytes in size. Thus we don't need to worry about ThumbEE
175 // or Thumb-2 where instructions can be 4 bytes in length.
176 u32 GetInstructionSize() const {
177 return TFlag ? 2 : 4;
178 }
179
180 u32 Emulate; // To start and stop emulation
181
182 // Order of the following register should not be modified
183 u32 Reg[16]; // The current register file
184 u32 Cpsr; // The current PSR
185 u32 Spsr_copy;
186 u32 phys_pc;
187 u32 Reg_usr[2];
188 u32 Reg_svc[2]; // R13_SVC R14_SVC
189 u32 Reg_abort[2]; // R13_ABORT R14_ABORT
190 u32 Reg_undef[2]; // R13 UNDEF R14 UNDEF
191 u32 Reg_irq[2]; // R13_IRQ R14_IRQ
192 u32 Reg_firq[7]; // R8---R14 FIRQ
193 u32 Spsr[7]; // The exception psr's
194 u32 Mode; // The current mode
195 u32 Bank; // The current register bank
196 u32 exclusive_tag; // The address for which the local monitor is in exclusive access mode
197 u32 exclusive_state;
198 u32 exclusive_result;
199 u32 CP15[CP15_REGISTER_COUNT];
200
201 // FPSID, FPSCR, and FPEXC
202 u32 VFP[VFP_SYSTEM_REGISTER_COUNT];
203 // VFPv2 and VFPv3-D16 has 16 doubleword registers (D0-D16 or S0-S31).
204 // VFPv3-D32/ASIMD may have up to 32 doubleword registers (D0-D31),
205 // and only 32 singleword registers are accessible (S0-S31).
206 u32 ExtReg[VFP_REG_NUM];
207 /* ---- End of the ordered registers ---- */
208
209 u32 NFlag, ZFlag, CFlag, VFlag, IFFlags; // Dummy flags for speed
210 unsigned int shifter_carry_out;
211
212 u32 TFlag; // Thumb state
213
214 unsigned long long NumInstrs; // The number of instructions executed
215 unsigned NumInstrsToExecute;
216
217 unsigned NresetSig; // Reset the processor
218 unsigned NfiqSig;
219 unsigned NirqSig;
220
221 unsigned abortSig;
222 unsigned NtransSig;
223 unsigned bigendSig;
224 unsigned syscallSig;
225
226 // TODO(bunnei): Move this cache to a better place - it should be per codeset (likely per
227 // process for our purposes), not per ARMul_State (which tracks CPU core state).
228 std::unordered_map<u32, int> instruction_cache;
229
230private:
231 void ResetMPCoreCP15Registers();
232};
diff --git a/src/core/arm/skyeye_common/armsupp.cpp b/src/core/arm/skyeye_common/armsupp.cpp
index affbf193a..d31fb9449 100644
--- a/src/core/arm/skyeye_common/armsupp.cpp
+++ b/src/core/arm/skyeye_common/armsupp.cpp
@@ -206,433 +206,3 @@ u32 ARMul_UnsignedSatQ(s32 value, u8 shift, bool* saturation_occurred)
206 *saturation_occurred = false; 206 *saturation_occurred = false;
207 return (u32)value; 207 return (u32)value;
208} 208}
209
210// Whether or not the given CPU is in big endian mode (E bit is set)
211bool InBigEndianMode(ARMul_State* cpu)
212{
213 return (cpu->Cpsr & (1 << 9)) != 0;
214}
215
216// Whether or not the given CPU is in a mode other than user mode.
217bool InAPrivilegedMode(ARMul_State* cpu)
218{
219 return (cpu->Mode != USER32MODE);
220}
221
222// Reads from the CP15 registers. Used with implementation of the MRC instruction.
223// Note that since the 3DS does not have the hypervisor extensions, these registers
224// are not implemented.
225u32 ReadCP15Register(ARMul_State* cpu, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2)
226{
227 // Unprivileged registers
228 if (crn == 13 && opcode_1 == 0 && crm == 0)
229 {
230 if (opcode_2 == 2)
231 return cpu->CP15[CP15_THREAD_UPRW];
232
233 if (opcode_2 == 3)
234 return cpu->CP15[CP15_THREAD_URO];
235 }
236
237 if (InAPrivilegedMode(cpu))
238 {
239 if (crn == 0 && opcode_1 == 0)
240 {
241 if (crm == 0)
242 {
243 if (opcode_2 == 0)
244 return cpu->CP15[CP15_MAIN_ID];
245
246 if (opcode_2 == 1)
247 return cpu->CP15[CP15_CACHE_TYPE];
248
249 if (opcode_2 == 3)
250 return cpu->CP15[CP15_TLB_TYPE];
251
252 if (opcode_2 == 5)
253 return cpu->CP15[CP15_CPU_ID];
254 }
255 else if (crm == 1)
256 {
257 if (opcode_2 == 0)
258 return cpu->CP15[CP15_PROCESSOR_FEATURE_0];
259
260 if (opcode_2 == 1)
261 return cpu->CP15[CP15_PROCESSOR_FEATURE_1];
262
263 if (opcode_2 == 2)
264 return cpu->CP15[CP15_DEBUG_FEATURE_0];
265
266 if (opcode_2 == 4)
267 return cpu->CP15[CP15_MEMORY_MODEL_FEATURE_0];
268
269 if (opcode_2 == 5)
270 return cpu->CP15[CP15_MEMORY_MODEL_FEATURE_1];
271
272 if (opcode_2 == 6)
273 return cpu->CP15[CP15_MEMORY_MODEL_FEATURE_2];
274
275 if (opcode_2 == 7)
276 return cpu->CP15[CP15_MEMORY_MODEL_FEATURE_3];
277 }
278 else if (crm == 2)
279 {
280 if (opcode_2 == 0)
281 return cpu->CP15[CP15_ISA_FEATURE_0];
282
283 if (opcode_2 == 1)
284 return cpu->CP15[CP15_ISA_FEATURE_1];
285
286 if (opcode_2 == 2)
287 return cpu->CP15[CP15_ISA_FEATURE_2];
288
289 if (opcode_2 == 3)
290 return cpu->CP15[CP15_ISA_FEATURE_3];
291
292 if (opcode_2 == 4)
293 return cpu->CP15[CP15_ISA_FEATURE_4];
294 }
295 }
296
297 if (crn == 1 && opcode_1 == 0 && crm == 0)
298 {
299 if (opcode_2 == 0)
300 return cpu->CP15[CP15_CONTROL];
301
302 if (opcode_2 == 1)
303 return cpu->CP15[CP15_AUXILIARY_CONTROL];
304
305 if (opcode_2 == 2)
306 return cpu->CP15[CP15_COPROCESSOR_ACCESS_CONTROL];
307 }
308
309 if (crn == 2 && opcode_1 == 0 && crm == 0)
310 {
311 if (opcode_2 == 0)
312 return cpu->CP15[CP15_TRANSLATION_BASE_TABLE_0];
313
314 if (opcode_2 == 1)
315 return cpu->CP15[CP15_TRANSLATION_BASE_TABLE_1];
316
317 if (opcode_2 == 2)
318 return cpu->CP15[CP15_TRANSLATION_BASE_CONTROL];
319 }
320
321 if (crn == 3 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
322 return cpu->CP15[CP15_DOMAIN_ACCESS_CONTROL];
323
324 if (crn == 5 && opcode_1 == 0 && crm == 0)
325 {
326 if (opcode_2 == 0)
327 return cpu->CP15[CP15_FAULT_STATUS];
328
329 if (opcode_2 == 1)
330 return cpu->CP15[CP15_INSTR_FAULT_STATUS];
331 }
332
333 if (crn == 6 && opcode_1 == 0 && crm == 0)
334 {
335 if (opcode_2 == 0)
336 return cpu->CP15[CP15_FAULT_ADDRESS];
337
338 if (opcode_2 == 1)
339 return cpu->CP15[CP15_WFAR];
340 }
341
342 if (crn == 7 && opcode_1 == 0 && crm == 4 && opcode_2 == 0)
343 return cpu->CP15[CP15_PHYS_ADDRESS];
344
345 if (crn == 9 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
346 return cpu->CP15[CP15_DATA_CACHE_LOCKDOWN];
347
348 if (crn == 10 && opcode_1 == 0)
349 {
350 if (crm == 0 && opcode_2 == 0)
351 return cpu->CP15[CP15_TLB_LOCKDOWN];
352
353 if (crm == 2)
354 {
355 if (opcode_2 == 0)
356 return cpu->CP15[CP15_PRIMARY_REGION_REMAP];
357
358 if (opcode_2 == 1)
359 return cpu->CP15[CP15_NORMAL_REGION_REMAP];
360 }
361 }
362
363 if (crn == 13 && crm == 0)
364 {
365 if (opcode_2 == 0)
366 return cpu->CP15[CP15_PID];
367
368 if (opcode_2 == 1)
369 return cpu->CP15[CP15_CONTEXT_ID];
370
371 if (opcode_2 == 4)
372 return cpu->CP15[CP15_THREAD_PRW];
373 }
374
375 if (crn == 15)
376 {
377 if (opcode_1 == 0 && crm == 12)
378 {
379 if (opcode_2 == 0)
380 return cpu->CP15[CP15_PERFORMANCE_MONITOR_CONTROL];
381
382 if (opcode_2 == 1)
383 return cpu->CP15[CP15_CYCLE_COUNTER];
384
385 if (opcode_2 == 2)
386 return cpu->CP15[CP15_COUNT_0];
387
388 if (opcode_2 == 3)
389 return cpu->CP15[CP15_COUNT_1];
390 }
391
392 if (opcode_1 == 5 && opcode_2 == 2)
393 {
394 if (crm == 5)
395 return cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_VIRT_ADDRESS];
396
397 if (crm == 6)
398 return cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_PHYS_ADDRESS];
399
400 if (crm == 7)
401 return cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_ATTRIBUTE];
402 }
403
404 if (opcode_1 == 7 && crm == 1 && opcode_2 == 0)
405 return cpu->CP15[CP15_TLB_DEBUG_CONTROL];
406 }
407 }
408
409 LOG_ERROR(Core_ARM11, "MRC CRn=%u, CRm=%u, OP1=%u OP2=%u is not implemented. Returning zero.", crn, crm, opcode_1, opcode_2);
410 return 0;
411}
412
413// Write to the CP15 registers. Used with implementation of the MCR instruction.
414// Note that since the 3DS does not have the hypervisor extensions, these registers
415// are not implemented.
416void WriteCP15Register(ARMul_State* cpu, u32 value, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2)
417{
418 if (InAPrivilegedMode(cpu))
419 {
420 if (crn == 1 && opcode_1 == 0 && crm == 0)
421 {
422 if (opcode_2 == 0)
423 cpu->CP15[CP15_CONTROL] = value;
424 else if (opcode_2 == 1)
425 cpu->CP15[CP15_AUXILIARY_CONTROL] = value;
426 else if (opcode_2 == 2)
427 cpu->CP15[CP15_COPROCESSOR_ACCESS_CONTROL] = value;
428 }
429 else if (crn == 2 && opcode_1 == 0 && crm == 0)
430 {
431 if (opcode_2 == 0)
432 cpu->CP15[CP15_TRANSLATION_BASE_TABLE_0] = value;
433 else if (opcode_2 == 1)
434 cpu->CP15[CP15_TRANSLATION_BASE_TABLE_1] = value;
435 else if (opcode_2 == 2)
436 cpu->CP15[CP15_TRANSLATION_BASE_CONTROL] = value;
437 }
438 else if (crn == 3 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
439 {
440 cpu->CP15[CP15_DOMAIN_ACCESS_CONTROL] = value;
441 }
442 else if (crn == 5 && opcode_1 == 0 && crm == 0)
443 {
444 if (opcode_2 == 0)
445 cpu->CP15[CP15_FAULT_STATUS] = value;
446 else if (opcode_2 == 1)
447 cpu->CP15[CP15_INSTR_FAULT_STATUS] = value;
448 }
449 else if (crn == 6 && opcode_1 == 0 && crm == 0)
450 {
451 if (opcode_2 == 0)
452 cpu->CP15[CP15_FAULT_ADDRESS] = value;
453 else if (opcode_2 == 1)
454 cpu->CP15[CP15_WFAR] = value;
455 }
456 else if (crn == 7 && opcode_1 == 0)
457 {
458 if (crm == 0 && opcode_2 == 4)
459 {
460 cpu->CP15[CP15_WAIT_FOR_INTERRUPT] = value;
461 }
462 else if (crm == 4 && opcode_2 == 0)
463 {
464 // NOTE: Not entirely accurate. This should do permission checks.
465 cpu->CP15[CP15_PHYS_ADDRESS] = Memory::VirtualToPhysicalAddress(value);
466 }
467 else if (crm == 5)
468 {
469 if (opcode_2 == 0)
470 cpu->CP15[CP15_INVALIDATE_INSTR_CACHE] = value;
471 else if (opcode_2 == 1)
472 cpu->CP15[CP15_INVALIDATE_INSTR_CACHE_USING_MVA] = value;
473 else if (opcode_2 == 2)
474 cpu->CP15[CP15_INVALIDATE_INSTR_CACHE_USING_INDEX] = value;
475 else if (opcode_2 == 6)
476 cpu->CP15[CP15_FLUSH_BRANCH_TARGET_CACHE] = value;
477 else if (opcode_2 == 7)
478 cpu->CP15[CP15_FLUSH_BRANCH_TARGET_CACHE_ENTRY] = value;
479 }
480 else if (crm == 6)
481 {
482 if (opcode_2 == 0)
483 cpu->CP15[CP15_INVALIDATE_DATA_CACHE] = value;
484 else if (opcode_2 == 1)
485 cpu->CP15[CP15_INVALIDATE_DATA_CACHE_LINE_USING_MVA] = value;
486 else if (opcode_2 == 2)
487 cpu->CP15[CP15_INVALIDATE_DATA_CACHE_LINE_USING_INDEX] = value;
488 }
489 else if (crm == 7 && opcode_2 == 0)
490 {
491 cpu->CP15[CP15_INVALIDATE_DATA_AND_INSTR_CACHE] = value;
492 }
493 else if (crm == 10)
494 {
495 if (opcode_2 == 0)
496 cpu->CP15[CP15_CLEAN_DATA_CACHE] = value;
497 else if (opcode_2 == 1)
498 cpu->CP15[CP15_CLEAN_DATA_CACHE_LINE_USING_MVA] = value;
499 else if (opcode_2 == 2)
500 cpu->CP15[CP15_CLEAN_DATA_CACHE_LINE_USING_INDEX] = value;
501 }
502 else if (crm == 14)
503 {
504 if (opcode_2 == 0)
505 cpu->CP15[CP15_CLEAN_AND_INVALIDATE_DATA_CACHE] = value;
506 else if (opcode_2 == 1)
507 cpu->CP15[CP15_CLEAN_AND_INVALIDATE_DATA_CACHE_LINE_USING_MVA] = value;
508 else if (opcode_2 == 2)
509 cpu->CP15[CP15_CLEAN_AND_INVALIDATE_DATA_CACHE_LINE_USING_INDEX] = value;
510 }
511 }
512 else if (crn == 8 && opcode_1 == 0)
513 {
514 LOG_WARNING(Core_ARM11, "TLB operations not fully implemented.");
515
516 if (crm == 5)
517 {
518 if (opcode_2 == 0)
519 cpu->CP15[CP15_INVALIDATE_ITLB] = value;
520 else if (opcode_2 == 1)
521 cpu->CP15[CP15_INVALIDATE_ITLB_SINGLE_ENTRY] = value;
522 else if (opcode_2 == 2)
523 cpu->CP15[CP15_INVALIDATE_ITLB_ENTRY_ON_ASID_MATCH] = value;
524 else if (opcode_2 == 3)
525 cpu->CP15[CP15_INVALIDATE_ITLB_ENTRY_ON_MVA] = value;
526 }
527 else if (crm == 6)
528 {
529 if (opcode_2 == 0)
530 cpu->CP15[CP15_INVALIDATE_DTLB] = value;
531 else if (opcode_2 == 1)
532 cpu->CP15[CP15_INVALIDATE_DTLB_SINGLE_ENTRY] = value;
533 else if (opcode_2 == 2)
534 cpu->CP15[CP15_INVALIDATE_DTLB_ENTRY_ON_ASID_MATCH] = value;
535 else if (opcode_2 == 3)
536 cpu->CP15[CP15_INVALIDATE_DTLB_ENTRY_ON_MVA] = value;
537 }
538 else if (crm == 7)
539 {
540 if (opcode_2 == 0)
541 cpu->CP15[CP15_INVALIDATE_UTLB] = value;
542 else if (opcode_2 == 1)
543 cpu->CP15[CP15_INVALIDATE_UTLB_SINGLE_ENTRY] = value;
544 else if (opcode_2 == 2)
545 cpu->CP15[CP15_INVALIDATE_UTLB_ENTRY_ON_ASID_MATCH] = value;
546 else if (opcode_2 == 3)
547 cpu->CP15[CP15_INVALIDATE_UTLB_ENTRY_ON_MVA] = value;
548 }
549 }
550 else if (crn == 9 && opcode_1 == 0 && crm == 0 && opcode_2 == 0)
551 {
552 cpu->CP15[CP15_DATA_CACHE_LOCKDOWN] = value;
553 }
554 else if (crn == 10 && opcode_1 == 0)
555 {
556 if (crm == 0 && opcode_2 == 0)
557 {
558 cpu->CP15[CP15_TLB_LOCKDOWN] = value;
559 }
560 else if (crm == 2)
561 {
562 if (opcode_2 == 0)
563 cpu->CP15[CP15_PRIMARY_REGION_REMAP] = value;
564 else if (opcode_2 == 1)
565 cpu->CP15[CP15_NORMAL_REGION_REMAP] = value;
566 }
567 }
568 else if (crn == 13 && opcode_1 == 0 && crm == 0)
569 {
570 if (opcode_2 == 0)
571 cpu->CP15[CP15_PID] = value;
572 else if (opcode_2 == 1)
573 cpu->CP15[CP15_CONTEXT_ID] = value;
574 else if (opcode_2 == 3)
575 cpu->CP15[CP15_THREAD_URO] = value;
576 else if (opcode_2 == 4)
577 cpu->CP15[CP15_THREAD_PRW] = value;
578 }
579 else if (crn == 15)
580 {
581 if (opcode_1 == 0 && crm == 12)
582 {
583 if (opcode_2 == 0)
584 cpu->CP15[CP15_PERFORMANCE_MONITOR_CONTROL] = value;
585 else if (opcode_2 == 1)
586 cpu->CP15[CP15_CYCLE_COUNTER] = value;
587 else if (opcode_2 == 2)
588 cpu->CP15[CP15_COUNT_0] = value;
589 else if (opcode_2 == 3)
590 cpu->CP15[CP15_COUNT_1] = value;
591 }
592 else if (opcode_1 == 5)
593 {
594 if (crm == 4)
595 {
596 if (opcode_2 == 2)
597 cpu->CP15[CP15_READ_MAIN_TLB_LOCKDOWN_ENTRY] = value;
598 else if (opcode_2 == 4)
599 cpu->CP15[CP15_WRITE_MAIN_TLB_LOCKDOWN_ENTRY] = value;
600 }
601 else if (crm == 5 && opcode_2 == 2)
602 {
603 cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_VIRT_ADDRESS] = value;
604 }
605 else if (crm == 6 && opcode_2 == 2)
606 {
607 cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_PHYS_ADDRESS] = value;
608 }
609 else if (crm == 7 && opcode_2 == 2)
610 {
611 cpu->CP15[CP15_MAIN_TLB_LOCKDOWN_ATTRIBUTE] = value;
612 }
613 }
614 else if (opcode_1 == 7 && crm == 1 && opcode_2 == 0)
615 {
616 cpu->CP15[CP15_TLB_DEBUG_CONTROL] = value;
617 }
618 }
619 }
620
621 // Unprivileged registers
622 if (crn == 7 && opcode_1 == 0 && crm == 5 && opcode_2 == 4)
623 {
624 cpu->CP15[CP15_FLUSH_PREFETCH_BUFFER] = value;
625 }
626 else if (crn == 7 && opcode_1 == 0 && crm == 10)
627 {
628 if (opcode_2 == 4)
629 cpu->CP15[CP15_DATA_SYNC_BARRIER] = value;
630 else if (opcode_2 == 5)
631 cpu->CP15[CP15_DATA_MEMORY_BARRIER] = value;
632
633 }
634 else if (crn == 13 && opcode_1 == 0 && crm == 0 && opcode_2 == 2)
635 {
636 cpu->CP15[CP15_THREAD_UPRW] = value;
637 }
638}
diff --git a/src/core/arm/skyeye_common/armsupp.h b/src/core/arm/skyeye_common/armsupp.h
index 5cf1cd1d3..391309fa8 100644
--- a/src/core/arm/skyeye_common/armsupp.h
+++ b/src/core/arm/skyeye_common/armsupp.h
@@ -6,8 +6,6 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8 8
9struct ARMul_State;
10
11#define BITS(s, a, b) ((s << ((sizeof(s) * 8 - 1) - b)) >> (sizeof(s) * 8 - b + a - 1)) 9#define BITS(s, a, b) ((s << ((sizeof(s) * 8 - 1) - b)) >> (sizeof(s) * 8 - b + a - 1))
12#define BIT(s, n) ((s >> (n)) & 1) 10#define BIT(s, n) ((s >> (n)) & 1)
13 11
@@ -32,9 +30,3 @@ u16 ARMul_UnsignedSaturatedSub16(u16, u16);
32u8 ARMul_UnsignedAbsoluteDifference(u8, u8); 30u8 ARMul_UnsignedAbsoluteDifference(u8, u8);
33u32 ARMul_SignedSatQ(s32, u8, bool*); 31u32 ARMul_SignedSatQ(s32, u8, bool*);
34u32 ARMul_UnsignedSatQ(s32, u8, bool*); 32u32 ARMul_UnsignedSatQ(s32, u8, bool*);
35
36bool InBigEndianMode(ARMul_State*);
37bool InAPrivilegedMode(ARMul_State*);
38
39u32 ReadCP15Register(ARMul_State* cpu, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2);
40void WriteCP15Register(ARMul_State* cpu, u32 value, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2);
diff --git a/src/core/arm/skyeye_common/vfp/vfpinstr.cpp b/src/core/arm/skyeye_common/vfp/vfpinstr.cpp
index 8efcbab1c..9b99fc5bc 100644
--- a/src/core/arm/skyeye_common/vfp/vfpinstr.cpp
+++ b/src/core/arm/skyeye_common/vfp/vfpinstr.cpp
@@ -51,7 +51,7 @@ VMLA_INST:
51 51
52 CHECK_VFP_CDP_RET; 52 CHECK_VFP_CDP_RET;
53 } 53 }
54 cpu->Reg[15] += GET_INST_SIZE(cpu); 54 cpu->Reg[15] += cpu->GetInstructionSize();
55 INC_PC(sizeof(vmla_inst)); 55 INC_PC(sizeof(vmla_inst));
56 FETCH_INST; 56 FETCH_INST;
57 GOTO_NEXT_INST; 57 GOTO_NEXT_INST;
@@ -100,7 +100,7 @@ VMLS_INST:
100 100
101 CHECK_VFP_CDP_RET; 101 CHECK_VFP_CDP_RET;
102 } 102 }
103 cpu->Reg[15] += GET_INST_SIZE(cpu); 103 cpu->Reg[15] += cpu->GetInstructionSize();
104 INC_PC(sizeof(vmls_inst)); 104 INC_PC(sizeof(vmls_inst));
105 FETCH_INST; 105 FETCH_INST;
106 GOTO_NEXT_INST; 106 GOTO_NEXT_INST;
@@ -149,7 +149,7 @@ VNMLA_INST:
149 149
150 CHECK_VFP_CDP_RET; 150 CHECK_VFP_CDP_RET;
151 } 151 }
152 cpu->Reg[15] += GET_INST_SIZE(cpu); 152 cpu->Reg[15] += cpu->GetInstructionSize();
153 INC_PC(sizeof(vnmla_inst)); 153 INC_PC(sizeof(vnmla_inst));
154 FETCH_INST; 154 FETCH_INST;
155 GOTO_NEXT_INST; 155 GOTO_NEXT_INST;
@@ -199,7 +199,7 @@ VNMLS_INST:
199 199
200 CHECK_VFP_CDP_RET; 200 CHECK_VFP_CDP_RET;
201 } 201 }
202 cpu->Reg[15] += GET_INST_SIZE(cpu); 202 cpu->Reg[15] += cpu->GetInstructionSize();
203 INC_PC(sizeof(vnmls_inst)); 203 INC_PC(sizeof(vnmls_inst));
204 FETCH_INST; 204 FETCH_INST;
205 GOTO_NEXT_INST; 205 GOTO_NEXT_INST;
@@ -248,7 +248,7 @@ VNMUL_INST:
248 248
249 CHECK_VFP_CDP_RET; 249 CHECK_VFP_CDP_RET;
250 } 250 }
251 cpu->Reg[15] += GET_INST_SIZE(cpu); 251 cpu->Reg[15] += cpu->GetInstructionSize();
252 INC_PC(sizeof(vnmul_inst)); 252 INC_PC(sizeof(vnmul_inst));
253 FETCH_INST; 253 FETCH_INST;
254 GOTO_NEXT_INST; 254 GOTO_NEXT_INST;
@@ -297,7 +297,7 @@ VMUL_INST:
297 297
298 CHECK_VFP_CDP_RET; 298 CHECK_VFP_CDP_RET;
299 } 299 }
300 cpu->Reg[15] += GET_INST_SIZE(cpu); 300 cpu->Reg[15] += cpu->GetInstructionSize();
301 INC_PC(sizeof(vmul_inst)); 301 INC_PC(sizeof(vmul_inst));
302 FETCH_INST; 302 FETCH_INST;
303 GOTO_NEXT_INST; 303 GOTO_NEXT_INST;
@@ -346,7 +346,7 @@ VADD_INST:
346 346
347 CHECK_VFP_CDP_RET; 347 CHECK_VFP_CDP_RET;
348 } 348 }
349 cpu->Reg[15] += GET_INST_SIZE(cpu); 349 cpu->Reg[15] += cpu->GetInstructionSize();
350 INC_PC(sizeof(vadd_inst)); 350 INC_PC(sizeof(vadd_inst));
351 FETCH_INST; 351 FETCH_INST;
352 GOTO_NEXT_INST; 352 GOTO_NEXT_INST;
@@ -395,7 +395,7 @@ VSUB_INST:
395 395
396 CHECK_VFP_CDP_RET; 396 CHECK_VFP_CDP_RET;
397 } 397 }
398 cpu->Reg[15] += GET_INST_SIZE(cpu); 398 cpu->Reg[15] += cpu->GetInstructionSize();
399 INC_PC(sizeof(vsub_inst)); 399 INC_PC(sizeof(vsub_inst));
400 FETCH_INST; 400 FETCH_INST;
401 GOTO_NEXT_INST; 401 GOTO_NEXT_INST;
@@ -444,7 +444,7 @@ VDIV_INST:
444 444
445 CHECK_VFP_CDP_RET; 445 CHECK_VFP_CDP_RET;
446 } 446 }
447 cpu->Reg[15] += GET_INST_SIZE(cpu); 447 cpu->Reg[15] += cpu->GetInstructionSize();
448 INC_PC(sizeof(vdiv_inst)); 448 INC_PC(sizeof(vdiv_inst));
449 FETCH_INST; 449 FETCH_INST;
450 GOTO_NEXT_INST; 450 GOTO_NEXT_INST;
@@ -492,7 +492,7 @@ VMOVI_INST:
492 492
493 VMOVI(cpu, inst_cream->single, inst_cream->d, inst_cream->imm); 493 VMOVI(cpu, inst_cream->single, inst_cream->d, inst_cream->imm);
494 } 494 }
495 cpu->Reg[15] += GET_INST_SIZE(cpu); 495 cpu->Reg[15] += cpu->GetInstructionSize();
496 INC_PC(sizeof(vmovi_inst)); 496 INC_PC(sizeof(vmovi_inst));
497 FETCH_INST; 497 FETCH_INST;
498 GOTO_NEXT_INST; 498 GOTO_NEXT_INST;
@@ -536,7 +536,7 @@ VMOVR_INST:
536 536
537 VMOVR(cpu, inst_cream->single, inst_cream->d, inst_cream->m); 537 VMOVR(cpu, inst_cream->single, inst_cream->d, inst_cream->m);
538 } 538 }
539 cpu->Reg[15] += GET_INST_SIZE(cpu); 539 cpu->Reg[15] += cpu->GetInstructionSize();
540 INC_PC(sizeof(vmovr_inst)); 540 INC_PC(sizeof(vmovr_inst));
541 FETCH_INST; 541 FETCH_INST;
542 GOTO_NEXT_INST; 542 GOTO_NEXT_INST;
@@ -585,7 +585,7 @@ VABS_INST:
585 585
586 CHECK_VFP_CDP_RET; 586 CHECK_VFP_CDP_RET;
587 } 587 }
588 cpu->Reg[15] += GET_INST_SIZE(cpu); 588 cpu->Reg[15] += cpu->GetInstructionSize();
589 INC_PC(sizeof(vabs_inst)); 589 INC_PC(sizeof(vabs_inst));
590 FETCH_INST; 590 FETCH_INST;
591 GOTO_NEXT_INST; 591 GOTO_NEXT_INST;
@@ -635,7 +635,7 @@ VNEG_INST:
635 635
636 CHECK_VFP_CDP_RET; 636 CHECK_VFP_CDP_RET;
637 } 637 }
638 cpu->Reg[15] += GET_INST_SIZE(cpu); 638 cpu->Reg[15] += cpu->GetInstructionSize();
639 INC_PC(sizeof(vneg_inst)); 639 INC_PC(sizeof(vneg_inst));
640 FETCH_INST; 640 FETCH_INST;
641 GOTO_NEXT_INST; 641 GOTO_NEXT_INST;
@@ -684,7 +684,7 @@ VSQRT_INST:
684 684
685 CHECK_VFP_CDP_RET; 685 CHECK_VFP_CDP_RET;
686 } 686 }
687 cpu->Reg[15] += GET_INST_SIZE(cpu); 687 cpu->Reg[15] += cpu->GetInstructionSize();
688 INC_PC(sizeof(vsqrt_inst)); 688 INC_PC(sizeof(vsqrt_inst));
689 FETCH_INST; 689 FETCH_INST;
690 GOTO_NEXT_INST; 690 GOTO_NEXT_INST;
@@ -733,7 +733,7 @@ VCMP_INST:
733 733
734 CHECK_VFP_CDP_RET; 734 CHECK_VFP_CDP_RET;
735 } 735 }
736 cpu->Reg[15] += GET_INST_SIZE(cpu); 736 cpu->Reg[15] += cpu->GetInstructionSize();
737 INC_PC(sizeof(vcmp_inst)); 737 INC_PC(sizeof(vcmp_inst));
738 FETCH_INST; 738 FETCH_INST;
739 GOTO_NEXT_INST; 739 GOTO_NEXT_INST;
@@ -782,7 +782,7 @@ VCMP2_INST:
782 782
783 CHECK_VFP_CDP_RET; 783 CHECK_VFP_CDP_RET;
784 } 784 }
785 cpu->Reg[15] += GET_INST_SIZE(cpu); 785 cpu->Reg[15] += cpu->GetInstructionSize();
786 INC_PC(sizeof(vcmp2_inst)); 786 INC_PC(sizeof(vcmp2_inst));
787 FETCH_INST; 787 FETCH_INST;
788 GOTO_NEXT_INST; 788 GOTO_NEXT_INST;
@@ -831,7 +831,7 @@ VCVTBDS_INST:
831 831
832 CHECK_VFP_CDP_RET; 832 CHECK_VFP_CDP_RET;
833 } 833 }
834 cpu->Reg[15] += GET_INST_SIZE(cpu); 834 cpu->Reg[15] += cpu->GetInstructionSize();
835 INC_PC(sizeof(vcvtbds_inst)); 835 INC_PC(sizeof(vcvtbds_inst));
836 FETCH_INST; 836 FETCH_INST;
837 GOTO_NEXT_INST; 837 GOTO_NEXT_INST;
@@ -882,7 +882,7 @@ VCVTBFF_INST:
882 882
883 CHECK_VFP_CDP_RET; 883 CHECK_VFP_CDP_RET;
884 } 884 }
885 cpu->Reg[15] += GET_INST_SIZE(cpu); 885 cpu->Reg[15] += cpu->GetInstructionSize();
886 INC_PC(sizeof(vcvtbff_inst)); 886 INC_PC(sizeof(vcvtbff_inst));
887 FETCH_INST; 887 FETCH_INST;
888 GOTO_NEXT_INST; 888 GOTO_NEXT_INST;
@@ -931,7 +931,7 @@ VCVTBFI_INST:
931 931
932 CHECK_VFP_CDP_RET; 932 CHECK_VFP_CDP_RET;
933 } 933 }
934 cpu->Reg[15] += GET_INST_SIZE(cpu); 934 cpu->Reg[15] += cpu->GetInstructionSize();
935 INC_PC(sizeof(vcvtbfi_inst)); 935 INC_PC(sizeof(vcvtbfi_inst));
936 FETCH_INST; 936 FETCH_INST;
937 GOTO_NEXT_INST; 937 GOTO_NEXT_INST;
@@ -981,7 +981,7 @@ VMOVBRS_INST:
981 981
982 VMOVBRS(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->n, &(cpu->Reg[inst_cream->t])); 982 VMOVBRS(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->n, &(cpu->Reg[inst_cream->t]));
983 } 983 }
984 cpu->Reg[15] += GET_INST_SIZE(cpu); 984 cpu->Reg[15] += cpu->GetInstructionSize();
985 INC_PC(sizeof(vmovbrs_inst)); 985 INC_PC(sizeof(vmovbrs_inst));
986 FETCH_INST; 986 FETCH_INST;
987 GOTO_NEXT_INST; 987 GOTO_NEXT_INST;
@@ -1032,7 +1032,7 @@ VMSR_INST:
1032 { 1032 {
1033 cpu->VFP[VFP_FPSCR] = cpu->Reg[rt]; 1033 cpu->VFP[VFP_FPSCR] = cpu->Reg[rt];
1034 } 1034 }
1035 else if (InAPrivilegedMode(cpu)) 1035 else if (cpu->InAPrivilegedMode())
1036 { 1036 {
1037 if (reg == 8) 1037 if (reg == 8)
1038 cpu->VFP[VFP_FPEXC] = cpu->Reg[rt]; 1038 cpu->VFP[VFP_FPEXC] = cpu->Reg[rt];
@@ -1042,7 +1042,7 @@ VMSR_INST:
1042 cpu->VFP[VFP_FPINST2] = cpu->Reg[rt]; 1042 cpu->VFP[VFP_FPINST2] = cpu->Reg[rt];
1043 } 1043 }
1044 } 1044 }
1045 cpu->Reg[15] += GET_INST_SIZE(cpu); 1045 cpu->Reg[15] += cpu->GetInstructionSize();
1046 INC_PC(sizeof(vmsr_inst)); 1046 INC_PC(sizeof(vmsr_inst));
1047 FETCH_INST; 1047 FETCH_INST;
1048 GOTO_NEXT_INST; 1048 GOTO_NEXT_INST;
@@ -1090,7 +1090,7 @@ VMOVBRC_INST:
1090 1090
1091 cpu->ExtReg[(2 * inst_cream->d) + inst_cream->index] = cpu->Reg[inst_cream->t]; 1091 cpu->ExtReg[(2 * inst_cream->d) + inst_cream->index] = cpu->Reg[inst_cream->t];
1092 } 1092 }
1093 cpu->Reg[15] += GET_INST_SIZE(cpu); 1093 cpu->Reg[15] += cpu->GetInstructionSize();
1094 INC_PC(sizeof(vmovbrc_inst)); 1094 INC_PC(sizeof(vmovbrc_inst));
1095 FETCH_INST; 1095 FETCH_INST;
1096 GOTO_NEXT_INST; 1096 GOTO_NEXT_INST;
@@ -1163,7 +1163,7 @@ VMRS_INST:
1163 { 1163 {
1164 cpu->Reg[rt] = cpu->VFP[VFP_MVFR0]; 1164 cpu->Reg[rt] = cpu->VFP[VFP_MVFR0];
1165 } 1165 }
1166 else if (InAPrivilegedMode(cpu)) 1166 else if (cpu->InAPrivilegedMode())
1167 { 1167 {
1168 if (reg == 8) 1168 if (reg == 8)
1169 cpu->Reg[rt] = cpu->VFP[VFP_FPEXC]; 1169 cpu->Reg[rt] = cpu->VFP[VFP_FPEXC];
@@ -1173,7 +1173,7 @@ VMRS_INST:
1173 cpu->Reg[rt] = cpu->VFP[VFP_FPINST2]; 1173 cpu->Reg[rt] = cpu->VFP[VFP_FPINST2];
1174 } 1174 }
1175 } 1175 }
1176 cpu->Reg[15] += GET_INST_SIZE(cpu); 1176 cpu->Reg[15] += cpu->GetInstructionSize();
1177 INC_PC(sizeof(vmrs_inst)); 1177 INC_PC(sizeof(vmrs_inst));
1178 FETCH_INST; 1178 FETCH_INST;
1179 GOTO_NEXT_INST; 1179 GOTO_NEXT_INST;
@@ -1221,7 +1221,7 @@ VMOVBCR_INST:
1221 1221
1222 cpu->Reg[inst_cream->t] = cpu->ExtReg[(2 * inst_cream->d) + inst_cream->index]; 1222 cpu->Reg[inst_cream->t] = cpu->ExtReg[(2 * inst_cream->d) + inst_cream->index];
1223 } 1223 }
1224 cpu->Reg[15] += GET_INST_SIZE(cpu); 1224 cpu->Reg[15] += cpu->GetInstructionSize();
1225 INC_PC(sizeof(vmovbcr_inst)); 1225 INC_PC(sizeof(vmovbcr_inst));
1226 FETCH_INST; 1226 FETCH_INST;
1227 GOTO_NEXT_INST; 1227 GOTO_NEXT_INST;
@@ -1274,7 +1274,7 @@ VMOVBRRSS_INST:
1274 VMOVBRRSS(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m, 1274 VMOVBRRSS(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m,
1275 &cpu->Reg[inst_cream->t], &cpu->Reg[inst_cream->t2]); 1275 &cpu->Reg[inst_cream->t], &cpu->Reg[inst_cream->t2]);
1276 } 1276 }
1277 cpu->Reg[15] += GET_INST_SIZE(cpu); 1277 cpu->Reg[15] += cpu->GetInstructionSize();
1278 INC_PC(sizeof(vmovbrrss_inst)); 1278 INC_PC(sizeof(vmovbrrss_inst));
1279 FETCH_INST; 1279 FETCH_INST;
1280 GOTO_NEXT_INST; 1280 GOTO_NEXT_INST;
@@ -1322,7 +1322,7 @@ VMOVBRRD_INST:
1322 VMOVBRRD(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m, 1322 VMOVBRRD(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m,
1323 &(cpu->Reg[inst_cream->t]), &(cpu->Reg[inst_cream->t2])); 1323 &(cpu->Reg[inst_cream->t]), &(cpu->Reg[inst_cream->t2]));
1324 } 1324 }
1325 cpu->Reg[15] += GET_INST_SIZE(cpu); 1325 cpu->Reg[15] += cpu->GetInstructionSize();
1326 INC_PC(sizeof(vmovbrrd_inst)); 1326 INC_PC(sizeof(vmovbrrd_inst));
1327 FETCH_INST; 1327 FETCH_INST;
1328 GOTO_NEXT_INST; 1328 GOTO_NEXT_INST;
@@ -1378,23 +1378,23 @@ VSTR_INST:
1378 1378
1379 if (inst_cream->single) 1379 if (inst_cream->single)
1380 { 1380 {
1381 WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d]); 1381 cpu->WriteMemory32(addr, cpu->ExtReg[inst_cream->d]);
1382 } 1382 }
1383 else 1383 else
1384 { 1384 {
1385 const u32 word1 = cpu->ExtReg[inst_cream->d*2+0]; 1385 const u32 word1 = cpu->ExtReg[inst_cream->d*2+0];
1386 const u32 word2 = cpu->ExtReg[inst_cream->d*2+1]; 1386 const u32 word2 = cpu->ExtReg[inst_cream->d*2+1];
1387 1387
1388 if (InBigEndianMode(cpu)) { 1388 if (cpu->InBigEndianMode()) {
1389 WriteMemory32(cpu, addr + 0, word2); 1389 cpu->WriteMemory32(addr + 0, word2);
1390 WriteMemory32(cpu, addr + 4, word1); 1390 cpu->WriteMemory32(addr + 4, word1);
1391 } else { 1391 } else {
1392 WriteMemory32(cpu, addr + 0, word1); 1392 cpu->WriteMemory32(addr + 0, word1);
1393 WriteMemory32(cpu, addr + 4, word2); 1393 cpu->WriteMemory32(addr + 4, word2);
1394 } 1394 }
1395 } 1395 }
1396 } 1396 }
1397 cpu->Reg[15] += GET_INST_SIZE(cpu); 1397 cpu->Reg[15] += cpu->GetInstructionSize();
1398 INC_PC(sizeof(vstr_inst)); 1398 INC_PC(sizeof(vstr_inst));
1399 FETCH_INST; 1399 FETCH_INST;
1400 GOTO_NEXT_INST; 1400 GOTO_NEXT_INST;
@@ -1444,7 +1444,7 @@ VPUSH_INST:
1444 { 1444 {
1445 if (inst_cream->single) 1445 if (inst_cream->single)
1446 { 1446 {
1447 WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d+i]); 1447 cpu->WriteMemory32(addr, cpu->ExtReg[inst_cream->d+i]);
1448 addr += 4; 1448 addr += 4;
1449 } 1449 }
1450 else 1450 else
@@ -1452,12 +1452,12 @@ VPUSH_INST:
1452 const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0]; 1452 const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0];
1453 const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1]; 1453 const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1];
1454 1454
1455 if (InBigEndianMode(cpu)) { 1455 if (cpu->InBigEndianMode()) {
1456 WriteMemory32(cpu, addr + 0, word2); 1456 cpu->WriteMemory32(addr + 0, word2);
1457 WriteMemory32(cpu, addr + 4, word1); 1457 cpu->WriteMemory32(addr + 4, word1);
1458 } else { 1458 } else {
1459 WriteMemory32(cpu, addr + 0, word1); 1459 cpu->WriteMemory32(addr + 0, word1);
1460 WriteMemory32(cpu, addr + 4, word2); 1460 cpu->WriteMemory32(addr + 4, word2);
1461 } 1461 }
1462 1462
1463 addr += 8; 1463 addr += 8;
@@ -1466,7 +1466,7 @@ VPUSH_INST:
1466 1466
1467 cpu->Reg[R13] -= inst_cream->imm32; 1467 cpu->Reg[R13] -= inst_cream->imm32;
1468 } 1468 }
1469 cpu->Reg[15] += GET_INST_SIZE(cpu); 1469 cpu->Reg[15] += cpu->GetInstructionSize();
1470 INC_PC(sizeof(vpush_inst)); 1470 INC_PC(sizeof(vpush_inst));
1471 FETCH_INST; 1471 FETCH_INST;
1472 GOTO_NEXT_INST; 1472 GOTO_NEXT_INST;
@@ -1522,7 +1522,7 @@ VSTM_INST: /* encoding 1 */
1522 { 1522 {
1523 if (inst_cream->single) 1523 if (inst_cream->single)
1524 { 1524 {
1525 WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d+i]); 1525 cpu->WriteMemory32(addr, cpu->ExtReg[inst_cream->d+i]);
1526 addr += 4; 1526 addr += 4;
1527 } 1527 }
1528 else 1528 else
@@ -1530,12 +1530,12 @@ VSTM_INST: /* encoding 1 */
1530 const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0]; 1530 const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0];
1531 const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1]; 1531 const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1];
1532 1532
1533 if (InBigEndianMode(cpu)) { 1533 if (cpu->InBigEndianMode()) {
1534 WriteMemory32(cpu, addr + 0, word2); 1534 cpu->WriteMemory32(addr + 0, word2);
1535 WriteMemory32(cpu, addr + 4, word1); 1535 cpu->WriteMemory32(addr + 4, word1);
1536 } else { 1536 } else {
1537 WriteMemory32(cpu, addr + 0, word1); 1537 cpu->WriteMemory32(addr + 0, word1);
1538 WriteMemory32(cpu, addr + 4, word2); 1538 cpu->WriteMemory32(addr + 4, word2);
1539 } 1539 }
1540 1540
1541 addr += 8; 1541 addr += 8;
@@ -1597,15 +1597,15 @@ VPOP_INST:
1597 { 1597 {
1598 if (inst_cream->single) 1598 if (inst_cream->single)
1599 { 1599 {
1600 cpu->ExtReg[inst_cream->d+i] = ReadMemory32(cpu, addr); 1600 cpu->ExtReg[inst_cream->d+i] = cpu->ReadMemory32(addr);
1601 addr += 4; 1601 addr += 4;
1602 } 1602 }
1603 else 1603 else
1604 { 1604 {
1605 const u32 word1 = ReadMemory32(cpu, addr + 0); 1605 const u32 word1 = cpu->ReadMemory32(addr + 0);
1606 const u32 word2 = ReadMemory32(cpu, addr + 4); 1606 const u32 word2 = cpu->ReadMemory32(addr + 4);
1607 1607
1608 if (InBigEndianMode(cpu)) { 1608 if (cpu->InBigEndianMode()) {
1609 cpu->ExtReg[(inst_cream->d+i)*2+0] = word2; 1609 cpu->ExtReg[(inst_cream->d+i)*2+0] = word2;
1610 cpu->ExtReg[(inst_cream->d+i)*2+1] = word1; 1610 cpu->ExtReg[(inst_cream->d+i)*2+1] = word1;
1611 } else { 1611 } else {
@@ -1618,7 +1618,7 @@ VPOP_INST:
1618 } 1618 }
1619 cpu->Reg[R13] += inst_cream->imm32; 1619 cpu->Reg[R13] += inst_cream->imm32;
1620 } 1620 }
1621 cpu->Reg[15] += GET_INST_SIZE(cpu); 1621 cpu->Reg[15] += cpu->GetInstructionSize();
1622 INC_PC(sizeof(vpop_inst)); 1622 INC_PC(sizeof(vpop_inst));
1623 FETCH_INST; 1623 FETCH_INST;
1624 GOTO_NEXT_INST; 1624 GOTO_NEXT_INST;
@@ -1670,14 +1670,14 @@ VLDR_INST:
1670 1670
1671 if (inst_cream->single) 1671 if (inst_cream->single)
1672 { 1672 {
1673 cpu->ExtReg[inst_cream->d] = ReadMemory32(cpu, addr); 1673 cpu->ExtReg[inst_cream->d] = cpu->ReadMemory32(addr);
1674 } 1674 }
1675 else 1675 else
1676 { 1676 {
1677 const u32 word1 = ReadMemory32(cpu, addr + 0); 1677 const u32 word1 = cpu->ReadMemory32(addr + 0);
1678 const u32 word2 = ReadMemory32(cpu, addr + 4); 1678 const u32 word2 = cpu->ReadMemory32(addr + 4);
1679 1679
1680 if (InBigEndianMode(cpu)) { 1680 if (cpu->InBigEndianMode()) {
1681 cpu->ExtReg[inst_cream->d*2+0] = word2; 1681 cpu->ExtReg[inst_cream->d*2+0] = word2;
1682 cpu->ExtReg[inst_cream->d*2+1] = word1; 1682 cpu->ExtReg[inst_cream->d*2+1] = word1;
1683 } else { 1683 } else {
@@ -1686,7 +1686,7 @@ VLDR_INST:
1686 } 1686 }
1687 } 1687 }
1688 } 1688 }
1689 cpu->Reg[15] += GET_INST_SIZE(cpu); 1689 cpu->Reg[15] += cpu->GetInstructionSize();
1690 INC_PC(sizeof(vldr_inst)); 1690 INC_PC(sizeof(vldr_inst));
1691 FETCH_INST; 1691 FETCH_INST;
1692 GOTO_NEXT_INST; 1692 GOTO_NEXT_INST;
@@ -1742,15 +1742,15 @@ VLDM_INST:
1742 { 1742 {
1743 if (inst_cream->single) 1743 if (inst_cream->single)
1744 { 1744 {
1745 cpu->ExtReg[inst_cream->d+i] = ReadMemory32(cpu, addr); 1745 cpu->ExtReg[inst_cream->d+i] = cpu->ReadMemory32(addr);
1746 addr += 4; 1746 addr += 4;
1747 } 1747 }
1748 else 1748 else
1749 { 1749 {
1750 const u32 word1 = ReadMemory32(cpu, addr + 0); 1750 const u32 word1 = cpu->ReadMemory32(addr + 0);
1751 const u32 word2 = ReadMemory32(cpu, addr + 4); 1751 const u32 word2 = cpu->ReadMemory32(addr + 4);
1752 1752
1753 if (InBigEndianMode(cpu)) { 1753 if (cpu->InBigEndianMode()) {
1754 cpu->ExtReg[(inst_cream->d+i)*2+0] = word2; 1754 cpu->ExtReg[(inst_cream->d+i)*2+0] = word2;
1755 cpu->ExtReg[(inst_cream->d+i)*2+1] = word1; 1755 cpu->ExtReg[(inst_cream->d+i)*2+1] = word1;
1756 } else { 1756 } else {
@@ -1766,7 +1766,7 @@ VLDM_INST:
1766 cpu->Reg[inst_cream->n] - inst_cream->imm32); 1766 cpu->Reg[inst_cream->n] - inst_cream->imm32);
1767 } 1767 }
1768 } 1768 }
1769 cpu->Reg[15] += GET_INST_SIZE(cpu); 1769 cpu->Reg[15] += cpu->GetInstructionSize();
1770 INC_PC(sizeof(vldm_inst)); 1770 INC_PC(sizeof(vldm_inst));
1771 FETCH_INST; 1771 FETCH_INST;
1772 GOTO_NEXT_INST; 1772 GOTO_NEXT_INST;