diff options
| author | 2015-02-13 09:59:17 -0500 | |
|---|---|---|
| committer | 2015-02-13 09:59:17 -0500 | |
| commit | c44d75787b03e84591aac3ab3cc07eaf8c023188 (patch) | |
| tree | fb2a89cbc953be437c43db3b16654be8f4d7efb8 /src/core | |
| parent | Merge pull request #569 from lioncash/modeswitch (diff) | |
| parent | arm: General cleanup (diff) | |
| download | yuzu-c44d75787b03e84591aac3ab3cc07eaf8c023188.tar.gz yuzu-c44d75787b03e84591aac3ab3cc07eaf8c023188.tar.xz yuzu-c44d75787b03e84591aac3ab3cc07eaf8c023188.zip | |
Merge pull request #571 from lioncash/cleanup
arm: General cleanup
Diffstat (limited to 'src/core')
| -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 | ||||
| -rw-r--r-- | src/core/arm/interpreter/arminit.cpp | 3 | ||||
| -rw-r--r-- | src/core/arm/interpreter/armsupp.cpp | 3 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/armdefs.h | 16 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/armemu.h | 71 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/skyeye_defs.h | 83 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/vfp/vfp.cpp | 9 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/vfp/vfp_helper.h | 6 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/vfp/vfpdouble.cpp | 1 |
13 files changed, 116 insertions, 227 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) |
diff --git a/src/core/arm/interpreter/arminit.cpp b/src/core/arm/interpreter/arminit.cpp index d3174c9a0..abafe226e 100644 --- a/src/core/arm/interpreter/arminit.cpp +++ b/src/core/arm/interpreter/arminit.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | along with this program; if not, write to the Free Software | 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. */ | 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 17 | 17 | ||
| 18 | #include <cstring> | ||
| 18 | #include "core/arm/skyeye_common/armdefs.h" | 19 | #include "core/arm/skyeye_common/armdefs.h" |
| 19 | #include "core/arm/skyeye_common/armemu.h" | 20 | #include "core/arm/skyeye_common/armemu.h" |
| 20 | 21 | ||
| @@ -23,7 +24,7 @@ | |||
| 23 | \***************************************************************************/ | 24 | \***************************************************************************/ |
| 24 | ARMul_State* ARMul_NewState(ARMul_State* state) | 25 | ARMul_State* ARMul_NewState(ARMul_State* state) |
| 25 | { | 26 | { |
| 26 | memset (state, 0, sizeof (ARMul_State)); | 27 | memset(state, 0, sizeof(ARMul_State)); |
| 27 | 28 | ||
| 28 | state->Emulate = RUN; | 29 | state->Emulate = RUN; |
| 29 | for (unsigned int i = 0; i < 16; i++) { | 30 | for (unsigned int i = 0; i < 16; i++) { |
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp index fd90fb0a4..ed4f6c2a2 100644 --- a/src/core/arm/interpreter/armsupp.cpp +++ b/src/core/arm/interpreter/armsupp.cpp | |||
| @@ -16,9 +16,6 @@ | |||
| 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 17 | 17 | ||
| 18 | #include "core/arm/skyeye_common/armdefs.h" | 18 | #include "core/arm/skyeye_common/armdefs.h" |
| 19 | #include "core/arm/skyeye_common/armemu.h" | ||
| 20 | #include "core/arm/disassembler/arm_disasm.h" | ||
| 21 | #include "core/mem_map.h" | ||
| 22 | 19 | ||
| 23 | // Unsigned sum of absolute difference | 20 | // Unsigned sum of absolute difference |
| 24 | u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right) | 21 | u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right) |
diff --git a/src/core/arm/skyeye_common/armdefs.h b/src/core/arm/skyeye_common/armdefs.h index dc2256a35..070fcf7dc 100644 --- a/src/core/arm/skyeye_common/armdefs.h +++ b/src/core/arm/skyeye_common/armdefs.h | |||
| @@ -17,19 +17,9 @@ | |||
| 17 | 17 | ||
| 18 | #pragma once | 18 | #pragma once |
| 19 | 19 | ||
| 20 | #include <cerrno> | ||
| 21 | #include <csignal> | ||
| 22 | #include <cstdio> | ||
| 23 | #include <cstdlib> | ||
| 24 | #include <cstring> | ||
| 25 | #include <fcntl.h> | ||
| 26 | #include <sys/stat.h> | ||
| 27 | #include <sys/types.h> | ||
| 28 | |||
| 29 | #include "arm_regformat.h" | ||
| 30 | #include "common/common_types.h" | 20 | #include "common/common_types.h" |
| 31 | #include "common/platform.h" | ||
| 32 | #include "core/arm/skyeye_common/armmmu.h" | 21 | #include "core/arm/skyeye_common/armmmu.h" |
| 22 | #include "core/arm/skyeye_common/arm_regformat.h" | ||
| 33 | #include "core/arm/skyeye_common/skyeye_defs.h" | 23 | #include "core/arm/skyeye_common/skyeye_defs.h" |
| 34 | 24 | ||
| 35 | #define BITS(s, a, b) ((s << ((sizeof(s) * 8 - 1) - b)) >> (sizeof(s) * 8 - b + a - 1)) | 25 | #define BITS(s, a, b) ((s << ((sizeof(s) * 8 - 1) - b)) >> (sizeof(s) * 8 - b + a - 1)) |
| @@ -118,9 +108,7 @@ struct ARMul_State | |||
| 118 | // Add armv6 flags dyf:2010-08-09 | 108 | // Add armv6 flags dyf:2010-08-09 |
| 119 | ARMword GEFlag, EFlag, AFlag, QFlag; | 109 | ARMword GEFlag, EFlag, AFlag, QFlag; |
| 120 | 110 | ||
| 121 | #ifdef MODET | ||
| 122 | ARMword TFlag; // Thumb state | 111 | ARMword TFlag; // Thumb state |
| 123 | #endif | ||
| 124 | 112 | ||
| 125 | unsigned long long NumInstrs; // The number of instructions executed | 113 | unsigned long long NumInstrs; // The number of instructions executed |
| 126 | unsigned NumInstrsToExecute; | 114 | unsigned NumInstrsToExecute; |
| @@ -218,8 +206,6 @@ So, if lateabtSig=1, then it means Late Abort Model(Base Updated Abort Model) | |||
| 218 | u32 CurrWrite; | 206 | u32 CurrWrite; |
| 219 | }; | 207 | }; |
| 220 | 208 | ||
| 221 | typedef ARMul_State arm_core_t; | ||
| 222 | |||
| 223 | /***************************************************************************\ | 209 | /***************************************************************************\ |
| 224 | * Types of ARM we know about * | 210 | * Types of ARM we know about * |
| 225 | \***************************************************************************/ | 211 | \***************************************************************************/ |
diff --git a/src/core/arm/skyeye_common/armemu.h b/src/core/arm/skyeye_common/armemu.h index 2467f4319..8bfd4e0f0 100644 --- a/src/core/arm/skyeye_common/armemu.h +++ b/src/core/arm/skyeye_common/armemu.h | |||
| @@ -19,61 +19,24 @@ | |||
| 19 | 19 | ||
| 20 | #include "core/arm/skyeye_common/armdefs.h" | 20 | #include "core/arm/skyeye_common/armdefs.h" |
| 21 | 21 | ||
| 22 | /* Macros to twiddle the status flags and mode. */ | 22 | // Flags for use with the APSR. |
| 23 | #define NBIT ((unsigned)1L << 31) | 23 | enum : u32 { |
| 24 | #define ZBIT (1L << 30) | 24 | NBIT = (1U << 31U), |
| 25 | #define CBIT (1L << 29) | 25 | ZBIT = (1 << 30), |
| 26 | #define VBIT (1L << 28) | 26 | CBIT = (1 << 29), |
| 27 | #define QBIT (1L << 27) | 27 | VBIT = (1 << 28), |
| 28 | #define IBIT (1L << 7) | 28 | QBIT = (1 << 27), |
| 29 | #define FBIT (1L << 6) | 29 | JBIT = (1 << 24), |
| 30 | #define IFBITS (3L << 6) | 30 | EBIT = (1 << 9), |
| 31 | #define R15IBIT (1L << 27) | 31 | ABIT = (1 << 8), |
| 32 | #define R15FBIT (1L << 26) | 32 | IBIT = (1 << 7), |
| 33 | #define R15IFBITS (3L << 26) | 33 | FBIT = (1 << 6), |
| 34 | TBIT = (1 << 5), | ||
| 34 | 35 | ||
| 35 | #if defined MODE32 || defined MODET | 36 | // Masks for groups of bits in the APSR. |
| 36 | #define CCBITS (0xf8000000L) | 37 | MODEBITS = 0x1F, |
| 37 | #else | 38 | INTBITS = 0xC0, |
| 38 | #define CCBITS (0xf0000000L) | 39 | }; |
| 39 | #endif | ||
| 40 | |||
| 41 | #define INTBITS (0xc0L) | ||
| 42 | |||
| 43 | #if defined MODET && defined MODE32 | ||
| 44 | #define PCBITS (0xffffffffL) | ||
| 45 | #else | ||
| 46 | #define PCBITS (0xfffffffcL) | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #define MODEBITS (0x1fL) | ||
| 50 | #define R15INTBITS (3L << 26) | ||
| 51 | |||
| 52 | #if defined MODET && defined MODE32 | ||
| 53 | #define R15PCBITS (0x03ffffffL) | ||
| 54 | #else | ||
| 55 | #define R15PCBITS (0x03fffffcL) | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #define R15MODEBITS (0x3L) | ||
| 59 | |||
| 60 | #ifdef MODE32 | ||
| 61 | #define PCMASK PCBITS | ||
| 62 | #define PCWRAP(pc) (pc) | ||
| 63 | #else | ||
| 64 | #define PCMASK R15PCBITS | ||
| 65 | #define PCWRAP(pc) ((pc) & R15PCBITS) | ||
| 66 | #endif | ||
| 67 | |||
| 68 | #define PC (state->Reg[15] & PCMASK) | ||
| 69 | #define R15CCINTMODE (state->Reg[15] & (CCBITS | R15INTBITS | R15MODEBITS)) | ||
| 70 | #define R15INT (state->Reg[15] & R15INTBITS) | ||
| 71 | #define R15INTPC (state->Reg[15] & (R15INTBITS | R15PCBITS)) | ||
| 72 | #define R15INTPCMODE (state->Reg[15] & (R15INTBITS | R15PCBITS | R15MODEBITS)) | ||
| 73 | #define R15INTMODE (state->Reg[15] & (R15INTBITS | R15MODEBITS)) | ||
| 74 | #define R15PC (state->Reg[15] & R15PCBITS) | ||
| 75 | #define R15PCMODE (state->Reg[15] & (R15PCBITS | R15MODEBITS)) | ||
| 76 | #define R15MODE (state->Reg[15] & R15MODEBITS) | ||
| 77 | 40 | ||
| 78 | // Different ways to start the next instruction. | 41 | // Different ways to start the next instruction. |
| 79 | enum { | 42 | enum { |
diff --git a/src/core/arm/skyeye_common/skyeye_defs.h b/src/core/arm/skyeye_common/skyeye_defs.h index 6648e9d66..edf6097e0 100644 --- a/src/core/arm/skyeye_common/skyeye_defs.h +++ b/src/core/arm/skyeye_common/skyeye_defs.h | |||
| @@ -1,57 +1,38 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #include "common/common.h" | 3 | #include "common/common_types.h" |
| 4 | 4 | ||
| 5 | #define MODE32 | 5 | struct cpu_config_t |
| 6 | #define MODET | ||
| 7 | |||
| 8 | typedef struct | ||
| 9 | { | 6 | { |
| 10 | const char *cpu_arch_name; /* CPU architecture version name.e.g. armv4t */ | 7 | const char* cpu_arch_name; // CPU architecture version name.e.g. ARMv4T |
| 11 | const char *cpu_name; /* CPU name. e.g. arm7tdmi or arm720t */ | 8 | const char* cpu_name; // CPU name. e.g. ARM7TDMI or ARM720T |
| 12 | u32 cpu_val; /*CPU value; also call MMU ID or processor id;see | 9 | u32 cpu_val; // CPU value; also call MMU ID or processor id;see |
| 13 | ARM Architecture Reference Manual B2-6 */ | 10 | // ARM Architecture Reference Manual B2-6 |
| 14 | u32 cpu_mask; /* cpu_val's mask. */ | 11 | u32 cpu_mask; // cpu_val's mask. |
| 15 | u32 cachetype; /* this CPU has what kind of cache */ | 12 | u32 cachetype; // CPU cache type |
| 16 | } cpu_config_t; | 13 | }; |
| 17 | 14 | ||
| 18 | typedef enum { | 15 | enum { |
| 19 | /* No exception */ | 16 | // No exception |
| 20 | No_exp = 0, | 17 | No_exp = 0, |
| 21 | /* Memory allocation exception */ | 18 | // Memory allocation exception |
| 22 | Malloc_exp, | 19 | Malloc_exp, |
| 23 | /* File open exception */ | 20 | // File open exception |
| 24 | File_open_exp, | 21 | File_open_exp, |
| 25 | /* DLL open exception */ | 22 | // DLL open exception |
| 26 | Dll_open_exp, | 23 | Dll_open_exp, |
| 27 | /* Invalid argument exception */ | 24 | // Invalid argument exception |
| 28 | Invarg_exp, | 25 | Invarg_exp, |
| 29 | /* Invalid module exception */ | 26 | // Invalid module exception |
| 30 | Invmod_exp, | 27 | Invmod_exp, |
| 31 | /* wrong format exception for config file parsing */ | 28 | // wrong format exception for config file parsing |
| 32 | Conf_format_exp, | 29 | Conf_format_exp, |
| 33 | /* some reference excess the predefiend range. Such as the index out of array range */ | 30 | // some reference excess the predefiend range. Such as the index out of array range |
| 34 | Excess_range_exp, | 31 | Excess_range_exp, |
| 35 | /* Can not find the desirable result */ | 32 | // Can not find the desirable result |
| 36 | Not_found_exp, | 33 | Not_found_exp, |
| 37 | 34 | // Unknown exception | |
| 38 | /* Unknown exception */ | 35 | Unknown_exp |
| 39 | Unknown_exp | 36 | }; |
| 40 | } exception_t; | ||
| 41 | |||
| 42 | typedef enum { | ||
| 43 | Align = 0, | ||
| 44 | UnAlign | ||
| 45 | } align_t; | ||
| 46 | |||
| 47 | typedef enum { | ||
| 48 | Little_endian = 0, | ||
| 49 | Big_endian | ||
| 50 | } endian_t; | ||
| 51 | |||
| 52 | typedef enum { | ||
| 53 | Phys_addr = 0, | ||
| 54 | Virt_addr | ||
| 55 | } addr_type_t; | ||
| 56 | 37 | ||
| 57 | typedef u32 addr_t; | 38 | typedef u32 addr_t; |
diff --git a/src/core/arm/skyeye_common/vfp/vfp.cpp b/src/core/arm/skyeye_common/vfp/vfp.cpp index 6f22923bb..6286e7b62 100644 --- a/src/core/arm/skyeye_common/vfp/vfp.cpp +++ b/src/core/arm/skyeye_common/vfp/vfp.cpp | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | /* Note: this file handles interface with arm core and vfp registers */ | 21 | /* Note: this file handles interface with arm core and vfp registers */ |
| 22 | 22 | ||
| 23 | #include "common/common.h" | 23 | #include "common/common.h" |
| 24 | #include "common/logging/log.h" | ||
| 24 | 25 | ||
| 25 | #include "core/arm/skyeye_common/armdefs.h" | 26 | #include "core/arm/skyeye_common/armdefs.h" |
| 26 | #include "core/arm/skyeye_common/vfp/asm_vfp.h" | 27 | #include "core/arm/skyeye_common/vfp/asm_vfp.h" |
| @@ -724,26 +725,26 @@ void VMOVR(ARMul_State* state, ARMword single, ARMword d, ARMword m) | |||
| 724 | } | 725 | } |
| 725 | 726 | ||
| 726 | /* Miscellaneous functions */ | 727 | /* Miscellaneous functions */ |
| 727 | int32_t vfp_get_float(arm_core_t* state, unsigned int reg) | 728 | int32_t vfp_get_float(ARMul_State* state, unsigned int reg) |
| 728 | { | 729 | { |
| 729 | LOG_TRACE(Core_ARM11, "VFP get float: s%d=[%08x]\n", reg, state->ExtReg[reg]); | 730 | LOG_TRACE(Core_ARM11, "VFP get float: s%d=[%08x]\n", reg, state->ExtReg[reg]); |
| 730 | return state->ExtReg[reg]; | 731 | return state->ExtReg[reg]; |
| 731 | } | 732 | } |
| 732 | 733 | ||
| 733 | void vfp_put_float(arm_core_t* state, int32_t val, unsigned int reg) | 734 | void vfp_put_float(ARMul_State* state, int32_t val, unsigned int reg) |
| 734 | { | 735 | { |
| 735 | LOG_TRACE(Core_ARM11, "VFP put float: s%d <= [%08x]\n", reg, val); | 736 | LOG_TRACE(Core_ARM11, "VFP put float: s%d <= [%08x]\n", reg, val); |
| 736 | state->ExtReg[reg] = val; | 737 | state->ExtReg[reg] = val; |
| 737 | } | 738 | } |
| 738 | 739 | ||
| 739 | uint64_t vfp_get_double(arm_core_t* state, unsigned int reg) | 740 | uint64_t vfp_get_double(ARMul_State* state, unsigned int reg) |
| 740 | { | 741 | { |
| 741 | uint64_t result = ((uint64_t) state->ExtReg[reg*2+1])<<32 | state->ExtReg[reg*2]; | 742 | uint64_t result = ((uint64_t) state->ExtReg[reg*2+1])<<32 | state->ExtReg[reg*2]; |
| 742 | LOG_TRACE(Core_ARM11, "VFP get double: s[%d-%d]=[%016llx]\n", reg * 2 + 1, reg * 2, result); | 743 | LOG_TRACE(Core_ARM11, "VFP get double: s[%d-%d]=[%016llx]\n", reg * 2 + 1, reg * 2, result); |
| 743 | return result; | 744 | return result; |
| 744 | } | 745 | } |
| 745 | 746 | ||
| 746 | void vfp_put_double(arm_core_t* state, uint64_t val, unsigned int reg) | 747 | void vfp_put_double(ARMul_State* state, uint64_t val, unsigned int reg) |
| 747 | { | 748 | { |
| 748 | LOG_TRACE(Core_ARM11, "VFP put double: s[%d-%d] <= [%08x-%08x]\n", reg * 2 + 1, reg * 2, (uint32_t)(val >> 32), (uint32_t)(val & 0xffffffff)); | 749 | LOG_TRACE(Core_ARM11, "VFP put double: s[%d-%d] <= [%08x-%08x]\n", reg * 2 + 1, reg * 2, (uint32_t)(val >> 32), (uint32_t)(val & 0xffffffff)); |
| 749 | state->ExtReg[reg*2] = (uint32_t) (val & 0xffffffff); | 750 | state->ExtReg[reg*2] = (uint32_t) (val & 0xffffffff); |
diff --git a/src/core/arm/skyeye_common/vfp/vfp_helper.h b/src/core/arm/skyeye_common/vfp/vfp_helper.h index b68090b80..75d860e95 100644 --- a/src/core/arm/skyeye_common/vfp/vfp_helper.h +++ b/src/core/arm/skyeye_common/vfp/vfp_helper.h | |||
| @@ -32,11 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | #pragma once | 33 | #pragma once |
| 34 | 34 | ||
| 35 | /* Custom edit */ | 35 | #include <cstdio> |
| 36 | |||
| 37 | #include <stdint.h> | ||
| 38 | #include <stdio.h> | ||
| 39 | |||
| 40 | #include "common/common_types.h" | 36 | #include "common/common_types.h" |
| 41 | #include "core/arm/skyeye_common/armdefs.h" | 37 | #include "core/arm/skyeye_common/armdefs.h" |
| 42 | 38 | ||
diff --git a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp index 9a7088088..17726b8bb 100644 --- a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp +++ b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | * =========================================================================== | 51 | * =========================================================================== |
| 52 | */ | 52 | */ |
| 53 | 53 | ||
| 54 | #include "common/logging/log.h" | ||
| 54 | #include "core/arm/skyeye_common/vfp/vfp.h" | 55 | #include "core/arm/skyeye_common/vfp/vfp.h" |
| 55 | #include "core/arm/skyeye_common/vfp/vfp_helper.h" | 56 | #include "core/arm/skyeye_common/vfp/vfp_helper.h" |
| 56 | #include "core/arm/skyeye_common/vfp/asm_vfp.h" | 57 | #include "core/arm/skyeye_common/vfp/asm_vfp.h" |