diff --git a/README.md b/README.md index b63652fffb..24c073a32b 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,14 @@ RPCS3 ===== [![Build Status](https://travis-ci.org/DHrpcs3/rpcs3.svg?branch=master)](https://travis-ci.org/DHrpcs3/rpcs3) + Coverity Scan Build Status +[![Coverage Status](https://coveralls.io/repos/DHrpcs3/rpcs3/badge.svg)](https://coveralls.io/r/DHrpcs3/rpcs3) + An open-source PlayStation 3 emulator/debugger written in C++. You can find some basic information in the [FAQ](https://github.com/DHrpcs3/rpcs3/wiki/FAQ). For discussion about this emulator and PS3 emulation please visit the [official forums](http://www.emunewz.net/forum/forumdisplay.php?fid=162). diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 557a51ec4a..3bc464fcb8 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -206,8 +206,6 @@ namespace fmt { throw "Invalid formatting (u8): " + std::string(fmt, len); } - - return{}; } }; @@ -228,8 +226,6 @@ namespace fmt { throw "Invalid formatting (u16): " + std::string(fmt, len); } - - return{}; } }; @@ -250,8 +246,6 @@ namespace fmt { throw "Invalid formatting (u32): " + std::string(fmt, len); } - - return{}; } }; @@ -272,8 +266,6 @@ namespace fmt { throw "Invalid formatting (u64): " + std::string(fmt, len); } - - return{}; } }; @@ -294,8 +286,6 @@ namespace fmt { throw "Invalid formatting (s8): " + std::string(fmt, len); } - - return{}; } }; @@ -316,8 +306,6 @@ namespace fmt { throw "Invalid formatting (s16): " + std::string(fmt, len); } - - return{}; } }; @@ -338,8 +326,6 @@ namespace fmt { throw "Invalid formatting (s32): " + std::string(fmt, len); } - - return{}; } }; @@ -360,8 +346,6 @@ namespace fmt { throw "Invalid formatting (s64): " + std::string(fmt, len); } - - return{}; } }; @@ -382,8 +366,6 @@ namespace fmt { throw "Invalid formatting (float): " + std::string(fmt, len); } - - return{}; } }; @@ -404,8 +386,6 @@ namespace fmt { throw "Invalid formatting (double): " + std::string(fmt, len); } - - return{}; } }; @@ -430,8 +410,6 @@ namespace fmt { throw "Invalid formatting (bool): " + std::string(fmt, len); } - - return{}; } }; @@ -448,8 +426,6 @@ namespace fmt { throw "Invalid formatting (const char*): " + std::string(fmt, len); } - - return{}; } }; diff --git a/Utilities/rFile.cpp b/Utilities/rFile.cpp index e6f657d39e..39fa91eceb 100644 --- a/Utilities/rFile.cpp +++ b/Utilities/rFile.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Log.h" +#pragma warning(disable : 4996) #include #include #include diff --git a/Utilities/rMsgBox.cpp b/Utilities/rMsgBox.cpp index cd3a46be0d..cf4c027096 100644 --- a/Utilities/rMsgBox.cpp +++ b/Utilities/rMsgBox.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "restore_new.h" +#pragma warning(disable : 4996) #include #include "define_new_memleakdetect.h" #include "rMsgBox.h" diff --git a/Utilities/rPlatform.cpp b/Utilities/rPlatform.cpp index a947b7a00f..57a32e1425 100644 --- a/Utilities/rPlatform.cpp +++ b/Utilities/rPlatform.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "restore_new.h" +#pragma warning(disable : 4996) #include #include "define_new_memleakdetect.h" diff --git a/Utilities/rTime.cpp b/Utilities/rTime.cpp index fccb0ac7df..194394317c 100644 --- a/Utilities/rTime.cpp +++ b/Utilities/rTime.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" #include "rTime.h" - +#pragma warning(disable : 4996) #include std::string rDefaultDateTimeFormat = "%c"; diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index 65e1d3e394..b4d18eb92d 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -5,6 +5,7 @@ #include "key_vault.h" #include "unpkg.h" #include "restore_new.h" +#pragma warning(disable : 4996) #include #include "define_new_memleakdetect.h" diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 28b464c100..954f29eb22 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -6,7 +6,7 @@ #include "utils.h" #include "Emu/FS/vfsLocalFile.h" #include "unself.h" - +#pragma warning(disable : 4996) #include #include diff --git a/rpcs3/Emu/ARMv7/ARMv7Context.h b/rpcs3/Emu/ARMv7/ARMv7Context.h index be06cc4a45..491e0a0845 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Context.h +++ b/rpcs3/Emu/ARMv7/ARMv7Context.h @@ -18,7 +18,6 @@ struct ARMv7Context void write_pc(u32 value); u32 read_pc(); - void put_stack_arg(u32 shift, u32 value); u32 get_stack_arg(u32 pos); void fast_call(u32 addr); @@ -39,6 +38,11 @@ struct ARMv7Context u32 LR; }; + + struct + { + u64 GPR_D[8]; + }; }; union diff --git a/rpcs3/Emu/ARMv7/ARMv7Decoder.cpp b/rpcs3/Emu/ARMv7/ARMv7Decoder.cpp index 42bda91fd6..f913bcbb8a 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Decoder.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Decoder.cpp @@ -649,8 +649,8 @@ const ARMv7_opcode_t ARMv7_opcode_table[] = ARMv7_OP4(0xfff0, 0xf0f0, 0xfac0, 0xf040, T1, USUB8), ARMv7_OP4(0x0ff0, 0x0ff0, 0x0650, 0x0ff0, A1, USUB8), - ARMv7_OP4(0xfff0, 0xf0c0, 0xfa50, 0xf080, T1, UXTAB), - ARMv7_OP4(0x0ff0, 0x03f0, 0x06e0, 0x0070, A1, UXTAB), + ARMv7_OP4(0xfff0, 0xf0c0, 0xfa50, 0xf080, T1, UXTAB, SKIP_IF( BF(16, 19) == 15 )), + ARMv7_OP4(0x0ff0, 0x03f0, 0x06e0, 0x0070, A1, UXTAB, SKIP_IF( BF(16, 19) == 15 )), ARMv7_OP4(0xfff0, 0xf0c0, 0xfa30, 0xf080, T1, UXTAB16), ARMv7_OP4(0x0ff0, 0x03f0, 0x06c0, 0x0070, A1, UXTAB16), diff --git a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp index c6292e371a..e6cd7dc651 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp @@ -8,253 +8,276 @@ #include "PSVFuncList.h" #include "ARMv7Interpreter.h" -template -u8 ARMv7_instrs::BitCount(T x, u8 len) -{ - u8 result = 0; +#define reject(cond, info) { if (cond) Error(__FUNCTION__, code, type, #cond, info); } - for (u8 mask = 1 << (len - 1); mask; mask >>= 1) +namespace ARMv7_instrs +{ + template + u32 BitCount(T x, size_t len = sizeof(T) * 8) { - if (x & mask) result++; - } + u32 result = 0; - return result; -} - -template -s8 ARMv7_instrs::LowestSetBit(T x, u8 len) -{ - if (!x) return len; - - u8 result = 0; - - for (T mask = 1, i = 0; i -s8 ARMv7_instrs::HighestSetBit(T x, u8 len) -{ - if (!x) return -1; - - u8 result = len; - - for (T mask = T(1) << (len - 1); (x & mask) == 0; mask >>= 1) - { - result--; - } - - return result; -} - -template -s8 ARMv7_instrs::CountLeadingZeroBits(T x, u8 len) -{ - return len - 1 - HighestSetBit(x, len); -} - -SRType ARMv7_instrs::DecodeImmShift(u32 type, u32 imm5, u32* shift_n) -{ - SRType shift_t = SRType_None; - - switch (type) - { - case 0: shift_t = SRType_LSL; if (shift_n) *shift_n = imm5; break; - case 1: shift_t = SRType_LSR; if (shift_n) *shift_n = imm5 == 0 ? 32 : imm5; break; - case 2: shift_t = SRType_ASR; if (shift_n) *shift_n = imm5 == 0 ? 32 : imm5; break; - case 3: - if (imm5 == 0) + for (T mask = static_cast(1) << (len - 1); mask; mask >>= 1) { - shift_t = SRType_RRX; if (shift_n) *shift_n = 1; + if (x & mask) result++; + } + + return result; + } + + //template + //s8 LowestSetBit(T x, u8 len) + //{ + // if (!x) return len; + + // u8 result = 0; + + // for (T mask = 1, i = 0; i + //s8 HighestSetBit(T x, u8 len) + //{ + // if (!x) return -1; + + // u8 result = len; + + // for (T mask = T(1) << (len - 1); (x & mask) == 0; mask >>= 1) + // { + // result--; + // } + + // return result; + //} + + //template + //s8 CountLeadingZeroBits(T x, u8 len) + //{ + // return len - 1 - HighestSetBit(x, len); + //} + + SRType DecodeImmShift(u32 type, u32 imm5, u32* shift_n) + { + SRType shift_t = SRType_None; + + switch (type) + { + case 0: shift_t = SRType_LSL; if (shift_n) *shift_n = imm5; break; + case 1: shift_t = SRType_LSR; if (shift_n) *shift_n = imm5 == 0 ? 32 : imm5; break; + case 2: shift_t = SRType_ASR; if (shift_n) *shift_n = imm5 == 0 ? 32 : imm5; break; + case 3: + if (imm5 == 0) + { + shift_t = SRType_RRX; if (shift_n) *shift_n = 1; + } + else + { + shift_t = SRType_ROR; if (shift_n) *shift_n = imm5; + } + break; + } + + return shift_t; + } + + SRType DecodeRegShift(u8 type) + { + SRType shift_t = SRType_None; + + switch (type) + { + case 0: shift_t = SRType_LSL; break; + case 1: shift_t = SRType_LSR; break; + case 2: shift_t = SRType_ASR; break; + case 3: shift_t = SRType_ROR; break; + } + + return shift_t; + } + + u32 LSL_C(u32 x, s32 shift, bool& carry_out) + { + assert(shift > 0); + carry_out = shift <= 32 ? x & (1 << (32 - shift)) : false; + return shift < 32 ? x << shift : 0; + } + + u32 LSL_(u32 x, s32 shift) + { + assert(shift >= 0); + return shift < 32 ? x << shift : 0; + } + + u32 LSR_C(u32 x, s32 shift, bool& carry_out) + { + assert(shift > 0); + carry_out = shift <= 32 ? x & (1 << (shift - 1)) : false; + return shift < 32 ? x >> shift : 0; + } + + u32 LSR_(u32 x, s32 shift) + { + assert(shift >= 0); + return shift < 32 ? x >> shift : 0; + } + + s32 ASR_C(s32 x, s32 shift, bool& carry_out) + { + assert(shift > 0); + carry_out = shift <= 32 ? x & (1 << (shift - 1)) : false; + return shift < 32 ? x >> shift : x >> 31; + } + + s32 ASR_(s32 x, s32 shift) + { + assert(shift >= 0); + return shift < 32 ? x >> shift : x >> 31; + } + + u32 ROR_C(u32 x, s32 shift, bool& carry_out) + { + assert(shift); + carry_out = x & (1 << (shift - 1)); + return x >> shift | x << (32 - shift); + } + + u32 ROR_(u32 x, s32 shift) + { + return x >> shift | x << (32 - shift); + } + + u32 RRX_C(u32 x, bool carry_in, bool& carry_out) + { + carry_out = x & 0x1; + return ((u32)carry_in << 31) | (x >> 1); + } + + u32 RRX_(u32 x, bool carry_in) + { + return ((u32)carry_in << 31) | (x >> 1); + } + + u32 Shift_C(u32 value, u32 type, s32 amount, bool carry_in, bool& carry_out) + { + assert(type != SRType_RRX || amount == 1); + + if (amount) + { + switch (type) + { + case SRType_LSL: return LSL_C(value, amount, carry_out); + case SRType_LSR: return LSR_C(value, amount, carry_out); + case SRType_ASR: return ASR_C(value, amount, carry_out); + case SRType_ROR: return ROR_C(value, amount, carry_out); + case SRType_RRX: return RRX_C(value, carry_in, carry_out); + default: throw __FUNCTION__; + } + } + + carry_out = carry_in; + return value; + } + + u32 Shift(u32 value, u32 type, s32 amount, bool carry_in) + { + bool carry_out; + return Shift_C(value, type, amount, carry_in, carry_out); + } + + template T AddWithCarry(T x, T y, bool carry_in, bool& carry_out, bool& overflow) + { + const T sign_mask = (T)1 << (sizeof(T) - 1); + + T result = x + y; + carry_out = ((x & y) | ((x ^ y) & ~result)) & sign_mask; + overflow = (x ^ result) & (y ^ result) & sign_mask; + if (carry_in) + { + result += 1; + carry_out ^= (result == 0); + overflow ^= (result == sign_mask); + } + return result; + } + + u32 ThumbExpandImm_C(u32 imm12, bool carry_in, bool& carry_out) + { + if ((imm12 & 0xc00) >> 10) + { + u32 unrotated_value = (imm12 & 0x7f) | 0x80; + + return ROR_C(unrotated_value, (imm12 & 0xf80) >> 7, carry_out); } else { - shift_t = SRType_ROR; if (shift_n) *shift_n = imm5; + carry_out = carry_in; + + u32 imm8 = imm12 & 0xff; + switch ((imm12 & 0x300) >> 8) + { + case 0: return imm8; + case 1: return imm8 << 16 | imm8; + case 2: return imm8 << 24 | imm8 << 8; + default: return imm8 << 24 | imm8 << 16 | imm8 << 8 | imm8; + } } - break; } - return shift_t; -} - -SRType ARMv7_instrs::DecodeRegShift(u8 type) -{ - SRType shift_t = SRType_None; - - switch (type) + u32 ThumbExpandImm(ARMv7Context& context, u32 imm12) { - case 0: shift_t = SRType_LSL; break; - case 1: shift_t = SRType_LSR; break; - case 2: shift_t = SRType_ASR; break; - case 3: shift_t = SRType_ROR; break; + bool carry = context.APSR.C; + return ThumbExpandImm_C(imm12, carry, carry); } - return shift_t; -} - -u32 ARMv7_instrs::LSL_C(u32 x, s32 shift, bool& carry_out) -{ - assert(shift > 0); - carry_out = shift <= 32 ? x & (1 << (32 - shift)) : false; - return shift < 32 ? x << shift : 0; -} - -u32 ARMv7_instrs::LSL_(u32 x, s32 shift) -{ - assert(shift >= 0); - return shift < 32 ? x << shift : 0; -} - -u32 ARMv7_instrs::LSR_C(u32 x, s32 shift, bool& carry_out) -{ - assert(shift > 0); - carry_out = shift <= 32 ? x & (1 << (shift - 1)) : false; - return shift < 32 ? x >> shift : 0; -} - -u32 ARMv7_instrs::LSR_(u32 x, s32 shift) -{ - assert(shift >= 0); - return shift < 32 ? x >> shift : 0; -} - -s32 ARMv7_instrs::ASR_C(s32 x, s32 shift, bool& carry_out) -{ - assert(shift > 0); - carry_out = shift <= 32 ? x & (1 << (shift - 1)) : false; - return shift < 32 ? x >> shift : x >> 31; -} - -s32 ARMv7_instrs::ASR_(s32 x, s32 shift) -{ - assert(shift >= 0); - return shift < 32 ? x >> shift : x >> 31; -} - -u32 ARMv7_instrs::ROR_C(u32 x, s32 shift, bool& carry_out) -{ - assert(shift); - carry_out = x & (1 << (shift - 1)); - return x >> shift | x << (32 - shift); -} - -u32 ARMv7_instrs::ROR_(u32 x, s32 shift) -{ - return x >> shift | x << (32 - shift); -} - -u32 ARMv7_instrs::RRX_C(u32 x, bool carry_in, bool& carry_out) -{ - carry_out = x & 0x1; - return ((u32)carry_in << 31) | (x >> 1); -} - -u32 ARMv7_instrs::RRX_(u32 x, bool carry_in) -{ - return ((u32)carry_in << 31) | (x >> 1); -} - -template T ARMv7_instrs::Shift_C(T value, SRType type, s32 amount, bool carry_in, bool& carry_out) -{ - assert(type != SRType_RRX || amount == 1); - - if (amount) + bool ConditionPassed(ARMv7Context& context, u32 cond) { - switch (type) + bool result = false; + + switch (cond >> 1) { - case SRType_LSL: return LSL_C(value, amount, carry_out); - case SRType_LSR: return LSR_C(value, amount, carry_out); - case SRType_ASR: return ASR_C(value, amount, carry_out); - case SRType_ROR: return ROR_C(value, amount, carry_out); - case SRType_RRX: return RRX_C(value, carry_in, carry_out); - default: throw __FUNCTION__; + case 0: result = context.APSR.Z == 1; break; + case 1: result = context.APSR.C == 1; break; + case 2: result = context.APSR.N == 1; break; + case 3: result = context.APSR.V == 1; break; + case 4: result = context.APSR.C == 1 && context.APSR.Z == 0; break; + case 5: result = context.APSR.N == context.APSR.V; break; + case 6: result = context.APSR.N == context.APSR.V && context.APSR.Z == 0; break; + case 7: return true; } - } - carry_out = carry_in; - return value; -} - -template T ARMv7_instrs::Shift(T value, SRType type, s32 amount, bool carry_in) -{ - bool carry_out; - return Shift_C(value, type, amount, carry_in, carry_out); -} - -template T ARMv7_instrs::AddWithCarry(T x, T y, bool carry_in, bool& carry_out, bool& overflow) -{ - const T sign_mask = (T)1 << (sizeof(T) - 1); - - T result = x + y; - carry_out = ((x & y) | ((x ^ y) & ~result)) & sign_mask; - overflow = (x ^ result) & (y ^ result) & sign_mask; - if (carry_in) - { - result += 1; - carry_out ^= (result == 0); - overflow ^= (result == sign_mask); - } - return result; -} - -u32 ARMv7_instrs::ThumbExpandImm_C(u32 imm12, bool carry_in, bool& carry_out) -{ - if ((imm12 & 0xc00) >> 10) - { - u32 unrotated_value = (imm12 & 0x7f) | 0x80; - - return ROR_C(unrotated_value, (imm12 & 0xf80) >> 7, carry_out); - } - else - { - carry_out = carry_in; - - u32 imm8 = imm12 & 0xff; - switch ((imm12 & 0x300) >> 8) + if (cond & 0x1) { - case 0: return imm8; - case 1: return imm8 << 16 | imm8; - case 2: return imm8 << 24 | imm8 << 8; - default: return imm8 << 24 | imm8 << 16 | imm8 << 8 | imm8; + return !result; } + + return result; } -} -u32 ARMv7_instrs::ThumbExpandImm(ARMv7Context& context, u32 imm12) -{ - bool carry = context.APSR.C; - return ThumbExpandImm_C(imm12, carry, carry); -} - -bool ARMv7_instrs::ConditionPassed(ARMv7Context& context, u32 cond) -{ - bool result = false; - - switch (cond >> 1) + void Error(const char* func, const ARMv7Code code, const ARMv7_encoding type, const char* cond, const char* info) { - case 0: result = context.APSR.Z == 1; break; - case 1: result = context.APSR.C == 1; break; - case 2: result = context.APSR.N == 1; break; - case 3: result = context.APSR.V == 1; break; - case 4: result = context.APSR.C == 1 && context.APSR.Z == 0; break; - case 5: result = context.APSR.N == context.APSR.V; break; - case 6: result = context.APSR.N == context.APSR.V && context.APSR.Z == 0; break; - case 7: return true; - } + auto format_encoding = [](const ARMv7_encoding type) -> const char* + { + switch (type) + { + case T1: return "T1"; + case T2: return "T2"; + case T3: return "T3"; + case T4: return "T4"; + case A1: return "A1"; + case A2: return "A2"; + default: return "???"; + } + }; - if (cond & 0x1) - { - return !result; + throw fmt::format("%s(%s) error: %s (%s)", func, format_encoding(type), info, cond); } - - return result; } -// instructions void ARMv7_instrs::UNK(ARMv7Context& context, const ARMv7Code code) { throw fmt::format("Unknown/illegal opcode: 0x%04x 0x%04x", code.code1, code.code0); @@ -267,13 +290,13 @@ void ARMv7_instrs::NULL_OP(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::HACK(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 func = 0; + u32 cond, func; switch (type) { case T1: { + cond = context.ITSTATE.advance(); func = code.data & 0xffff; break; } @@ -294,19 +317,14 @@ void ARMv7_instrs::HACK(ARMv7Context& context, const ARMv7Code code, const ARMv7 void ARMv7_instrs::MRC_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 t = 0; - u32 cp = 0; - u32 opc1 = 0; - u32 opc2 = 0; - u32 cn = 0; - u32 cm = 0; + u32 cond, t, cp, opc1, opc2, cn, cm; switch (type) { case T1: case A1: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; cp = (code.data & 0xf00) >> 8; opc1 = (code.data & 0xe00000) >> 21; @@ -314,10 +332,8 @@ void ARMv7_instrs::MRC_(ARMv7Context& context, const ARMv7Code code, const ARMv7 cn = (code.data & 0xf0000) >> 16; cm = (code.data & 0xf); - if (cp - 10 < 2) - { - throw "MRC_(T1/A1): Advanced SIMD and VFP"; - } + reject(cp - 10 < 2, "Advanced SIMD and VFP"); + reject(t == 13 && type == T1, "UNPREDICTABLE"); break; } default: throw __FUNCTION__; @@ -371,15 +387,13 @@ void ARMv7_instrs::ADC_RSR(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::ADD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { bool set_flags = !context.ITSTATE; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 n = 0; - u32 imm32 = 0; + u32 cond, d, n, imm32; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0x7); n = (code.data & 0x38) >> 3; imm32 = (code.data & 0x1c0) >> 6; @@ -387,42 +401,35 @@ void ARMv7_instrs::ADD_IMM(ARMv7Context& context, const ARMv7Code code, const AR } case T2: { + cond = context.ITSTATE.advance(); d = n = (code.data & 0x700) >> 8; imm32 = (code.data & 0xff); break; } case T3: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; set_flags = (code.data & 0x100000); imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); - if (d == 15 && set_flags) - { - throw "ADD_IMM_T3: CMN (immediate)"; - } - if (n == 13) - { - throw "ADD_IMM_T3: ADD (SP plus immediate)"; - } + reject(d == 15 && set_flags, "CMN (immediate)"); + reject(n == 13, "ADD (SP plus immediate)"); + reject(d == 13 || n == 15, "UNPREDICTABLE"); break; } case T4: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; set_flags = false; imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); - if (n == 15) - { - throw "ADD_IMM_T4: ADR"; - } - if (n == 13) - { - throw "ADD_IMM_T4: ADD (SP plus immediate)"; - } + reject(n == 15, "ADR"); + reject(n == 13, "ADD (SP plus immediate)"); + reject(d == 13 || d == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -451,50 +458,46 @@ void ARMv7_instrs::ADD_IMM(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::ADD_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { bool set_flags = !context.ITSTATE; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 n = 0; - u32 m = 0; - auto shift_t = SRType_LSL; - u32 shift_n = 0; + u32 cond, d, n, m, shift_t, shift_n; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0x7); n = (code.data & 0x38) >> 3; m = (code.data & 0x1c0) >> 6; + shift_t = SRType_LSL; + shift_n = 0; break; } case T2: { + cond = context.ITSTATE.advance(); n = d = (code.data & 0x80) >> 4 | (code.data & 0x7); m = (code.data & 0x78) >> 3; set_flags = false; + shift_t = SRType_LSL; + shift_n = 0; - if (n == 13 || m == 13) - { - throw "ADD_REG_T2: ADD (SP plus register)"; - } + reject(n == 13 || m == 13, "ADD (SP plus register)"); + reject(n == 15 && m == 15, "UNPREDICTABLE"); + reject(d == 15 && context.ITSTATE, "UNPREDICTABLE"); break; } case T3: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; m = (code.data & 0xf); set_flags = (code.data & 0x100000); shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); - if (d == 15 && set_flags) - { - throw "ADD_REG_T3: CMN (register)"; - } - if (n == 13) - { - throw "ADD_REG_T3: ADD (SP plus register)"; - } + reject(d == 15 && set_flags, "CMN (register)"); + reject(n == 13, "ADD (SP plus register)"); + reject(d == 13 || n == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -532,41 +535,46 @@ void ARMv7_instrs::ADD_RSR(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::ADD_SPI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 d = 13; - bool set_flags = false; - u32 imm32 = 0; + bool set_flags; + u32 cond, d, imm32; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0x700) >> 8; + set_flags = false; imm32 = (code.data & 0xff) << 2; break; } case T2: { + cond = context.ITSTATE.advance(); + d = 13; + set_flags = false; imm32 = (code.data & 0x7f) << 2; break; } case T3: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; set_flags = (code.data & 0x100000); imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); - if (d == 15 && set_flags) - { - throw "ADD_SPI_T3: CMN (immediate)"; - } + reject(d == 15 && set_flags, "CMN (immediate)"); + reject(d == 15, "UNPREDICTABLE"); break; } case T4: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; set_flags = false; imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); + + reject(d == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -594,36 +602,42 @@ void ARMv7_instrs::ADD_SPI(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::ADD_SPR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 d = 13; - u32 m = 0; - bool set_flags = false; - auto shift_t = SRType_LSL; - u32 shift_n = 0; + bool set_flags; + u32 cond, d, m, shift_t, shift_n; switch (type) { case T1: { - m = d = (code.data & 0x80) >> 4 | (code.data & 0x7); + cond = context.ITSTATE.advance(); + d = m = (code.data & 0x80) >> 4 | (code.data & 0x7); + set_flags = false; + shift_t = SRType_LSL; + shift_n = 0; break; } case T2: { + cond = context.ITSTATE.advance(); + d = 13; m = (code.data & 0x78) >> 3; + set_flags = false; + shift_t = SRType_LSL; + shift_n = 0; - if (m == 13) - { - throw "ADD_SPR_T2: T1"; - } + reject(m == 13, "encoding T1"); break; } case T3: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; m = (code.data & 0xf); set_flags = (code.data & 0x100000); shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); + + reject(d == 13 && (shift_t != SRType_LSL || shift_n > 3), "UNPREDICTABLE"); + reject(d == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -672,11 +686,51 @@ void ARMv7_instrs::AND_IMM(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::AND_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { + bool set_flags = !context.ITSTATE; + u32 cond, d, n, m, shift_t, shift_n; + switch (type) { + case T1: + { + cond = context.ITSTATE.advance(); + d = n = (code.data & 0x7); + m = (code.data & 0x38) >> 3; + shift_t = SRType_LSL; + shift_n = 0; + break; + } + case T2: + { + cond = context.ITSTATE.advance(); + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + set_flags = (code.data & 0x100000); + shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); + + reject(d == 15 && set_flags, "TST (register)"); + reject(d == 13 || d == 15 || n == 13 || n == 15 || m == 13 || m == 15, "UNPREDICTABLE"); + break; + } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } + + if (ConditionPassed(context, cond)) + { + bool carry; + const u32 shifted = Shift_C(context.read_gpr(m), shift_t, shift_n, context.APSR.C, carry); + const u32 result = context.read_gpr(n) & shifted; + context.write_gpr(d, result); + + if (set_flags) + { + context.APSR.N = result >> 31; + context.APSR.Z = result == 0; + context.APSR.C = carry; + } + } } void ARMv7_instrs::AND_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) @@ -710,47 +764,53 @@ void ARMv7_instrs::ASR_REG(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::B(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 jump = 0; // jump = instr_size + imm32 ??? + u32 cond, jump; switch (type) { case T1: { cond = (code.data >> 8) & 0xf; - if (cond == 0xf) - { - throw "B_T1: SVC"; - } - jump = 4 + sign<9, u32>((code.data & 0xff) << 1); + + reject(cond == 14, "UNDEFINED"); + reject(cond == 15, "SVC"); + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case T2: { + cond = context.ITSTATE.advance(); jump = 4 + sign<12, u32>((code.data & 0x7ff) << 1); + + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case T3: { cond = (code.data >> 22) & 0xf; - if (cond >= 0xe) { - throw "B_T3: Related encodings"; + const u32 s = (code.data >> 26) & 0x1; + const u32 j1 = (code.data >> 13) & 0x1; + const u32 j2 = (code.data >> 11) & 0x1; + jump = 4 + sign<21, u32>(s << 20 | j2 << 19 | j1 << 18 | (code.data & 0x3f0000) >> 4 | (code.data & 0x7ff) << 1); } - u32 s = (code.data >> 26) & 0x1; - u32 j1 = (code.data >> 13) & 0x1; - u32 j2 = (code.data >> 11) & 0x1; - jump = 4 + sign<21, u32>(s << 20 | j2 << 19 | j1 << 18 | (code.data & 0x3f0000) >> 4 | (code.data & 0x7ff) << 1); + reject(cond >= 14, "Related encodings"); + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case T4: { - u32 s = (code.data >> 26) & 0x1; - u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; - u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; - jump = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + cond = context.ITSTATE.advance(); + { + const u32 s = (code.data >> 26) & 0x1; + const u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; + const u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; + jump = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + } + + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case A1: @@ -828,26 +888,29 @@ void ARMv7_instrs::BKPT(ARMv7Context& context, const ARMv7Code code, const ARMv7 void ARMv7_instrs::BL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 newLR = context.thread.PC; - u32 imm32 = 0; + u32 cond, imm32, newLR; switch (type) { case T1: { - u32 s = (code.data >> 26) & 0x1; - u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; - u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; - imm32 = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + cond = context.ITSTATE.advance(); newLR = (context.thread.PC + 4) | 1; + { + const u32 s = (code.data >> 26) & 0x1; + const u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; + const u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; + imm32 = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + } + + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case A1: { cond = code.data >> 28; - imm32 = 4 + sign<26, u32>((code.data & 0xffffff) << 2); newLR = (context.thread.PC + 4) - 4; + imm32 = 4 + sign<26, u32>((code.data & 0xffffff) << 2); break; } default: throw __FUNCTION__; @@ -862,38 +925,49 @@ void ARMv7_instrs::BL(ARMv7Context& context, const ARMv7Code code, const ARMv7_e void ARMv7_instrs::BLX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 newLR = context.thread.PC; - u32 target = 0; + u32 cond, target, newLR; switch (type) { case T1: { - target = context.read_gpr((code.data >> 3) & 0xf); + cond = context.ITSTATE.advance(); newLR = (context.thread.PC + 2) | 1; // ??? + { + const u32 m = (code.data >> 3) & 0xf; + reject(m == 15, "UNPREDICTABLE"); + target = context.read_gpr(m); + } + + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case T2: { - u32 s = (code.data >> 26) & 0x1; - u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; - u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; - target = (context.thread.PC + 4 & ~3) + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + cond = context.ITSTATE.advance(); newLR = (context.thread.PC + 4) | 1; + { + const u32 s = (code.data >> 26) & 0x1; + const u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; + const u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; + target = (context.thread.PC + 4 & ~3) + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + } + + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case A1: { cond = code.data >> 28; - target = context.read_gpr(code.data & 0xf); newLR = (context.thread.PC + 4) - 4; + target = context.read_gpr(code.data & 0xf); break; } case A2: { - target = (context.thread.PC + 4 | 1) + sign<25, u32>((code.data & 0xffffff) << 2 | (code.data & 0x1000000) >> 23); + cond = 15; newLR = (context.thread.PC + 4) - 4; + target = (context.thread.PC + 4 | 1) + sign<25, u32>((code.data & 0xffffff) << 2 | (code.data & 0x1000000) >> 23); break; } default: throw __FUNCTION__; @@ -917,20 +991,23 @@ void ARMv7_instrs::BLX(ARMv7Context& context, const ARMv7Code code, const ARMv7_ void ARMv7_instrs::BX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 target = 0; + u32 cond, target; switch (type) { case T1: { + cond = context.ITSTATE.advance(); target = context.read_gpr((code.data >> 3) & 0xf); + + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case A1: { cond = code.data >> 28; target = context.read_gpr(code.data & 0xf); + break; } default: throw __FUNCTION__; } @@ -953,26 +1030,54 @@ void ARMv7_instrs::BX(ARMv7Context& context, const ARMv7Code code, const ARMv7_e void ARMv7_instrs::CB_Z(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { + u32 n, imm32; + bool nonzero; + switch (type) { - case T1: break; + case T1: + { + n = code.data & 0x7; + imm32 = (code.data & 0xf8) >> 2 | (code.data & 0x200) >> 3; + nonzero = (code.data & 0x800); + + reject(context.ITSTATE, "UNPREDICTABLE"); + break; + } default: throw __FUNCTION__; } - if ((context.read_gpr(code.data & 0x7) == 0) ^ ((code.data & 0x800) != 0)) + if ((context.read_gpr(n) == 0) ^ nonzero) { - context.thread.SetBranch(context.thread.PC + 2 + ((code.data & 0xf8) >> 2) + ((code.data & 0x200) >> 3)); + context.thread.SetBranch(context.thread.PC + 2 + imm32); } } void ARMv7_instrs::CLZ(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { + u32 cond, d, m; + switch (type) { + case T1: + { + cond = context.ITSTATE.advance(); + d = (code.data & 0xf00) >> 8; + m = (code.data & 0xf); + + reject((code.data & 0xf0000) >> 16 != m, "UNPREDICTABLE"); + reject(d == 13 || d == 15 || m == 13 || m == 15, "UNPREDICTABLE"); + break; + } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } + + if (ConditionPassed(context, cond)) + { + context.write_gpr(d, cntlz32(context.read_gpr(m))); + } } @@ -1006,22 +1111,24 @@ void ARMv7_instrs::CMN_RSR(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::CMP_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 n = 0; - u32 imm32 = 0; + u32 cond, n, imm32; switch (type) { case T1: { + cond = context.ITSTATE.advance(); n = (code.data & 0x700) >> 8; imm32 = (code.data & 0xff); break; } case T2: { + cond = context.ITSTATE.advance(); n = (code.data & 0xf0000) >> 16; imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); + + reject(n == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1041,24 +1148,29 @@ void ARMv7_instrs::CMP_IMM(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::CMP_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 n = 0; - u32 m = 0; - auto shift_t = SRType_LSL; - u32 shift_n = 0; + u32 cond, n, m, shift_t, shift_n; switch (type) { case T1: { + cond = context.ITSTATE.advance(); n = (code.data & 0x7); m = (code.data & 0x38) >> 3; + shift_t = SRType_LSL; + shift_n = 0; break; } case T2: { + cond = context.ITSTATE.advance(); n = (code.data & 0x80) >> 4 | (code.data & 0x7); m = (code.data & 0x78) >> 3; + shift_t = SRType_LSL; + shift_n = 0; + + reject(n < 8 && m < 8, "UNPREDICTABLE"); + reject(n == 15 || m == 15, "UNPREDICTABLE"); break; } case T3: @@ -1066,6 +1178,8 @@ void ARMv7_instrs::CMP_REG(ARMv7Context& context, const ARMv7Code code, const AR n = (code.data & 0xf0000) >> 16; m = (code.data & 0xf); shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); + + reject(n == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1128,16 +1242,19 @@ void ARMv7_instrs::IT(ARMv7Context& context, const ARMv7Code code, const ARMv7_e { case T1: { - if ((code.data & 0xf) == 0) - { - throw "IT_T1: Related encodings"; - } - - context.ITSTATE.IT = code.data & 0xff; - return; + const u32 mask = code.data & 0xf; + const u32 first = (code.data & 0xf0) >> 4; + + reject(mask == 0, "Related encodings"); + reject(first == 15, "UNPREDICTABLE"); + reject(first == 14 && BitCount(mask) != 1, "UNPREDICTABLE"); + reject(context.ITSTATE, "UNPREDICTABLE"); + break; } default: throw __FUNCTION__; } + + context.ITSTATE.IT = code.data & 0xff; } @@ -1180,43 +1297,50 @@ void ARMv7_instrs::LDMIB(ARMv7Context& context, const ARMv7Code code, const ARMv void ARMv7_instrs::LDR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 t = 0; - u32 n = 13; - u32 imm32 = 0; - bool index = true; - bool add = true; - bool wback = false; + u32 cond, t, n, imm32; + bool index, add, wback; switch (type) { case T1: { + cond = context.ITSTATE.advance(); t = (code.data & 0x7); n = (code.data & 0x38) >> 3; imm32 = (code.data & 0x7c0) >> 4; + index = true; + add = true; + wback = false; break; } case T2: { + cond = context.ITSTATE.advance(); t = (code.data & 0x700) >> 8; + n = 13; imm32 = (code.data & 0xff) << 2; + index = true; + add = true; + wback = false; break; } case T3: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; imm32 = (code.data & 0xfff); + index = true; + add = true; + wback = false; - if (n == 15) - { - throw "LDR_IMM_T3: LDR (literal)"; - } + reject(n == 15, "LDR (literal)"); + reject(t == 15 && context.ITSTATE, "UNPREDICTABLE"); break; } case T4: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; imm32 = (code.data & 0xff); @@ -1224,22 +1348,11 @@ void ARMv7_instrs::LDR_IMM(ARMv7Context& context, const ARMv7Code code, const AR add = (code.data & 0x200); wback = (code.data & 0x100); - if (n == 15) - { - throw "LDR_IMM_T4: LDR (literal)"; - } - if (index && add && !wback) - { - throw "LDR_IMM_T4: LDRT"; - } - if (n == 13 && !index && add && wback && imm32 == 4) - { - throw "LDR_IMM_T4: POP"; - } - if (!index && !wback) - { - throw "LDR_IMM_T4: undefined"; - } + reject(n == 15, "LDR (literal)"); + reject(index && add && !wback, "LDRT"); + reject(n == 13 && !index && add && wback && imm32 == 4, "POP"); + reject(!index && !wback, "UNDEFINED"); + reject((wback && n == t) || (t == 15 && context.ITSTATE), "UNPREDICTABLE"); break; } default: throw __FUNCTION__; @@ -1270,36 +1383,39 @@ void ARMv7_instrs::LDR_LIT(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::LDR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 t = 0; - u32 n = 0; - u32 m = 0; - bool index = true; - bool add = true; - bool wback = false; - auto shift_t = SRType_LSL; - u32 shift_n = 0; + u32 cond, t, n, m, shift_t, shift_n; + bool index, add, wback; switch (type) { case T1: { + cond = context.ITSTATE.advance(); t = (code.data & 0x7); n = (code.data & 0x38) >> 3; m = (code.data & 0x1c0) >> 6; + index = true; + add = true; + wback = false; + shift_t = SRType_LSL; + shift_n = 0; break; } case T2: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; m = (code.data & 0xf); - shift_n = (code.data & 0x30) >> 4; + index = true; + add = true; + wback = false; + shift_t = (code.data & 0x30) >> 4; + shift_n = 0; - if (n == 15) - { - throw "LDR_REG_T2: LDR (literal)"; - } + reject(n == 15, "LDR (literal)"); + reject(m == 13 || m == 15, "UNPREDICTABLE"); + reject(t == 15 && context.ITSTATE, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1353,19 +1469,14 @@ void ARMv7_instrs::LDRB_REG(ARMv7Context& context, const ARMv7Code code, const A void ARMv7_instrs::LDRD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 t = 0; - u32 t2 = 0; - u32 n = 13; - u32 imm32 = 0; - bool index = true; - bool add = true; - bool wback = false; + u32 cond, t, t2, n, imm32; + bool index, add, wback; switch (type) { case T1: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; t2 = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; @@ -1374,14 +1485,10 @@ void ARMv7_instrs::LDRD_IMM(ARMv7Context& context, const ARMv7Code code, const A add = (code.data & 0x800000); wback = (code.data & 0x200000); - if (!index && !wback) - { - throw "LDRD_IMM_T1: Related encodings"; - } - if (n == 15) - { - throw "LDRD_IMM_T1: LDRD (literal)"; - } + reject(!index && !wback, "Related encodings"); + reject(n == 15, "LDRD (literal)"); + reject(wback && (n == t || n == t2), "UNPREDICTABLE"); + reject(t == 13 || t == 15 || t2 == 13 || t2 == 15 || t == t2, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1509,18 +1616,18 @@ void ARMv7_instrs::LDRSH_REG(ARMv7Context& context, const ARMv7Code code, const void ARMv7_instrs::LDREX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 t = 0; - u32 n = 0; - u32 imm32 = 0; + u32 cond, t, n, imm32; switch (type) { case T1: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; imm32 = (code.data & 0xff) << 2; + + reject(t == 13 || t == 15 || n == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1569,36 +1676,30 @@ void ARMv7_instrs::LDREXH(ARMv7Context& context, const ARMv7Code code, const ARM void ARMv7_instrs::LSL_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { bool set_flags = !context.ITSTATE; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 m = 0; - u32 shift_n = 0; + u32 cond, d, m, shift_n; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0x7); m = (code.data & 0x38) >> 3; shift_n = (code.data & 0x7c0) >> 6; - if (!shift_n) - { - throw "LSL_IMM_T1: MOV (register)"; - } + reject(!shift_n, "MOV (register)"); break; } case T2: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; m = (code.data & 0xf); set_flags = (code.data & 0x100000); shift_n = (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6; - if (!shift_n) - { - throw "LSL_IMM_T2: MOV (register)"; - } + reject(!shift_n, "MOV (register)"); + reject(d == 13 || d == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1608,7 +1709,7 @@ void ARMv7_instrs::LSL_IMM(ARMv7Context& context, const ARMv7Code code, const AR if (ConditionPassed(context, cond)) { bool carry; - const u32 res = Shift_C(context.read_gpr(m), SRType_LSL, shift_n, context.APSR.C, carry); + const u32 res = Shift_C(context.read_gpr(m), SRType_LSL, shift_n, context.APSR.C, carry); context.write_gpr(d, res); if (set_flags) { @@ -1622,25 +1723,26 @@ void ARMv7_instrs::LSL_IMM(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::LSL_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { bool set_flags = !context.ITSTATE; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 n = 0; - u32 m = 0; + u32 cond, d, n, m; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = n = (code.data & 0x7); m = (code.data & 0x38) >> 3; break; } case T2: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; m = (code.data & 0xf); set_flags = (code.data & 0x100000); + + reject(d == 13 || d == 15 || n == 13 || n == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1704,30 +1806,35 @@ void ARMv7_instrs::MOV_IMM(ARMv7Context& context, const ARMv7Code code, const AR { bool set_flags = !context.ITSTATE; bool carry = context.APSR.C; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 imm32 = 0; + u32 cond, d, imm32; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data >> 8) & 0x7; imm32 = sign<8, u32>(code.data & 0xff); break; } case T2: { + cond = context.ITSTATE.advance(); set_flags = code.data & 0x100000; d = (code.data >> 8) & 0xf; imm32 = ThumbExpandImm_C((code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff), carry, carry); + + reject(d == 13 || d == 15, "UNPREDICTABLE"); break; } case T3: { + cond = context.ITSTATE.advance(); set_flags = false; d = (code.data >> 8) & 0xf; imm32 = (code.data & 0xf0000) >> 4 | (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); + + reject(d == 13 || d == 15, "UNPREDICTABLE"); break; } default: throw __FUNCTION__; @@ -1747,31 +1854,40 @@ void ARMv7_instrs::MOV_IMM(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::MOV_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 m = 0; - bool set_flags = false; + u32 cond, d, m; + bool set_flags; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0x80) >> 4 | (code.data & 0x7); m = (code.data & 0x78) >> 3; + set_flags = false; + + reject(d == 15 && context.ITSTATE, "UNPREDICTABLE"); break; } case T2: { + cond = 15; d = (code.data & 0x7); m = (code.data & 0x38) >> 3; set_flags = true; + + reject(context.ITSTATE, "UNPREDICTABLE"); break; } case T3: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; m = (code.data & 0xf); set_flags = (code.data & 0x100000); + + reject((d == 13 || m == 13 || m == 15) && set_flags, "UNPREDICTABLE"); + reject((d == 13 && (m == 13 || m == 15)) || d == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1793,16 +1909,17 @@ void ARMv7_instrs::MOV_REG(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::MOVT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 imm16 = 0; + u32 cond, d, imm16; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; imm16 = (code.data & 0xf0000) >> 4 | (code.data & 0x4000000) >> 14 | (code.data & 0x7000) >> 4 | (code.data & 0xff); + + reject(d == 13 || d == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1847,25 +1964,28 @@ void ARMv7_instrs::MSR_REG(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::MUL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { bool set_flags = !context.ITSTATE; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 n = 0; - u32 m = 0; + u32 cond, d, n, m; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = m = code.data & 0x7; n = (code.data & 0x38) >> 3; + + //reject(ArchVersion() < 6 && d == n, "UNPREDICTABLE"); break; } case T2: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; m = (code.data & 0xf); set_flags = false; + + reject(d == 13 || d == 15 || n == 13 || n == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -1890,11 +2010,37 @@ void ARMv7_instrs::MUL(ARMv7Context& context, const ARMv7Code code, const ARMv7_ void ARMv7_instrs::MVN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { + u32 cond, d, imm32; + bool set_flags, carry; + switch (type) { + case T1: + { + cond = context.ITSTATE.advance(); + d = (code.data & 0xf00) >> 8; + set_flags = (code.data & 0x100000); + imm32 = ThumbExpandImm_C((code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff), context.APSR.C, carry); + + reject(d == 13 || d == 15, "UNPREDICTABLE"); + break; + } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } + + if (ConditionPassed(context, cond)) + { + const u32 result = ~imm32; + context.write_gpr(d, result); + + if (set_flags) + { + context.APSR.N = result >> 31; + context.APSR.Z = result == 0; + context.APSR.C = carry; + } + } } void ARMv7_instrs::MVN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) @@ -1918,16 +2064,18 @@ void ARMv7_instrs::MVN_RSR(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::NOP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); + u32 cond; switch (type) { case T1: { + cond = context.ITSTATE.advance(); break; } case T2: { + cond = context.ITSTATE.advance(); break; } case A1: @@ -2003,40 +2151,50 @@ void ARMv7_instrs::PKH(ARMv7Context& context, const ARMv7Code code, const ARMv7_ void ARMv7_instrs::POP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u16 reg_list = 0; + u32 cond, reg_list; switch (type) { case T1: { + cond = context.ITSTATE.advance(); reg_list = ((code.data & 0x100) << 7) | (code.data & 0xff); + + reject(!reg_list, "UNPREDICTABLE"); break; } case T2: { + cond = context.ITSTATE.advance(); reg_list = code.data & 0xdfff; + + reject(BitCount(reg_list, 16) < 2 || ((reg_list & 0x8000) && (reg_list & 0x4000)), "UNPREDICTABLE"); + reject((reg_list & 0x8000) && context.ITSTATE, "UNPREDICTABLE"); break; } case T3: { - reg_list = 1 << (code.data >> 12); + cond = context.ITSTATE.advance(); + reg_list = 1 << ((code.data & 0xf000) >> 12); + + reject((reg_list & 0x2000) || ((reg_list & 0x8000) && context.ITSTATE), "UNPREDICTABLE"); break; } case A1: { cond = code.data >> 28; reg_list = code.data & 0xffff; - if (BitCount(reg_list) < 2) - { - throw "POP_A1: LDM / LDMIA / LDMFD"; - } + + reject(BitCount(reg_list, 16) < 2, "LDM / LDMIA / LDMFD"); + reject((reg_list & 0x2000) /* && ArchVersion() >= 7*/, "UNPREDICTABLE"); break; } case A2: { cond = code.data >> 28; - reg_list = 1 << ((code.data >> 12) & 0xf); + reg_list = 1 << ((code.data & 0xf000) >> 12); + + reject(reg_list & 0x2000, "UNPREDICTABLE"); break; } default: throw __FUNCTION__; @@ -2060,40 +2218,48 @@ void ARMv7_instrs::POP(ARMv7Context& context, const ARMv7Code code, const ARMv7_ void ARMv7_instrs::PUSH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u16 reg_list = 0; + u32 cond, reg_list; switch (type) { case T1: { + cond = context.ITSTATE.advance(); reg_list = ((code.data & 0x100) << 6) | (code.data & 0xff); + + reject(!reg_list, "UNPREDICTABLE"); break; } case T2: { + cond = context.ITSTATE.advance(); reg_list = code.data & 0x5fff; + + reject(BitCount(reg_list, 16) < 2, "UNPREDICTABLE"); break; } case T3: { - reg_list = 1 << (code.data >> 12); + cond = context.ITSTATE.advance(); + reg_list = 1 << ((code.data & 0xf000) >> 12); + + reject((reg_list & 0x8000) || (reg_list & 0x2000), "UNPREDICTABLE"); break; } case A1: { cond = code.data >> 28; reg_list = code.data & 0xffff; - if (BitCount(reg_list) < 2) - { - throw "PUSH_A1: STMDB / STMFD"; - } + + reject(BitCount(reg_list) < 2, "STMDB / STMFD"); break; } case A2: { cond = code.data >> 28; - reg_list = 1 << ((code.data >> 12) & 0xf); + reg_list = 1 << ((code.data & 0xf000) >> 12); + + reject(reg_list & 0x2000, "UNPREDICTABLE"); break; } default: throw __FUNCTION__; @@ -2700,43 +2866,50 @@ void ARMv7_instrs::STMIB(ARMv7Context& context, const ARMv7Code code, const ARMv void ARMv7_instrs::STR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 t = 16; - u32 n = 13; - u32 imm32 = 0; - bool index = true; - bool add = true; - bool wback = false; + u32 cond, t, n, imm32; + bool index, add, wback; switch (type) { case T1: { + cond = context.ITSTATE.advance(); t = (code.data & 0x7); n = (code.data & 0x38) >> 3; imm32 = (code.data & 0x7c0) >> 4; + index = true; + add = true; + wback = false; break; } case T2: { + cond = context.ITSTATE.advance(); t = (code.data & 0x700) >> 8; + n = 13; imm32 = (code.data & 0xff) << 2; + index = true; + add = true; + wback = false; break; } case T3: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; imm32 = (code.data & 0xfff); + index = true; + add = true; + wback = false; - if (n == 0xf) - { - throw "STR_IMM_T3: undefined"; - } + reject(n == 15, "UNDEFINED"); + reject(t == 15, "UNPREDICTABLE"); break; } case T4: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; imm32 = (code.data & 0xff); @@ -2744,18 +2917,10 @@ void ARMv7_instrs::STR_IMM(ARMv7Context& context, const ARMv7Code code, const AR add = (code.data & 0x200); wback = (code.data & 0x100); - if (index && add && !wback) - { - throw "STR_IMM_T4: STRT"; - } - if (n == 13 && index && !add && wback && imm32 == 4) - { - throw "STR_IMM_T4: PUSH"; - } - if (n == 15 || (!index && !wback)) - { - throw "STR_IMM_T4: undefined"; - } + reject(index && add && !wback, "STRT"); + reject(n == 13 && index && !add && wback && imm32 == 4, "PUSH"); + reject(n == 15 || (!index && !wback), "UNDEFINED"); + reject(t == 15 || (wback && n == t), "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -2778,36 +2943,38 @@ void ARMv7_instrs::STR_IMM(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::STR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 t = 0; - u32 n = 0; - u32 m = 0; - bool index = true; - bool add = true; - bool wback = false; - auto shift_t = SRType_LSL; - u32 shift_n = 0; + u32 cond, t, n, m, shift_t, shift_n; + bool index, add, wback; switch (type) { case T1: { + cond = context.ITSTATE.advance(); t = (code.data & 0x7); n = (code.data & 0x38) >> 3; m = (code.data & 0x1c0) >> 6; + index = true; + add = true; + wback = false; + shift_t = SRType_LSL; + shift_n = 0; break; } case T2: { + cond = context.ITSTATE.advance(); t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; m = (code.data & 0xf); + index = true; + add = true; + wback = false; + shift_t = SRType_LSL; shift_n = (code.data & 0x30) >> 4; - if (n == 15) - { - throw "STR_REG_T2: undefined"; - } + reject(n == 15, "UNDEFINED"); + reject(t == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -2889,20 +3056,20 @@ void ARMv7_instrs::STRH_REG(ARMv7Context& context, const ARMv7Code code, const A void ARMv7_instrs::STREX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 t = 0; - u32 n = 0; - u32 imm32 = 0; + u32 cond, d, t, n, imm32; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; t = (code.data & 0xf000) >> 12; n = (code.data & 0xf0000) >> 16; imm32 = (code.data & 0xff) << 2; + + reject(d == 13 || d == 15 || t == 13 || t == 15 || n == 15, "UNPREDICTABLE"); + reject(d == n || d == t, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -2951,15 +3118,13 @@ void ARMv7_instrs::STREXH(ARMv7Context& context, const ARMv7Code code, const ARM void ARMv7_instrs::SUB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { bool set_flags = !context.ITSTATE; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 n = 0; - u32 imm32 = 0; + u32 cond, d, n, imm32; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0x7); n = (code.data & 0x38) >> 3; imm32 = (code.data & 0x1c) >> 6; @@ -2967,42 +3132,35 @@ void ARMv7_instrs::SUB_IMM(ARMv7Context& context, const ARMv7Code code, const AR } case T2: { + cond = context.ITSTATE.advance(); d = n = (code.data & 0x700) >> 8; imm32 = (code.data & 0xff); break; } case T3: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; set_flags = (code.data & 0x100000); imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); - if (d == 15 && set_flags) - { - throw "SUB_IMM_T3: CMP (immediate)"; - } - if (n == 13) - { - throw "SUB_IMM_T3: SUB (SP minus immediate)"; - } + reject(d == 15 && set_flags, "CMP (immediate)"); + reject(n == 13, "SUB (SP minus immediate)"); + reject(d == 13 || d == 15 || n == 15, "UNPREDICTABLE"); break; } case T4: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; set_flags = false; imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); - if (d == 15) - { - throw "SUB_IMM_T4: ADR"; - } - if (n == 13) - { - throw "SUB_IMM_T4: SUB (SP minus immediate)"; - } + reject(d == 15, "ADR"); + reject(n == 13, "SUB (SP minus immediate)"); + reject(d == 13 || d == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -3031,38 +3189,32 @@ void ARMv7_instrs::SUB_IMM(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::SUB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { bool set_flags = !context.ITSTATE; - u32 cond = context.ITSTATE.advance(); - u32 d = 0; - u32 n = 0; - u32 m = 0; - auto shift_t = SRType_LSL; - u32 shift_n = 0; + u32 cond, d, n, m, shift_t, shift_n; switch (type) { case T1: { + cond = context.ITSTATE.advance(); d = (code.data & 0x7); n = (code.data & 0x38) >> 3; m = (code.data & 0x1c0) >> 6; + shift_t = SRType_LSL; + shift_n = 0; break; } case T2: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; n = (code.data & 0xf0000) >> 16; m = (code.data & 0xf); set_flags = (code.data & 0x100000); shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); - if (d == 15 && set_flags) - { - throw "SUB_REG_T2: CMP (register)"; - } - if (n == 13) - { - throw "SUB_REG_T2: SUB (SP minus register)"; - } + reject(d == 15 && set_flags, "CMP (register)"); + reject(n == 13, "SUB (SP minus register)"); + reject(d == 13 || d == 15 || n == 15 || m == 13 || m == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -3100,35 +3252,38 @@ void ARMv7_instrs::SUB_RSR(ARMv7Context& context, const ARMv7Code code, const AR void ARMv7_instrs::SUB_SPI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = context.ITSTATE.advance(); - u32 d = 13; - bool set_flags = false; - u32 imm32 = 0; + u32 cond, d, imm32; + bool set_flags; switch (type) { case T1: { + cond = context.ITSTATE.advance(); + d = 13; + set_flags = false; imm32 = (code.data & 0x7f) << 2; break; } case T2: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; set_flags = (code.data & 0x100000); imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); - if (d == 15 && set_flags) - { - throw "SUB_SPI_T2: CMP (immediate)"; - } + reject(d == 15 && set_flags, "CMP (immediate)"); + reject(d == 15, "UNPREDICTABLE"); break; } case T3: { + cond = context.ITSTATE.advance(); d = (code.data & 0xf00) >> 8; set_flags = false; imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); + + reject(d == 15, "UNPREDICTABLE"); break; } case A1: throw __FUNCTION__; @@ -3567,11 +3722,36 @@ void ARMv7_instrs::UXTAH(ARMv7Context& context, const ARMv7Code code, const ARMv void ARMv7_instrs::UXTB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { + u32 cond, d, m, rot; + switch (type) { + case T1: + { + cond = context.ITSTATE.advance(); + d = (code.data & 0x7); + m = (code.data & 0x38) >> 3; + rot = 0; + break; + } + case T2: + { + cond = context.ITSTATE.advance(); + d = (code.data & 0xf00) >> 8; + m = (code.data & 0xf); + rot = (code.data & 0x30) >> 1; + + reject(d == 13 || d == 15 || m == 13 || m == 15, "UNPREDICTABLE"); + break; + } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } + + if (ConditionPassed(context, cond)) + { + context.write_gpr(d, (context.read_gpr(m) >> rot) & 0xff); + } } void ARMv7_instrs::UXTB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) diff --git a/rpcs3/Emu/ARMv7/ARMv7Interpreter.h b/rpcs3/Emu/ARMv7/ARMv7Interpreter.h index c99958a35c..4e4b8b6dc1 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Interpreter.h +++ b/rpcs3/Emu/ARMv7/ARMv7Interpreter.h @@ -28,71 +28,6 @@ enum SRType : u32 namespace ARMv7_instrs { - template - static bool IsZero(T x) - { - return x == T(0); - } - - template - static bool IsOnes(T x) - { - return x == ~T(0); - } - - template - static u8 IsZeroBit(T x) - { - return IsZero(x) ? 1 : 0; - } - - template - static bool IsOnesBit(T x, u8 len = sizeof(T) * 8) - { - return IsOnes(x) ? 1 : 0; - } - - template - u8 BitCount(T x, u8 len = sizeof(T) * 8); - - template - s8 LowestSetBit(T x, u8 len = sizeof(T) * 8); - - template - s8 HighestSetBit(T x, u8 len = sizeof(T) * 8); - - template - s8 CountLeadingZeroBits(T x, u8 len = sizeof(T) * 8); - - SRType DecodeImmShift(u32 type, u32 imm5, u32* shift_n); - SRType DecodeRegShift(u8 type); - - u32 LSL_C(u32 x, s32 shift, bool& carry_out); - u32 LSL_(u32 x, s32 shift); - u32 LSR_C(u32 x, s32 shift, bool& carry_out); - u32 LSR_(u32 x, s32 shift); - - s32 ASR_C(s32 x, s32 shift, bool& carry_out); - s32 ASR_(s32 x, s32 shift); - - u32 ROR_C(u32 x, s32 shift, bool& carry_out); - u32 ROR_(u32 x, s32 shift); - - u32 RRX_C(u32 x, bool carry_in, bool& carry_out); - u32 RRX_(u32 x, bool carry_in); - - template T Shift_C(T value, SRType type, s32 amount, bool carry_in, bool& carry_out); - - template T Shift(T value, SRType type, s32 amount, bool carry_in); - - template T AddWithCarry(T x, T y, bool carry_in, bool& carry_out, bool& overflow); - - u32 ThumbExpandImm_C(u32 imm12, bool carry_in, bool& carry_out); - u32 ThumbExpandImm(ARMv7Context& context, u32 imm12); - - bool ConditionPassed(ARMv7Context& context, u32 cond); - - // instructions void UNK(ARMv7Context& context, const ARMv7Code code); void NULL_OP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp index e4b1d65291..0b9710ffe2 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp @@ -20,11 +20,6 @@ u32 ARMv7Context::read_pc() return thread.PC; } -void ARMv7Context::put_stack_arg(u32 shift, u32 value) -{ - vm::psv::write32(SP + shift, value); -} - u32 ARMv7Context::get_stack_arg(u32 pos) { return vm::psv::read32(SP + sizeof(u32) * (pos - 5)); diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp index 73a6f864e3..ac2600dc4b 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp @@ -1,93 +1,36 @@ #include "stdafx.h" #include "Emu/System.h" -#include "Emu/Memory/Memory.h" #include "Emu/ARMv7/PSVFuncList.h" #include "Emu/CPU/CPUThreadManager.h" +#include "Emu/SysCalls/Callback.h" #include "Emu/ARMv7/ARMv7Thread.h" -extern psv_log_base sceLibKernel; +#include "sceLibKernel.h" #define RETURN_ERROR(code) { Emu.Pause(); sceLibKernel.Error("%s() failed: %s", __FUNCTION__, #code); return code; } -#pragma pack(push, 4) - -typedef s32(*SceKernelThreadEntry)(u32 argSize, vm::psv::ptr pArgBlock); - -union SceKernelSysClock +s32 sceKernelAllocMemBlock(vm::psv::ptr name, s32 type, u32 vsize, vm::psv::ptr pOpt) { - struct - { - u32 low; - u32 hi; - }; - u64 quad; -}; + throw __FUNCTION__; +} -struct SceKernelThreadOptParam +s32 sceKernelFreeMemBlock(s32 uid) { - u32 size; - u32 attr; -}; + throw __FUNCTION__; +} -struct SceKernelThreadInfo +s32 sceKernelGetMemBlockBase(s32 uid, vm::psv::ptr> ppBase) { - u32 size; - s32 processId; - char name[32]; - u32 attr; - u32 status; - SceKernelThreadEntry entry; - vm::psv::ptr pStack; - u32 stackSize; - s32 initPriority; - s32 currentPriority; - s32 initCpuAffinityMask; - s32 currentCpuAffinityMask; - s32 currentCpuId; - s32 lastExecutedCpuId; - u32 waitType; - s32 waitId; - s32 exitStatus; - SceKernelSysClock runClocks; - u32 intrPreemptCount; - u32 threadPreemptCount; - u32 threadReleaseCount; - s32 changeCpuCount; - s32 fNotifyCallback; - s32 reserved; -}; + throw __FUNCTION__; +} -struct SceKernelThreadRunStatus +s32 sceKernelGetMemBlockInfoByAddr(vm::psv::ptr vbase, vm::psv::ptr pInfo) { - u32 size; + throw __FUNCTION__; +} - struct - { - s32 processId; - s32 threadId; - s32 priority; - - } cpuInfo[4]; -}; - -struct SceKernelSystemInfo -{ - u32 size; - u32 activeCpuMask; - - struct - { - SceKernelSysClock idleClock; - u32 comesOutOfIdleCount; - u32 threadSwitchCount; - - } cpuInfo[4]; -}; - -#pragma pack(pop) - -u32 sceKernelCreateThread( +s32 sceKernelCreateThread( vm::psv::ptr pName, vm::psv::ptr entry, s32 initPriority, @@ -113,17 +56,24 @@ u32 sceKernelCreateThread( return id; } -s32 sceKernelStartThread(u32 threadId, u32 argSize, vm::psv::ptr pArgBlock) +s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr pArgBlock) { sceLibKernel.Error("sceKernelStartThread(threadId=0x%x, argSize=0x%x, pArgBlock=0x%x)", threadId, argSize, pArgBlock); - std::shared_ptr t = Emu.GetCPU().GetThread(threadId); + std::shared_ptr t = Emu.GetCPU().GetThread(threadId, CPU_THREAD_ARMv7); - if (!t || t->GetType() != CPU_THREAD_ARMv7) + if (!t) { RETURN_ERROR(SCE_KERNEL_ERROR_INVALID_UID); } + // thread should be in DORMANT state, but it's not possible to check it correctly atm + + if (t->IsAlive()) + { + RETURN_ERROR(SCE_KERNEL_ERROR_NOT_DORMANT); + } + ARMv7Thread& thread = static_cast(*t); // push arg block onto the stack @@ -148,46 +98,71 @@ s32 sceKernelExitThread(ARMv7Context& context, s32 exitStatus) return SCE_OK; } -s32 sceKernelDeleteThread(u32 threadId) +s32 sceKernelDeleteThread(s32 threadId) { - sceLibKernel.Todo("sceKernelDeleteThread(threadId=0x%x)", threadId); + sceLibKernel.Error("sceKernelDeleteThread(threadId=0x%x)", threadId); + + std::shared_ptr t = Emu.GetCPU().GetThread(threadId, CPU_THREAD_ARMv7); + + if (!t) + { + RETURN_ERROR(SCE_KERNEL_ERROR_INVALID_UID); + } + + // thread should be in DORMANT state, but it's not possible to check it correctly atm + + if (t->IsAlive()) + { + RETURN_ERROR(SCE_KERNEL_ERROR_NOT_DORMANT); + } + + Emu.GetCPU().RemoveThread(threadId); + return SCE_OK; +} + +s32 sceKernelExitDeleteThread(ARMv7Context& context, s32 exitStatus) +{ + sceLibKernel.Error("sceKernelExitDeleteThread(exitStatus=0x%x)", exitStatus); + + // exit status is stored in r0 + context.thread.Stop(); + + // current thread should be deleted + const u32 id = context.thread.GetId(); + CallAfter([id]() + { + Emu.GetCPU().RemoveThread(id); + }); return SCE_OK; } -s32 sceKernelExitDeleteThread(s32 exitStatus) -{ - sceLibKernel.Todo("sceKernelExitDeleteThread(exitStatus=0x%x)", exitStatus); - - return SCE_OK; -} - -s32 sceKernelChangeThreadCpuAffinityMask(u32 threadId, s32 cpuAffinityMask) +s32 sceKernelChangeThreadCpuAffinityMask(s32 threadId, s32 cpuAffinityMask) { sceLibKernel.Todo("sceKernelChangeThreadCpuAffinityMask(threadId=0x%x, cpuAffinityMask=0x%x)", threadId, cpuAffinityMask); - return SCE_OK; + throw __FUNCTION__; } -s32 sceKernelGetThreadCpuAffinityMask(u32 threadId) +s32 sceKernelGetThreadCpuAffinityMask(s32 threadId) { sceLibKernel.Todo("sceKernelGetThreadCpuAffinityMask(threadId=0x%x)", threadId); - return SCE_OK; + throw __FUNCTION__; } -s32 sceKernelChangeThreadPriority(u32 threadId, s32 priority) +s32 sceKernelChangeThreadPriority(s32 threadId, s32 priority) { sceLibKernel.Todo("sceKernelChangeThreadPriority(threadId=0x%x, priority=%d)", threadId, priority); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelGetThreadCurrentPriority() { sceLibKernel.Todo("sceKernelGetThreadCurrentPriority()"); - return SCE_OK; + throw __FUNCTION__; } u32 sceKernelGetThreadId(ARMv7Context& context) @@ -201,93 +176,93 @@ s32 sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr) { sceLibKernel.Todo("sceKernelChangeCurrentThreadAttr()"); - return SCE_OK; + throw __FUNCTION__; } -s32 sceKernelGetThreadExitStatus(u32 threadId, vm::psv::ptr pExitStatus) +s32 sceKernelGetThreadExitStatus(s32 threadId, vm::psv::ptr pExitStatus) { sceLibKernel.Todo("sceKernelGetThreadExitStatus(threadId=0x%x, pExitStatus=0x%x)", threadId, pExitStatus); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelGetProcessId() { sceLibKernel.Todo("sceKernelGetProcessId()"); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelCheckWaitableStatus() { sceLibKernel.Todo("sceKernelCheckWaitableStatus()"); - return SCE_OK; + throw __FUNCTION__; } -s32 sceKernelGetThreadInfo(u32 threadId, vm::psv::ptr pInfo) +s32 sceKernelGetThreadInfo(s32 threadId, vm::psv::ptr pInfo) { sceLibKernel.Todo("sceKernelGetThreadInfo(threadId=0x%x, pInfo=0x%x)", threadId, pInfo); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelGetThreadRunStatus(vm::psv::ptr pStatus) { sceLibKernel.Todo("sceKernelGetThreadRunStatus(pStatus=0x%x)", pStatus); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelGetSystemInfo(vm::psv::ptr pInfo) { sceLibKernel.Todo("sceKernelGetSystemInfo(pInfo=0x%x)", pInfo); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelGetThreadmgrUIDClass(s32 uid) { sceLibKernel.Todo("sceKernelGetThreadmgrUIDClass(uid=0x%x)", uid); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelChangeThreadVfpException(s32 clearMask, s32 setMask) { sceLibKernel.Todo("sceKernelChangeThreadVfpException(clearMask=0x%x, setMask=0x%x)", clearMask, setMask); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelGetCurrentThreadVfpException() { sceLibKernel.Todo("sceKernelGetCurrentThreadVfpException()"); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelDelayThread(u32 usec) { sceLibKernel.Todo("sceKernelDelayThread()"); - return SCE_OK; + throw __FUNCTION__; } s32 sceKernelDelayThreadCB(u32 usec) { sceLibKernel.Todo("sceKernelDelayThreadCB()"); - return SCE_OK; + throw __FUNCTION__; } -s32 sceKernelWaitThreadEnd(u32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) +s32 sceKernelWaitThreadEnd(s32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) { sceLibKernel.Error("sceKernelWaitThreadEnd(threadId=0x%x, pExitStatus=0x%x, pTimeout=0x%x)", threadId, pExitStatus, pTimeout); - std::shared_ptr t = Emu.GetCPU().GetThread(threadId); + std::shared_ptr t = Emu.GetCPU().GetThread(threadId, CPU_THREAD_ARMv7); - if (!t || t->GetType() != CPU_THREAD_ARMv7) + if (!t) { RETURN_ERROR(SCE_KERNEL_ERROR_INVALID_UID); } @@ -316,13 +291,675 @@ s32 sceKernelWaitThreadEnd(u32 threadId, vm::psv::ptr pExitStatus, vm::psv: return SCE_OK; } -s32 sceKernelWaitThreadEndCB(u32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) +s32 sceKernelWaitThreadEndCB(s32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) { sceLibKernel.Todo("sceKernelWaitThreadEndCB(threadId=0x%x, pExitStatus=0x%x, pTimeout=0x%x)", threadId, pExitStatus, pTimeout); - return SCE_OK; + throw __FUNCTION__; } +// Callback functions + +s32 sceKernelCreateCallback(vm::psv::ptr pName, u32 attr, vm::psv::ptr callbackFunc, vm::psv::ptr pCommon) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteCallback(s32 callbackId) +{ + throw __FUNCTION__; +} + +s32 sceKernelNotifyCallback(s32 callbackId, s32 notifyArg) +{ + throw __FUNCTION__; +} + +s32 sceKernelCancelCallback(s32 callbackId) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetCallbackCount(s32 callbackId) +{ + throw __FUNCTION__; +} + +s32 sceKernelCheckCallback() +{ + throw __FUNCTION__; +} + +s32 sceKernelGetCallbackInfo(s32 callbackId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +s32 sceKernelRegisterCallbackToEvent(s32 eventId, s32 callbackId) +{ + throw __FUNCTION__; +} + +s32 sceKernelUnregisterCallbackFromEvent(s32 eventId, s32 callbackId) +{ + throw __FUNCTION__; +} + +s32 sceKernelUnregisterCallbackFromEventAll(s32 eventId) +{ + throw __FUNCTION__; +} + +// Event functions + +s32 sceKernelWaitEvent(s32 eventId, u32 waitPattern, vm::psv::ptr pResultPattern, vm::psv::ptr pUserData, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitEventCB(s32 eventId, u32 waitPattern, vm::psv::ptr pResultPattern, vm::psv::ptr pUserData, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelPollEvent(s32 eventId, u32 bitPattern, vm::psv::ptr pResultPattern, vm::psv::ptr pUserData) +{ + throw __FUNCTION__; +} + +s32 sceKernelCancelEvent(s32 eventId, vm::psv::ptr pNumWaitThreads) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetEventInfo(s32 eventId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitMultipleEvents(vm::psv::ptr pWaitEventList, s32 numEvents, u32 waitMode, vm::psv::ptr pResultEventList, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitMultipleEventsCB(vm::psv::ptr pWaitEventList, s32 numEvents, u32 waitMode, vm::psv::ptr pResultEventList, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +// Event flag functions + +s32 sceKernelCreateEventFlag(vm::psv::ptr pName, u32 attr, u32 initPattern, vm::psv::ptr pOptParam) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteEventFlag(s32 evfId) +{ + throw __FUNCTION__; +} + +s32 sceKernelOpenEventFlag(vm::psv::ptr pName) +{ + throw __FUNCTION__; +} + +s32 sceKernelCloseEventFlag(s32 evfId) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitEventFlag(s32 evfId, u32 bitPattern, u32 waitMode, vm::psv::ptr pResultPat, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitEventFlagCB(s32 evfId, u32 bitPattern, u32 waitMode, vm::psv::ptr pResultPat, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelPollEventFlag(s32 evfId, u32 bitPattern, u32 waitMode, vm::psv::ptr pResultPat) +{ + throw __FUNCTION__; +} + +s32 sceKernelSetEventFlag(s32 evfId, u32 bitPattern) +{ + throw __FUNCTION__; +} + +s32 sceKernelClearEventFlag(s32 evfId, u32 bitPattern) +{ + throw __FUNCTION__; +} + +s32 sceKernelCancelEventFlag(s32 evfId, u32 setPattern, vm::psv::ptr pNumWaitThreads) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetEventFlagInfo(s32 evfId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// Semaphore functions + +s32 sceKernelCreateSema(vm::psv::ptr pName, u32 attr, s32 initCount, s32 maxCount, vm::psv::ptr pOptParam) +{ + sceLibKernel.Error("sceKernelCreateSema(pName=0x%x, attr=0x%x, initCount=%d, maxCount=%d, pOptParam=0x%x)", pName, attr, initCount, maxCount, pOptParam); + + throw __FUNCTION__; +} + +s32 sceKernelDeleteSema(s32 semaId) +{ + throw __FUNCTION__; +} + +s32 sceKernelOpenSema(vm::psv::ptr pName) +{ + throw __FUNCTION__; +} + +s32 sceKernelCloseSema(s32 semaId) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitSema(s32 semaId, s32 needCount, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitSemaCB(s32 semaId, s32 needCount, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelPollSema(s32 semaId, s32 needCount) +{ + throw __FUNCTION__; +} + +s32 sceKernelSignalSema(s32 semaId, s32 signalCount) +{ + throw __FUNCTION__; +} + +s32 sceKernelCancelSema(s32 semaId, s32 setCount, vm::psv::ptr pNumWaitThreads) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetSemaInfo(s32 semaId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// Mutex functions + +s32 sceKernelCreateMutex(vm::psv::ptr pName, u32 attr, s32 initCount, vm::psv::ptr pOptParam) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteMutex(s32 mutexId) +{ + throw __FUNCTION__; +} + +s32 sceKernelOpenMutex(vm::psv::ptr pName) +{ + throw __FUNCTION__; +} + +s32 sceKernelCloseMutex(s32 mutexId) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockMutex(s32 mutexId, s32 lockCount, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockMutexCB(s32 mutexId, s32 lockCount, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelTryLockMutex(s32 mutexId, s32 lockCount) +{ + throw __FUNCTION__; +} + +s32 sceKernelUnlockMutex(s32 mutexId, s32 unlockCount) +{ + throw __FUNCTION__; +} + +s32 sceKernelCancelMutex(s32 mutexId, s32 newCount, vm::psv::ptr pNumWaitThreads) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetMutexInfo(s32 mutexId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// Lightweight mutex functions + +s32 sceKernelCreateLwMutex(vm::psv::ptr pWork, vm::psv::ptr pName, u32 attr, s32 initCount, vm::psv::ptr pOptParam) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteLwMutex(vm::psv::ptr pWork) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockLwMutex(vm::psv::ptr pWork, s32 lockCount, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockLwMutexCB(vm::psv::ptr pWork, s32 lockCount, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelTryLockLwMutex(vm::psv::ptr pWork, s32 lockCount) +{ + throw __FUNCTION__; +} + +s32 sceKernelUnlockLwMutex(vm::psv::ptr pWork, s32 unlockCount) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetLwMutexInfo(vm::psv::ptr pWork, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetLwMutexInfoById(s32 lwMutexId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// Condition variable functions + +s32 sceKernelCreateCond(vm::psv::ptr pName, u32 attr, s32 mutexId, vm::psv::ptr pOptParam) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteCond(s32 condId) +{ + throw __FUNCTION__; +} + +s32 sceKernelOpenCond(vm::psv::ptr pName) +{ + throw __FUNCTION__; +} + +s32 sceKernelCloseCond(s32 condId) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitCond(s32 condId, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitCondCB(s32 condId, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelSignalCond(s32 condId) +{ + throw __FUNCTION__; +} + +s32 sceKernelSignalCondAll(s32 condId) +{ + throw __FUNCTION__; +} + +s32 sceKernelSignalCondTo(s32 condId, s32 threadId) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetCondInfo(s32 condId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// Lightweight condition variable functions + +s32 sceKernelCreateLwCond(vm::psv::ptr pWork, vm::psv::ptr pName, u32 attr, vm::psv::ptr pLwMutex, vm::psv::ptr pOptParam) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteLwCond(vm::psv::ptr pWork) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitLwCond(vm::psv::ptr pWork, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelWaitLwCondCB(vm::psv::ptr pWork, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelSignalLwCond(vm::psv::ptr pWork) +{ + throw __FUNCTION__; +} + +s32 sceKernelSignalLwCondAll(vm::psv::ptr pWork) +{ + throw __FUNCTION__; +} + +s32 sceKernelSignalLwCondTo(vm::psv::ptr pWork, s32 threadId) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetLwCondInfo(vm::psv::ptr pWork, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetLwCondInfoById(s32 lwCondId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// Time functions + +s32 sceKernelGetSystemTime(vm::psv::ptr pClock) +{ + throw __FUNCTION__; +} + +u64 sceKernelGetSystemTimeWide() +{ + throw __FUNCTION__; +} + +u32 sceKernelGetSystemTimeLow() +{ + throw __FUNCTION__; +} + +// Timer functions + +s32 sceKernelCreateTimer(vm::psv::ptr pName, u32 attr, vm::psv::ptr pOptParam) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteTimer(s32 timerId) +{ + throw __FUNCTION__; +} + +s32 sceKernelOpenTimer(vm::psv::ptr pName) +{ + throw __FUNCTION__; +} + +s32 sceKernelCloseTimer(s32 timerId) +{ + throw __FUNCTION__; +} + +s32 sceKernelStartTimer(s32 timerId) +{ + throw __FUNCTION__; +} + +s32 sceKernelStopTimer(s32 timerId) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetTimerBase(s32 timerId, vm::psv::ptr pBase) +{ + throw __FUNCTION__; +} + +u64 sceKernelGetTimerBaseWide(s32 timerId) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetTimerTime(s32 timerId, vm::psv::ptr pClock) +{ + throw __FUNCTION__; +} + +u64 sceKernelGetTimerTimeWide(s32 timerId) +{ + throw __FUNCTION__; +} + +s32 sceKernelSetTimerTime(s32 timerId, vm::psv::ptr pClock) +{ + throw __FUNCTION__; +} + +u64 sceKernelSetTimerTimeWide(s32 timerId, u64 clock) +{ + throw __FUNCTION__; +} + +s32 sceKernelSetTimerEvent(s32 timerId, s32 type, vm::psv::ptr pInterval, s32 fRepeat) +{ + throw __FUNCTION__; +} + +s32 sceKernelCancelTimer(s32 timerId, vm::psv::ptr pNumWaitThreads) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetTimerInfo(s32 timerId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// Reader/writer lock functions + +s32 sceKernelCreateRWLock(vm::psv::ptr pName, u32 attr, vm::psv::ptr pOptParam) +{ + throw __FUNCTION__; +} + +s32 sceKernelDeleteRWLock(s32 rwLockId) +{ + throw __FUNCTION__; +} + +s32 sceKernelOpenRWLock(vm::psv::ptr pName) +{ + throw __FUNCTION__; +} + +s32 sceKernelCloseRWLock(s32 rwLockId) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockReadRWLock(s32 rwLockId, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockReadRWLockCB(s32 rwLockId, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelTryLockReadRWLock(s32 rwLockId) +{ + throw __FUNCTION__; +} + +s32 sceKernelUnlockReadRWLock(s32 rwLockId) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockWriteRWLock(s32 rwLockId, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelLockWriteRWLockCB(s32 rwLockId, vm::psv::ptr pTimeout) +{ + throw __FUNCTION__; +} + +s32 sceKernelTryLockWriteRWLock(s32 rwLockId) +{ + throw __FUNCTION__; +} + +s32 sceKernelUnlockWriteRWLock(s32 rwLockId) +{ + throw __FUNCTION__; +} + +s32 sceKernelCancelRWLock(s32 rwLockId, vm::psv::ptr pNumReadWaitThreads, vm::psv::ptr pNumWriteWaitThreads, s32 flag) +{ + throw __FUNCTION__; +} + +s32 sceKernelGetRWLockInfo(s32 rwLockId, vm::psv::ptr pInfo) +{ + throw __FUNCTION__; +} + +// IO/File functions + +s32 sceIoRemove(vm::psv::ptr filename) +{ + throw __FUNCTION__; +} + +s32 sceIoMkdir(vm::psv::ptr dirname, s32 mode) +{ + throw __FUNCTION__; +} + +s32 sceIoRmdir(vm::psv::ptr dirname) +{ + throw __FUNCTION__; +} + +s32 sceIoRename(vm::psv::ptr oldname, vm::psv::ptr newname) +{ + throw __FUNCTION__; +} + +s32 sceIoDevctl(vm::psv::ptr devname, s32 cmd, vm::psv::ptr arg, u32 arglen, vm::psv::ptr bufp, u32 buflen) +{ + throw __FUNCTION__; +} + +s32 sceIoSync(vm::psv::ptr devname, s32 flag) +{ + throw __FUNCTION__; +} + +s32 sceIoOpen(vm::psv::ptr filename, s32 flag, s32 mode) +{ + throw __FUNCTION__; +} + +s32 sceIoClose(s32 fd) +{ + throw __FUNCTION__; +} + +s32 sceIoIoctl(s32 fd, s32 cmd, vm::psv::ptr argp, u32 arglen, vm::psv::ptr bufp, u32 buflen) +{ + throw __FUNCTION__; +} + +s64 sceIoLseek(s32 fd, s64 offset, s32 whence) +{ + throw __FUNCTION__; +} + +s32 sceIoLseek32(s32 fd, s32 offset, s32 whence) +{ + throw __FUNCTION__; +} + +s32 sceIoRead(s32 fd, vm::psv::ptr buf, u32 nbyte) +{ + throw __FUNCTION__; +} + +s32 sceIoWrite(s32 fd, vm::psv::ptr buf, u32 nbyte) +{ + throw __FUNCTION__; +} + +s32 sceIoPread(s32 fd, vm::psv::ptr buf, u32 nbyte, s64 offset) +{ + throw __FUNCTION__; +} + +s32 sceIoPwrite(s32 fd, vm::psv::ptr buf, u32 nbyte, s64 offset) +{ + throw __FUNCTION__; +} + +s32 sceIoDopen(vm::psv::ptr dirname) +{ + throw __FUNCTION__; +} + +s32 sceIoDclose(s32 fd) +{ + throw __FUNCTION__; +} + +s32 sceIoDread(s32 fd, vm::psv::ptr buf) +{ + throw __FUNCTION__; +} + +s32 sceIoChstat(vm::psv::ptr name, vm::psv::ptr buf, u32 cbit) +{ + throw __FUNCTION__; +} + +s32 sceIoGetstat(vm::psv::ptr name, vm::psv::ptr buf) +{ + throw __FUNCTION__; +} + + #define REG_FUNC(nid, name) reg_psv_func(nid, &sceLibKernel, #name, &name) psv_log_base sceLibKernel("sceLibKernel", []() @@ -331,6 +968,8 @@ psv_log_base sceLibKernel("sceLibKernel", []() sceLibKernel.on_unload = nullptr; sceLibKernel.on_stop = nullptr; + // REG_FUNC(???, sceKernelGetEventInfo); + //REG_FUNC(0x23EAA62, sceKernelPuts); //REG_FUNC(0xB0335388, sceClibToupper); //REG_FUNC(0x4C5471BC, sceClibTolower); @@ -452,11 +1091,11 @@ psv_log_base sceLibKernel("sceLibKernel", []() //REG_FUNC(0x4E81DD5C, sceKernelReceiveMsgPipe); //REG_FUNC(0x33AF829B, sceKernelReceiveMsgPipeCB); //REG_FUNC(0x5615B006, sceKernelTryReceiveMsgPipe); - //REG_FUNC(0xA7819967, sceKernelLockLwMutex); - //REG_FUNC(0x6F9C4CC1, sceKernelLockLwMutexCB); - //REG_FUNC(0x9EF798C1, sceKernelTryLockLwMutex); - //REG_FUNC(0x499EA781, sceKernelUnlockLwMutex); - //REG_FUNC(0xF7D8F1FC, sceKernelGetLwMutexInfo); + REG_FUNC(0xA7819967, sceKernelLockLwMutex); + REG_FUNC(0x6F9C4CC1, sceKernelLockLwMutexCB); + REG_FUNC(0x9EF798C1, sceKernelTryLockLwMutex); + REG_FUNC(0x499EA781, sceKernelUnlockLwMutex); + REG_FUNC(0xF7D8F1FC, sceKernelGetLwMutexInfo); REG_FUNC(0xDDB395A9, sceKernelWaitThreadEnd); REG_FUNC(0xC54941ED, sceKernelWaitThreadEndCB); REG_FUNC(0xD5DC26C4, sceKernelGetThreadExitStatus); @@ -474,62 +1113,62 @@ psv_log_base sceLibKernel("sceLibKernel", []() REG_FUNC(0xF994FE65, sceKernelGetThreadmgrUIDClass); //REG_FUNC(0xB4DE10C7, sceKernelGetActiveCpuMask); REG_FUNC(0x2C1321A3, sceKernelChangeThreadVfpException); - //REG_FUNC(0x3849359A, sceKernelCreateCallback); - //REG_FUNC(0x88DD1BC8, sceKernelGetCallbackInfo); - //REG_FUNC(0x464559D3, sceKernelDeleteCallback); - //REG_FUNC(0xBD9C8F2B, sceKernelNotifyCallback); - //REG_FUNC(0x3137A687, sceKernelCancelCallback); - //REG_FUNC(0x76A2EF81, sceKernelGetCallbackCount); - //REG_FUNC(0xD4F75281, sceKernelRegisterCallbackToEvent); - //REG_FUNC(0x8D3940DF, sceKernelUnregisterCallbackFromEvent); - //REG_FUNC(0x2BD1E682, sceKernelUnregisterCallbackFromEventAll); - //REG_FUNC(0x120F03AF, sceKernelWaitEvent); - //REG_FUNC(0xA0490795, sceKernelWaitEventCB); - //REG_FUNC(0x241F3634, sceKernelPollEvent); - //REG_FUNC(0x603AB770, sceKernelCancelEvent); - //REG_FUNC(0x10586418, sceKernelWaitMultipleEvents); - //REG_FUNC(0x4263DBC9, sceKernelWaitMultipleEventsCB); - //REG_FUNC(0x8516D040, sceKernelCreateEventFlag); - //REG_FUNC(0x11FE9B8B, sceKernelDeleteEventFlag); - //REG_FUNC(0xE04EC73A, sceKernelOpenEventFlag); - //REG_FUNC(0x9C0B8285, sceKernelCloseEventFlag); - //REG_FUNC(0x83C0E2AF, sceKernelWaitEventFlag); - //REG_FUNC(0xE737B1DF, sceKernelWaitEventFlagCB); - //REG_FUNC(0x1FBB0FE1, sceKernelPollEventFlag); - //REG_FUNC(0x2A12D9B7, sceKernelCancelEventFlag); - //REG_FUNC(0x8BA4C0C1, sceKernelGetEventFlagInfo); - //REG_FUNC(0x9EF9C0C5, sceKernelSetEventFlag); - //REG_FUNC(0xD018793F, sceKernelClearEventFlag); - //REG_FUNC(0x297AA2AE, sceKernelCreateSema); - //REG_FUNC(0xC08F5BC5, sceKernelDeleteSema); - //REG_FUNC(0xB028AB78, sceKernelOpenSema); - //REG_FUNC(0x817707AB, sceKernelCloseSema); - //REG_FUNC(0xC7B834B, sceKernelWaitSema); - //REG_FUNC(0x174692B4, sceKernelWaitSemaCB); - //REG_FUNC(0x66D6BF05, sceKernelCancelSema); - //REG_FUNC(0x595D3FA6, sceKernelGetSemaInfo); - //REG_FUNC(0x3012A9C6, sceKernelPollSema); - //REG_FUNC(0x2053A496, sceKernelSignalSema); - //REG_FUNC(0xED53334A, sceKernelCreateMutex); - //REG_FUNC(0x12D11F65, sceKernelDeleteMutex); - //REG_FUNC(0x16B85235, sceKernelOpenMutex); - //REG_FUNC(0x43DDC9CC, sceKernelCloseMutex); - //REG_FUNC(0x1D8D7945, sceKernelLockMutex); - //REG_FUNC(0x2BDAA524, sceKernelLockMutexCB); - //REG_FUNC(0x2144890D, sceKernelCancelMutex); - //REG_FUNC(0x9A6C43CA, sceKernelGetMutexInfo); - //REG_FUNC(0xE5901FF9, sceKernelTryLockMutex); - //REG_FUNC(0x34746309, sceKernelUnlockMutex); - //REG_FUNC(0x50572FDA, sceKernelCreateCond); - //REG_FUNC(0xFD295414, sceKernelDeleteCond); - //REG_FUNC(0xCB2A73A9, sceKernelOpenCond); - //REG_FUNC(0x4FB91A89, sceKernelCloseCond); - //REG_FUNC(0xC88D44AD, sceKernelWaitCond); - //REG_FUNC(0x4CE42CE2, sceKernelWaitCondCB); - //REG_FUNC(0x6864DCE2, sceKernelGetCondInfo); - //REG_FUNC(0x10A4976F, sceKernelSignalCond); - //REG_FUNC(0x2EB86929, sceKernelSignalCondAll); - //REG_FUNC(0x87629E6, sceKernelSignalCondTo); + REG_FUNC(0x3849359A, sceKernelCreateCallback); + REG_FUNC(0x88DD1BC8, sceKernelGetCallbackInfo); + REG_FUNC(0x464559D3, sceKernelDeleteCallback); + REG_FUNC(0xBD9C8F2B, sceKernelNotifyCallback); + REG_FUNC(0x3137A687, sceKernelCancelCallback); + REG_FUNC(0x76A2EF81, sceKernelGetCallbackCount); + REG_FUNC(0xD4F75281, sceKernelRegisterCallbackToEvent); + REG_FUNC(0x8D3940DF, sceKernelUnregisterCallbackFromEvent); + REG_FUNC(0x2BD1E682, sceKernelUnregisterCallbackFromEventAll); + REG_FUNC(0x120F03AF, sceKernelWaitEvent); + REG_FUNC(0xA0490795, sceKernelWaitEventCB); + REG_FUNC(0x241F3634, sceKernelPollEvent); + REG_FUNC(0x603AB770, sceKernelCancelEvent); + REG_FUNC(0x10586418, sceKernelWaitMultipleEvents); + REG_FUNC(0x4263DBC9, sceKernelWaitMultipleEventsCB); + REG_FUNC(0x8516D040, sceKernelCreateEventFlag); + REG_FUNC(0x11FE9B8B, sceKernelDeleteEventFlag); + REG_FUNC(0xE04EC73A, sceKernelOpenEventFlag); + REG_FUNC(0x9C0B8285, sceKernelCloseEventFlag); + REG_FUNC(0x83C0E2AF, sceKernelWaitEventFlag); + REG_FUNC(0xE737B1DF, sceKernelWaitEventFlagCB); + REG_FUNC(0x1FBB0FE1, sceKernelPollEventFlag); + REG_FUNC(0x2A12D9B7, sceKernelCancelEventFlag); + REG_FUNC(0x8BA4C0C1, sceKernelGetEventFlagInfo); + REG_FUNC(0x9EF9C0C5, sceKernelSetEventFlag); + REG_FUNC(0xD018793F, sceKernelClearEventFlag); + REG_FUNC(0x297AA2AE, sceKernelCreateSema); + REG_FUNC(0xC08F5BC5, sceKernelDeleteSema); + REG_FUNC(0xB028AB78, sceKernelOpenSema); + REG_FUNC(0x817707AB, sceKernelCloseSema); + REG_FUNC(0xC7B834B, sceKernelWaitSema); + REG_FUNC(0x174692B4, sceKernelWaitSemaCB); + REG_FUNC(0x66D6BF05, sceKernelCancelSema); + REG_FUNC(0x595D3FA6, sceKernelGetSemaInfo); + REG_FUNC(0x3012A9C6, sceKernelPollSema); + REG_FUNC(0x2053A496, sceKernelSignalSema); + REG_FUNC(0xED53334A, sceKernelCreateMutex); + REG_FUNC(0x12D11F65, sceKernelDeleteMutex); + REG_FUNC(0x16B85235, sceKernelOpenMutex); + REG_FUNC(0x43DDC9CC, sceKernelCloseMutex); + REG_FUNC(0x1D8D7945, sceKernelLockMutex); + REG_FUNC(0x2BDAA524, sceKernelLockMutexCB); + REG_FUNC(0x2144890D, sceKernelCancelMutex); + REG_FUNC(0x9A6C43CA, sceKernelGetMutexInfo); + REG_FUNC(0xE5901FF9, sceKernelTryLockMutex); + REG_FUNC(0x34746309, sceKernelUnlockMutex); + REG_FUNC(0x50572FDA, sceKernelCreateCond); + REG_FUNC(0xFD295414, sceKernelDeleteCond); + REG_FUNC(0xCB2A73A9, sceKernelOpenCond); + REG_FUNC(0x4FB91A89, sceKernelCloseCond); + REG_FUNC(0xC88D44AD, sceKernelWaitCond); + REG_FUNC(0x4CE42CE2, sceKernelWaitCondCB); + REG_FUNC(0x6864DCE2, sceKernelGetCondInfo); + REG_FUNC(0x10A4976F, sceKernelSignalCond); + REG_FUNC(0x2EB86929, sceKernelSignalCondAll); + REG_FUNC(0x87629E6, sceKernelSignalCondTo); //REG_FUNC(0xA10C1C8, sceKernelCreateMsgPipe); //REG_FUNC(0x69F6575D, sceKernelDeleteMsgPipe); //REG_FUNC(0x230691DA, sceKernelOpenMsgPipe); @@ -542,72 +1181,72 @@ psv_log_base sceLibKernel("sceLibKernel", []() //REG_FUNC(0x86ECC0FF, sceKernelTryReceiveMsgPipeVector); //REG_FUNC(0xEF14BA37, sceKernelCancelMsgPipe); //REG_FUNC(0x4046D16B, sceKernelGetMsgPipeInfo); - //REG_FUNC(0xDA6EC8EF, sceKernelCreateLwMutex); - //REG_FUNC(0x244E76D2, sceKernelDeleteLwMutex); - //REG_FUNC(0x4846613D, sceKernelGetLwMutexInfoById); - //REG_FUNC(0x48C7EAE6, sceKernelCreateLwCond); - //REG_FUNC(0x721F6CB3, sceKernelDeleteLwCond); - //REG_FUNC(0xE1878282, sceKernelWaitLwCond); - //REG_FUNC(0x8FA54B07, sceKernelWaitLwCondCB); - //REG_FUNC(0x3AC63B9A, sceKernelSignalLwCond); - //REG_FUNC(0xE5241A0C, sceKernelSignalLwCondAll); - //REG_FUNC(0xFC1A48EB, sceKernelSignalLwCondTo); - //REG_FUNC(0xE4DF36A0, sceKernelGetLwCondInfo); - //REG_FUNC(0x971F1DE8, sceKernelGetLwCondInfoById); - //REG_FUNC(0x2255B2A5, sceKernelCreateTimer); - //REG_FUNC(0x746F3290, sceKernelDeleteTimer); - //REG_FUNC(0x2F3D35A3, sceKernelOpenTimer); - //REG_FUNC(0x17283DE6, sceKernelCloseTimer); - //REG_FUNC(0x1478249B, sceKernelStartTimer); - //REG_FUNC(0x75B1329, sceKernelStopTimer); - //REG_FUNC(0x1F59E04D, sceKernelGetTimerBase); - //REG_FUNC(0x3223CCD1, sceKernelGetTimerBaseWide); - //REG_FUNC(0x381DC300, sceKernelGetTimerTime); - //REG_FUNC(0x53C5D833, sceKernelGetTimerTimeWide); - //REG_FUNC(0xFFAD717F, sceKernelSetTimerTime); - //REG_FUNC(0xAF67678B, sceKernelSetTimerTimeWide); - //REG_FUNC(0x621D293B, sceKernelSetTimerEvent); - //REG_FUNC(0x9CCF768C, sceKernelCancelTimer); - //REG_FUNC(0x7E35E10A, sceKernelGetTimerInfo); - //REG_FUNC(0x8667951D, sceKernelCreateRWLock); - //REG_FUNC(0x3D750204, sceKernelDeleteRWLock); - //REG_FUNC(0xBA4DAC9A, sceKernelOpenRWLock); - //REG_FUNC(0xA7F94E64, sceKernelCloseRWLock); - //REG_FUNC(0xFA670F0F, sceKernelLockReadRWLock); - //REG_FUNC(0x2D4A62B7, sceKernelLockReadRWLockCB); - //REG_FUNC(0x1B8586C0, sceKernelTryLockReadRWLock); - //REG_FUNC(0x675D10A8, sceKernelUnlockReadRWLock); - //REG_FUNC(0x67A187BB, sceKernelLockWriteRWLock); - //REG_FUNC(0xA4777082, sceKernelLockWriteRWLockCB); - //REG_FUNC(0x597D4607, sceKernelTryLockWriteRWLock); - //REG_FUNC(0xD9369DF2, sceKernelUnlockWriteRWLock); - //REG_FUNC(0x190CA94B, sceKernelCancelRWLock); - //REG_FUNC(0x79A573B, sceKernelGetRWLockInfo); - //REG_FUNC(0x8AF15B5F, sceKernelGetSystemTime); + REG_FUNC(0xDA6EC8EF, sceKernelCreateLwMutex); + REG_FUNC(0x244E76D2, sceKernelDeleteLwMutex); + REG_FUNC(0x4846613D, sceKernelGetLwMutexInfoById); + REG_FUNC(0x48C7EAE6, sceKernelCreateLwCond); + REG_FUNC(0x721F6CB3, sceKernelDeleteLwCond); + REG_FUNC(0xE1878282, sceKernelWaitLwCond); + REG_FUNC(0x8FA54B07, sceKernelWaitLwCondCB); + REG_FUNC(0x3AC63B9A, sceKernelSignalLwCond); + REG_FUNC(0xE5241A0C, sceKernelSignalLwCondAll); + REG_FUNC(0xFC1A48EB, sceKernelSignalLwCondTo); + REG_FUNC(0xE4DF36A0, sceKernelGetLwCondInfo); + REG_FUNC(0x971F1DE8, sceKernelGetLwCondInfoById); + REG_FUNC(0x2255B2A5, sceKernelCreateTimer); + REG_FUNC(0x746F3290, sceKernelDeleteTimer); + REG_FUNC(0x2F3D35A3, sceKernelOpenTimer); + REG_FUNC(0x17283DE6, sceKernelCloseTimer); + REG_FUNC(0x1478249B, sceKernelStartTimer); + REG_FUNC(0x75B1329, sceKernelStopTimer); + REG_FUNC(0x1F59E04D, sceKernelGetTimerBase); + REG_FUNC(0x3223CCD1, sceKernelGetTimerBaseWide); + REG_FUNC(0x381DC300, sceKernelGetTimerTime); + REG_FUNC(0x53C5D833, sceKernelGetTimerTimeWide); + REG_FUNC(0xFFAD717F, sceKernelSetTimerTime); + REG_FUNC(0xAF67678B, sceKernelSetTimerTimeWide); + REG_FUNC(0x621D293B, sceKernelSetTimerEvent); + REG_FUNC(0x9CCF768C, sceKernelCancelTimer); + REG_FUNC(0x7E35E10A, sceKernelGetTimerInfo); + REG_FUNC(0x8667951D, sceKernelCreateRWLock); + REG_FUNC(0x3D750204, sceKernelDeleteRWLock); + REG_FUNC(0xBA4DAC9A, sceKernelOpenRWLock); + REG_FUNC(0xA7F94E64, sceKernelCloseRWLock); + REG_FUNC(0xFA670F0F, sceKernelLockReadRWLock); + REG_FUNC(0x2D4A62B7, sceKernelLockReadRWLockCB); + REG_FUNC(0x1B8586C0, sceKernelTryLockReadRWLock); + REG_FUNC(0x675D10A8, sceKernelUnlockReadRWLock); + REG_FUNC(0x67A187BB, sceKernelLockWriteRWLock); + REG_FUNC(0xA4777082, sceKernelLockWriteRWLockCB); + REG_FUNC(0x597D4607, sceKernelTryLockWriteRWLock); + REG_FUNC(0xD9369DF2, sceKernelUnlockWriteRWLock); + REG_FUNC(0x190CA94B, sceKernelCancelRWLock); + REG_FUNC(0x79A573B, sceKernelGetRWLockInfo); + REG_FUNC(0x8AF15B5F, sceKernelGetSystemTime); //REG_FUNC(0x99B2BF15, sceKernelPMonThreadGetCounter); //REG_FUNC(0x7C21C961, sceKernelPMonCpuGetCounter); //REG_FUNC(0xADCA94E5, sceKernelWaitSignal); //REG_FUNC(0x24460BB3, sceKernelWaitSignalCB); //REG_FUNC(0x7BE9C4C8, sceKernelSendSignal); REG_FUNC(0xC5C11EE7, sceKernelCreateThread); - //REG_FUNC(0x6C60AC61, sceIoOpen); - //REG_FUNC(0xF5C6F098, sceIoClose); - //REG_FUNC(0x713523E1, sceIoRead); - //REG_FUNC(0x11FED231, sceIoWrite); - //REG_FUNC(0x99BA173E, sceIoLseek); - //REG_FUNC(0x5CC983AC, sceIoLseek32); - //REG_FUNC(0xE20ED0F3, sceIoRemove); - //REG_FUNC(0xF737E369, sceIoRename); - //REG_FUNC(0x9670D39F, sceIoMkdir); - //REG_FUNC(0xE9F91EC8, sceIoRmdir); - //REG_FUNC(0xA9283DD0, sceIoDopen); - //REG_FUNC(0x9DFF9C59, sceIoDclose); - //REG_FUNC(0x9C8B6624, sceIoDread); - //REG_FUNC(0xBCA5B623, sceIoGetstat); - //REG_FUNC(0x29482F7F, sceIoChstat); - //REG_FUNC(0x98ACED6D, sceIoSync); - //REG_FUNC(0x4B30CB2, sceIoDevctl); - //REG_FUNC(0x54ABACFA, sceIoIoctl); + REG_FUNC(0x6C60AC61, sceIoOpen); + REG_FUNC(0xF5C6F098, sceIoClose); + REG_FUNC(0x713523E1, sceIoRead); + REG_FUNC(0x11FED231, sceIoWrite); + REG_FUNC(0x99BA173E, sceIoLseek); + REG_FUNC(0x5CC983AC, sceIoLseek32); + REG_FUNC(0xE20ED0F3, sceIoRemove); + REG_FUNC(0xF737E369, sceIoRename); + REG_FUNC(0x9670D39F, sceIoMkdir); + REG_FUNC(0xE9F91EC8, sceIoRmdir); + REG_FUNC(0xA9283DD0, sceIoDopen); + REG_FUNC(0x9DFF9C59, sceIoDclose); + REG_FUNC(0x9C8B6624, sceIoDread); + REG_FUNC(0xBCA5B623, sceIoGetstat); + REG_FUNC(0x29482F7F, sceIoChstat); + REG_FUNC(0x98ACED6D, sceIoSync); + REG_FUNC(0x4B30CB2, sceIoDevctl); + REG_FUNC(0x54ABACFA, sceIoIoctl); //REG_FUNC(0x6A7EA9FD, sceIoOpenAsync); //REG_FUNC(0x84201C9B, sceIoCloseAsync); //REG_FUNC(0x7B3BE857, sceIoReadAsync); @@ -627,8 +1266,8 @@ psv_log_base sceLibKernel("sceLibKernel", []() //REG_FUNC(0xF7C7FBFE, sceIoSyncAsync); //REG_FUNC(0xEC96EA71, sceIoCancel); //REG_FUNC(0x857E0C71, sceIoComplete); - //REG_FUNC(0x52315AD7, sceIoPread); - //REG_FUNC(0x8FFFF5A8, sceIoPwrite); + REG_FUNC(0x52315AD7, sceIoPread); + REG_FUNC(0x8FFFF5A8, sceIoPwrite); //REG_FUNC(0xA010141E, sceIoPreadAsync); //REG_FUNC(0xED25BEEF, sceIoPwriteAsync); //REG_FUNC(0xA792C404, sceIoCompleteMultiple); @@ -663,12 +1302,12 @@ psv_log_base sceLibKernel("sceLibKernel", []() //REG_FUNC(0x35EE7CF5, sceKernelStderr); /* SceSysmem */ - //REG_FUNC(0xB9D5EBDE, sceKernelAllocMemBlock); - //REG_FUNC(0xA91E15EE, sceKernelFreeMemBlock); - //REG_FUNC(0xB8EF5818, sceKernelGetMemBlockBase); + REG_FUNC(0xB9D5EBDE, sceKernelAllocMemBlock); + REG_FUNC(0xA91E15EE, sceKernelFreeMemBlock); + REG_FUNC(0xB8EF5818, sceKernelGetMemBlockBase); //REG_FUNC(0x3B29E0F5, sceKernelRemapMemBlock); //REG_FUNC(0xA33B99D1, sceKernelFindMemBlockByAddr); - //REG_FUNC(0x4010AD65, sceKernelGetMemBlockInfoByAddr); + REG_FUNC(0x4010AD65, sceKernelGetMemBlockInfoByAddr); /* SceCpu */ //REG_FUNC(0x2704CFEE, sceKernelCpuId); @@ -688,9 +1327,9 @@ psv_log_base sceLibKernel("sceLibKernel", []() REG_FUNC(0x751C9B7A, sceKernelChangeCurrentThreadAttr); REG_FUNC(0xD9BD74EB, sceKernelCheckWaitableStatus); REG_FUNC(0x9DCB4B7A, sceKernelGetProcessId); - //REG_FUNC(0xE53E41F6, sceKernelCheckCallback); - //REG_FUNC(0xF4EE4FA9, sceKernelGetSystemTimeWide); - //REG_FUNC(0x47F6DE49, sceKernelGetSystemTimeLow); + REG_FUNC(0xE53E41F6, sceKernelCheckCallback); + REG_FUNC(0xF4EE4FA9, sceKernelGetSystemTimeWide); + REG_FUNC(0x47F6DE49, sceKernelGetSystemTimeLow); //REG_FUNC(0xC0FAF6A3, sceKernelCreateThreadForUser); /* SceDebugLed */ diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h new file mode 100644 index 0000000000..dca20547c1 --- /dev/null +++ b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h @@ -0,0 +1,595 @@ +#pragma once + +// Error Codes + +enum +{ + SCE_KERNEL_ERROR_ERROR = 0x80020001, + SCE_KERNEL_ERROR_NOT_IMPLEMENTED = 0x80020002, + SCE_KERNEL_ERROR_INVALID_ARGUMENT = 0x80020003, + SCE_KERNEL_ERROR_INVALID_ARGUMENT_SIZE = 0x80020004, + SCE_KERNEL_ERROR_INVALID_FLAGS = 0x80020005, + SCE_KERNEL_ERROR_ILLEGAL_SIZE = 0x80020006, + SCE_KERNEL_ERROR_ILLEGAL_ADDR = 0x80020007, + SCE_KERNEL_ERROR_UNSUP = 0x80020008, + SCE_KERNEL_ERROR_ILLEGAL_MODE = 0x80020009, + SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT = 0x8002000A, + SCE_KERNEL_ERROR_NOSYS = 0x8002000B, + SCE_KERNEL_ERROR_DEBUG_ERROR = 0x80021000, + SCE_KERNEL_ERROR_ILLEGAL_DIPSW_NUMBER = 0x80021001, + SCE_KERNEL_ERROR_CPU_ERROR = 0x80022000, + SCE_KERNEL_ERROR_MMU_ILLEGAL_L1_TYPE = 0x80022001, + SCE_KERNEL_ERROR_MMU_L2_INDEX_OVERFLOW = 0x80022002, + SCE_KERNEL_ERROR_MMU_L2_SIZE_OVERFLOW = 0x80022003, + SCE_KERNEL_ERROR_INVALID_CPU_AFFINITY = 0x80022004, + SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS = 0x80022005, + SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS_PERMISSION = 0x80022006, + SCE_KERNEL_ERROR_VA2PA_FAULT = 0x80022007, + SCE_KERNEL_ERROR_VA2PA_MAPPED = 0x80022008, + SCE_KERNEL_ERROR_VALIDATION_CHECK_FAILED = 0x80022009, + SCE_KERNEL_ERROR_SYSMEM_ERROR = 0x80024000, + SCE_KERNEL_ERROR_INVALID_PROCESS_CONTEXT = 0x80024001, + SCE_KERNEL_ERROR_UID_NAME_TOO_LONG = 0x80024002, + SCE_KERNEL_ERROR_VARANGE_IS_NOT_PHYSICAL_CONTINUOUS = 0x80024003, + SCE_KERNEL_ERROR_PHYADDR_ERROR = 0x80024100, + SCE_KERNEL_ERROR_NO_PHYADDR = 0x80024101, + SCE_KERNEL_ERROR_PHYADDR_USED = 0x80024102, + SCE_KERNEL_ERROR_PHYADDR_NOT_USED = 0x80024103, + SCE_KERNEL_ERROR_NO_IOADDR = 0x80024104, + SCE_KERNEL_ERROR_PHYMEM_ERROR = 0x80024300, + SCE_KERNEL_ERROR_ILLEGAL_PHYPAGE_STATUS = 0x80024301, + SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE = 0x80024302, + SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE_UNIT = 0x80024303, + SCE_KERNEL_ERROR_PHYMEMPART_NOT_EMPTY = 0x80024304, + SCE_KERNEL_ERROR_NO_PHYMEMPART_LPDDR2 = 0x80024305, + SCE_KERNEL_ERROR_NO_PHYMEMPART_CDRAM = 0x80024306, + SCE_KERNEL_ERROR_FIXEDHEAP_ERROR = 0x80024400, + SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_SIZE = 0x80024401, + SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_INDEX = 0x80024402, + SCE_KERNEL_ERROR_FIXEDHEAP_INDEX_OVERFLOW = 0x80024403, + SCE_KERNEL_ERROR_FIXEDHEAP_NO_CHUNK = 0x80024404, + SCE_KERNEL_ERROR_UID_ERROR = 0x80024500, + SCE_KERNEL_ERROR_INVALID_UID = 0x80024501, + SCE_KERNEL_ERROR_SYSMEM_UID_INVALID_ARGUMENT = 0x80024502, + SCE_KERNEL_ERROR_SYSMEM_INVALID_UID_RANGE = 0x80024503, + SCE_KERNEL_ERROR_SYSMEM_NO_VALID_UID = 0x80024504, + SCE_KERNEL_ERROR_SYSMEM_CANNOT_ALLOCATE_UIDENTRY = 0x80024505, + SCE_KERNEL_ERROR_NOT_PROCESS_UID = 0x80024506, + SCE_KERNEL_ERROR_NOT_KERNEL_UID = 0x80024507, + SCE_KERNEL_ERROR_INVALID_UID_CLASS = 0x80024508, + SCE_KERNEL_ERROR_INVALID_UID_SUBCLASS = 0x80024509, + SCE_KERNEL_ERROR_UID_CANNOT_FIND_BY_NAME = 0x8002450A, + SCE_KERNEL_ERROR_VIRPAGE_ERROR = 0x80024600, + SCE_KERNEL_ERROR_ILLEGAL_VIRPAGE_TYPE = 0x80024601, + SCE_KERNEL_ERROR_BLOCK_ERROR = 0x80024700, + SCE_KERNEL_ERROR_ILLEGAL_BLOCK_ID = 0x80024701, + SCE_KERNEL_ERROR_ILLEGAL_BLOCK_TYPE = 0x80024702, + SCE_KERNEL_ERROR_BLOCK_IN_USE = 0x80024703, + SCE_KERNEL_ERROR_PARTITION_ERROR = 0x80024800, + SCE_KERNEL_ERROR_ILLEGAL_PARTITION_ID = 0x80024801, + SCE_KERNEL_ERROR_ILLEGAL_PARTITION_INDEX = 0x80024802, + SCE_KERNEL_ERROR_NO_L2PAGETABLE = 0x80024803, + SCE_KERNEL_ERROR_HEAPLIB_ERROR = 0x80024900, + SCE_KERNEL_ERROR_ILLEGAL_HEAP_ID = 0x80024901, + SCE_KERNEL_ERROR_OUT_OF_RANG = 0x80024902, + SCE_KERNEL_ERROR_HEAPLIB_NOMEM = 0x80024903, + SCE_KERNEL_ERROR_SYSMEM_ADDRESS_SPACE_ERROR = 0x80024A00, + SCE_KERNEL_ERROR_INVALID_ADDRESS_SPACE_ID = 0x80024A01, + SCE_KERNEL_ERROR_INVALID_PARTITION_INDEX = 0x80024A02, + SCE_KERNEL_ERROR_ADDRESS_SPACE_CANNOT_FIND_PARTITION_BY_ADDR = 0x80024A03, + SCE_KERNEL_ERROR_SYSMEM_MEMBLOCK_ERROR = 0x80024B00, + SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_TYPE = 0x80024B01, + SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_REMAP_TYPE = 0x80024B02, + SCE_KERNEL_ERROR_NOT_PHY_CONT_MEMBLOCK = 0x80024B03, + SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_CODE = 0x80024B04, + SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_SIZE = 0x80024B05, + SCE_KERNEL_ERROR_ILLEGAL_USERMAP_SIZE = 0x80024B06, + SCE_KERNEL_ERROR_MEMBLOCK_TYPE_FOR_KERNEL_PROCESS = 0x80024B07, + SCE_KERNEL_ERROR_PROCESS_CANNOT_REMAP_MEMBLOCK = 0x80024B08, + SCE_KERNEL_ERROR_SYSMEM_PHYMEMLOW_ERROR = 0x80024C00, + SCE_KERNEL_ERROR_CANNOT_ALLOC_PHYMEMLOW = 0x80024C01, + SCE_KERNEL_ERROR_UNKNOWN_PHYMEMLOW_TYPE = 0x80024C02, + SCE_KERNEL_ERROR_SYSMEM_BITHEAP_ERROR = 0x80024D00, + SCE_KERNEL_ERROR_CANNOT_ALLOC_BITHEAP = 0x80024D01, + SCE_KERNEL_ERROR_LOADCORE_ERROR = 0x80025000, + SCE_KERNEL_ERROR_ILLEGAL_ELF_HEADER = 0x80025001, + SCE_KERNEL_ERROR_ILLEGAL_SELF_HEADER = 0x80025002, + SCE_KERNEL_ERROR_EXCPMGR_ERROR = 0x80027000, + SCE_KERNEL_ERROR_ILLEGAL_EXCPCODE = 0x80027001, + SCE_KERNEL_ERROR_ILLEGAL_EXCPHANDLER = 0x80027002, + SCE_KERNEL_ERROR_NOTFOUND_EXCPHANDLER = 0x80027003, + SCE_KERNEL_ERROR_CANNOT_RELEASE_EXCPHANDLER = 0x80027004, + SCE_KERNEL_ERROR_INTRMGR_ERROR = 0x80027100, + SCE_KERNEL_ERROR_ILLEGAL_CONTEXT = 0x80027101, + SCE_KERNEL_ERROR_ILLEGAL_INTRCODE = 0x80027102, + SCE_KERNEL_ERROR_ILLEGAL_INTRPARAM = 0x80027103, + SCE_KERNEL_ERROR_ILLEGAL_INTRPRIORITY = 0x80027104, + SCE_KERNEL_ERROR_ILLEGAL_TARGET_CPU = 0x80027105, + SCE_KERNEL_ERROR_ILLEGAL_INTRFILTER = 0x80027106, + SCE_KERNEL_ERROR_ILLEGAL_INTRTYPE = 0x80027107, + SCE_KERNEL_ERROR_ILLEGAL_HANDLER = 0x80027108, + SCE_KERNEL_ERROR_FOUND_HANDLER = 0x80027109, + SCE_KERNEL_ERROR_NOTFOUND_HANDLER = 0x8002710A, + SCE_KERNEL_ERROR_NO_MEMORY = 0x8002710B, + SCE_KERNEL_ERROR_DMACMGR_ERROR = 0x80027200, + SCE_KERNEL_ERROR_ALREADY_QUEUED = 0x80027201, + SCE_KERNEL_ERROR_NOT_QUEUED = 0x80027202, + SCE_KERNEL_ERROR_NOT_SETUP = 0x80027203, + SCE_KERNEL_ERROR_ON_TRANSFERRING = 0x80027204, + SCE_KERNEL_ERROR_NOT_INITIALIZED = 0x80027205, + SCE_KERNEL_ERROR_TRANSFERRED = 0x80027206, + SCE_KERNEL_ERROR_NOT_UNDER_CONTROL = 0x80027207, + SCE_KERNEL_ERROR_SYSTIMER_ERROR = 0x80027300, + SCE_KERNEL_ERROR_NO_FREE_TIMER = 0x80027301, + SCE_KERNEL_ERROR_TIMER_NOT_ALLOCATED = 0x80027302, + SCE_KERNEL_ERROR_TIMER_COUNTING = 0x80027303, + SCE_KERNEL_ERROR_TIMER_STOPPED = 0x80027304, + SCE_KERNEL_ERROR_THREADMGR_ERROR = 0x80028000, + SCE_KERNEL_ERROR_DORMANT = 0x80028001, + SCE_KERNEL_ERROR_NOT_DORMANT = 0x80028002, + SCE_KERNEL_ERROR_UNKNOWN_THID = 0x80028003, + SCE_KERNEL_ERROR_CAN_NOT_WAIT = 0x80028004, + SCE_KERNEL_ERROR_ILLEGAL_THID = 0x80028005, + SCE_KERNEL_ERROR_THREAD_TERMINATED = 0x80028006, + SCE_KERNEL_ERROR_DELETED = 0x80028007, + SCE_KERNEL_ERROR_WAIT_TIMEOUT = 0x80028008, + SCE_KERNEL_ERROR_NOTIFY_CALLBACK = 0x80028009, + SCE_KERNEL_ERROR_WAIT_DELETE = 0x8002800A, + SCE_KERNEL_ERROR_ILLEGAL_ATTR = 0x8002800B, + SCE_KERNEL_ERROR_EVF_MULTI = 0x8002800C, + SCE_KERNEL_ERROR_WAIT_CANCEL = 0x8002800D, + SCE_KERNEL_ERROR_EVF_COND = 0x8002800E, + SCE_KERNEL_ERROR_ILLEGAL_COUNT = 0x8002800F, + SCE_KERNEL_ERROR_ILLEGAL_PRIORITY = 0x80028010, + SCE_KERNEL_ERROR_MUTEX_RECURSIVE = 0x80028011, + SCE_KERNEL_ERROR_MUTEX_LOCK_OVF = 0x80028012, + SCE_KERNEL_ERROR_MUTEX_NOT_OWNED = 0x80028013, + SCE_KERNEL_ERROR_MUTEX_UNLOCK_UDF = 0x80028014, + SCE_KERNEL_ERROR_MUTEX_FAILED_TO_OWN = 0x80028015, + SCE_KERNEL_ERROR_FAST_MUTEX_RECURSIVE = 0x80028016, + SCE_KERNEL_ERROR_FAST_MUTEX_LOCK_OVF = 0x80028017, + SCE_KERNEL_ERROR_FAST_MUTEX_FAILED_TO_OWN = 0x80028018, + SCE_KERNEL_ERROR_FAST_MUTEX_NOT_OWNED = 0x80028019, + SCE_KERNEL_ERROR_FAST_MUTEX_OWNED = 0x8002801A, + SCE_KERNEL_ERROR_ALARM_CAN_NOT_CANCEL = 0x8002801B, + SCE_KERNEL_ERROR_INVALID_OBJECT_TYPE = 0x8002801C, + SCE_KERNEL_ERROR_KERNEL_TLS_FULL = 0x8002801D, + SCE_KERNEL_ERROR_ILLEGAL_KERNEL_TLS_INDEX = 0x8002801E, + SCE_KERNEL_ERROR_KERNEL_TLS_BUSY = 0x8002801F, + SCE_KERNEL_ERROR_DIFFERENT_UID_CLASS = 0x80028020, + SCE_KERNEL_ERROR_UNKNOWN_UID = 0x80028021, + SCE_KERNEL_ERROR_SEMA_ZERO = 0x80028022, + SCE_KERNEL_ERROR_SEMA_OVF = 0x80028023, + SCE_KERNEL_ERROR_PMON_NOT_THREAD_MODE = 0x80028024, + SCE_KERNEL_ERROR_PMON_NOT_CPU_MODE = 0x80028025, + SCE_KERNEL_ERROR_ALREADY_REGISTERED = 0x80028026, + SCE_KERNEL_ERROR_INVALID_THREAD_ID = 0x80028027, + SCE_KERNEL_ERROR_ALREADY_DEBUG_SUSPENDED = 0x80028028, + SCE_KERNEL_ERROR_NOT_DEBUG_SUSPENDED = 0x80028029, + SCE_KERNEL_ERROR_CAN_NOT_USE_VFP = 0x8002802A, + SCE_KERNEL_ERROR_RUNNING = 0x8002802B, + SCE_KERNEL_ERROR_EVENT_COND = 0x8002802C, + SCE_KERNEL_ERROR_MSG_PIPE_FULL = 0x8002802D, + SCE_KERNEL_ERROR_MSG_PIPE_EMPTY = 0x8002802E, + SCE_KERNEL_ERROR_ALREADY_SENT = 0x8002802F, + SCE_KERNEL_ERROR_CAN_NOT_SUSPEND = 0x80028030, + SCE_KERNEL_ERROR_FAST_MUTEX_ALREADY_INITIALIZED = 0x80028031, + SCE_KERNEL_ERROR_FAST_MUTEX_NOT_INITIALIZED = 0x80028032, + SCE_KERNEL_ERROR_THREAD_STOPPED = 0x80028033, + SCE_KERNEL_ERROR_THREAD_SUSPENDED = 0x80028034, + SCE_KERNEL_ERROR_NOT_SUSPENDED = 0x80028035, + SCE_KERNEL_ERROR_WAIT_DELETE_MUTEX = 0x80028036, + SCE_KERNEL_ERROR_WAIT_CANCEL_MUTEX = 0x80028037, + SCE_KERNEL_ERROR_WAIT_DELETE_COND = 0x80028038, + SCE_KERNEL_ERROR_WAIT_CANCEL_COND = 0x80028039, + SCE_KERNEL_ERROR_LW_MUTEX_NOT_OWNED = 0x8002803A, + SCE_KERNEL_ERROR_LW_MUTEX_LOCK_OVF = 0x8002803B, + SCE_KERNEL_ERROR_LW_MUTEX_UNLOCK_UDF = 0x8002803C, + SCE_KERNEL_ERROR_LW_MUTEX_RECURSIVE = 0x8002803D, + SCE_KERNEL_ERROR_LW_MUTEX_FAILED_TO_OWN = 0x8002803E, + SCE_KERNEL_ERROR_WAIT_DELETE_LW_MUTEX = 0x8002803F, + SCE_KERNEL_ERROR_ILLEGAL_STACK_SIZE = 0x80028040, + SCE_KERNEL_ERROR_RW_LOCK_RECURSIVE = 0x80028041, + SCE_KERNEL_ERROR_RW_LOCK_LOCK_OVF = 0x80028042, + SCE_KERNEL_ERROR_RW_LOCK_NOT_OWNED = 0x80028043, + SCE_KERNEL_ERROR_RW_LOCK_UNLOCK_UDF = 0x80028044, + SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_LOCK = 0x80028045, + SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_UNLOCK = 0x80028046, + + SCE_KERNEL_ERROR_PROCESSMGR_ERROR = 0x80029000, + SCE_KERNEL_ERROR_INVALID_PID = 0x80029001, + SCE_KERNEL_ERROR_INVALID_PROCESS_TYPE = 0x80029002, + SCE_KERNEL_ERROR_PLS_FULL = 0x80029003, + SCE_KERNEL_ERROR_INVALID_PROCESS_STATUS = 0x80029004, + SCE_KERNEL_ERROR_INVALID_BUDGET_ID = 0x80029005, + SCE_KERNEL_ERROR_INVALID_BUDGET_SIZE = 0x80029006, + SCE_KERNEL_ERROR_CP14_DISABLED = 0x80029007, + SCE_KERNEL_ERROR_EXCEEDED_MAX_PROCESSES = 0x80029008, + SCE_KERNEL_ERROR_PROCESS_REMAINING = 0x80029009, + SCE_KERNEL_ERROR_IOFILEMGR_ERROR = 0x8002A000, + SCE_KERNEL_ERROR_IO_NAME_TOO_LONG = 0x8002A001, + SCE_KERNEL_ERROR_IO_REG_DEV = 0x8002A002, + SCE_KERNEL_ERROR_IO_ALIAS_USED = 0x8002A003, + SCE_KERNEL_ERROR_IO_DEL_DEV = 0x8002A004, + SCE_KERNEL_ERROR_IO_WOULD_BLOCK = 0x8002A005, + SCE_KERNEL_ERROR_MODULEMGR_START_FAILED = 0x8002D000, + SCE_KERNEL_ERROR_MODULEMGR_STOP_FAIL = 0x8002D001, + SCE_KERNEL_ERROR_MODULEMGR_IN_USE = 0x8002D002, + SCE_KERNEL_ERROR_MODULEMGR_NO_LIB = 0x8002D003, + SCE_KERNEL_ERROR_MODULEMGR_SYSCALL_REG = 0x8002D004, + SCE_KERNEL_ERROR_MODULEMGR_NOMEM_LIB = 0x8002D005, + SCE_KERNEL_ERROR_MODULEMGR_NOMEM_STUB = 0x8002D006, + SCE_KERNEL_ERROR_MODULEMGR_NOMEM_SELF = 0x8002D007, + SCE_KERNEL_ERROR_MODULEMGR_NOMEM = 0x8002D008, + SCE_KERNEL_ERROR_MODULEMGR_INVALID_LIB = 0x8002D009, + SCE_KERNEL_ERROR_MODULEMGR_INVALID_STUB = 0x8002D00A, + SCE_KERNEL_ERROR_MODULEMGR_NO_FUNC_NID = 0x8002D00B, + SCE_KERNEL_ERROR_MODULEMGR_NO_VAR_NID = 0x8002D00C, + SCE_KERNEL_ERROR_MODULEMGR_INVALID_TYPE = 0x8002D00D, + SCE_KERNEL_ERROR_MODULEMGR_NO_MOD_ENTRY = 0x8002D00E, + SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROC_PARAM = 0x8002D00F, + SCE_KERNEL_ERROR_MODULEMGR_NO_MODOBJ = 0x8002D010, + SCE_KERNEL_ERROR_MODULEMGR_NO_MOD = 0x8002D011, + SCE_KERNEL_ERROR_MODULEMGR_NO_PROCESS = 0x8002D012, + SCE_KERNEL_ERROR_MODULEMGR_OLD_LIB = 0x8002D013, + SCE_KERNEL_ERROR_MODULEMGR_STARTED = 0x8002D014, + SCE_KERNEL_ERROR_MODULEMGR_NOT_STARTED = 0x8002D015, + SCE_KERNEL_ERROR_MODULEMGR_NOT_STOPPED = 0x8002D016, + SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROCESS_UID = 0x8002D017, + SCE_KERNEL_ERROR_MODULEMGR_CANNOT_EXPORT_LIB_TO_SHARED = 0x8002D018, + SCE_KERNEL_ERROR_MODULEMGR_INVALID_REL_INFO = 0x8002D019, + SCE_KERNEL_ERROR_MODULEMGR_INVALID_REF_INFO = 0x8002D01A, + SCE_KERNEL_ERROR_MODULEMGR_ELINK = 0x8002D01B, + SCE_KERNEL_ERROR_MODULEMGR_NOENT = 0x8002D01C, + SCE_KERNEL_ERROR_MODULEMGR_BUSY = 0x8002D01D, + SCE_KERNEL_ERROR_MODULEMGR_NOEXEC = 0x8002D01E, + SCE_KERNEL_ERROR_MODULEMGR_NAMETOOLONG = 0x8002D01F, + SCE_KERNEL_ERROR_LIBRARYDB_NOENT = 0x8002D080, + SCE_KERNEL_ERROR_LIBRARYDB_NO_LIB = 0x8002D081, + SCE_KERNEL_ERROR_LIBRARYDB_NO_MOD = 0x8002D082, + SCE_KERNEL_ERROR_AUTHFAIL = 0x8002F000, + SCE_KERNEL_ERROR_NO_AUTH = 0x8002F001, +}; + +union SceKernelSysClock +{ + struct + { + u32 low; + u32 hi; + }; + + u64 quad; +}; + +struct SceKernelCallFrame +{ + u32 sp; + u32 pc; +}; + +// Memory Manager definitions + +typedef s32 SceKernelMemoryType; + +struct SceKernelMemBlockInfo +{ + u32 size; + vm::psv::ptr mappedBase; + u32 mappedSize; + SceKernelMemoryType memoryType; + u32 access; +}; + +struct SceKernelAllocMemBlockOpt +{ + u32 size; + u32 attr; + u32 alignment; + s32 uidBaseBlock; + vm::psv::ptr strBaseBlockName; +}; + +// Thread Manager definitions (threads) + +typedef s32(*SceKernelThreadEntry)(u32 argSize, vm::psv::ptr pArgBlock); + +struct SceKernelThreadOptParam +{ + u32 size; + u32 attr; +}; + +struct SceKernelThreadInfo +{ + u32 size; + s32 processId; + char name[32]; + u32 attr; + u32 status; + vm::psv::ptr entry; + vm::psv::ptr pStack; + u32 stackSize; + s32 initPriority; + s32 currentPriority; + s32 initCpuAffinityMask; + s32 currentCpuAffinityMask; + s32 currentCpuId; + s32 lastExecutedCpuId; + u32 waitType; + s32 waitId; + s32 exitStatus; + SceKernelSysClock runClocks; + u32 intrPreemptCount; + u32 threadPreemptCount; + u32 threadReleaseCount; + s32 changeCpuCount; + s32 fNotifyCallback; + s32 reserved; +}; + +struct SceKernelThreadRunStatus +{ + u32 size; + + struct + { + s32 processId; + s32 threadId; + s32 priority; + + } cpuInfo[4]; +}; + +struct SceKernelSystemInfo +{ + u32 size; + u32 activeCpuMask; + + struct + { + SceKernelSysClock idleClock; + u32 comesOutOfIdleCount; + u32 threadSwitchCount; + + } cpuInfo[4]; +}; + +// Thread Manager definitions (callbacks) + +typedef s32(*SceKernelCallbackFunction)(s32 notifyId, s32 notifyCount, s32 notifyArg, vm::psv::ptr pCommon); + +struct SceKernelCallbackInfo +{ + u32 size; + s32 callbackId; + char name[32]; + u32 attr; + s32 threadId; + vm::psv::ptr callbackFunc; + s32 notifyId; + s32 notifyCount; + s32 notifyArg; + vm::psv::ptr pCommon; +}; + +// Thread Manager definitions (events) + +typedef s32(*SceKernelThreadEventHandler)(s32 type, s32 threadId, s32 arg, vm::psv::ptr pCommon); + +struct SceKernelEventInfo +{ + u32 size; + s32 eventId; + char name[32]; + u32 attr; + u32 eventPattern; + u64 userData; + u32 numWaitThreads; + s32 reserved[1]; +}; + +struct SceKernelWaitEvent +{ + s32 eventId; + u32 eventPattern; +}; + +struct SceKernelResultEvent +{ + s32 eventId; + s32 result; + u32 resultPattern; + s32 reserved[1]; + u64 userData; +}; + +// Thread Manager definitions (event flags) + +struct SceKernelEventFlagOptParam +{ + u32 size; +}; + +struct SceKernelEventFlagInfo +{ + u32 size; + s32 evfId; + char name[32]; + u32 attr; + u32 initPattern; + u32 currentPattern; + s32 numWaitThreads; +}; + +// Thread Manager definitions (semaphores) + +struct SceKernelSemaOptParam +{ + u32 size; +}; + +struct SceKernelSemaInfo +{ + u32 size; + s32 semaId; + char name[32]; + u32 attr; + s32 initCount; + s32 currentCount; + s32 maxCount; + s32 numWaitThreads; +}; + +// Thread Manager definitions (mutexes) + +struct SceKernelMutexOptParam +{ + u32 size; + s32 ceilingPriority; +}; + +struct SceKernelMutexInfo +{ + u32 size; + s32 mutexId; + char name[32]; + u32 attr; + s32 initCount; + s32 currentCount; + s32 currentOwnerId; + s32 numWaitThreads; +}; + +// Thread Manager definitions (lightweight mutexes) + +struct SceKernelLwMutexWork +{ + s32 data[4]; +}; + +struct SceKernelLwMutexOptParam +{ + u32 size; +}; + +struct SceKernelLwMutexInfo +{ + u32 size; + s32 uid; + char name[32]; + u32 attr; + vm::psv::ptr pWork; + s32 initCount; + s32 currentCount; + s32 currentOwnerId; + s32 numWaitThreads; +}; + +// Thread Manager definitions (condition variables) + +struct SceKernelCondOptParam +{ + u32 size; +}; + +struct SceKernelCondInfo +{ + u32 size; + s32 condId; + char name[32]; + u32 attr; + s32 mutexId; + u32 numWaitThreads; +}; + +// Thread Manager definitions (lightweight condition variables) + +struct SceKernelLwCondWork +{ + s32 data[4]; +}; + +struct SceKernelLwCondOptParam +{ + u32 size; +}; + +struct SceKernelLwCondInfo +{ + u32 size; + s32 uid; + char name[32]; + u32 attr; + vm::psv::ptr pWork; + vm::psv::ptr pLwMutex; + u32 numWaitThreads; +}; + +// Thread Manager definitions (timers) + +struct SceKernelTimerOptParam +{ + u32 size; +}; + +struct SceKernelTimerInfo +{ + u32 size; + s32 timerId; + char name[32]; + u32 attr; + s32 fActive; + SceKernelSysClock baseTime; + SceKernelSysClock currentTime; + SceKernelSysClock schedule; + SceKernelSysClock interval; + s32 type; + s32 fRepeat; + s32 numWaitThreads; + s32 reserved[1]; +}; + +// Thread Manager definitions (reader/writer locks) + +struct SceKernelRWLockOptParam +{ + u32 size; +}; + +struct SceKernelRWLockInfo +{ + u32 size; + s32 rwLockId; + char name[32]; + u32 attr; + s32 lockCount; + s32 writeOwnerId; + s32 numReadWaitThreads; + s32 numWriteWaitThreads; +}; + +// IO/File Manager definitions + +struct SceIoStat +{ + s32 mode; + u32 attr; + s64 size; + SceDateTime ctime; + SceDateTime atime; + SceDateTime mtime; + u64 _private[6]; +}; + +struct SceIoDirent +{ + SceIoStat d_stat; + char d_name[256]; + vm::psv::ptr d_private; + s32 dummy; +}; + +// Module + +extern psv_log_base sceLibKernel; diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp index a81d82ac51..f0e596af2b 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp @@ -1,7 +1,6 @@ #include "stdafx.h" #include "Utilities/Log.h" #include "Emu/System.h" -#include "Emu/Memory/Memory.h" #include "Emu/ARMv7/PSVFuncList.h" #include "Emu/ARMv7/ARMv7Callback.h" diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp index db7745f9f3..c0b847e6e5 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "Emu/System.h" -#include "Emu/Memory/Memory.h" #include "Emu/ARMv7/PSVFuncList.h" extern psv_log_base sceLibm; diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp index ef215f0971..44b3b75ff8 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "Emu/System.h" -#include "Emu/Memory/Memory.h" #include "Emu/ARMv7/PSVFuncList.h" extern psv_log_base sceLibstdcxx; diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.h b/rpcs3/Emu/ARMv7/PSVFuncList.h index cf34bf846e..0326208f9f 100644 --- a/rpcs3/Emu/ARMv7/PSVFuncList.h +++ b/rpcs3/Emu/ARMv7/PSVFuncList.h @@ -1,7 +1,9 @@ #pragma once +#include "Emu/Memory/Memory.h" #include "ARMv7Context.h" #include "Emu/SysCalls/LogBase.h" +// PSV module class class psv_log_base : public LogBase { std::string m_name; @@ -31,385 +33,7 @@ public: }; -enum psv_error_codes -{ - SCE_OK = 0, - - SCE_ERROR_ERRNO_EPERM = 0x80010001, - SCE_ERROR_ERRNO_ENOENT = 0x80010002, - SCE_ERROR_ERRNO_ESRCH = 0x80010003, - SCE_ERROR_ERRNO_EINTR = 0x80010004, - SCE_ERROR_ERRNO_EIO = 0x80010005, - SCE_ERROR_ERRNO_ENXIO = 0x80010006, - SCE_ERROR_ERRNO_E2BIG = 0x80010007, - SCE_ERROR_ERRNO_ENOEXEC = 0x80010008, - SCE_ERROR_ERRNO_EBADF = 0x80010009, - SCE_ERROR_ERRNO_ECHILD = 0x8001000A, - SCE_ERROR_ERRNO_EAGAIN = 0x8001000B, - SCE_ERROR_ERRNO_ENOMEM = 0x8001000C, - SCE_ERROR_ERRNO_EACCES = 0x8001000D, - SCE_ERROR_ERRNO_EFAULT = 0x8001000E, - SCE_ERROR_ERRNO_ENOTBLK = 0x8001000F, - SCE_ERROR_ERRNO_EBUSY = 0x80010010, - SCE_ERROR_ERRNO_EEXIST = 0x80010011, - SCE_ERROR_ERRNO_EXDEV = 0x80010012, - SCE_ERROR_ERRNO_ENODEV = 0x80010013, - SCE_ERROR_ERRNO_ENOTDIR = 0x80010014, - SCE_ERROR_ERRNO_EISDIR = 0x80010015, - SCE_ERROR_ERRNO_EINVAL = 0x80010016, - SCE_ERROR_ERRNO_ENFILE = 0x80010017, - SCE_ERROR_ERRNO_EMFILE = 0x80010018, - SCE_ERROR_ERRNO_ENOTTY = 0x80010019, - SCE_ERROR_ERRNO_ETXTBSY = 0x8001001A, - SCE_ERROR_ERRNO_EFBIG = 0x8001001B, - SCE_ERROR_ERRNO_ENOSPC = 0x8001001C, - SCE_ERROR_ERRNO_ESPIPE = 0x8001001D, - SCE_ERROR_ERRNO_EROFS = 0x8001001E, - SCE_ERROR_ERRNO_EMLINK = 0x8001001F, - SCE_ERROR_ERRNO_EPIPE = 0x80010020, - SCE_ERROR_ERRNO_EDOM = 0x80010021, - SCE_ERROR_ERRNO_ERANGE = 0x80010022, - SCE_ERROR_ERRNO_ENOMSG = 0x80010023, - SCE_ERROR_ERRNO_EIDRM = 0x80010024, - SCE_ERROR_ERRNO_ECHRNG = 0x80010025, - SCE_ERROR_ERRNO_EL2NSYNC = 0x80010026, - SCE_ERROR_ERRNO_EL3HLT = 0x80010027, - SCE_ERROR_ERRNO_EL3RST = 0x80010028, - SCE_ERROR_ERRNO_ELNRNG = 0x80010029, - SCE_ERROR_ERRNO_EUNATCH = 0x8001002A, - SCE_ERROR_ERRNO_ENOCSI = 0x8001002B, - SCE_ERROR_ERRNO_EL2HLT = 0x8001002C, - SCE_ERROR_ERRNO_EDEADLK = 0x8001002D, - SCE_ERROR_ERRNO_ENOLCK = 0x8001002E, - SCE_ERROR_ERRNO_EFORMAT = 0x8001002F, - SCE_ERROR_ERRNO_EUNSUP = 0x80010030, - SCE_ERROR_ERRNO_EBADE = 0x80010032, - SCE_ERROR_ERRNO_EBADR = 0x80010033, - SCE_ERROR_ERRNO_EXFULL = 0x80010034, - SCE_ERROR_ERRNO_ENOANO = 0x80010035, - SCE_ERROR_ERRNO_EBADRQC = 0x80010036, - SCE_ERROR_ERRNO_EBADSLT = 0x80010037, - SCE_ERROR_ERRNO_EDEADLOCK = 0x80010038, - SCE_ERROR_ERRNO_EBFONT = 0x80010039, - SCE_ERROR_ERRNO_ENOSTR = 0x8001003C, - SCE_ERROR_ERRNO_ENODATA = 0x8001003D, - SCE_ERROR_ERRNO_ETIME = 0x8001003E, - SCE_ERROR_ERRNO_ENOSR = 0x8001003F, - SCE_ERROR_ERRNO_ENONET = 0x80010040, - SCE_ERROR_ERRNO_ENOPKG = 0x80010041, - SCE_ERROR_ERRNO_EREMOTE = 0x80010042, - SCE_ERROR_ERRNO_ENOLINK = 0x80010043, - SCE_ERROR_ERRNO_EADV = 0x80010044, - SCE_ERROR_ERRNO_ESRMNT = 0x80010045, - SCE_ERROR_ERRNO_ECOMM = 0x80010046, - SCE_ERROR_ERRNO_EPROTO = 0x80010047, - SCE_ERROR_ERRNO_EMULTIHOP = 0x8001004A, - SCE_ERROR_ERRNO_ELBIN = 0x8001004B, - SCE_ERROR_ERRNO_EDOTDOT = 0x8001004C, - SCE_ERROR_ERRNO_EBADMSG = 0x8001004D, - SCE_ERROR_ERRNO_EFTYPE = 0x8001004F, - SCE_ERROR_ERRNO_ENOTUNIQ = 0x80010050, - SCE_ERROR_ERRNO_EBADFD = 0x80010051, - SCE_ERROR_ERRNO_EREMCHG = 0x80010052, - SCE_ERROR_ERRNO_ELIBACC = 0x80010053, - SCE_ERROR_ERRNO_ELIBBAD = 0x80010054, - SCE_ERROR_ERRNO_ELIBSCN = 0x80010055, - SCE_ERROR_ERRNO_ELIBMAX = 0x80010056, - SCE_ERROR_ERRNO_ELIBEXEC = 0x80010057, - SCE_ERROR_ERRNO_ENOSYS = 0x80010058, - SCE_ERROR_ERRNO_ENMFILE = 0x80010059, - SCE_ERROR_ERRNO_ENOTEMPTY = 0x8001005A, - SCE_ERROR_ERRNO_ENAMETOOLONG = 0x8001005B, - SCE_ERROR_ERRNO_ELOOP = 0x8001005C, - SCE_ERROR_ERRNO_EOPNOTSUPP = 0x8001005F, - SCE_ERROR_ERRNO_EPFNOSUPPORT = 0x80010060, - SCE_ERROR_ERRNO_ECONNRESET = 0x80010068, - SCE_ERROR_ERRNO_ENOBUFS = 0x80010069, - SCE_ERROR_ERRNO_EAFNOSUPPORT = 0x8001006A, - SCE_ERROR_ERRNO_EPROTOTYPE = 0x8001006B, - SCE_ERROR_ERRNO_ENOTSOCK = 0x8001006C, - SCE_ERROR_ERRNO_ENOPROTOOPT = 0x8001006D, - SCE_ERROR_ERRNO_ESHUTDOWN = 0x8001006E, - SCE_ERROR_ERRNO_ECONNREFUSED = 0x8001006F, - SCE_ERROR_ERRNO_EADDRINUSE = 0x80010070, - SCE_ERROR_ERRNO_ECONNABORTED = 0x80010071, - SCE_ERROR_ERRNO_ENETUNREACH = 0x80010072, - SCE_ERROR_ERRNO_ENETDOWN = 0x80010073, - SCE_ERROR_ERRNO_ETIMEDOUT = 0x80010074, - SCE_ERROR_ERRNO_EHOSTDOWN = 0x80010075, - SCE_ERROR_ERRNO_EHOSTUNREACH = 0x80010076, - SCE_ERROR_ERRNO_EINPROGRESS = 0x80010077, - SCE_ERROR_ERRNO_EALREADY = 0x80010078, - SCE_ERROR_ERRNO_EDESTADDRREQ = 0x80010079, - SCE_ERROR_ERRNO_EMSGSIZE = 0x8001007A, - SCE_ERROR_ERRNO_EPROTONOSUPPORT = 0x8001007B, - SCE_ERROR_ERRNO_ESOCKTNOSUPPORT = 0x8001007C, - SCE_ERROR_ERRNO_EADDRNOTAVAIL = 0x8001007D, - SCE_ERROR_ERRNO_ENETRESET = 0x8001007E, - SCE_ERROR_ERRNO_EISCONN = 0x8001007F, - SCE_ERROR_ERRNO_ENOTCONN = 0x80010080, - SCE_ERROR_ERRNO_ETOOMANYREFS = 0x80010081, - SCE_ERROR_ERRNO_EPROCLIM = 0x80010082, - SCE_ERROR_ERRNO_EUSERS = 0x80010083, - SCE_ERROR_ERRNO_EDQUOT = 0x80010084, - SCE_ERROR_ERRNO_ESTALE = 0x80010085, - SCE_ERROR_ERRNO_ENOTSUP = 0x80010086, - SCE_ERROR_ERRNO_ENOMEDIUM = 0x80010087, - SCE_ERROR_ERRNO_ENOSHARE = 0x80010088, - SCE_ERROR_ERRNO_ECASECLASH = 0x80010089, - SCE_ERROR_ERRNO_EILSEQ = 0x8001008A, - SCE_ERROR_ERRNO_EOVERFLOW = 0x8001008B, - SCE_ERROR_ERRNO_ECANCELED = 0x8001008C, - SCE_ERROR_ERRNO_ENOTRECOVERABLE = 0x8001008D, - SCE_ERROR_ERRNO_EOWNERDEAD = 0x8001008E, - - SCE_KERNEL_ERROR_ERROR = 0x80020001, - SCE_KERNEL_ERROR_NOT_IMPLEMENTED = 0x80020002, - SCE_KERNEL_ERROR_INVALID_ARGUMENT = 0x80020003, - SCE_KERNEL_ERROR_INVALID_ARGUMENT_SIZE = 0x80020004, - SCE_KERNEL_ERROR_INVALID_FLAGS = 0x80020005, - SCE_KERNEL_ERROR_ILLEGAL_SIZE = 0x80020006, - SCE_KERNEL_ERROR_ILLEGAL_ADDR = 0x80020007, - SCE_KERNEL_ERROR_UNSUP = 0x80020008, - SCE_KERNEL_ERROR_ILLEGAL_MODE = 0x80020009, - SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT = 0x8002000A, - SCE_KERNEL_ERROR_NOSYS = 0x8002000B, - SCE_KERNEL_ERROR_DEBUG_ERROR = 0x80021000, - SCE_KERNEL_ERROR_ILLEGAL_DIPSW_NUMBER = 0x80021001, - SCE_KERNEL_ERROR_CPU_ERROR = 0x80022000, - SCE_KERNEL_ERROR_MMU_ILLEGAL_L1_TYPE = 0x80022001, - SCE_KERNEL_ERROR_MMU_L2_INDEX_OVERFLOW = 0x80022002, - SCE_KERNEL_ERROR_MMU_L2_SIZE_OVERFLOW = 0x80022003, - SCE_KERNEL_ERROR_INVALID_CPU_AFFINITY = 0x80022004, - SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS = 0x80022005, - SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS_PERMISSION = 0x80022006, - SCE_KERNEL_ERROR_VA2PA_FAULT = 0x80022007, - SCE_KERNEL_ERROR_VA2PA_MAPPED = 0x80022008, - SCE_KERNEL_ERROR_VALIDATION_CHECK_FAILED = 0x80022009, - SCE_KERNEL_ERROR_SYSMEM_ERROR = 0x80024000, - SCE_KERNEL_ERROR_INVALID_PROCESS_CONTEXT = 0x80024001, - SCE_KERNEL_ERROR_UID_NAME_TOO_LONG = 0x80024002, - SCE_KERNEL_ERROR_VARANGE_IS_NOT_PHYSICAL_CONTINUOUS = 0x80024003, - SCE_KERNEL_ERROR_PHYADDR_ERROR = 0x80024100, - SCE_KERNEL_ERROR_NO_PHYADDR = 0x80024101, - SCE_KERNEL_ERROR_PHYADDR_USED = 0x80024102, - SCE_KERNEL_ERROR_PHYADDR_NOT_USED = 0x80024103, - SCE_KERNEL_ERROR_NO_IOADDR = 0x80024104, - SCE_KERNEL_ERROR_PHYMEM_ERROR = 0x80024300, - SCE_KERNEL_ERROR_ILLEGAL_PHYPAGE_STATUS = 0x80024301, - SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE = 0x80024302, - SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE_UNIT = 0x80024303, - SCE_KERNEL_ERROR_PHYMEMPART_NOT_EMPTY = 0x80024304, - SCE_KERNEL_ERROR_NO_PHYMEMPART_LPDDR2 = 0x80024305, - SCE_KERNEL_ERROR_NO_PHYMEMPART_CDRAM = 0x80024306, - SCE_KERNEL_ERROR_FIXEDHEAP_ERROR = 0x80024400, - SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_SIZE = 0x80024401, - SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_INDEX = 0x80024402, - SCE_KERNEL_ERROR_FIXEDHEAP_INDEX_OVERFLOW = 0x80024403, - SCE_KERNEL_ERROR_FIXEDHEAP_NO_CHUNK = 0x80024404, - SCE_KERNEL_ERROR_UID_ERROR = 0x80024500, - SCE_KERNEL_ERROR_INVALID_UID = 0x80024501, - SCE_KERNEL_ERROR_SYSMEM_UID_INVALID_ARGUMENT = 0x80024502, - SCE_KERNEL_ERROR_SYSMEM_INVALID_UID_RANGE = 0x80024503, - SCE_KERNEL_ERROR_SYSMEM_NO_VALID_UID = 0x80024504, - SCE_KERNEL_ERROR_SYSMEM_CANNOT_ALLOCATE_UIDENTRY = 0x80024505, - SCE_KERNEL_ERROR_NOT_PROCESS_UID = 0x80024506, - SCE_KERNEL_ERROR_NOT_KERNEL_UID = 0x80024507, - SCE_KERNEL_ERROR_INVALID_UID_CLASS = 0x80024508, - SCE_KERNEL_ERROR_INVALID_UID_SUBCLASS = 0x80024509, - SCE_KERNEL_ERROR_UID_CANNOT_FIND_BY_NAME = 0x8002450A, - SCE_KERNEL_ERROR_VIRPAGE_ERROR = 0x80024600, - SCE_KERNEL_ERROR_ILLEGAL_VIRPAGE_TYPE = 0x80024601, - SCE_KERNEL_ERROR_BLOCK_ERROR = 0x80024700, - SCE_KERNEL_ERROR_ILLEGAL_BLOCK_ID = 0x80024701, - SCE_KERNEL_ERROR_ILLEGAL_BLOCK_TYPE = 0x80024702, - SCE_KERNEL_ERROR_BLOCK_IN_USE = 0x80024703, - SCE_KERNEL_ERROR_PARTITION_ERROR = 0x80024800, - SCE_KERNEL_ERROR_ILLEGAL_PARTITION_ID = 0x80024801, - SCE_KERNEL_ERROR_ILLEGAL_PARTITION_INDEX = 0x80024802, - SCE_KERNEL_ERROR_NO_L2PAGETABLE = 0x80024803, - SCE_KERNEL_ERROR_HEAPLIB_ERROR = 0x80024900, - SCE_KERNEL_ERROR_ILLEGAL_HEAP_ID = 0x80024901, - SCE_KERNEL_ERROR_OUT_OF_RANG = 0x80024902, - SCE_KERNEL_ERROR_HEAPLIB_NOMEM = 0x80024903, - SCE_KERNEL_ERROR_SYSMEM_ADDRESS_SPACE_ERROR = 0x80024A00, - SCE_KERNEL_ERROR_INVALID_ADDRESS_SPACE_ID = 0x80024A01, - SCE_KERNEL_ERROR_INVALID_PARTITION_INDEX = 0x80024A02, - SCE_KERNEL_ERROR_ADDRESS_SPACE_CANNOT_FIND_PARTITION_BY_ADDR = 0x80024A03, - SCE_KERNEL_ERROR_SYSMEM_MEMBLOCK_ERROR = 0x80024B00, - SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_TYPE = 0x80024B01, - SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_REMAP_TYPE = 0x80024B02, - SCE_KERNEL_ERROR_NOT_PHY_CONT_MEMBLOCK = 0x80024B03, - SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_CODE = 0x80024B04, - SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_SIZE = 0x80024B05, - SCE_KERNEL_ERROR_ILLEGAL_USERMAP_SIZE = 0x80024B06, - SCE_KERNEL_ERROR_MEMBLOCK_TYPE_FOR_KERNEL_PROCESS = 0x80024B07, - SCE_KERNEL_ERROR_PROCESS_CANNOT_REMAP_MEMBLOCK = 0x80024B08, - SCE_KERNEL_ERROR_SYSMEM_PHYMEMLOW_ERROR = 0x80024C00, - SCE_KERNEL_ERROR_CANNOT_ALLOC_PHYMEMLOW = 0x80024C01, - SCE_KERNEL_ERROR_UNKNOWN_PHYMEMLOW_TYPE = 0x80024C02, - SCE_KERNEL_ERROR_SYSMEM_BITHEAP_ERROR = 0x80024D00, - SCE_KERNEL_ERROR_CANNOT_ALLOC_BITHEAP = 0x80024D01, - SCE_KERNEL_ERROR_LOADCORE_ERROR = 0x80025000, - SCE_KERNEL_ERROR_ILLEGAL_ELF_HEADER = 0x80025001, - SCE_KERNEL_ERROR_ILLEGAL_SELF_HEADER = 0x80025002, - SCE_KERNEL_ERROR_EXCPMGR_ERROR = 0x80027000, - SCE_KERNEL_ERROR_ILLEGAL_EXCPCODE = 0x80027001, - SCE_KERNEL_ERROR_ILLEGAL_EXCPHANDLER = 0x80027002, - SCE_KERNEL_ERROR_NOTFOUND_EXCPHANDLER = 0x80027003, - SCE_KERNEL_ERROR_CANNOT_RELEASE_EXCPHANDLER = 0x80027004, - SCE_KERNEL_ERROR_INTRMGR_ERROR = 0x80027100, - SCE_KERNEL_ERROR_ILLEGAL_CONTEXT = 0x80027101, - SCE_KERNEL_ERROR_ILLEGAL_INTRCODE = 0x80027102, - SCE_KERNEL_ERROR_ILLEGAL_INTRPARAM = 0x80027103, - SCE_KERNEL_ERROR_ILLEGAL_INTRPRIORITY = 0x80027104, - SCE_KERNEL_ERROR_ILLEGAL_TARGET_CPU = 0x80027105, - SCE_KERNEL_ERROR_ILLEGAL_INTRFILTER = 0x80027106, - SCE_KERNEL_ERROR_ILLEGAL_INTRTYPE = 0x80027107, - SCE_KERNEL_ERROR_ILLEGAL_HANDLER = 0x80027108, - SCE_KERNEL_ERROR_FOUND_HANDLER = 0x80027109, - SCE_KERNEL_ERROR_NOTFOUND_HANDLER = 0x8002710A, - SCE_KERNEL_ERROR_NO_MEMORY = 0x8002710B, - SCE_KERNEL_ERROR_DMACMGR_ERROR = 0x80027200, - SCE_KERNEL_ERROR_ALREADY_QUEUED = 0x80027201, - SCE_KERNEL_ERROR_NOT_QUEUED = 0x80027202, - SCE_KERNEL_ERROR_NOT_SETUP = 0x80027203, - SCE_KERNEL_ERROR_ON_TRANSFERRING = 0x80027204, - SCE_KERNEL_ERROR_NOT_INITIALIZED = 0x80027205, - SCE_KERNEL_ERROR_TRANSFERRED = 0x80027206, - SCE_KERNEL_ERROR_NOT_UNDER_CONTROL = 0x80027207, - SCE_KERNEL_ERROR_SYSTIMER_ERROR = 0x80027300, - SCE_KERNEL_ERROR_NO_FREE_TIMER = 0x80027301, - SCE_KERNEL_ERROR_TIMER_NOT_ALLOCATED = 0x80027302, - SCE_KERNEL_ERROR_TIMER_COUNTING = 0x80027303, - SCE_KERNEL_ERROR_TIMER_STOPPED = 0x80027304, - SCE_KERNEL_ERROR_THREADMGR_ERROR = 0x80028000, - SCE_KERNEL_ERROR_DORMANT = 0x80028001, - SCE_KERNEL_ERROR_NOT_DORMANT = 0x80028002, - SCE_KERNEL_ERROR_UNKNOWN_THID = 0x80028003, - SCE_KERNEL_ERROR_CAN_NOT_WAIT = 0x80028004, - SCE_KERNEL_ERROR_ILLEGAL_THID = 0x80028005, - SCE_KERNEL_ERROR_THREAD_TERMINATED = 0x80028006, - SCE_KERNEL_ERROR_DELETED = 0x80028007, - SCE_KERNEL_ERROR_WAIT_TIMEOUT = 0x80028008, - SCE_KERNEL_ERROR_NOTIFY_CALLBACK = 0x80028009, - SCE_KERNEL_ERROR_WAIT_DELETE = 0x8002800A, - SCE_KERNEL_ERROR_ILLEGAL_ATTR = 0x8002800B, - SCE_KERNEL_ERROR_EVF_MULTI = 0x8002800C, - SCE_KERNEL_ERROR_WAIT_CANCEL = 0x8002800D, - SCE_KERNEL_ERROR_EVF_COND = 0x8002800E, - SCE_KERNEL_ERROR_ILLEGAL_COUNT = 0x8002800F, - SCE_KERNEL_ERROR_ILLEGAL_PRIORITY = 0x80028010, - SCE_KERNEL_ERROR_MUTEX_RECURSIVE = 0x80028011, - SCE_KERNEL_ERROR_MUTEX_LOCK_OVF = 0x80028012, - SCE_KERNEL_ERROR_MUTEX_NOT_OWNED = 0x80028013, - SCE_KERNEL_ERROR_MUTEX_UNLOCK_UDF = 0x80028014, - SCE_KERNEL_ERROR_MUTEX_FAILED_TO_OWN = 0x80028015, - SCE_KERNEL_ERROR_FAST_MUTEX_RECURSIVE = 0x80028016, - SCE_KERNEL_ERROR_FAST_MUTEX_LOCK_OVF = 0x80028017, - SCE_KERNEL_ERROR_FAST_MUTEX_FAILED_TO_OWN = 0x80028018, - SCE_KERNEL_ERROR_FAST_MUTEX_NOT_OWNED = 0x80028019, - SCE_KERNEL_ERROR_FAST_MUTEX_OWNED = 0x8002801A, - SCE_KERNEL_ERROR_ALARM_CAN_NOT_CANCEL = 0x8002801B, - SCE_KERNEL_ERROR_INVALID_OBJECT_TYPE = 0x8002801C, - SCE_KERNEL_ERROR_KERNEL_TLS_FULL = 0x8002801D, - SCE_KERNEL_ERROR_ILLEGAL_KERNEL_TLS_INDEX = 0x8002801E, - SCE_KERNEL_ERROR_KERNEL_TLS_BUSY = 0x8002801F, - SCE_KERNEL_ERROR_DIFFERENT_UID_CLASS = 0x80028020, - SCE_KERNEL_ERROR_UNKNOWN_UID = 0x80028021, - SCE_KERNEL_ERROR_SEMA_ZERO = 0x80028022, - SCE_KERNEL_ERROR_SEMA_OVF = 0x80028023, - SCE_KERNEL_ERROR_PMON_NOT_THREAD_MODE = 0x80028024, - SCE_KERNEL_ERROR_PMON_NOT_CPU_MODE = 0x80028025, - SCE_KERNEL_ERROR_ALREADY_REGISTERED = 0x80028026, - SCE_KERNEL_ERROR_INVALID_THREAD_ID = 0x80028027, - SCE_KERNEL_ERROR_ALREADY_DEBUG_SUSPENDED = 0x80028028, - SCE_KERNEL_ERROR_NOT_DEBUG_SUSPENDED = 0x80028029, - SCE_KERNEL_ERROR_CAN_NOT_USE_VFP = 0x8002802A, - SCE_KERNEL_ERROR_RUNNING = 0x8002802B, - SCE_KERNEL_ERROR_EVENT_COND = 0x8002802C, - SCE_KERNEL_ERROR_MSG_PIPE_FULL = 0x8002802D, - SCE_KERNEL_ERROR_MSG_PIPE_EMPTY = 0x8002802E, - SCE_KERNEL_ERROR_ALREADY_SENT = 0x8002802F, - SCE_KERNEL_ERROR_CAN_NOT_SUSPEND = 0x80028030, - SCE_KERNEL_ERROR_FAST_MUTEX_ALREADY_INITIALIZED = 0x80028031, - SCE_KERNEL_ERROR_FAST_MUTEX_NOT_INITIALIZED = 0x80028032, - SCE_KERNEL_ERROR_THREAD_STOPPED = 0x80028033, - SCE_KERNEL_ERROR_THREAD_SUSPENDED = 0x80028034, - SCE_KERNEL_ERROR_NOT_SUSPENDED = 0x80028035, - SCE_KERNEL_ERROR_WAIT_DELETE_MUTEX = 0x80028036, - SCE_KERNEL_ERROR_WAIT_CANCEL_MUTEX = 0x80028037, - SCE_KERNEL_ERROR_WAIT_DELETE_COND = 0x80028038, - SCE_KERNEL_ERROR_WAIT_CANCEL_COND = 0x80028039, - SCE_KERNEL_ERROR_LW_MUTEX_NOT_OWNED = 0x8002803A, - SCE_KERNEL_ERROR_LW_MUTEX_LOCK_OVF = 0x8002803B, - SCE_KERNEL_ERROR_LW_MUTEX_UNLOCK_UDF = 0x8002803C, - SCE_KERNEL_ERROR_LW_MUTEX_RECURSIVE = 0x8002803D, - SCE_KERNEL_ERROR_LW_MUTEX_FAILED_TO_OWN = 0x8002803E, - SCE_KERNEL_ERROR_WAIT_DELETE_LW_MUTEX = 0x8002803F, - SCE_KERNEL_ERROR_ILLEGAL_STACK_SIZE = 0x80028040, - SCE_KERNEL_ERROR_RW_LOCK_RECURSIVE = 0x80028041, - SCE_KERNEL_ERROR_RW_LOCK_LOCK_OVF = 0x80028042, - SCE_KERNEL_ERROR_RW_LOCK_NOT_OWNED = 0x80028043, - SCE_KERNEL_ERROR_RW_LOCK_UNLOCK_UDF = 0x80028044, - SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_LOCK = 0x80028045, - SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_UNLOCK = 0x80028046, - - SCE_KERNEL_ERROR_PROCESSMGR_ERROR = 0x80029000, - SCE_KERNEL_ERROR_INVALID_PID = 0x80029001, - SCE_KERNEL_ERROR_INVALID_PROCESS_TYPE = 0x80029002, - SCE_KERNEL_ERROR_PLS_FULL = 0x80029003, - SCE_KERNEL_ERROR_INVALID_PROCESS_STATUS = 0x80029004, - SCE_KERNEL_ERROR_INVALID_BUDGET_ID = 0x80029005, - SCE_KERNEL_ERROR_INVALID_BUDGET_SIZE = 0x80029006, - SCE_KERNEL_ERROR_CP14_DISABLED = 0x80029007, - SCE_KERNEL_ERROR_EXCEEDED_MAX_PROCESSES = 0x80029008, - SCE_KERNEL_ERROR_PROCESS_REMAINING = 0x80029009, - SCE_KERNEL_ERROR_IOFILEMGR_ERROR = 0x8002A000, - SCE_KERNEL_ERROR_IO_NAME_TOO_LONG = 0x8002A001, - SCE_KERNEL_ERROR_IO_REG_DEV = 0x8002A002, - SCE_KERNEL_ERROR_IO_ALIAS_USED = 0x8002A003, - SCE_KERNEL_ERROR_IO_DEL_DEV = 0x8002A004, - SCE_KERNEL_ERROR_IO_WOULD_BLOCK = 0x8002A005, - SCE_KERNEL_ERROR_MODULEMGR_START_FAILED = 0x8002D000, - SCE_KERNEL_ERROR_MODULEMGR_STOP_FAIL = 0x8002D001, - SCE_KERNEL_ERROR_MODULEMGR_IN_USE = 0x8002D002, - SCE_KERNEL_ERROR_MODULEMGR_NO_LIB = 0x8002D003, - SCE_KERNEL_ERROR_MODULEMGR_SYSCALL_REG = 0x8002D004, - SCE_KERNEL_ERROR_MODULEMGR_NOMEM_LIB = 0x8002D005, - SCE_KERNEL_ERROR_MODULEMGR_NOMEM_STUB = 0x8002D006, - SCE_KERNEL_ERROR_MODULEMGR_NOMEM_SELF = 0x8002D007, - SCE_KERNEL_ERROR_MODULEMGR_NOMEM = 0x8002D008, - SCE_KERNEL_ERROR_MODULEMGR_INVALID_LIB = 0x8002D009, - SCE_KERNEL_ERROR_MODULEMGR_INVALID_STUB = 0x8002D00A, - SCE_KERNEL_ERROR_MODULEMGR_NO_FUNC_NID = 0x8002D00B, - SCE_KERNEL_ERROR_MODULEMGR_NO_VAR_NID = 0x8002D00C, - SCE_KERNEL_ERROR_MODULEMGR_INVALID_TYPE = 0x8002D00D, - SCE_KERNEL_ERROR_MODULEMGR_NO_MOD_ENTRY = 0x8002D00E, - SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROC_PARAM = 0x8002D00F, - SCE_KERNEL_ERROR_MODULEMGR_NO_MODOBJ = 0x8002D010, - SCE_KERNEL_ERROR_MODULEMGR_NO_MOD = 0x8002D011, - SCE_KERNEL_ERROR_MODULEMGR_NO_PROCESS = 0x8002D012, - SCE_KERNEL_ERROR_MODULEMGR_OLD_LIB = 0x8002D013, - SCE_KERNEL_ERROR_MODULEMGR_STARTED = 0x8002D014, - SCE_KERNEL_ERROR_MODULEMGR_NOT_STARTED = 0x8002D015, - SCE_KERNEL_ERROR_MODULEMGR_NOT_STOPPED = 0x8002D016, - SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROCESS_UID = 0x8002D017, - SCE_KERNEL_ERROR_MODULEMGR_CANNOT_EXPORT_LIB_TO_SHARED = 0x8002D018, - SCE_KERNEL_ERROR_MODULEMGR_INVALID_REL_INFO = 0x8002D019, - SCE_KERNEL_ERROR_MODULEMGR_INVALID_REF_INFO = 0x8002D01A, - SCE_KERNEL_ERROR_MODULEMGR_ELINK = 0x8002D01B, - SCE_KERNEL_ERROR_MODULEMGR_NOENT = 0x8002D01C, - SCE_KERNEL_ERROR_MODULEMGR_BUSY = 0x8002D01D, - SCE_KERNEL_ERROR_MODULEMGR_NOEXEC = 0x8002D01E, - SCE_KERNEL_ERROR_MODULEMGR_NAMETOOLONG = 0x8002D01F, - SCE_KERNEL_ERROR_LIBRARYDB_NOENT = 0x8002D080, - SCE_KERNEL_ERROR_LIBRARYDB_NO_LIB = 0x8002D081, - SCE_KERNEL_ERROR_LIBRARYDB_NO_MOD = 0x8002D082, - SCE_KERNEL_ERROR_AUTHFAIL = 0x8002F000, - SCE_KERNEL_ERROR_NO_AUTH = 0x8002F001, -}; - +// Abstract HLE function caller base class class psv_func_caller { public: @@ -417,6 +41,7 @@ public: virtual ~psv_func_caller(){}; }; +// Utilities for binding ARMv7Context to C++ function arguments received by HLE functions or sent to callbacks namespace psv_func_detail { enum bind_arg_type @@ -448,6 +73,39 @@ namespace psv_func_detail } }; + template + struct bind_arg + { + // first u64 argument is passed in r0-r1, second one is passed in r2-r3 (if g_count = 3) + static_assert(g_count == 1 || g_count == 3, "Wrong u64 argument position"); + + __forceinline static u64 get_arg(ARMv7Context& context) + { + return context.GPR_D[g_count >> 1]; + } + + __forceinline static void put_arg(ARMv7Context& context, u64 arg) + { + context.GPR_D[g_count >> 1] = arg; + } + }; + + template + struct bind_arg + { + static_assert(g_count == 1 || g_count == 3, "Wrong s64 argument position"); + + __forceinline static s64 get_arg(ARMv7Context& context) + { + return context.GPR_D[g_count >> 1]; + } + + __forceinline static void put_arg(ARMv7Context& context, s64 arg) + { + context.GPR_D[g_count >> 1] = arg; + } + }; + template struct bind_arg { @@ -488,7 +146,7 @@ namespace psv_func_detail __forceinline static T get_arg(ARMv7Context& context) { // TODO: check - return cast_from_armv7_gpr(context.get_stack_arg(g_count)); + return cast_from_armv7_gpr(vm::psv::read32(context.SP + sizeof(u32) * (g_count - 5))); } __forceinline static void put_arg(ARMv7Context& context, const T& arg) @@ -497,7 +155,45 @@ namespace psv_func_detail const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; static_assert(stack_pos < 0, "TODO: Increase fixed stack frame size (arg count limit broken)"); - context.put_stack_arg(stack_pos, cast_to_armv7_gpr(arg)); + vm::psv::write32(context.SP + stack_pos, cast_to_armv7_gpr(arg)); + } + }; + + template + struct bind_arg + { + __forceinline static u64 get_arg(ARMv7Context& context) + { + // TODO: check + return vm::psv::read64(context.SP + sizeof(u32) * (g_count - 5)); + } + + __forceinline static void put_arg(ARMv7Context& context, u64 arg) + { + // TODO: check + const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; + static_assert(stack_pos < -4, "TODO: Increase fixed stack frame size (arg count limit broken)"); + + vm::psv::write64(context.SP + stack_pos, arg); + } + }; + + template + struct bind_arg + { + __forceinline static s64 get_arg(ARMv7Context& context) + { + // TODO: check + return vm::psv::read64(context.SP + sizeof(u32) * (g_count - 5)); + } + + __forceinline static void put_arg(ARMv7Context& context, s64 arg) + { + // TODO: check + const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; + static_assert(stack_pos < -4, "TODO: Increase fixed stack frame size (arg count limit broken)"); + + vm::psv::write64(context.SP + stack_pos, arg); } }; @@ -520,6 +216,34 @@ namespace psv_func_detail } }; + template<> + struct bind_result + { + __forceinline static u64 get_result(ARMv7Context& context) + { + return context.GPR_D[0]; + } + + __forceinline static void put_result(ARMv7Context& context, u64 result) + { + context.GPR_D[0] = result; + } + }; + + template<> + struct bind_result + { + __forceinline static s64 get_result(ARMv7Context& context) + { + return context.GPR_D[0]; + } + + __forceinline static void put_result(ARMv7Context& context, s64 result) + { + context.GPR_D[0] = result; + } + }; + //template //struct bind_result //{ @@ -558,12 +282,14 @@ namespace psv_func_detail // TODO: check calculations static const bool is_float = std::is_floating_point::value; static const bool is_vector = std::is_same::value; + static const int g_align = __alignof(T) > 4 ? __alignof(T) >> 2 : 1; + static const int g_pos = (is_float || is_vector) ? g_count : ((g_count + (g_align - 1)) & ~(g_align - 1)) + 1; + static const int g_next = g_pos + g_align - 1; + static const int f_value = !is_float ? f_count : f_count + 1; + static const int v_value = !is_vector ? v_count : v_count + 1; static const bind_arg_type value = is_float - ? ((f_count >= 4) ? ARG_STACK : ARG_FLOAT) - : (is_vector ? ((v_count >= 4) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 4) ? ARG_STACK : ARG_GENERAL)); - static const int g_value = g_count + (is_float || is_vector ? 0 : 1); - static const int f_value = f_count + (is_float ? 1 : 0); - static const int v_value = v_count + (is_vector ? 1 : 0); + ? ((f_value > 9000) ? ARG_STACK : ARG_FLOAT) + : (is_vector ? ((v_value > 9000) ? ARG_STACK : ARG_VECTOR) : ((g_pos > 4) ? ARG_STACK : ARG_GENERAL)); }; template @@ -603,11 +329,12 @@ namespace psv_func_detail { typedef arg_type type; const bind_arg_type t = type::value; - const int g = type::g_value; + const int g0 = type::g_pos; + const int g1 = type::g_next; const int f = type::f_value; const int v = type::v_value; - return std::tuple_cat(std::tuple(bind_arg::get_arg(context)), get_func_args(context)); + return std::tuple_cat(std::tuple(bind_arg::get_arg(context)), get_func_args(context)); } template @@ -622,14 +349,15 @@ namespace psv_func_detail { typedef arg_type type; const bind_arg_type t = type::value; - const int g = type::g_value; + const int g0 = type::g_pos; + const int g1 = type::g_next; const int f = type::f_value; const int v = type::v_value; - bind_arg::put_arg(context, arg); + bind_arg::put_arg(context, arg); // return true if stack was used - return put_func_args(context, args...) || (t == ARG_STACK); + return put_func_args(context, args...) || (t == ARG_STACK); } template @@ -741,18 +469,19 @@ namespace psv_func_detail }; } +// Basic information about the HLE function struct psv_func { - u32 nid; - const char* name; - std::shared_ptr func; - psv_log_base* module; + u32 nid; // Unique function ID only for old PSV executables (should be generated individually for each elf loaded) + const char* name; // Function name for information + std::shared_ptr func; // Function caller instance + psv_log_base* module; // Module for information }; +// Do not call directly void add_psv_func(psv_func& data); - -template -void reg_psv_func(u32 nid, psv_log_base* module, const char* name, RT(*func)(T...)) +// Do not call directly +template void reg_psv_func(u32 nid, psv_log_base* module, const char* name, RT(*func)(T...)) { psv_func f; f.nid = nid; @@ -762,10 +491,159 @@ void reg_psv_func(u32 nid, psv_log_base* module, const char* name, RT(*func)(T.. add_psv_func(f); } - +// Find registered HLE function by its ID psv_func* get_psv_func_by_nid(u32 nid); +// Get index of registered HLE function u32 get_psv_func_index(psv_func* func); - +// Execute registered HLE function by its index void execute_psv_func_by_index(ARMv7Context& context, u32 index); +// Register all HLE functions void initialize_psv_modules(); +// Unregister all HLE functions void finalize_psv_modules(); + +// General definitions + +enum psv_error_codes +{ + SCE_OK = 0, + + SCE_ERROR_ERRNO_EPERM = 0x80010001, + SCE_ERROR_ERRNO_ENOENT = 0x80010002, + SCE_ERROR_ERRNO_ESRCH = 0x80010003, + SCE_ERROR_ERRNO_EINTR = 0x80010004, + SCE_ERROR_ERRNO_EIO = 0x80010005, + SCE_ERROR_ERRNO_ENXIO = 0x80010006, + SCE_ERROR_ERRNO_E2BIG = 0x80010007, + SCE_ERROR_ERRNO_ENOEXEC = 0x80010008, + SCE_ERROR_ERRNO_EBADF = 0x80010009, + SCE_ERROR_ERRNO_ECHILD = 0x8001000A, + SCE_ERROR_ERRNO_EAGAIN = 0x8001000B, + SCE_ERROR_ERRNO_ENOMEM = 0x8001000C, + SCE_ERROR_ERRNO_EACCES = 0x8001000D, + SCE_ERROR_ERRNO_EFAULT = 0x8001000E, + SCE_ERROR_ERRNO_ENOTBLK = 0x8001000F, + SCE_ERROR_ERRNO_EBUSY = 0x80010010, + SCE_ERROR_ERRNO_EEXIST = 0x80010011, + SCE_ERROR_ERRNO_EXDEV = 0x80010012, + SCE_ERROR_ERRNO_ENODEV = 0x80010013, + SCE_ERROR_ERRNO_ENOTDIR = 0x80010014, + SCE_ERROR_ERRNO_EISDIR = 0x80010015, + SCE_ERROR_ERRNO_EINVAL = 0x80010016, + SCE_ERROR_ERRNO_ENFILE = 0x80010017, + SCE_ERROR_ERRNO_EMFILE = 0x80010018, + SCE_ERROR_ERRNO_ENOTTY = 0x80010019, + SCE_ERROR_ERRNO_ETXTBSY = 0x8001001A, + SCE_ERROR_ERRNO_EFBIG = 0x8001001B, + SCE_ERROR_ERRNO_ENOSPC = 0x8001001C, + SCE_ERROR_ERRNO_ESPIPE = 0x8001001D, + SCE_ERROR_ERRNO_EROFS = 0x8001001E, + SCE_ERROR_ERRNO_EMLINK = 0x8001001F, + SCE_ERROR_ERRNO_EPIPE = 0x80010020, + SCE_ERROR_ERRNO_EDOM = 0x80010021, + SCE_ERROR_ERRNO_ERANGE = 0x80010022, + SCE_ERROR_ERRNO_ENOMSG = 0x80010023, + SCE_ERROR_ERRNO_EIDRM = 0x80010024, + SCE_ERROR_ERRNO_ECHRNG = 0x80010025, + SCE_ERROR_ERRNO_EL2NSYNC = 0x80010026, + SCE_ERROR_ERRNO_EL3HLT = 0x80010027, + SCE_ERROR_ERRNO_EL3RST = 0x80010028, + SCE_ERROR_ERRNO_ELNRNG = 0x80010029, + SCE_ERROR_ERRNO_EUNATCH = 0x8001002A, + SCE_ERROR_ERRNO_ENOCSI = 0x8001002B, + SCE_ERROR_ERRNO_EL2HLT = 0x8001002C, + SCE_ERROR_ERRNO_EDEADLK = 0x8001002D, + SCE_ERROR_ERRNO_ENOLCK = 0x8001002E, + SCE_ERROR_ERRNO_EFORMAT = 0x8001002F, + SCE_ERROR_ERRNO_EUNSUP = 0x80010030, + SCE_ERROR_ERRNO_EBADE = 0x80010032, + SCE_ERROR_ERRNO_EBADR = 0x80010033, + SCE_ERROR_ERRNO_EXFULL = 0x80010034, + SCE_ERROR_ERRNO_ENOANO = 0x80010035, + SCE_ERROR_ERRNO_EBADRQC = 0x80010036, + SCE_ERROR_ERRNO_EBADSLT = 0x80010037, + SCE_ERROR_ERRNO_EDEADLOCK = 0x80010038, + SCE_ERROR_ERRNO_EBFONT = 0x80010039, + SCE_ERROR_ERRNO_ENOSTR = 0x8001003C, + SCE_ERROR_ERRNO_ENODATA = 0x8001003D, + SCE_ERROR_ERRNO_ETIME = 0x8001003E, + SCE_ERROR_ERRNO_ENOSR = 0x8001003F, + SCE_ERROR_ERRNO_ENONET = 0x80010040, + SCE_ERROR_ERRNO_ENOPKG = 0x80010041, + SCE_ERROR_ERRNO_EREMOTE = 0x80010042, + SCE_ERROR_ERRNO_ENOLINK = 0x80010043, + SCE_ERROR_ERRNO_EADV = 0x80010044, + SCE_ERROR_ERRNO_ESRMNT = 0x80010045, + SCE_ERROR_ERRNO_ECOMM = 0x80010046, + SCE_ERROR_ERRNO_EPROTO = 0x80010047, + SCE_ERROR_ERRNO_EMULTIHOP = 0x8001004A, + SCE_ERROR_ERRNO_ELBIN = 0x8001004B, + SCE_ERROR_ERRNO_EDOTDOT = 0x8001004C, + SCE_ERROR_ERRNO_EBADMSG = 0x8001004D, + SCE_ERROR_ERRNO_EFTYPE = 0x8001004F, + SCE_ERROR_ERRNO_ENOTUNIQ = 0x80010050, + SCE_ERROR_ERRNO_EBADFD = 0x80010051, + SCE_ERROR_ERRNO_EREMCHG = 0x80010052, + SCE_ERROR_ERRNO_ELIBACC = 0x80010053, + SCE_ERROR_ERRNO_ELIBBAD = 0x80010054, + SCE_ERROR_ERRNO_ELIBSCN = 0x80010055, + SCE_ERROR_ERRNO_ELIBMAX = 0x80010056, + SCE_ERROR_ERRNO_ELIBEXEC = 0x80010057, + SCE_ERROR_ERRNO_ENOSYS = 0x80010058, + SCE_ERROR_ERRNO_ENMFILE = 0x80010059, + SCE_ERROR_ERRNO_ENOTEMPTY = 0x8001005A, + SCE_ERROR_ERRNO_ENAMETOOLONG = 0x8001005B, + SCE_ERROR_ERRNO_ELOOP = 0x8001005C, + SCE_ERROR_ERRNO_EOPNOTSUPP = 0x8001005F, + SCE_ERROR_ERRNO_EPFNOSUPPORT = 0x80010060, + SCE_ERROR_ERRNO_ECONNRESET = 0x80010068, + SCE_ERROR_ERRNO_ENOBUFS = 0x80010069, + SCE_ERROR_ERRNO_EAFNOSUPPORT = 0x8001006A, + SCE_ERROR_ERRNO_EPROTOTYPE = 0x8001006B, + SCE_ERROR_ERRNO_ENOTSOCK = 0x8001006C, + SCE_ERROR_ERRNO_ENOPROTOOPT = 0x8001006D, + SCE_ERROR_ERRNO_ESHUTDOWN = 0x8001006E, + SCE_ERROR_ERRNO_ECONNREFUSED = 0x8001006F, + SCE_ERROR_ERRNO_EADDRINUSE = 0x80010070, + SCE_ERROR_ERRNO_ECONNABORTED = 0x80010071, + SCE_ERROR_ERRNO_ENETUNREACH = 0x80010072, + SCE_ERROR_ERRNO_ENETDOWN = 0x80010073, + SCE_ERROR_ERRNO_ETIMEDOUT = 0x80010074, + SCE_ERROR_ERRNO_EHOSTDOWN = 0x80010075, + SCE_ERROR_ERRNO_EHOSTUNREACH = 0x80010076, + SCE_ERROR_ERRNO_EINPROGRESS = 0x80010077, + SCE_ERROR_ERRNO_EALREADY = 0x80010078, + SCE_ERROR_ERRNO_EDESTADDRREQ = 0x80010079, + SCE_ERROR_ERRNO_EMSGSIZE = 0x8001007A, + SCE_ERROR_ERRNO_EPROTONOSUPPORT = 0x8001007B, + SCE_ERROR_ERRNO_ESOCKTNOSUPPORT = 0x8001007C, + SCE_ERROR_ERRNO_EADDRNOTAVAIL = 0x8001007D, + SCE_ERROR_ERRNO_ENETRESET = 0x8001007E, + SCE_ERROR_ERRNO_EISCONN = 0x8001007F, + SCE_ERROR_ERRNO_ENOTCONN = 0x80010080, + SCE_ERROR_ERRNO_ETOOMANYREFS = 0x80010081, + SCE_ERROR_ERRNO_EPROCLIM = 0x80010082, + SCE_ERROR_ERRNO_EUSERS = 0x80010083, + SCE_ERROR_ERRNO_EDQUOT = 0x80010084, + SCE_ERROR_ERRNO_ESTALE = 0x80010085, + SCE_ERROR_ERRNO_ENOTSUP = 0x80010086, + SCE_ERROR_ERRNO_ENOMEDIUM = 0x80010087, + SCE_ERROR_ERRNO_ENOSHARE = 0x80010088, + SCE_ERROR_ERRNO_ECASECLASH = 0x80010089, + SCE_ERROR_ERRNO_EILSEQ = 0x8001008A, + SCE_ERROR_ERRNO_EOVERFLOW = 0x8001008B, + SCE_ERROR_ERRNO_ECANCELED = 0x8001008C, + SCE_ERROR_ERRNO_ENOTRECOVERABLE = 0x8001008D, + SCE_ERROR_ERRNO_EOWNERDEAD = 0x8001008E, +}; + +struct SceDateTime +{ + u16 year; + u16 month; + u16 day; + u16 hour; + u16 minute; + u16 second; + u32 microsecond; +}; diff --git a/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.cpp b/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.cpp index e8155b89a3..adcb26a2a6 100644 --- a/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.cpp +++ b/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.cpp @@ -15,7 +15,7 @@ void XAudio2Thread::Init() { HRESULT hr = S_OK; -#if (_WIN32_WINNT < 0x0602) +#if (FORCED_WINVER < 0x0602) hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); if (FAILED(hr)) { @@ -53,7 +53,7 @@ void XAudio2Thread::Quit() m_xaudio2_instance->Release(); m_xaudio2_instance = nullptr; -#if (_WIN32_WINNT < 0x0602) +#if (FORCED_WINVER < 0x0602) CoUninitialize(); #endif } diff --git a/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.h b/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.h index 3a362714ad..3771f7bd3e 100644 --- a/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.h +++ b/rpcs3/Emu/Audio/XAudio2/XAudio2Thread.h @@ -4,10 +4,9 @@ #if defined (_WIN32) // forced define Win7, delete this for using XAudio2 2.8 -#define WINVER 0x0601 -#define _WIN32_WINNT 0x0601 +#define FORCED_WINVER 0x0601 -#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) +#if (FORCED_WINVER >= 0x0602 /*_WIN32_WINNT_WIN8*/) #include #pragma comment(lib,"xaudio2.lib") #else diff --git a/rpcs3/Emu/CPU/CPUDecoder.h b/rpcs3/Emu/CPU/CPUDecoder.h index 0a0aea1e0c..68f21cf542 100644 --- a/rpcs3/Emu/CPU/CPUDecoder.h +++ b/rpcs3/Emu/CPU/CPUDecoder.h @@ -1,6 +1,5 @@ #pragma once #include "CPUInstrTable.h" -#pragma warning( disable : 4800 ) class CPUDecoder { diff --git a/rpcs3/Emu/CPU/CPUThreadManager.cpp b/rpcs3/Emu/CPU/CPUThreadManager.cpp index fa682b4e82..dca9be9e98 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.cpp +++ b/rpcs3/Emu/CPU/CPUThreadManager.cpp @@ -117,6 +117,19 @@ std::shared_ptr CPUThreadManager::GetThread(u32 id) return res; } +std::shared_ptr CPUThreadManager::GetThread(u32 id, CPUThreadType type) +{ + std::shared_ptr res; + + if (!id) return nullptr; + + if (!Emu.GetIdManager().GetIDData(id, res)) return nullptr; + + if (res->GetType() != type) return nullptr; + + return res; +} + RawSPUThread* CPUThreadManager::GetRawSPUThread(u32 num) { if (num < sizeof(Memory.RawSPUMem) / sizeof(Memory.RawSPUMem[0])) diff --git a/rpcs3/Emu/CPU/CPUThreadManager.h b/rpcs3/Emu/CPU/CPUThreadManager.h index e3fc1df32b..66fef8b377 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.h +++ b/rpcs3/Emu/CPU/CPUThreadManager.h @@ -21,6 +21,7 @@ public: //std::vector>& GetThreads() { return m_threads; } s32 GetThreadNumById(CPUThreadType type, u32 id); std::shared_ptr GetThread(u32 id); + std::shared_ptr GetThread(u32 id, CPUThreadType type); RawSPUThread* GetRawSPUThread(u32 num); void Exec(); diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index 2c5c13246d..fa7d6803f0 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -363,6 +363,7 @@ struct PPCdouble case _FPCLASS_PD: return FPR_PD; case _FPCLASS_PN: return FPR_PN; case _FPCLASS_PINF: return FPR_PINF; + default: throw fmt::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc); } #else switch (fpc) @@ -374,8 +375,6 @@ struct PPCdouble default: return std::signbit(_double) ? FPR_NN : FPR_PN; } #endif - - throw fmt::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc); } FPRType GetType() const diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index f65cfbdcb2..11feecb3ef 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -325,7 +325,7 @@ vfsDevice* VFS::GetDevice(const std::string& ps3_path, std::string& path) const path = m_devices[max_i]->GetLocalPath(); - for (u32 i = max_eq; i < ps3_path_blocks.size(); i++) + for (size_t i = max_eq; i < ps3_path_blocks.size(); i++) { path += "/" + ps3_path_blocks[i]; } @@ -382,7 +382,7 @@ vfsDevice* VFS::GetDeviceLocal(const std::string& local_path, std::string& path) path = m_devices[max_i]->GetPs3Path(); - for (u32 i = max_eq; i < local_path_blocks.size(); i++) + for (size_t i = max_eq; i < local_path_blocks.size(); i++) { path += "/" + local_path_blocks[i]; } diff --git a/rpcs3/Emu/FS/vfsDirBase.h b/rpcs3/Emu/FS/vfsDirBase.h index 0d05dcbaf5..c4d515899c 100644 --- a/rpcs3/Emu/FS/vfsDirBase.h +++ b/rpcs3/Emu/FS/vfsDirBase.h @@ -68,8 +68,7 @@ public: } iterator(const DirEntryInfo* data) - : parent(parent) - , data(data) + : data(data) { } diff --git a/rpcs3/Emu/FS/vfsStreamMemory.cpp b/rpcs3/Emu/FS/vfsStreamMemory.cpp index f385a4ecb3..5ce30c3a7c 100644 --- a/rpcs3/Emu/FS/vfsStreamMemory.cpp +++ b/rpcs3/Emu/FS/vfsStreamMemory.cpp @@ -6,15 +6,15 @@ vfsStreamMemory::vfsStreamMemory() : vfsStream() { } -vfsStreamMemory::vfsStreamMemory(u64 addr, u64 size) : vfsStream() +vfsStreamMemory::vfsStreamMemory(u32 addr, u32 size) : vfsStream() { Open(addr, size); } -void vfsStreamMemory::Open(u64 addr, u64 size) +void vfsStreamMemory::Open(u32 addr, u32 size) { m_addr = addr; - m_size = size ? size : ~0ULL; + m_size = size ? size : 0x100000000ull - addr; // determine max possible size vfsStream::Reset(); } @@ -26,24 +26,24 @@ u64 vfsStreamMemory::GetSize() u64 vfsStreamMemory::Write(const void* src, u64 size) { - if(Tell() + size > GetSize()) + assert(Tell() < m_size); + if (Tell() + size > m_size) { - size = GetSize() - Tell(); + size = m_size - Tell(); } - memcpy(vm::get_ptr(m_addr + Tell()), src, size); - + memcpy(vm::get_ptr(vm::cast(m_addr + Tell())), src, size); return vfsStream::Write(src, size); } u64 vfsStreamMemory::Read(void* dst, u64 size) { - if(Tell() + size > GetSize()) + assert(Tell() < GetSize()); + if (Tell() + size > GetSize()) { size = GetSize() - Tell(); } - memcpy(dst, vm::get_ptr(m_addr + Tell()), size); - + memcpy(dst, vm::get_ptr(vm::cast(m_addr + Tell())), size); return vfsStream::Read(dst, size); } diff --git a/rpcs3/Emu/FS/vfsStreamMemory.h b/rpcs3/Emu/FS/vfsStreamMemory.h index 00cb675013..1e3e06a73b 100644 --- a/rpcs3/Emu/FS/vfsStreamMemory.h +++ b/rpcs3/Emu/FS/vfsStreamMemory.h @@ -3,14 +3,14 @@ struct vfsStreamMemory : public vfsStream { - u64 m_addr; + u32 m_addr; u64 m_size; public: vfsStreamMemory(); - vfsStreamMemory(u64 addr, u64 size = 0); + vfsStreamMemory(u32 addr, u32 size = 0); - void Open(u64 addr, u64 size = 0); + void Open(u32 addr, u32 size = 0); virtual u64 GetSize() override; diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index ea6bb1a0bb..d537bdf92d 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -495,9 +495,9 @@ void GLFragmentDecompilerThread::Task() case RSX_FP_OPCODE_NRM: SetDst("normalize($0)"); break; case RSX_FP_OPCODE_BEM: LOG_ERROR(RSX, "Unimplemented TEX_SRB instruction: BEM"); break; case RSX_FP_OPCODE_TEX: SetDst("texture($t, $0.xy)"); break; - case RSX_FP_OPCODE_TEXBEM: LOG_ERROR(RSX, "Unimplemented TEX_SRB instruction: TEXBEM"); break; - case RSX_FP_OPCODE_TXP: SetDst("textureProj($t, $0.xy, $1)"); break; //TODO: More testing (Sonic The Hedgehog (NPUB-30442/NPEB-00478) and The Simpsons Arcade Game (NPUB30563)) - case RSX_FP_OPCODE_TXPBEM: LOG_ERROR(RSX, "Unimplemented TEX_SRB instruction: TXPBEM"); break; + case RSX_FP_OPCODE_TEXBEM: SetDst("texture($t, $0.xy, $1.x)"); break; + case RSX_FP_OPCODE_TXP: SetDst("textureProj($t, $0.xy, $1.x)"); break; //TODO: More testing (Sonic The Hedgehog (NPUB-30442/NPEB-00478) and The Simpsons Arcade Game (NPUB30563)) + case RSX_FP_OPCODE_TXPBEM: SetDst("textureProj($t, $0.xy, $1.x)"); break; case RSX_FP_OPCODE_TXD: LOG_ERROR(RSX, "Unimplemented TEX_SRB instruction: TXD"); break; case RSX_FP_OPCODE_TXB: SetDst("texture($t, $0.xy, $1.x)"); break; case RSX_FP_OPCODE_TXL: SetDst("textureLod($t, $0.xy, $1.x)"); break; diff --git a/rpcs3/Emu/RSX/RSXTexture.cpp b/rpcs3/Emu/RSX/RSXTexture.cpp index 7a21e076d3..ba07dfd5a3 100644 --- a/rpcs3/Emu/RSX/RSXTexture.cpp +++ b/rpcs3/Emu/RSX/RSXTexture.cpp @@ -289,19 +289,19 @@ u16 RSXVertexTexture::GetMipmap() const u8 RSXVertexTexture::GetWrapS() const { return 1; - return ((methodRegisters[NV4097_SET_VERTEX_TEXTURE_ADDRESS + (m_index * 32)]) & 0xf); + //return ((methodRegisters[NV4097_SET_VERTEX_TEXTURE_ADDRESS + (m_index * 32)]) & 0xf); } u8 RSXVertexTexture::GetWrapT() const { return 1; - return ((methodRegisters[NV4097_SET_VERTEX_TEXTURE_ADDRESS + (m_index * 32)] >> 8) & 0xf); + //return ((methodRegisters[NV4097_SET_VERTEX_TEXTURE_ADDRESS + (m_index * 32)] >> 8) & 0xf); } u8 RSXVertexTexture::GetWrapR() const { return 1; - return ((methodRegisters[NV4097_SET_VERTEX_TEXTURE_ADDRESS + (m_index * 32)] >> 16) & 0xf); + //return ((methodRegisters[NV4097_SET_VERTEX_TEXTURE_ADDRESS + (m_index * 32)] >> 16) & 0xf); } u8 RSXVertexTexture::GetUnsignedRemap() const diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index f91f4cb1c6..96e693d4ea 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -542,14 +542,12 @@ int cellGcmSetSecondVFrequency(u32 freq) switch (freq) { case CELL_GCM_DISPLAY_FREQUENCY_59_94HZ: - cellGcmSys->Todo("Unimplemented display frequency: 59.94Hz"); + Emu.GetGSManager().GetRender().m_frequency_mode = freq; cellGcmSys->Todo("Unimplemented display frequency: 59.94Hz"); break; case CELL_GCM_DISPLAY_FREQUENCY_SCANOUT: - cellGcmSys->Todo("Unimplemented display frequency: Scanout"); + Emu.GetGSManager().GetRender().m_frequency_mode = freq; cellGcmSys->Todo("Unimplemented display frequency: Scanout"); break; case CELL_GCM_DISPLAY_FREQUENCY_DISABLE: - Emu.GetGSManager().GetRender().m_frequency_mode = freq; - break; - - default: return CELL_EINVAL; + Emu.GetGSManager().GetRender().m_frequency_mode = freq; cellGcmSys->Todo("Unimplemented display frequency: Disabled"); break; + default: cellGcmSys->Error("Improper display frequency specified!"); return CELL_OK; } return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/Modules/cellKb.cpp b/rpcs3/Emu/SysCalls/Modules/cellKb.cpp index e8976c0de2..f580155138 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellKb.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellKb.cpp @@ -11,17 +11,24 @@ extern Module *sys_io; int cellKbInit(u32 max_connect) { sys_io->Warning("cellKbInit(max_connect=%d)", max_connect); - if(Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_ALREADY_INITIALIZED; - if(max_connect > 7) return CELL_KB_ERROR_INVALID_PARAMETER; + + if (Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_ALREADY_INITIALIZED; + if (max_connect > 7) + return CELL_KB_ERROR_INVALID_PARAMETER; Emu.GetKeyboardManager().Init(max_connect); + return CELL_OK; } int cellKbEnd() { sys_io->Log("cellKbEnd()"); - if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED; + + if (!Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_UNINITIALIZED; + Emu.GetKeyboardManager().Close(); return CELL_OK; } @@ -29,8 +36,12 @@ int cellKbEnd() int cellKbClearBuf(u32 port_no) { sys_io->Log("cellKbClearBuf(port_no=%d)", port_no); - if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED; - if(port_no >= Emu.GetKeyboardManager().GetKeyboards().size()) return CELL_KB_ERROR_INVALID_PARAMETER; + + if (!Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_UNINITIALIZED; + + if (port_no >= Emu.GetKeyboardManager().GetKeyboards().size()) + return CELL_KB_ERROR_INVALID_PARAMETER; //? @@ -42,12 +53,10 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode) sys_io->Log("cellKbCnvRawCode(arrange=%d,mkey=%d,led=%d,rawcode=%d)", arrange, mkey, led, rawcode); // CELL_KB_RAWDAT - if ((rawcode >= 0x00 && rawcode <= 0x03) || rawcode == 0x29 || rawcode == 0x35 || - (rawcode >= 0x39 && rawcode <= 0x53) || rawcode == 0x65 || rawcode == 0x88 || - rawcode == 0x8A || rawcode == 0x8B) - { - return rawcode | 0x8000; - } + if (rawcode <= 0x03 || rawcode == 0x29 || rawcode == 0x35 || (rawcode >= 0x39 && rawcode <= 0x53) || rawcode == 0x65 || rawcode == 0x88 || rawcode == 0x8A || rawcode == 0x8B) + { + return rawcode | 0x8000; + } // CELL_KB_NUMPAD if (rawcode >= 0x59 && rawcode <= 0x61) return (rawcode - 0x28) | 0x4000; // '1' - '9' @@ -88,13 +97,16 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode) int cellKbGetInfo(vm::ptr info) { sys_io->Log("cellKbGetInfo(info_addr=0x%x)", info.addr()); - if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED; + + if (!Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_UNINITIALIZED; const KbInfo& current_info = Emu.GetKeyboardManager().GetInfo(); info->max_connect = current_info.max_connect; info->now_connect = current_info.now_connect; info->info = current_info.info; - for(u32 i=0; istatus[i] = current_info.status[i]; } @@ -107,14 +119,18 @@ int cellKbRead(u32 port_no, vm::ptr data) sys_io->Log("cellKbRead(port_no=%d,info_addr=0x%x)", port_no, data.addr()); const std::vector& keyboards = Emu.GetKeyboardManager().GetKeyboards(); - if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED; - if(port_no >= keyboards.size()) return CELL_KB_ERROR_INVALID_PARAMETER; + if (!Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_UNINITIALIZED; + + if (port_no >= keyboards.size()) + return CELL_KB_ERROR_INVALID_PARAMETER; KbData& current_data = Emu.GetKeyboardManager().GetData(port_no); data->led = current_data.led; data->mkey = current_data.mkey; data->len = std::min((u32)current_data.len, CELL_KB_MAX_KEYCODES); - for(s32 i=0; ikeycode[i] = current_data.keycode[i]; } @@ -127,7 +143,9 @@ int cellKbRead(u32 port_no, vm::ptr data) int cellKbSetCodeType(u32 port_no, u32 type) { sys_io->Log("cellKbSetCodeType(port_no=%d,type=%d)", port_no, type); - if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED; + + if (!Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_UNINITIALIZED; KbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no); current_config.code_type = type; @@ -143,7 +161,9 @@ int cellKbSetLEDStatus(u32 port_no, u8 led) int cellKbSetReadMode(u32 port_no, u32 rmode) { sys_io->Log("cellKbSetReadMode(port_no=%d,rmode=%d)", port_no, rmode); - if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED; + + if (!Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_UNINITIALIZED; KbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no); current_config.read_mode = rmode; @@ -154,7 +174,9 @@ int cellKbSetReadMode(u32 port_no, u32 rmode) int cellKbGetConfiguration(u32 port_no, vm::ptr config) { sys_io->Log("cellKbGetConfiguration(port_no=%d,config_addr=0x%x)", port_no, config.addr()); - if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED; + + if (!Emu.GetKeyboardManager().IsInited()) + return CELL_KB_ERROR_UNINITIALIZED; const KbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no); config->arrange = current_config.arrange; diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index 64107c9461..31e3114a3b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -127,8 +127,8 @@ s32 cellMsgDialogOpen2(u32 type, vm::ptr msgString, vm::ptr cal } char errorCodeHex[12]; +#if __STDC_WANT_SECURE_LIB__ && !_WIN32_WCE + sprintf_s(errorCodeHex, "\n(%08x)", errorCode); +#else sprintf(errorCodeHex, "\n(%08x)", errorCode); +#endif errorMessage.append(errorCodeHex); u64 status; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 0c372e82e8..a652921035 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -1060,8 +1060,10 @@ s32 syncLFQueueGetPushPointer(vm::ptr queue, s32& pointer, u32 res = CELL_SYNC_ERROR_AGAIN; if (!push.m_h7.data() || res) { + // TODO: This condition is always true - wrong implementation? return res; } + break; } else if (!useEventQueue) @@ -1437,8 +1439,10 @@ s32 syncLFQueueGetPopPointer(vm::ptr queue, s32& pointer, u32 i res = CELL_SYNC_ERROR_AGAIN; if (!pop.m_h3.data() || res) { + // TODO: This condition is always true - wrong implementation? return res; } + break; } else if (!useEventQueue) diff --git a/rpcs3/Gui/CompilerELF.cpp b/rpcs3/Gui/CompilerELF.cpp index 0dcd836eca..3fc419f2f1 100644 --- a/rpcs3/Gui/CompilerELF.cpp +++ b/rpcs3/Gui/CompilerELF.cpp @@ -210,91 +210,91 @@ void CompilerELF::OnUpdate(wxCommandEvent& event) DoAnalyzeCode(false); return; - asm_list->Freeze(); - asm_list->SetStyle(0, asm_list->GetValue().Len(), wxTextAttr("Black")); + //asm_list->Freeze(); + //asm_list->SetStyle(0, asm_list->GetValue().Len(), wxTextAttr("Black")); - /* - for(u32 i=0; iGetValue().find('#', p)) >= 0;) - { - const int from = p++; - p = asm_list->GetValue().find('\n', p); + //for(int p=0; (p = asm_list->GetValue().find('#', p)) >= 0;) + //{ + // const int from = p++; + // p = asm_list->GetValue().find('\n', p); - if(p < 0) p = asm_list->GetValue().Len(); + // if(p < 0) p = asm_list->GetValue().Len(); - asm_list->SetStyle(from, p, wxTextAttr(0x009900)); - } - - for(int p=0; (p = asm_list->GetValue().find('"', p)) >= 0;) - { - const int from = p++; - const int p1 = asm_list->GetValue().find('\n', p); + // asm_list->SetStyle(from, p, wxTextAttr(0x009900)); + //} + // + //for(int p=0; (p = asm_list->GetValue().find('"', p)) >= 0;) + //{ + // const int from = p++; + // const int p1 = asm_list->GetValue().find('\n', p); - int p2 = p; - for(;;) - { - p2 = asm_list->GetValue().find('"', p2); - if(p2 == -1) break; + // int p2 = p; + // for(;;) + // { + // p2 = asm_list->GetValue().find('"', p2); + // if(p2 == -1) break; - if(asm_list->GetValue()[p2 - 1] == '\\') - { - if(p2 > 2 && asm_list->GetValue()[p2 - 2] == '\\') break; + // if(asm_list->GetValue()[p2 - 1] == '\\') + // { + // if(p2 > 2 && asm_list->GetValue()[p2 - 2] == '\\') break; - p2++; - continue; - } - break; - } + // p2++; + // continue; + // } + // break; + // } - if(p1 < 0 && p2 < 0) - { - p = asm_list->GetValue().Len(); - } - else if(p1 >= 0 && p2 < 0) - { - p = p1; - } - else if(p2 >= 0 && p1 < 0) - { - p = p2 + 1; - } - else - { - p = p1 > p2 ? p2 + 1 : p1; - } + // if(p1 < 0 && p2 < 0) + // { + // p = asm_list->GetValue().Len(); + // } + // else if(p1 >= 0 && p2 < 0) + // { + // p = p1; + // } + // else if(p2 >= 0 && p1 < 0) + // { + // p = p2 + 1; + // } + // else + // { + // p = p1 > p2 ? p2 + 1 : p1; + // } - asm_list->SetStyle(from, p, wxTextAttr(0x000099)); - } + // asm_list->SetStyle(from, p, wxTextAttr(0x000099)); + //} - asm_list->Thaw(); + //asm_list->Thaw(); - UpdateScroll(true, wxVERTICAL); + //UpdateScroll(true, wxVERTICAL); } void CompilerELF::OnScroll(wxScrollWinEvent& event) diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 42813536b7..4b4a2d6539 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -274,6 +274,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 4965248105..fdd71b410a 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -1291,5 +1291,8 @@ Emu\CPU\ARMv7 + + Emu\CPU\ARMv7\Modules + \ No newline at end of file diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 825c1c4007..66792d0ea4 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -14,6 +14,8 @@ #endif // This header should be frontend-agnostic, so don't assume wx includes everything +#pragma warning( disable : 4800 ) + #include #include #include