diff options
| author | 2015-07-25 20:19:39 -0400 | |
|---|---|---|
| committer | 2015-07-25 20:35:18 -0400 | |
| commit | 0191c26521930d439d5474dd2e861ef595405147 (patch) | |
| tree | 2804060011f6f34e5ca71f7c25ecd5206a5be524 /src/core | |
| parent | dyncom: Move arminit.cpp and armsupp.cpp into skyeye_common (diff) | |
| download | yuzu-0191c26521930d439d5474dd2e861ef595405147.tar.gz yuzu-0191c26521930d439d5474dd2e861ef595405147.tar.xz yuzu-0191c26521930d439d5474dd2e861ef595405147.zip | |
dyncom: Move helper functions to their own header
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom.cpp | 1 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_dec.cpp | 4 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_dec.h | 4 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 1 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_thumb.cpp | 1 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/armdefs.h | 34 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/armmmu.h | 1 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/armsupp.cpp | 9 | ||||
| -rw-r--r-- | src/core/arm/skyeye_common/armsupp.h | 42 |
10 files changed, 57 insertions, 41 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index adf15d66f..2fab2570f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -134,6 +134,7 @@ set(HEADERS | |||
| 134 | arm/skyeye_common/arm_regformat.h | 134 | arm/skyeye_common/arm_regformat.h |
| 135 | arm/skyeye_common/armdefs.h | 135 | arm/skyeye_common/armdefs.h |
| 136 | arm/skyeye_common/armmmu.h | 136 | arm/skyeye_common/armmmu.h |
| 137 | arm/skyeye_common/armsupp.h | ||
| 137 | arm/skyeye_common/vfp/asm_vfp.h | 138 | arm/skyeye_common/vfp/asm_vfp.h |
| 138 | arm/skyeye_common/vfp/vfp.h | 139 | arm/skyeye_common/vfp/vfp.h |
| 139 | arm/skyeye_common/vfp/vfp_helper.h | 140 | arm/skyeye_common/vfp/vfp_helper.h |
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp index 529c4ac70..60a1dcf66 100644 --- a/src/core/arm/dyncom/arm_dyncom.cpp +++ b/src/core/arm/dyncom/arm_dyncom.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "common/make_unique.h" | 7 | #include "common/make_unique.h" |
| 8 | 8 | ||
| 9 | #include "core/arm/skyeye_common/armdefs.h" | 9 | #include "core/arm/skyeye_common/armdefs.h" |
| 10 | #include "core/arm/skyeye_common/armsupp.h" | ||
| 10 | #include "core/arm/skyeye_common/vfp/vfp.h" | 11 | #include "core/arm/skyeye_common/vfp/vfp.h" |
| 11 | 12 | ||
| 12 | #include "core/arm/dyncom/arm_dyncom.h" | 13 | #include "core/arm/dyncom/arm_dyncom.h" |
diff --git a/src/core/arm/dyncom/arm_dyncom_dec.cpp b/src/core/arm/dyncom/arm_dyncom_dec.cpp index 697be9556..3ab9f2c17 100644 --- a/src/core/arm/dyncom/arm_dyncom_dec.cpp +++ b/src/core/arm/dyncom/arm_dyncom_dec.cpp | |||
| @@ -2,8 +2,8 @@ | |||
| 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/armdefs.h" | ||
| 6 | #include "core/arm/dyncom/arm_dyncom_dec.h" | 5 | #include "core/arm/dyncom/arm_dyncom_dec.h" |
| 6 | #include "core/arm/skyeye_common/armsupp.h" | ||
| 7 | 7 | ||
| 8 | const ISEITEM arm_instruction[] = { | 8 | const ISEITEM arm_instruction[] = { |
| 9 | { "vmla", 4, ARMVFP2, { 23, 27, 0x1C, 20, 21, 0x0, 9, 11, 0x5, 4, 4, 0 }}, | 9 | { "vmla", 4, ARMVFP2, { 23, 27, 0x1C, 20, 21, 0x0, 9, 11, 0x5, 4, 4, 0 }}, |
| @@ -414,7 +414,7 @@ const ISEITEM arm_exclusion_code[] = { | |||
| 414 | { "invalid", 0, INVALID, { 0 }} | 414 | { "invalid", 0, INVALID, { 0 }} |
| 415 | }; | 415 | }; |
| 416 | 416 | ||
| 417 | int decode_arm_instr(uint32_t instr, int32_t *idx) { | 417 | int decode_arm_instr(u32 instr, s32* idx) { |
| 418 | int n = 0; | 418 | int n = 0; |
| 419 | int base = 0; | 419 | int base = 0; |
| 420 | int ret = DECODE_FAILURE; | 420 | int ret = DECODE_FAILURE; |
diff --git a/src/core/arm/dyncom/arm_dyncom_dec.h b/src/core/arm/dyncom/arm_dyncom_dec.h index 4b5f5ad7e..5f6279627 100644 --- a/src/core/arm/dyncom/arm_dyncom_dec.h +++ b/src/core/arm/dyncom/arm_dyncom_dec.h | |||
| @@ -4,7 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | int decode_arm_instr(uint32_t instr, int32_t *idx); | 7 | #include "common/common_types.h" |
| 8 | |||
| 9 | int decode_arm_instr(u32 instr, s32* idx); | ||
| 8 | 10 | ||
| 9 | enum DECODE_STATUS { | 11 | enum DECODE_STATUS { |
| 10 | DECODE_SUCCESS, | 12 | DECODE_SUCCESS, |
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index 785f39566..d9db0daa0 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "core/arm/dyncom/arm_dyncom_run.h" | 19 | #include "core/arm/dyncom/arm_dyncom_run.h" |
| 20 | #include "core/arm/skyeye_common/armdefs.h" | 20 | #include "core/arm/skyeye_common/armdefs.h" |
| 21 | #include "core/arm/skyeye_common/armmmu.h" | 21 | #include "core/arm/skyeye_common/armmmu.h" |
| 22 | #include "core/arm/skyeye_common/armsupp.h" | ||
| 22 | #include "core/arm/skyeye_common/vfp/vfp.h" | 23 | #include "core/arm/skyeye_common/vfp/vfp.h" |
| 23 | 24 | ||
| 24 | Common::Profiling::TimingCategory profile_execute("DynCom::Execute"); | 25 | Common::Profiling::TimingCategory profile_execute("DynCom::Execute"); |
diff --git a/src/core/arm/dyncom/arm_dyncom_thumb.cpp b/src/core/arm/dyncom/arm_dyncom_thumb.cpp index f10a5b70f..13cc34be4 100644 --- a/src/core/arm/dyncom/arm_dyncom_thumb.cpp +++ b/src/core/arm/dyncom/arm_dyncom_thumb.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | // ARM instruction, and using the existing ARM simulator. | 6 | // ARM instruction, and using the existing ARM simulator. |
| 7 | 7 | ||
| 8 | #include "core/arm/dyncom/arm_dyncom_thumb.h" | 8 | #include "core/arm/dyncom/arm_dyncom_thumb.h" |
| 9 | #include "core/arm/skyeye_common/armsupp.h" | ||
| 9 | 10 | ||
| 10 | // Decode a 16bit Thumb instruction. The instruction is in the low 16-bits of the tinstr field, | 11 | // Decode a 16bit Thumb instruction. The instruction is in the low 16-bits of the tinstr field, |
| 11 | // with the following Thumb instruction held in the high 16-bits. Passing in two Thumb instructions | 12 | // with the following Thumb instruction held in the high 16-bits. Passing in two Thumb instructions |
diff --git a/src/core/arm/skyeye_common/armdefs.h b/src/core/arm/skyeye_common/armdefs.h index a0ec108c7..f183b5098 100644 --- a/src/core/arm/skyeye_common/armdefs.h +++ b/src/core/arm/skyeye_common/armdefs.h | |||
| @@ -22,9 +22,6 @@ | |||
| 22 | #include "common/common_types.h" | 22 | #include "common/common_types.h" |
| 23 | #include "core/arm/skyeye_common/arm_regformat.h" | 23 | #include "core/arm/skyeye_common/arm_regformat.h" |
| 24 | 24 | ||
| 25 | #define BITS(s, a, b) ((s << ((sizeof(s) * 8 - 1) - b)) >> (sizeof(s) * 8 - b + a - 1)) | ||
| 26 | #define BIT(s, n) ((s >> (n)) & 1) | ||
| 27 | |||
| 28 | // Signal levels | 25 | // Signal levels |
| 29 | enum { | 26 | enum { |
| 30 | LOW = 0, | 27 | LOW = 0, |
| @@ -47,9 +44,6 @@ enum { | |||
| 47 | ABORT_BASE_UPDATED = 2 | 44 | ABORT_BASE_UPDATED = 2 |
| 48 | }; | 45 | }; |
| 49 | 46 | ||
| 50 | #define POS(i) ( (~(i)) >> 31 ) | ||
| 51 | #define NEG(i) ( (i) >> 31 ) | ||
| 52 | |||
| 53 | typedef u64 ARMdword; // must be 64 bits wide | 47 | typedef u64 ARMdword; // must be 64 bits wide |
| 54 | typedef u32 ARMword; // must be 32 bits wide | 48 | typedef u32 ARMword; // must be 32 bits wide |
| 55 | typedef u16 ARMhword; // must be 16 bits wide | 49 | typedef u16 ARMhword; // must be 16 bits wide |
| @@ -288,31 +282,3 @@ enum { | |||
| 288 | ONCE = 2, // Execute just one iteration | 282 | ONCE = 2, // Execute just one iteration |
| 289 | RUN = 3 // Continuous execution | 283 | RUN = 3 // Continuous execution |
| 290 | }; | 284 | }; |
| 291 | |||
| 292 | |||
| 293 | bool AddOverflow(ARMword, ARMword, ARMword); | ||
| 294 | bool SubOverflow(ARMword, ARMword, ARMword); | ||
| 295 | |||
| 296 | void ARMul_SelectProcessor(ARMul_State*, unsigned); | ||
| 297 | |||
| 298 | u32 AddWithCarry(u32, u32, u32, bool*, bool*); | ||
| 299 | bool ARMul_AddOverflowQ(ARMword, ARMword); | ||
| 300 | |||
| 301 | u8 ARMul_SignedSaturatedAdd8(u8, u8); | ||
| 302 | u8 ARMul_SignedSaturatedSub8(u8, u8); | ||
| 303 | u16 ARMul_SignedSaturatedAdd16(u16, u16); | ||
| 304 | u16 ARMul_SignedSaturatedSub16(u16, u16); | ||
| 305 | |||
| 306 | u8 ARMul_UnsignedSaturatedAdd8(u8, u8); | ||
| 307 | u16 ARMul_UnsignedSaturatedAdd16(u16, u16); | ||
| 308 | u8 ARMul_UnsignedSaturatedSub8(u8, u8); | ||
| 309 | u16 ARMul_UnsignedSaturatedSub16(u16, u16); | ||
| 310 | u8 ARMul_UnsignedAbsoluteDifference(u8, u8); | ||
| 311 | u32 ARMul_SignedSatQ(s32, u8, bool*); | ||
| 312 | u32 ARMul_UnsignedSatQ(s32, u8, bool*); | ||
| 313 | |||
| 314 | bool InBigEndianMode(ARMul_State*); | ||
| 315 | bool InAPrivilegedMode(ARMul_State*); | ||
| 316 | |||
| 317 | u32 ReadCP15Register(ARMul_State* cpu, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2); | ||
| 318 | void WriteCP15Register(ARMul_State* cpu, u32 value, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2); | ||
diff --git a/src/core/arm/skyeye_common/armmmu.h b/src/core/arm/skyeye_common/armmmu.h index c67d7209b..6aa2e0771 100644 --- a/src/core/arm/skyeye_common/armmmu.h +++ b/src/core/arm/skyeye_common/armmmu.h | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | #include "core/memory.h" | 25 | #include "core/memory.h" |
| 26 | #include "core/arm/skyeye_common/armdefs.h" | 26 | #include "core/arm/skyeye_common/armdefs.h" |
| 27 | #include "core/arm/skyeye_common/armsupp.h" | ||
| 27 | 28 | ||
| 28 | // Register numbers in the MMU | 29 | // Register numbers in the MMU |
| 29 | enum | 30 | enum |
diff --git a/src/core/arm/skyeye_common/armsupp.cpp b/src/core/arm/skyeye_common/armsupp.cpp index 83f7f3e2c..e1d4509c4 100644 --- a/src/core/arm/skyeye_common/armsupp.cpp +++ b/src/core/arm/skyeye_common/armsupp.cpp | |||
| @@ -18,8 +18,9 @@ | |||
| 18 | #include "common/logging/log.h" | 18 | #include "common/logging/log.h" |
| 19 | 19 | ||
| 20 | #include "core/mem_map.h" | 20 | #include "core/mem_map.h" |
| 21 | #include "core/arm/skyeye_common/armdefs.h" | ||
| 22 | #include "core/arm/skyeye_common/arm_regformat.h" | 21 | #include "core/arm/skyeye_common/arm_regformat.h" |
| 22 | #include "core/arm/skyeye_common/armdefs.h" | ||
| 23 | #include "core/arm/skyeye_common/armsupp.h" | ||
| 23 | 24 | ||
| 24 | // Unsigned sum of absolute difference | 25 | // Unsigned sum of absolute difference |
| 25 | u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right) | 26 | u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right) |
| @@ -47,21 +48,21 @@ u32 AddWithCarry(u32 left, u32 right, u32 carry_in, bool* carry_out_occurred, bo | |||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | // Compute whether an addition of A and B, giving RESULT, overflowed. | 50 | // Compute whether an addition of A and B, giving RESULT, overflowed. |
| 50 | bool AddOverflow(ARMword a, ARMword b, ARMword result) | 51 | bool AddOverflow(u32 a, u32 b, u32 result) |
| 51 | { | 52 | { |
| 52 | return ((NEG(a) && NEG(b) && POS(result)) || | 53 | return ((NEG(a) && NEG(b) && POS(result)) || |
| 53 | (POS(a) && POS(b) && NEG(result))); | 54 | (POS(a) && POS(b) && NEG(result))); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | // Compute whether a subtraction of A and B, giving RESULT, overflowed. | 57 | // Compute whether a subtraction of A and B, giving RESULT, overflowed. |
| 57 | bool SubOverflow(ARMword a, ARMword b, ARMword result) | 58 | bool SubOverflow(u32 a, u32 b, u32 result) |
| 58 | { | 59 | { |
| 59 | return ((NEG(a) && POS(b) && POS(result)) || | 60 | return ((NEG(a) && POS(b) && POS(result)) || |
| 60 | (POS(a) && NEG(b) && NEG(result))); | 61 | (POS(a) && NEG(b) && NEG(result))); |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | // Returns true if the Q flag should be set as a result of overflow. | 64 | // Returns true if the Q flag should be set as a result of overflow. |
| 64 | bool ARMul_AddOverflowQ(ARMword a, ARMword b) | 65 | bool ARMul_AddOverflowQ(u32 a, u32 b) |
| 65 | { | 66 | { |
| 66 | u32 result = a + b; | 67 | u32 result = a + b; |
| 67 | if (((result ^ a) & (u32)0x80000000) && ((a ^ b) & (u32)0x80000000) == 0) | 68 | if (((result ^ a) & (u32)0x80000000) && ((a ^ b) & (u32)0x80000000) == 0) |
diff --git a/src/core/arm/skyeye_common/armsupp.h b/src/core/arm/skyeye_common/armsupp.h new file mode 100644 index 000000000..d82b21107 --- /dev/null +++ b/src/core/arm/skyeye_common/armsupp.h | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | struct ARMul_State; | ||
| 10 | |||
| 11 | #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) | ||
| 13 | |||
| 14 | #define POS(i) ( (~(i)) >> 31 ) | ||
| 15 | #define NEG(i) ( (i) >> 31 ) | ||
| 16 | |||
| 17 | bool AddOverflow(u32, u32, u32); | ||
| 18 | bool SubOverflow(u32, u32, u32); | ||
| 19 | |||
| 20 | void ARMul_SelectProcessor(ARMul_State*, unsigned); | ||
| 21 | |||
| 22 | u32 AddWithCarry(u32, u32, u32, bool*, bool*); | ||
| 23 | bool ARMul_AddOverflowQ(u32, u32); | ||
| 24 | |||
| 25 | u8 ARMul_SignedSaturatedAdd8(u8, u8); | ||
| 26 | u8 ARMul_SignedSaturatedSub8(u8, u8); | ||
| 27 | u16 ARMul_SignedSaturatedAdd16(u16, u16); | ||
| 28 | u16 ARMul_SignedSaturatedSub16(u16, u16); | ||
| 29 | |||
| 30 | u8 ARMul_UnsignedSaturatedAdd8(u8, u8); | ||
| 31 | u16 ARMul_UnsignedSaturatedAdd16(u16, u16); | ||
| 32 | u8 ARMul_UnsignedSaturatedSub8(u8, u8); | ||
| 33 | u16 ARMul_UnsignedSaturatedSub16(u16, u16); | ||
| 34 | u8 ARMul_UnsignedAbsoluteDifference(u8, u8); | ||
| 35 | u32 ARMul_SignedSatQ(s32, u8, bool*); | ||
| 36 | u32 ARMul_UnsignedSatQ(s32, u8, bool*); | ||
| 37 | |||
| 38 | bool InBigEndianMode(ARMul_State*); | ||
| 39 | bool InAPrivilegedMode(ARMul_State*); | ||
| 40 | |||
| 41 | u32 ReadCP15Register(ARMul_State* cpu, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2); | ||
| 42 | void WriteCP15Register(ARMul_State* cpu, u32 value, u32 crn, u32 opcode_1, u32 crm, u32 opcode_2); | ||