diff --git a/Utilities/BEType.h b/Utilities/BEType.h index b8786b7374..1bbc0a8114 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -1,20 +1,91 @@ #pragma once -#include - union _CRT_ALIGN(16) u128 { u64 _u64[2]; s64 _s64[2]; + + class u64_reversed_array_2 + { + u64 data[2]; + + public: + u64& operator [] (s32 index) + { + return data[1 - index]; + } + + const u64& operator [] (s32 index) const + { + return data[1 - index]; + } + + } u64r; + u32 _u32[4]; s32 _s32[4]; + + class u32_reversed_array_4 + { + u32 data[4]; + + public: + u32& operator [] (s32 index) + { + return data[3 - index]; + } + + const u32& operator [] (s32 index) const + { + return data[3 - index]; + } + + } u32r; + u16 _u16[8]; s16 _s16[8]; + + class u16_reversed_array_8 + { + u16 data[8]; + + public: + u16& operator [] (s32 index) + { + return data[7 - index]; + } + + const u16& operator [] (s32 index) const + { + return data[7 - index]; + } + + } u16r; + u8 _u8[16]; s8 _s8[16]; + + class u8_reversed_array_16 + { + u8 data[16]; + + public: + u8& operator [] (s32 index) + { + return data[15 - index]; + } + + const u8& operator [] (s32 index) const + { + return data[15 - index]; + } + + } u8r; + float _f[4]; double _d[2]; - __m128 xmm; + __m128 vf; + __m128i vi; class bit_array_128 { @@ -94,6 +165,11 @@ union _CRT_ALIGN(16) u128 return ret; } + static u128 from64r(u64 _1, u64 _0 = 0) + { + return from64(_0, _1); + } + static u128 from32(u32 _0, u32 _1 = 0, u32 _2 = 0, u32 _3 = 0) { u128 ret; @@ -105,12 +181,21 @@ union _CRT_ALIGN(16) u128 } static u128 from32r(u32 _3, u32 _2 = 0, u32 _1 = 0, u32 _0 = 0) + { + return from32(_0, _1, _2, _3); + } + + static u128 from32p(u32 value) { u128 ret; - ret._u32[0] = _0; - ret._u32[1] = _1; - ret._u32[2] = _2; - ret._u32[3] = _3; + ret.vi = _mm_set1_epi32((int)value); + return ret; + } + + static u128 from8p(u8 value) + { + u128 ret; + ret.vi = _mm_set1_epi8((char)value); return ret; } @@ -121,9 +206,41 @@ union _CRT_ALIGN(16) u128 return ret; } - void setBit(u32 bit) + static u128 fromV(__m128i value) { - _bit[bit] = true; + u128 ret; + ret.vi = value; + return ret; + } + + static __forceinline u128 add8(const u128& left, const u128& right) + { + return fromV(_mm_add_epi8(left.vi, right.vi)); + } + + static __forceinline u128 sub8(const u128& left, const u128& right) + { + return fromV(_mm_sub_epi8(left.vi, right.vi)); + } + + static __forceinline u128 minu8(const u128& left, const u128& right) + { + return fromV(_mm_min_epu8(left.vi, right.vi)); + } + + static __forceinline u128 eq8(const u128& left, const u128& right) + { + return fromV(_mm_cmpeq_epi8(left.vi, right.vi)); + } + + static __forceinline u128 gtu8(const u128& left, const u128& right) + { + return fromV(_mm_cmpgt_epu8(left.vi, right.vi)); + } + + static __forceinline u128 leu8(const u128& left, const u128& right) + { + return fromV(_mm_cmple_epu8(left.vi, right.vi)); } bool operator == (const u128& right) const @@ -136,19 +253,19 @@ union _CRT_ALIGN(16) u128 return (_u64[0] != right._u64[0]) || (_u64[1] != right._u64[1]); } - u128 operator | (const u128& right) const + __forceinline u128 operator | (const u128& right) const { - return from64(_u64[0] | right._u64[0], _u64[1] | right._u64[1]); + return fromV(_mm_or_si128(vi, right.vi)); } - u128 operator & (const u128& right) const + __forceinline u128 operator & (const u128& right) const { - return from64(_u64[0] & right._u64[0], _u64[1] & right._u64[1]); + return fromV(_mm_and_si128(vi, right.vi)); } - u128 operator ^ (const u128& right) const + __forceinline u128 operator ^ (const u128& right) const { - return from64(_u64[0] ^ right._u64[0], _u64[1] ^ right._u64[1]); + return fromV(_mm_xor_si128(vi, right.vi)); } u128 operator ~ () const @@ -156,6 +273,12 @@ union _CRT_ALIGN(16) u128 return from64(~_u64[0], ~_u64[1]); } + // result = (~left) & (right) + static __forceinline u128 andnot(const u128& left, const u128& right) + { + return fromV(_mm_andnot_si128(left.vi, right.vi)); + } + void clear() { _u64[1] = _u64[0] = 0; @@ -180,6 +303,72 @@ union _CRT_ALIGN(16) u128 } }; +#ifndef InterlockedCompareExchange +static __forceinline u128 InterlockedCompareExchange(volatile u128* dest, u128 exch, u128 comp) +{ +#if defined(__GNUG__) + auto res = __sync_val_compare_and_swap((volatile __int128_t*)dest, (__int128_t&)comp, (__int128_t&)exch); + return (u128&)res; +#else + _InterlockedCompareExchange128((volatile long long*)dest, exch._u64[1], exch._u64[0], (long long*)&comp); + return comp; +#endif +} +#endif + +static __forceinline bool InterlockedCompareExchangeTest(volatile u128* dest, u128 exch, u128 comp) +{ +#if defined(__GNUG__) + return __sync_bool_compare_and_swap((volatile __int128_t*)dest, (__int128_t&)comp, (__int128_t&)exch); +#else + return _InterlockedCompareExchange128((volatile long long*)dest, exch._u64[1], exch._u64[0], (long long*)&comp) != 0; +#endif +} + +#ifndef InterlockedExchange +static __forceinline u128 InterlockedExchange(volatile u128* dest, u128 value) +{ + while (true) + { + const u128 old = *(u128*)dest; + if (InterlockedCompareExchangeTest(dest, value, old)) return old; + } +} +#endif + +#ifndef InterlockedOr +static __forceinline u128 InterlockedOr(volatile u128* dest, u128 value) +{ + while (true) + { + const u128 old = *(u128*)dest; + if (InterlockedCompareExchangeTest(dest, old | value, old)) return old; + } +} +#endif + +#ifndef InterlockedAnd +static __forceinline u128 InterlockedAnd(volatile u128* dest, u128 value) +{ + while (true) + { + const u128 old = *(u128*)dest; + if (InterlockedCompareExchangeTest(dest, old & value, old)) return old; + } +} +#endif + +#ifndef InterlockedXor +static __forceinline u128 InterlockedXor(volatile u128* dest, u128 value) +{ + while (true) + { + const u128 old = *(u128*)dest; + if (InterlockedCompareExchangeTest(dest, old ^ value, old)) return old; + } +} +#endif + #define re16(val) _byteswap_ushort(val) #define re32(val) _byteswap_ulong(val) #define re64(val) _byteswap_uint64(val) diff --git a/Utilities/GNU.h b/Utilities/GNU.h index b1bcbfb982..91fc34ae50 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -1,5 +1,7 @@ #pragma once +#include + #ifdef _WIN32 #define thread_local __declspec(thread) #elif __APPLE__ @@ -44,23 +46,6 @@ void strcpy_trunc(char(&dst)[size], const char(&src)[rsize]) #define _byteswap_uint64(x) __builtin_bswap64(x) #define INFINITE 0xFFFFFFFF #define _CRT_ALIGN(x) __attribute__((aligned(x))) -#define InterlockedCompareExchange(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val) -#define InterlockedExchange(ptr, value) __sync_lock_test_and_set(ptr, value) -#define InterlockedOr(ptr, value) __sync_fetch_and_or(ptr, value) -#define InterlockedAnd(ptr, value) __sync_fetch_and_and(ptr, value) -#define InterlockedXor(ptr, value) __sync_fetch_and_xor(ptr, value) - -//inline int64_t InterlockedOr64(volatile int64_t *dest, int64_t val) -//{ -// int64_t olderval; -// int64_t oldval = *dest; -// do -// { -// olderval = oldval; -// oldval = __sync_val_compare_and_swap(dest, olderval | val, olderval); -// } while (olderval != oldval); -// return oldval; -//} inline uint64_t __umulh(uint64_t a, uint64_t b) { @@ -97,95 +82,208 @@ int clock_gettime(int foo, struct timespec *ts); #ifndef InterlockedCompareExchange static __forceinline uint8_t InterlockedCompareExchange(volatile uint8_t* dest, uint8_t exch, uint8_t comp) { +#if defined(__GNUG__) + return __sync_val_compare_and_swap(dest, comp, exch); +#else return _InterlockedCompareExchange8((volatile char*)dest, exch, comp); +#endif } static __forceinline uint16_t InterlockedCompareExchange(volatile uint16_t* dest, uint16_t exch, uint16_t comp) { +#if defined(__GNUG__) + return __sync_val_compare_and_swap(dest, comp, exch); +#else return _InterlockedCompareExchange16((volatile short*)dest, exch, comp); +#endif } static __forceinline uint32_t InterlockedCompareExchange(volatile uint32_t* dest, uint32_t exch, uint32_t comp) { +#if defined(__GNUG__) + return __sync_val_compare_and_swap(dest, comp, exch); +#else return _InterlockedCompareExchange((volatile long*)dest, exch, comp); +#endif } static __forceinline uint64_t InterlockedCompareExchange(volatile uint64_t* dest, uint64_t exch, uint64_t comp) { +#if defined(__GNUG__) + return __sync_val_compare_and_swap(dest, comp, exch); +#else return _InterlockedCompareExchange64((volatile long long*)dest, exch, comp); +#endif } #endif +static __forceinline bool InterlockedCompareExchangeTest(volatile uint8_t* dest, uint8_t exch, uint8_t comp) +{ +#if defined(__GNUG__) + return __sync_bool_compare_and_swap(dest, comp, exch); +#else + return (uint8_t)_InterlockedCompareExchange8((volatile char*)dest, exch, comp) == comp; +#endif +} +static __forceinline bool InterlockedCompareExchangeTest(volatile uint16_t* dest, uint16_t exch, uint16_t comp) +{ +#if defined(__GNUG__) + return __sync_bool_compare_and_swap(dest, comp, exch); +#else + return (uint16_t)_InterlockedCompareExchange16((volatile short*)dest, exch, comp) == comp; +#endif +} +static __forceinline bool InterlockedCompareExchangeTest(volatile uint32_t* dest, uint32_t exch, uint32_t comp) +{ +#if defined(__GNUG__) + return __sync_bool_compare_and_swap(dest, comp, exch); +#else + return (uint32_t)_InterlockedCompareExchange((volatile long*)dest, exch, comp) == comp; +#endif +} +static __forceinline bool InterlockedCompareExchangeTest(volatile uint64_t* dest, uint64_t exch, uint64_t comp) +{ +#if defined(__GNUG__) + return __sync_bool_compare_and_swap(dest, comp, exch); +#else + return (uint64_t)_InterlockedCompareExchange64((volatile long long*)dest, exch, comp) == comp; +#endif +} + #ifndef InterlockedExchange static __forceinline uint8_t InterlockedExchange(volatile uint8_t* dest, uint8_t value) { +#if defined(__GNUG__) + return __sync_lock_test_and_set(dest, value); +#else return _InterlockedExchange8((volatile char*)dest, value); +#endif } static __forceinline uint16_t InterlockedExchange(volatile uint16_t* dest, uint16_t value) { +#if defined(__GNUG__) + return __sync_lock_test_and_set(dest, value); +#else return _InterlockedExchange16((volatile short*)dest, value); +#endif } static __forceinline uint32_t InterlockedExchange(volatile uint32_t* dest, uint32_t value) { +#if defined(__GNUG__) + return __sync_lock_test_and_set(dest, value); +#else return _InterlockedExchange((volatile long*)dest, value); +#endif } static __forceinline uint64_t InterlockedExchange(volatile uint64_t* dest, uint64_t value) { +#if defined(__GNUG__) + return __sync_lock_test_and_set(dest, value); +#else return _InterlockedExchange64((volatile long long*)dest, value); +#endif } #endif #ifndef InterlockedOr static __forceinline uint8_t InterlockedOr(volatile uint8_t* dest, uint8_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_or(dest, value); +#else return _InterlockedOr8((volatile char*)dest, value); +#endif } static __forceinline uint16_t InterlockedOr(volatile uint16_t* dest, uint16_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_or(dest, value); +#else return _InterlockedOr16((volatile short*)dest, value); +#endif } static __forceinline uint32_t InterlockedOr(volatile uint32_t* dest, uint32_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_or(dest, value); +#else return _InterlockedOr((volatile long*)dest, value); +#endif } static __forceinline uint64_t InterlockedOr(volatile uint64_t* dest, uint64_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_or(dest, value); +#else return _InterlockedOr64((volatile long long*)dest, value); +#endif } #endif #ifndef InterlockedAnd static __forceinline uint8_t InterlockedAnd(volatile uint8_t* dest, uint8_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_and(dest, value); +#else return _InterlockedAnd8((volatile char*)dest, value); +#endif } static __forceinline uint16_t InterlockedAnd(volatile uint16_t* dest, uint16_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_and(dest, value); +#else return _InterlockedAnd16((volatile short*)dest, value); +#endif } static __forceinline uint32_t InterlockedAnd(volatile uint32_t* dest, uint32_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_and(dest, value); +#else return _InterlockedAnd((volatile long*)dest, value); +#endif } static __forceinline uint64_t InterlockedAnd(volatile uint64_t* dest, uint64_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_and(dest, value); +#else return _InterlockedAnd64((volatile long long*)dest, value); +#endif } #endif #ifndef InterlockedXor static __forceinline uint8_t InterlockedXor(volatile uint8_t* dest, uint8_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_xor(dest, value); +#else return _InterlockedXor8((volatile char*)dest, value); +#endif } static __forceinline uint16_t InterlockedXor(volatile uint16_t* dest, uint16_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_xor(dest, value); +#else return _InterlockedXor16((volatile short*)dest, value); +#endif } static __forceinline uint32_t InterlockedXor(volatile uint32_t* dest, uint32_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_xor(dest, value); +#else return _InterlockedXor((volatile long*)dest, value); +#endif } static __forceinline uint64_t InterlockedXor(volatile uint64_t* dest, uint64_t value) { +#if defined(__GNUG__) + return __sync_fetch_and_xor(dest, value); +#else return _InterlockedXor64((volatile long long*)dest, value); +#endif } #endif @@ -222,3 +320,17 @@ static __forceinline uint64_t cntlz64(uint64_t arg) } #endif } + +// compare 16 packed unsigned bytes (greater than) +static __forceinline __m128i _mm_cmpgt_epu8(__m128i A, __m128i B) +{ + // (A xor 0x80) > (B xor 0x80) + return _mm_cmpgt_epi8(_mm_xor_si128(A, _mm_set1_epi8(-128)), _mm_xor_si128(B, _mm_set1_epi8(-128))); +} + +// compare 16 packed unsigned bytes (less or equal) +static __forceinline __m128i _mm_cmple_epu8(__m128i A, __m128i B) +{ + // ((B xor 0x80) > (A xor 0x80)) || A == B + return _mm_or_si128(_mm_cmpgt_epu8(B, A), _mm_cmpeq_epi8(A, B)); +} diff --git a/Utilities/SMutex.cpp b/Utilities/SMutex.cpp index 684429b60e..e10296bd68 100644 --- a/Utilities/SMutex.cpp +++ b/Utilities/SMutex.cpp @@ -8,15 +8,3 @@ bool SM_IsAborted() { return Emu.IsStopped(); } - -void SM_Sleep() -{ - if (NamedThreadBase* t = GetCurrentNamedThread()) - { - t->WaitForAnySignal(); - } - else - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } -} diff --git a/Utilities/SMutex.h b/Utilities/SMutex.h index 88d22d7a68..5d50fe18e1 100644 --- a/Utilities/SMutex.h +++ b/Utilities/SMutex.h @@ -2,7 +2,6 @@ #include "Emu/Memory/atomic_type.h" bool SM_IsAborted(); -void SM_Sleep(); enum SMutexResult { @@ -20,8 +19,7 @@ template < typename T, const u64 free_value = 0, - const u64 dead_value = 0xffffffffffffffffull, - void (*wait)() = SM_Sleep + const u64 dead_value = 0xffffffffffffffffull > class SMutexBase { @@ -118,7 +116,7 @@ public: default: return res; } - if (wait != nullptr) wait(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (timeout && counter++ > timeout) { diff --git a/Utilities/SQueue.h b/Utilities/SQueue.h index 83d7adc3dd..7d140e3cdd 100644 --- a/Utilities/SQueue.h +++ b/Utilities/SQueue.h @@ -33,7 +33,7 @@ public: return false; } - SM_Sleep(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -60,7 +60,7 @@ public: return false; } - SM_Sleep(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -112,7 +112,7 @@ public: break; } - SM_Sleep(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index b24ad1036f..63f0e83078 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "Emu/System.h" #include "Log.h" #include "Thread.h" @@ -207,3 +208,58 @@ bool thread::joinable() const { return m_thr.joinable(); } + +bool waiter_map_t::is_stopped(u64 signal_id) +{ + if (Emu.IsStopped()) + { + LOG_WARNING(Log::HLE, "%s.waiter_op() aborted (signal_id=0x%llx)", m_name.c_str(), signal_id); + return true; + } + return false; +} + +waiter_map_t::waiter_reg_t::waiter_reg_t(waiter_map_t& map, u64 signal_id) + : signal_id(signal_id) + , thread(GetCurrentNamedThread()) + , map(map) +{ + std::lock_guard lock(map.m_mutex); + + // add waiter + map.m_waiters.push_back({ signal_id, thread }); +} + +waiter_map_t::waiter_reg_t::~waiter_reg_t() +{ + std::lock_guard lock(map.m_mutex); + + // remove waiter + for (size_t i = map.m_waiters.size() - 1; i >= 0; i--) + { + if (map.m_waiters[i].signal_id == signal_id && map.m_waiters[i].thread == thread) + { + map.m_waiters.erase(map.m_waiters.begin() + i); + return; + } + } + + LOG_ERROR(HLE, "%s(): waiter not found (signal_id=0x%llx, map='%s')", __FUNCTION__, signal_id, map.m_name.c_str()); + Emu.Pause(); +} + +void waiter_map_t::notify(u64 signal_id) +{ + if (!m_waiters.size()) return; + + std::lock_guard lock(m_mutex); + + // find waiter and signal + for (auto& v : m_waiters) + { + if (v.signal_id == signal_id) + { + v.thread->Notify(); + } + } +} diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 2566cdf43b..3e793c523d 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -69,4 +69,56 @@ public: void detach(); void join(); bool joinable() const; -}; \ No newline at end of file +}; + +class waiter_map_t +{ + // TODO: optimize (use custom lightweight readers-writer lock) + std::mutex m_mutex; + + struct waiter_t + { + u64 signal_id; + NamedThreadBase* thread; + }; + + std::vector m_waiters; + + std::string m_name; + + struct waiter_reg_t + { + const u64 signal_id; + NamedThreadBase* const thread; + waiter_map_t& map; + + waiter_reg_t(waiter_map_t& map, u64 signal_id); + ~waiter_reg_t(); + }; + + bool is_stopped(u64 signal_id); + +public: + waiter_map_t(const char* name) : m_name(name) {} + + // wait until waiter_func() returns true, signal_id is an arbitrary number + template __forceinline void wait_op(u64 signal_id, const WT waiter_func) + { + // check condition + if (waiter_func()) return; + + // register waiter + waiter_reg_t waiter(*this, signal_id); + + while (true) + { + // wait for 1 ms or until signal arrived + waiter.thread->WaitForAnySignal(1); + if (is_stopped(signal_id)) break; + if (waiter_func()) break; + } + } + + // signal all threads waiting on waiter_op() with the same signal_id (signaling only hints those threads that corresponding conditions are *probably* met) + void notify(u64 signal_id); +}; diff --git a/asmjit b/asmjit index 0cff228354..1318c9aff7 160000 --- a/asmjit +++ b/asmjit @@ -1 +1 @@ -Subproject commit 0cff228354124bd81050b949097282f78ad0e91a +Subproject commit 1318c9aff7137b30aec7dee2ababb2b313ae0f06 diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index fac66da910..fea5e15400 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -28,6 +28,7 @@ CPUThread::CPUThread(CPUThreadType type) , m_is_branch(false) , m_status(Stopped) , m_last_syscall(0) + , m_trace_enabled(false) { } @@ -298,7 +299,7 @@ void _se_translator(unsigned int u, EXCEPTION_POINTERS* pExp) void CPUThread::Task() { - if (Ini.HLELogging.GetValue()) LOG_NOTICE(PPU, "%s enter", CPUThread::GetFName().c_str()); + if (Ini.HLELogging.GetValue()) LOG_NOTICE(GENERAL, "%s enter", CPUThread::GetFName().c_str()); const std::vector& bp = Emu.GetBreakPoints(); @@ -337,7 +338,7 @@ void CPUThread::Task() } Step(); - //if (PC - 0x13ED4 < 0x288) trace.push_back(PC); + //if (m_trace_enabled) trace.push_back(PC); NextPc(m_dec->DecodeMemory(PC + m_offset)); if (status == CPUThread_Step) @@ -373,7 +374,25 @@ void CPUThread::Task() // TODO: linux version #endif - for (auto& v : trace) LOG_NOTICE(PPU, "PC = 0x%x", v); + if (trace.size()) + { + LOG_NOTICE(GENERAL, "Trace begin (%d elements)", trace.size()); - if (Ini.HLELogging.GetValue()) LOG_NOTICE(PPU, "%s leave", CPUThread::GetFName().c_str()); + u32 start = trace[0], prev = trace[0] - 4; + + for (auto& v : trace) //LOG_NOTICE(GENERAL, "PC = 0x%x", v); + { + if (v - prev != 4) + { + LOG_NOTICE(GENERAL, "Trace: 0x%08x .. 0x%08x", start, prev); + start = v; + } + prev = v; + } + + LOG_NOTICE(GENERAL, "Trace end: 0x%08x .. 0x%08x", start, prev); + } + + + if (Ini.HLELogging.GetValue()) LOG_NOTICE(GENERAL, "%s leave", CPUThread::GetFName().c_str()); } diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index e70007773c..3acb2c12b3 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -119,6 +119,7 @@ public: u32 nPC; u64 cycle; bool m_is_branch; + bool m_trace_enabled; bool m_is_interrupt; bool m_has_interrupt; diff --git a/rpcs3/Emu/CPU/CPUThreadManager.cpp b/rpcs3/Emu/CPU/CPUThreadManager.cpp index af9368f338..b745da0177 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.cpp +++ b/rpcs3/Emu/CPU/CPUThreadManager.cpp @@ -135,22 +135,6 @@ RawSPUThread* CPUThreadManager::GetRawSPUThread(u32 num) } } -void CPUThreadManager::NotifyThread(const u32 id) -{ - if (!id) return; - - std::lock_guard lock(m_mtx_thread); - - for (u32 i = 0; i < m_threads.size(); i++) - { - if (m_threads[i]->GetId() == id) - { - m_threads[i]->Notify(); - return; - } - } -} - void CPUThreadManager::Exec() { std::lock_guard lock(m_mtx_thread); diff --git a/rpcs3/Emu/CPU/CPUThreadManager.h b/rpcs3/Emu/CPU/CPUThreadManager.h index 480ef940f0..d43a7506c3 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.h +++ b/rpcs3/Emu/CPU/CPUThreadManager.h @@ -17,7 +17,6 @@ public: CPUThread& AddThread(CPUThreadType type); void RemoveThread(const u32 id); - void NotifyThread(const u32 id); std::vector& GetThreads() { return m_threads; } s32 GetThreadNumById(CPUThreadType type, u32 id); diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index 3e1925644e..7af886b969 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -2216,11 +2216,11 @@ private: { if (is_r) // rldcr { - RLDICR(ra, rs, (u32)CPU.GPR[rb] & 0x3F, m_eb, rc); + RLDICR(ra, rs, (u32)(CPU.GPR[rb] & 0x3F), m_eb, rc); } else // rldcl { - RLDICL(ra, rs, (u32)CPU.GPR[rb] & 0x3F, m_eb, rc); + RLDICL(ra, rs, (u32)(CPU.GPR[rb] & 0x3F), m_eb, rc); } } void CMP(u32 crfd, u32 l, u32 ra, u32 rb) @@ -2367,7 +2367,6 @@ private: } CPU.GPR[ra] = i; - if(rc) CPU.UpdateCR0(CPU.GPR[ra]); } void SLD(u32 ra, u32 rs, u32 rb, bool rc) diff --git a/rpcs3/Emu/Cell/SPUInterpreter.h b/rpcs3/Emu/Cell/SPUInterpreter.h index d903353991..7f88e6e3ec 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.h +++ b/rpcs3/Emu/Cell/SPUInterpreter.h @@ -251,10 +251,12 @@ private: } void BIZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } u32 target = branchTarget(CPU.GPR[ra]._u32[3], 0); @@ -270,10 +272,12 @@ private: } void BINZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } u32 target = branchTarget(CPU.GPR[ra]._u32[3], 0); @@ -289,10 +293,12 @@ private: } void BIHZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } u32 target = branchTarget(CPU.GPR[ra]._u32[3], 0); @@ -308,10 +314,12 @@ private: } void BIHNZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } u32 target = branchTarget(CPU.GPR[ra]._u32[3], 0); @@ -337,10 +345,12 @@ private: } void BI(u32 intr, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } u32 target = branchTarget(CPU.GPR[ra]._u32[3], 0); @@ -349,10 +359,12 @@ private: } void BISL(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } u32 target = branchTarget(CPU.GPR[ra]._u32[3], 0); diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index dafae1842b..82c2c287f6 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -9,64 +9,6 @@ using namespace asmjit::host; #define UNIMPLEMENTED() UNK(__FUNCTION__) -#define mmToU64Ptr(x) ((u64*)(&x)) -#define mmToU32Ptr(x) ((u32*)(&x)) -#define mmToU16Ptr(x) ((u16*)(&x)) -#define mmToU8Ptr(x) ((u8*)(&x)) - -struct g_imm_table_struct -{ - //u16 cntb_table[65536]; - - __m128i fsmb_table[65536]; - __m128i fsmh_table[256]; - __m128i fsm_table[16]; - - __m128i sldq_pshufb[32]; - __m128i srdq_pshufb[32]; - __m128i rldq_pshufb[16]; - - g_imm_table_struct() - { - /*static_assert(offsetof(g_imm_table_struct, cntb_table) == 0, "offsetof(cntb_table) != 0"); - for (u32 i = 0; i < sizeof(cntb_table) / sizeof(cntb_table[0]); i++) - { - u32 cnt_low = 0, cnt_high = 0; - for (u32 j = 0; j < 8; j++) - { - cnt_low += (i >> j) & 1; - cnt_high += (i >> (j + 8)) & 1; - } - cntb_table[i] = (cnt_high << 8) | cnt_low; - }*/ - for (u32 i = 0; i < sizeof(fsm_table) / sizeof(fsm_table[0]); i++) - { - - for (u32 j = 0; j < 4; j++) mmToU32Ptr(fsm_table[i])[j] = (i & (1 << j)) ? ~0 : 0; - } - for (u32 i = 0; i < sizeof(fsmh_table) / sizeof(fsmh_table[0]); i++) - { - for (u32 j = 0; j < 8; j++) mmToU16Ptr(fsmh_table[i])[j] = (i & (1 << j)) ? ~0 : 0; - } - for (u32 i = 0; i < sizeof(fsmb_table) / sizeof(fsmb_table[0]); i++) - { - for (u32 j = 0; j < 16; j++) mmToU8Ptr(fsmb_table[i])[j] = (i & (1 << j)) ? ~0 : 0; - } - for (u32 i = 0; i < sizeof(sldq_pshufb) / sizeof(sldq_pshufb[0]); i++) - { - for (u32 j = 0; j < 16; j++) mmToU8Ptr(sldq_pshufb[i])[j] = (u8)(j - i); - } - for (u32 i = 0; i < sizeof(srdq_pshufb) / sizeof(srdq_pshufb[0]); i++) - { - for (u32 j = 0; j < 16; j++) mmToU8Ptr(srdq_pshufb[i])[j] = (j + i > 15) ? 0xff : (u8)(j + i); - } - for (u32 i = 0; i < sizeof(rldq_pshufb) / sizeof(rldq_pshufb[0]); i++) - { - for (u32 j = 0; j < 16; j++) mmToU8Ptr(rldq_pshufb[i])[j] = (u8)(j - i) & 0xf; - } - } -}; - class SPURecompiler; class SPURecompilerCore : public CPUDecoder @@ -1132,10 +1074,12 @@ private: } void BIZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } c.mov(cpu_dword(PC), CPU.PC); @@ -1151,10 +1095,12 @@ private: } void BINZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } c.mov(cpu_dword(PC), CPU.PC); @@ -1170,10 +1116,12 @@ private: } void BIHZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } c.mov(cpu_dword(PC), CPU.PC); @@ -1189,10 +1137,12 @@ private: } void BIHNZ(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } c.mov(cpu_dword(PC), CPU.PC); @@ -1239,10 +1189,12 @@ private: } void BI(u32 intr, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } c.mov(cpu_dword(PC), CPU.PC); @@ -1255,10 +1207,12 @@ private: } void BISL(u32 intr, u32 rt, u32 ra) { - if (intr) + switch (intr) { - UNIMPLEMENTED(); - return; + case 0: break; + case 0x10: break; // enable interrupts + case 0x20: break; // disable interrupts + default: UNIMPLEMENTED(); return; } XmmInvalidate(rt); diff --git a/rpcs3/Emu/Cell/SPURecompilerCore.cpp b/rpcs3/Emu/Cell/SPURecompilerCore.cpp index 66c1181a34..c5edf35a7b 100644 --- a/rpcs3/Emu/Cell/SPURecompilerCore.cpp +++ b/rpcs3/Emu/Cell/SPURecompilerCore.cpp @@ -13,7 +13,7 @@ #include "SPUInterpreter.h" #include "SPURecompiler.h" -static const g_imm_table_struct g_imm_table; +const g_imm_table_struct g_imm_table; SPURecompilerCore::SPURecompilerCore(SPUThread& cpu) : m_enc(new SPURecompiler(cpu, *this)) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 04bb14b88f..5d069af957 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -1018,7 +1018,7 @@ void SPUThread::StopAndSignal(u32 code) case 0x003: { - GPR[3]._u32[3] = m_code3_func(*this); + GPR[3]._u64[1] = m_code3_func(*this); break; } @@ -1161,7 +1161,7 @@ void SPUThread::StopAndSignal(u32 code) { LOG_ERROR(Log::SPU, "Unknown STOP code: 0x%x (message=0x%x)", code, SPU.Out_MBox.GetValue()); } - Stop(); + Emu.Pause(); break; } } diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 8eef83d71f..5553d2fc28 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -105,6 +105,66 @@ enum SPU_RdSigNotify2_offs = 0x1C00C, }; +#define mmToU64Ptr(x) ((u64*)(&x)) +#define mmToU32Ptr(x) ((u32*)(&x)) +#define mmToU16Ptr(x) ((u16*)(&x)) +#define mmToU8Ptr(x) ((u8*)(&x)) + +struct g_imm_table_struct +{ + //u16 cntb_table[65536]; + + __m128i fsmb_table[65536]; + __m128i fsmh_table[256]; + __m128i fsm_table[16]; + + __m128i sldq_pshufb[32]; + __m128i srdq_pshufb[32]; + __m128i rldq_pshufb[16]; + + g_imm_table_struct() + { + /*static_assert(offsetof(g_imm_table_struct, cntb_table) == 0, "offsetof(cntb_table) != 0"); + for (u32 i = 0; i < sizeof(cntb_table) / sizeof(cntb_table[0]); i++) + { + u32 cnt_low = 0, cnt_high = 0; + for (u32 j = 0; j < 8; j++) + { + cnt_low += (i >> j) & 1; + cnt_high += (i >> (j + 8)) & 1; + } + cntb_table[i] = (cnt_high << 8) | cnt_low; + }*/ + for (u32 i = 0; i < sizeof(fsm_table) / sizeof(fsm_table[0]); i++) + { + + for (u32 j = 0; j < 4; j++) mmToU32Ptr(fsm_table[i])[j] = (i & (1 << j)) ? ~0 : 0; + } + for (u32 i = 0; i < sizeof(fsmh_table) / sizeof(fsmh_table[0]); i++) + { + for (u32 j = 0; j < 8; j++) mmToU16Ptr(fsmh_table[i])[j] = (i & (1 << j)) ? ~0 : 0; + } + for (u32 i = 0; i < sizeof(fsmb_table) / sizeof(fsmb_table[0]); i++) + { + for (u32 j = 0; j < 16; j++) mmToU8Ptr(fsmb_table[i])[j] = (i & (1 << j)) ? ~0 : 0; + } + for (u32 i = 0; i < sizeof(sldq_pshufb) / sizeof(sldq_pshufb[0]); i++) + { + for (u32 j = 0; j < 16; j++) mmToU8Ptr(sldq_pshufb[i])[j] = (u8)(j - i); + } + for (u32 i = 0; i < sizeof(srdq_pshufb) / sizeof(srdq_pshufb[0]); i++) + { + for (u32 j = 0; j < 16; j++) mmToU8Ptr(srdq_pshufb[i])[j] = (j + i > 15) ? 0xff : (u8)(j + i); + } + for (u32 i = 0; i < sizeof(rldq_pshufb) / sizeof(rldq_pshufb[0]); i++) + { + for (u32 j = 0; j < 16; j++) mmToU8Ptr(rldq_pshufb[i])[j] = (u8)(j - i) & 0xf; + } + } +}; + +extern const g_imm_table_struct g_imm_table; + //Floating point status and control register. Unsure if this is one of the GPRs or SPRs //Is 128 bits, but bits 0-19, 24-28, 32-49, 56-60, 64-81, 88-92, 96-115, 120-124 are unused class FPSCR @@ -451,7 +511,7 @@ public: void WriteLS128(const u32 lsa, const u128& data) const { vm::write128(lsa + m_offset, data); } std::function m_custom_task; - std::function m_code3_func; + std::function m_code3_func; public: SPUThread(CPUThreadType type = CPU_THREAD_SPU); diff --git a/rpcs3/Emu/Memory/atomic_type.h b/rpcs3/Emu/Memory/atomic_type.h index 35ebf639bd..7309f9cd2b 100644 --- a/rpcs3/Emu/Memory/atomic_type.h +++ b/rpcs3/Emu/Memory/atomic_type.h @@ -49,7 +49,7 @@ public: // atomically compare data with cmp, replace with exch if equal, return true if data was replaced __forceinline bool compare_and_swap_test(const T& cmp, const T& exch) volatile { - return InterlockedCompareExchange(&data, (atomic_type&)(exch), (atomic_type&)(cmp)) == (atomic_type&)(cmp); + return InterlockedCompareExchangeTest(&data, (atomic_type&)(exch), (atomic_type&)(cmp)); } // read data with memory barrier diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp index e761b90f65..0c65d26982 100644 --- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp @@ -90,7 +90,7 @@ std::string GLFragmentDecompilerThread::AddConst() return name; } - auto data = vm::ptr>::make(m_addr + m_size + m_offset); + auto data = vm::ptr::make(m_addr + m_size + m_offset); m_offset += 4 * 4; u32 x = GetData(data[0]); @@ -279,7 +279,7 @@ std::string GLFragmentDecompilerThread::BuildCode() void GLFragmentDecompilerThread::Task() { - auto data = vm::ptr>::make(m_addr); + auto data = vm::ptr::make(m_addr); m_size = 0; m_location = 0; m_loop_count = 0; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 509ff8b303..7bfc5daa6c 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -3,6 +3,7 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "Emu/RSX/GSManager.h" #include "RSXThread.h" #include "Emu/SysCalls/Callback.h" @@ -45,15 +46,40 @@ void RSXThread::nativeRescale(float width, float height) u32 GetAddress(u32 offset, u32 location) { + u32 res = 0; + switch(location) { - case CELL_GCM_LOCATION_LOCAL: return (u32)Memory.RSXFBMem.GetStartAddr() + offset; - case CELL_GCM_LOCATION_MAIN: return (u32)Memory.RSXIOMem.RealAddr(offset); // TODO: Error Check? + case CELL_GCM_LOCATION_LOCAL: + { + res = (u32)Memory.RSXFBMem.GetStartAddr() + offset; + break; + } + case CELL_GCM_LOCATION_MAIN: + { + res = (u32)Memory.RSXIOMem.RealAddr(offset); // TODO: Error Check? + if (res == 0) + { + LOG_ERROR(RSX, "GetAddress(offset=0x%x): RSXIO memory not mapped", offset); + Emu.Pause(); + break; + } + + if (Emu.GetGSManager().GetRender().m_strict_ordering[offset >> 20]) + { + _mm_mfence(); // probably doesn't have any effect on current implementation + } + break; + } + default: + { + LOG_ERROR(RSX, "GetAddress(offset=0x%x, location=0x%x): invalid location", offset, location); + Emu.Pause(); + break; + } } - LOG_ERROR(RSX, "GetAddress(offset=0x%x, location=0x%x)", location); - assert(0); - return 0; + return res; } RSXVertexData::RSXVertexData() @@ -144,7 +170,7 @@ u32 RSXVertexData::GetTypeSize() u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count, const u32 args_addr) { - auto args = vm::ptr>::make(args_addr); + auto args = vm::ptr::make(args_addr); std::string debug = GetMethodName(cmd); debug += "("; for(u32 i=0; i>::make(args_addr); + auto args = vm::ptr::make(args_addr); #if CMD_DEBUG std::string debug = GetMethodName(cmd); @@ -2234,19 +2260,19 @@ void RSXThread::Task() if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) { //LOG_WARNING(RSX, "non increment cmd! 0x%x", cmd); - inc=0; + inc = 0; } if(cmd == 0) { LOG_ERROR(Log::RSX, "null cmd: cmd=0x%x, put=0x%x, get=0x%x (addr=0x%x)", cmd, put, get, (u32)Memory.RSXIOMem.RealAddr(get)); - Emu.Pause(); - //HACK! We couldn't be here + //Emu.Pause(); + //HACK! We shouldn't be here m_ctrl->get = get + (count + 1) * 4; continue; } - auto args = vm::ptr>::make((u32)Memory.RSXIOMem.RealAddr(get + 4)); + auto args = vm::ptr::make((u32)Memory.RSXIOMem.RealAddr(get + 4)); for(u32 i=0; i type, vm::ptr attr) return CELL_OK; } -int cellAdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr> handle) +int cellAdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { cellAdec->Warning("cellAdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", type.addr(), res.addr(), cb.addr(), handle.addr()); @@ -617,7 +617,7 @@ int cellAdecOpen(vm::ptr type, vm::ptr res, vm:: return CELL_OK; } -int cellAdecOpenEx(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr> handle) +int cellAdecOpenEx(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { cellAdec->Warning("cellAdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", type.addr(), res.addr(), cb.addr(), handle.addr()); @@ -757,7 +757,7 @@ int cellAdecGetPcm(u32 handle, vm::ptr outBuffer) return CELL_OK; } -int cellAdecGetPcmItem(u32 handle, vm::ptr> pcmItem_ptr) +int cellAdecGetPcmItem(u32 handle, vm::ptr pcmItem_ptr) { cellAdec->Log("cellAdecGetPcmItem(handle=%d, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp index 6e9a72d357..d619d0ff9f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp @@ -6,7 +6,7 @@ Module *cellAtrac = nullptr; #include "cellAtrac.h" -int cellAtracSetDataAndGetMemSize(vm::ptr pHandle, u32 pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, vm::ptr> puiWorkMemByte) +int cellAtracSetDataAndGetMemSize(vm::ptr pHandle, u32 pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, vm::ptr puiWorkMemByte) { cellAtrac->Todo("cellAtracSetDataAndGetMemSize(pHandle=0x%x, pucBufferAddr=0x%x, uiReadByte=0x%x, uiBufferByte=0x%x, puiWorkMemByte_addr=0x%x)", pHandle.addr(), pucBufferAddr, uiReadByte, uiBufferByte, puiWorkMemByte.addr()); @@ -39,7 +39,7 @@ int cellAtracDeleteDecoder(vm::ptr pHandle) return CELL_OK; } -int cellAtracDecode(vm::ptr pHandle, u32 pfOutAddr, vm::ptr> puiSamples, vm::ptr> puiFinishflag, vm::ptr> piRemainFrame) +int cellAtracDecode(vm::ptr pHandle, u32 pfOutAddr, vm::ptr puiSamples, vm::ptr puiFinishflag, vm::ptr piRemainFrame) { cellAtrac->Todo("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()); @@ -50,7 +50,7 @@ int cellAtracDecode(vm::ptr pHandle, u32 pfOutAddr, vm::ptr pHandle, vm::ptr> ppucWritePointer, vm::ptr> puiWritableByte, vm::ptr> puiReadPosition) +int cellAtracGetStreamDataInfo(vm::ptr pHandle, vm::ptr ppucWritePointer, vm::ptr puiWritableByte, vm::ptr puiReadPosition) { cellAtrac->Todo("cellAtracGetStreamDataInfo(pHandle=0x%x, ppucWritePointer_addr=0x%x, puiWritableByte_addr=0x%x, puiReadPosition_addr=0x%x)", pHandle.addr(), ppucWritePointer.addr(), puiWritableByte.addr(), puiReadPosition.addr()); @@ -67,7 +67,7 @@ int cellAtracAddStreamData(vm::ptr pHandle, u32 uiAddByte) return CELL_OK; } -int cellAtracGetRemainFrame(vm::ptr pHandle, vm::ptr> piRemainFrame) +int cellAtracGetRemainFrame(vm::ptr pHandle, vm::ptr piRemainFrame) { cellAtrac->Todo("cellAtracGetRemainFrame(pHandle=0x%x, piRemainFrame_addr=0x%x)", pHandle.addr(), piRemainFrame.addr()); @@ -75,7 +75,7 @@ int cellAtracGetRemainFrame(vm::ptr pHandle, vm::ptr> return CELL_OK; } -int cellAtracGetVacantSize(vm::ptr pHandle, vm::ptr> puiVacantSize) +int cellAtracGetVacantSize(vm::ptr pHandle, vm::ptr puiVacantSize) { cellAtrac->Todo("cellAtracGetVacantSize(pHandle=0x%x, puiVacantSize_addr=0x%x)", pHandle.addr(), puiVacantSize.addr()); @@ -89,7 +89,7 @@ int cellAtracIsSecondBufferNeeded(vm::ptr pHandle) return CELL_OK; } -int cellAtracGetSecondBufferInfo(vm::ptr pHandle, vm::ptr> puiReadPosition, vm::ptr> puiDataByte) +int cellAtracGetSecondBufferInfo(vm::ptr pHandle, vm::ptr puiReadPosition, vm::ptr puiDataByte) { cellAtrac->Todo("cellAtracGetSecondBufferInfo(pHandle=0x%x, puiReadPosition_addr=0x%x, puiDataByte_addr=0x%x)", pHandle.addr(), puiReadPosition.addr(), puiDataByte.addr()); @@ -106,7 +106,7 @@ int cellAtracSetSecondBuffer(vm::ptr pHandle, u32 pucSecondBuff return CELL_OK; } -int cellAtracGetChannel(vm::ptr pHandle, vm::ptr> puiChannel) +int cellAtracGetChannel(vm::ptr pHandle, vm::ptr puiChannel) { cellAtrac->Todo("cellAtracGetChannel(pHandle=0x%x, puiChannel_addr=0x%x)", pHandle.addr(), puiChannel.addr()); @@ -114,7 +114,7 @@ int cellAtracGetChannel(vm::ptr pHandle, vm::ptr> pui return CELL_OK; } -int cellAtracGetMaxSample(vm::ptr pHandle, vm::ptr> puiMaxSample) +int cellAtracGetMaxSample(vm::ptr pHandle, vm::ptr puiMaxSample) { cellAtrac->Todo("cellAtracGetMaxSample(pHandle=0x%x, puiMaxSample_addr=0x%x)", pHandle.addr(), puiMaxSample.addr()); @@ -122,7 +122,7 @@ int cellAtracGetMaxSample(vm::ptr pHandle, vm::ptr> p return CELL_OK; } -int cellAtracGetNextSample(vm::ptr pHandle, vm::ptr> puiNextSample) +int cellAtracGetNextSample(vm::ptr pHandle, vm::ptr puiNextSample) { cellAtrac->Todo("cellAtracGetNextSample(pHandle=0x%x, puiNextSample_addr=0x%x)", pHandle.addr(), puiNextSample.addr()); @@ -130,7 +130,7 @@ int cellAtracGetNextSample(vm::ptr pHandle, vm::ptr> return CELL_OK; } -int cellAtracGetSoundInfo(vm::ptr pHandle, vm::ptr> piEndSample, vm::ptr> piLoopStartSample, vm::ptr> piLoopEndSample) +int cellAtracGetSoundInfo(vm::ptr pHandle, vm::ptr piEndSample, vm::ptr piLoopStartSample, vm::ptr piLoopEndSample) { cellAtrac->Todo("cellAtracGetSoundInfo(pHandle=0x%x, piEndSample_addr=0x%x, piLoopStartSample_addr=0x%x, piLoopEndSample_addr=0x%x)", pHandle.addr(), piEndSample.addr(), piLoopStartSample.addr(), piLoopEndSample.addr()); @@ -141,7 +141,7 @@ int cellAtracGetSoundInfo(vm::ptr pHandle, vm::ptr> p return CELL_OK; } -int cellAtracGetNextDecodePosition(vm::ptr pHandle, vm::ptr> puiSamplePosition) +int cellAtracGetNextDecodePosition(vm::ptr pHandle, vm::ptr puiSamplePosition) { cellAtrac->Todo("cellAtracGetNextDecodePosition(pHandle=0x%x, puiSamplePosition_addr=0x%x)", pHandle.addr(), puiSamplePosition.addr()); @@ -150,7 +150,7 @@ int cellAtracGetNextDecodePosition(vm::ptr pHandle, vm::ptr pHandle, vm::ptr> puiBitrate) +int cellAtracGetBitrate(vm::ptr pHandle, vm::ptr puiBitrate) { cellAtrac->Todo("cellAtracGetBitrate(pHandle=0x%x, puiBitrate_addr=0x%x)", pHandle.addr(), puiBitrate.addr()); @@ -159,7 +159,7 @@ int cellAtracGetBitrate(vm::ptr pHandle, vm::ptr> pui return CELL_OK; } -int cellAtracGetLoopInfo(vm::ptr pHandle, vm::ptr> piLoopNum, vm::ptr> puiLoopStatus) +int cellAtracGetLoopInfo(vm::ptr pHandle, vm::ptr piLoopNum, vm::ptr puiLoopStatus) { cellAtrac->Todo("cellAtracGetLoopInfo(pHandle=0x%x, piLoopNum_addr=0x%x, puiLoopStatus_addr=0x%x)", pHandle.addr(), piLoopNum.addr(), puiLoopStatus.addr()); @@ -194,7 +194,7 @@ int cellAtracResetPlayPosition(vm::ptr pHandle, u32 uiSample, u return CELL_OK; } -int cellAtracGetInternalErrorInfo(vm::ptr pHandle, vm::ptr> piResult) +int cellAtracGetInternalErrorInfo(vm::ptr pHandle, vm::ptr piResult) { cellAtrac->Todo("cellAtracGetInternalErrorInfo(pHandle=0x%x, piResult_addr=0x%x)", pHandle.addr(), piResult.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 262ae847aa..8ffb250aa3 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -385,7 +385,7 @@ int cellAudioInit() { std::lock_guard lock(audioMutex); // update indexes: - auto indexes = vm::ptr>::make(m_config.m_indexes); + auto indexes = vm::ptr::make(m_config.m_indexes); for (u32 i = 0; i < m_config.AUDIO_PORT_COUNT; i++) { if (!m_config.m_ports[i].m_is_audio_port_started) continue; @@ -505,7 +505,7 @@ int cellAudioQuit() return CELL_OK; } -int cellAudioPortOpen(vm::ptr audioParam, vm::ptr> portNum) +int cellAudioPortOpen(vm::ptr audioParam, vm::ptr portNum) { cellAudio->Warning("cellAudioPortOpen(audioParam_addr=0x%x, portNum_addr=0x%x)", audioParam.addr(), portNum.addr()); @@ -657,7 +657,7 @@ int cellAudioPortStop(u32 portNum) return CELL_OK; } -int cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr> stamp) +int cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr stamp) { cellAudio->Log("cellAudioGetPortTimestamp(portNum=0x%x, tag=0x%llx, stamp_addr=0x%x)", portNum, tag, stamp.addr()); @@ -685,7 +685,7 @@ int cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr> stamp) return CELL_OK; } -int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, vm::ptr> tag) +int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, vm::ptr tag) { cellAudio->Log("cellAudioGetPortBlockTag(portNum=0x%x, blockNo=0x%llx, tag_addr=0x%x)", portNum, blockNo, tag.addr()); @@ -736,7 +736,7 @@ int cellAudioSetPortLevel(u32 portNum, float level) } // Utility Functions -int cellAudioCreateNotifyEventQueue(vm::ptr> id, vm::ptr> key) +int cellAudioCreateNotifyEventQueue(vm::ptr id, vm::ptr key) { cellAudio->Warning("cellAudioCreateNotifyEventQueue(id_addr=0x%x, key_addr=0x%x)", id.addr(), key.addr()); @@ -764,7 +764,7 @@ int cellAudioCreateNotifyEventQueue(vm::ptr> id, vm::ptr> ke return CELL_OK; } -int cellAudioCreateNotifyEventQueueEx(vm::ptr> id, vm::ptr> key, u32 iFlags) +int cellAudioCreateNotifyEventQueueEx(vm::ptr id, vm::ptr key, u32 iFlags) { cellAudio->Todo("cellAudioCreateNotifyEventQueueEx(id_addr=0x%x, key_addr=0x%x, iFlags=0x%x)", id.addr(), key.addr(), iFlags); return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index 3e715a2dfb..410153cdbd 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -720,7 +720,7 @@ int cellDmuxQueryAttr2(vm::ptr demuxerType2, vm::ptr demuxerType, vm::ptr demuxerResource, - vm::ptr demuxerCb, vm::ptr> demuxerHandle) + vm::ptr demuxerCb, vm::ptr demuxerHandle) { cellDmux->Warning("cellDmuxOpen(demuxerType_addr=0x%x, demuxerResource_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", demuxerType.addr(), demuxerResource.addr(), demuxerCb.addr(), demuxerHandle.addr()); @@ -738,7 +738,7 @@ int cellDmuxOpen(vm::ptr demuxerType, vm::ptr demuxerType, vm::ptr demuxerResourceEx, - vm::ptr demuxerCb, vm::ptr> demuxerHandle) + vm::ptr demuxerCb, vm::ptr demuxerHandle) { cellDmux->Warning("cellDmuxOpenEx(demuxerType_addr=0x%x, demuxerResourceEx_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", demuxerType.addr(), demuxerResourceEx.addr(), demuxerCb.addr(), demuxerHandle.addr()); @@ -756,7 +756,7 @@ int cellDmuxOpenEx(vm::ptr demuxerType, vm::ptr demuxerType2, vm::ptr demuxerResource2, - vm::ptr demuxerCb, vm::ptr> demuxerHandle) + vm::ptr demuxerCb, vm::ptr demuxerHandle) { cellDmux->Warning("cellDmuxOpen2(demuxerType2_addr=0x%x, demuxerResource2_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)", demuxerType2.addr(), demuxerResource2.addr(), demuxerCb.addr(), demuxerHandle.addr()); @@ -923,7 +923,7 @@ int cellDmuxQueryEsAttr2(vm::ptr demuxerType2, vm::ptr esFilterId, vm::ptr esResourceInfo, vm::ptr esCb, - const u32 esSpecificInfo_addr, vm::ptr> esHandle) + const u32 esSpecificInfo_addr, vm::ptr esHandle) { cellDmux->Warning("cellDmuxEnableEs(demuxerHandle=%d, esFilterId_addr=0x%x, esResourceInfo_addr=0x%x, esCb_addr=0x%x, " "esSpecificInfo_addr=0x%x, esHandle_addr=0x%x)", demuxerHandle, esFilterId.addr(), esResourceInfo.addr(), @@ -992,7 +992,7 @@ int cellDmuxResetEs(u32 esHandle) return CELL_OK; } -int cellDmuxGetAu(u32 esHandle, vm::ptr> auInfo_ptr, vm::ptr> auSpecificInfo_ptr) +int cellDmuxGetAu(u32 esHandle, vm::ptr auInfo_ptr, vm::ptr auSpecificInfo_ptr) { cellDmux->Log("cellDmuxGetAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr()); @@ -1015,7 +1015,7 @@ int cellDmuxGetAu(u32 esHandle, vm::ptr> auInfo_ptr, vm::ptr return CELL_OK; } -int cellDmuxPeekAu(u32 esHandle, vm::ptr> auInfo_ptr, vm::ptr> auSpecificInfo_ptr) +int cellDmuxPeekAu(u32 esHandle, vm::ptr auInfo_ptr, vm::ptr auSpecificInfo_ptr) { cellDmux->Log("cellDmuxPeekAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr()); @@ -1038,7 +1038,7 @@ int cellDmuxPeekAu(u32 esHandle, vm::ptr> auInfo_ptr, vm::ptr> auInfoEx_ptr, vm::ptr> auSpecificInfo_ptr) +int cellDmuxGetAuEx(u32 esHandle, vm::ptr auInfoEx_ptr, vm::ptr auSpecificInfo_ptr) { cellDmux->Log("cellDmuxGetAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr()); @@ -1061,7 +1061,7 @@ int cellDmuxGetAuEx(u32 esHandle, vm::ptr> auInfoEx_ptr, vm::ptr> auInfoEx_ptr, vm::ptr> auSpecificInfo_ptr) +int cellDmuxPeekAuEx(u32 esHandle, vm::ptr auInfoEx_ptr, vm::ptr auSpecificInfo_ptr) { cellDmux->Log("cellDmuxPeekAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)", esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 010f69c9e7..59130605eb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -383,7 +383,7 @@ int cellFontGetEffectSlant(vm::ptr font, vm::ptr> slantPar return CELL_FONT_OK; } -int cellFontGetFontIdCode(vm::ptr font, u32 code, vm::ptr> fontId, vm::ptr> fontCode) +int cellFontGetFontIdCode(vm::ptr font, u32 code, vm::ptr fontId, vm::ptr fontCode) { cellFont->Todo("cellFontGetFontIdCode(font_addr=0x%x, code=0x%x, fontId_addr=0x%x, fontCode_addr=0x%x", font.addr(), code, fontId.addr(), fontCode.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 5d12d644fe..2e320f6a49 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -15,7 +15,7 @@ Module *cellGame = nullptr; std::string contentInfo = ""; std::string usrdir = ""; -int cellGameBootCheck(vm::ptr> type, vm::ptr> attributes, vm::ptr size, vm::ptr dirName) +int cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr size, vm::ptr dirName) { cellGame->Warning("cellGameBootCheck(type_addr=0x%x, attributes_addr=0x%x, size_addr=0x%x, dirName_addr=0x%x)", type.addr(), attributes.addr(), size.addr(), dirName.addr()); @@ -325,7 +325,7 @@ int cellGameDeleteGameData() return CELL_OK; } -int cellGameGetParamInt(u32 id, vm::ptr> value) +int cellGameGetParamInt(u32 id, vm::ptr value) { cellGame->Warning("cellGameGetParamInt(id=%d, value_addr=0x%x)", id, value.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 1200f9408b..31eae6d11c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -61,11 +61,11 @@ CellGcmOffsetTable offsetTable; void InitOffsetTable() { - offsetTable.ioAddress = (u32)Memory.Alloc(3072 * sizeof(u16), 1); - offsetTable.eaAddress = (u32)Memory.Alloc(512 * sizeof(u16), 1); + offsetTable.ioAddress.set(be_t::make((u32)Memory.Alloc(3072 * sizeof(u16), 1))); + offsetTable.eaAddress.set(be_t::make((u32)Memory.Alloc(512 * sizeof(u16), 1))); - memset(vm::get_ptr(offsetTable.ioAddress), 0xFF, 3072 * sizeof(u16)); - memset(vm::get_ptr(offsetTable.eaAddress), 0xFF, 512 * sizeof(u16)); + memset(offsetTable.ioAddress.get_ptr(), 0xFF, 3072 * sizeof(u16)); + memset(offsetTable.eaAddress.get_ptr(), 0xFF, 512 * sizeof(u16)); } //---------------------------------------------------------------------------- @@ -129,7 +129,7 @@ u32 cellGcmGetNotifyDataAddress(u32 index) cellGcmGetOffsetTable(table); // If entry not in use, return NULL - u16 entry = vm::read16(table->eaAddress + 241 * sizeof(u16)); + u16 entry = table->eaAddress[241]; if (entry == 0xFFFF) { return 0; } @@ -540,7 +540,9 @@ int cellGcmSetSecondVFrequency(u32 freq) switch (freq) { case CELL_GCM_DISPLAY_FREQUENCY_59_94HZ: + cellGcmSys->Todo("Unimplemented display frequency: 59.94Hz"); case CELL_GCM_DISPLAY_FREQUENCY_SCANOUT: + cellGcmSys->Todo("Unimplemented display frequency: Scanout"); case CELL_GCM_DISPLAY_FREQUENCY_DISABLE: Emu.GetGSManager().GetRender().m_frequency_mode = freq; break; @@ -814,7 +816,7 @@ s32 cellGcmAddressToOffset(u64 address, vm::ptr> offset) // Address in main memory else check else { - u16 upper12Bits = vm::read16(offsetTable.ioAddress + sizeof(u16)*(address >> 20)); + u16 upper12Bits = offsetTable.ioAddress[address >> 20]; // If the address is mapped in IO if (upper12Bits != 0xFFFF) { @@ -858,10 +860,8 @@ s32 cellGcmIoOffsetToAddress(u32 ioOffset, u64 address) return CELL_OK; } -s32 cellGcmMapEaIoAddress(u32 ea, u32 io, u32 size) +s32 gcmMapEaIoAddress(u32 ea, u32 io, u32 size, bool is_strict) { - cellGcmSys->Warning("cellGcmMapEaIoAddress(ea=0x%x, io=0x%x, size=0x%x)", ea, io, size); - if ((ea & 0xFFFFF) || (io & 0xFFFFF) || (size & 0xFFFFF)) return CELL_GCM_ERROR_FAILURE; // Check if the mapping was successfull @@ -870,8 +870,9 @@ s32 cellGcmMapEaIoAddress(u32 ea, u32 io, u32 size) // Fill the offset table for (u32 i = 0; i<(size >> 20); i++) { - vm::write16(offsetTable.ioAddress + ((ea >> 20) + i)*sizeof(u16), (io >> 20) + i); - vm::write16(offsetTable.eaAddress + ((io >> 20) + i)*sizeof(u16), (ea >> 20) + i); + offsetTable.ioAddress[(ea >> 20) + i] = (io >> 20) + i; + offsetTable.eaAddress[(io >> 20) + i] = (ea >> 20) + i; + Emu.GetGSManager().GetRender().m_strict_ordering[(io >> 20) + i] = is_strict; } } else @@ -883,10 +884,20 @@ s32 cellGcmMapEaIoAddress(u32 ea, u32 io, u32 size) return CELL_OK; } +s32 cellGcmMapEaIoAddress(u32 ea, u32 io, u32 size) +{ + cellGcmSys->Warning("cellGcmMapEaIoAddress(ea=0x%x, io=0x%x, size=0x%x)", ea, io, size); + + return gcmMapEaIoAddress(ea, io, size, false); +} + s32 cellGcmMapEaIoAddressWithFlags(u32 ea, u32 io, u32 size, u32 flags) { cellGcmSys->Warning("cellGcmMapEaIoAddressWithFlags(ea=0x%x, io=0x%x, size=0x%x, flags=0x%x)", ea, io, size, flags); - return cellGcmMapEaIoAddress(ea, io, size); // TODO: strict ordering + + assert(flags == 2 /*CELL_GCM_IOMAP_FLAG_STRICT_ORDERING*/); + + return gcmMapEaIoAddress(ea, io, size, true); } s32 cellGcmMapLocalMemory(u64 address, u64 size) @@ -910,7 +921,7 @@ s32 cellGcmMapLocalMemory(u64 address, u64 size) return CELL_OK; } -s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr> offset) +s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr offset) { cellGcmSys->Warning("cellGcmMapMainMemory(ea=0x%x,size=0x%x,offset_addr=0x%x)", ea, size, offset.addr()); @@ -919,13 +930,14 @@ s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr> offset) u32 io = Memory.RSXIOMem.Map(ea, size); //check if the mapping was successfull - if (Memory.RSXIOMem.Write32(io, 0)) + if (Memory.RSXIOMem.RealAddr(io) == ea) { //fill the offset table for (u32 i = 0; i<(size >> 20); i++) { - vm::write16(offsetTable.ioAddress + ((ea >> 20) + i) * sizeof(u16), (u16)(io >> 20) + i); - vm::write16(offsetTable.eaAddress + ((io >> 20) + i) * sizeof(u16), (u16)(ea >> 20) + i); + offsetTable.ioAddress[(ea >> 20) + i] = (u16)((io >> 20) + i); + offsetTable.eaAddress[(io >> 20) + i] = (u16)((ea >> 20) + i); + Emu.GetGSManager().GetRender().m_strict_ordering[(io >> 20) + i] = false; } *offset = io; @@ -970,12 +982,12 @@ s32 cellGcmUnmapEaIoAddress(u64 ea) { u64 io; ea = ea >> 20; - io = vm::read16(offsetTable.ioAddress + (ea*sizeof(u16))); + io = offsetTable.ioAddress[ea]; for (u32 i = 0; i> 20; - ea = vm::read16(offsetTable.eaAddress + (io*sizeof(u16))); + ea = offsetTable.eaAddress[io]; for (u32 i = 0; i ioAddress; // u16* - be_t eaAddress; // u16* + vm::bptr ioAddress; + vm::bptr eaAddress; }; // Auxiliary functions @@ -30,7 +30,7 @@ void cellGcmGetOffsetTable(vm::ptr table); s32 cellGcmIoOffsetToAddress(u32 ioOffset, u64 address); s32 cellGcmMapEaIoAddress(u32 ea, u32 io, u32 size); s32 cellGcmMapEaIoAddressWithFlags(u32 ea, u32 io, u32 size, u32 flags); -s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr> offset); +s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr offset); s32 cellGcmReserveIoMapSize(u32 size); s32 cellGcmUnmapEaIoAddress(u64 ea); s32 cellGcmUnmapIoAddress(u64 io); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp index 56c3c2ced9..d9f51ef96a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp @@ -21,36 +21,60 @@ cellGemInternal cellGemInstance; int cellGemCalibrate() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemClearStatusFlags() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemConvertVideoFinish() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemConvertVideoStart() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemEnableCameraPitchAngleCorrection() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemEnableMagnetometer() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } @@ -69,60 +93,100 @@ int cellGemEnd() int cellGemFilterState() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemForceRGB() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetAccelerometerPositionInDevice() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetAllTrackableHues() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetCameraState() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetEnvironmentLightingColor() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetHuePixels() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetImageState() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetInertialState() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetInfo() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } @@ -140,30 +204,50 @@ s32 cellGemGetMemorySize(be_t max_connect) int cellGemGetRGB() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetRumble() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetState() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetStatusFlags() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemGetTrackerHue() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } @@ -188,6 +272,10 @@ int cellGemInit(vm::ptr attribute) int cellGemInvalidateCalibration() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } @@ -200,54 +288,90 @@ int cellGemIsTrackableHue() int cellGemPrepareCamera() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemPrepareVideoConvert() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemReset() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemSetRumble() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemSetYaw() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemTrackHues() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemUpdateFinish() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemUpdateStart() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } int cellGemWriteExternalPort() { UNIMPLEMENTED_FUNC(cellGem); + + if (!cellGemInstance.m_bInitialized) + return CELL_GEM_ERROR_UNINITIALIZED; + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index c39f8ec181..db9da02789 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -21,7 +21,7 @@ int cellGifDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u return CELL_OK; } -int cellGifDecOpen(u32 mainHandle, vm::ptr> subHandle, vm::ptr src, vm::ptr openInfo) +int cellGifDecOpen(u32 mainHandle, vm::ptr subHandle, vm::ptr src, vm::ptr openInfo) { cellGifDec->Warning("cellGifDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)", mainHandle, subHandle.addr(), src.addr(), openInfo.addr()); @@ -39,7 +39,7 @@ int cellGifDecOpen(u32 mainHandle, vm::ptr> subHandle, vm::ptr> fd; - int ret = cellFsOpen(vm::ptr::make(src->fileName.addr()), 0, fd, vm::ptr>::make(0), 0); + int ret = cellFsOpen(vm::ptr::make(src->fileName.addr()), 0, fd, vm::ptr::make(0), 0); current_subHandle->fd = fd->ToLE(); if (ret != CELL_OK) return CELL_GIFDEC_ERROR_OPEN_FILE; diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index 7039b25c65..9ac73c1584 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -26,7 +26,7 @@ int cellJpgDecDestroy(u32 mainHandle) return CELL_OK; } -int cellJpgDecOpen(u32 mainHandle, vm::ptr> subHandle, vm::ptr src, vm::ptr openInfo) +int cellJpgDecOpen(u32 mainHandle, vm::ptr subHandle, vm::ptr src, vm::ptr openInfo) { cellJpgDec->Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)", mainHandle, subHandle.addr(), src.addr(), openInfo.addr()); @@ -45,7 +45,7 @@ int cellJpgDecOpen(u32 mainHandle, vm::ptr> subHandle, vm::ptr> fd; - int ret = cellFsOpen(vm::ptr::make(src->fileName.addr()), 0, fd, vm::ptr>::make(0), 0); + int ret = cellFsOpen(vm::ptr::make(src->fileName.addr()), 0, fd, vm::ptr::make(0), 0); current_subHandle->fd = fd->ToLE(); if (ret != CELL_OK) return CELL_JPGDEC_ERROR_OPEN_FILE; diff --git a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp index 6c06746ebb..60bae80ecc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp @@ -16,7 +16,7 @@ Module *cellL10n = nullptr; -int UTF16stoUTF8s(vm::lptrl utf16, vm::ptr> utf16_len, vm::ptr utf8, vm::ptr> utf8_len) +int UTF16stoUTF8s(vm::lptrl utf16, vm::ptr utf16_len, vm::ptr utf8, vm::ptr utf8_len) { cellL10n->Warning("UTF16stoUTF8s(utf16_addr=0x%x, utf16_len_addr=0x%x, utf8_addr=0x%x, utf8_len_addr=0x%x)", utf16.addr(), utf16_len.addr(), utf8.addr(), utf8_len.addr()); @@ -281,7 +281,7 @@ int _L10nConvertStr(int src_code, const void* src, size_t * src_len, int dst_cod #endif //TODO: Check the code in emulation. If support for UTF8/UTF16/UTF32/UCS2/UCS4 should use wider chars.. awful. -int L10nConvertStr(int src_code, vm::ptr src, vm::ptr> src_len, int dst_code, vm::ptr dst, vm::ptr> dst_len) +int L10nConvertStr(int src_code, vm::ptr src, vm::ptr src_len, int dst_code, vm::ptr dst, vm::ptr dst_len) { cellL10n->Error("L10nConvertStr(src_code=%d, srca_addr=0x%x, src_len_addr=0x%x, dst_code=%d, dst_addr=0x%x, dst_len_addr=0x%x)", src_code, src.addr(), src_len.addr(), dst_code, dst.addr(), dst_len.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMic.cpp b/rpcs3/Emu/SysCalls/Modules/cellMic.cpp index a3a665f55e..6841e37ccf 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMic.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMic.cpp @@ -1,40 +1,45 @@ #include "stdafx.h" -#if 0 +#include "Emu/Memory/Memory.h" +#include "Emu/System.h" +#include "Emu/SysCalls/Modules.h" -void cellMic_init(); -Module cellMic(0x0022, cellMic_init); +#include "cellMic.h" -// Error Codes -enum +Module *cellMic = nullptr; + +struct cellMicInternal { - CELL_MICIN_ERROR_ALREADY_INIT = 0x80140101, - CELL_MICIN_ERROR_SYSTEM = 0x80140102, - CELL_MICIN_ERROR_NOT_INIT = 0x80140103, - CELL_MICIN_ERROR_PARAM = 0x80140104, - CELL_MICIN_ERROR_PORT_FULL = 0x80140105, - CELL_MICIN_ERROR_ALREADY_OPEN = 0x80140106, - CELL_MICIN_ERROR_NOT_OPEN = 0x80140107, - CELL_MICIN_ERROR_NOT_RUN = 0x80140108, - CELL_MICIN_ERROR_TRANS_EVENT = 0x80140109, - CELL_MICIN_ERROR_OPEN = 0x8014010a, - CELL_MICIN_ERROR_SHAREDMEMORY = 0x8014010b, - CELL_MICIN_ERROR_MUTEX = 0x8014010c, - CELL_MICIN_ERROR_EVENT_QUEUE = 0x8014010d, - CELL_MICIN_ERROR_DEVICE_NOT_FOUND = 0x8014010e, - CELL_MICIN_ERROR_SYSTEM_NOT_FOUND = 0x8014010e, - CELL_MICIN_ERROR_FATAL = 0x8014010f, - CELL_MICIN_ERROR_DEVICE_NOT_SUPPORT = 0x80140110, + bool m_bCellMicInitialized;; + + cellMicInternal() + : m_bCellMicInitialized(false) + { + } }; +cellMicInternal CellMicInstance; + int cellMicInit() { - UNIMPLEMENTED_FUNC(cellMic); + cellMic->Warning("cellMicInit()"); + + if (CellMicInstance.m_bCellMicInitialized) + return CELL_MICIN_ERROR_ALREADY_INIT; + + CellMicInstance.m_bCellMicInitialized = true; + return CELL_OK; } int cellMicEnd() { - UNIMPLEMENTED_FUNC(cellMic); + cellMic->Warning("cellMicEnd()"); + + if (!CellMicInstance.m_bCellMicInitialized) + return CELL_MICIN_ERROR_NOT_INIT; + + CellMicInstance.m_bCellMicInitialized = false; + return CELL_OK; } @@ -278,54 +283,60 @@ int cellMicGetDeviceIdentifier() return CELL_OK; } -void cellMic_init() +void cellMic_unload() { - cellMic.AddFunc(0x8325e02d, cellMicInit); - cellMic.AddFunc(0xc6328caa, cellMicEnd); - cellMic.AddFunc(0xdd1b59f0, cellMicOpen); - cellMic.AddFunc(0x8d229f8e, cellMicClose); - - cellMic.AddFunc(0x017024a8, cellMicGetDeviceGUID); - cellMic.AddFunc(0xa52d2ae4, cellMicGetType); - cellMic.AddFunc(0x1b42101b, cellMicIsAttached); - cellMic.AddFunc(0x186cb1fb, cellMicIsOpen); - cellMic.AddFunc(0x6a024aa0, cellMicGetDeviceAttr); - cellMic.AddFunc(0xb2c16321, cellMicSetDeviceAttr); - cellMic.AddFunc(0xac5ba03a, cellMicGetSignalAttr); - cellMic.AddFunc(0x323deb41, cellMicSetSignalAttr); - cellMic.AddFunc(0xb30780eb, cellMicGetSignalState); - - cellMic.AddFunc(0xdd724314, cellMicStart); - cellMic.AddFunc(0x07e1b12c, cellMicRead); - cellMic.AddFunc(0xfcfaf246, cellMicStop); - cellMic.AddFunc(0x6bc46aab, cellMicReset); - - cellMic.AddFunc(0x7903400e, cellMicSetNotifyEventQueue); - cellMic.AddFunc(0x6cc7ae00, cellMicSetNotifyEventQueue2); - cellMic.AddFunc(0x65336418, cellMicRemoveNotifyEventQueue); - - cellMic.AddFunc(0x05709bbf, cellMicOpenEx); - cellMic.AddFunc(0xddd19a89, cellMicStartEx); - cellMic.AddFunc(0x4e0b69ee, cellMicGetFormatRaw); - cellMic.AddFunc(0xfda12276, cellMicGetFormatAux); - cellMic.AddFunc(0x87a08d29, cellMicGetFormatDsp); - cellMic.AddFunc(0xa42ac07a, cellMicOpenRaw); - cellMic.AddFunc(0x72165a7f, cellMicReadRaw); - cellMic.AddFunc(0x3acc118e, cellMicReadAux); - cellMic.AddFunc(0xc414faa5, cellMicReadDsp); - - cellMic.AddFunc(0x25c5723f, cellMicGetStatus); - cellMic.AddFunc(0xe839380f, cellMicStopEx); - cellMic.AddFunc(0x3ace58f3, cellMicSysShareClose); - cellMic.AddFunc(0x48108a23, cellMicGetFormat); - cellMic.AddFunc(0x891c6291, cellMicSetMultiMicNotifyEventQueue); - cellMic.AddFunc(0xad049ecf, cellMicGetFormatEx); - cellMic.AddFunc(0xbdfd51e2, cellMicSysShareStop); - cellMic.AddFunc(0xc3610dbd, cellMicSysShareOpen); - cellMic.AddFunc(0xc461563c, cellMicCommand); - cellMic.AddFunc(0xcac7e7d7, cellMicSysShareStart); - cellMic.AddFunc(0xd127cd3e, cellMicSysShareInit); - cellMic.AddFunc(0xf82bbf7c, cellMicSysShareEnd); - cellMic.AddFunc(0xfdbbe469, cellMicGetDeviceIdentifier); + CellMicInstance.m_bCellMicInitialized = false; +} + +void cellMic_init(Module *pxThis) +{ + cellMic = pxThis; + + cellMic->AddFunc(0x8325e02d, cellMicInit); + cellMic->AddFunc(0xc6328caa, cellMicEnd); + cellMic->AddFunc(0xdd1b59f0, cellMicOpen); + cellMic->AddFunc(0x8d229f8e, cellMicClose); + + cellMic->AddFunc(0x017024a8, cellMicGetDeviceGUID); + cellMic->AddFunc(0xa52d2ae4, cellMicGetType); + cellMic->AddFunc(0x1b42101b, cellMicIsAttached); + cellMic->AddFunc(0x186cb1fb, cellMicIsOpen); + cellMic->AddFunc(0x6a024aa0, cellMicGetDeviceAttr); + cellMic->AddFunc(0xb2c16321, cellMicSetDeviceAttr); + cellMic->AddFunc(0xac5ba03a, cellMicGetSignalAttr); + cellMic->AddFunc(0x323deb41, cellMicSetSignalAttr); + cellMic->AddFunc(0xb30780eb, cellMicGetSignalState); + + cellMic->AddFunc(0xdd724314, cellMicStart); + cellMic->AddFunc(0x07e1b12c, cellMicRead); + cellMic->AddFunc(0xfcfaf246, cellMicStop); + cellMic->AddFunc(0x6bc46aab, cellMicReset); + + cellMic->AddFunc(0x7903400e, cellMicSetNotifyEventQueue); + cellMic->AddFunc(0x6cc7ae00, cellMicSetNotifyEventQueue2); + cellMic->AddFunc(0x65336418, cellMicRemoveNotifyEventQueue); + + cellMic->AddFunc(0x05709bbf, cellMicOpenEx); + cellMic->AddFunc(0xddd19a89, cellMicStartEx); + cellMic->AddFunc(0x4e0b69ee, cellMicGetFormatRaw); + cellMic->AddFunc(0xfda12276, cellMicGetFormatAux); + cellMic->AddFunc(0x87a08d29, cellMicGetFormatDsp); + cellMic->AddFunc(0xa42ac07a, cellMicOpenRaw); + cellMic->AddFunc(0x72165a7f, cellMicReadRaw); + cellMic->AddFunc(0x3acc118e, cellMicReadAux); + cellMic->AddFunc(0xc414faa5, cellMicReadDsp); + + cellMic->AddFunc(0x25c5723f, cellMicGetStatus); + cellMic->AddFunc(0xe839380f, cellMicStopEx); + cellMic->AddFunc(0x3ace58f3, cellMicSysShareClose); + cellMic->AddFunc(0x48108a23, cellMicGetFormat); + cellMic->AddFunc(0x891c6291, cellMicSetMultiMicNotifyEventQueue); + cellMic->AddFunc(0xad049ecf, cellMicGetFormatEx); + cellMic->AddFunc(0xbdfd51e2, cellMicSysShareStop); + cellMic->AddFunc(0xc3610dbd, cellMicSysShareOpen); + cellMic->AddFunc(0xc461563c, cellMicCommand); + cellMic->AddFunc(0xcac7e7d7, cellMicSysShareStart); + cellMic->AddFunc(0xd127cd3e, cellMicSysShareInit); + cellMic->AddFunc(0xf82bbf7c, cellMicSysShareEnd); + cellMic->AddFunc(0xfdbbe469, cellMicGetDeviceIdentifier); } -#endif diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index 53cf172f63..9ba08b4753 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -91,8 +91,8 @@ int cellMsgDialogOpen2(u32 type, vm::ptr msgString, vm::ptr msgString, vm::ptr s32 + s32 status = (s32)g_msg_dialog_status; + Emu.GetCallbackManager().Register([callback, userData, status]() -> s32 { - callback((s32)g_msg_dialog_status, userData); + callback(status, userData); return CELL_OK; }); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h index 11b6695518..4cb89a6962 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h @@ -257,4 +257,4 @@ struct CellNetCtlNatInfo be_t mapped_addr; }; -typedef void(*cellNetCtlHandler)(s32 prev_state, s32 new_state, s32 event, s32 error_code, vm::ptr> arg); +typedef void(*cellNetCtlHandler)(s32 prev_state, s32 new_state, s32 event, s32 error_code, vm::ptr arg); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp index ae5095c809..93438d8029 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp @@ -124,7 +124,7 @@ u8 pamfGetStreamChannel(vm::ptr pSelf, u8 stream) } -int cellPamfGetHeaderSize(vm::ptr pAddr, u64 fileSize, vm::ptr> pSize) +int cellPamfGetHeaderSize(vm::ptr pAddr, u64 fileSize, vm::ptr pSize) { cellPamf->Warning("cellPamfGetHeaderSize(pAddr=0x%x, fileSize=%d, pSize_addr=0x%x)", pAddr.addr(), fileSize, pSize.addr()); @@ -136,7 +136,7 @@ int cellPamfGetHeaderSize(vm::ptr pAddr, u64 fileSize, vm::ptr pAddr, u64 fileSize, u32 attribute, vm::ptr> pSize) +int cellPamfGetHeaderSize2(vm::ptr pAddr, u64 fileSize, u32 attribute, vm::ptr pSize) { cellPamf->Warning("cellPamfGetHeaderSize2(pAddr=0x%x, fileSize=%d, attribute=0x%x, pSize_addr=0x%x)", pAddr.addr(), fileSize, attribute, pSize.addr()); @@ -148,7 +148,7 @@ int cellPamfGetHeaderSize2(vm::ptr pAddr, u64 fileSize, u32 attribut return CELL_OK; } -int cellPamfGetStreamOffsetAndSize(vm::ptr pAddr, u64 fileSize, vm::ptr> pOffset, vm::ptr> pSize) +int cellPamfGetStreamOffsetAndSize(vm::ptr pAddr, u64 fileSize, vm::ptr pOffset, vm::ptr pSize) { cellPamf->Warning("cellPamfGetStreamOffsetAndSize(pAddr=0x%x, fileSize=%d, pOffset_addr=0x%x, pSize_addr=0x%x)", pAddr.addr(), fileSize, pOffset.addr(), pSize.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index 609096d59c..9abe3d29c8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -84,7 +84,7 @@ s32 pngDecOpen( case se32(CELL_PNGDEC_FILE): // Get file descriptor vm::var> fd; - int ret = cellFsOpen(vm::ptr::make(src->fileName.addr()), 0, fd, vm::ptr>::make(0), 0); + int ret = cellFsOpen(vm::ptr::make(src->fileName.addr()), 0, fd, vm::ptr::make(0), 0); stream->fd = fd->ToLE(); if (ret != CELL_OK) return CELL_PNGDEC_ERROR_OPEN_FILE; @@ -804,7 +804,7 @@ void cellPngDec_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { - libpngdec = (u32)Memory.PRXMem.AllocAlign(sizeof(libpngdec_data), 4096); + 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/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 8c7961e5b1..c87eb12b6d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -620,7 +620,7 @@ void cellRescExit() s_rescInternalInstance->m_bInitialized = false; } -int cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, vm::ptr> bufferMode) +int cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, vm::ptr bufferMode) { cellResc->Log("cellRescVideoOutResolutionId2RescBufferMode(resolutionId=%d, bufferMode_addr=0x%x)", resolutionId, bufferMode.addr()); @@ -858,7 +858,7 @@ int cellRescSetPalInterpolateDropFlexRatio(float ratio) return CELL_OK; } -int cellRescGetBufferSize(vm::ptr> colorBuffers, vm::ptr> vertexArray, vm::ptr> fragmentShader) +int cellRescGetBufferSize(vm::ptr colorBuffers, vm::ptr vertexArray, vm::ptr fragmentShader) { cellResc->Warning("cellRescGetBufferSize(colorBuffers_addr=0x%x, vertexArray_addr=0x%x, fragmentShader_addr=0x%x)", colorBuffers.addr(), vertexArray.addr(), fragmentShader.addr()); @@ -1029,7 +1029,7 @@ int cellRescSetWaitFlip() return CELL_OK; } -int cellRescSetBufferAddress(vm::ptr> colorBuffers, vm::ptr> vertexArray, vm::ptr> fragmentShader) +int cellRescSetBufferAddress(vm::ptr colorBuffers, vm::ptr vertexArray, vm::ptr fragmentShader) { cellResc->Warning("cellRescSetBufferAddress(colorBuffers_addr=0x%x, vertexArray_addr=0x%x, fragmentShader_addr=0x%x)", colorBuffers.addr(), vertexArray.addr(), fragmentShader.addr()); @@ -1169,8 +1169,8 @@ int CreateInterlaceTable(u32 ea_addr, float srcH, float dstH, CellRescTableEleme float bandwidth = 0.5f / (srcH / dstH); float phi_b = 2.f * PI * bandwidth; float window[4]; - auto buf16 = vm::ptr>::make(ea_addr); - auto buf32 = vm::ptr>::make(ea_addr); + auto buf16 = vm::ptr::make(ea_addr); + auto buf32 = vm::ptr::make(ea_addr); blackman(window); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp index 99f281514c..aae606a4d1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp @@ -310,7 +310,7 @@ int cellRtcConvertLocalTimeToUtc(vm::ptr pLocalTime, vm::ptr pDateTime, vm::ptr> puiDosTime) +int cellRtcGetDosTime(vm::ptr pDateTime, vm::ptr puiDosTime) { cellRtc->Log("cellRtcGetDosTime(pDateTime=0x%x, puiDosTime=0x%x)", pDateTime.addr(), puiDosTime.addr()); @@ -321,7 +321,7 @@ int cellRtcGetDosTime(vm::ptr pDateTime, vm::ptr> pui return CELL_OK; } -int cellRtcGetTime_t(vm::ptr pDateTime, vm::ptr> piTime) +int cellRtcGetTime_t(vm::ptr pDateTime, vm::ptr piTime) { cellRtc->Log("cellRtcGetTime_t(pDateTime=0x%x, piTime=0x%x)", pDateTime.addr(), piTime.addr()); @@ -333,7 +333,7 @@ int cellRtcGetTime_t(vm::ptr pDateTime, vm::ptr> piTi return CELL_OK; } -int cellRtcGetWin32FileTime(vm::ptr pDateTime, vm::ptr> pulWin32FileTime) +int cellRtcGetWin32FileTime(vm::ptr pDateTime, vm::ptr pulWin32FileTime) { cellRtc->Log("cellRtcGetWin32FileTime(pDateTime=0x%x, pulWin32FileTime=0x%x)", pDateTime.addr(), pulWin32FileTime.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp index 409535dd88..262eca19b1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp @@ -6,9 +6,12 @@ Module *cellSail = nullptr; -int cellSailMemAllocatorInitialize() +int cellSailMemAllocatorInitialize(vm::ptr pSelf, vm::ptr pCallbacks) { - UNIMPLEMENTED_FUNC(cellSail); + cellSail->Warning("cellSailMemAllocatorInitialize(pSelf_addr=0x%x, pCallbacks_addr=0x%x)", pSelf.addr(), pCallbacks.addr()); + + pSelf->callbacks = pCallbacks; + return CELL_OK; } @@ -66,16 +69,19 @@ int cellSailDescriptorGetMediaInfo() return CELL_OK; } -int cellSailDescriptorSetAutoSelection() +int cellSailDescriptorSetAutoSelection(vm::ptr pSelf, bool autoSelection) { - UNIMPLEMENTED_FUNC(cellSail); - return CELL_OK; + cellSail->Todo("cellSailDescriptorSetAutoSelection(pSelf_addr=0x%x, autoSelection=%b)", pSelf.addr(), autoSelection); + + pSelf->autoSelection = autoSelection; + + return autoSelection; } -int cellSailDescriptorIsAutoSelection() +int cellSailDescriptorIsAutoSelection(vm::ptr pSelf) { - UNIMPLEMENTED_FUNC(cellSail); - return CELL_OK; + cellSail->Warning("cellSailDescriptorIsAutoSelection(pSelf_addr=0x%x)", pSelf.addr()); + return pSelf->autoSelection; } int cellSailDescriptorCreateDatabase() @@ -486,9 +492,18 @@ int cellSailPlayerInitialize() return CELL_OK; } -int cellSailPlayerInitialize2() +int cellSailPlayerInitialize2(vm::ptr pSelf, vm::ptr pAllocator, vm::ptr pCallback, u64 callbackArg, + vm::ptr pAttribute, vm::ptr pResource) { - UNIMPLEMENTED_FUNC(cellSail); + cellSail->Warning("cellSailPlayerInitialize2(pSelf_addr=0x%x, pAllocator_addr=0x%x, pCallback=0x%x, callbackArg=%d, pAttribute_addr=0x%x, pResource=0x%x)", pSelf.addr(), + pAllocator.addr(), pCallback.addr(), callbackArg, pAttribute.addr(), pResource.addr()); + + pSelf->allocator = pAllocator; + pSelf->callback = pCallback; + pSelf->callbackArgument = callbackArg; + pSelf->attribute = pAttribute; + pSelf->resource = pResource; + return CELL_OK; } @@ -576,34 +591,76 @@ int cellSailPlayerBoot() return CELL_OK; } -int cellSailPlayerCreateDescriptor() +int cellSailPlayerAddDescriptor(vm::ptr pSelf, vm::ptr pDesc) { - UNIMPLEMENTED_FUNC(cellSail); + cellSail->Warning("cellSailPlayerAddDescriptor(pSelf_addr=0x%x, pDesc_addr=0x%x)", pSelf.addr(), pDesc.addr()); + + if (pSelf->descriptors < 3) + { + pSelf->descriptors++; + pSelf->registeredDescriptors[pSelf->descriptors] = pDesc; + pDesc->registered = true; + } + else + { + cellSail->Error("Descriptor limit reached! This should never happen, report this to a developer."); + } + return CELL_OK; } -int cellSailPlayerDestroyDescriptor() +int cellSailPlayerCreateDescriptor(vm::ptr pSelf, s32 streamType, vm::ptr pMediaInfo, vm::ptr pUri, vm::ptr ppDesc) { - UNIMPLEMENTED_FUNC(cellSail); + cellSail->Todo("cellSailPlayerCreateDescriptor(pSelf_addr=0x%x, streamType=%d, pMediaInfo_addr=0x%x, pUri_addr=0x%x, ppDesc_addr=0x%x)", pSelf.addr(), streamType, + pMediaInfo.addr(), pUri.addr(), ppDesc.addr()); + + // TODO: Let the game allocate memory for the descriptor, setup the descriptor and pass it back to the game + + //CellSailDescriptor *pDesc = new CellSailDescriptor(); + //u32 descriptorAddress = pSelf->allocator->callbacks->pAlloc(pSelf->allocator->pArg, 4, descriptorAddress); + //cellSail->Error("Address: 0x%x", descriptorAddress); + //vm::ptr descriptor = vm::ptr::make(Memory.RealToVirtualAddr(&descriptorAddress)); + //descriptor->streamType = streamType; + //descriptor->registered = false; + + pSelf->descriptors = 0; + pSelf->repeatMode = 0; + //ppDesc = descriptor; + + //cellSail->Todo("pSelf_addr=0x%x, pDesc_addr=0x%x", pSelf.addr(), descriptor.addr()); + //cellSailPlayerAddDescriptor(pSelf, ppDesc); + return CELL_OK; } -int cellSailPlayerAddDescriptor() +int cellSailPlayerDestroyDescriptor(vm::ptr pSelf, vm::ptr pDesc) { - UNIMPLEMENTED_FUNC(cellSail); + cellSail->Todo("cellSailPlayerAddDescriptor(pSelf_addr=0x%x, pDesc_addr=0x%x)", pSelf.addr(), pDesc.addr()); + + if (pDesc->registered) + return CELL_SAIL_ERROR_INVALID_STATE; + return CELL_OK; } -int cellSailPlayerRemoveDescriptor() +int cellSailPlayerRemoveDescriptor(vm::ptr pSelf, vm::ptr ppDesc) { - UNIMPLEMENTED_FUNC(cellSail); - return CELL_OK; + cellSail->Warning("cellSailPlayerAddDescriptor(pSelf_addr=0x%x, pDesc_addr=0x%x)", pSelf.addr(), ppDesc.addr()); + + if (pSelf->descriptors > 0) + { + ppDesc = pSelf->registeredDescriptors[pSelf->descriptors]; + delete &pSelf->registeredDescriptors[pSelf->descriptors]; + pSelf->descriptors--; + } + + return pSelf->descriptors; } -int cellSailPlayerGetDescriptorCount() +int cellSailPlayerGetDescriptorCount(vm::ptr pSelf) { - UNIMPLEMENTED_FUNC(cellSail); - return CELL_OK; + cellSail->Warning("cellSailPlayerGetDescriptorCount(pSelf_addr=0x%x)", pSelf.addr()); + return pSelf->descriptors; } int cellSailPlayerGetCurrentDescriptor() @@ -714,16 +771,23 @@ int cellSailPlayerIsPaused() return CELL_OK; } -int cellSailPlayerSetRepeatMode() +int cellSailPlayerSetRepeatMode(vm::ptr pSelf, s32 repeatMode, vm::ptr pCommand) { - UNIMPLEMENTED_FUNC(cellSail); - return CELL_OK; + cellSail->Warning("cellSailPlayerSetRepeatMode(pSelf_addr=0x%x, repeatMode=%i, pCommand_addr=0x%x)", pSelf.addr(), repeatMode, pCommand.addr()); + + pSelf->repeatMode = repeatMode; + pSelf->playbackCommand = pCommand; + + return pSelf->repeatMode; } -int cellSailPlayerGetRepeatMode() +int cellSailPlayerGetRepeatMode(vm::ptr pSelf, vm::ptr pCommand) { - UNIMPLEMENTED_FUNC(cellSail); - return CELL_OK; + cellSail->Warning("cellSailPlayerGetRepeatMode(pSelf_addr=0x%x, pCommand_addr=0x%x)", pSelf.addr(), pCommand.addr()); + + pCommand = pSelf->playbackCommand; + + return pSelf->repeatMode; } int cellSailPlayerSetEsAudioMuted() diff --git a/rpcs3/Emu/SysCalls/Modules/cellSail.h b/rpcs3/Emu/SysCalls/Modules/cellSail.h index 55dc556dc3..18c244ab3a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSail.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSail.h @@ -17,6 +17,519 @@ enum CELL_SAIL_ERROR_FATAL = 0x806107FF, }; +// Call types +enum { + CELL_SAIL_PLAYER_CALL_NONE = 0, + CELL_SAIL_PLAYER_CALL_BOOT = 1, + CELL_SAIL_PLAYER_CALL_OPEN_STREAM = 2, + CELL_SAIL_PLAYER_CALL_CLOSE_STREAM = 3, + CELL_SAIL_PLAYER_CALL_OPEN_ES_AUDIO = 4, + CELL_SAIL_PLAYER_CALL_OPEN_ES_VIDEO = 5, + CELL_SAIL_PLAYER_CALL_OPEN_ES_USER = 6, + CELL_SAIL_PLAYER_CALL_CLOSE_ES_AUDIO = 7, + CELL_SAIL_PLAYER_CALL_CLOSE_ES_VIDEO = 8, + CELL_SAIL_PLAYER_CALL_CLOSE_ES_USER = 9, + CELL_SAIL_PLAYER_CALL_START = 10, + CELL_SAIL_PLAYER_CALL_STOP = 11, + CELL_SAIL_PLAYER_CALL_NEXT = 12, + CELL_SAIL_PLAYER_CALL_REOPEN_ES_AUDIO = 13, + CELL_SAIL_PLAYER_CALL_REOPEN_ES_VIDEO = 14, + CELL_SAIL_PLAYER_CALL_REOPEN_ES_USER = 15, + + _CELL_SAIL_PLAYER_CALL_TYPE_NUM_OF_ELEMENTS = 16, // Never used? +}; + +// State types +enum { + CELL_SAIL_PLAYER_STATE_INITIALIZED = 0, + CELL_SAIL_PLAYER_STATE_BOOT_TRANSITION = 1, + CELL_SAIL_PLAYER_STATE_CLOSED = 2, + CELL_SAIL_PLAYER_STATE_OPEN_TRANSITION = 3, + CELL_SAIL_PLAYER_STATE_OPENED = 4, + CELL_SAIL_PLAYER_STATE_START_TRANSITION = 5, + CELL_SAIL_PLAYER_STATE_RUNNING = 6, + CELL_SAIL_PLAYER_STATE_STOP_TRANSITION = 7, + CELL_SAIL_PLAYER_STATE_CLOSE_TRANSITION = 8, + CELL_SAIL_PLAYER_STATE_LOST = 9, + _CELL_SAIL_PLAYER_STATE_TYPE_NUM_OF_ELEMENTS = 10, // Never used? +}; + +// Preset types +enum { + CELL_SAIL_PLAYER_PRESET_AV_SYNC = 0, // Deprecated, same as 59_94HZ + CELL_SAIL_PLAYER_PRESET_AS_IS = 1, + CELL_SAIL_PLAYER_PRESET_AV_SYNC_59_94HZ = 2, + CELL_SAIL_PLAYER_PRESET_AV_SYNC_29_97HZ = 3, + CELL_SAIL_PLAYER_PRESET_AV_SYNC_50HZ = 4, + CELL_SAIL_PLAYER_PRESET_AV_SYNC_25HZ = 5, + CELL_SAIL_PLAYER_PRESET_AV_SYNC_AUTO_DETECT = 6, +}; + +// Parameter types +enum { + CELL_SAIL_PARAMETER_ENABLE_VPOST = 0, + + // Player + CELL_SAIL_PARAMETER_CONTROL_QUEUE_DEPTH = 1, + CELL_SAIL_PARAMETER_CONTROL_PPU_THREAD_PRIORITY = 2, + + // SPURS + CELL_SAIL_PARAMETER_SPURS_NUM_OF_SPUS = 3, + CELL_SAIL_PARAMETER_SPURS_SPU_THREAD_PRIORITY = 4, + CELL_SAIL_PARAMETER_SPURS_PPU_THREAD_PRIORITY = 5, + CELL_SAIL_PARAMETER_SPURS_EXIT_IF_NO_WORK = 6, + + // Source + CELL_SAIL_PARAMETER_IO_PPU_THREAD_PRIORITY = 7, + + // Dmux + CELL_SAIL_PARAMETER_DMUX_PPU_THREAD_PRIORITY = 8, + CELL_SAIL_PARAMETER_DMUX_SPU_THREAD_PRIORITY = 9, // Deprecated + CELL_SAIL_PARAMETER_DMUX_NUM_OF_SPUS = 10, + CELL_SAIL_PARAMETER_DMUX_SPURS_TASK_PRIORITIES = 11, + + // Adec + CELL_SAIL_PARAMETER_ADEC_PPU_THREAD_PRIORITY = 12, + CELL_SAIL_PARAMETER_ADEC_SPU_THREAD_PRIORITY = 13, // Deprecated + CELL_SAIL_PARAMETER_ADEC_NUM_OF_SPUS = 14, + CELL_SAIL_PARAMETER_ADEC_SPURS_TASK_PRIORITIES = 15, + + // Vdec + CELL_SAIL_PARAMETER_VDEC_PPU_THREAD_PRIORITY = 16, + CELL_SAIL_PARAMETER_VDEC_SPU_THREAD_PRIORITY = 17, // Deprecated + CELL_SAIL_PARAMETER_VDEC_M2V_NUM_OF_SPUS = 18, + CELL_SAIL_PARAMETER_VDEC_AVC_NUM_OF_SPUS = 19, + CELL_SAIL_PARAMETER_VDEC_SPURS_TASK_PRIORITIES = 20, + + // Vpost */ + CELL_SAIL_PARAMETER_VPOST_PPU_THREAD_PRIORITY = 21, // Deprecated + CELL_SAIL_PARAMETER_VPOST_SPU_THREAD_PRIORITY = 22, // Deprecated + CELL_SAIL_PARAMETER_VPOST_NUM_OF_SPUS = 23, + CELL_SAIL_PARAMETER_VPOST_SPURS_TASK_PRIORITIES = 24, + + // Graphics Adapter + CELL_SAIL_PARAMETER_GRAPHICS_ADAPTER_BUFFER_RELEASE_DELAY = 25, + + // AV Sync + CELL_SAIL_PARAMETER_AV_SYNC_ES_AUDIO = 26, + CELL_SAIL_PARAMETER_AV_SYNC_ES_VIDEO = 27, + CELL_SAIL_PARAMETER_AV_SYNC_ES_USER = 28, // Not available + + // Control + CELL_SAIL_PARAMETER_CONTROL_PPU_THREAD_STACK_SIZE = 29, + CELL_SAIL_PARAMETER_RESERVED0_ = 30, // Should be never used + CELL_SAIL_PARAMETER_RESERVED1 = 31, // Should be never used + + // Apost + CELL_SAIL_PARAMETER_ENABLE_APOST_SRC = 32, + + // File I/O Interface + CELL_SAIL_PARAMETER_FS = 33, + CELL_SAIL_PARAMETER_IO_PPU_THREAD_STACK_SIZE = 34, + CELL_SAIL_PARAMETER_VIDEO_PERFORMANCE_POLICY = 35, + _CELL_SAIL_PARAMETER_TYPE_NUM_OF_ELEMENTS = 36, // Should be never used + CELL_SAIL_PARAMETER_SOURCE_PPU_THREAD_PRIORITY = CELL_SAIL_PARAMETER_IO_PPU_THREAD_PRIORITY, + CELL_SAIL_PARAMETER_DMUX_SPURS_TASK_PRIORITY = CELL_SAIL_PARAMETER_DMUX_SPURS_TASK_PRIORITIES, // Deprecated + CELL_SAIL_PARAMETER_VDEC_SPURS_TASK_PRIORITY = CELL_SAIL_PARAMETER_VDEC_SPURS_TASK_PRIORITIES, // Deprecated + CELL_SAIL_PARAMETER_ADEC_SPURS_TASK_PRIORITY = CELL_SAIL_PARAMETER_ADEC_SPURS_TASK_PRIORITIES, // Deprecated + CELL_SAIL_PARAMETER_VPOST_SPURS_TASK_PRIORITY = CELL_SAIL_PARAMETER_VPOST_SPURS_TASK_PRIORITIES, // Deprecated +}; + +// Media states +enum { + CELL_SAIL_MEDIA_STATE_FINE = 0, + CELL_SAIL_MEDIA_STATE_BAD = 1, + CELL_SAIL_MEDIA_STATE_LOST = 2, +}; + +// Stream Types +enum +{ + CELL_SAIL_STREAM_PAMF = 0, + CELL_SAIL_STREAM_MP4 = 1, + CELL_SAIL_STREAM_AVI = 2, + + CELL_SAIL_STREAM_UNSPECIFIED = -1, +}; + +// Sync Types +enum { + CELL_SAIL_SYNC_MODE_REPEAT = 1 << 0, + CELL_SAIL_SYNC_MODE_SKIP = 1 << 1, +}; + +// Flags +enum { + CELL_SAIL_AVISF_DISABLED = 0x00000001, + CELL_SAIL_AVIF_HASINDEX = 0x00000010, + CELL_SAIL_AVIF_MUSTUSEINDEX = 0x00000020, + CELL_SAIL_AVIF_ISINTERLEAVED = 0x00000100, + CELL_SAIL_AVIF_WASCAPTUREFILE = 0x00010000, + CELL_SAIL_AVISF_VIDEO_PALCHANGES = 0x00010000, + CELL_SAIL_AVIF_COPYRIGHTED = 0x00020000, + + CELL_SAIL_AVIF_TRUSTCKTYPE = 0x00000800, // Open-DML only +}; + +// Wave types +enum { + CELL_SAIL_WAVE_FORMAT_PCM = 0x0001, + CELL_SAIL_WAVE_FORMAT_MPEG = 0x0050, + CELL_SAIL_WAVE_FORMAT_MPEGLAYER3 = 0x0055, + CELL_SAIL_WAVE_FORMAT_AC3 = 0x2000, + CELL_SAIL_WAVE_FORMAT_UNSPECIFIED = 0xFFFF, +}; + +// MPEG Layers +enum { + CELL_SAIL_ACM_MPEG_LAYER1 = 0x0001, + CELL_SAIL_ACM_MPEG_LAYER2 = 0x0002, + CELL_SAIL_ACM_MPEG_LAYER3 = 0x0004, +}; + +// MPEG Modes +enum { + CELL_SAIL_ACM_MPEG_STEREO = 0x0001, + CELL_SAIL_ACM_MPEG_JOINTSTEREO = 0x0002, + CELL_SAIL_ACM_MPEG_DUALCHANNEL = 0x0004, + CELL_SAIL_ACM_MPEG_SINGLECHANNEL = 0x0008, +}; + +// MPEG Flags +enum { + CELL_SAIL_ACM_MPEG_PRIVATEBIT = 0x0001, + CELL_SAIL_ACM_MPEG_COPYRIGHT = 0x0002, + CELL_SAIL_ACM_MPEG_ORIGINALHOME = 0x0004, + CELL_SAIL_ACM_MPEG_PROTECTIONBIT = 0x0008, + CELL_SAIL_ACM_MPEG_ID_MPEG1 = 0x0010, +}; + +// MPEG Layer 3 Flags +enum { + CELL_SAIL_MPEGLAYER3_ID_UNKNOWN = 0, + CELL_SAIL_MPEGLAYER3_ID_MPEG = 1, + CELL_SAIL_MPEGLAYER3_ID_CONSTANTFRAMESIZE = 2, + CELL_SAIL_MPEGLAYER3_FLAG_PADDING_ISO = 0x00000000, + CELL_SAIL_MPEGLAYER3_FLAG_PADDING_ON = 0x00000001, + CELL_SAIL_MPEGLAYER3_FLAG_PADDING_OFF = 0x00000002, +}; + +// ES Types +enum { + CELL_SAIL_ES_AUDIO = 0, + CELL_SAIL_ES_VIDEO = 1, + CELL_SAIL_ES_USER = 2, +}; + +// Audio Coding Types +enum { + CELL_SAIL_AUDIO_CODING_UNSPECIFIED = -1, + CELL_SAIL_AUDIO_CODING_LPCM_FLOAT32 = 1, +}; + +enum { + CELL_SAIL_AUDIO_CHNUM_UNSPECIFIED = -1, + CELL_SAIL_AUDIO_CH_NUM_UNSPECIFIED = -1, + CELL_SAIL_AUDIO_AUSAMPLE_UNSPECIFIED = -1, + CELL_SAIL_AUDIO_SAMPLE_NUM_UNSPECIFIED = -1, +}; + +enum { + CELL_SAIL_AUDIO_FS_32000HZ = 32000, + CELL_SAIL_AUDIO_FS_44100HZ = 44100, + CELL_SAIL_AUDIO_FS_48000HZ = 48000, + + CELL_SAIL_AUDIO_FS_96000HZ = 96000, + CELL_SAIL_AUDIO_FS_88200HZ = 88200, + CELL_SAIL_AUDIO_FS_64000HZ = 64000, + //CELL_SAIL_AUDIO_FS_48000HZ = 48000, + //CELL_SAIL_AUDIO_FS_44100HZ = 44100, + //CELL_SAIL_AUDIO_FS_32000HZ = 32000, + CELL_SAIL_AUDIO_FS_24000HZ = 24000, + CELL_SAIL_AUDIO_FS_22050HZ = 22050, + CELL_SAIL_AUDIO_FS_16000HZ = 16000, + CELL_SAIL_AUDIO_FS_12000HZ = 12000, + CELL_SAIL_AUDIO_FS_11025HZ = 11025, + CELL_SAIL_AUDIO_FS_8000HZ = 8000, + CELL_SAIL_AUDIO_FS_7350HZ = 7350, + + CELL_SAIL_AUDIO_FS_192000HZ = 192000, + //CELL_SAIL_AUDIO_FS_11024HZ = 11025, + CELL_SAIL_AUDIO_FS_UNSPECIFIED = -1, + +}; + +enum { + CELL_SAIL_AUDIO_CH_LAYOUT_UNDEFINED = 0, + + // monoral + CELL_SAIL_AUDIO_CH_LAYOUT_1CH = 1, + + // 1. Front Left + // 2. Front Right + CELL_SAIL_AUDIO_CH_LAYOUT_2CH_LR = 2, + + // 1. Front Left + // 2. Front Center + // 3. Front Right + // for m4aac ac3 + CELL_SAIL_AUDIO_CH_LAYOUT_3CH_LCR = 3, + + // 1. Front Left + // 2. Front Center + // 3. Surround + // for m4aac ac3 + CELL_SAIL_AUDIO_CH_LAYOUT_3CH_LRc = 4, + + // 1. Front Left + // 2. Front Center + // 3. Front Right + // 4. Surround + // for m4aac ac3 + CELL_SAIL_AUDIO_CH_LAYOUT_4CH_LCRc = 5, + + // 1. Front Left + // 2. Front Right + // 3. Surround Left + // 4. Surround Right + // for m4aac + CELL_SAIL_AUDIO_CH_LAYOUT_4CH_LRlr = 6, + + // 1. Front Left + // 2. Front Center + // 3. Front Right + // 4. Surround Left + // 5. Surround Right + // for m4aac + CELL_SAIL_AUDIO_CH_LAYOUT_5CH_LCRlr = 7, + + // 1. Front Left + // 2. Front Center + // 3. Front Right + // 4. Surround Left + // 5. Surround Right + // 6. LFE + // for lpcm ac3 m4aac + CELL_SAIL_AUDIO_CH_LAYOUT_6CH_LCRlrE = 8, + + // 1. Front Left + // 2. Front Center + // 3. Front Right + // 4. Back Left + // 5. Back Right + // 6. LFE + // for at3plus + CELL_SAIL_AUDIO_CH_LAYOUT_6CH_LCRxyE = 9, + + // 1. Front Left + // 2. Front Center + // 3. Front Right + // 4. Back Left + // 5. Back Right + // 6. Back Center + // 7. LFE + // (for at3plus) + CELL_SAIL_AUDIO_CH_LAYOUT_7CH_LCRxycE = 10, + + // 1. Front Left + // 2. Front Center + // 3. Front Right + // 4. LFE + // 5. Surround Left + // 6. Surround Right + // 7. Back Left (Left-Extend) + // 8. Back Right (Right-Extend) + // for lpcm at3plus + CELL_SAIL_AUDIO_CH_LAYOUT_8CH_LRCElrxy = 11, + + CELL_SAIL_AUDIO_CH_LAYOUT_2CH_DUAL = 12, + CELL_SAIL_AUDIO_CH_LAYOUT_UNSPECIFIED = -1, +}; + +// Video Codings +enum { + CELL_SAIL_VIDEO_CODING_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_CODING_ARGB_INTERLEAVED = 0, + CELL_SAIL_VIDEO_CODING_RGBA_INTERLEAVED = 1, + CELL_SAIL_VIDEO_CODING_YUV422_U_Y0_V_Y1 = 2, + CELL_SAIL_VIDEO_CODING_YUV420_PLANAR = 3, + + // Suported by cellCamera + CELL_SAIL_VIDEO_CODING_YUV422_Y0_U_Y1_V = 4, + CELL_SAIL_VIDEO_CODING_YUV422_V_Y1_U_Y0 = 9, + CELL_SAIL_VIDEO_CODING_YUV422_Y1_V_Y0_U = 10, + CELL_SAIL_VIDEO_CODING_JPEG = 11, + CELL_SAIL_VIDEO_CODING_RAW8_BAYER_BGGR = 12, + _CELL_SAIL_VIDEO_CODING_TYPE_NUM_OF_ELEMENTS = 13, + CELL_SAIL_VIDEO_CODING_UYVY422_INTERLEAVED = 2, + CELL_SAIL_VIDEO_CODING_YUYV422_INTERLEAVED = 4, + CELL_SAIL_VIDEO_CODING_VYUY422_REVERSE_INTERLEAVED = 9, + CELL_SAIL_VIDEO_CODING_RAW8_BAYER_GRBG = 12, +}; + +// Video Color Types +enum { + CELL_SAIL_VIDEO_COLOR_MATRIX_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_COLOR_MATRIX_BT601 = 0, + CELL_SAIL_VIDEO_COLOR_MATRIX_BT709 = 1, + _CELL_SAIL_VIDEO_COLOR_MATRIX_TYPE_NUM_OF_ELEMENTS = 2, +}; + +// Video Scan Types +enum { + CELL_SAIL_VIDEO_SCAN_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_SCAN_PROGRESSIVE = 0, + CELL_SAIL_VIDEO_SCAN_INTERLACE = 1, + _CELL_SAIL_VIDEO_SCAN_TYPE_NUM_OF_ELEMENTS = 2, +}; + +// Framerates +enum { + CELL_SAIL_VIDEO_FRAME_RATE_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_FRAME_RATE_24000_1001HZ = 0, + CELL_SAIL_VIDEO_FRAME_RATE_24HZ = 1, + CELL_SAIL_VIDEO_FRAME_RATE_25HZ = 2, + CELL_SAIL_VIDEO_FRAME_RATE_30000_1001HZ = 3, + CELL_SAIL_VIDEO_FRAME_RATE_30HZ = 4, + CELL_SAIL_VIDEO_FRAME_RATE_50HZ = 5, + CELL_SAIL_VIDEO_FRAME_RATE_60000_1001HZ = 6, + CELL_SAIL_VIDEO_FRAME_RATE_60HZ = 7, + _CELL_SAIL_VIDEO_FRAME_RATE_TYPE_NUM_OF_ELEMENTS = 8, +}; + +// Aspect Ratios +enum { + CELL_SAIL_VIDEO_ASPECT_RATIO_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_ASPECT_RATIO_1_1 = 1, // 1920x1080 1280x720 + CELL_SAIL_VIDEO_ASPECT_RATIO_12_11 = 2, // 720x576 normal + CELL_SAIL_VIDEO_ASPECT_RATIO_10_11 = 3, // 720x480 normal + CELL_SAIL_VIDEO_ASPECT_RATIO_16_11 = 4, // 720x576 wide + CELL_SAIL_VIDEO_ASPECT_RATIO_40_33 = 5, // 720x480 wide + CELL_SAIL_VIDEO_ASPECT_RATIO_4_3 = 14, // 1440x1080 +}; + +enum { + CELL_SAIL_VIDEO_WIDTH_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_HEIGHT_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_PITCH_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_BITS_PER_COLOR_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_ALPHA_UNSPECIFIED = -1, +}; + +// Color Ranges +enum { + CELL_SAIL_VIDEO_COLOR_RANGE_UNSPECIFIED = -1, + CELL_SAIL_VIDEO_COLOR_RANGE_LIMITED = 1, + CELL_SAIL_VIDEO_COLOR_RANGE_FULL = 0, +}; + +enum { + CELL_SAIL_START_NOT_SPECIFIED = 0, + CELL_SAIL_START_NORMAL = 1 << 0, //1 + CELL_SAIL_START_TIME_SCALE = 1 << 2, //4 + CELL_SAIL_START_EP_SKIP = 1 << 4, //16 + CELL_SAIL_START_EP_SKIP_REVERSE = 1 << 5, //32 + CELL_SAIL_START_FRAME_STEP = 1 << 6, //64 +}; + +// Seek Types +enum { + CELL_SAIL_SEEK_NOT_SPECIFIED = 0, + CELL_SAIL_SEEK_ABSOLUTE_BYTE_POSITION = 1 << 0, // For PAMF + CELL_SAIL_SEEK_RELATIVE_BYTE_POSITION = 1 << 1, // Not implemented + CELL_SAIL_SEEK_ABSOLUTE_TIME_POSITION = 1 << 4, // MP4, AVI + CELL_SAIL_SEEK_CURRENT_POSITION = 1 << 6, + CELL_SAIL_SEEK_MP4_SCALE_AND_TIME = 1 << 4, // For MP4, obsolete +}; + +// Terminus Types +enum { + CELL_SAIL_TERMINUS_NOT_SPECIFIED = 0, + CELL_SAIL_TERMINUS_EOS = 1 << 0, + CELL_SAIL_TERMINUS_ABSOLUTE_BYTE_POSITION = 1 << 1, // For PAMF + CELL_SAIL_TERMINUS_RELATIVE_BYTE_POSITION = 1 << 2, // Mot implemented + CELL_SAIL_TERMINUS_ABSOLUTE_TIME_POSITION = 1 << 5, // For MP4, AVI + CELL_SAIL_TERMINUS_MP4_SCALE_AND_TIME = 1 << 5, // For MP4, obsolete + CELL_SAIL_TERMINUS_MP4_SCALE_ANT_TIME = 1 << 5, // For MP4, here because of a typo +}; + +// Start Flag Types +enum { + CELL_SAIL_START_FLAG_NOT_SPECIFIED = 0, + CELL_SAIL_START_FLAG_UNFLUSH = 1 << 0, + CELL_SAIL_START_FLAG_PAUSE_BEGIN = 1 << 1, + CELL_SAIL_START_FLAG_PAUSE_END = 1 << 2, + CELL_SAIL_START_FLAG_COMPLETE_STREAM = 1 << 3, + CELL_SAIL_START_FLAG_STICKY = 1 << 4, + CELL_SAIL_START_FLAG_PAUSE = 1 << 1, // Obsolete +}; + +enum { + _CELL_SAIL_SYNC_SHIFT_NUM = 8, + + // Buffering + CELL_SAIL_SYNC_UNDERFLOW = 1, + // = 2, Reserved + + // Sync Status + CELL_SAIL_SYNC_ON_TIME = 1 << 2, + CELL_SAIL_SYNC_MAYBE_ON_TIME = 2 << 2, + CELL_SAIL_SYNC_EARLY = 3 << 2, + CELL_SAIL_SYNC_LATE = 4 << 2, + CELL_SAIL_SYNC_NO_SYNC = 5 << 2, + CELL_SAIL_SYNC_NO_PTS = 6 << 2, + CELL_SAIL_SYNC_NOT_READY = 7 << 2, + CELL_SAIL_SYNC_DISABLED = 8 << 2, + CELL_SAIL_SYNC_PAUSED = 9 << 2, + CELL_SAIL_SYNC_DISABLED_PAUSED = 10 << 2, + CELL_SAIL_SYNC_MUTED = 11 << 2, + CELL_SAIL_SYNC_DONE = 12 << 2, + // = 13 << 2, Reserved + // = 14 << 2, Reserved + // = 15 << 2, Reserved + + //CELL_SAIL_SYNC_FIRST_FRAME = 64, + //CELL_SAIL_SYNC_LAST_FRAME = 128, + + + // Frame Status + CELL_SAIL_SYNC_NO_FRAME = 0, + CELL_SAIL_SYNC_REPEATED = 1 << _CELL_SAIL_SYNC_SHIFT_NUM, + CELL_SAIL_SYNC_NEXT = 2 << _CELL_SAIL_SYNC_SHIFT_NUM, + CELL_SAIL_SYNC_SKIPPED_ONE = 3 << _CELL_SAIL_SYNC_SHIFT_NUM, +}; + +enum { + CELL_SAIL_EVENT_RECORDER_CALL_COMPLETED = 2, + CELL_SAIL_EVENT_RECORDER_STATE_CHANGED = 3, +}; + + +enum { + CELL_SAIL_VIDEO_FRAME_RATE_100HZ = 8, + CELL_SAIL_VIDEO_FRAME_RATE_120000_1001HZ = 9, + CELL_SAIL_VIDEO_FRAME_RATE_120HZ = 10, +}; + +enum { + CELL_SAIL_GRAPHICS_ADAPTER_FIELD_TOP = 0, + CELL_SAIL_GRAPHICS_ADAPTER_FIELD_BOTTOM = 1, + CELL_SAIL_GRAPHICS_ADAPTER_FIELD_DONT_CARE = 2, +}; + +enum { + CELL_SAIL_SOURCE_SEEK_ABSOLUTE_BYTE_POSITION = 1 << 0, +}; + +enum { + CELL_SAIL_SOURCE_CAPABILITY_NONE = 0, + CELL_SAIL_SOURCE_CAPABILITY_SEEK_ABSOLUTE_BYTE_POSITION = 1 << 0, + CELL_SAIL_SOURCE_CAPABILITY_PAUSE = 1 << 4, + CELL_SAIL_SOURCE_CAPABILITY_GAPLESS = 1 << 5, + CELL_SAIL_SOURCE_CAPABILITY_EOS = 1 << 6, + CELL_SAIL_SOURCE_CAPABILITY_SEEK_ABSOLUTE_TIME_POSITION = 1 << 7, +}; + struct CellSailAudioFormat { s8 coding; @@ -105,8 +618,8 @@ union CellSailEvent }; }; -typedef void(*CellSailMemAllocatorFuncAlloc)(u32 pArg, u32 boundary, u32 size); -typedef void(*CellSailMemAllocatorFuncFree)(u32 pArg, u32 boundary, u32 pMemory); +typedef u32(*CellSailMemAllocatorFuncAlloc)(u32 pArg, u32 boundary, u32 size); +typedef u32(*CellSailMemAllocatorFuncFree)(u32 pArg, u32 boundary, u32 pMemory); typedef int(*CellSailSoundAdapterFuncMakeup)(u32 pArg); typedef int(*CellSailSoundAdapterFuncCleanup)(u32 pArg); @@ -172,7 +685,7 @@ struct CellSailMemAllocatorFuncs struct CellSailMemAllocator { - CellSailMemAllocatorFuncs callbacks; + vm::ptr callbacks; be_t pArg; }; @@ -522,6 +1035,9 @@ struct CellSailMpegLayer3WaveFormat struct CellSailDescriptor { + bool autoSelection; + bool registered; + be_t streamType; be_t internalData[32]; }; @@ -577,5 +1093,13 @@ struct CellSailPlayerResource struct CellSailPlayer { - be_t internalData[128]; + vm::ptr allocator; + vm::ptr callback; + be_t callbackArgument; + vm::ptr attribute; + vm::ptr resource; + vm::ptr playbackCommand; + be_t repeatMode; + be_t descriptors; + vm::ptr registeredDescriptors[2]; }; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp index 5f12fc853b..e5796c775a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp @@ -989,7 +989,7 @@ int cellSaveDataFixedExport() //const char *dirName, u32 maxSizeKB, CellSaveData return CELL_SAVEDATA_RET_OK; } -int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, vm::ptr> bind, vm::ptr> sizeKB +int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, vm::ptr bind, vm::ptr sizeKB { UNIMPLEMENTED_FUNC(cellSysutil); return CELL_SAVEDATA_RET_OK; @@ -1025,7 +1025,7 @@ int cellSaveDataUserFixedExport() //CellSysutilUserId userId, const char *dirNam return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, vm::ptr> bind, vm::ptr> sizeKB +int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, vm::ptr bind, vm::ptr sizeKB { UNIMPLEMENTED_FUNC(cellSysutil); return CELL_SAVEDATA_RET_OK; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index ac46056b38..ae7565535c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -25,7 +25,7 @@ s64 spursCreateLv2EventQueue(vm::ptr spurs, u32& queue_id, vm::ptr> queue; - s32 res = cb_call, vm::ptr>, vm::ptr, s32, u32>(GetCurrentPPUThread(), libsre + 0xB14C, libsre_rtoc, + s32 res = cb_call, vm::ptr, vm::ptr, s32, u32>(GetCurrentPPUThread(), libsre + 0xB14C, libsre_rtoc, spurs, queue, port, size, vm::read32(libsre_rtoc - 0x7E2C)); queue_id = queue->ToLE(); return res; @@ -60,6 +60,7 @@ s64 spursInit( return cb_call, u32, u32, s32, s32, s32, u32, u32, u32, u32, u32, u32, u32>(GetCurrentPPUThread(), libsre + 0x74E4, libsre_rtoc, spurs, revision, sdkVersion, nSpus, spuPriority, ppuPriority, flags, Memory.RealToVirtualAddr(prefix), prefixSize, container, Memory.RealToVirtualAddr(swlPriority), swlMaxSpu, swlIsPreem); #endif + // SPURS initialization (asserts should actually rollback and return the error instead) if (!spurs) @@ -170,13 +171,267 @@ s64 spursInit( SPU.GPR[4]._u64[1] = spurs.addr(); return SPU.FastCall(SPU.PC); #endif - //SPU.WriteLS32(0x808, 2); // hack for cellSpursModuleExit - //SPU.WriteLS32(0x260, 3); // hack for cellSpursModulePollStatus - //SPU.WriteLS32(0x264, 0x35000000); // bi $0 + + // code replacement: + { + const u32 addr = /*SPU.ReadLS32(0x1e0) +*/ 8; //SPU.ReadLS32(0x1e4); + SPU.WriteLS32(addr + 0, 3); // hack for cellSpursModulePollStatus + SPU.WriteLS32(addr + 4, 0x35000000); // bi $0 + SPU.WriteLS32(0x1e4, addr); + + SPU.WriteLS32(SPU.ReadLS32(0x1e0), 2); // hack for cellSpursModuleExit + } + + if (!isSecond) SPU.m_code3_func = [spurs, num](SPUThread& SPU) -> u64 // first kernel + { + LV2_LOCK(0); // TODO: lock-free implementation if possible + + const u32 arg1 = SPU.GPR[3]._u32[3]; + u32 var0 = SPU.ReadLS32(0x1d8); + u32 var1 = SPU.ReadLS32(0x1dc); + u128 wklA = vm::read128(spurs.addr() + 0x20); + u128 wklB = vm::read128(spurs.addr() + 0x30); + u128 savedA = SPU.ReadLS128(0x180); + u128 savedB = SPU.ReadLS128(0x190); + u128 vAA = u128::sub8(wklA, savedA); + u128 vBB = u128::sub8(wklB, savedB); + u128 vM1 = {}; if (var1 <= 15) vM1.u8r[var1] = 0xff; + u128 vAABB = (arg1 == 0) ? vAA : u128::add8(vAA, u128::andnot(vM1, vBB)); + + u32 vNUM = 0x20; + u64 vRES = 0x20ull << 32; + u128 vSET = {}; + + if (spurs->m.x72.read_relaxed() & (1 << num)) + { + SPU.WriteLS8(0x1eb, 0); // var4 + if (arg1 == 0 || var1 == 0x20) + { + spurs->m.x72._and_not(1 << num); + } + } + else + { + u128 wklReadyCount0 = vm::read128(spurs.addr() + 0x0); + u128 wklReadyCount1 = vm::read128(spurs.addr() + 0x10); + u128 savedC = SPU.ReadLS128(0x1A0); + u128 savedD = SPU.ReadLS128(0x1B0); + u128 vRC = u128::add8(u128::minu8(wklReadyCount0, u128::from8p(8)), u128::minu8(wklReadyCount1, u128::from8p(8))); + u32 wklFlag = spurs->m.wklFlag.flag.read_relaxed(); + u32 flagRecv = spurs->m.flagRecv.read_relaxed(); + u128 vFM = u128::fromV(g_imm_table.fsmb_table[(wklFlag == 0) && (flagRecv < 16) ? 0x8000 >> flagRecv : 0]); + u128 wklSet1 = u128::fromV(g_imm_table.fsmb_table[spurs->m.wklSet1.read_relaxed()]); + u128 vFMS1 = vFM | wklSet1; + u128 vFMV1 = u128::fromV(g_imm_table.fsmb_table[(var1 < 16) ? 0x8000 >> var1 : 0]); + u32 var5 = SPU.ReadLS32(0x1ec); + u128 wklMinCnt = vm::read128(spurs.addr() + 0x40); + u128 wklMaxCnt = vm::read128(spurs.addr() + 0x50); + u128 vCC = u128::andnot(vFMS1, u128::eq8(wklReadyCount0, {}) | u128::leu8(vRC, vAABB)) | + u128::leu8(wklMaxCnt, vAABB) | + u128::eq8(savedC, {}) | + u128::fromV(g_imm_table.fsmb_table[(~var5) >> 16]); + u128 vCCH1 = u128::andnot(vCC, + u128::from8p(0x80) & (vFMS1 | u128::gtu8(wklReadyCount0, vAABB)) | + u128::from8p(0x7f) & savedC); + u128 vCCL1 = u128::andnot(vCC, + u128::from8p(0x80) & vFMV1 | + u128::from8p(0x40) & u128::gtu8(vAABB, {}) & u128::gtu8(wklMinCnt, vAABB) | + u128::from8p(0x3c) & u128::fromV(_mm_slli_epi32(u128::sub8(u128::from8p(8), vAABB).vi, 2)) | + u128::from8p(0x02) & u128::eq8(savedD, u128::from8p((u8)var0)) | + u128::from8p(0x01)); + u128 vSTAT = + u128::from8p(0x01) & u128::gtu8(wklReadyCount0, vAABB) | + u128::from8p(0x02) & wklSet1 | + u128::from8p(0x04) & vFM; + + for (s32 i = 0, max = -1; i < 0x10; i++) + { + const s32 value = ((s32)vCCH1.u8r[i] << 8) | ((s32)vCCL1.u8r[i]); + if (value > max && (vCC.u8r[i] & 1) == 0) + { + vNUM = i; + max = value; + } + } + + if (vNUM < 0x10) + { + vRES = ((u64)vNUM << 32) | vSTAT.u8r[vNUM]; + vSET.u8r[vNUM] = 0x01; + } + + SPU.WriteLS8(0x1eb, vNUM == 0x20); + + if (!arg1 || var1 == vNUM) + { + spurs->m.wklSet1._and_not(be_t::make((u16)(vNUM < 16 ? 0x8000 >> vNUM : 0))); + if (vNUM == flagRecv && wklFlag == 0) + { + spurs->m.wklFlag.flag.write_relaxed(be_t::make(-1)); + } + } + } + + if (arg1 == 0) + { + vm::write128(spurs.addr() + 0x20, u128::add8(vAA, vSET)); // update wklA + + SPU.WriteLS128(0x180, vSET); // update savedA + SPU.WriteLS32(0x1dc, vNUM); // update var1 + } + + if (arg1 == 1 && vNUM != var1) + { + vm::write128(spurs.addr() + 0x30, u128::add8(vBB, vSET)); // update wklB + + SPU.WriteLS128(0x190, vSET); // update savedB + } + else + { + vm::write128(spurs.addr() + 0x30, vBB); // update wklB + + SPU.WriteLS128(0x190, {}); // update savedB + } + + return vRES; + }; + else SPU.m_code3_func = [spurs, num](SPUThread& SPU) -> u64 // second kernel + { + LV2_LOCK(0); // TODO: lock-free implementation if possible + + const u32 arg1 = SPU.GPR[3]._u32[3]; + u32 var0 = SPU.ReadLS32(0x1d8); + u32 var1 = SPU.ReadLS32(0x1dc); + u128 wklA = vm::read128(spurs.addr() + 0x20); + u128 wklB = vm::read128(spurs.addr() + 0x30); + u128 savedA = SPU.ReadLS128(0x180); + u128 savedB = SPU.ReadLS128(0x190); + u128 vAA = u128::sub8(wklA, savedA); + u128 vBB = u128::sub8(wklB, savedB); + u128 vM1 = {}; if (var1 <= 31) vM1.u8r[var1 & 0xf] = (var1 <= 15) ? 0xf : 0xf0; + u128 vAABB = (arg1 == 0) ? vAA : u128::add8(vAA, u128::andnot(vM1, vBB)); + + u32 vNUM = 0x20; + u64 vRES = 0x20ull << 32; + u128 vSET = {}; + + if (spurs->m.x72.read_relaxed() & (1 << num)) + { + SPU.WriteLS8(0x1eb, 0); // var4 + if (arg1 == 0 || var1 == 0x20) + { + spurs->m.x72._and_not(1 << num); + } + } + else + { + u128 wklReadyCount0 = vm::read128(spurs.addr() + 0x0); + u128 wklReadyCount1 = vm::read128(spurs.addr() + 0x10); + u128 savedC = SPU.ReadLS128(0x1A0); + u128 wklMaxCnt = vm::read128(spurs.addr() + 0x50); + u32 wklFlag = spurs->m.wklFlag.flag.read_relaxed(); + u32 flagRecv = spurs->m.flagRecv.read_relaxed(); + u128 wklSet1 = u128::fromV(g_imm_table.fsmb_table[spurs->m.wklSet1.read_relaxed()]); + u128 wklSet2 = u128::fromV(g_imm_table.fsmb_table[spurs->m.wklSet2.read_relaxed()]); + u128 vABL = vAABB & u128::from8p(0x0f); + u128 vABH = u128::fromV(_mm_srli_epi32((vAABB & u128::from8p(0xf0)).vi, 4)); + u32 var5 = SPU.ReadLS32(0x1ec); + u128 v5L = u128::fromV(g_imm_table.fsmb_table[var5 >> 16]); + u128 v5H = u128::fromV(g_imm_table.fsmb_table[(u16)var5]); + u128 vFML = u128::fromV(g_imm_table.fsmb_table[(wklFlag == 0) && (flagRecv < 16) ? 0x8000 >> flagRecv : 0]); + u128 vFMH = u128::fromV(g_imm_table.fsmb_table[(u16)((wklFlag == 0) && (flagRecv < 32) ? 0x80000000 >> flagRecv : 0)]); + u128 vCL = u128::fromV(_mm_slli_epi32((savedC & u128::from8p(0x0f)).vi, 4)); + u128 vCH = savedC & u128::from8p(0xf0); + u128 vABRL = u128::gtu8(wklReadyCount0, vABL); + u128 vABRH = u128::gtu8(wklReadyCount1, vABH); + u128 vCCL = v5L & u128::gtu8(vCL, {}) & u128::gtu8(wklMaxCnt & u128::from8p(0x0f), vABL) & (wklSet1 | vFML | vABRL); + u128 vCCH = v5H & u128::gtu8(vCH, {}) & u128::gtu8(u128::fromV(_mm_srli_epi32((wklMaxCnt & u128::from8p(0xf0)).vi, 4)), vABH) & (wklSet2 | vFMH | vABRH); + u128 v1H = {}; if (var1 <= 31 && var1 > 15) v1H.u8r[var1 & 0xf] = 4; + u128 v1L = {}; if (var1 <= 15) v1L.u8r[var1] = 4; + u128 vCH1 = (v1H | vCH & u128::from8p(0xFB)) & vCCH; + u128 vCL1 = (v1L | vCL & u128::from8p(0xFB)) & vCCL; + u128 vSTATL = vABRL & u128::from8p(1) | wklSet1 & u128::from8p(2) | vFML & u128::from8p(4); + u128 vSTATH = vABRH & u128::from8p(1) | wklSet2 & u128::from8p(2) | vFMH & u128::from8p(4); + + s32 max = -1; + for (u32 i = 0; i < 0x10; i++) + { + const s32 value = vCL1.u8r[i]; + if (value > max && (vCCL.u8r[i] & 1)) + { + vNUM = i; + max = value; + } + } + for (u32 i = 16; i < 0x20; i++) + { + const s32 value = vCH1.u8r[i]; + if (value > max && (vCCH.u8r[i] & 1)) + { + vNUM = i; + max = value; + } + } + + if (vNUM < 0x10) + { + vRES = ((u64)vNUM << 32) | vSTATL.u8r[vNUM]; + vSET.u8r[vNUM] = 0x01; + } + else if (vNUM < 0x20) + { + vRES = ((u64)vNUM << 32) | vSTATH.u8r[vNUM & 0xf]; + vSET.u8r[vNUM] = 0x10; + } + + SPU.WriteLS8(0x1eb, vNUM == 0x20); + + if (!arg1 || var1 == vNUM) + { + spurs->m.wklSet1._and_not(be_t::make((u16)(vNUM < 16 ? 0x8000 >> vNUM : 0))); + spurs->m.wklSet2._and_not(be_t::make((u16)(0x80000000 >> vNUM))); + if (vNUM == flagRecv && wklFlag == 0) + { + spurs->m.wklFlag.flag.write_relaxed(be_t::make(-1)); + } + } + } + + if (arg1 == 0) + { + vm::write128(spurs.addr() + 0x20, u128::add8(vAA, vSET)); // update wklA + + SPU.WriteLS128(0x180, vSET); // update savedA + SPU.WriteLS32(0x1dc, vNUM); // update var1 + } + + if (arg1 == 1 && vNUM != var1) + { + vm::write128(spurs.addr() + 0x30, u128::add8(vBB, vSET)); // update wklB + + SPU.WriteLS128(0x190, vSET); // update savedB + } + else + { + vm::write128(spurs.addr() + 0x30, vBB); // update wklB + + SPU.WriteLS128(0x190, {}); // update savedB + } + + return vRES; + }; + //SPU.m_code3_func = [spurs, num](SPUThread& SPU) -> u64 // test + //{ + // LV2_LOCK(0); + // SPU.FastCall(0x290); + // u64 vRES = SPU.GPR[3]._u64[1]; + // return vRES; + //}; SPU.WriteLS128(0x1c0, u128::from32r(0, spurs.addr(), num, 0x1f)); u32 wid = 0x20; + u32 stat = 0; while (true) { if (Emu.IsStopped()) @@ -202,7 +457,7 @@ s64 spursInit( SPU.GPR[1]._u32[3] = 0x3FFB0; SPU.GPR[3]._u32[3] = 0x100; SPU.GPR[4]._u64[1] = wkl.data; - SPU.GPR[5]._u32[3] = 0; + SPU.GPR[5]._u32[3] = stat; SPU.FastCall(0xa00); // check status: @@ -217,8 +472,11 @@ s64 spursInit( } // get workload id: - //SPU.GPR[3].clear(); - //wid = SPU.m_code3_func(SPU); + SPU.GPR[3].clear(); + assert(SPU.m_code3_func); + u64 res = SPU.m_code3_func(SPU); + stat = (u32)(res); + wid = (u32)(res >> 32); } })->GetId(); @@ -262,6 +520,7 @@ s64 spursInit( #ifdef PRX_DEBUG_XXX return cb_call>(CPU, libsre + 0x9214, libsre_rtoc, spurs); #endif + if (spurs->m.flags & SAF_UNKNOWN_FLAG_30) { return; @@ -346,7 +605,7 @@ s64 spursInit( if (Emu.IsStopped()) continue; assert(sys_spu_thread_group_start(spurs->m.spuTG) == CELL_OK); - if (s32 res = sys_spu_thread_group_join(spurs->m.spuTG, vm::ptr>::make(0), vm::ptr>::make(0))) + if (s32 res = sys_spu_thread_group_join(spurs->m.spuTG, vm::ptr::make(0), vm::ptr::make(0))) { if (res == CELL_ESTAT) { @@ -408,10 +667,10 @@ s64 cellSpursInitialize(vm::ptr spurs, s32 nSpus, s32 spuPriority, s3 { cellSpurs->Warning("cellSpursInitialize(spurs_addr=0x%x, nSpus=%d, spuPriority=%d, ppuPriority=%d, exitIfNoWork=%d)", spurs.addr(), nSpus, spuPriority, ppuPriority, exitIfNoWork ? 1 : 0); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x8480, libsre_rtoc); #endif + return spursInit( spurs, 0, @@ -431,10 +690,10 @@ s64 cellSpursInitialize(vm::ptr spurs, s32 nSpus, s32 spuPriority, s3 s64 cellSpursInitializeWithAttribute(vm::ptr spurs, vm::ptr attr) { cellSpurs->Warning("cellSpursInitializeWithAttribute(spurs_addr=0x%x, attr_addr=0x%x)", spurs.addr(), attr.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x839C, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -467,10 +726,10 @@ s64 cellSpursInitializeWithAttribute(vm::ptr spurs, vm::ptr spurs, vm::ptr attr) { cellSpurs->Warning("cellSpursInitializeWithAttribute2(spurs_addr=0x%x, attr_addr=0x%x)", spurs.addr(), attr.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x82B4, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -504,10 +763,10 @@ s64 _cellSpursAttributeInitialize(vm::ptr attr, u32 revision { cellSpurs->Warning("_cellSpursAttributeInitialize(attr_addr=0x%x, revision=%d, sdkVersion=0x%x, nSpus=%d, spuPriority=%d, ppuPriority=%d, exitIfNoWork=%d)", attr.addr(), revision, sdkVersion, nSpus, spuPriority, ppuPriority, exitIfNoWork ? 1 : 0); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x72CC, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -530,10 +789,10 @@ s64 _cellSpursAttributeInitialize(vm::ptr attr, u32 revision s64 cellSpursAttributeSetMemoryContainerForSpuThread(vm::ptr attr, u32 container) { cellSpurs->Warning("cellSpursAttributeSetMemoryContainerForSpuThread(attr_addr=0x%x, container=%d)", attr.addr(), container); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x6FF8, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -556,10 +815,10 @@ s64 cellSpursAttributeSetMemoryContainerForSpuThread(vm::ptr s64 cellSpursAttributeSetNamePrefix(vm::ptr attr, vm::ptr prefix, u32 size) { cellSpurs->Warning("cellSpursAttributeSetNamePrefix(attr_addr=0x%x, prefix_addr=0x%x, size=%d)", attr.addr(), prefix.addr(), size); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x7234, libsre_rtoc); #endif + if (!attr || !prefix) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -582,10 +841,10 @@ s64 cellSpursAttributeSetNamePrefix(vm::ptr attr, vm::ptr attr) { cellSpurs->Warning("cellSpursAttributeEnableSpuPrintfIfAvailable(attr_addr=0x%x)", attr.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x7150, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -602,10 +861,10 @@ s64 cellSpursAttributeEnableSpuPrintfIfAvailable(vm::ptr att s64 cellSpursAttributeSetSpuThreadGroupType(vm::ptr attr, s32 type) { cellSpurs->Warning("cellSpursAttributeSetSpuThreadGroupType(attr_addr=0x%x, type=%d)", attr.addr(), type); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x70C8, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -638,10 +897,10 @@ s64 cellSpursAttributeEnableSystemWorkload(vm::ptr attr, vm: { cellSpurs->Warning("cellSpursAttributeEnableSystemWorkload(attr_addr=0x%x, priority_addr=0x%x, maxSpu=%d, isPreemptible_addr=0x%x)", attr.addr(), priority.addr(), maxSpu, isPreemptible.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0xF410, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -694,11 +953,11 @@ s64 cellSpursAttributeEnableSystemWorkload(vm::ptr attr, vm: s64 cellSpursFinalize(vm::ptr spurs) { - cellSpurs->Warning("cellSpursFinalize(spurs_addr=0x%x)", spurs.addr()); - + cellSpurs->Todo("cellSpursFinalize(spurs_addr=0x%x)", spurs.addr()); #ifdef PRX_DEBUG return GetCurrentPPUThread().FastCall2(libsre + 0x8568, libsre_rtoc); #endif + return CELL_OK; } @@ -708,6 +967,7 @@ s64 spursAttachLv2EventQueue(vm::ptr spurs, u32 queue, vm::ptr po return cb_call, u32, vm::ptr, s32, bool>(GetCurrentPPUThread(), libsre + 0xAE34, libsre_rtoc, spurs, queue, port, isDynamic, wasCreated); #endif + if (!spurs || !port) { return CELL_SPURS_CORE_ERROR_NULL_POINTER; @@ -767,10 +1027,10 @@ s64 cellSpursAttachLv2EventQueue(vm::ptr spurs, u32 queue, vm::ptrWarning("cellSpursAttachLv2EventQueue(spurs_addr=0x%x, queue=%d, port_addr=0x%x, isDynamic=%d)", spurs.addr(), queue, port.addr(), isDynamic); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0xAFE0, libsre_rtoc); #endif + return spursAttachLv2EventQueue(spurs, queue, port, isDynamic, false); } @@ -796,37 +1056,69 @@ s64 cellSpursGetSpuGuid() #endif } -s64 cellSpursGetSpuThreadGroupId(vm::ptr spurs, vm::ptr> group) +s64 cellSpursGetSpuThreadGroupId(vm::ptr spurs, vm::ptr group) { -#ifdef PRX_DEBUG cellSpurs->Warning("cellSpursGetSpuThreadGroupId(spurs_addr=0x%x, group_addr=0x%x)", spurs.addr(), group.addr()); +#ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x8B30, libsre_rtoc); -#else - UNIMPLEMENTED_FUNC(cellSpurs); - return CELL_OK; #endif + + if (!spurs || !group) + { + return CELL_SPURS_CORE_ERROR_NULL_POINTER; + } + if (spurs.addr() % 128) + { + return CELL_SPURS_CORE_ERROR_ALIGN; + } + + *group = spurs->m.spuTG; + return CELL_OK; } -s64 cellSpursGetNumSpuThread(vm::ptr spurs, vm::ptr> nThreads) +s64 cellSpursGetNumSpuThread(vm::ptr spurs, vm::ptr nThreads) { -#ifdef PRX_DEBUG cellSpurs->Warning("cellSpursGetNumSpuThread(spurs_addr=0x%x, nThreads_addr=0x%x)", spurs.addr(), nThreads.addr()); +#ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x8B78, libsre_rtoc); -#else - UNIMPLEMENTED_FUNC(cellSpurs); - return CELL_OK; #endif + + if (!spurs || !nThreads) + { + return CELL_SPURS_CORE_ERROR_NULL_POINTER; + } + if (spurs.addr() % 128) + { + return CELL_SPURS_CORE_ERROR_ALIGN; + } + + *nThreads = (u32)spurs->m.nSpus; + return CELL_OK; } -s64 cellSpursGetSpuThreadId(vm::ptr spurs, vm::ptr> thread, vm::ptr> nThreads) +s64 cellSpursGetSpuThreadId(vm::ptr spurs, vm::ptr thread, vm::ptr nThreads) { -#ifdef PRX_DEBUG cellSpurs->Warning("cellSpursGetSpuThreadId(spurs_addr=0x%x, thread_addr=0x%x, nThreads_addr=0x%x)", spurs.addr(), thread.addr(), nThreads.addr()); +#ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x8A98, libsre_rtoc); -#else - UNIMPLEMENTED_FUNC(cellSpurs); - return CELL_OK; #endif + + if (!spurs || !thread || !nThreads) + { + return CELL_SPURS_CORE_ERROR_NULL_POINTER; + } + if (spurs.addr() % 128) + { + return CELL_SPURS_CORE_ERROR_ALIGN; + } + + const u32 count = std::min(*nThreads, spurs->m.nSpus); + for (u32 i = 0; i < count; i++) + { + thread[i] = spurs->m.spus[i]; + } + *nThreads = count; + return CELL_OK; } s64 cellSpursSetMaxContention(vm::ptr spurs, u32 workloadId, u32 maxContention) @@ -912,6 +1204,7 @@ s64 spursWakeUp(vm::ptr spurs) #ifdef PRX_DEBUG_XXX return cb_call>(GetCurrentPPUThread(), libsre + 0x84D8, libsre_rtoc, spurs); #endif + if (!spurs) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -961,6 +1254,7 @@ s32 spursAddWorkload( spurs, wid, pm, size, data, Memory.RealToVirtualAddr(priorityTable), minContention, maxContention, nameClass.addr(), nameInstance.addr(), hook.addr(), hookArg.addr()); #endif + if (!spurs || !wid || !pm) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1123,7 +1417,6 @@ s64 cellSpursAddWorkload( { cellSpurs->Warning("%s(spurs_addr=0x%x, wid_addr=0x%x, pm_addr=0x%x, size=0x%x, data=0x%llx, priorityTable_addr=0x%x, minContention=0x%x, maxContention=0x%x)", __FUNCTION__, spurs.addr(), wid.addr(), pm.addr(), size, data, priorityTable.addr(), minContention, maxContention); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x9ED0, libsre_rtoc); #endif @@ -1156,10 +1449,10 @@ s64 _cellSpursWorkloadAttributeInitialize( { cellSpurs->Warning("%s(attr_addr=0x%x, revision=%d, sdkVersion=0x%x, pm_addr=0x%x, size=0x%x, data=0x%llx, priorityTable_addr=0x%x, minContention=0x%x, maxContention=0x%x)", __FUNCTION__, attr.addr(), revision, sdkVersion, pm.addr(), size, data, priorityTable.addr(), minContention, maxContention); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x9F08, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1196,10 +1489,10 @@ s64 _cellSpursWorkloadAttributeInitialize( s64 cellSpursWorkloadAttributeSetName(vm::ptr attr, vm::ptr nameClass, vm::ptr nameInstance) { cellSpurs->Warning("%s(attr_addr=0x%x, nameClass_addr=0x%x, nameInstance_addr=0x%x)", __FUNCTION__, attr.addr(), nameClass.addr(), nameInstance.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x9664, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1217,10 +1510,10 @@ s64 cellSpursWorkloadAttributeSetName(vm::ptr attr, s64 cellSpursWorkloadAttributeSetShutdownCompletionEventHook(vm::ptr attr, vm::ptr hook, vm::ptr arg) { cellSpurs->Warning("%s(attr_addr=0x%x, hook_addr=0x%x, arg=0x%x)", __FUNCTION__, attr.addr(), hook.addr(), arg.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x96A4, libsre_rtoc); #endif + if (!attr || !hook) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1238,10 +1531,10 @@ s64 cellSpursWorkloadAttributeSetShutdownCompletionEventHook(vm::ptr spurs, vm::ptr wid, vm::ptr attr) { cellSpurs->Warning("%s(spurs_addr=0x%x, wid_addr=0x%x, attr_addr=0x%x)", __FUNCTION__, spurs.addr(), wid.addr(), attr.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0x9E14, libsre_rtoc); #endif + if (!attr) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1306,10 +1599,10 @@ s64 cellSpursShutdownWorkload() s64 _cellSpursWorkloadFlagReceiver(vm::ptr spurs, u32 wid, u32 is_set) { cellSpurs->Warning("%s(spurs_addr=0x%x, wid=%d, is_set=%d)", __FUNCTION__, spurs.addr(), wid, is_set); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0xF158, libsre_rtoc); #endif + if (!spurs) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1376,10 +1669,10 @@ s64 _cellSpursWorkloadFlagReceiver(vm::ptr spurs, u32 wid, u32 is_set s64 cellSpursGetWorkloadFlag(vm::ptr spurs, vm::ptr> flag) { cellSpurs->Warning("%s(spurs_addr=0x%x, flag_addr=0x%x)", __FUNCTION__, spurs.addr(), flag.addr()); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0xEC00, libsre_rtoc); #endif + if (!spurs || !flag) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1418,10 +1711,10 @@ s64 cellSpursGetWorkloadData() s64 cellSpursReadyCountStore(vm::ptr spurs, u32 wid, u32 value) { cellSpurs->Warning("%s(spurs_addr=0x%x, wid=%d, value=0x%x)", __FUNCTION__, spurs.addr(), wid, value); - #ifdef PRX_DEBUG_XXX return GetCurrentPPUThread().FastCall2(libsre + 0xAB2C, libsre_rtoc); #endif + if (!spurs) { return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER; @@ -1569,7 +1862,7 @@ s64 cellSpursEventFlagDetachLv2EventQueue(vm::ptr eventFlag) #endif } -s64 cellSpursEventFlagWait(vm::ptr eventFlag, vm::ptr> mask, u32 mode) +s64 cellSpursEventFlagWait(vm::ptr eventFlag, vm::ptr mask, u32 mode) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursEventFlagWait(eventFlag_addr=0x%x, mask_addr=0x%x, mode=%d)", eventFlag.addr(), mask.addr(), mode); @@ -1602,7 +1895,7 @@ s64 cellSpursEventFlagSet(vm::ptr eventFlag, u16 bits) #endif } -s64 cellSpursEventFlagTryWait(vm::ptr eventFlag, vm::ptr> mask, u32 mode) +s64 cellSpursEventFlagTryWait(vm::ptr eventFlag, vm::ptr mask, u32 mode) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursEventFlagTryWait(eventFlag_addr=0x%x, mask_addr=0x%x, mode=0x%x)", eventFlag.addr(), mask.addr(), mode); @@ -1613,7 +1906,7 @@ s64 cellSpursEventFlagTryWait(vm::ptr eventFlag, vm::ptr eventFlag, vm::ptr> direction) +s64 cellSpursEventFlagGetDirection(vm::ptr eventFlag, vm::ptr direction) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursEventFlagGetDirection(eventFlag_addr=0x%x, direction_addr=0x%x)", eventFlag.addr(), direction.addr()); @@ -1624,7 +1917,7 @@ s64 cellSpursEventFlagGetDirection(vm::ptr eventFlag, vm::pt #endif } -s64 cellSpursEventFlagGetClearMode(vm::ptr eventFlag, vm::ptr> clear_mode) +s64 cellSpursEventFlagGetClearMode(vm::ptr eventFlag, vm::ptr clear_mode) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursEventFlagGetClearMode(eventFlag_addr=0x%x, clear_mode_addr=0x%x)", eventFlag.addr(), clear_mode.addr()); @@ -1980,7 +2273,7 @@ s64 cellSpursJoinTaskset(vm::ptr taskset) #endif } -s64 cellSpursGetTasksetId(vm::ptr taskset, vm::ptr> workloadId) +s64 cellSpursGetTasksetId(vm::ptr taskset, vm::ptr workloadId) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursGetTasksetId(taskset_addr=0x%x, workloadId_addr=0x%x)", taskset.addr(), workloadId.addr()); @@ -2002,7 +2295,7 @@ s64 cellSpursShutdownTaskset(vm::ptr taskset) #endif } -s64 cellSpursCreateTask(vm::ptr taskset, vm::ptr> taskID, u32 elf_addr, u32 context_addr, u32 context_size, vm::ptr lsPattern, +s64 cellSpursCreateTask(vm::ptr taskset, vm::ptr taskID, u32 elf_addr, u32 context_addr, u32 context_size, vm::ptr lsPattern, vm::ptr argument) { #ifdef PRX_DEBUG diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp index 8c8e50f384..ed4c73b9be 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.cpp @@ -766,7 +766,7 @@ void cellSpursJq_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { - libspurs_jq = (u32)Memory.PRXMem.AllocAlign(sizeof(libspurs_jq_data), 4096); + 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 4a0e1a3ccd..a8899f250f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -16,6 +16,13 @@ u32 libsre; u32 libsre_rtoc; #endif +waiter_map_t g_sync_mutex_wm("sync_mutex_wm"); +waiter_map_t g_sync_barrier_wait_wm("sync_barrier_wait_wm"); +waiter_map_t g_sync_barrier_notify_wm("sync_barrier_notify_wm"); +waiter_map_t g_sync_rwm_read_wm("sync_rwm_read_wm"); +waiter_map_t g_sync_rwm_write_wm("sync_rwm_write_wm"); +waiter_map_t g_sync_queue_wm("sync_queue_wm"); + s32 syncMutexInitialize(vm::ptr mutex) { if (!mutex) @@ -60,15 +67,10 @@ s32 cellSyncMutexLock(vm::ptr mutex) }); // prx: wait until this old value is equal to m_rel - while (order != mutex->data.read_relaxed().m_rel) + g_sync_mutex_wm.wait_op(mutex.addr(), [mutex, order]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncMutexLock(mutex_addr=0x%x) aborted", mutex.addr()); - break; - } - } + return order == mutex->data.read_relaxed().m_rel; + }); // prx: sync mutex->data.read_sync(); @@ -116,6 +118,8 @@ s32 cellSyncMutexUnlock(vm::ptr mutex) { mutex.m_rel++; }); + + g_sync_mutex_wm.notify(mutex.addr()); return CELL_OK; } @@ -177,15 +181,12 @@ s32 cellSyncBarrierNotify(vm::ptr barrier) return CELL_SYNC_ERROR_ALIGN; } - while (barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryNotifyOp)) + g_sync_barrier_notify_wm.wait_op(barrier.addr(), [barrier]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncBarrierNotify(barrier_addr=0x%x) aborted", barrier.addr()); - return CELL_OK; - } - } + return barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryNotifyOp) == CELL_OK; + }); + + g_sync_barrier_wait_wm.notify(barrier.addr()); return CELL_OK; } @@ -202,7 +203,13 @@ s32 cellSyncBarrierTryNotify(vm::ptr barrier) return CELL_SYNC_ERROR_ALIGN; } - return barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryNotifyOp); + if (s32 res = barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryNotifyOp)) + { + return res; + } + + g_sync_barrier_wait_wm.notify(barrier.addr()); + return CELL_OK; } s32 syncBarrierTryWaitOp(CellSyncBarrier::data_t& barrier) @@ -236,15 +243,12 @@ s32 cellSyncBarrierWait(vm::ptr barrier) return CELL_SYNC_ERROR_ALIGN; } - while (barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryWaitOp)) + g_sync_barrier_wait_wm.wait_op(barrier.addr(), [barrier]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncBarrierWait(barrier_addr=0x%x) aborted", barrier.addr()); - return CELL_OK; - } - } + return barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryWaitOp) == CELL_OK; + }); + + g_sync_barrier_notify_wm.notify(barrier.addr()); return CELL_OK; } @@ -261,7 +265,13 @@ s32 cellSyncBarrierTryWait(vm::ptr barrier) return CELL_SYNC_ERROR_ALIGN; } - return barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryWaitOp); + if (s32 res = barrier->data.atomic_op_sync(CELL_OK, syncBarrierTryWaitOp)) + { + return res; + } + + g_sync_barrier_notify_wm.notify(barrier.addr()); + return CELL_OK; } s32 syncRwmInitialize(vm::ptr rwm, vm::ptr buffer, u32 buffer_size) @@ -299,6 +309,7 @@ s32 syncRwmTryReadBeginOp(CellSyncRwm::data_t& rwm) { return CELL_SYNC_ERROR_BUSY; } + rwm.m_readers++; return CELL_OK; } @@ -310,6 +321,7 @@ s32 syncRwmReadEndOp(CellSyncRwm::data_t& rwm) cellSync->Error("syncRwmReadEndOp(rwm_addr=0x%x): m_readers == 0 (m_writers=%d)", Memory.RealToVirtualAddr(&rwm), (u16)rwm.m_writers); return CELL_SYNC_ERROR_ABORT; } + rwm.m_readers--; return CELL_OK; } @@ -328,21 +340,22 @@ s32 cellSyncRwmRead(vm::ptr rwm, vm::ptr buffer) } // prx: increase m_readers, wait until m_writers is zero - while (rwm->data.atomic_op(CELL_OK, syncRwmTryReadBeginOp)) + g_sync_rwm_read_wm.wait_op(rwm.addr(), [rwm]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncRwmRead(rwm_addr=0x%x) aborted", rwm.addr()); - return CELL_OK; - } - } + return rwm->data.atomic_op(CELL_OK, syncRwmTryReadBeginOp) == CELL_OK; + }); // copy data to buffer_addr memcpy(buffer.get_ptr(), rwm->m_buffer.get_ptr(), (u32)rwm->m_size); // prx: decrease m_readers (return 0x8041010C if already zero) - return rwm->data.atomic_op(CELL_OK, syncRwmReadEndOp); + if (s32 res = rwm->data.atomic_op(CELL_OK, syncRwmReadEndOp)) + { + return res; + } + + g_sync_rwm_write_wm.notify(rwm.addr()); + return CELL_OK; } s32 cellSyncRwmTryRead(vm::ptr rwm, vm::ptr buffer) @@ -365,7 +378,13 @@ s32 cellSyncRwmTryRead(vm::ptr rwm, vm::ptr buffer) memcpy(buffer.get_ptr(), rwm->m_buffer.get_ptr(), (u32)rwm->m_size); - return rwm->data.atomic_op(CELL_OK, syncRwmReadEndOp); + if (s32 res = rwm->data.atomic_op(CELL_OK, syncRwmReadEndOp)) + { + return res; + } + + g_sync_rwm_write_wm.notify(rwm.addr()); + return CELL_OK; } s32 syncRwmTryWriteBeginOp(CellSyncRwm::data_t& rwm) @@ -374,6 +393,7 @@ s32 syncRwmTryWriteBeginOp(CellSyncRwm::data_t& rwm) { return CELL_SYNC_ERROR_BUSY; } + rwm.m_writers = 1; return CELL_OK; } @@ -391,32 +411,23 @@ s32 cellSyncRwmWrite(vm::ptr rwm, vm::ptr buffer) return CELL_SYNC_ERROR_ALIGN; } - while (rwm->data.atomic_op(CELL_OK, syncRwmTryWriteBeginOp)) + g_sync_rwm_read_wm.wait_op(rwm.addr(), [rwm]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncRwmWrite(rwm_addr=0x%x) aborted (I)", rwm.addr()); - return CELL_OK; - } - } + return rwm->data.atomic_op(CELL_OK, syncRwmTryWriteBeginOp) == CELL_OK; + }); // prx: wait until m_readers == 0 - while (rwm->data.read_relaxed().m_readers.ToBE()) + g_sync_rwm_write_wm.wait_op(rwm.addr(), [rwm]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncRwmWrite(rwm_addr=0x%x) aborted (II)", rwm.addr()); - return CELL_OK; - } - } + return rwm->data.read_relaxed().m_readers.ToBE() == 0; + }); // prx: copy data from buffer_addr memcpy(rwm->m_buffer.get_ptr(), buffer.get_ptr(), (u32)rwm->m_size); // prx: sync and zeroize m_readers and m_writers rwm->data.exchange({}); + g_sync_rwm_read_wm.notify(rwm.addr()); return CELL_OK; } @@ -434,7 +445,7 @@ s32 cellSyncRwmTryWrite(vm::ptr rwm, vm::ptr buffer) } // prx: compare m_readers | m_writers with 0, return if not zero, set m_writers to 1 - if (!rwm->data.compare_and_swap_test({}, {be_t::make(0), be_t::make(1)})) + if (!rwm->data.compare_and_swap_test({}, { be_t::make(0), be_t::make(1) })) { return CELL_SYNC_ERROR_BUSY; } @@ -444,6 +455,7 @@ s32 cellSyncRwmTryWrite(vm::ptr rwm, vm::ptr buffer) // prx: sync and zeroize m_readers and m_writers rwm->data.exchange({}); + g_sync_rwm_read_wm.notify(rwm.addr()); return CELL_OK; } @@ -520,24 +532,20 @@ s32 cellSyncQueuePush(vm::ptr queue, vm::ptr buffer) assert(((u32)data.m_v1 & 0xffffff) <= depth && ((u32)data.m_v2 & 0xffffff) <= depth); u32 position; - while (queue->data.atomic_op(CELL_OK, [depth, &position](CellSyncQueue::data_t& queue) -> s32 + g_sync_queue_wm.wait_op(queue.addr(), [queue, depth, &position]() { - return syncQueueTryPushOp(queue, depth, position); - })) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) + return CELL_OK == queue->data.atomic_op(CELL_OK, [depth, &position](CellSyncQueue::data_t& queue) -> s32 { - cellSync->Warning("cellSyncQueuePush(queue_addr=0x%x) aborted", queue.addr()); - return CELL_OK; - } - } + return syncQueueTryPushOp(queue, depth, position); + }); + }); // prx: memcpy(position * m_size + m_addr, buffer_addr, m_size), sync memcpy(&queue->m_buffer[position * size], buffer.get_ptr(), size); // prx: atomically insert 0 in 5th u8 queue->data &= { be_t::make(~0), be_t::make(0xffffff) }; + g_sync_queue_wm.notify(queue.addr()); return CELL_OK; } @@ -570,6 +578,7 @@ s32 cellSyncQueueTryPush(vm::ptr queue, vm::ptr buffe memcpy(&queue->m_buffer[position * size], buffer.get_ptr(), size); queue->data &= { be_t::make(~0), be_t::make(0xffffff) }; + g_sync_queue_wm.notify(queue.addr()); return CELL_OK; } @@ -612,24 +621,20 @@ s32 cellSyncQueuePop(vm::ptr queue, vm::ptr buffer) assert(((u32)data.m_v1 & 0xffffff) <= depth && ((u32)data.m_v2 & 0xffffff) <= depth); u32 position; - while (queue->data.atomic_op(CELL_OK, [depth, &position](CellSyncQueue::data_t& queue) -> s32 + g_sync_queue_wm.wait_op(queue.addr(), [queue, depth, &position]() { - return syncQueueTryPopOp(queue, depth, position); - })) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) + return CELL_OK == queue->data.atomic_op(CELL_OK, [depth, &position](CellSyncQueue::data_t& queue) -> s32 { - cellSync->Warning("cellSyncQueuePop(queue_addr=0x%x) aborted", queue.addr()); - return CELL_OK; - } - } + return syncQueueTryPopOp(queue, depth, position); + }); + }); // prx: (sync), memcpy(buffer_addr, position * m_size + m_addr, m_size) memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size); // prx: atomically insert 0 in first u8 queue->data &= { be_t::make(0xffffff), be_t::make(~0) }; + g_sync_queue_wm.notify(queue.addr()); return CELL_OK; } @@ -662,6 +667,7 @@ s32 cellSyncQueueTryPop(vm::ptr queue, vm::ptr buffer) memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size); queue->data &= { be_t::make(0xffffff), be_t::make(~0) }; + g_sync_queue_wm.notify(queue.addr()); return CELL_OK; } @@ -698,21 +704,17 @@ s32 cellSyncQueuePeek(vm::ptr queue, vm::ptr buffer) assert(((u32)data.m_v1 & 0xffffff) <= depth && ((u32)data.m_v2 & 0xffffff) <= depth); u32 position; - while (queue->data.atomic_op(CELL_OK, [depth, &position](CellSyncQueue::data_t& queue) -> s32 + g_sync_queue_wm.wait_op(queue.addr(), [queue, depth, &position]() { - return syncQueueTryPeekOp(queue, depth, position); - })) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) + return CELL_OK == queue->data.atomic_op(CELL_OK, [depth, &position](CellSyncQueue::data_t& queue) -> s32 { - cellSync->Warning("cellSyncQueuePeek(queue_addr=0x%x) aborted", queue.addr()); - return CELL_OK; - } - } + return syncQueueTryPeekOp(queue, depth, position); + }); + }); memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size); queue->data &= { be_t::make(0xffffff), be_t::make(~0) }; + g_sync_queue_wm.notify(queue.addr()); return CELL_OK; } @@ -745,6 +747,7 @@ s32 cellSyncQueueTryPeek(vm::ptr queue, vm::ptr buffer) memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size); queue->data &= { be_t::make(0xffffff), be_t::make(~0) }; + g_sync_queue_wm.notify(queue.addr()); return CELL_OK; } @@ -787,47 +790,40 @@ s32 cellSyncQueueClear(vm::ptr queue) assert(((u32)data.m_v1 & 0xffffff) <= depth && ((u32)data.m_v2 & 0xffffff) <= depth); // TODO: optimize if possible - while (queue->data.atomic_op(CELL_OK, [depth](CellSyncQueue::data_t& queue) -> s32 + g_sync_queue_wm.wait_op(queue.addr(), [queue, depth]() { - const u32 v1 = (u32)queue.m_v1; - // prx: extract first u8, repeat if not zero, insert 1 - if (v1 >> 24) + return CELL_OK == queue->data.atomic_op(CELL_OK, [depth](CellSyncQueue::data_t& queue) -> s32 { - return CELL_SYNC_ERROR_BUSY; - } - queue.m_v1 = v1 | 0x1000000; - return CELL_OK; - })) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncQueueClear(queue_addr=0x%x) aborted (I)", queue.addr()); - return CELL_OK; - } - } + const u32 v1 = (u32)queue.m_v1; + // prx: extract first u8, repeat if not zero, insert 1 + if (v1 >> 24) + { + return CELL_SYNC_ERROR_BUSY; + } - while (queue->data.atomic_op(CELL_OK, [depth](CellSyncQueue::data_t& queue) -> s32 - { - const u32 v2 = (u32)queue.m_v2; - // prx: extract 5th u8, repeat if not zero, insert 1 - if (v2 >> 24) - { - return CELL_SYNC_ERROR_BUSY; - } - queue.m_v2 = v2 | 0x1000000; - return CELL_OK; - })) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack - if (Emu.IsStopped()) - { - cellSync->Warning("cellSyncQueueClear(queue_addr=0x%x) aborted (II)", queue.addr()); + queue.m_v1 = v1 | 0x1000000; return CELL_OK; - } - } + }); + }); + + g_sync_queue_wm.wait_op(queue.addr(), [queue, depth]() + { + return CELL_OK == queue->data.atomic_op(CELL_OK, [depth](CellSyncQueue::data_t& queue) -> s32 + { + const u32 v2 = (u32)queue.m_v2; + // prx: extract 5th u8, repeat if not zero, insert 1 + if (v2 >> 24) + { + return CELL_SYNC_ERROR_BUSY; + } + + queue.m_v2 = v2 | 0x1000000; + return CELL_OK; + }); + }); queue->data.exchange({}); + g_sync_queue_wm.notify(queue.addr()); return CELL_OK; } @@ -1092,7 +1088,7 @@ s32 syncLFQueueGetPushPointer(vm::ptr queue, s32& pointer, u32 } } -s32 _cellSyncLFQueueGetPushPointer(vm::ptr queue, vm::ptr> pointer, u32 isBlocking, u32 useEventQueue) +s32 _cellSyncLFQueueGetPushPointer(vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { cellSync->Todo("_cellSyncLFQueueGetPushPointer(queue_addr=0x%x, pointer_addr=0x%x, isBlocking=%d, useEventQueue=%d)", queue.addr(), pointer.addr(), isBlocking, useEventQueue); @@ -1111,7 +1107,7 @@ s32 syncLFQueueGetPushPointer2(vm::ptr queue, s32& pointer, u32 return CELL_OK; } -s32 _cellSyncLFQueueGetPushPointer2(vm::ptr queue, vm::ptr> pointer, u32 isBlocking, u32 useEventQueue) +s32 _cellSyncLFQueueGetPushPointer2(vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { // arguments copied from _cellSyncLFQueueGetPushPointer cellSync->Todo("_cellSyncLFQueueGetPushPointer2(queue_addr=0x%x, pointer_addr=0x%x, isBlocking=%d, useEventQueue=%d)", @@ -1471,7 +1467,7 @@ s32 syncLFQueueGetPopPointer(vm::ptr queue, s32& pointer, u32 i } } -s32 _cellSyncLFQueueGetPopPointer(vm::ptr queue, vm::ptr> pointer, u32 isBlocking, u32 arg4, u32 useEventQueue) +s32 _cellSyncLFQueueGetPopPointer(vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 arg4, u32 useEventQueue) { cellSync->Todo("_cellSyncLFQueueGetPopPointer(queue_addr=0x%x, pointer_addr=0x%x, isBlocking=%d, arg4=%d, useEventQueue=%d)", queue.addr(), pointer.addr(), isBlocking, arg4, useEventQueue); @@ -1490,7 +1486,7 @@ s32 syncLFQueueGetPopPointer2(vm::ptr queue, s32& pointer, u32 return CELL_OK; } -s32 _cellSyncLFQueueGetPopPointer2(vm::ptr queue, vm::ptr> pointer, u32 isBlocking, u32 useEventQueue) +s32 _cellSyncLFQueueGetPopPointer2(vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { // arguments copied from _cellSyncLFQueueGetPopPointer cellSync->Todo("_cellSyncLFQueueGetPopPointer2(queue_addr=0x%x, pointer_addr=0x%x, isBlocking=%d, useEventQueue=%d)", @@ -1797,7 +1793,7 @@ s32 cellSyncLFQueueClear(vm::ptr queue) return CELL_OK; } -s32 cellSyncLFQueueSize(vm::ptr queue, vm::ptr> size) +s32 cellSyncLFQueueSize(vm::ptr queue, vm::ptr size) { cellSync->Warning("cellSyncLFQueueSize(queue_addr=0x%x, size_addr=0x%x)", queue.addr(), size.addr()); @@ -1832,7 +1828,7 @@ s32 cellSyncLFQueueSize(vm::ptr queue, vm::ptr> size) } } -s32 cellSyncLFQueueDepth(vm::ptr queue, vm::ptr> depth) +s32 cellSyncLFQueueDepth(vm::ptr queue, vm::ptr depth) { cellSync->Log("cellSyncLFQueueDepth(queue_addr=0x%x, depth_addr=0x%x)", queue.addr(), depth.addr()); @@ -1849,7 +1845,7 @@ s32 cellSyncLFQueueDepth(vm::ptr queue, vm::ptr> dept return CELL_OK; } -s32 _cellSyncLFQueueGetSignalAddress(vm::ptr queue, vm::ptr> ppSignal) +s32 _cellSyncLFQueueGetSignalAddress(vm::ptr queue, vm::ptr ppSignal) { cellSync->Log("_cellSyncLFQueueGetSignalAddress(queue_addr=0x%x, ppSignal_addr=0x%x)", queue.addr(), ppSignal.addr()); @@ -1866,7 +1862,7 @@ s32 _cellSyncLFQueueGetSignalAddress(vm::ptr queue, vm::p return CELL_OK; } -s32 cellSyncLFQueueGetDirection(vm::ptr queue, vm::ptr> direction) +s32 cellSyncLFQueueGetDirection(vm::ptr queue, vm::ptr direction) { cellSync->Log("cellSyncLFQueueGetDirection(queue_addr=0x%x, direction_addr=0x%x)", queue.addr(), direction.addr()); @@ -1883,7 +1879,7 @@ s32 cellSyncLFQueueGetDirection(vm::ptr queue, vm::ptr queue, vm::ptr> entry_size) +s32 cellSyncLFQueueGetEntrySize(vm::ptr queue, vm::ptr entry_size) { cellSync->Log("cellSyncLFQueueGetEntrySize(queue_addr=0x%x, entry_size_addr=0x%x)", queue.addr(), entry_size.addr()); @@ -1990,7 +1986,7 @@ void cellSync_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { - libsre = (u32)Memory.PRXMem.AllocAlign(sizeof(libsre_data), 4096); + 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 de4ca912e0..7359814b89 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp @@ -458,7 +458,7 @@ void cellSync2_init(Module *pxThis) #ifdef PRX_DEBUG CallAfter([]() { - libsync2 = (u32)Memory.PRXMem.AllocAlign(sizeof(libsync2_data), 4096); + 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/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index e096a7e657..2c4271e8ff 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -23,7 +23,7 @@ typedef void (*CellHddGameStatCallback)(vm::ptr cbResult, v Module *cellSysutil = nullptr; -int cellSysutilGetSystemParamInt(int id, vm::ptr> value) +int cellSysutilGetSystemParamInt(int id, vm::ptr value) { cellSysutil->Log("cellSysutilGetSystemParamInt(id=0x%x, value_addr=0x%x)", id, value.addr()); @@ -825,7 +825,7 @@ int cellSysutilGetBgmPlaybackStatus2(vm::ptr stat return CELL_OK; } -int cellWebBrowserEstimate2(const vm::ptr config, vm::ptr> memSize) +int cellWebBrowserEstimate2(const vm::ptr config, vm::ptr memSize) { cellSysutil->Warning("cellWebBrowserEstimate2(config_addr=0x%x, memSize_addr=0x%x)", config.addr(), memSize.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp index 8c4d653abc..8815280edc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp @@ -55,7 +55,7 @@ int cellUserInfoEnableOverlay() return CELL_OK; } -int cellUserInfoGetList(vm::ptr> listNum, vm::ptr listBuf, vm::ptr> currentUserId) +int cellUserInfoGetList(vm::ptr listNum, vm::ptr listBuf, vm::ptr currentUserId) { cellUserInfo->Warning("cellUserInfoGetList(listNum_addr=0x%x, listBuf_addr=0x%x, currentUserId_addr=0x%x)", listNum.addr(), listBuf.addr(), currentUserId.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index 55dc0e5c1e..e14cf2413c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -484,7 +484,7 @@ int cellVdecQueryAttrEx(vm::ptr type, vm::ptrcodecType, type->profileLevel, type->codecSpecificInfo_addr, attr); } -int cellVdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr> handle) +int cellVdecOpen(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { cellVdec->Warning("cellVdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", type.addr(), res.addr(), cb.addr(), handle.addr()); @@ -494,7 +494,7 @@ int cellVdecOpen(vm::ptr type, vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr> handle) +int cellVdecOpenEx(vm::ptr type, vm::ptr res, vm::ptr cb, vm::ptr handle) { cellVdec->Warning("cellVdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)", type.addr(), res.addr(), cb.addr(), handle.addr()); @@ -658,7 +658,7 @@ int cellVdecGetPicture(u32 handle, vm::ptr format, vm:: return CELL_OK; } -int cellVdecGetPicItem(u32 handle, vm::ptr> picItem_ptr) +int cellVdecGetPicItem(u32 handle, vm::ptr picItem_ptr) { cellVdec->Log("cellVdecGetPicItem(handle=%d, picItem_ptr_addr=0x%x)", handle, picItem_ptr.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp index 749dc18f42..d4790ca782 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp @@ -35,7 +35,7 @@ u32 vpostOpen(VpostInstance* data) return id; } -int cellVpostOpen(vm::ptr cfgParam, vm::ptr resource, vm::ptr> handle) +int cellVpostOpen(vm::ptr cfgParam, vm::ptr resource, vm::ptr handle) { cellVpost->Warning("cellVpostOpen(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)", cfgParam.addr(), resource.addr(), handle.addr()); @@ -45,7 +45,7 @@ int cellVpostOpen(vm::ptr cfgParam, vm::ptr cfgParam, vm::ptr resource, vm::ptr> handle) +int cellVpostOpenEx(vm::ptr cfgParam, vm::ptr resource, vm::ptr handle) { cellVpost->Warning("cellVpostOpenEx(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)", cfgParam.addr(), resource.addr(), handle.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp index 618be0c3c2..fb55cca939 100644 --- a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp @@ -140,7 +140,7 @@ int cellAANDisconnect(u32 receive, u32 receivePortNo, u32 source, u32 sourcePort return CELL_OK; } -int cellSSPlayerCreate(vm::ptr> handle, vm::ptr config) +int cellSSPlayerCreate(vm::ptr handle, vm::ptr config) { libmixer->Warning("cellSSPlayerCreate(handle_addr=0x%x, config_addr=0x%x)", handle.addr(), config.addr()); @@ -471,14 +471,14 @@ int cellSurMixerCreate(vm::ptr config) return CELL_OK; } -int cellSurMixerGetAANHandle(vm::ptr> handle) +int cellSurMixerGetAANHandle(vm::ptr handle) { libmixer->Warning("cellSurMixerGetAANHandle(handle_addr=0x%x) -> %d", handle.addr(), 0x11111111); *handle = 0x11111111; return CELL_OK; } -int cellSurMixerChStripGetAANPortNo(vm::ptr> port, u32 type, u32 index) +int cellSurMixerChStripGetAANPortNo(vm::ptr port, u32 type, u32 index) { libmixer->Warning("cellSurMixerChStripGetAANPortNo(port_addr=0x%x, type=0x%x, index=0x%x) -> 0x%x", port.addr(), type, index, (type << 16) | index); *port = (type << 16) | index; @@ -593,7 +593,7 @@ int cellSurMixerPause(u32 type) return CELL_OK; } -int cellSurMixerGetCurrentBlockTag(vm::ptr> tag) +int cellSurMixerGetCurrentBlockTag(vm::ptr tag) { libmixer->Log("cellSurMixerGetCurrentBlockTag(tag_addr=0x%x)", tag.addr()); @@ -601,7 +601,7 @@ int cellSurMixerGetCurrentBlockTag(vm::ptr> tag) return CELL_OK; } -int cellSurMixerGetTimestamp(u64 tag, vm::ptr> stamp) +int cellSurMixerGetTimestamp(u64 tag, vm::ptr stamp) { libmixer->Log("cellSurMixerGetTimestamp(tag=0x%llx, stamp_addr=0x%x)", tag, stamp.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index add879bb34..e9d7b4fd0a 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -181,7 +181,7 @@ int sceNpDrmExecuteGamePurchase() return CELL_OK; } -int sceNpDrmGetTimelimit(u32 drm_path_addr, vm::ptr> time_remain_usec) +int sceNpDrmGetTimelimit(u32 drm_path_addr, vm::ptr time_remain_usec) { UNIMPLEMENTED_FUNC(sceNp); return CELL_OK; @@ -901,7 +901,7 @@ int sceNpManagerUnregisterCallback() return CELL_OK; } -int sceNpManagerGetStatus(vm::ptr> status) +int sceNpManagerGetStatus(vm::ptr status) { sceNp->Log("sceNpManagerGetStatus(status_addr=0x%x)", status.addr()); @@ -962,9 +962,17 @@ int sceNpManagerGetAccountAge() return CELL_OK; } -int sceNpManagerGetContentRatingFlag() +int sceNpManagerGetContentRatingFlag(vm::ptr isRestricted, vm::ptr age) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp->Warning("sceNpManagerGetContentRatingFlag(isRestricted=%d, age=%d)", isRestricted, age); + + if (!sceNpInstance.m_bSceNpInitialized) + return SCE_NP_ERROR_NOT_INITIALIZED; + + // TODO: read user's parental control information + *isRestricted = 0; + *age = 18; + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index 612ddb9e2f..375a830aa3 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -84,7 +84,7 @@ int sceNpTrophyInit(u32 pool_addr, u32 poolSize, u32 containerId, u64 options) return CELL_OK; } -int sceNpTrophyCreateContext(vm::ptr> context, vm::ptr commID, vm::ptr commSign, u64 options) +int sceNpTrophyCreateContext(vm::ptr context, vm::ptr commID, vm::ptr commSign, u64 options) { sceNpTrophy->Warning("sceNpTrophyCreateContext(context_addr=0x%x, commID_addr=0x%x, commSign_addr=0x%x, options=0x%llx)", context.addr(), commID.addr(), commSign.addr(), options); @@ -122,7 +122,7 @@ int sceNpTrophyCreateContext(vm::ptr> context, vm::ptr> handle) +int sceNpTrophyCreateHandle(vm::ptr handle) { sceNpTrophy->Warning("sceNpTrophyCreateHandle(handle_addr=0x%x)", handle.addr()); @@ -212,7 +212,7 @@ int sceNpTrophySetSoundLevel() return CELL_OK; } -int sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, vm::ptr> reqspace, u64 options) +int sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, vm::ptr reqspace, u64 options) { sceNpTrophy->Warning("sceNpTrophyGetRequiredDiskSpace(context=%d, handle=%d, reqspace_addr=0x%x, options=0x%llx)", context, handle, reqspace.addr(), options); @@ -307,7 +307,7 @@ int sceNpTrophyDestroyHandle() return CELL_OK; } -int sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::ptr> platinumId) +int sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::ptr platinumId) { sceNpTrophy->Warning("sceNpTrophyUnlockTrophy(context=%d, handle=%d, trophyId=%d, platinumId_addr=0x%x)", context, handle, trophyId, platinumId.addr()); @@ -344,7 +344,7 @@ int sceNpTrophyTerm() return CELL_OK; } -int sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, vm::ptr flags, vm::ptr> count) +int sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, vm::ptr flags, vm::ptr count) { sceNpTrophy->Warning("sceNpTrophyGetTrophyUnlockState(context=%d, handle=%d, flags_addr=0x%x, count_addr=0x%x)", context, handle, flags.addr(), count.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index d445a37911..61430024f0 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -81,7 +81,7 @@ s64 sys_prx_exitspawn_with_level() return CELL_OK; } -int sys_spu_elf_get_information(u32 elf_img, vm::ptr> entry, vm::ptr> nseg) +int sys_spu_elf_get_information(u32 elf_img, vm::ptr entry, vm::ptr nseg) { sysPrxForUser->Todo("sys_spu_elf_get_information(elf_img=0x%x, entry_addr=0x%x, nseg_addr=0x%x)", elf_img, entry.addr(), nseg.addr()); return CELL_OK; @@ -106,7 +106,7 @@ int sys_spu_image_close(vm::ptr img) return CELL_OK; } -int sys_raw_spu_load(s32 id, vm::ptr path, vm::ptr> entry) +int sys_raw_spu_load(s32 id, vm::ptr path, vm::ptr entry) { sysPrxForUser->Warning("sys_raw_spu_load(id=0x%x, path_addr=0x%x('%s'), entry_addr=0x%x)", id, path.addr(), path.get_ptr(), entry.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index 0c3c18224b..8cbefa8055 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -111,7 +111,7 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil } -int cellFsSdataOpen(vm::ptr path, int flags, vm::ptr> fd, vm::ptr> arg, u64 size) +int cellFsSdataOpen(vm::ptr path, int flags, vm::ptr> fd, vm::ptr arg, u64 size) { sys_fs->Warning("cellFsSdataOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx) -> cellFsOpen()", path.get_ptr(), flags, fd.addr(), arg.addr(), size); @@ -136,7 +136,7 @@ int cellFsSdataOpen(vm::ptr path, int flags, vm::ptr> fd, return cellFsOpen(path, flags, fd, arg, size); } -int cellFsSdataOpenByFd(int mself_fd, int flags, vm::ptr> sdata_fd, u64 offset, vm::ptr> arg, u64 size) +int cellFsSdataOpenByFd(int mself_fd, int flags, vm::ptr sdata_fd, u64 offset, vm::ptr arg, u64 size) { sys_fs->Todo("cellFsSdataOpenByFd(mself_fd=0x%x, flags=0x%x, sdata_fd_addr=0x%x, offset=0x%llx, arg_addr=0x%x, size=0x%llx) -> cellFsOpen()", mself_fd, flags, sdata_fd.addr(), offset, arg.addr(), size); @@ -208,7 +208,7 @@ void fsAioRead(u32 fd, vm::ptr aio, int xid, vm::ptr aio, vm::ptr> aio_id, vm::ptr xaio, int error, int xid, u64 size)> func) +int cellFsAioRead(vm::ptr aio, vm::ptr aio_id, vm::ptr xaio, int error, int xid, u64 size)> func) { sys_fs->Warning("cellFsAioRead(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr()); @@ -239,7 +239,7 @@ int cellFsAioRead(vm::ptr aio, vm::ptr> aio_id, vm::ptr aio, vm::ptr> aio_id, vm::ptr xaio, int error, int xid, u64 size)> func) +int cellFsAioWrite(vm::ptr aio, vm::ptr aio_id, vm::ptr xaio, int error, int xid, u64 size)> func) { sys_fs->Todo("cellFsAioWrite(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr()); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp index a98f61d002..90e781ead1 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp @@ -19,7 +19,7 @@ extern "C" Module *sys_net = nullptr; -vm::ptr> g_lastError = vm::ptr>::make(0); +vm::ptr g_lastError = vm::ptr::make(0); // Auxiliary Functions @@ -341,7 +341,7 @@ int socketselect() int sys_net_initialize_network_ex(vm::ptr param) { sys_net->Warning("sys_net_initialize_network_ex(param_addr=0x%x)", param.addr()); - g_lastError = vm::ptr>::make((u32)Memory.Alloc(4, 1)); + g_lastError = vm::ptr::make((u32)Memory.Alloc(4, 1)); #ifdef _WIN32 WSADATA wsaData; WORD wVersionRequested = MAKEWORD(1,1); @@ -474,7 +474,7 @@ int sys_net_finalize_network() { sys_net->Warning("sys_net_initialize_network_ex()"); Memory.Free(g_lastError.addr()); - g_lastError = vm::ptr>::make(0); + g_lastError = vm::ptr::make(0); #ifdef _WIN32 WSACleanup(); #endif diff --git a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp index e7dceb38c6..9c5feb2a0c 100644 --- a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp +++ b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp @@ -30,7 +30,7 @@ struct FsRingBufferConfig } fs_config; -s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::ptr> arg, u64 size) +s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::ptr arg, u64 size) { sys_fs->Log("cellFsOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx)", path.get_ptr(), flags, fd.addr(), arg.addr(), size); @@ -137,7 +137,7 @@ s32 cellFsRead(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr> nread) return CELL_OK; } -s32 cellFsWrite(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr> nwrite) +s32 cellFsWrite(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nwrite) { sys_fs->Log("cellFsWrite(fd=%d, buf_addr=0x%x, nbytes=0x%llx, nwrite_addr=0x%x)", fd, buf.addr(), nbytes, nwrite.addr()); @@ -170,7 +170,7 @@ s32 cellFsClose(u32 fd) return CELL_OK; } -s32 cellFsOpendir(vm::ptr path, vm::ptr> fd) +s32 cellFsOpendir(vm::ptr path, vm::ptr fd) { sys_fs->Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.get_ptr(), fd.addr()); @@ -187,7 +187,7 @@ s32 cellFsOpendir(vm::ptr path, vm::ptr> fd) return CELL_OK; } -s32 cellFsReaddir(u32 fd, vm::ptr dir, vm::ptr> nread) +s32 cellFsReaddir(u32 fd, vm::ptr dir, vm::ptr nread) { sys_fs->Warning("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.addr(), nread.addr()); @@ -496,7 +496,7 @@ s32 cellFsTruncate(vm::ptr path, u64 size) return CELL_OK; } -s32 cellFsFGetBlockSize(u32 fd, vm::ptr> sector_size, vm::ptr> block_size) +s32 cellFsFGetBlockSize(u32 fd, vm::ptr sector_size, vm::ptr block_size) { sys_fs->Warning("cellFsFGetBlockSize(fd=%d, sector_size_addr=0x%x, block_size_addr=0x%x)", fd, sector_size.addr(), block_size.addr()); @@ -512,7 +512,7 @@ s32 cellFsFGetBlockSize(u32 fd, vm::ptr> sector_size, vm::ptr path, vm::ptr> sector_size, vm::ptr> block_size) +s32 cellFsGetBlockSize(vm::ptr path, vm::ptr sector_size, vm::ptr block_size) { sys_fs->Warning("cellFsGetBlockSize(file='%s', sector_size_addr=0x%x, block_size_addr=0x%x)", path.get_ptr(), sector_size.addr(), block_size.addr()); @@ -525,7 +525,7 @@ s32 cellFsGetBlockSize(vm::ptr path, vm::ptr> sector_size, return CELL_OK; } -s32 cellFsGetFreeSize(vm::ptr path, vm::ptr> block_size, vm::ptr> block_count) +s32 cellFsGetFreeSize(vm::ptr path, vm::ptr block_size, vm::ptr block_count) { sys_fs->Warning("cellFsGetFreeSize(path=\"%s\", block_size_addr=0x%x, block_count_addr=0x%x)", path.get_ptr(), block_size.addr(), block_count.addr()); @@ -539,7 +539,7 @@ s32 cellFsGetFreeSize(vm::ptr path, vm::ptr> block_size, v return CELL_OK; } -s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 entries_size, vm::ptr> data_count) +s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 entries_size, vm::ptr data_count) { sys_fs->Warning("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size=0x%x, data_count_addr=0x%x)", fd, entries.addr(), entries_size, data_count.addr()); @@ -637,7 +637,7 @@ s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr ringbuf) return CELL_OK; } -s32 cellFsStReadGetStatus(u32 fd, vm::ptr> status) +s32 cellFsStReadGetStatus(u32 fd, vm::ptr status) { sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, status_addr=0x%x)", fd, status.addr()); @@ -651,7 +651,7 @@ s32 cellFsStReadGetStatus(u32 fd, vm::ptr> status) return CELL_OK; } -s32 cellFsStReadGetRegid(u32 fd, vm::ptr> regid) +s32 cellFsStReadGetRegid(u32 fd, vm::ptr regid) { sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, regid_addr=0x%x)", fd, regid.addr()); @@ -694,7 +694,7 @@ s32 cellFsStReadStop(u32 fd) return CELL_OK; } -s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr> rsize) +s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr rsize) { sys_fs->Warning("cellFsStRead(fd=%d, buf_addr=0x%x, size=0x%llx, rsize_addr=0x%x)", fd, buf_addr, size, rsize.addr()); @@ -714,7 +714,7 @@ s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr> rsize) return CELL_OK; } -s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr> addr, vm::ptr> size) +s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr addr, vm::ptr size) { sys_fs->Todo("cellFsStReadGetCurrentAddr(fd=%d, addr_addr=0x%x, size_addr=0x%x)", fd, addr.addr(), size.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/lv2Fs.h b/rpcs3/Emu/SysCalls/lv2/lv2Fs.h index c7cf8814fe..6adb71cdc9 100644 --- a/rpcs3/Emu/SysCalls/lv2/lv2Fs.h +++ b/rpcs3/Emu/SysCalls/lv2/lv2Fs.h @@ -128,12 +128,12 @@ struct CellFsRingBuffer }; // SysCalls -s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::ptr> arg, u64 size); +s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::ptr arg, u64 size); s32 cellFsRead(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr> nread); -s32 cellFsWrite(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr> nwrite); +s32 cellFsWrite(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nwrite); s32 cellFsClose(u32 fd); -s32 cellFsOpendir(vm::ptr path, vm::ptr> fd); -s32 cellFsReaddir(u32 fd, vm::ptr dir, vm::ptr> nread); +s32 cellFsOpendir(vm::ptr path, vm::ptr fd); +s32 cellFsReaddir(u32 fd, vm::ptr dir, vm::ptr nread); s32 cellFsClosedir(u32 fd); s32 cellFsStat(vm::ptr path, vm::ptr sb); s32 cellFsFstat(u32 fd, vm::ptr sb); @@ -146,19 +146,19 @@ s32 cellFsUnlink(vm::ptr path); s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr> pos); s32 cellFsFtruncate(u32 fd, u64 size); s32 cellFsTruncate(vm::ptr path, u64 size); -s32 cellFsFGetBlockSize(u32 fd, vm::ptr> sector_size, vm::ptr> block_size); -s32 cellFsGetBlockSize(vm::ptr path, vm::ptr> sector_size, vm::ptr> block_size); -s32 cellFsGetFreeSize(vm::ptr path, vm::ptr> block_size, vm::ptr> block_count); -s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 entries_size, vm::ptr> data_count); +s32 cellFsFGetBlockSize(u32 fd, vm::ptr sector_size, vm::ptr block_size); +s32 cellFsGetBlockSize(vm::ptr path, vm::ptr sector_size, vm::ptr block_size); +s32 cellFsGetFreeSize(vm::ptr path, vm::ptr block_size, vm::ptr block_count); +s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 entries_size, vm::ptr data_count); s32 cellFsStReadInit(u32 fd, vm::ptr ringbuf); s32 cellFsStReadFinish(u32 fd); s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr ringbuf); -s32 cellFsStReadGetStatus(u32 fd, vm::ptr> status); -s32 cellFsStReadGetRegid(u32 fd, vm::ptr> regid); +s32 cellFsStReadGetStatus(u32 fd, vm::ptr status); +s32 cellFsStReadGetRegid(u32 fd, vm::ptr regid); s32 cellFsStReadStart(u32 fd, u64 offset, u64 size); s32 cellFsStReadStop(u32 fd); -s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr> rsize); -s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr> addr_addr, vm::ptr> size); +s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr rsize); +s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr addr_addr, vm::ptr size); s32 cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size); s32 cellFsStReadWait(u32 fd, u64 size); s32 cellFsStReadWaitCallback(u32 fd, u64 size, vm::ptr func); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp index a51b9f977a..ab53f0699a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp @@ -9,7 +9,7 @@ SysCallBase sys_cond("sys_cond"); -s32 sys_cond_create(vm::ptr> cond_id, u32 mutex_id, vm::ptr attr) +s32 sys_cond_create(vm::ptr cond_id, u32 mutex_id, vm::ptr attr) { sys_cond.Log("sys_cond_create(cond_id_addr=0x%x, mutex_id=%d, attr_addr=0x%x)", cond_id.addr(), mutex_id, attr.addr()); @@ -80,9 +80,7 @@ s32 sys_cond_signal(u32 cond_id) if (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? cond->m_queue.pop_prio() : cond->m_queue.pop())) { - //cond->signal_stamp = get_system_time(); cond->signal.lock(target); - Emu.GetCPU().NotifyThread(target); if (Emu.IsStopped()) { @@ -108,9 +106,7 @@ s32 sys_cond_signal_all(u32 cond_id) while (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? cond->m_queue.pop_prio() : cond->m_queue.pop())) { cond->signaler = GetCurrentPPUThread().GetId(); - //cond->signal_stamp = get_system_time(); cond->signal.lock(target); - Emu.GetCPU().NotifyThread(target); if (Emu.IsStopped()) { @@ -147,9 +143,7 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id) u32 target = thread_id; { - //cond->signal_stamp = get_system_time(); cond->signal.lock(target); - Emu.GetCPU().NotifyThread(target); } if (Emu.IsStopped()) @@ -195,7 +189,6 @@ s32 sys_cond_wait(u32 cond_id, u64 timeout) { if (cond->signal.unlock(tid, tid) == SMR_OK) { - //const u64 stamp2 = get_system_time(); if (SMutexResult res = mutex->m_mutex.trylock(tid)) { if (res != SMR_FAILED) @@ -215,14 +208,11 @@ s32 sys_cond_wait(u32 cond_id, u64 timeout) } } mutex->recursive = 1; - const volatile u64 stamp = cond->signal_stamp; cond->signal.unlock(tid); - Emu.GetCPU().NotifyThread(cond->signaler); - //ConLog.Write("sys_cond_wait(): signal latency %lld (minimum %lld)", get_system_time() - stamp, stamp2 - stamp); return CELL_OK; } - SM_Sleep(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (counter++ > max_counter) { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.h b/rpcs3/Emu/SysCalls/lv2/sys_cond.h index c6ea124172..f1278a484d 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.h @@ -32,7 +32,7 @@ struct Cond }; // SysCalls -s32 sys_cond_create(vm::ptr> cond_id, u32 mutex_id, vm::ptr attr); +s32 sys_cond_create(vm::ptr cond_id, u32 mutex_id, vm::ptr attr); s32 sys_cond_destroy(u32 cond_id); s32 sys_cond_wait(u32 cond_id, u64 timeout); s32 sys_cond_signal(u32 cond_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp index e2f76cb351..701c827c40 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp @@ -27,7 +27,7 @@ u32 event_queue_create(u32 protocol, s32 type, u64 name_u64, u64 event_queue_key return id; } -s32 sys_event_queue_create(vm::ptr> equeue_id, vm::ptr attr, u64 event_queue_key, s32 size) +s32 sys_event_queue_create(vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size) { sys_event.Warning("sys_event_queue_create(equeue_id_addr=0x%x, attr_addr=0x%x, event_queue_key=0x%llx, size=%d)", equeue_id.addr(), attr.addr(), event_queue_key, size); @@ -112,7 +112,7 @@ s32 sys_event_queue_destroy(u32 equeue_id, int mode) return CELL_OK; } -s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ptr> number) +s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ptr number) { sys_event.Todo("sys_event_queue_tryreceive(equeue_id=%d, event_array_addr=0x%x, size=%d, number_addr=0x%x)", equeue_id, event_array.addr(), size, number.addr()); @@ -246,7 +246,7 @@ u32 event_port_create(u64 name) return id; } -s32 sys_event_port_create(vm::ptr> eport_id, s32 port_type, u64 name) +s32 sys_event_port_create(vm::ptr eport_id, s32 port_type, u64 name) { sys_event.Warning("sys_event_port_create(eport_id_addr=0x%x, port_type=0x%x, name=0x%llx)", eport_id.addr(), port_type, name); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event.h b/rpcs3/Emu/SysCalls/lv2/sys_event.h index 16b99d7ec9..61180f5982 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_event.h @@ -221,13 +221,13 @@ u32 event_port_create(u64 name); u32 event_queue_create(u32 protocol, s32 type, u64 name_u64, u64 event_queue_key, s32 size); // SysCalls -s32 sys_event_queue_create(vm::ptr> equeue_id, vm::ptr attr, u64 event_queue_key, s32 size); +s32 sys_event_queue_create(vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size); s32 sys_event_queue_destroy(u32 equeue_id, s32 mode); s32 sys_event_queue_receive(u32 equeue_id, vm::ptr dummy_event, u64 timeout); -s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ptr> number); +s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ptr number); s32 sys_event_queue_drain(u32 event_queue_id); -s32 sys_event_port_create(vm::ptr> eport_id, s32 port_type, u64 name); +s32 sys_event_port_create(vm::ptr eport_id, s32 port_type, u64 name); s32 sys_event_port_destroy(u32 eport_id); s32 sys_event_port_connect_local(u32 event_port_id, u32 event_queue_id); s32 sys_event_port_disconnect(u32 eport_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp index 22cd01956a..244d19cec4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp @@ -37,7 +37,7 @@ u32 EventFlag::check() return target; } -s32 sys_event_flag_create(vm::ptr> eflag_id, vm::ptr attr, u64 init) +s32 sys_event_flag_create(vm::ptr eflag_id, vm::ptr attr, u64 init) { sys_event_flag.Warning("sys_event_flag_create(eflag_id_addr=0x%x, attr_addr=0x%x, init=0x%llx)", eflag_id.addr(), attr.addr(), init); @@ -88,7 +88,7 @@ s32 sys_event_flag_destroy(u32 eflag_id) return CELL_OK; } -s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr> result, u64 timeout) +s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr result, u64 timeout) { sys_event_flag.Log("sys_event_flag_wait(eflag_id=%d, bitptn=0x%llx, mode=0x%x, result_addr=0x%x, timeout=%lld)", eflag_id, bitptn, mode, result.addr(), timeout); @@ -225,7 +225,7 @@ s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr> r } } -s32 sys_event_flag_trywait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr> result) +s32 sys_event_flag_trywait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr result) { sys_event_flag.Log("sys_event_flag_trywait(eflag_id=%d, bitptn=0x%llx, mode=0x%x, result_addr=0x%x)", eflag_id, bitptn, mode, result.addr()); @@ -316,7 +316,7 @@ s32 sys_event_flag_clear(u32 eflag_id, u64 bitptn) return CELL_OK; } -s32 sys_event_flag_cancel(u32 eflag_id, vm::ptr> num) +s32 sys_event_flag_cancel(u32 eflag_id, vm::ptr num) { sys_event_flag.Log("sys_event_flag_cancel(eflag_id=%d, num_addr=0x%x)", eflag_id, num.addr()); @@ -354,7 +354,7 @@ s32 sys_event_flag_cancel(u32 eflag_id, vm::ptr> num) return CELL_OK; } -s32 sys_event_flag_get(u32 eflag_id, vm::ptr> flags) +s32 sys_event_flag_get(u32 eflag_id, vm::ptr flags) { sys_event_flag.Log("sys_event_flag_get(eflag_id=%d, flags_addr=0x%x)", eflag_id, flags.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h index b3c12f18de..05309fb748 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h @@ -52,11 +52,11 @@ struct EventFlag u32 check(); }; -s32 sys_event_flag_create(vm::ptr> eflag_id, vm::ptr attr, u64 init); +s32 sys_event_flag_create(vm::ptr eflag_id, vm::ptr attr, u64 init); s32 sys_event_flag_destroy(u32 eflag_id); -s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr> result, u64 timeout); -s32 sys_event_flag_trywait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr> result); +s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr result, u64 timeout); +s32 sys_event_flag_trywait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr result); s32 sys_event_flag_set(u32 eflag_id, u64 bitptn); s32 sys_event_flag_clear(u32 eflag_id, u64 bitptn); -s32 sys_event_flag_cancel(u32 eflag_id, vm::ptr> num); -s32 sys_event_flag_get(u32 eflag_id, vm::ptr> flags); \ No newline at end of file +s32 sys_event_flag_cancel(u32 eflag_id, vm::ptr num); +s32 sys_event_flag_get(u32 eflag_id, vm::ptr flags); \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp index 94e8cd2eaa..cd7f229b71 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp @@ -37,7 +37,7 @@ s32 sys_interrupt_tag_destroy(u32 intrtag) return CELL_OK; } -s32 sys_interrupt_thread_establish(vm::ptr> ih, u32 intrtag, u64 intrthread, u64 arg) +s32 sys_interrupt_thread_establish(vm::ptr ih, u32 intrtag, u64 intrthread, u64 arg) { sys_interrupt.Warning("sys_interrupt_thread_establish(ih_addr=0x%x, intrtag=%d, intrthread=%lld, arg=0x%llx)", ih.addr(), intrtag, intrthread, arg); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h index 9ada3e84d7..7cef6ced32 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h @@ -2,6 +2,6 @@ // SysCalls s32 sys_interrupt_tag_destroy(u32 intrtag); -s32 sys_interrupt_thread_establish(vm::ptr> ih, u32 intrtag, u64 intrthread, u64 arg); +s32 sys_interrupt_thread_establish(vm::ptr ih, u32 intrtag, u64 intrthread, u64 arg); s32 sys_interrupt_thread_disestablish(u32 ih); void sys_interrupt_thread_eoi(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp b/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp index 9f89e0bebb..02b3ae4662 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp @@ -108,7 +108,7 @@ s32 sys_memory_get_user_memory_size(vm::ptr mem_info) return CELL_OK; } -s32 sys_memory_container_create(vm::ptr> cid, u32 yield_size) +s32 sys_memory_container_create(vm::ptr cid, u32 yield_size) { sys_memory.Warning("sys_memory_container_create(cid_addr=0x%x, yield_size=0x%x)", cid.addr(), yield_size); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_memory.h b/rpcs3/Emu/SysCalls/lv2/sys_memory.h index fd4c9102b9..f0cf7e7ac4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_memory.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_memory.h @@ -57,6 +57,6 @@ s32 sys_memory_allocate_from_container(u32 size, u32 cid, u32 flags, u32 alloc_a s32 sys_memory_free(u32 start_addr); s32 sys_memory_get_page_attribute(u32 addr, vm::ptr attr); s32 sys_memory_get_user_memory_size(vm::ptr mem_info); -s32 sys_memory_container_create(vm::ptr> cid, u32 yield_size); +s32 sys_memory_container_create(vm::ptr cid, u32 yield_size); s32 sys_memory_container_destroy(u32 cid); s32 sys_memory_container_get_size(vm::ptr mem_info, u32 cid); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp index bfba1da9a4..53891b7565 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp @@ -53,7 +53,7 @@ s32 sys_mmapper_allocate_fixed_address() return CELL_OK; } -s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr> mem_id) +s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr mem_id) { sys_mmapper.Warning("sys_mmapper_allocate_memory(size=0x%x, flags=0x%llx, mem_id_addr=0x%x)", size, flags, mem_id.addr()); @@ -80,7 +80,7 @@ s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr> mem_id) return CELL_OK; } -s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm::ptr> mem_id) +s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm::ptr mem_id) { sys_mmapper.Warning("sys_mmapper_allocate_memory_from_container(size=0x%x, cid=%d, flags=0x%llx, mem_id_addr=0x%x)", size, cid, flags, mem_id.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h index 7e71de3730..608f6b8dac 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h @@ -22,8 +22,8 @@ struct mmapper_info // SysCalls s32 sys_mmapper_allocate_address(u32 size, u64 flags, u32 alignment, u32 alloc_addr); s32 sys_mmapper_allocate_fixed_address(); -s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr> mem_id); -s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm::ptr> mem_id); +s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr mem_id); +s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm::ptr mem_id); s32 sys_mmapper_change_address_access_right(u32 start_addr, u64 flags); s32 sys_mmapper_free_address(u32 start_addr); s32 sys_mmapper_free_memory(u32 mem_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp b/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp index 75a23f43cc..92eff86687 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp @@ -26,7 +26,7 @@ Mutex::~Mutex() m_queue.m_mutex.unlock(); } -s32 sys_mutex_create(vm::ptr> mutex_id, vm::ptr attr) +s32 sys_mutex_create(vm::ptr mutex_id, vm::ptr attr) { sys_mutex.Log("sys_mutex_create(mutex_id_addr=0x%x, attr_addr=0x%x)", mutex_id.addr(), attr.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mutex.h b/rpcs3/Emu/SysCalls/lv2/sys_mutex.h index d3d261138e..74a7378e63 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mutex.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_mutex.h @@ -41,7 +41,7 @@ struct Mutex }; // SysCalls -s32 sys_mutex_create(vm::ptr> mutex_id, vm::ptr attr); +s32 sys_mutex_create(vm::ptr mutex_id, vm::ptr attr); s32 sys_mutex_destroy(u32 mutex_id); s32 sys_mutex_lock(u32 mutex_id, u64 timeout); s32 sys_mutex_trylock(u32 mutex_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp index f9e931ad60..fb7772db2e 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp @@ -34,7 +34,7 @@ void sys_ppu_thread_exit(PPUThread& CPU, u64 errorcode) void sys_internal_ppu_thread_exit(PPUThread& CPU, u64 errorcode) { - sys_ppu_thread.Log("sys_internal_ppu_thread_exit(0x%llx)", errorcode); + sys_ppu_thread.Warning("sys_internal_ppu_thread_exit(0x%llx)", errorcode); ppu_thread_exit(CPU, errorcode); } @@ -47,7 +47,7 @@ s32 sys_ppu_thread_yield() return CELL_OK; } -s32 sys_ppu_thread_join(u64 thread_id, vm::ptr> vptr) +s32 sys_ppu_thread_join(u64 thread_id, vm::ptr vptr) { sys_ppu_thread.Warning("sys_ppu_thread_join(thread_id=%lld, vptr_addr=0x%x)", thread_id, vptr.addr()); @@ -182,7 +182,7 @@ PPUThread* ppu_thread_create(u32 entry, u64 arg, s32 prio, u32 stacksize, bool i return &new_thread; } -s32 sys_ppu_thread_create(vm::ptr> thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::ptr threadname) +s32 sys_ppu_thread_create(vm::ptr thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::ptr threadname) { sys_ppu_thread.Log("sys_ppu_thread_create(thread_id_addr=0x%x, entry=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x('%s'))", thread_id.addr(), entry, arg, prio, stacksize, flags, threadname.addr(), threadname ? threadname.get_ptr() : ""); @@ -223,7 +223,7 @@ void sys_ppu_thread_once(PPUThread& CPU, vm::ptr> once_ctrl, vm::p } } -s32 sys_ppu_thread_get_id(PPUThread& CPU, vm::ptr> thread_id) +s32 sys_ppu_thread_get_id(PPUThread& CPU, vm::ptr thread_id) { sys_ppu_thread.Log("sys_ppu_thread_get_id(thread_id_addr=0x%x)", thread_id.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h index 923ef045fe..83fe511b8f 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h @@ -21,7 +21,7 @@ PPUThread* ppu_thread_create(u32 entry, u64 arg, s32 prio, u32 stacksize, bool i void sys_ppu_thread_exit(PPUThread& CPU, u64 errorcode); void sys_internal_ppu_thread_exit(PPUThread& CPU, u64 errorcode); s32 sys_ppu_thread_yield(); -s32 sys_ppu_thread_join(u64 thread_id, vm::ptr> vptr); +s32 sys_ppu_thread_join(u64 thread_id, vm::ptr vptr); s32 sys_ppu_thread_detach(u64 thread_id); void sys_ppu_thread_get_join_state(PPUThread& CPU, vm::ptr isjoinable); s32 sys_ppu_thread_set_priority(u64 thread_id, s32 prio); @@ -29,7 +29,7 @@ s32 sys_ppu_thread_get_priority(u64 thread_id, u32 prio_addr); s32 sys_ppu_thread_get_stack_information(PPUThread& CPU, u32 info_addr); s32 sys_ppu_thread_stop(u64 thread_id); s32 sys_ppu_thread_restart(u64 thread_id); -s32 sys_ppu_thread_create(vm::ptr> thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::ptr threadname); +s32 sys_ppu_thread_create(vm::ptr thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::ptr threadname); void sys_ppu_thread_once(PPUThread& CPU, vm::ptr> once_ctrl, vm::ptr init); -s32 sys_ppu_thread_get_id(PPUThread& CPU, vm::ptr> thread_id); +s32 sys_ppu_thread_get_id(PPUThread& CPU, vm::ptr thread_id); s32 sys_ppu_thread_rename(u64 thread_id, vm::ptr name); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp index 039bbe66b2..964bafcc4b 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp @@ -134,7 +134,7 @@ void sys_game_process_exitspawn2( return; } -s32 sys_process_get_number_of_object(u32 object, vm::ptr> nump) +s32 sys_process_get_number_of_object(u32 object, vm::ptr nump) { sys_process.Warning("sys_process_get_number_of_object(object=%d, nump_addr=0x%x)", object, nump.addr()); @@ -169,7 +169,7 @@ s32 sys_process_get_number_of_object(u32 object, vm::ptr> nump) return CELL_OK; } -s32 sys_process_get_id(u32 object, vm::ptr> buffer, u32 size, vm::ptr> set_size) +s32 sys_process_get_id(u32 object, vm::ptr buffer, u32 size, vm::ptr set_size) { sys_process.Todo("sys_process_get_id(object=%d, buffer_addr=0x%x, size=%d, set_size_addr=0x%x)", object, buffer.addr(), size, set_size.addr()); @@ -258,7 +258,7 @@ s32 process_get_sdk_version(u32 pid, s32& ver) return CELL_OK; } -s32 sys_process_get_sdk_version(u32 pid, vm::ptr> version) +s32 sys_process_get_sdk_version(u32 pid, vm::ptr version) { sys_process.Warning("sys_process_get_sdk_version(pid=%d, version_addr=0x%x)", pid, version.addr()); @@ -281,7 +281,7 @@ s32 sys_process_kill(u32 pid) return CELL_OK; } -s32 sys_process_wait_for_child(u32 pid, vm::ptr> status, u64 unk) +s32 sys_process_wait_for_child(u32 pid, vm::ptr status, u64 unk) { sys_process.Todo("sys_process_wait_for_child(pid=%d, status_addr=0x%x, unk=0x%llx", pid, status.addr(), unk); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.h b/rpcs3/Emu/SysCalls/lv2/sys_process.h index faa8194bbe..e7a1240444 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.h @@ -31,15 +31,15 @@ s32 process_is_spu_lock_line_reservation_address(u32 addr, u64 flags); // SysCalls s32 sys_process_getpid(); s32 sys_process_getppid(); -s32 sys_process_get_number_of_object(u32 object, vm::ptr> nump); -s32 sys_process_get_id(u32 object, vm::ptr> buffer, u32 size, vm::ptr> set_size); +s32 sys_process_get_number_of_object(u32 object, vm::ptr nump); +s32 sys_process_get_id(u32 object, vm::ptr buffer, u32 size, vm::ptr set_size); s32 sys_process_get_paramsfo(vm::ptr buffer); -s32 sys_process_get_sdk_version(u32 pid, vm::ptr> version); +s32 sys_process_get_sdk_version(u32 pid, vm::ptr version); s32 sys_process_get_status(u64 unk); s32 sys_process_is_spu_lock_line_reservation_address(u32 addr, u64 flags); s32 sys_process_exit(s32 errorcode); s32 sys_process_kill(u32 pid); -s32 sys_process_wait_for_child(u32 pid, vm::ptr> status, u64 unk); +s32 sys_process_wait_for_child(u32 pid, vm::ptr status, u64 unk); s32 sys_process_wait_for_child2(u64 unk1, u64 unk2, u64 unk3, u64 unk4, u64 unk5, u64 unk6); s32 sys_process_detach_child(u64 unk); void sys_game_process_exitspawn(vm::ptr path, u32 argv_addr, u32 envp_addr, diff --git a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp index 43e1d449e5..3f1ff87e22 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp @@ -61,7 +61,7 @@ s32 sys_prx_load_module_on_memcontainer_by_fd() return CELL_OK; } -s32 sys_prx_start_module(s32 id, u32 args, u32 argp_addr, vm::ptr> modres, u64 flags, vm::ptr pOpt) +s32 sys_prx_start_module(s32 id, u32 args, u32 argp_addr, vm::ptr modres, u64 flags, vm::ptr pOpt) { sys_prx.Todo("sys_prx_start_module(id=%d, args=%d, argp_addr=0x%x, modres_addr=0x%x, flags=0x%llx, pOpt=0x%x)", id, args, argp_addr, modres.addr(), flags, pOpt.addr()); @@ -76,7 +76,7 @@ s32 sys_prx_start_module(s32 id, u32 args, u32 argp_addr, vm::ptr> mod return CELL_OK; } -s32 sys_prx_stop_module(s32 id, u32 args, u32 argp_addr, vm::ptr> modres, u64 flags, vm::ptr pOpt) +s32 sys_prx_stop_module(s32 id, u32 args, u32 argp_addr, vm::ptr modres, u64 flags, vm::ptr pOpt) { sys_prx.Todo("sys_prx_stop_module(id=%d, args=%d, argp_addr=0x%x, modres_addr=0x%x, flags=0x%llx, pOpt=0x%x)", id, args, argp_addr, modres.addr(), flags, pOpt.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_prx.h b/rpcs3/Emu/SysCalls/lv2/sys_prx.h index 8ff2af9b8f..e83daad0be 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_prx.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_prx.h @@ -69,8 +69,8 @@ s32 sys_prx_load_module(vm::ptr path, u64 flags, vm::ptr> modres, u64 flags, vm::ptr pOpt); -s32 sys_prx_stop_module(s32 id, u32 args, u32 argp_addr, vm::ptr> modres, u64 flags, vm::ptr pOpt); +s32 sys_prx_start_module(s32 id, u32 args, u32 argp_addr, vm::ptr modres, u64 flags, vm::ptr pOpt); +s32 sys_prx_stop_module(s32 id, u32 args, u32 argp_addr, vm::ptr modres, u64 flags, vm::ptr pOpt); s32 sys_prx_unload_module(s32 id, u64 flags, vm::ptr pOpt); s32 sys_prx_get_module_list(); s32 sys_prx_get_my_module_id(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp index c6e6ec7d53..21b572a4b4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp @@ -29,7 +29,7 @@ s32 sys_rsx_device_close() * @param a6 (IN): E.g. Immediate value passed in cellGcmSys is 16. * @param a7 (IN): E.g. Immediate value passed in cellGcmSys is 8. */ -s32 sys_rsx_memory_allocate(vm::ptr> mem_handle, vm::ptr> mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7) +s32 sys_rsx_memory_allocate(vm::ptr mem_handle, vm::ptr mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7) { sys_rsx.Todo("sys_rsx_memory_allocate(mem_handle_addr=0x%x, local_mem_addr=0x%x, size=0x%x, flags=0x%x, a5=%d, a6=%d, a7=%d)", mem_handle.addr(), mem_addr.addr(), size, flags, a5, a6, a7); @@ -55,7 +55,7 @@ s32 sys_rsx_memory_free(u32 mem_handle) * @param mem_ctx (IN): mem_ctx given by sys_rsx_memory_allocate * @param system_mode (IN): */ -s32 sys_rsx_context_allocate(vm::ptr> context_id, vm::ptr> lpar_dma_control, vm::ptr> lpar_driver_info, vm::ptr> lpar_reports, u64 mem_ctx, u64 system_mode) +s32 sys_rsx_context_allocate(vm::ptr context_id, vm::ptr lpar_dma_control, vm::ptr lpar_driver_info, vm::ptr lpar_reports, u64 mem_ctx, u64 system_mode) { sys_rsx.Todo("sys_rsx_context_allocate(context_id_addr=0x%x, lpar_dma_control_addr=0x%x, lpar_driver_info_addr=0x%x, lpar_reports_addr=0x%x, mem_ctx=0x%x, system_mode=0x%x)", context_id.addr(), lpar_dma_control.addr(), lpar_driver_info.addr(), lpar_reports.addr(), mem_ctx, system_mode); @@ -170,7 +170,7 @@ s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u6 * @param a2 (OUT): Unused? * @param dev_id (IN): An immediate value and always 8. (cellGcmInitPerfMon uses 11, 10, 9, 7, 12 successively). */ -s32 sys_rsx_device_map(vm::ptr> a1, vm::ptr> a2, u32 dev_id) +s32 sys_rsx_device_map(vm::ptr a1, vm::ptr a2, u32 dev_id) { sys_rsx.Todo("sys_rsx_device_map(a1_addr=0x%x, a2_addr=0x%x, a3=%d)", a1.addr(), a2.addr(), dev_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rsx.h b/rpcs3/Emu/SysCalls/lv2/sys_rsx.h index 244588c8c7..f44254cef5 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rsx.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_rsx.h @@ -3,13 +3,13 @@ // SysCalls s32 sys_rsx_device_open(); s32 sys_rsx_device_close(); -s32 sys_rsx_memory_allocate(vm::ptr> mem_handle, vm::ptr> mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7); +s32 sys_rsx_memory_allocate(vm::ptr mem_handle, vm::ptr mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7); s32 sys_rsx_memory_free(u32 mem_handle); -s32 sys_rsx_context_allocate(vm::ptr> context_id, vm::ptr> lpar_dma_control, vm::ptr> lpar_driver_info, vm::ptr> lpar_reports, u64 mem_ctx, u64 system_mode); +s32 sys_rsx_context_allocate(vm::ptr context_id, vm::ptr lpar_dma_control, vm::ptr lpar_driver_info, vm::ptr lpar_reports, u64 mem_ctx, u64 system_mode); s32 sys_rsx_context_free(u32 context_id); s32 sys_rsx_context_iomap(u32 context_id, u32 io, u32 ea, u32 size, u64 flags); s32 sys_rsx_context_iounmap(u32 context_id, u32 a2, u32 io_addr, u32 size); s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u64 a5, u64 a6); -s32 sys_rsx_device_map(vm::ptr> a1, vm::ptr> a2, u32 dev_id); +s32 sys_rsx_device_map(vm::ptr a1, vm::ptr a2, u32 dev_id); s32 sys_rsx_device_unmap(u32 dev_id); s32 sys_rsx_attribute(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp index aec4007308..b35ff563ff 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp @@ -9,7 +9,7 @@ SysCallBase sys_rwlock("sys_rwlock"); -s32 sys_rwlock_create(vm::ptr> rw_lock_id, vm::ptr attr) +s32 sys_rwlock_create(vm::ptr rw_lock_id, vm::ptr attr) { sys_rwlock.Warning("sys_rwlock_create(rw_lock_id_addr=0x%x, attr_addr=0x%x)", rw_lock_id.addr(), attr.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h index 9b3dcff1a3..eab184f21f 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h @@ -150,7 +150,7 @@ struct RWLock }; // SysCalls -s32 sys_rwlock_create(vm::ptr> rw_lock_id, vm::ptr attr); +s32 sys_rwlock_create(vm::ptr rw_lock_id, vm::ptr attr); s32 sys_rwlock_destroy(u32 rw_lock_id); s32 sys_rwlock_rlock(u32 rw_lock_id, u64 timeout); s32 sys_rwlock_tryrlock(u32 rw_lock_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp index 7d26df4c05..c7dc32e5c3 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp @@ -21,7 +21,7 @@ u32 semaphore_create(s32 initial_count, s32 max_count, u32 protocol, u64 name_u6 return id; } -s32 sys_semaphore_create(vm::ptr> sem, vm::ptr attr, s32 initial_count, s32 max_count) +s32 sys_semaphore_create(vm::ptr sem, vm::ptr attr, s32 initial_count, s32 max_count) { sys_semaphore.Warning("sys_semaphore_create(sem_addr=0x%x, attr_addr=0x%x, initial_count=%d, max_count=%d)", sem.addr(), attr.addr(), initial_count, max_count); @@ -119,11 +119,10 @@ s32 sys_semaphore_wait(u32 sem_id, u64 timeout) continue; } sem->signal = 0; - // TODO: notify signaler return CELL_OK; } - SM_Sleep(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } @@ -182,7 +181,7 @@ s32 sys_semaphore_post(u32 sem_id, s32 count) if (sem->signal && sem->m_queue.count()) { - SM_Sleep(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } @@ -190,7 +189,6 @@ s32 sys_semaphore_post(u32 sem_id, s32 count) { count--; sem->signal = target; - Emu.GetCPU().NotifyThread(target); } else { @@ -202,7 +200,7 @@ s32 sys_semaphore_post(u32 sem_id, s32 count) return CELL_OK; } -s32 sys_semaphore_get_value(u32 sem_id, vm::ptr> count) +s32 sys_semaphore_get_value(u32 sem_id, vm::ptr count) { sys_semaphore.Log("sys_semaphore_get_value(sem_id=%d, count_addr=0x%x)", sem_id, count.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h index d0deccb14e..19956ad377 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h @@ -41,9 +41,9 @@ struct Semaphore u32 semaphore_create(s32 initial_count, s32 max_count, u32 protocol, u64 name_u64); // SysCalls -s32 sys_semaphore_create(vm::ptr> sem, vm::ptr attr, s32 initial_count, s32 max_count); +s32 sys_semaphore_create(vm::ptr sem, vm::ptr attr, s32 initial_count, s32 max_count); s32 sys_semaphore_destroy(u32 sem_id); s32 sys_semaphore_wait(u32 sem_id, u64 timeout); s32 sys_semaphore_trywait(u32 sem_id); s32 sys_semaphore_post(u32 sem_id, s32 count); -s32 sys_semaphore_get_value(u32 sem_id, vm::ptr> count); +s32 sys_semaphore_get_value(u32 sem_id, vm::ptr count); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp index 431fcc3bcd..4c7163f3d2 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp @@ -106,7 +106,7 @@ SPUThread* spu_thread_initialize(SpuGroupInfo* group, u32 spu_num, sys_spu_image return &new_thread; } -s32 sys_spu_thread_initialize(vm::ptr> thread, u32 group, u32 spu_num, vm::ptr img, vm::ptr attr, vm::ptr arg) +s32 sys_spu_thread_initialize(vm::ptr thread, u32 group, u32 spu_num, vm::ptr img, vm::ptr attr, vm::ptr arg) { sys_spu.Warning("sys_spu_thread_initialize(thread_addr=0x%x, group=0x%x, spu_num=%d, img_addr=0x%x, attr_addr=0x%x, arg_addr=0x%x)", thread.addr(), group, spu_num, img.addr(), attr.addr(), arg.addr()); @@ -161,7 +161,7 @@ s32 sys_spu_thread_set_argument(u32 id, vm::ptr arg) return CELL_OK; } -s32 sys_spu_thread_get_exit_status(u32 id, vm::ptr> status) +s32 sys_spu_thread_get_exit_status(u32 id, vm::ptr status) { sys_spu.Warning("sys_spu_thread_get_exit_status(id=%d, status_addr=0x%x)", id, status.addr()); @@ -451,7 +451,7 @@ SpuGroupInfo* spu_thread_group_create(const std::string& name, u32 num, s32 prio return group; } -s32 sys_spu_thread_group_create(vm::ptr> id, u32 num, s32 prio, vm::ptr attr) +s32 sys_spu_thread_group_create(vm::ptr id, u32 num, s32 prio, vm::ptr attr) { sys_spu.Warning("sys_spu_thread_group_create(id_addr=0x%x, num=%d, prio=%d, attr_addr=0x%x)", id.addr(), num, prio, attr.addr()); @@ -465,7 +465,7 @@ s32 sys_spu_thread_group_create(vm::ptr> id, u32 num, s32 prio, vm::pt return CELL_OK; } -s32 sys_spu_thread_group_join(u32 id, vm::ptr> cause, vm::ptr> status) +s32 sys_spu_thread_group_join(u32 id, vm::ptr cause, vm::ptr status) { sys_spu.Warning("sys_spu_thread_group_join(id=%d, cause_addr=0x%x, status_addr=0x%x)", id, cause.addr(), status.addr()); @@ -518,7 +518,7 @@ s32 sys_spu_thread_group_join(u32 id, vm::ptr> cause, vm::ptr> thread_id, vm::ptr> entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr) +s32 sys_spu_thread_create(vm::ptr thread_id, vm::ptr entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr) { sys_spu.Todo("sys_spu_thread_create(thread_id_addr=0x%x, entry_addr=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x", thread_id.addr(), entry.addr(), arg, prio, stacksize, flags, threadname_addr); @@ -569,7 +569,7 @@ s32 sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type) } } -s32 sys_spu_thread_read_ls(u32 id, u32 address, vm::ptr> value, u32 type) +s32 sys_spu_thread_read_ls(u32 id, u32 address, vm::ptr value, u32 type) { sys_spu.Log("sys_spu_thread_read_ls(id=%d, address=0x%x, value_addr=0x%x, type=0x%x)", id, address, value.addr(), type); @@ -638,7 +638,7 @@ s32 sys_spu_thread_set_spu_cfg(u32 id, u64 value) return CELL_OK; } -s32 sys_spu_thread_get_spu_cfg(u32 id, vm::ptr> value) +s32 sys_spu_thread_get_spu_cfg(u32 id, vm::ptr value) { sys_spu.Warning("sys_spu_thread_get_spu_cfg(id=%d, value_addr=0x%x)", id, value.addr()); @@ -914,7 +914,7 @@ s32 sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup) return CELL_OK; } -s32 sys_raw_spu_create(vm::ptr> id, u32 attr_addr) +s32 sys_raw_spu_create(vm::ptr id, u32 attr_addr) { sys_spu.Warning("sys_raw_spu_create(id_addr=0x%x, attr_addr=0x%x)", id.addr(), attr_addr); @@ -947,7 +947,7 @@ s32 sys_raw_spu_destroy(u32 id) return CELL_OK; } -s32 sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, vm::ptr> intrtag) +s32 sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, vm::ptr intrtag) { sys_spu.Warning("sys_raw_spu_create_interrupt_tag(id=%d, class_id=%d, hwthread=0x%x, intrtag_addr=0x%x)", id, class_id, hwthread, intrtag.addr()); @@ -993,7 +993,7 @@ s32 sys_raw_spu_set_int_mask(u32 id, u32 class_id, u64 mask) return CELL_OK; } -s32 sys_raw_spu_get_int_mask(u32 id, u32 class_id, vm::ptr> mask) +s32 sys_raw_spu_get_int_mask(u32 id, u32 class_id, vm::ptr mask) { sys_spu.Log("sys_raw_spu_get_int_mask(id=%d, class_id=%d, mask_addr=0x%x)", id, class_id, mask.addr()); @@ -1031,7 +1031,7 @@ s32 sys_raw_spu_set_int_stat(u32 id, u32 class_id, u64 stat) return CELL_OK; } -s32 sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr> stat) +s32 sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr stat) { sys_spu.Log("sys_raw_spu_get_int_stat(id=%d, class_id=%d, stat_addr=0xx)", id, class_id, stat.addr()); @@ -1050,7 +1050,7 @@ s32 sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr> stat) return CELL_OK; } -s32 sys_raw_spu_read_puint_mb(u32 id, vm::ptr> value) +s32 sys_raw_spu_read_puint_mb(u32 id, vm::ptr value) { sys_spu.Log("sys_raw_spu_read_puint_mb(id=%d, value_addr=0x%x)", id, value.addr()); @@ -1080,7 +1080,7 @@ s32 sys_raw_spu_set_spu_cfg(u32 id, u32 value) return CELL_OK; } -s32 sys_raw_spu_get_spu_cfg(u32 id, vm::ptr> value) +s32 sys_raw_spu_get_spu_cfg(u32 id, vm::ptr value) { sys_spu.Log("sys_raw_spu_get_spu_afg(id=%d, value_addr=0x%x)", id, value.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.h b/rpcs3/Emu/SysCalls/lv2/sys_spu.h index 203138e8c8..e9886b0e0d 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.h @@ -163,7 +163,7 @@ SPUThread* spu_thread_initialize(SpuGroupInfo* group, u32 spu_num, sys_spu_image // SysCalls s32 sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu); s32 sys_spu_image_open(vm::ptr img, vm::ptr path); -s32 sys_spu_thread_initialize(vm::ptr> thread, u32 group, u32 spu_num, vm::ptr img, vm::ptr attr, vm::ptr arg); +s32 sys_spu_thread_initialize(vm::ptr thread, u32 group, u32 spu_num, vm::ptr img, vm::ptr attr, vm::ptr arg); s32 sys_spu_thread_set_argument(u32 id, vm::ptr arg); s32 sys_spu_thread_group_destroy(u32 id); s32 sys_spu_thread_group_start(u32 id); @@ -171,32 +171,32 @@ s32 sys_spu_thread_group_suspend(u32 id); s32 sys_spu_thread_group_resume(u32 id); s32 sys_spu_thread_group_yield(u32 id); s32 sys_spu_thread_group_terminate(u32 id, int value); -s32 sys_spu_thread_group_create(vm::ptr> id, u32 num, int prio, vm::ptr attr); -s32 sys_spu_thread_create(vm::ptr> thread_id, vm::ptr> entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr); -s32 sys_spu_thread_group_join(u32 id, vm::ptr> cause, vm::ptr> status); +s32 sys_spu_thread_group_create(vm::ptr id, u32 num, int prio, vm::ptr attr); +s32 sys_spu_thread_create(vm::ptr thread_id, vm::ptr entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr); +s32 sys_spu_thread_group_join(u32 id, vm::ptr cause, vm::ptr status); s32 sys_spu_thread_group_connect_event(u32 id, u32 eq, u32 et); s32 sys_spu_thread_group_disconnect_event(u32 id, u32 et); s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, vm::ptr spup); s32 sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup); s32 sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type); -s32 sys_spu_thread_read_ls(u32 id, u32 address, vm::ptr> value, u32 type); +s32 sys_spu_thread_read_ls(u32 id, u32 address, vm::ptr value, u32 type); s32 sys_spu_thread_write_spu_mb(u32 id, u32 value); s32 sys_spu_thread_set_spu_cfg(u32 id, u64 value); -s32 sys_spu_thread_get_spu_cfg(u32 id, vm::ptr> value); +s32 sys_spu_thread_get_spu_cfg(u32 id, vm::ptr value); s32 sys_spu_thread_write_snr(u32 id, u32 number, u32 value); s32 sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup); s32 sys_spu_thread_disconnect_event(u32 id, u32 event_type, u8 spup); s32 sys_spu_thread_bind_queue(u32 id, u32 spuq, u32 spuq_num); s32 sys_spu_thread_unbind_queue(u32 id, u32 spuq_num); -s32 sys_spu_thread_get_exit_status(u32 id, vm::ptr> status); +s32 sys_spu_thread_get_exit_status(u32 id, vm::ptr status); -s32 sys_raw_spu_create(vm::ptr> id, u32 attr_addr); +s32 sys_raw_spu_create(vm::ptr id, u32 attr_addr); s32 sys_raw_spu_destroy(u32 id); -s32 sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, vm::ptr> intrtag); +s32 sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, vm::ptr intrtag); s32 sys_raw_spu_set_int_mask(u32 id, u32 class_id, u64 mask); -s32 sys_raw_spu_get_int_mask(u32 id, u32 class_id, vm::ptr> mask); +s32 sys_raw_spu_get_int_mask(u32 id, u32 class_id, vm::ptr mask); s32 sys_raw_spu_set_int_stat(u32 id, u32 class_id, u64 stat); -s32 sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr> stat); -s32 sys_raw_spu_read_puint_mb(u32 id, vm::ptr> value); +s32 sys_raw_spu_get_int_stat(u32 id, u32 class_id, vm::ptr stat); +s32 sys_raw_spu_read_puint_mb(u32 id, vm::ptr value); s32 sys_raw_spu_set_spu_cfg(u32 id, u32 value); -s32 sys_raw_spu_get_spu_cfg(u32 id, vm::ptr> value); +s32 sys_raw_spu_get_spu_cfg(u32 id, vm::ptr value); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp index ee65e07e19..c408931bad 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp @@ -18,7 +18,7 @@ SysCallBase sys_time("sys_time"); static const u64 timebase_frequency = /*79800000*/ 80000000; // 80 Mhz -extern int cellSysutilGetSystemParamInt(int id, vm::ptr> value); +extern int cellSysutilGetSystemParamInt(int id, vm::ptr value); // Auxiliary functions u64 get_time() @@ -59,7 +59,7 @@ u64 get_system_time() // Functions -s32 sys_time_get_timezone(vm::ptr> timezone, vm::ptr> summertime) +s32 sys_time_get_timezone(vm::ptr timezone, vm::ptr summertime) { sys_time.Warning("sys_time_get_timezone(timezone_addr=0x%x, summertime_addr=0x%x)", timezone.addr(), summertime.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_time.h b/rpcs3/Emu/SysCalls/lv2/sys_time.h index 28863999e5..34d755db8a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_time.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_time.h @@ -7,7 +7,7 @@ u64 get_time(); u64 get_system_time(); // SysCalls -s32 sys_time_get_timezone(vm::ptr> timezone, vm::ptr> summertime); +s32 sys_time_get_timezone(vm::ptr timezone, vm::ptr summertime); s32 sys_time_get_current_time(u32 sec_addr, u32 nsec_addr); s64 sys_time_get_system_time(); u64 sys_time_get_timebase_frequency(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp index 31cd0699ae..c2f5d259d7 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp @@ -8,7 +8,7 @@ SysCallBase sys_timer("sys_timer"); -s32 sys_timer_create(vm::ptr> timer_id) +s32 sys_timer_create(vm::ptr timer_id) { sys_timer.Warning("sys_timer_create(timer_id_addr=0x%x)", timer_id.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.h b/rpcs3/Emu/SysCalls/lv2/sys_timer.h index 1d65520047..61cd8bbe8e 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.h @@ -19,7 +19,7 @@ struct timer sys_timer_information_t timer_information_t; }; -s32 sys_timer_create(vm::ptr> timer_id); +s32 sys_timer_create(vm::ptr timer_id); s32 sys_timer_destroy(u32 timer_id); s32 sys_timer_get_information(u32 timer_id, vm::ptr info); s32 sys_timer_start(u32 timer_id, s64 basetime, u64 period); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 53af9489b8..07475922c0 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -340,14 +340,14 @@ void Emulator::Load() m_rsx_callback = (u32)Memory.MainMem.AllocAlign(4 * 4) + 4; vm::write32(m_rsx_callback - 4, m_rsx_callback); - auto callback_data = vm::ptr>::make(m_rsx_callback); + auto callback_data = vm::ptr::make(m_rsx_callback); callback_data[0] = ADDI(11, 0, 0x3ff); callback_data[1] = SC(2); callback_data[2] = BCLR(0x10 | 0x04, 0, 0, 0); m_ppu_thr_exit = (u32)Memory.MainMem.AllocAlign(4 * 4); - auto ppu_thr_exit_data = vm::ptr>::make(m_ppu_thr_exit); + auto ppu_thr_exit_data = vm::ptr::make(m_ppu_thr_exit); //ppu_thr_exit_data += ADDI(3, 0, 0); // why it kills return value (GPR[3]) ? ppu_thr_exit_data[0] = ADDI(11, 0, 41); ppu_thr_exit_data[1] = SC(2); @@ -355,7 +355,7 @@ void Emulator::Load() m_ppu_thr_stop = (u32)Memory.MainMem.AllocAlign(2 * 4); - auto ppu_thr_stop_data = vm::ptr>::make(m_ppu_thr_stop); + auto ppu_thr_stop_data = vm::ptr::make(m_ppu_thr_stop); ppu_thr_stop_data[0] = SC(4); ppu_thr_stop_data[1] = BCLR(0x10 | 0x04, 0, 0, 0); diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index 2fb700cb6f..85ab9a5672 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -831,7 +831,7 @@ wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA } else if(!(cmd & (CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_CALL)) && cmd != CELL_GCM_METHOD_FLAG_RETURN) { - auto args = vm::ptr>::make(currentAddr + 4); + auto args = vm::ptr::make(currentAddr + 4); u32 index = 0; switch(cmd & 0x3ffff) diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 2b236aace5..119a4913b9 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -470,11 +470,11 @@ bool ELF64Loader::LoadPhdrData(u64 offset) #endif vm::write32(stub.s_text + i*4, (u32)tbl + i*8); - auto out_tbl = vm::ptr>::make((u32)tbl + i * 8); + auto out_tbl = vm::ptr::make((u32)tbl + i * 8); out_tbl[0] = (u32)dst + i*section; out_tbl[1] = Emu.GetModuleManager().GetFuncNumById(nid); - auto out_dst = vm::ptr>::make((u32)dst + i * section); + auto out_dst = vm::ptr::make((u32)dst + i * section); out_dst[0] = OR(11, 2, 2, 0); out_dst[1] = SC(2); out_dst[2] = BLR(); diff --git a/rpcs3/cellMic.h b/rpcs3/cellMic.h new file mode 100644 index 0000000000..4fbc695af2 --- /dev/null +++ b/rpcs3/cellMic.h @@ -0,0 +1,23 @@ +#pragma once + +// Error Codes +enum +{ + CELL_MICIN_ERROR_ALREADY_INIT = 0x80140101, + CELL_MICIN_ERROR_SYSTEM = 0x80140102, + CELL_MICIN_ERROR_NOT_INIT = 0x80140103, + CELL_MICIN_ERROR_PARAM = 0x80140104, + CELL_MICIN_ERROR_PORT_FULL = 0x80140105, + CELL_MICIN_ERROR_ALREADY_OPEN = 0x80140106, + CELL_MICIN_ERROR_NOT_OPEN = 0x80140107, + CELL_MICIN_ERROR_NOT_RUN = 0x80140108, + CELL_MICIN_ERROR_TRANS_EVENT = 0x80140109, + CELL_MICIN_ERROR_OPEN = 0x8014010a, + CELL_MICIN_ERROR_SHAREDMEMORY = 0x8014010b, + CELL_MICIN_ERROR_MUTEX = 0x8014010c, + CELL_MICIN_ERROR_EVENT_QUEUE = 0x8014010d, + CELL_MICIN_ERROR_DEVICE_NOT_FOUND = 0x8014010e, + CELL_MICIN_ERROR_SYSTEM_NOT_FOUND = 0x8014010e, + CELL_MICIN_ERROR_FATAL = 0x8014010f, + CELL_MICIN_ERROR_DEVICE_NOT_SUPPORT = 0x80140110, +}; \ No newline at end of file diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 7d4a01eb8c..5a3098c609 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -246,6 +246,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index c91cb01f4b..e50b775409 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -422,9 +422,6 @@ Emu\SysCalls\currently_unused - - Emu\SysCalls\currently_unused - Emu\SysCalls\currently_unused @@ -626,6 +623,9 @@ Crypto + + Emu\SysCalls\Modules + Emu\Cell @@ -1237,6 +1237,9 @@ Crypto + + Emu\SysCalls\Modules + Emu\Cell