diff options
| author | 2015-02-13 08:08:21 -0500 | |
|---|---|---|
| committer | 2015-02-13 09:11:12 -0500 | |
| commit | a75e1ff6e6b33b3e4751b82e0ab91b8dad169fc6 (patch) | |
| tree | fb2a89cbc953be437c43db3b16654be8f4d7efb8 /src/core/arm/dyncom | |
| parent | Merge pull request #569 from lioncash/modeswitch (diff) | |
| download | yuzu-a75e1ff6e6b33b3e4751b82e0ab91b8dad169fc6.tar.gz yuzu-a75e1ff6e6b33b3e4751b82e0ab91b8dad169fc6.tar.xz yuzu-a75e1ff6e6b33b3e4751b82e0ab91b8dad169fc6.zip | |
arm: General cleanup
- Remove several typedefs for ARMul_State.
- Remove unused functions
- Remove unused/unnecessary headers
- Removed unused enums, etc.
Diffstat (limited to 'src/core/arm/dyncom')
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_dec.cpp | 1 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 122 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_run.cpp | 2 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_run.h | 8 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_thumb.cpp | 18 |
5 files changed, 57 insertions, 94 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom_dec.cpp b/src/core/arm/dyncom/arm_dyncom_dec.cpp index 0927eece1..ffa627352 100644 --- a/src/core/arm/dyncom/arm_dyncom_dec.cpp +++ b/src/core/arm/dyncom/arm_dyncom_dec.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/arm/skyeye_common/arm_regformat.h" | ||
| 6 | #include "core/arm/skyeye_common/armdefs.h" | 5 | #include "core/arm/skyeye_common/armdefs.h" |
| 7 | #include "core/arm/dyncom/arm_dyncom_dec.h" | 6 | #include "core/arm/dyncom/arm_dyncom_dec.h" |
| 8 | 7 | ||
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index 17944c0a8..f701ee8b0 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -5,23 +5,19 @@ | |||
| 5 | #define CITRA_IGNORE_EXIT(x) | 5 | #define CITRA_IGNORE_EXIT(x) |
| 6 | 6 | ||
| 7 | #include <algorithm> | 7 | #include <algorithm> |
| 8 | #include <unordered_map> | ||
| 9 | #include <stdio.h> | ||
| 10 | #include <assert.h> | ||
| 11 | #include <cstdio> | 8 | #include <cstdio> |
| 12 | #include <vector> | 9 | #include <unordered_map> |
| 13 | 10 | ||
| 14 | using namespace std; | 11 | #include "common/logging/log.h" |
| 15 | 12 | ||
| 13 | #include "core/mem_map.h" | ||
| 14 | #include "core/hle/hle.h" | ||
| 15 | #include "core/arm/disassembler/arm_disasm.h" | ||
| 16 | #include "core/arm/dyncom/arm_dyncom_thumb.h" | ||
| 17 | #include "core/arm/dyncom/arm_dyncom_run.h" | ||
| 16 | #include "core/arm/skyeye_common/armdefs.h" | 18 | #include "core/arm/skyeye_common/armdefs.h" |
| 17 | #include "core/arm/skyeye_common/armmmu.h" | 19 | #include "core/arm/skyeye_common/armmmu.h" |
| 18 | #include "arm_dyncom_thumb.h" | ||
| 19 | #include "arm_dyncom_run.h" | ||
| 20 | #include "core/arm/skyeye_common/vfp/vfp.h" | 20 | #include "core/arm/skyeye_common/vfp/vfp.h" |
| 21 | #include "core/arm/disassembler/arm_disasm.h" | ||
| 22 | |||
| 23 | #include "core/mem_map.h" | ||
| 24 | #include "core/hle/hle.h" | ||
| 25 | 21 | ||
| 26 | enum { | 22 | enum { |
| 27 | COND = (1 << 0), | 23 | COND = (1 << 0), |
| @@ -44,8 +40,7 @@ enum { | |||
| 44 | #define ROTATE_RIGHT_32(n, i) ROTATE_RIGHT(n, i, 32) | 40 | #define ROTATE_RIGHT_32(n, i) ROTATE_RIGHT(n, i, 32) |
| 45 | #define ROTATE_LEFT_32(n, i) ROTATE_LEFT(n, i, 32) | 41 | #define ROTATE_LEFT_32(n, i) ROTATE_LEFT(n, i, 32) |
| 46 | 42 | ||
| 47 | typedef arm_core_t arm_processor; | 43 | typedef unsigned int (*shtop_fp_t)(ARMul_State* cpu, unsigned int sht_oper); |
| 48 | typedef unsigned int (*shtop_fp_t)(arm_processor *cpu, unsigned int sht_oper); | ||
| 49 | 44 | ||
| 50 | // Defines a reservation granule of 2 words, which protects the first 2 words starting at the tag. | 45 | // Defines a reservation granule of 2 words, which protects the first 2 words starting at the tag. |
| 51 | // This is the smallest granule allowed by the v7 spec, and is coincidentally just large enough to | 46 | // This is the smallest granule allowed by the v7 spec, and is coincidentally just large enough to |
| @@ -53,7 +48,7 @@ typedef unsigned int (*shtop_fp_t)(arm_processor *cpu, unsigned int sht_oper); | |||
| 53 | static const ARMword RESERVATION_GRANULE_MASK = 0xFFFFFFF8; | 48 | static const ARMword RESERVATION_GRANULE_MASK = 0xFFFFFFF8; |
| 54 | 49 | ||
| 55 | // Exclusive memory access | 50 | // Exclusive memory access |
| 56 | static int exclusive_detect(ARMul_State* state, ARMword addr){ | 51 | static int exclusive_detect(ARMul_State* state, ARMword addr) { |
| 57 | if(state->exclusive_tag == (addr & RESERVATION_GRANULE_MASK)) | 52 | if(state->exclusive_tag == (addr & RESERVATION_GRANULE_MASK)) |
| 58 | return 0; | 53 | return 0; |
| 59 | else | 54 | else |
| @@ -69,7 +64,7 @@ static void remove_exclusive(ARMul_State* state, ARMword addr){ | |||
| 69 | state->exclusive_tag = 0xFFFFFFFF; | 64 | state->exclusive_tag = 0xFFFFFFFF; |
| 70 | } | 65 | } |
| 71 | 66 | ||
| 72 | unsigned int DPO(Immediate)(arm_processor *cpu, unsigned int sht_oper) { | 67 | unsigned int DPO(Immediate)(ARMul_State* cpu, unsigned int sht_oper) { |
| 73 | unsigned int immed_8 = BITS(sht_oper, 0, 7); | 68 | unsigned int immed_8 = BITS(sht_oper, 0, 7); |
| 74 | unsigned int rotate_imm = BITS(sht_oper, 8, 11); | 69 | unsigned int rotate_imm = BITS(sht_oper, 8, 11); |
| 75 | unsigned int shifter_operand = ROTATE_RIGHT_32(immed_8, rotate_imm * 2); | 70 | unsigned int shifter_operand = ROTATE_RIGHT_32(immed_8, rotate_imm * 2); |
| @@ -80,14 +75,14 @@ unsigned int DPO(Immediate)(arm_processor *cpu, unsigned int sht_oper) { | |||
| 80 | return shifter_operand; | 75 | return shifter_operand; |
| 81 | } | 76 | } |
| 82 | 77 | ||
| 83 | unsigned int DPO(Register)(arm_processor *cpu, unsigned int sht_oper) { | 78 | unsigned int DPO(Register)(ARMul_State* cpu, unsigned int sht_oper) { |
| 84 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 79 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 85 | unsigned int shifter_operand = rm; | 80 | unsigned int shifter_operand = rm; |
| 86 | cpu->shifter_carry_out = cpu->CFlag; | 81 | cpu->shifter_carry_out = cpu->CFlag; |
| 87 | return shifter_operand; | 82 | return shifter_operand; |
| 88 | } | 83 | } |
| 89 | 84 | ||
| 90 | unsigned int DPO(LogicalShiftLeftByImmediate)(arm_processor *cpu, unsigned int sht_oper) { | 85 | unsigned int DPO(LogicalShiftLeftByImmediate)(ARMul_State* cpu, unsigned int sht_oper) { |
| 91 | int shift_imm = BITS(sht_oper, 7, 11); | 86 | int shift_imm = BITS(sht_oper, 7, 11); |
| 92 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 87 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 93 | unsigned int shifter_operand; | 88 | unsigned int shifter_operand; |
| @@ -101,7 +96,7 @@ unsigned int DPO(LogicalShiftLeftByImmediate)(arm_processor *cpu, unsigned int s | |||
| 101 | return shifter_operand; | 96 | return shifter_operand; |
| 102 | } | 97 | } |
| 103 | 98 | ||
| 104 | unsigned int DPO(LogicalShiftLeftByRegister)(arm_processor *cpu, unsigned int sht_oper) { | 99 | unsigned int DPO(LogicalShiftLeftByRegister)(ARMul_State* cpu, unsigned int sht_oper) { |
| 105 | int shifter_operand; | 100 | int shifter_operand; |
| 106 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 101 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 107 | unsigned int rs = CHECK_READ_REG15(cpu, RS); | 102 | unsigned int rs = CHECK_READ_REG15(cpu, RS); |
| @@ -121,7 +116,7 @@ unsigned int DPO(LogicalShiftLeftByRegister)(arm_processor *cpu, unsigned int sh | |||
| 121 | return shifter_operand; | 116 | return shifter_operand; |
| 122 | } | 117 | } |
| 123 | 118 | ||
| 124 | unsigned int DPO(LogicalShiftRightByImmediate)(arm_processor *cpu, unsigned int sht_oper) { | 119 | unsigned int DPO(LogicalShiftRightByImmediate)(ARMul_State* cpu, unsigned int sht_oper) { |
| 125 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 120 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 126 | unsigned int shifter_operand; | 121 | unsigned int shifter_operand; |
| 127 | int shift_imm = BITS(sht_oper, 7, 11); | 122 | int shift_imm = BITS(sht_oper, 7, 11); |
| @@ -135,7 +130,7 @@ unsigned int DPO(LogicalShiftRightByImmediate)(arm_processor *cpu, unsigned int | |||
| 135 | return shifter_operand; | 130 | return shifter_operand; |
| 136 | } | 131 | } |
| 137 | 132 | ||
| 138 | unsigned int DPO(LogicalShiftRightByRegister)(arm_processor *cpu, unsigned int sht_oper) { | 133 | unsigned int DPO(LogicalShiftRightByRegister)(ARMul_State* cpu, unsigned int sht_oper) { |
| 139 | unsigned int rs = CHECK_READ_REG15(cpu, RS); | 134 | unsigned int rs = CHECK_READ_REG15(cpu, RS); |
| 140 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 135 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 141 | unsigned int shifter_operand; | 136 | unsigned int shifter_operand; |
| @@ -155,7 +150,7 @@ unsigned int DPO(LogicalShiftRightByRegister)(arm_processor *cpu, unsigned int s | |||
| 155 | return shifter_operand; | 150 | return shifter_operand; |
| 156 | } | 151 | } |
| 157 | 152 | ||
| 158 | unsigned int DPO(ArithmeticShiftRightByImmediate)(arm_processor *cpu, unsigned int sht_oper) { | 153 | unsigned int DPO(ArithmeticShiftRightByImmediate)(ARMul_State* cpu, unsigned int sht_oper) { |
| 159 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 154 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 160 | unsigned int shifter_operand; | 155 | unsigned int shifter_operand; |
| 161 | int shift_imm = BITS(sht_oper, 7, 11); | 156 | int shift_imm = BITS(sht_oper, 7, 11); |
| @@ -172,7 +167,7 @@ unsigned int DPO(ArithmeticShiftRightByImmediate)(arm_processor *cpu, unsigned i | |||
| 172 | return shifter_operand; | 167 | return shifter_operand; |
| 173 | } | 168 | } |
| 174 | 169 | ||
| 175 | unsigned int DPO(ArithmeticShiftRightByRegister)(arm_processor *cpu, unsigned int sht_oper) { | 170 | unsigned int DPO(ArithmeticShiftRightByRegister)(ARMul_State* cpu, unsigned int sht_oper) { |
| 176 | unsigned int rs = CHECK_READ_REG15(cpu, RS); | 171 | unsigned int rs = CHECK_READ_REG15(cpu, RS); |
| 177 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 172 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 178 | unsigned int shifter_operand; | 173 | unsigned int shifter_operand; |
| @@ -192,7 +187,7 @@ unsigned int DPO(ArithmeticShiftRightByRegister)(arm_processor *cpu, unsigned in | |||
| 192 | return shifter_operand; | 187 | return shifter_operand; |
| 193 | } | 188 | } |
| 194 | 189 | ||
| 195 | unsigned int DPO(RotateRightByImmediate)(arm_processor *cpu, unsigned int sht_oper) { | 190 | unsigned int DPO(RotateRightByImmediate)(ARMul_State* cpu, unsigned int sht_oper) { |
| 196 | unsigned int shifter_operand; | 191 | unsigned int shifter_operand; |
| 197 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 192 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 198 | int shift_imm = BITS(sht_oper, 7, 11); | 193 | int shift_imm = BITS(sht_oper, 7, 11); |
| @@ -206,7 +201,7 @@ unsigned int DPO(RotateRightByImmediate)(arm_processor *cpu, unsigned int sht_op | |||
| 206 | return shifter_operand; | 201 | return shifter_operand; |
| 207 | } | 202 | } |
| 208 | 203 | ||
| 209 | unsigned int DPO(RotateRightByRegister)(arm_processor *cpu, unsigned int sht_oper) { | 204 | unsigned int DPO(RotateRightByRegister)(ARMul_State* cpu, unsigned int sht_oper) { |
| 210 | unsigned int rm = CHECK_READ_REG15(cpu, RM); | 205 | unsigned int rm = CHECK_READ_REG15(cpu, RM); |
| 211 | unsigned int rs = CHECK_READ_REG15(cpu, RS); | 206 | unsigned int rs = CHECK_READ_REG15(cpu, RS); |
| 212 | unsigned int shifter_operand; | 207 | unsigned int shifter_operand; |
| @@ -223,7 +218,7 @@ unsigned int DPO(RotateRightByRegister)(arm_processor *cpu, unsigned int sht_ope | |||
| 223 | return shifter_operand; | 218 | return shifter_operand; |
| 224 | } | 219 | } |
| 225 | 220 | ||
| 226 | typedef void (*get_addr_fp_t)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw); | 221 | typedef void (*get_addr_fp_t)(ARMul_State *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw); |
| 227 | 222 | ||
| 228 | typedef struct _ldst_inst { | 223 | typedef struct _ldst_inst { |
| 229 | unsigned int inst; | 224 | unsigned int inst; |
| @@ -231,7 +226,7 @@ typedef struct _ldst_inst { | |||
| 231 | } ldst_inst; | 226 | } ldst_inst; |
| 232 | #define DEBUG_MSG LOG_DEBUG(Core_ARM11, "inst is %x", inst); CITRA_IGNORE_EXIT(0) | 227 | #define DEBUG_MSG LOG_DEBUG(Core_ARM11, "inst is %x", inst); CITRA_IGNORE_EXIT(0) |
| 233 | 228 | ||
| 234 | int CondPassed(arm_processor *cpu, unsigned int cond); | 229 | int CondPassed(ARMul_State* cpu, unsigned int cond); |
| 235 | 230 | ||
| 236 | #define LnSWoUB(s) glue(LnSWoUB, s) | 231 | #define LnSWoUB(s) glue(LnSWoUB, s) |
| 237 | #define MLnS(s) glue(MLnS, s) | 232 | #define MLnS(s) glue(MLnS, s) |
| @@ -243,7 +238,7 @@ int CondPassed(arm_processor *cpu, unsigned int cond); | |||
| 243 | #define P_BIT BIT(inst, 24) | 238 | #define P_BIT BIT(inst, 24) |
| 244 | #define OFFSET_12 BITS(inst, 0, 11) | 239 | #define OFFSET_12 BITS(inst, 0, 11) |
| 245 | 240 | ||
| 246 | void LnSWoUB(ImmediateOffset)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 241 | void LnSWoUB(ImmediateOffset)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 247 | unsigned int Rn = BITS(inst, 16, 19); | 242 | unsigned int Rn = BITS(inst, 16, 19); |
| 248 | unsigned int addr; | 243 | unsigned int addr; |
| 249 | 244 | ||
| @@ -255,7 +250,7 @@ void LnSWoUB(ImmediateOffset)(arm_processor *cpu, unsigned int inst, unsigned in | |||
| 255 | virt_addr = addr; | 250 | virt_addr = addr; |
| 256 | } | 251 | } |
| 257 | 252 | ||
| 258 | void LnSWoUB(RegisterOffset)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 253 | void LnSWoUB(RegisterOffset)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 259 | unsigned int Rn = BITS(inst, 16, 19); | 254 | unsigned int Rn = BITS(inst, 16, 19); |
| 260 | unsigned int Rm = BITS(inst, 0, 3); | 255 | unsigned int Rm = BITS(inst, 0, 3); |
| 261 | unsigned int rn = CHECK_READ_REG15_WA(cpu, Rn); | 256 | unsigned int rn = CHECK_READ_REG15_WA(cpu, Rn); |
| @@ -270,7 +265,7 @@ void LnSWoUB(RegisterOffset)(arm_processor *cpu, unsigned int inst, unsigned int | |||
| 270 | virt_addr = addr; | 265 | virt_addr = addr; |
| 271 | } | 266 | } |
| 272 | 267 | ||
| 273 | void LnSWoUB(ImmediatePostIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 268 | void LnSWoUB(ImmediatePostIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 274 | unsigned int Rn = BITS(inst, 16, 19); | 269 | unsigned int Rn = BITS(inst, 16, 19); |
| 275 | unsigned int addr = CHECK_READ_REG15_WA(cpu, Rn); | 270 | unsigned int addr = CHECK_READ_REG15_WA(cpu, Rn); |
| 276 | 271 | ||
| @@ -282,7 +277,7 @@ void LnSWoUB(ImmediatePostIndexed)(arm_processor *cpu, unsigned int inst, unsign | |||
| 282 | virt_addr = addr; | 277 | virt_addr = addr; |
| 283 | } | 278 | } |
| 284 | 279 | ||
| 285 | void LnSWoUB(ImmediatePreIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 280 | void LnSWoUB(ImmediatePreIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 286 | unsigned int Rn = BITS(inst, 16, 19); | 281 | unsigned int Rn = BITS(inst, 16, 19); |
| 287 | unsigned int addr; | 282 | unsigned int addr; |
| 288 | 283 | ||
| @@ -297,7 +292,7 @@ void LnSWoUB(ImmediatePreIndexed)(arm_processor *cpu, unsigned int inst, unsigne | |||
| 297 | cpu->Reg[Rn] = addr; | 292 | cpu->Reg[Rn] = addr; |
| 298 | } | 293 | } |
| 299 | 294 | ||
| 300 | void MLnS(RegisterPreIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 295 | void MLnS(RegisterPreIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 301 | unsigned int addr; | 296 | unsigned int addr; |
| 302 | unsigned int Rn = BITS(inst, 16, 19); | 297 | unsigned int Rn = BITS(inst, 16, 19); |
| 303 | unsigned int Rm = BITS(inst, 0, 3); | 298 | unsigned int Rm = BITS(inst, 0, 3); |
| @@ -315,7 +310,7 @@ void MLnS(RegisterPreIndexed)(arm_processor *cpu, unsigned int inst, unsigned in | |||
| 315 | cpu->Reg[Rn] = addr; | 310 | cpu->Reg[Rn] = addr; |
| 316 | } | 311 | } |
| 317 | 312 | ||
| 318 | void LnSWoUB(RegisterPreIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 313 | void LnSWoUB(RegisterPreIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 319 | unsigned int Rn = BITS(inst, 16, 19); | 314 | unsigned int Rn = BITS(inst, 16, 19); |
| 320 | unsigned int Rm = BITS(inst, 0, 3); | 315 | unsigned int Rm = BITS(inst, 0, 3); |
| 321 | unsigned int rn = CHECK_READ_REG15_WA(cpu, Rn); | 316 | unsigned int rn = CHECK_READ_REG15_WA(cpu, Rn); |
| @@ -334,7 +329,7 @@ void LnSWoUB(RegisterPreIndexed)(arm_processor *cpu, unsigned int inst, unsigned | |||
| 334 | } | 329 | } |
| 335 | } | 330 | } |
| 336 | 331 | ||
| 337 | void LnSWoUB(ScaledRegisterPreIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 332 | void LnSWoUB(ScaledRegisterPreIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 338 | unsigned int shift = BITS(inst, 5, 6); | 333 | unsigned int shift = BITS(inst, 5, 6); |
| 339 | unsigned int shift_imm = BITS(inst, 7, 11); | 334 | unsigned int shift_imm = BITS(inst, 7, 11); |
| 340 | unsigned int Rn = BITS(inst, 16, 19); | 335 | unsigned int Rn = BITS(inst, 16, 19); |
| @@ -385,7 +380,7 @@ void LnSWoUB(ScaledRegisterPreIndexed)(arm_processor *cpu, unsigned int inst, un | |||
| 385 | cpu->Reg[Rn] = addr; | 380 | cpu->Reg[Rn] = addr; |
| 386 | } | 381 | } |
| 387 | 382 | ||
| 388 | void LnSWoUB(ScaledRegisterPostIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 383 | void LnSWoUB(ScaledRegisterPostIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 389 | unsigned int shift = BITS(inst, 5, 6); | 384 | unsigned int shift = BITS(inst, 5, 6); |
| 390 | unsigned int shift_imm = BITS(inst, 7, 11); | 385 | unsigned int shift_imm = BITS(inst, 7, 11); |
| 391 | unsigned int Rn = BITS(inst, 16, 19); | 386 | unsigned int Rn = BITS(inst, 16, 19); |
| @@ -434,7 +429,7 @@ void LnSWoUB(ScaledRegisterPostIndexed)(arm_processor *cpu, unsigned int inst, u | |||
| 434 | } | 429 | } |
| 435 | } | 430 | } |
| 436 | 431 | ||
| 437 | void LnSWoUB(RegisterPostIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 432 | void LnSWoUB(RegisterPostIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 438 | unsigned int Rn = BITS(inst, 16, 19); | 433 | unsigned int Rn = BITS(inst, 16, 19); |
| 439 | unsigned int Rm = BITS(inst, 0, 3); | 434 | unsigned int Rm = BITS(inst, 0, 3); |
| 440 | unsigned int rm = CHECK_READ_REG15_WA(cpu, Rm); | 435 | unsigned int rm = CHECK_READ_REG15_WA(cpu, Rm); |
| @@ -450,7 +445,7 @@ void LnSWoUB(RegisterPostIndexed)(arm_processor *cpu, unsigned int inst, unsigne | |||
| 450 | } | 445 | } |
| 451 | } | 446 | } |
| 452 | 447 | ||
| 453 | void MLnS(ImmediateOffset)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 448 | void MLnS(ImmediateOffset)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 454 | unsigned int immedL = BITS(inst, 0, 3); | 449 | unsigned int immedL = BITS(inst, 0, 3); |
| 455 | unsigned int immedH = BITS(inst, 8, 11); | 450 | unsigned int immedH = BITS(inst, 8, 11); |
| 456 | unsigned int Rn = BITS(inst, 16, 19); | 451 | unsigned int Rn = BITS(inst, 16, 19); |
| @@ -466,7 +461,7 @@ void MLnS(ImmediateOffset)(arm_processor *cpu, unsigned int inst, unsigned int & | |||
| 466 | virt_addr = addr; | 461 | virt_addr = addr; |
| 467 | } | 462 | } |
| 468 | 463 | ||
| 469 | void MLnS(RegisterOffset)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 464 | void MLnS(RegisterOffset)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 470 | unsigned int addr; | 465 | unsigned int addr; |
| 471 | unsigned int Rn = BITS(inst, 16, 19); | 466 | unsigned int Rn = BITS(inst, 16, 19); |
| 472 | unsigned int Rm = BITS(inst, 0, 3); | 467 | unsigned int Rm = BITS(inst, 0, 3); |
| @@ -481,7 +476,7 @@ void MLnS(RegisterOffset)(arm_processor *cpu, unsigned int inst, unsigned int &v | |||
| 481 | virt_addr = addr; | 476 | virt_addr = addr; |
| 482 | } | 477 | } |
| 483 | 478 | ||
| 484 | void MLnS(ImmediatePreIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 479 | void MLnS(ImmediatePreIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 485 | unsigned int Rn = BITS(inst, 16, 19); | 480 | unsigned int Rn = BITS(inst, 16, 19); |
| 486 | unsigned int immedH = BITS(inst, 8, 11); | 481 | unsigned int immedH = BITS(inst, 8, 11); |
| 487 | unsigned int immedL = BITS(inst, 0, 3); | 482 | unsigned int immedL = BITS(inst, 0, 3); |
| @@ -500,7 +495,7 @@ void MLnS(ImmediatePreIndexed)(arm_processor *cpu, unsigned int inst, unsigned i | |||
| 500 | cpu->Reg[Rn] = addr; | 495 | cpu->Reg[Rn] = addr; |
| 501 | } | 496 | } |
| 502 | 497 | ||
| 503 | void MLnS(ImmediatePostIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 498 | void MLnS(ImmediatePostIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 504 | unsigned int Rn = BITS(inst, 16, 19); | 499 | unsigned int Rn = BITS(inst, 16, 19); |
| 505 | unsigned int immedH = BITS(inst, 8, 11); | 500 | unsigned int immedH = BITS(inst, 8, 11); |
| 506 | unsigned int immedL = BITS(inst, 0, 3); | 501 | unsigned int immedL = BITS(inst, 0, 3); |
| @@ -519,7 +514,7 @@ void MLnS(ImmediatePostIndexed)(arm_processor *cpu, unsigned int inst, unsigned | |||
| 519 | } | 514 | } |
| 520 | } | 515 | } |
| 521 | 516 | ||
| 522 | void MLnS(RegisterPostIndexed)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 517 | void MLnS(RegisterPostIndexed)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 523 | unsigned int Rn = BITS(inst, 16, 19); | 518 | unsigned int Rn = BITS(inst, 16, 19); |
| 524 | unsigned int Rm = BITS(inst, 0, 3); | 519 | unsigned int Rm = BITS(inst, 0, 3); |
| 525 | unsigned int rm = CHECK_READ_REG15_WA(cpu, Rm); | 520 | unsigned int rm = CHECK_READ_REG15_WA(cpu, Rm); |
| @@ -534,7 +529,7 @@ void MLnS(RegisterPostIndexed)(arm_processor *cpu, unsigned int inst, unsigned i | |||
| 534 | } | 529 | } |
| 535 | } | 530 | } |
| 536 | 531 | ||
| 537 | void LdnStM(DecrementBefore)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 532 | void LdnStM(DecrementBefore)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 538 | unsigned int Rn = BITS(inst, 16, 19); | 533 | unsigned int Rn = BITS(inst, 16, 19); |
| 539 | unsigned int i = BITS(inst, 0, 15); | 534 | unsigned int i = BITS(inst, 0, 15); |
| 540 | int count = 0; | 535 | int count = 0; |
| @@ -550,7 +545,7 @@ void LdnStM(DecrementBefore)(arm_processor *cpu, unsigned int inst, unsigned int | |||
| 550 | cpu->Reg[Rn] -= count * 4; | 545 | cpu->Reg[Rn] -= count * 4; |
| 551 | } | 546 | } |
| 552 | 547 | ||
| 553 | void LdnStM(IncrementBefore)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 548 | void LdnStM(IncrementBefore)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 554 | unsigned int Rn = BITS(inst, 16, 19); | 549 | unsigned int Rn = BITS(inst, 16, 19); |
| 555 | unsigned int i = BITS(inst, 0, 15); | 550 | unsigned int i = BITS(inst, 0, 15); |
| 556 | int count = 0; | 551 | int count = 0; |
| @@ -566,7 +561,7 @@ void LdnStM(IncrementBefore)(arm_processor *cpu, unsigned int inst, unsigned int | |||
| 566 | cpu->Reg[Rn] += count * 4; | 561 | cpu->Reg[Rn] += count * 4; |
| 567 | } | 562 | } |
| 568 | 563 | ||
| 569 | void LdnStM(IncrementAfter)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 564 | void LdnStM(IncrementAfter)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 570 | unsigned int Rn = BITS(inst, 16, 19); | 565 | unsigned int Rn = BITS(inst, 16, 19); |
| 571 | unsigned int i = BITS(inst, 0, 15); | 566 | unsigned int i = BITS(inst, 0, 15); |
| 572 | int count = 0; | 567 | int count = 0; |
| @@ -582,7 +577,7 @@ void LdnStM(IncrementAfter)(arm_processor *cpu, unsigned int inst, unsigned int | |||
| 582 | cpu->Reg[Rn] += count * 4; | 577 | cpu->Reg[Rn] += count * 4; |
| 583 | } | 578 | } |
| 584 | 579 | ||
| 585 | void LdnStM(DecrementAfter)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 580 | void LdnStM(DecrementAfter)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 586 | unsigned int Rn = BITS(inst, 16, 19); | 581 | unsigned int Rn = BITS(inst, 16, 19); |
| 587 | unsigned int i = BITS(inst, 0, 15); | 582 | unsigned int i = BITS(inst, 0, 15); |
| 588 | int count = 0; | 583 | int count = 0; |
| @@ -600,7 +595,7 @@ void LdnStM(DecrementAfter)(arm_processor *cpu, unsigned int inst, unsigned int | |||
| 600 | } | 595 | } |
| 601 | } | 596 | } |
| 602 | 597 | ||
| 603 | void LnSWoUB(ScaledRegisterOffset)(arm_processor *cpu, unsigned int inst, unsigned int &virt_addr, unsigned int rw) { | 598 | void LnSWoUB(ScaledRegisterOffset)(ARMul_State* cpu, unsigned int inst, unsigned int& virt_addr, unsigned int rw) { |
| 604 | unsigned int shift = BITS(inst, 5, 6); | 599 | unsigned int shift = BITS(inst, 5, 6); |
| 605 | unsigned int shift_imm = BITS(inst, 7, 11); | 600 | unsigned int shift_imm = BITS(inst, 7, 11); |
| 606 | unsigned int Rn = BITS(inst, 16, 19); | 601 | unsigned int Rn = BITS(inst, 16, 19); |
| @@ -1115,7 +1110,7 @@ inline void *AllocBuffer(unsigned int size) { | |||
| 1115 | return (void *)&inst_buf[start]; | 1110 | return (void *)&inst_buf[start]; |
| 1116 | } | 1111 | } |
| 1117 | 1112 | ||
| 1118 | int CondPassed(arm_processor *cpu, unsigned int cond) { | 1113 | int CondPassed(ARMul_State* cpu, unsigned int cond) { |
| 1119 | #define NFLAG cpu->NFlag | 1114 | #define NFLAG cpu->NFlag |
| 1120 | #define ZFLAG cpu->ZFlag | 1115 | #define ZFLAG cpu->ZFlag |
| 1121 | #define CFLAG cpu->CFlag | 1116 | #define CFLAG cpu->CFlag |
| @@ -3469,13 +3464,13 @@ const transop_fp_t arm_instruction_trans[] = { | |||
| 3469 | }; | 3464 | }; |
| 3470 | 3465 | ||
| 3471 | typedef std::unordered_map<u32, int> bb_map; | 3466 | typedef std::unordered_map<u32, int> bb_map; |
| 3472 | bb_map CreamCache; | 3467 | static bb_map CreamCache; |
| 3473 | 3468 | ||
| 3474 | void insert_bb(unsigned int addr, int start) { | 3469 | static void insert_bb(unsigned int addr, int start) { |
| 3475 | CreamCache[addr] = start; | 3470 | CreamCache[addr] = start; |
| 3476 | } | 3471 | } |
| 3477 | 3472 | ||
| 3478 | int find_bb(unsigned int addr, int &start) { | 3473 | static int find_bb(unsigned int addr, int& start) { |
| 3479 | int ret = -1; | 3474 | int ret = -1; |
| 3480 | bb_map::const_iterator it = CreamCache.find(addr); | 3475 | bb_map::const_iterator it = CreamCache.find(addr); |
| 3481 | if (it != CreamCache.end()) { | 3476 | if (it != CreamCache.end()) { |
| @@ -3492,7 +3487,7 @@ enum { | |||
| 3492 | FETCH_FAILURE | 3487 | FETCH_FAILURE |
| 3493 | }; | 3488 | }; |
| 3494 | 3489 | ||
| 3495 | static tdstate decode_thumb_instr(arm_processor *cpu, uint32_t inst, addr_t addr, uint32_t *arm_inst, uint32_t* inst_size, ARM_INST_PTR* ptr_inst_base){ | 3490 | static tdstate decode_thumb_instr(ARMul_State* cpu, uint32_t inst, addr_t addr, uint32_t* arm_inst, uint32_t* inst_size, ARM_INST_PTR* ptr_inst_base){ |
| 3496 | // Check if in Thumb mode | 3491 | // Check if in Thumb mode |
| 3497 | tdstate ret = thumb_translate (addr, inst, arm_inst, inst_size); | 3492 | tdstate ret = thumb_translate (addr, inst, arm_inst, inst_size); |
| 3498 | if(ret == t_branch){ | 3493 | if(ret == t_branch){ |
| @@ -3555,24 +3550,7 @@ typedef struct instruction_set_encoding_item ISEITEM; | |||
| 3555 | 3550 | ||
| 3556 | extern const ISEITEM arm_instruction[]; | 3551 | extern const ISEITEM arm_instruction[]; |
| 3557 | 3552 | ||
| 3558 | vector<uint64_t> code_page_set; | 3553 | int InterpreterTranslate(ARMul_State* cpu, int& bb_start, addr_t addr) { |
| 3559 | |||
| 3560 | void flush_bb(uint32_t addr) { | ||
| 3561 | bb_map::iterator it; | ||
| 3562 | uint32_t start; | ||
| 3563 | |||
| 3564 | addr &= 0xfffff000; | ||
| 3565 | for (it = CreamCache.begin(); it != CreamCache.end(); ) { | ||
| 3566 | start = static_cast<uint32_t>(it->first); | ||
| 3567 | start &= 0xfffff000; | ||
| 3568 | if (start == addr) { | ||
| 3569 | CreamCache.erase(it++); | ||
| 3570 | } else | ||
| 3571 | ++it; | ||
| 3572 | } | ||
| 3573 | } | ||
| 3574 | |||
| 3575 | int InterpreterTranslate(arm_processor *cpu, int &bb_start, addr_t addr) { | ||
| 3576 | // Decode instruction, get index | 3554 | // Decode instruction, get index |
| 3577 | // Allocate memory and init InsCream | 3555 | // Allocate memory and init InsCream |
| 3578 | // Go on next, until terminal instruction | 3556 | // Go on next, until terminal instruction |
| @@ -3628,8 +3606,6 @@ translated: | |||
| 3628 | return KEEP_GOING; | 3606 | return KEEP_GOING; |
| 3629 | } | 3607 | } |
| 3630 | 3608 | ||
| 3631 | #define LOG_IN_CLR skyeye_printf_in_color | ||
| 3632 | |||
| 3633 | int clz(unsigned int x) { | 3609 | int clz(unsigned int x) { |
| 3634 | int n; | 3610 | int n; |
| 3635 | if (x == 0) return (32); | 3611 | if (x == 0) return (32); |
| @@ -3642,9 +3618,7 @@ int clz(unsigned int x) { | |||
| 3642 | return n; | 3618 | return n; |
| 3643 | } | 3619 | } |
| 3644 | 3620 | ||
| 3645 | unsigned arm_dyncom_SWI (ARMul_State * state, ARMword number); | 3621 | static bool InAPrivilegedMode(ARMul_State* core) { |
| 3646 | |||
| 3647 | static bool InAPrivilegedMode(arm_core_t *core) { | ||
| 3648 | return (core->Mode != USER32MODE); | 3622 | return (core->Mode != USER32MODE); |
| 3649 | } | 3623 | } |
| 3650 | 3624 | ||
| @@ -3904,7 +3878,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) { | |||
| 3904 | #define PC (cpu->Reg[15]) | 3878 | #define PC (cpu->Reg[15]) |
| 3905 | #define CHECK_EXT_INT if (!cpu->NirqSig && !(cpu->Cpsr & 0x80)) goto END; | 3879 | #define CHECK_EXT_INT if (!cpu->NirqSig && !(cpu->Cpsr & 0x80)) goto END; |
| 3906 | 3880 | ||
| 3907 | arm_processor *cpu = state; | 3881 | ARMul_State* cpu = state; |
| 3908 | 3882 | ||
| 3909 | // GCC and Clang have a C++ extension to support a lookup table of labels. Otherwise, fallback | 3883 | // GCC and Clang have a C++ extension to support a lookup table of labels. Otherwise, fallback |
| 3910 | // to a clunky switch statement. | 3884 | // to a clunky switch statement. |
diff --git a/src/core/arm/dyncom/arm_dyncom_run.cpp b/src/core/arm/dyncom/arm_dyncom_run.cpp index d79e3e4b2..3a05ea8ac 100644 --- a/src/core/arm/dyncom/arm_dyncom_run.cpp +++ b/src/core/arm/dyncom/arm_dyncom_run.cpp | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "core/arm/skyeye_common/armdefs.h" | 5 | #include "core/arm/skyeye_common/armdefs.h" |
| 6 | 6 | ||
| 7 | void switch_mode(arm_core_t *core, uint32_t mode) { | 7 | void switch_mode(ARMul_State* core, uint32_t mode) { |
| 8 | if (core->Mode == mode) | 8 | if (core->Mode == mode) |
| 9 | return; | 9 | return; |
| 10 | 10 | ||
diff --git a/src/core/arm/dyncom/arm_dyncom_run.h b/src/core/arm/dyncom/arm_dyncom_run.h index b1c0daaf7..e79439f80 100644 --- a/src/core/arm/dyncom/arm_dyncom_run.h +++ b/src/core/arm/dyncom/arm_dyncom_run.h | |||
| @@ -18,10 +18,10 @@ | |||
| 18 | 18 | ||
| 19 | #pragma once | 19 | #pragma once |
| 20 | 20 | ||
| 21 | void switch_mode(arm_core_t *core, uint32_t mode); | 21 | void switch_mode(ARMul_State* core, uint32_t mode); |
| 22 | 22 | ||
| 23 | /* FIXME, we temporarily think thumb instruction is always 16 bit */ | 23 | /* FIXME, we temporarily think thumb instruction is always 16 bit */ |
| 24 | static inline u32 GET_INST_SIZE(arm_core_t* core) { | 24 | static inline u32 GET_INST_SIZE(ARMul_State* core) { |
| 25 | return core->TFlag? 2 : 4; | 25 | return core->TFlag? 2 : 4; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| @@ -33,7 +33,7 @@ static inline u32 GET_INST_SIZE(arm_core_t* core) { | |||
| 33 | * | 33 | * |
| 34 | * @return | 34 | * @return |
| 35 | */ | 35 | */ |
| 36 | static inline addr_t CHECK_READ_REG15_WA(arm_core_t* core, int Rn) { | 36 | static inline addr_t CHECK_READ_REG15_WA(ARMul_State* core, int Rn) { |
| 37 | return (Rn == 15)? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; | 37 | return (Rn == 15)? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| @@ -45,6 +45,6 @@ static inline addr_t CHECK_READ_REG15_WA(arm_core_t* core, int Rn) { | |||
| 45 | * | 45 | * |
| 46 | * @return | 46 | * @return |
| 47 | */ | 47 | */ |
| 48 | static inline u32 CHECK_READ_REG15(arm_core_t* core, int Rn) { | 48 | static inline u32 CHECK_READ_REG15(ARMul_State* core, int Rn) { |
| 49 | return (Rn == 15)? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; | 49 | return (Rn == 15)? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; |
| 50 | } | 50 | } |
diff --git a/src/core/arm/dyncom/arm_dyncom_thumb.cpp b/src/core/arm/dyncom/arm_dyncom_thumb.cpp index d5a698365..e30d515fb 100644 --- a/src/core/arm/dyncom/arm_dyncom_thumb.cpp +++ b/src/core/arm/dyncom/arm_dyncom_thumb.cpp | |||
| @@ -5,27 +5,17 @@ | |||
| 5 | // We can provide simple Thumb simulation by decoding the Thumb instruction into its corresponding | 5 | // We can provide simple Thumb simulation by decoding the Thumb instruction into its corresponding |
| 6 | // ARM instruction, and using the existing ARM simulator. | 6 | // ARM instruction, and using the existing ARM simulator. |
| 7 | 7 | ||
| 8 | #include "core/arm/skyeye_common/skyeye_defs.h" | ||
| 9 | |||
| 10 | #ifndef MODET // Required for the Thumb instruction support | ||
| 11 | #if 1 | ||
| 12 | #error "MODET needs to be defined for the Thumb world to work" | ||
| 13 | #else | ||
| 14 | #define MODET (1) | ||
| 15 | #endif | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #include "core/arm/skyeye_common/armos.h" | ||
| 19 | #include "core/arm/dyncom/arm_dyncom_thumb.h" | 8 | #include "core/arm/dyncom/arm_dyncom_thumb.h" |
| 9 | #include "core/arm/skyeye_common/armos.h" | ||
| 10 | #include "core/arm/skyeye_common/skyeye_defs.h" | ||
| 20 | 11 | ||
| 21 | // Decode a 16bit Thumb instruction. The instruction is in the low 16-bits of the tinstr field, | 12 | // Decode a 16bit Thumb instruction. The instruction is in the low 16-bits of the tinstr field, |
| 22 | // with the following Thumb instruction held in the high 16-bits. Passing in two Thumb instructions | 13 | // with the following Thumb instruction held in the high 16-bits. Passing in two Thumb instructions |
| 23 | // allows easier simulation of the special dual BL instruction. | 14 | // allows easier simulation of the special dual BL instruction. |
| 24 | 15 | ||
| 25 | tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t* inst_size) { | 16 | tdstate thumb_translate(addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t* inst_size) { |
| 26 | tdstate valid = t_uninitialized; | 17 | tdstate valid = t_uninitialized; |
| 27 | ARMword tinstr; | 18 | ARMword tinstr = instr; |
| 28 | tinstr = instr; | ||
| 29 | 19 | ||
| 30 | // The endian should be judge here | 20 | // The endian should be judge here |
| 31 | if((addr & 0x3) != 0) | 21 | if((addr & 0x3) != 0) |