diff --git a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp index 2f60850f59..b977d8006f 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp @@ -3,6 +3,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/CPU/CPUDecoder.h" #include "ARMv7Thread.h" +#include "PSVFuncList.h" #include "ARMv7Interpreter.h" void ARMv7Interpreter::UNK(const u32 data) @@ -40,7 +41,7 @@ void ARMv7Interpreter::HACK(const u32 data, const ARMv7_encoding type) if (ConditionPassed(cond)) { - // + execute_psv_func_by_index(CPU, code); } } @@ -74,11 +75,42 @@ void ARMv7Interpreter::ADC_RSR(const u32 data, const ARMv7_encoding type) void ARMv7Interpreter::ADD_IMM(const u32 data, const ARMv7_encoding type) { + bool set_flags = !CPU.ITSTATE; + u32 cond = CPU.ITSTATE.advance(); + u32 d = 0; + u32 n = 0; + u32 imm32 = 0; + switch (type) { + case T1: + { + d = (data & 0x7); + n = (data & 0x38) >> 3; + imm32 = (data & 0x1c0) >> 6; + break; + } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } + + if (ConditionPassed(cond)) + { + if (set_flags) + { + bool carry, overflow; + u32 res = AddWithCarry(CPU.read_gpr(n), imm32, false, carry, overflow); + CPU.write_gpr(d, res); + CPU.APSR.N = res >> 31; + CPU.APSR.Z = res == 0; + CPU.APSR.C = carry; + CPU.APSR.V = overflow; + } + else + { + CPU.write_gpr(d, CPU.read_gpr(n) + imm32); + } + } } void ARMv7Interpreter::ADD_REG(const u32 data, const ARMv7_encoding type) @@ -809,9 +841,8 @@ void ARMv7Interpreter::MLS(const u32 data, const ARMv7_encoding type) void ARMv7Interpreter::MOV_IMM(const u32 data, const ARMv7_encoding type) { - bool set_flags = CPU.ITSTATE; + bool set_flags = !CPU.ITSTATE; bool carry = CPU.APSR.C; - u32 cond = CPU.ITSTATE.advance(); u32 d = 0; u32 imm32 = 0; @@ -855,20 +886,72 @@ void ARMv7Interpreter::MOV_IMM(const u32 data, const ARMv7_encoding type) void ARMv7Interpreter::MOV_REG(const u32 data, const ARMv7_encoding type) { + u32 cond = CPU.ITSTATE.advance(); + u32 d = 0; + u32 m = 0; + bool set_flags = false; + switch (type) { + case T1: + { + d = (data & 0x80) >> 4 | (data & 0x7); + m = (data & 0x78) >> 3; + break; + } + case T2: + { + d = (data & 0x7); + m = (data & 0x38) >> 3; + set_flags = true; + break; + } + case T3: + { + d = (data & 0xf00) >> 8; + m = (data & 0xf); + set_flags = (data & 0x100000); + break; + } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } + + if (ConditionPassed(cond)) + { + u32 res = CPU.read_gpr(m); + CPU.write_gpr(d, res); + if (set_flags) + { + CPU.APSR.N = res >> 31; + CPU.APSR.Z = res == 0; + //CPU.APSR.C = ? + } + } } void ARMv7Interpreter::MOVT(const u32 data, const ARMv7_encoding type) { + u32 cond = CPU.ITSTATE.advance(); + u32 d = 0; + u32 imm16 = 0; + switch (type) { + case T1: + { + d = (data & 0xf00) >> 8; + imm16 = (data & 0xf0000) >> 4 | (data & 0x4000000) >> 14 | (data & 0x7000) >> 4 | (data & 0xff); + break; + } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } + + if (ConditionPassed(cond)) + { + CPU.write_gpr(d, (CPU.read_gpr(d) & 0xffff) | (imm16 << 16)); + } } @@ -1889,12 +1972,37 @@ void ARMv7Interpreter::SUB_RSR(const u32 data, const ARMv7_encoding type) void ARMv7Interpreter::SUB_SPI(const u32 data, const ARMv7_encoding type) { u32 cond = CPU.ITSTATE.advance(); + u32 d = 13; + u32 imm32 = 0; + bool set_flags = false; switch (type) { - case T1: if (ConditionPassed(cond)) CPU.SP -= (data & 0x7f) << 2; return; + case T1: + { + imm32 = (data & 0x7f) << 2; + break; + } default: throw __FUNCTION__; } + + if (ConditionPassed(cond)) + { + if (set_flags) + { + bool carry, overflow; + u32 res = AddWithCarry(CPU.SP, ~imm32, true, carry, overflow); + CPU.write_gpr(d, res); + CPU.APSR.N = res >> 31; + CPU.APSR.Z = res == 0; + CPU.APSR.C = carry; + CPU.APSR.V = overflow; + } + else + { + CPU.write_gpr(d, CPU.SP - imm32); + } + } } void ARMv7Interpreter::SUB_SPR(const u32 data, const ARMv7_encoding type) diff --git a/rpcs3/Emu/ARMv7/ARMv7Interpreter.h b/rpcs3/Emu/ARMv7/ARMv7Interpreter.h index ebcb66b983..bfe7539967 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Interpreter.h +++ b/rpcs3/Emu/ARMv7/ARMv7Interpreter.h @@ -225,11 +225,17 @@ public: template T AddWithCarry(T x, T y, bool carry_in, bool& carry_out, bool& overflow) { - uint unsigned_sum = (uint)x + (uint)y + (uint)carry_in; - int signed_sum = (int)x + (int)y + (int)carry_in; - T result = unsigned_sum & ~(T(1) << (sizeof(T) - 1)); - carry_out = (uint)result != unsigned_sum; - overflow = (int)result != signed_sum; + 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; } diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp new file mode 100644 index 0000000000..ac4bbaa532 --- /dev/null +++ b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp @@ -0,0 +1,41 @@ +#include "stdafx.h" +#include "Emu/ARMv7/PSVFuncList.h" + +extern psv_log_base sceLibc; + +namespace sce_libc_func +{ + void __cxa_atexit() + { + sceLibc.Todo(__FUNCTION__); + } + + void exit() + { + sceLibc.Todo(__FUNCTION__); + } + + void printf() + { + sceLibc.Todo(__FUNCTION__); + } + + void __cxa_set_dso_handle_main() + { + sceLibc.Todo(__FUNCTION__); + } +} + +psv_log_base sceLibc = []() -> psv_log_base& +{ + psv_log_base* module = new psv_log_base("sceLibc"); + +#define REG_FUNC(nid, name) reg_psv_func(nid, module, sce_libc_func::name) + + REG_FUNC(0x33b83b70, __cxa_atexit); + REG_FUNC(0x826bbbaf, exit); + REG_FUNC(0x9a004680, printf); + REG_FUNC(0xbfe02b3a, __cxa_set_dso_handle_main); + + return std::move(*module); +}(); diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.cpp b/rpcs3/Emu/ARMv7/PSVFuncList.cpp new file mode 100644 index 0000000000..168ea1cfce --- /dev/null +++ b/rpcs3/Emu/ARMv7/PSVFuncList.cpp @@ -0,0 +1,45 @@ +#include "stdafx.h" +#include "PSVFuncList.h" + +std::vector g_psv_func_list; + +void add_psv_func(psv_func& data) +{ + g_psv_func_list.push_back(data); +} + +psv_func* get_psv_func_by_nid(u32 nid) +{ + for (auto& f : g_psv_func_list) + { + if (f.nid == nid) + { + return &f; + } + } + + return nullptr; +} + +u32 get_psv_func_index(psv_func* func) +{ + u32 res = func - g_psv_func_list.data(); + + assert(res < g_psv_func_list.size()); + + return res; +} + +void execute_psv_func_by_index(ARMv7Thread& CPU, u32 index) +{ + assert(index < g_psv_func_list.size()); + + (*g_psv_func_list[index].func)(CPU); +} + +extern psv_log_base sceLibc; + +void list_known_psv_modules() +{ + sceLibc.Log(""); +} diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.h b/rpcs3/Emu/ARMv7/PSVFuncList.h new file mode 100644 index 0000000000..b6356ebea8 --- /dev/null +++ b/rpcs3/Emu/ARMv7/PSVFuncList.h @@ -0,0 +1,290 @@ +#pragma once +#include "ARMv7Thread.h" +#include "Emu/SysCalls/LogBase.h" + +class psv_log_base : public LogBase +{ + std::string m_name; + +public: + psv_log_base(const std::string& name) + : m_name(name) + { + } + + virtual const std::string& GetName() const override + { + return m_name; + } + +}; + +class psv_func_caller +{ +public: + virtual void operator()(ARMv7Thread& CPU) = 0; + virtual ~psv_func_caller(){}; +}; + +namespace psv_func_detail +{ + enum bind_arg_type + { + ARG_GENERAL, + ARG_FLOAT, + ARG_VECTOR, + ARG_STACK, + }; + + template + struct bind_arg; + + template + struct bind_arg + { + static_assert(sizeof(T) <= 4, "Invalid function argument type for ARG_GENERAL"); + + static __forceinline T func(ARMv7Thread& CPU) + { + return (T&)CPU.GPR[g_count - 1]; + } + }; + + template + struct bind_arg + { + static_assert(f_count <= 0, "TODO: Unsupported argument type (float)"); + static_assert(sizeof(T) <= 8, "Invalid function argument type for ARG_FLOAT"); + + static __forceinline T func(ARMv7Thread& CPU) + { + } + }; + + template + struct bind_arg + { + static_assert(v_count <= 0, "TODO: Unsupported argument type (vector)"); + static_assert(sizeof(T) == 16, "Invalid function argument type for ARG_VECTOR"); + + static __forceinline T func(ARMv7Thread& CPU) + { + } + }; + + template + struct bind_arg + { + static_assert(f_count <= 4, "TODO: Unsupported stack argument type (general)"); + static_assert(f_count <= 0, "TODO: Unsupported stack argument type (float)"); + static_assert(v_count <= 0, "TODO: Unsupported stack argument type (vector)"); + static_assert(sizeof(T) <= 4, "Invalid function argument type for ARG_STACK"); + + static __forceinline T func(ARMv7Thread& CPU) + { + } + }; + + template + struct bind_result + { + static_assert(type != ARG_FLOAT, "TODO: Unsupported funcion result type (float)"); + static_assert(type != ARG_VECTOR, "TODO: Unsupported funcion result type (vector)"); + static_assert(type == ARG_GENERAL, "Wrong use of bind_result template"); + static_assert(sizeof(T) <= 4, "Invalid function result type for ARG_GENERAL"); + + static __forceinline void func(ARMv7Thread& CPU, T result) + { + (T&)CPU.GPR[0] = result; + } + }; + + //template + //struct bind_result + //{ + // static_assert(sizeof(T) <= 8, "Invalid function result type for ARG_FLOAT"); + + // static __forceinline void func(ARMv7Thread& CPU, T result) + // { + // } + //}; + + //template + //struct bind_result + //{ + // static_assert(sizeof(T) == 16, "Invalid function result type for ARG_VECTOR"); + + // static __forceinline void func(ARMv7Thread& CPU, const T result) + // { + // } + //}; + + template + struct call_impl + { + static __forceinline RT call(F f, Tuple && t) + { + return call_impl::call(f, std::forward(t)); + } + }; + + template + struct call_impl + { + static __forceinline RT call(F f, Tuple && t) + { + return f(std::get(std::forward(t))...); + } + }; + + template + static __forceinline RT call(F f, Tuple && t) + { + typedef typename std::decay::type ttype; + return psv_func_detail::call_impl::value, std::tuple_size::value>::call(f, std::forward(t)); + } + + template + static __forceinline std::tuple<> iterate(ARMv7Thread& CPU) + { + // terminator + return std::tuple<>(); + } + + template + static __forceinline std::tuple iterate(ARMv7Thread& CPU) + { + static_assert(!std::is_pointer::value, "Invalid function argument type (pointer)"); + static_assert(!std::is_reference::value, "Invalid function argument type (reference)"); + // TODO: check calculations + const bool is_float = std::is_floating_point::value; + const bool is_vector = std::is_same::value; + const bind_arg_type t = is_float + ? ((f_count >= 13) ? ARG_STACK : ARG_FLOAT) + : (is_vector ? ((v_count >= 12) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 8) ? ARG_STACK : ARG_GENERAL)); + const int g = g_count + (is_float || is_vector ? 0 : 1); + const int f = f_count + (is_float ? 1 : 0); + const int v = v_count + (is_vector ? 1 : 0); + + return std::tuple_cat(std::tuple(bind_arg::func(CPU)), iterate(CPU)); + } + + template + class func_binder; + + template + class func_binder : public psv_func_caller + { + typedef void(*func_t)(T...); + const func_t m_call; + + public: + func_binder(func_t call) + : psv_func_caller() + , m_call(call) + { + } + + virtual void operator()(ARMv7Thread& CPU) + { + call(m_call, iterate<0, 0, 0, T...>(CPU)); + } + }; + + template + class func_binder : public psv_func_caller + { + typedef void(*func_t)(ARMv7Thread&, T...); + const func_t m_call; + + public: + func_binder(func_t call) + : psv_func_caller() + , m_call(call) + { + } + + virtual void operator()(ARMv7Thread& CPU) + { + call(m_call, std::tuple_cat(std::tuple(CPU), iterate<0, 0, 0, T...>(CPU))); + } + }; + + template + class func_binder : public psv_func_caller + { + typedef RT(*func_t)(T...); + const func_t m_call; + + public: + func_binder(func_t call) + : psv_func_caller() + , m_call(call) + { + } + + virtual void operator()(ARMv7Thread& CPU) + { + static_assert(!std::is_pointer::value, "Invalid function result type (pointer)"); + static_assert(!std::is_reference::value, "Invalid function result type (reference)"); + const bool is_float = std::is_floating_point::value; + const bool is_vector = std::is_same::value; + const bind_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); + + bind_result::func(CPU, call(m_call, iterate<0, 0, 0, T...>(CPU))); + } + }; + + template + class func_binder : public psv_func_caller + { + typedef RT(*func_t)(ARMv7Thread&, T...); + const func_t m_call; + + public: + func_binder(func_t call) + : psv_func_caller() + , m_call(call) + { + } + + virtual void operator()(ARMv7Thread& CPU) + { + static_assert(!std::is_pointer::value, "Invalid function result type (pointer)"); + static_assert(!std::is_reference::value, "Invalid function result type (reference)"); + const bool is_float = std::is_floating_point::value; + const bool is_vector = std::is_same::value; + const bind_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); + + bind_result::func(CPU, call(m_call, std::tuple_cat(std::tuple(CPU), iterate<0, 0, 0, T...>(CPU)))); + } + }; +} + +struct psv_func +{ + const u32 nid; + psv_func_caller* const func; + psv_log_base* const module; +}; + +void add_psv_func(psv_func& data); + +template +void reg_psv_func(u32 nid, psv_log_base* module, RT(*func)(T...)) +{ + psv_func f = + { + nid, + new psv_func_detail::func_binder(func), + module + }; + + add_psv_func(f); +} + +psv_func* get_psv_func_by_nid(u32 nid); +u32 get_psv_func_index(psv_func* func); + +void execute_psv_func_by_index(ARMv7Thread& CPU, u32 index); +void list_known_psv_modules(); diff --git a/rpcs3/Emu/Memory/Memory.cpp b/rpcs3/Emu/Memory/Memory.cpp index 1cc432d4cd..59c6c5feb3 100644 --- a/rpcs3/Emu/Memory/Memory.cpp +++ b/rpcs3/Emu/Memory/Memory.cpp @@ -412,6 +412,12 @@ void DynamicMemoryBlockBase::Delete() bool DynamicMemoryBlockBase::AllocFixed(u64 addr, u32 size) { + if (!MemoryBlock::GetStartAddr()) + { + LOG_ERROR(MEMORY, "DynamicMemoryBlockBase::AllocFixed(addr=0x%llx, size=0x%x): memory block not initialized", addr, size); + return false; + } + size = PAGE_4K(size + (addr & 4095)); // align size addr &= ~4095; // align start address @@ -441,6 +447,12 @@ void DynamicMemoryBlockBase::AppendMem(u64 addr, u32 size) /* private */ u64 DynamicMemoryBlockBase::AllocAlign(u32 size, u32 align) { + if (!MemoryBlock::GetStartAddr()) + { + LOG_ERROR(MEMORY, "DynamicMemoryBlockBase::AllocAlign(size=0x%x, align=0x%x): memory block not initialized", size, align); + return 0; + } + size = PAGE_4K(size); u32 exsize; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp index 57442cdd91..5ee26e36d0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp @@ -13,7 +13,7 @@ u32 libatrac3plus; u32 libatrac3plus_rtoc; #endif -s32 cellAtracSetDataAndGetMemSize(vm::ptr pHandle, u32 pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, vm::ptr puiWorkMemByte) +s64 cellAtracSetDataAndGetMemSize(vm::ptr pHandle, u32 pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, vm::ptr puiWorkMemByte) { cellAtrac->Warning("cellAtracSetDataAndGetMemSize(pHandle=0x%x, pucBufferAddr=0x%x, uiReadByte=0x%x, uiBufferByte=0x%x, puiWorkMemByte_addr=0x%x)", pHandle.addr(), pucBufferAddr, uiReadByte, uiBufferByte, puiWorkMemByte.addr()); @@ -25,7 +25,7 @@ s32 cellAtracSetDataAndGetMemSize(vm::ptr pHandle, u32 pucBuffe return CELL_OK; } -s32 cellAtracCreateDecoder(vm::ptr pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, u32 uiSpuThreadPriority) +s64 cellAtracCreateDecoder(vm::ptr pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, u32 uiSpuThreadPriority) { cellAtrac->Warning("cellAtracCreateDecoder(pHandle=0x%x, pucWorkMem_addr=0x%x, uiPpuThreadPriority=%d, uiSpuThreadPriority=%d)", pHandle.addr(), pucWorkMem_addr, uiPpuThreadPriority, uiSpuThreadPriority); @@ -37,7 +37,7 @@ s32 cellAtracCreateDecoder(vm::ptr pHandle, u32 pucWorkMem_addr return CELL_OK; } -s32 cellAtracCreateDecoderExt(vm::ptr pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, vm::ptr pExtRes) +s64 cellAtracCreateDecoderExt(vm::ptr pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, vm::ptr pExtRes) { cellAtrac->Warning("cellAtracCreateDecoderExt(pHandle=0x%x, pucWorkMem_addr=0x%x, uiPpuThreadPriority=%d, pExtRes_addr=0x%x)", pHandle.addr(), pucWorkMem_addr, uiPpuThreadPriority, pExtRes.addr()); @@ -49,7 +49,7 @@ s32 cellAtracCreateDecoderExt(vm::ptr pHandle, u32 pucWorkMem_a return CELL_OK; } -s32 cellAtracDeleteDecoder(vm::ptr pHandle) +s64 cellAtracDeleteDecoder(vm::ptr pHandle) { cellAtrac->Warning("cellAtracDeleteDecoder(pHandle=0x%x)", pHandle.addr()); #ifdef PRX_DEBUG @@ -59,7 +59,7 @@ s32 cellAtracDeleteDecoder(vm::ptr pHandle) return CELL_OK; } -s32 cellAtracDecode(vm::ptr pHandle, u32 pfOutAddr, vm::ptr puiSamples, vm::ptr puiFinishflag, vm::ptr piRemainFrame) +s64 cellAtracDecode(vm::ptr pHandle, u32 pfOutAddr, vm::ptr puiSamples, vm::ptr puiFinishflag, vm::ptr piRemainFrame) { cellAtrac->Warning("cellAtracDecode(pHandle=0x%x, pfOutAddr=0x%x, puiSamples_addr=0x%x, puiFinishFlag_addr=0x%x, piRemainFrame_addr=0x%x)", pHandle.addr(), pfOutAddr, puiSamples.addr(), puiFinishflag.addr(), piRemainFrame.addr()); @@ -73,7 +73,7 @@ s32 cellAtracDecode(vm::ptr pHandle, u32 pfOutAddr, vm::ptr pHandle, vm::ptr ppucWritePointer, vm::ptr puiWritableByte, vm::ptr puiReadPosition) +s64 cellAtracGetStreamDataInfo(vm::ptr pHandle, vm::ptr ppucWritePointer, vm::ptr puiWritableByte, vm::ptr puiReadPosition) { cellAtrac->Warning("cellAtracGetStreamDataInfo(pHandle=0x%x, ppucWritePointer_addr=0x%x, puiWritableByte_addr=0x%x, puiReadPosition_addr=0x%x)", pHandle.addr(), ppucWritePointer.addr(), puiWritableByte.addr(), puiReadPosition.addr()); @@ -87,7 +87,7 @@ s32 cellAtracGetStreamDataInfo(vm::ptr pHandle, vm::ptr pp return CELL_OK; } -s32 cellAtracAddStreamData(vm::ptr pHandle, u32 uiAddByte) +s64 cellAtracAddStreamData(vm::ptr pHandle, u32 uiAddByte) { cellAtrac->Warning("cellAtracAddStreamData(pHandle=0x%x, uiAddByte=0x%x)", pHandle.addr(), uiAddByte); #ifdef PRX_DEBUG @@ -97,7 +97,7 @@ s32 cellAtracAddStreamData(vm::ptr pHandle, u32 uiAddByte) return CELL_OK; } -s32 cellAtracGetRemainFrame(vm::ptr pHandle, vm::ptr piRemainFrame) +s64 cellAtracGetRemainFrame(vm::ptr pHandle, vm::ptr piRemainFrame) { cellAtrac->Warning("cellAtracGetRemainFrame(pHandle=0x%x, piRemainFrame_addr=0x%x)", pHandle.addr(), piRemainFrame.addr()); #ifdef PRX_DEBUG @@ -108,7 +108,7 @@ s32 cellAtracGetRemainFrame(vm::ptr pHandle, vm::ptr piRem return CELL_OK; } -s32 cellAtracGetVacantSize(vm::ptr pHandle, vm::ptr puiVacantSize) +s64 cellAtracGetVacantSize(vm::ptr pHandle, vm::ptr puiVacantSize) { cellAtrac->Warning("cellAtracGetVacantSize(pHandle=0x%x, puiVacantSize_addr=0x%x)", pHandle.addr(), puiVacantSize.addr()); #ifdef PRX_DEBUG @@ -119,7 +119,7 @@ s32 cellAtracGetVacantSize(vm::ptr pHandle, vm::ptr puiVac return CELL_OK; } -s32 cellAtracIsSecondBufferNeeded(vm::ptr pHandle) +s64 cellAtracIsSecondBufferNeeded(vm::ptr pHandle) { cellAtrac->Warning("cellAtracIsSecondBufferNeeded(pHandle=0x%x)", pHandle.addr()); #ifdef PRX_DEBUG @@ -129,7 +129,7 @@ s32 cellAtracIsSecondBufferNeeded(vm::ptr pHandle) return CELL_OK; } -s32 cellAtracGetSecondBufferInfo(vm::ptr pHandle, vm::ptr puiReadPosition, vm::ptr puiDataByte) +s64 cellAtracGetSecondBufferInfo(vm::ptr pHandle, vm::ptr puiReadPosition, vm::ptr puiDataByte) { cellAtrac->Warning("cellAtracGetSecondBufferInfo(pHandle=0x%x, puiReadPosition_addr=0x%x, puiDataByte_addr=0x%x)", pHandle.addr(), puiReadPosition.addr(), puiDataByte.addr()); @@ -142,7 +142,7 @@ s32 cellAtracGetSecondBufferInfo(vm::ptr pHandle, vm::ptr return CELL_OK; } -s32 cellAtracSetSecondBuffer(vm::ptr pHandle, u32 pucSecondBufferAddr, u32 uiSecondBufferByte) +s64 cellAtracSetSecondBuffer(vm::ptr pHandle, u32 pucSecondBufferAddr, u32 uiSecondBufferByte) { cellAtrac->Warning("cellAtracSetSecondBuffer(pHandle=0x%x, pucSecondBufferAddr=0x%x, uiSecondBufferByte=0x%x)", pHandle.addr(), pucSecondBufferAddr, uiSecondBufferByte); @@ -153,7 +153,7 @@ s32 cellAtracSetSecondBuffer(vm::ptr pHandle, u32 pucSecondBuff return CELL_OK; } -s32 cellAtracGetChannel(vm::ptr pHandle, vm::ptr puiChannel) +s64 cellAtracGetChannel(vm::ptr pHandle, vm::ptr puiChannel) { cellAtrac->Warning("cellAtracGetChannel(pHandle=0x%x, puiChannel_addr=0x%x)", pHandle.addr(), puiChannel.addr()); #ifdef PRX_DEBUG @@ -164,7 +164,7 @@ s32 cellAtracGetChannel(vm::ptr pHandle, vm::ptr puiChanne return CELL_OK; } -s32 cellAtracGetMaxSample(vm::ptr pHandle, vm::ptr puiMaxSample) +s64 cellAtracGetMaxSample(vm::ptr pHandle, vm::ptr puiMaxSample) { cellAtrac->Warning("cellAtracGetMaxSample(pHandle=0x%x, puiMaxSample_addr=0x%x)", pHandle.addr(), puiMaxSample.addr()); #ifdef PRX_DEBUG @@ -175,7 +175,7 @@ s32 cellAtracGetMaxSample(vm::ptr pHandle, vm::ptr puiMaxS return CELL_OK; } -s32 cellAtracGetNextSample(vm::ptr pHandle, vm::ptr puiNextSample) +s64 cellAtracGetNextSample(vm::ptr pHandle, vm::ptr puiNextSample) { cellAtrac->Warning("cellAtracGetNextSample(pHandle=0x%x, puiNextSample_addr=0x%x)", pHandle.addr(), puiNextSample.addr()); #ifdef PRX_DEBUG @@ -186,7 +186,7 @@ s32 cellAtracGetNextSample(vm::ptr pHandle, vm::ptr puiNex return CELL_OK; } -s32 cellAtracGetSoundInfo(vm::ptr pHandle, vm::ptr piEndSample, vm::ptr piLoopStartSample, vm::ptr piLoopEndSample) +s64 cellAtracGetSoundInfo(vm::ptr pHandle, vm::ptr piEndSample, vm::ptr piLoopStartSample, vm::ptr piLoopEndSample) { cellAtrac->Warning("cellAtracGetSoundInfo(pHandle=0x%x, piEndSample_addr=0x%x, piLoopStartSample_addr=0x%x, piLoopEndSample_addr=0x%x)", pHandle.addr(), piEndSample.addr(), piLoopStartSample.addr(), piLoopEndSample.addr()); @@ -200,7 +200,7 @@ s32 cellAtracGetSoundInfo(vm::ptr pHandle, vm::ptr piEndSa return CELL_OK; } -s32 cellAtracGetNextDecodePosition(vm::ptr pHandle, vm::ptr puiSamplePosition) +s64 cellAtracGetNextDecodePosition(vm::ptr pHandle, vm::ptr puiSamplePosition) { cellAtrac->Warning("cellAtracGetNextDecodePosition(pHandle=0x%x, puiSamplePosition_addr=0x%x)", pHandle.addr(), puiSamplePosition.addr()); @@ -212,7 +212,7 @@ s32 cellAtracGetNextDecodePosition(vm::ptr pHandle, vm::ptr pHandle, vm::ptr puiBitrate) +s64 cellAtracGetBitrate(vm::ptr pHandle, vm::ptr puiBitrate) { cellAtrac->Warning("cellAtracGetBitrate(pHandle=0x%x, puiBitrate_addr=0x%x)", pHandle.addr(), puiBitrate.addr()); @@ -224,7 +224,7 @@ s32 cellAtracGetBitrate(vm::ptr pHandle, vm::ptr puiBitrat return CELL_OK; } -s32 cellAtracGetLoopInfo(vm::ptr pHandle, vm::ptr piLoopNum, vm::ptr puiLoopStatus) +s64 cellAtracGetLoopInfo(vm::ptr pHandle, vm::ptr piLoopNum, vm::ptr puiLoopStatus) { cellAtrac->Warning("cellAtracGetLoopInfo(pHandle=0x%x, piLoopNum_addr=0x%x, puiLoopStatus_addr=0x%x)", pHandle.addr(), piLoopNum.addr(), puiLoopStatus.addr()); @@ -237,7 +237,7 @@ s32 cellAtracGetLoopInfo(vm::ptr pHandle, vm::ptr piLoopNu return CELL_OK; } -s32 cellAtracSetLoopNum(vm::ptr pHandle, int iLoopNum) +s64 cellAtracSetLoopNum(vm::ptr pHandle, int iLoopNum) { cellAtrac->Warning("cellAtracSetLoopNum(pHandle=0x%x, iLoopNum=0x%x)", pHandle.addr(), iLoopNum); #ifdef PRX_DEBUG @@ -247,7 +247,7 @@ s32 cellAtracSetLoopNum(vm::ptr pHandle, int iLoopNum) return CELL_OK; } -s32 cellAtracGetBufferInfoForResetting(vm::ptr pHandle, u32 uiSample, vm::ptr pBufferInfo) +s64 cellAtracGetBufferInfoForResetting(vm::ptr pHandle, u32 uiSample, vm::ptr pBufferInfo) { cellAtrac->Warning("cellAtracGetBufferInfoForResetting(pHandle=0x%x, uiSample=0x%x, pBufferInfo_addr=0x%x)", pHandle.addr(), uiSample, pBufferInfo.addr()); @@ -262,7 +262,7 @@ s32 cellAtracGetBufferInfoForResetting(vm::ptr pHandle, u32 uiS return CELL_OK; } -s32 cellAtracResetPlayPosition(vm::ptr pHandle, u32 uiSample, u32 uiWriteByte) +s64 cellAtracResetPlayPosition(vm::ptr pHandle, u32 uiSample, u32 uiWriteByte) { cellAtrac->Warning("cellAtracResetPlayPosition(pHandle=0x%x, uiSample=0x%x, uiWriteByte=0x%x)", pHandle.addr(), uiSample, uiWriteByte); @@ -273,7 +273,7 @@ s32 cellAtracResetPlayPosition(vm::ptr pHandle, u32 uiSample, u return CELL_OK; } -s32 cellAtracGetInternalErrorInfo(vm::ptr pHandle, vm::ptr piResult) +s64 cellAtracGetInternalErrorInfo(vm::ptr pHandle, vm::ptr piResult) { cellAtrac->Warning("cellAtracGetInternalErrorInfo(pHandle=0x%x, piResult_addr=0x%x)", pHandle.addr(), piResult.addr()); @@ -323,6 +323,8 @@ void cellAtrac_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { + if (!Memory.MainMem.GetStartAddr()) return; + libatrac3plus = (u32)Memory.MainMem.AllocAlign(sizeof(libatrac3plus_data), 0x100000); memcpy(vm::get_ptr(libatrac3plus), libatrac3plus_data, sizeof(libatrac3plus_data)); libatrac3plus_rtoc = libatrac3plus + 0xBED0; diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index fbace88771..05e88cd71e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -16,7 +16,7 @@ u32 libpngdec; u32 libpngdec_rtoc; #endif -s32 pngDecCreate( +s64 pngDecCreate( vm::ptr mainHandle, vm::ptr param, vm::ptr ext = vm::ptr::make(0)) @@ -45,7 +45,7 @@ s32 pngDecCreate( return CELL_OK; } -s32 pngDecDestroy(CellPngDecMainHandle dec) +s64 pngDecDestroy(CellPngDecMainHandle dec) { if (!Memory.Free(dec.addr())) { @@ -55,7 +55,7 @@ s32 pngDecDestroy(CellPngDecMainHandle dec) return CELL_OK; } -s32 pngDecOpen( +s64 pngDecOpen( CellPngDecMainHandle dec, vm::ptr subHandle, vm::ptr src, @@ -115,7 +115,7 @@ s32 pngDecOpen( return CELL_OK; } -s32 pngDecClose(CellPngDecSubHandle stream) +s64 pngDecClose(CellPngDecSubHandle stream) { cellFsClose(stream->fd); if (!Memory.Free(stream.addr())) @@ -126,7 +126,7 @@ s32 pngDecClose(CellPngDecSubHandle stream) return CELL_OK; } -s32 pngReadHeader( +s64 pngReadHeader( CellPngDecSubHandle stream, vm::ptr info, vm::ptr extInfo = vm::ptr::make(0)) @@ -189,7 +189,7 @@ s32 pngReadHeader( return CELL_OK; } -s32 pngDecSetParameter( +s64 pngDecSetParameter( CellPngDecSubHandle stream, vm::ptr inParam, vm::ptr outParam, @@ -230,7 +230,7 @@ s32 pngDecSetParameter( return CELL_OK; } -s32 pngDecodeData( +s64 pngDecodeData( CellPngDecSubHandle stream, vm::ptr data, vm::ptr dataCtrlParam, @@ -359,7 +359,7 @@ s32 pngDecodeData( return CELL_OK; } -s32 cellPngDecCreate(vm::ptr mainHandle, vm::ptr threadInParam, vm::ptr threadOutParam) +s64 cellPngDecCreate(vm::ptr mainHandle, vm::ptr threadInParam, vm::ptr threadOutParam) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -379,7 +379,7 @@ s32 cellPngDecCreate(vm::ptr mainHandle, vm::ptr mainHandle, vm::ptr threadInParam, vm::ptr threadOutParam, @@ -405,7 +405,7 @@ s32 cellPngDecExtCreate( #endif } -s32 cellPngDecDestroy(CellPngDecMainHandle mainHandle) +s64 cellPngDecDestroy(CellPngDecMainHandle mainHandle) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -418,7 +418,7 @@ s32 cellPngDecDestroy(CellPngDecMainHandle mainHandle) #endif } -s32 cellPngDecOpen( +s64 cellPngDecOpen( CellPngDecMainHandle mainHandle, vm::ptr subHandle, vm::ptr src, @@ -436,7 +436,7 @@ s32 cellPngDecOpen( #endif } -s32 cellPngDecExtOpen( +s64 cellPngDecExtOpen( CellPngDecMainHandle mainHandle, vm::ptr subHandle, vm::ptr src, @@ -456,7 +456,7 @@ s32 cellPngDecExtOpen( #endif } -s32 cellPngDecClose(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle) +s64 cellPngDecClose(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -468,7 +468,7 @@ s32 cellPngDecClose(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHand #endif } -s32 cellPngDecReadHeader(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr info) +s64 cellPngDecReadHeader(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr info) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -481,7 +481,7 @@ s32 cellPngDecReadHeader(CellPngDecMainHandle mainHandle, CellPngDecSubHandle su #endif } -s32 cellPngDecExtReadHeader( +s64 cellPngDecExtReadHeader( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr info, @@ -498,7 +498,7 @@ s32 cellPngDecExtReadHeader( #endif } -s32 cellPngDecSetParameter( +s64 cellPngDecSetParameter( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr inParam, @@ -515,7 +515,7 @@ s32 cellPngDecSetParameter( #endif } -s32 cellPngDecExtSetParameter( +s64 cellPngDecExtSetParameter( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr inParam, @@ -534,7 +534,7 @@ s32 cellPngDecExtSetParameter( #endif } -s32 cellPngDecDecodeData( +s64 cellPngDecDecodeData( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr data, @@ -552,7 +552,7 @@ s32 cellPngDecDecodeData( #endif } -s32 cellPngDecExtDecodeData( +s64 cellPngDecExtDecodeData( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr data, @@ -572,7 +572,7 @@ s32 cellPngDecExtDecodeData( #endif } -s32 cellPngDecGetUnknownChunks( +s64 cellPngDecGetUnknownChunks( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr> unknownChunk, @@ -587,7 +587,7 @@ s32 cellPngDecGetUnknownChunks( #endif } -s32 cellPngDecGetpCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr pcal) +s64 cellPngDecGetpCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr pcal) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -598,7 +598,7 @@ s32 cellPngDecGetpCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetcHRM(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr chrm) +s64 cellPngDecGetcHRM(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr chrm) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -609,7 +609,7 @@ s32 cellPngDecGetcHRM(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetsCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr scal) +s64 cellPngDecGetsCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr scal) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -620,7 +620,7 @@ s32 cellPngDecGetsCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetpHYs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr phys) +s64 cellPngDecGetpHYs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr phys) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -631,7 +631,7 @@ s32 cellPngDecGetpHYs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetoFFs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr offs) +s64 cellPngDecGetoFFs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr offs) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -642,7 +642,7 @@ s32 cellPngDecGetoFFs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetsPLT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr splt) +s64 cellPngDecGetsPLT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr splt) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -653,7 +653,7 @@ s32 cellPngDecGetsPLT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetbKGD(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr bkgd) +s64 cellPngDecGetbKGD(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr bkgd) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -664,7 +664,7 @@ s32 cellPngDecGetbKGD(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGettIME(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr time) +s64 cellPngDecGettIME(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr time) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -675,7 +675,7 @@ s32 cellPngDecGettIME(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGethIST(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr hist) +s64 cellPngDecGethIST(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr hist) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -686,7 +686,7 @@ s32 cellPngDecGethIST(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGettRNS(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr trns) +s64 cellPngDecGettRNS(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr trns) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -697,7 +697,7 @@ s32 cellPngDecGettRNS(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetsBIT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr sbit) +s64 cellPngDecGetsBIT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr sbit) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -708,7 +708,7 @@ s32 cellPngDecGetsBIT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetiCCP(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr iccp) +s64 cellPngDecGetiCCP(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr iccp) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -719,7 +719,7 @@ s32 cellPngDecGetiCCP(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetsRGB(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr srgb) +s64 cellPngDecGetsRGB(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr srgb) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -730,7 +730,7 @@ s32 cellPngDecGetsRGB(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetgAMA(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr gama) +s64 cellPngDecGetgAMA(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr gama) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -741,7 +741,7 @@ s32 cellPngDecGetgAMA(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr plte) +s64 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr plte) { #ifdef PRX_DEBUG cellPngDec->Warning("%s()", __FUNCTION__); @@ -752,7 +752,7 @@ s32 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHa #endif } -s32 cellPngDecGetTextChunk( +s64 cellPngDecGetTextChunk( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr textInfoNum, @@ -804,6 +804,8 @@ void cellPngDec_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { + if (!Memory.MainMem.GetStartAddr()) return; + libpngdec = (u32)Memory.MainMem.AllocAlign(sizeof(libpngdec_data), 0x100000); memcpy(vm::get_ptr(libpngdec), libpngdec_data, sizeof(libpngdec_data)); libpngdec_rtoc = libpngdec + 0x49710; diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.h b/rpcs3/Emu/SysCalls/Modules/cellPngDec.h index 6bb2d021a4..e0a5473584 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.h @@ -183,77 +183,77 @@ struct CellPngDecDataOutInfo }; // Functions -s32 cellPngDecCreate(vm::ptr mainHandle, vm::ptr threadInParam, vm::ptr threadOutParam); +s64 cellPngDecCreate(vm::ptr mainHandle, vm::ptr threadInParam, vm::ptr threadOutParam); -s32 cellPngDecExtCreate( +s64 cellPngDecExtCreate( vm::ptr mainHandle, vm::ptr threadInParam, vm::ptr threadOutParam, vm::ptr extThreadInParam, vm::ptr extThreadOutParam); -s32 cellPngDecOpen( +s64 cellPngDecOpen( CellPngDecMainHandle mainHandle, vm::ptr subHandle, vm::ptr src, vm::ptr openInfo); -s32 cellPngDecReadHeader(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr info); +s64 cellPngDecReadHeader(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr info); -s32 cellPngDecSetParameter( +s64 cellPngDecSetParameter( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr inParam, vm::ptr outParam); -s32 cellPngDecDecodeData( +s64 cellPngDecDecodeData( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr data, vm::ptr dataCtrlParam, vm::ptr dataOutInfo); -s32 cellPngDecClose(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle); +s64 cellPngDecClose(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle); -s32 cellPngDecDestroy(CellPngDecMainHandle mainHandle); +s64 cellPngDecDestroy(CellPngDecMainHandle mainHandle); -s32 cellPngDecGetTextChunk( +s64 cellPngDecGetTextChunk( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr textInfoNum, vm::ptr> textInfo); -s32 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr plte); +s64 cellPngDecGetPLTE(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr plte); -s32 cellPngDecGetgAMA(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr gama); +s64 cellPngDecGetgAMA(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr gama); -s32 cellPngDecGetsRGB(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr srgb); +s64 cellPngDecGetsRGB(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr srgb); -s32 cellPngDecGetiCCP(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr iccp); +s64 cellPngDecGetiCCP(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr iccp); -s32 cellPngDecGetsBIT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr sbit); +s64 cellPngDecGetsBIT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr sbit); -s32 cellPngDecGettRNS(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr trns); +s64 cellPngDecGettRNS(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr trns); -s32 cellPngDecGethIST(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr hist); +s64 cellPngDecGethIST(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr hist); -s32 cellPngDecGettIME(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr time); +s64 cellPngDecGettIME(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr time); -s32 cellPngDecGetbKGD(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr bkgd); +s64 cellPngDecGetbKGD(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr bkgd); -s32 cellPngDecGetsPLT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr splt); +s64 cellPngDecGetsPLT(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr splt); -s32 cellPngDecGetoFFs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr offs); +s64 cellPngDecGetoFFs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr offs); -s32 cellPngDecGetpHYs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr phys); +s64 cellPngDecGetpHYs(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr phys); -s32 cellPngDecGetsCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr scal); +s64 cellPngDecGetsCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr scal); -s32 cellPngDecGetcHRM(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr chrm); +s64 cellPngDecGetcHRM(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr chrm); -s32 cellPngDecGetpCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr pcal); +s64 cellPngDecGetpCAL(CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr pcal); -s32 cellPngDecGetUnknownChunks( +s64 cellPngDecGetUnknownChunks( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr> unknownChunk, @@ -349,7 +349,7 @@ struct CellPngDecCbCtrlDisp }; // Functions -s32 cellPngDecExtOpen( +s64 cellPngDecExtOpen( CellPngDecMainHandle mainHandle, vm::ptr subHandle, vm::ptr src, @@ -357,13 +357,13 @@ s32 cellPngDecExtOpen( vm::ptr cbCtrlStrm, vm::ptr opnParam); -s32 cellPngDecExtReadHeader( +s64 cellPngDecExtReadHeader( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr info, vm::ptr extInfo); -s32 cellPngDecExtSetParameter( +s64 cellPngDecExtSetParameter( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr inParam, @@ -371,7 +371,7 @@ s32 cellPngDecExtSetParameter( vm::ptr extInParam, vm::ptr extOutParam); -s32 cellPngDecExtDecodeData( +s64 cellPngDecExtDecodeData( CellPngDecMainHandle mainHandle, CellPngDecSubHandle subHandle, vm::ptr data, diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index ae7565535c..9a293f5476 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -557,9 +557,9 @@ s64 spursInit( { if (spurs->m.wklReadyCount[i].read_relaxed() || spurs->m.wklSet1.read_relaxed() & (0x8000u >> i) || - spurs->m.wklFlag.flag.read_relaxed() == 0 && + (spurs->m.wklFlag.flag.read_relaxed() == 0 && spurs->m.flagRecv.read_relaxed() == (u8)i - ) + )) { do_break = true; break; @@ -575,9 +575,9 @@ s64 spursInit( { if (spurs->m.wklReadyCount[i + 0x10].read_relaxed() || spurs->m.wklSet2.read_relaxed() & (0x8000u >> i) || - spurs->m.wklFlag.flag.read_relaxed() == 0 && + (spurs->m.wklFlag.flag.read_relaxed() == 0 && spurs->m.flagRecv.read_relaxed() == (u8)i + 0x10 - ) + )) { do_break = true; break; @@ -953,11 +953,26 @@ s64 cellSpursAttributeEnableSystemWorkload(vm::ptr attr, vm: s64 cellSpursFinalize(vm::ptr spurs) { - cellSpurs->Todo("cellSpursFinalize(spurs_addr=0x%x)", spurs.addr()); -#ifdef PRX_DEBUG + cellSpurs->Warning("cellSpursFinalize(spurs_addr=0x%x)", spurs.addr()); +#ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x8568, libsre_rtoc); #endif + if (!spurs) + { + return CELL_SPURS_CORE_ERROR_NULL_POINTER; + } + if (spurs.addr() % 128) + { + return CELL_SPURS_CORE_ERROR_ALIGN; + } + if (spurs->m.xD66.read_relaxed()) + { + return CELL_SPURS_CORE_ERROR_STAT; + } + + + return CELL_OK; } @@ -1360,13 +1375,7 @@ s32 spursAddWorkload( spurs->m.wklSet2._and_not({ be_t::make(0x8000 >> index) }); // clear bit in wklFlag2 } - spurs->m.flagRecv.atomic_op([wnum](u8& FR) - { - if (FR == wnum) - { - FR = 0xff; - } - }); + spurs->m.flagRecv.compare_and_swap(wnum, 0xff); u32 res_wkl; CellSpurs::_sub_str3& wkl = wnum <= 15 ? spurs->m.wklG1[wnum] : spurs->m.wklG2[wnum & 0xf]; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp index ed4c73b9be..c1ad643060 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp @@ -766,6 +766,8 @@ void cellSpursJq_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { + if (!Memory.MainMem.GetStartAddr()) return; + libspurs_jq = (u32)Memory.MainMem.AllocAlign(sizeof(libspurs_jq_data), 0x100000); memcpy(vm::get_ptr(libspurs_jq), libspurs_jq_data, sizeof(libspurs_jq_data)); libspurs_jq_rtoc = libspurs_jq + 0x17E80; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 32cb8b42b4..e77004872a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -1989,6 +1989,8 @@ void cellSync_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { + if (!Memory.MainMem.GetStartAddr()) return; + libsre = (u32)Memory.MainMem.AllocAlign(sizeof(libsre_data), 0x100000); memcpy(vm::get_ptr(libsre), libsre_data, sizeof(libsre_data)); libsre_rtoc = libsre + 0x399B0; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp index 7359814b89..fb39449614 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp @@ -458,6 +458,8 @@ void cellSync2_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { + if (!Memory.MainMem.GetStartAddr()) return; + libsync2 = (u32)Memory.MainMem.AllocAlign(sizeof(libsync2_data), 0x100000); memcpy(vm::get_ptr(libsync2), libsync2_data, sizeof(libsync2_data)); libsync2_rtoc = libsync2 + 0xF280; diff --git a/rpcs3/Emu/SysCalls/SC_FUNC.h b/rpcs3/Emu/SysCalls/SC_FUNC.h index 28c4ef0582..111c4333b2 100644 --- a/rpcs3/Emu/SysCalls/SC_FUNC.h +++ b/rpcs3/Emu/SysCalls/SC_FUNC.h @@ -249,4 +249,4 @@ template func_caller* bind_func(RT(*call)(T...)) { return new detail::func_binder(call); -} \ No newline at end of file +} diff --git a/rpcs3/Loader/ELF32.cpp b/rpcs3/Loader/ELF32.cpp index 430ae52f32..d7765e5e32 100644 --- a/rpcs3/Loader/ELF32.cpp +++ b/rpcs3/Loader/ELF32.cpp @@ -3,8 +3,11 @@ #include "Utilities/rFile.h" #include "Emu/FS/vfsStream.h" #include "Emu/Memory/Memory.h" +#include "Emu/ARMv7/PSVFuncList.h" #include "ELF32.h" +#define LOADER_DEBUG + void Elf32_Ehdr::Show() { #ifdef LOADER_DEBUG @@ -502,6 +505,8 @@ bool ELF32Loader::LoadPhdrData(u64 _offset) bool ELF32Loader::LoadShdrData(u64 offset) { + u32 fnid_addr = 0; + for(u32 i=0; i::make(fnid_addr); + auto fstub = vm::psv::ptr::make(shdr.sh_addr); + + for (u32 j = 0; j < shdr.sh_size / 4; j++) + { + u32 nid = fnid[j]; + u32 addr = fstub[j]; + + if (auto func = get_psv_func_by_nid(nid)) + { + LOG_NOTICE(LOADER, "Imported function 0x%x (addr=0x%x)", nid, addr); + + // writing Thumb code (temporarily, because it should be ARM) + vm::psv::write16(addr + 0, 0xf870); // HACK (special instruction that calls HLE function + vm::psv::write16(addr + 2, (u16)get_psv_func_index(func)); + vm::psv::write16(addr + 4, 0x4770); // BX LR + vm::psv::write16(addr + 6, 0); // null + } + else + { + LOG_ERROR(LOADER, "Unimplemented function 0x%x (addr=0x%x)", nid, addr); + + // writing Thumb code (temporarily - it shouldn't be written in this case) + vm::psv::write16(addr + 0, 0xf06f); // MVN r0,#0x0 + vm::psv::write16(addr + 2, 0x0000); + vm::psv::write16(addr + 4, 0x4770); // BX LR + vm::psv::write16(addr + 6, 0); // null + } + } + } + else if (machine == MACHINE_ARM && !strcmp(shdr_name_arr[i].c_str(), ".sceRefs.rodata")) + { + // basically unknown struct + + struct reloc_info + { + u32 code; // 0xff + u32 data; // address that will be written + u32 code1; // 0x2f + u32 addr1; // address of movw r12,# instruction to be replaced + u32 code2; // 0x30 + u32 addr2; // address of movt r12,# instruction to be replaced + u32 code3; // 0 + }; + + auto rel = vm::psv::ptr::make(shdr.sh_addr); + + for (u32 j = 0; j < shdr.sh_size / sizeof(reloc_info); j++) + { + if (rel[j].code == 0xff && rel[j].code1 == 0x2f && rel[j].code2 == 0x30 && rel[j].code3 == 0) + { + const u32 data = rel[j].data; + vm::psv::write16(rel[j].addr1 + 0, 0xf240 | (data & 0x800) >> 1 | (data & 0xf000) >> 12); // MOVW + vm::psv::write16(rel[j].addr1 + 2, 0x0c00 | (data & 0x700) << 4 | (data & 0xff)); + vm::psv::write16(rel[j].addr2 + 0, 0xf2c0 | (data & 0x8000000) >> 17 | (data & 0xf0000000) >> 28); // MOVT + vm::psv::write16(rel[j].addr2 + 2, 0x0c00 | (data & 0x7000000) >> 12 | (data & 0xff0000) >> 16); + } + else + { + LOG_ERROR(LOADER, "sceRefs: unknown code found (code=0x%x, code1=0x%x, code2=0x%x, code3=0x%x)", rel[j].code, rel[j].code1, rel[j].code2, rel[j].code3); + } + } + } } //TODO diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 158775bfe8..bef91f680b 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -57,6 +57,8 @@ + + @@ -264,6 +266,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index e82a2cae4a..0b23ec7b36 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -75,6 +75,9 @@ {ead7494f-a872-4b4d-a864-1a61c3b6012f} + + {1d9e6fc4-9a79-4329-a8b5-081e24822aaa} + @@ -638,6 +641,12 @@ Emu\ARMv7 + + Emu\ARMv7 + + + Emu\ARMv7\Modules + @@ -1249,5 +1258,8 @@ Emu\Cell + + Emu\ARMv7 + \ No newline at end of file