IdManager improved, atomic_t improved

Various changes
This commit is contained in:
Nekotekina 2015-05-27 06:11:59 +03:00
parent cdf70e0b77
commit 22b78fec71
69 changed files with 4304 additions and 4098 deletions

View File

@ -388,10 +388,9 @@ union _CRT_ALIGN(16) u128
}
};
#ifndef InterlockedCompareExchange
static __forceinline u128 InterlockedCompareExchange(volatile u128* dest, u128 exch, u128 comp)
static __forceinline u128 __sync_val_compare_and_swap(volatile u128* dest, u128 comp, u128 exch)
{
#if defined(__GNUG__)
#if !defined(_MSC_VER)
auto res = __sync_val_compare_and_swap((volatile __int128_t*)dest, (__int128_t&)comp, (__int128_t&)exch);
return (u128&)res;
#else
@ -399,60 +398,51 @@ static __forceinline u128 InterlockedCompareExchange(volatile u128* dest, u128 e
return comp;
#endif
}
#endif
static __forceinline bool InterlockedCompareExchangeTest(volatile u128* dest, u128 exch, u128 comp)
static __forceinline bool __sync_bool_compare_and_swap(volatile u128* dest, u128 comp, u128 exch)
{
#if defined(__GNUG__)
#if !defined(_MSC_VER)
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)
static __forceinline u128 __sync_lock_test_and_set(volatile u128* dest, u128 value)
{
while (true)
{
const u128 old = *(u128*)dest;
if (InterlockedCompareExchangeTest(dest, value, old)) return old;
if (__sync_bool_compare_and_swap(dest, old, value)) return old;
}
}
#endif
#ifndef InterlockedOr
static __forceinline u128 InterlockedOr(volatile u128* dest, u128 value)
static __forceinline u128 __sync_fetch_and_or(volatile u128* dest, u128 value)
{
while (true)
{
const u128 old = *(u128*)dest;
if (InterlockedCompareExchangeTest(dest, old | value, old)) return old;
if (__sync_bool_compare_and_swap(dest, old, value | old)) return old;
}
}
#endif
#ifndef InterlockedAnd
static __forceinline u128 InterlockedAnd(volatile u128* dest, u128 value)
static __forceinline u128 __sync_fetch_and_and(volatile u128* dest, u128 value)
{
while (true)
{
const u128 old = *(u128*)dest;
if (InterlockedCompareExchangeTest(dest, old & value, old)) return old;
if (__sync_bool_compare_and_swap(dest, old, value & old)) return old;
}
}
#endif
#ifndef InterlockedXor
static __forceinline u128 InterlockedXor(volatile u128* dest, u128 value)
static __forceinline u128 __sync_fetch_and_xor(volatile u128* dest, u128 value)
{
while (true)
{
const u128 old = *(u128*)dest;
if (InterlockedCompareExchangeTest(dest, old ^ value, old)) return old;
if (__sync_bool_compare_and_swap(dest, old, value ^ old)) return old;
}
}
#endif
#define re16(val) _byteswap_ushort(val)
#define re32(val) _byteswap_ulong(val)
@ -926,3 +916,7 @@ __forceinline void convert_le_be(Tto& dst, Tfrom&& src)
{
dst = convert_le_be_t<Tto, Tfrom>::func(src);
}
template<typename T> using le_t = T;
template<typename T> struct to_le_t { using type = T; };

View File

@ -37,7 +37,7 @@ void strcpy_trunc(char(&dst)[size], const char(&src)[rsize])
}
#if defined(__GNUG__)
#include <cmath>
#include <stdlib.h>
#include <cstdint>
@ -67,10 +67,8 @@ inline int64_t __mulh(int64_t a, int64_t b)
return result;
}
void * _aligned_malloc(size_t size, size_t alignment);
#ifdef __APPLE__
int clock_gettime(int foo, struct timespec *ts);
#define wxIsNaN(x) ((x) != (x))
@ -80,218 +78,185 @@ int clock_gettime(int foo, struct timespec *ts);
#endif /* __APPLE__ */
#define _aligned_free free
#endif /* __GNUG__ */
#define DWORD int32_t
#endif
#if defined(_MSC_VER)
#ifndef InterlockedCompareExchange
static __forceinline uint8_t InterlockedCompareExchange(volatile uint8_t* dest, uint8_t exch, uint8_t comp)
// atomic compare and swap functions
static __forceinline uint8_t __sync_val_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch)
{
#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)
static __forceinline uint16_t __sync_val_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch)
{
#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)
static __forceinline uint32_t __sync_val_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch)
{
#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)
static __forceinline uint64_t __sync_val_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch)
{
#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)
static __forceinline bool __sync_bool_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch)
{
#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)
static __forceinline bool __sync_bool_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch)
{
#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)
static __forceinline bool __sync_bool_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch)
{
#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)
static __forceinline bool __sync_bool_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch)
{
#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)
// atomic exchange functions
static __forceinline uint8_t __sync_lock_test_and_set(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)
static __forceinline uint16_t __sync_lock_test_and_set(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)
static __forceinline uint32_t __sync_lock_test_and_set(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)
static __forceinline uint64_t __sync_lock_test_and_set(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)
// atomic add functions
static __forceinline uint8_t __sync_fetch_and_add(volatile uint8_t* dest, uint8_t value)
{
return _InterlockedExchangeAdd8((volatile char*)dest, value);
}
static __forceinline uint16_t __sync_fetch_and_add(volatile uint16_t* dest, uint16_t value)
{
return _InterlockedExchangeAdd16((volatile short*)dest, value);
}
static __forceinline uint32_t __sync_fetch_and_add(volatile uint32_t* dest, uint32_t value)
{
return _InterlockedExchangeAdd((volatile long*)dest, value);
}
static __forceinline uint64_t __sync_fetch_and_add(volatile uint64_t* dest, uint64_t value)
{
return _InterlockedExchangeAdd64((volatile long long*)dest, value);
}
// atomic sub functions
static __forceinline uint8_t __sync_fetch_and_sub(volatile uint8_t* dest, uint8_t value)
{
return _InterlockedExchangeAdd8((volatile char*)dest, -(char)value);
}
static __forceinline uint16_t __sync_fetch_and_sub(volatile uint16_t* dest, uint16_t value)
{
return _InterlockedExchangeAdd16((volatile short*)dest, -(short)value);
}
static __forceinline uint32_t __sync_fetch_and_sub(volatile uint32_t* dest, uint32_t value)
{
return _InterlockedExchangeAdd((volatile long*)dest, -(long)value);
}
static __forceinline uint64_t __sync_fetch_and_sub(volatile uint64_t* dest, uint64_t value)
{
return _InterlockedExchangeAdd64((volatile long long*)dest, -(long long)value);
}
// atomic bitwise or functions
static __forceinline uint8_t __sync_fetch_and_or(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)
static __forceinline uint16_t __sync_fetch_and_or(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)
static __forceinline uint32_t __sync_fetch_and_or(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)
static __forceinline uint64_t __sync_fetch_and_or(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)
// atomic bitwise and functions
static __forceinline uint8_t __sync_fetch_and_and(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)
static __forceinline uint16_t __sync_fetch_and_and(volatile uint16_t* dest, uint16_t value)
{
return _InterlockedAnd16((volatile short*)dest, value);
}
static __forceinline uint32_t __sync_fetch_and_and(volatile uint32_t* dest, uint32_t value)
{
return _InterlockedAnd((volatile long*)dest, value);
}
static __forceinline uint64_t __sync_fetch_and_and(volatile uint64_t* dest, uint64_t value)
{
return _InterlockedAnd64((volatile long long*)dest, value);
}
// atomic bitwise xor functions
static __forceinline uint8_t __sync_fetch_and_xor(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)
static __forceinline uint16_t __sync_fetch_and_xor(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)
static __forceinline uint32_t __sync_fetch_and_xor(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)
static __forceinline uint64_t __sync_fetch_and_xor(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
#endif /* _MSC_VER */
static __forceinline uint32_t cntlz32(uint32_t arg)
{

View File

@ -1002,10 +1002,10 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
switch (d_size)
{
case 1: reg_value = vm::priv_ref<atomic_le_t<u8>>(addr).exchange((u8)reg_value); break;
case 2: reg_value = vm::priv_ref<atomic_le_t<u16>>(addr).exchange((u16)reg_value); break;
case 4: reg_value = vm::priv_ref<atomic_le_t<u32>>(addr).exchange((u32)reg_value); break;
case 8: reg_value = vm::priv_ref<atomic_le_t<u64>>(addr).exchange((u64)reg_value); break;
case 1: reg_value = vm::priv_ref<atomic<u8>>(addr).exchange((u8)reg_value); break;
case 2: reg_value = vm::priv_ref<atomic<u16>>(addr).exchange((u16)reg_value); break;
case 4: reg_value = vm::priv_ref<atomic<u32>>(addr).exchange((u32)reg_value); break;
case 8: reg_value = vm::priv_ref<atomic<u64>>(addr).exchange((u64)reg_value); break;
default: return false;
}
@ -1025,10 +1025,10 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
switch (d_size)
{
case 1: old_value = vm::priv_ref<atomic_le_t<u8>>(addr).compare_and_swap((u8)cmp_value, (u8)reg_value); break;
case 2: old_value = vm::priv_ref<atomic_le_t<u16>>(addr).compare_and_swap((u16)cmp_value, (u16)reg_value); break;
case 4: old_value = vm::priv_ref<atomic_le_t<u32>>(addr).compare_and_swap((u32)cmp_value, (u32)reg_value); break;
case 8: old_value = vm::priv_ref<atomic_le_t<u64>>(addr).compare_and_swap((u64)cmp_value, (u64)reg_value); break;
case 1: old_value = vm::priv_ref<atomic<u8>>(addr).compare_and_swap((u8)cmp_value, (u8)reg_value); break;
case 2: old_value = vm::priv_ref<atomic<u16>>(addr).compare_and_swap((u16)cmp_value, (u16)reg_value); break;
case 4: old_value = vm::priv_ref<atomic<u32>>(addr).compare_and_swap((u32)cmp_value, (u32)reg_value); break;
case 8: old_value = vm::priv_ref<atomic<u64>>(addr).compare_and_swap((u64)cmp_value, (u64)reg_value); break;
default: return false;
}
@ -1048,10 +1048,10 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
switch (d_size)
{
case 1: value = vm::priv_ref<atomic_le_t<u8>>(addr) &= value; break;
case 2: value = vm::priv_ref<atomic_le_t<u16>>(addr) &= value; break;
case 4: value = vm::priv_ref<atomic_le_t<u32>>(addr) &= value; break;
case 8: value = vm::priv_ref<atomic_le_t<u64>>(addr) &= value; break;
case 1: value = vm::priv_ref<atomic<u8>>(addr) &= value; break;
case 2: value = vm::priv_ref<atomic<u16>>(addr) &= value; break;
case 4: value = vm::priv_ref<atomic<u32>>(addr) &= value; break;
case 8: value = vm::priv_ref<atomic<u64>>(addr) &= value; break;
default: return false;
}

View File

@ -173,7 +173,7 @@ class squeue_t
};
};
atomic_le_t<squeue_sync_var_t> m_sync;
atomic<squeue_sync_var_t> m_sync;
mutable std::mutex m_rcv_mutex;
mutable std::mutex m_wcv_mutex;

View File

@ -49,7 +49,7 @@ public:
}
// share object with UID specified
__forceinline std::shared_ptr<T> get(s32 uid)
inline std::shared_ptr<T> get(s32 uid)
{
if (!check(uid))
{
@ -61,7 +61,7 @@ public:
return m_data[psv_uid_t::make(uid).number];
}
__forceinline std::shared_ptr<T> operator [](s32 uid)
inline std::shared_ptr<T> operator [](s32 uid)
{
return this->get(uid);
}

View File

@ -34,12 +34,12 @@ std::shared_ptr<CPUThread> CPUThreadManager::AddThread(CPUThreadType type)
{
case CPU_THREAD_PPU:
{
new_thread.reset(new PPUThread());
new_thread = std::make_shared<PPUThread>();
break;
}
case CPU_THREAD_SPU:
{
new_thread.reset(new SPUThread());
new_thread = std::make_shared<SPUThread>();
break;
}
case CPU_THREAD_RAW_SPU:
@ -48,7 +48,7 @@ std::shared_ptr<CPUThread> CPUThreadManager::AddThread(CPUThreadType type)
{
if (!m_raw_spu[i])
{
new_thread.reset(new RawSPUThread());
new_thread = std::make_shared<RawSPUThread>();
new_thread->index = i;
m_raw_spu[i] = new_thread;
@ -67,7 +67,7 @@ std::shared_ptr<CPUThread> CPUThreadManager::AddThread(CPUThreadType type)
if (new_thread)
{
new_thread->SetId(Emu.GetIdManager().GetNewID(new_thread));
new_thread->SetId(Emu.GetIdManager().add(new_thread));
m_threads.push_back(new_thread);
SendDbgCommand(DID_CREATE_THREAD, new_thread.get());
@ -106,13 +106,13 @@ void CPUThreadManager::RemoveThread(u32 id)
}
// Removing the ID should trigger the actual deletion of the thread
Emu.GetIdManager().RemoveID<CPUThread>(id);
Emu.GetIdManager().remove<CPUThread>(id);
Emu.CheckStatus();
}
std::shared_ptr<CPUThread> CPUThreadManager::GetThread(u32 id)
{
return Emu.GetIdManager().GetIDData<CPUThread>(id);
return Emu.GetIdManager().get<CPUThread>(id);
}
std::shared_ptr<CPUThread> CPUThreadManager::GetThread(u32 id, CPUThreadType type)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -760,7 +760,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
LV2_LOCK;
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(data);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(data);
if (!ef)
{
@ -806,7 +806,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
LV2_LOCK;
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(data);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(data);
if (!ef)
{
@ -1054,7 +1054,7 @@ void SPUThread::stop_and_signal(u32 code)
LV2_LOCK;
std::shared_ptr<event_queue_t> queue;
std::shared_ptr<lv2_event_queue_t> queue;
for (auto& v : this->spuq)
{

View File

@ -4,7 +4,7 @@
#include "Emu/Cell/SPUContext.h"
#include "MFC.h"
struct event_queue_t;
struct lv2_event_queue_t;
struct spu_group_t;
// SPU Channels
@ -137,7 +137,7 @@ union spu_channel_t
u32 value;
};
atomic_t<sync_var_t> sync_var; // atomic variable
atomic<sync_var_t> sync_var; // atomic variable
public:
bool push(u32 value)
@ -223,8 +223,8 @@ struct spu_channel_4_t
u32 value2;
};
atomic_le_t<sync_var_t> sync_var;
atomic_le_t<u32> value3;
atomic<sync_var_t> sync_var;
atomic<u32> value3;
public:
void clear()
@ -280,10 +280,10 @@ public:
struct spu_interrupt_tag_t
{
atomic_le_t<u64> mask;
atomic_le_t<u64> stat;
atomic<u64> mask;
atomic<u64> stat;
atomic_le_t<s32> assigned;
atomic<s32> assigned;
std::mutex handler_mutex;
std::condition_variable cond;
@ -527,22 +527,22 @@ public:
spu_channel_t ch_snr2; // SPU Signal Notification Register 2
u32 ch_event_mask;
atomic_le_t<u32> ch_event_stat;
atomic<u32> ch_event_stat;
u64 ch_dec_start_timestamp; // timestamp of writing decrementer value
u32 ch_dec_value; // written decrementer value
atomic_le_t<u32> run_ctrl; // SPU Run Control register (only provided to get latest data written)
atomic_le_t<u32> status; // SPU Status register
atomic_le_t<u32> npc; // SPU Next Program Counter register
atomic<u32> run_ctrl; // SPU Run Control register (only provided to get latest data written)
atomic<u32> status; // SPU Status register
atomic<u32> npc; // SPU Next Program Counter register
spu_interrupt_tag_t int0; // SPU Class 0 Interrupt Management
spu_interrupt_tag_t int2; // SPU Class 2 Interrupt Management
std::weak_ptr<spu_group_t> tg; // SPU Thread Group
std::array<std::pair<u32, std::weak_ptr<event_queue_t>>, 32> spuq; // Event Queue Keys for SPU Thread
std::weak_ptr<event_queue_t> spup[64]; // SPU Ports
std::array<std::pair<u32, std::weak_ptr<lv2_event_queue_t>>, 32> spuq; // Event Queue Keys for SPU Thread
std::weak_ptr<lv2_event_queue_t> spup[64]; // SPU Ports
void write_snr(bool number, u32 value)
{

View File

@ -28,9 +28,9 @@ bool EventManager::CheckKey(u64 key)
return eq_map.find(key) != eq_map.end();
}
bool EventManager::RegisterKey(std::shared_ptr<event_queue_t>& data, u64 key)
bool EventManager::RegisterKey(const std::shared_ptr<lv2_event_queue_t>& data)
{
if (!key)
if (!data->key)
{
// always ok
return true;
@ -38,12 +38,12 @@ bool EventManager::RegisterKey(std::shared_ptr<event_queue_t>& data, u64 key)
std::lock_guard<std::mutex> lock(m_lock);
if (eq_map.find(key) != eq_map.end())
if (eq_map.find(data->key) != eq_map.end())
{
return false;
}
eq_map[key] = data;
eq_map[data->key] = data;
return true;
}
@ -68,7 +68,7 @@ bool EventManager::UnregisterKey(u64 key)
return false;
}
std::shared_ptr<event_queue_t> EventManager::GetEventQueue(u64 key)
std::shared_ptr<lv2_event_queue_t> EventManager::GetEventQueue(u64 key)
{
if (!key)
{

View File

@ -1,18 +1,25 @@
#pragma once
struct event_queue_t;
struct lv2_event_queue_t;
class EventManager
{
std::mutex m_lock;
std::unordered_map<u64, std::shared_ptr<event_queue_t>> eq_map;
std::unordered_map<u64, std::shared_ptr<lv2_event_queue_t>> eq_map;
public:
void Init();
void Clear();
bool CheckKey(u64 key);
bool RegisterKey(std::shared_ptr<event_queue_t>& data, u64 key);
bool RegisterKey(const std::shared_ptr<lv2_event_queue_t>& data);
bool UnregisterKey(u64 key);
std::shared_ptr<event_queue_t> GetEventQueue(u64 key);
template<typename... Args> std::shared_ptr<lv2_event_queue_t> MakeEventQueue(Args&&... args)
{
const auto queue = std::make_shared<lv2_event_queue_t>(args...);
return RegisterKey(queue) ? queue : nullptr;
}
std::shared_ptr<lv2_event_queue_t> GetEventQueue(u64 key);
};

View File

@ -2,210 +2,181 @@
#define ID_MANAGER_INCLUDED
enum IDType
// ID type
enum : u32
{
// Special objects
TYPE_MEM,
TYPE_MUTEX,
TYPE_COND,
TYPE_RWLOCK,
TYPE_INTR_TAG,
TYPE_INTR_SERVICE_HANDLE,
TYPE_EVENT_QUEUE,
TYPE_EVENT_PORT,
TYPE_TRACE,
TYPE_SPUIMAGE,
TYPE_PRX,
TYPE_SPUPORT,
TYPE_LWMUTEX,
TYPE_TIMER,
TYPE_SEMAPHORE,
TYPE_FS_FILE,
TYPE_FS_DIR,
TYPE_LWCOND,
TYPE_EVENT_FLAG,
// Any other objects
TYPE_OTHER,
ID_TYPE_NONE = 0,
};
class ID final
// Helper template to detect type
template<typename T> struct ID_type
{
const std::type_info& m_info;
std::shared_ptr<void> m_data;
IDType m_type;
//static_assert(sizeof(T) == 0, "ID type not registered (use REG_ID_TYPE)");
static const u32 type = ID_TYPE_NONE; // default type
};
class ID_data_t final
{
public:
template<typename T> ID(std::shared_ptr<T>& data, const IDType type)
: m_info(typeid(T))
, m_data(data)
, m_type(type)
const std::shared_ptr<void> data;
const std::type_info& info;
const u32 type;
template<typename T, typename... Args> ID_data_t(u32 type, Args&&... args) // doesn't work
: data(std::make_shared<T>(args...))
, info(typeid(T))
, type(type)
{
}
ID()
: m_info(typeid(void))
, m_data(nullptr)
, m_type(TYPE_OTHER)
template<typename T> ID_data_t(const std::shared_ptr<T>& data, u32 type)
: data(data)
, info(typeid(T))
, type(type)
{
}
ID(const ID& right) = delete;
ID_data_t(const ID_data_t& right) = delete;
ID(ID&& right)
: m_info(right.m_info)
, m_data(right.m_data)
, m_type(right.m_type)
ID_data_t& operator =(const ID_data_t& right) = delete;
ID_data_t(ID_data_t&& right)
: data(right.data)
, info(right.info)
, type(right.type)
{
right.m_data = nullptr;
right.m_type = TYPE_OTHER;
}
ID& operator=(ID&& other) = delete;
const std::type_info& GetInfo() const
{
return m_info;
}
template<typename T> std::shared_ptr<T> GetData() const
{
return std::static_pointer_cast<T>(m_data);
}
IDType GetType() const
{
return m_type;
}
ID_data_t& operator =(ID_data_t&& other) = delete;
};
class IdManager
class ID_manager
{
static const u32 s_first_id = 1;
static const u32 s_max_id = -1;
std::unordered_map<u32, ID> m_id_map;
std::set<u32> m_types[TYPE_OTHER];
std::mutex m_mutex;
u32 m_cur_id = s_first_id;
std::unordered_map<u32, ID_data_t> m_id_map;
u32 m_cur_id = 1; // first ID
public:
template<typename T> bool CheckID(const u32 id)
// check if ID exists and has specified type
template<typename T> bool check_id(const u32 id)
{
std::lock_guard<std::mutex> lock(m_mutex);
auto f = m_id_map.find(id);
return f != m_id_map.end() && f->second.GetInfo() == typeid(T);
return f != m_id_map.end() && f->second.info == typeid(T);
}
void Clear()
// must be called from the constructor called through make() to get further ID of current object
u32 get_cur_id()
{
// if called correctly from make(), the mutex is locked
// if called illegally, the mutex is unlocked with high probability (wrong ID is returned otherwise)
if (m_mutex.try_lock())
{
// schedule unlocking
std::lock_guard<std::mutex> lock(m_mutex, std::adopt_lock);
throw "Invalid get_cur_id() usage";
}
return m_cur_id;
}
void clear()
{
std::lock_guard<std::mutex> lock(m_mutex);
m_id_map.clear();
m_cur_id = s_first_id;
m_cur_id = 1; // first ID
}
template<typename T> u32 GetNewID(std::shared_ptr<T>& data, const IDType type = TYPE_OTHER)
// add new ID using existing std::shared_ptr (not recommended, use make() instead)
template<typename T> u32 add(const std::shared_ptr<T>& data, u32 type = ID_type<T>::type)
{
std::lock_guard<std::mutex> lock(m_mutex);
m_id_map.emplace(m_cur_id, ID(data, type));
if (type < TYPE_OTHER)
{
m_types[type].insert(m_cur_id);
}
m_id_map.emplace(m_cur_id, ID_data_t(data, type));
return m_cur_id++;
}
template<typename T> std::shared_ptr<T> GetIDData(const u32 id)
// add new ID of specified type with specified constructor arguments (passed to std::make_shared<>)
template<typename T, typename... Args> u32 make(Args&&... args)
{
std::lock_guard<std::mutex> lock(m_mutex);
const u32 type = ID_type<T>::type;
m_id_map.emplace(m_cur_id, ID_data_t(std::make_shared<T>(args...), type));
return m_cur_id++;
}
template<typename T> std::shared_ptr<T> get(u32 id)
{
std::lock_guard<std::mutex> lock(m_mutex);
auto f = m_id_map.find(id);
if (f == m_id_map.end() || f->second.GetInfo() != typeid(T))
if (f == m_id_map.end() || f->second.info != typeid(T))
{
return nullptr;
}
return f->second.GetData<T>();
return std::static_pointer_cast<T>(f->second.data);
}
bool HasID(const u32 id)
{
std::lock_guard<std::mutex> lock(m_mutex);
return m_id_map.find(id) != m_id_map.end();
}
IDType GetIDType(const u32 id)
template<typename T> bool remove(u32 id)
{
std::lock_guard<std::mutex> lock(m_mutex);
auto item = m_id_map.find(id);
if (item == m_id_map.end())
{
return TYPE_OTHER;
}
return item->second.GetType();
}
template<typename T> bool RemoveID(const u32 id)
{
std::lock_guard<std::mutex> lock(m_mutex);
auto item = m_id_map.find(id);
if (item == m_id_map.end() || item->second.GetInfo() != typeid(T))
if (item == m_id_map.end() || item->second.info != typeid(T))
{
return false;
}
if (item->second.GetType() < TYPE_OTHER)
{
m_types[item->second.GetType()].erase(id);
}
m_id_map.erase(item);
return true;
}
u32 GetTypeCount(IDType type)
u32 get_count_by_type(u32 type)
{
std::lock_guard<std::mutex> lock(m_mutex);
if (type < TYPE_OTHER)
u32 result = 0;
for (auto& v : m_id_map)
{
return (u32)m_types[type].size();
}
else
{
assert(!"Invalid ID type");
return 0;
if (v.second.type == type)
{
result++;
}
}
return result;
}
std::set<u32> GetTypeIDs(IDType type)
std::set<u32> get_IDs_by_type(u32 type)
{
// you cannot simply return reference to existing set
std::lock_guard<std::mutex> lock(m_mutex);
if (type < TYPE_OTHER)
std::set<u32> result;
for (auto& v : m_id_map)
{
return m_types[type];
}
else
{
assert(!"Invalid ID type");
return std::set<u32>{};
if (v.second.type == type)
{
result.insert(v.first);
}
}
return result;
}
};

View File

@ -1,11 +1,5 @@
#pragma once
#undef InterlockedExchange
#undef InterlockedCompareExchange
#undef InterlockedOr
#undef InterlockedAnd
#undef InterlockedXor
template<typename T, size_t size = sizeof(T)>
struct _to_atomic_subtype
{
@ -70,25 +64,25 @@ public:
// atomically compare data with cmp, replace with exch if equal, return previous data value anyway
__forceinline const type compare_and_swap(const type& cmp, const type& exch) volatile
{
return from_subtype(InterlockedCompareExchange(&sub_data, to_subtype(exch), to_subtype(cmp)));
return from_subtype(__sync_val_compare_and_swap(&sub_data, to_subtype(cmp), to_subtype(exch)));
}
// atomically compare data with cmp, replace with exch if equal, return true if data was replaced
__forceinline bool compare_and_swap_test(const type& cmp, const type& exch) volatile
{
return InterlockedCompareExchangeTest(&sub_data, to_subtype(exch), to_subtype(cmp));
return __sync_bool_compare_and_swap(&sub_data, to_subtype(cmp), to_subtype(exch));
}
// read data with memory barrier
__forceinline const type read_sync() const volatile
{
return from_subtype(InterlockedCompareExchange(const_cast<subtype*>(&sub_data), 0, 0));
return from_subtype(__sync_val_compare_and_swap(const_cast<subtype*>(&sub_data), 0, 0));
}
// atomically replace data with exch, return previous data value
__forceinline const type exchange(const type& exch) volatile
{
return from_subtype(InterlockedExchange(&sub_data, to_subtype(exch)));
return from_subtype(__sync_lock_test_and_set(&sub_data, to_subtype(exch)));
}
// read data without memory barrier
@ -112,7 +106,7 @@ public:
const subtype old = const_cast<const subtype&>(sub_data);
subtype _new = old;
atomic_proc(to_type(_new)); // function should accept reference to T type
if (InterlockedCompareExchangeTest(&sub_data, _new, old)) return;
if (__sync_bool_compare_and_swap(&sub_data, old, _new)) return;
}
}
@ -125,19 +119,19 @@ public:
subtype _new = old;
auto res = static_cast<RT>(atomic_proc(to_type(_new))); // function should accept reference to T type and return some value
if (res != proceed_value) return res;
if (InterlockedCompareExchangeTest(&sub_data, _new, old)) return proceed_value;
if (__sync_bool_compare_and_swap(&sub_data, old, _new)) return proceed_value;
}
}
// perform atomic operation on data with additional memory barrier
template<typename FT> __forceinline void atomic_op_sync(const FT atomic_proc) volatile
{
subtype old = InterlockedCompareExchange(&sub_data, 0, 0);
subtype old = __sync_val_compare_and_swap(&sub_data, 0, 0);
while (true)
{
subtype _new = old;
atomic_proc(to_type(_new)); // function should accept reference to T type
const subtype val = InterlockedCompareExchange(&sub_data, _new, old);
const subtype val = __sync_val_compare_and_swap(&sub_data, old, _new);
if (val == old) return;
old = val;
}
@ -146,13 +140,13 @@ public:
// perform atomic operation on data with additional memory barrier and special exit condition (if intermediate result != proceed_value)
template<typename RT, typename FT> __forceinline RT atomic_op_sync(const RT proceed_value, const FT atomic_proc) volatile
{
subtype old = InterlockedCompareExchange(&sub_data, 0, 0);
subtype old = __sync_val_compare_and_swap(&sub_data, 0, 0);
while (true)
{
subtype _new = old;
auto res = static_cast<RT>(atomic_proc(to_type(_new))); // function should accept reference to T type and return some value
if (res != proceed_value) return res;
const subtype val = InterlockedCompareExchange(&sub_data, _new, old);
const subtype val = __sync_val_compare_and_swap(&sub_data, old, _new);
if (val == old) return proceed_value;
old = val;
}
@ -161,119 +155,76 @@ public:
// atomic bitwise OR, returns previous data
__forceinline const type _or(const type& right) volatile
{
return from_subtype(InterlockedOr(&sub_data, to_subtype(right)));
return from_subtype(__sync_fetch_and_or(&sub_data, to_subtype(right)));
}
// atomic bitwise AND, returns previous data
__forceinline const type _and(const type& right) volatile
{
return from_subtype(InterlockedAnd(&sub_data, to_subtype(right)));
return from_subtype(__sync_fetch_and_and(&sub_data, to_subtype(right)));
}
// atomic bitwise AND NOT (inverts right argument), returns previous data
__forceinline const type _and_not(const type& right) volatile
{
return from_subtype(InterlockedAnd(&sub_data, ~to_subtype(right)));
return from_subtype(__sync_fetch_and_and(&sub_data, ~to_subtype(right)));
}
// atomic bitwise XOR, returns previous data
__forceinline const type _xor(const type& right) volatile
{
return from_subtype(InterlockedXor(&sub_data, to_subtype(right)));
return from_subtype(__sync_fetch_and_xor(&sub_data, to_subtype(right)));
}
__forceinline const type operator |= (const type& right) volatile
{
return from_subtype(InterlockedOr(&sub_data, to_subtype(right)) | to_subtype(right));
return from_subtype(__sync_fetch_and_or(&sub_data, to_subtype(right)) | to_subtype(right));
}
__forceinline const type operator &= (const type& right) volatile
{
return from_subtype(InterlockedAnd(&sub_data, to_subtype(right)) & to_subtype(right));
return from_subtype(__sync_fetch_and_and(&sub_data, to_subtype(right)) & to_subtype(right));
}
__forceinline const type operator ^= (const type& right) volatile
{
return from_subtype(InterlockedXor(&sub_data, to_subtype(right)) ^ to_subtype(right));
return from_subtype(__sync_fetch_and_xor(&sub_data, to_subtype(right)) ^ to_subtype(right));
}
};
// Helper definitions
template<typename T, typename T2 = T> using if_arithmetic_t = const typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<T2>::value, T>::type;
template<typename T, typename T2 = T> using if_arithmetic_le_t = const typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<T2>::value, le_t<T>>::type;
template<typename T, typename T2 = T> using if_arithmetic_be_t = const typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<T2>::value, be_t<T>>::type;
template<typename T, typename T2 = T> using if_arithmetic_atomic_t = typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<T2>::value, _atomic_base<T>&>::type;
template<typename T, typename T2 = T> using if_arithmetic_atomic_be_t = typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<T2>::value, _atomic_base<be_t<T>>&>::type;
template<typename T> inline static if_arithmetic_t<T> operator ++(_atomic_base<T>& left)
template<typename T> inline static if_arithmetic_le_t<T> operator ++(_atomic_base<le_t<T>>& left)
{
T result;
left.atomic_op([&result](T& value)
{
result = ++value;
});
return result;
return left.from_subtype(__sync_fetch_and_add(&left.sub_data, 1) + 1);
}
template<typename T> inline static if_arithmetic_t<T> operator --(_atomic_base<T>& left)
template<typename T> inline static if_arithmetic_le_t<T> operator --(_atomic_base<le_t<T>>& left)
{
T result;
left.atomic_op([&result](T& value)
{
result = --value;
});
return result;
return left.from_subtype(__sync_fetch_and_sub(&left.sub_data, 1) - 1);
}
template<typename T> inline static if_arithmetic_t<T> operator ++(_atomic_base<T>& left, int)
template<typename T> inline static if_arithmetic_le_t<T> operator ++(_atomic_base<le_t<T>>& left, int)
{
T result;
left.atomic_op([&result](T& value)
{
result = value++;
});
return result;
return left.from_subtype(__sync_fetch_and_add(&left.sub_data, 1));
}
template<typename T> inline static if_arithmetic_t<T> operator --(_atomic_base<T>& left, int)
template<typename T> inline static if_arithmetic_le_t<T> operator --(_atomic_base<le_t<T>>& left, int)
{
T result;
left.atomic_op([&result](T& value)
{
result = value--;
});
return result;
return left.from_subtype(__sync_fetch_and_sub(&left.sub_data, 1));
}
template<typename T, typename T2> inline static if_arithmetic_t<T, T2> operator +=(_atomic_base<T>& left, T2 right)
template<typename T, typename T2> inline static if_arithmetic_le_t<T, T2> operator +=(_atomic_base<le_t<T>>& left, T2 right)
{
T result;
left.atomic_op([&result, right](T& value)
{
result = (value += right);
});
return result;
return left.from_subtype(__sync_fetch_and_add(&left.sub_data, right) + right);
}
template<typename T, typename T2> inline static if_arithmetic_t<T, T2> operator -=(_atomic_base<T>& left, T2 right)
template<typename T, typename T2> inline static if_arithmetic_le_t<T, T2> operator -=(_atomic_base<le_t<T>>& left, T2 right)
{
T result;
left.atomic_op([&result, right](T& value)
{
result = (value -= right);
});
return result;
return left.from_subtype(__sync_fetch_and_sub(&left.sub_data, right) - right);
}
template<typename T> inline static if_arithmetic_be_t<T> operator ++(_atomic_base<be_t<T>>& left)
@ -348,18 +299,8 @@ template<typename T, typename T2> inline static if_arithmetic_be_t<T, T2> operat
return result;
}
template<typename T> using atomic_le_t = _atomic_base<T>;
template<typename T> using atomic = _atomic_base<T>; // Atomic Type with native endianness (for emulator memory)
template<typename T> using atomic_be_t = _atomic_base<typename to_be_t<T>::type>;
template<typename T> using atomic_be_t = _atomic_base<typename to_be_t<T>::type>; // Atomic BE Type (for PS3 virtual memory)
namespace ps3
{
template<typename T> using atomic_t = atomic_be_t<T>;
}
namespace psv
{
template<typename T> using atomic_t = atomic_le_t<T>;
}
using namespace ps3;
template<typename T> using atomic_le_t = _atomic_base<typename to_le_t<T>::type>; // Atomic LE Type (for PSV virtual memory)

View File

@ -75,7 +75,7 @@ namespace vm
void* g_base_addr = (atexit(finalize), initialize());
void* g_priv_addr;
std::array<atomic_le_t<u8>, 0x100000000ull / 4096> g_page_info = {}; // information about every page
std::array<atomic<u8>, 0x100000000ull / 4096> g_page_info = {}; // information about every page
class reservation_mutex_t
{

View File

@ -6,11 +6,10 @@ struct ARMv7Context;
namespace vm
{
template<typename T, int lvl = 1, typename AT = u32>
class _ptr_base
struct _ptr_base
{
AT m_addr;
public:
typedef typename std::remove_cv<T>::type type;
static const u32 address_size = sizeof(AT);
@ -103,11 +102,10 @@ namespace vm
};
template<typename T, typename AT>
class _ptr_base<T, 1, AT>
struct _ptr_base<T, 1, AT>
{
AT m_addr;
public:
static_assert(!std::is_pointer<T>::value, "vm::_ptr_base<> error: invalid type (pointer)");
static_assert(!std::is_reference<T>::value, "vm::_ptr_base<> error: invalid type (reference)");
typedef typename std::remove_cv<T>::type type;
@ -228,11 +226,10 @@ namespace vm
};
template<typename AT>
class _ptr_base<void, 1, AT>
struct _ptr_base<void, 1, AT>
{
AT m_addr;
public:
AT addr() const
{
return m_addr;
@ -291,11 +288,10 @@ namespace vm
};
template<typename AT>
class _ptr_base<const void, 1, AT>
struct _ptr_base<const void, 1, AT>
{
AT m_addr;
public:
AT addr() const
{
return m_addr;
@ -347,11 +343,10 @@ namespace vm
};
template<typename AT, typename RT, typename ...T>
class _ptr_base<RT(T...), 1, AT>
struct _ptr_base<RT(T...), 1, AT>
{
AT m_addr;
public:
typedef RT(type)(T...);
RT operator()(PPUThread& CPU, T... args) const; // defined in CB_FUNC.h, call using specified PPU thread context
@ -402,39 +397,47 @@ namespace vm
};
template<typename AT, typename RT, typename ...T>
class _ptr_base<RT(*)(T...), 1, AT>
struct _ptr_base<RT(*)(T...), 1, AT>
{
AT m_addr;
public:
static_assert(!sizeof(AT), "vm::_ptr_base<> error: use RT(T...) format for functions instead of RT(*)(T...)");
};
// Native endianness pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> using ptrl = _ptr_base<typename to_le_t<T>::type, lvl, AT>;
// Native endianness pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> using ptrb = _ptr_base<typename to_be_t<T>::type, lvl, AT>;
// BE pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> using bptrl = _ptr_base<T, lvl, typename to_be_t<AT>::type>;
template<typename T, int lvl = 1, typename AT = u32> using bptrl = _ptr_base<typename to_le_t<T>::type, lvl, typename to_be_t<AT>::type>;
// BE pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> using bptrb = _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>;
// LE pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> using lptrb = _ptr_base<typename to_be_t<T>::type, lvl, AT>;
// LE pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> using lptrl = _ptr_base<T, lvl, AT>;
template<typename T, int lvl = 1, typename AT = u32> using lptrl = _ptr_base<typename to_le_t<T>::type, lvl, typename to_le_t<AT>::type>;
// LE pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> using lptrb = _ptr_base<typename to_be_t<T>::type, lvl, typename to_le_t<AT>::type>;
namespace ps3
{
// default pointer for HLE functions (LE pointer to BE data)
template<typename T, int lvl = 1, typename AT = u32> using ptr = lptrb<T, lvl, AT>;
// default pointer for PS3 HLE functions (Native endianness pointer to BE data)
template<typename T, int lvl = 1, typename AT = u32> using ptr = ptrb<T, lvl, AT>;
// default pointer for HLE structures (BE pointer to BE data)
// default pointer for PS3 HLE structures (BE pointer to BE data)
template<typename T, int lvl = 1, typename AT = u32> using bptr = bptrb<T, lvl, AT>;
}
namespace psv
{
// default pointer for HLE functions & structures (LE pointer to LE data)
template<typename T, int lvl = 1, typename AT = u32> using ptr = lptrl<T, lvl, AT>;
// default pointer for PSV HLE functions (Native endianness pointer to LE data)
template<typename T, int lvl = 1, typename AT = u32> using ptr = ptrl<T, lvl, AT>;
// default pointer for PSV HLE structures (LE pointer to LE data)
template<typename T, int lvl = 1, typename AT = u32> using lptr = lptrl<T, lvl, AT>;
}
// PS3 emulation is main now, so lets it be as default

View File

@ -60,31 +60,40 @@ namespace vm
}
};
//BE reference to LE data
template<typename T, typename AT = u32> using brefl = _ref_base<T, typename to_be_t<AT>::type>;
// Native endianness reference to LE data
template<typename T, typename AT = u32> using refl = _ref_base<typename to_le_t<T>::type, AT>;
//BE reference to BE data
// Native endianness reference to BE data
template<typename T, typename AT = u32> using refb = _ref_base<typename to_be_t<T>::type, AT>;
// BE reference to LE data
template<typename T, typename AT = u32> using brefl = _ref_base<typename to_le_t<T>::type, typename to_be_t<AT>::type>;
// BE reference to BE data
template<typename T, typename AT = u32> using brefb = _ref_base<typename to_be_t<T>::type, typename to_be_t<AT>::type>;
//LE reference to BE data
template<typename T, typename AT = u32> using lrefb = _ref_base<typename to_be_t<T>::type, AT>;
// LE reference to LE data
template<typename T, typename AT = u32> using lrefl = _ref_base<typename to_le_t<T>::type, typename to_le_t<AT>::type>;
//LE reference to LE data
template<typename T, typename AT = u32> using lrefl = _ref_base<T, AT>;
// LE reference to BE data
template<typename T, typename AT = u32> using lrefb = _ref_base<typename to_be_t<T>::type, typename to_le_t<AT>::type>;
namespace ps3
{
//default reference for HLE functions (LE reference to BE data)
template<typename T, typename AT = u32> using ref = lrefb<T, AT>;
// default reference for PS3 HLE functions (Native endianness reference to BE data)
template<typename T, typename AT = u32> using ref = refb<T, AT>;
//default reference for HLE structures (BE reference to BE data)
// default reference for PS3 HLE structures (BE reference to BE data)
template<typename T, typename AT = u32> using bref = brefb<T, AT>;
}
namespace psv
{
//default reference for HLE functions & structures (LE reference to LE data)
template<typename T, typename AT = u32> using ref = lrefl<T, AT>;
// default reference for PSV HLE functions (Native endianness reference to LE data)
template<typename T, typename AT = u32> using ref = refl<T, AT>;
// default reference for PSV HLE structures (LE reference to LE data)
template<typename T, typename AT = u32> using lref = lrefl<T, AT>;
}
//PS3 emulation is main now, so lets it be as default

View File

@ -201,9 +201,9 @@ enum
struct CellGcmControl
{
atomic_t<u32> put;
atomic_t<u32> get;
atomic_t<u32> ref;
atomic_be_t<u32> put;
atomic_be_t<u32> get;
atomic_be_t<u32> ref;
};
struct CellGcmConfig

View File

@ -216,12 +216,10 @@ next:
}
}
u32 adecOpen(AudioDecoder* adec_ptr)
void adecOpen(u32 adec_id) // TODO: call from the constructor
{
std::shared_ptr<AudioDecoder> sptr(adec_ptr);
AudioDecoder& adec = *adec_ptr;
u32 adec_id = Emu.GetIdManager().GetNewID(sptr);
const auto sptr = Emu.GetIdManager().get<AudioDecoder>(adec_id);
AudioDecoder& adec = *sptr;
adec.id = adec_id;
@ -234,9 +232,9 @@ u32 adecOpen(AudioDecoder* adec_ptr)
adec.adecCb->InitRegs();
adec.adecCb->DoRun();
thread_t t(fmt::format("AudioDecoder[0x%x] Thread", adec_id), [adec_ptr, sptr]()
thread_t t(fmt::format("AudioDecoder[0x%x] Thread", adec_id), [sptr]()
{
AudioDecoder& adec = *adec_ptr;
AudioDecoder& adec = *sptr;
AdecTask& task = adec.task;
while (true)
@ -478,8 +476,6 @@ u32 adecOpen(AudioDecoder* adec_ptr)
adec.is_finished = true;
});
return adec_id;
}
bool adecCheckType(AudioCodecType type)
@ -536,7 +532,7 @@ s32 cellAdecOpen(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResource> res, vm::
return CELL_ADEC_ERROR_ARG;
}
*handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
adecOpen(*handle = Emu.GetIdManager().make<AudioDecoder>(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
@ -550,7 +546,7 @@ s32 cellAdecOpenEx(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResourceEx> res,
return CELL_ADEC_ERROR_ARG;
}
*handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
adecOpen(*handle = Emu.GetIdManager().make<AudioDecoder>(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
@ -564,7 +560,7 @@ s32 cellAdecClose(u32 handle)
{
cellAdec.Warning("cellAdecClose(handle=0x%x)", handle);
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
const auto adec = Emu.GetIdManager().get<AudioDecoder>(handle);
if (!adec)
{
@ -585,7 +581,7 @@ s32 cellAdecClose(u32 handle)
}
if (adec->adecCb) Emu.GetCPU().RemoveThread(adec->adecCb->GetId());
Emu.GetIdManager().RemoveID<AudioDecoder>(handle);
Emu.GetIdManager().remove<AudioDecoder>(handle);
return CELL_OK;
}
@ -593,7 +589,7 @@ s32 cellAdecStartSeq(u32 handle, u32 param)
{
cellAdec.Warning("cellAdecStartSeq(handle=0x%x, param=*0x%x)", handle, param);
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
const auto adec = Emu.GetIdManager().get<AudioDecoder>(handle);
if (!adec)
{
@ -646,7 +642,7 @@ s32 cellAdecEndSeq(u32 handle)
{
cellAdec.Warning("cellAdecEndSeq(handle=0x%x)", handle);
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
const auto adec = Emu.GetIdManager().get<AudioDecoder>(handle);
if (!adec)
{
@ -661,7 +657,7 @@ s32 cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
{
cellAdec.Log("cellAdecDecodeAu(handle=0x%x, auInfo=*0x%x)", handle, auInfo);
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
const auto adec = Emu.GetIdManager().get<AudioDecoder>(handle);
if (!adec)
{
@ -684,7 +680,7 @@ s32 cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
{
cellAdec.Log("cellAdecGetPcm(handle=0x%x, outBuffer=*0x%x)", handle, outBuffer);
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
const auto adec = Emu.GetIdManager().get<AudioDecoder>(handle);
if (!adec)
{
@ -800,7 +796,7 @@ s32 cellAdecGetPcmItem(u32 handle, vm::ptr<vm::bptr<CellAdecPcmItem>> pcmItem)
{
cellAdec.Log("cellAdecGetPcmItem(handle=0x%x, pcmItem=**0x%x)", handle, pcmItem);
const auto adec = Emu.GetIdManager().GetIDData<AudioDecoder>(handle);
const auto adec = Emu.GetIdManager().get<AudioDecoder>(handle);
if (!adec)
{

View File

@ -763,12 +763,12 @@ s32 cellAudioCreateNotifyEventQueue(vm::ptr<u32> id, vm::ptr<u64> key)
{
const u64 key_value = 0x80004d494f323221ull + k;
std::shared_ptr<event_queue_t> queue(new event_queue_t(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0, key_value, 32));
const auto queue = std::make_shared<lv2_event_queue_t>(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0, key_value, 32);
// register key if not used yet
if (Emu.GetEventManager().RegisterKey(queue, key_value))
if (Emu.GetEventManager().RegisterKey(queue))
{
*id = Emu.GetIdManager().GetNewID(queue, TYPE_EVENT_QUEUE);
*id = Emu.GetIdManager().add(queue);
*key = key_value;
return CELL_OK;

View File

@ -98,7 +98,7 @@ enum AudioPortState : u32
struct AudioPortConfig
{
std::mutex mutex;
atomic_le_t<AudioPortState> state;
atomic<AudioPortState> state;
u32 channel;
u32 block;
@ -116,13 +116,13 @@ struct AudioPortConfig
};
float level;
atomic_le_t<level_set_t> level_set;
atomic<level_set_t> level_set;
};
struct AudioConfig //custom structure
{
std::mutex mutex;
atomic_le_t<AudioState> state;
atomic<AudioState> state;
thread_t audio_thread;
AudioPortConfig ports[AUDIO_PORT_COUNT];

View File

@ -298,12 +298,10 @@ void dmuxQueryEsAttr(u32 info /* may be 0 */, vm::ptr<const CellCodecEsFilterId>
cellDmux.Warning("*** filter(0x%x, 0x%x, 0x%x, 0x%x)", esFilterId->filterIdMajor, esFilterId->filterIdMinor, esFilterId->supplementalInfo1, esFilterId->supplementalInfo2);
}
u32 dmuxOpen(Demuxer* dmux_ptr)
void dmuxOpen(u32 dmux_id) // TODO: call from the constructor
{
std::shared_ptr<Demuxer> sptr(dmux_ptr);
Demuxer& dmux = *dmux_ptr;
u32 dmux_id = Emu.GetIdManager().GetNewID(sptr);
const auto sptr = Emu.GetIdManager().get<Demuxer>(dmux_id);
Demuxer& dmux = *sptr;
dmux.id = dmux_id;
@ -316,9 +314,9 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
dmux.dmuxCb->InitRegs();
dmux.dmuxCb->DoRun();
thread_t t(fmt::format("Demuxer[0x%x] Thread", dmux_id), [dmux_ptr, sptr]()
thread_t t(fmt::format("Demuxer[0x%x] Thread", dmux_id), [sptr]()
{
Demuxer& dmux = *dmux_ptr;
Demuxer& dmux = *sptr;
DemuxerTask task;
DemuxerStream stream = {};
@ -711,7 +709,7 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
}
}
es.dmux = nullptr;
Emu.GetIdManager().RemoveID<ElementaryStream>(task.es.es);
Emu.GetIdManager().remove<ElementaryStream>(task.es.es);
break;
}
@ -772,8 +770,6 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
dmux.is_finished = true;
});
return dmux_id;
}
s32 cellDmuxQueryAttr(vm::ptr<const CellDmuxType> type, vm::ptr<CellDmuxAttr> attr)
@ -813,7 +809,7 @@ s32 cellDmuxOpen(vm::ptr<const CellDmuxType> type, vm::ptr<const CellDmuxResourc
// TODO: check demuxerResource and demuxerCb arguments
*handle = dmuxOpen(new Demuxer(res->memAddr, res->memSize, cb->cbMsgFunc, cb->cbArg));
dmuxOpen(*handle = Emu.GetIdManager().make<Demuxer>(res->memAddr, res->memSize, cb->cbMsgFunc, cb->cbArg));
return CELL_OK;
}
@ -829,7 +825,7 @@ s32 cellDmuxOpenEx(vm::ptr<const CellDmuxType> type, vm::ptr<const CellDmuxResou
// TODO: check demuxerResourceEx and demuxerCb arguments
*handle = dmuxOpen(new Demuxer(resEx->memAddr, resEx->memSize, cb->cbMsgFunc, cb->cbArg));
dmuxOpen(*handle = Emu.GetIdManager().make<Demuxer>(resEx->memAddr, resEx->memSize, cb->cbMsgFunc, cb->cbArg));
return CELL_OK;
}
@ -850,7 +846,7 @@ s32 cellDmuxOpen2(vm::ptr<const CellDmuxType2> type2, vm::ptr<const CellDmuxReso
// TODO: check demuxerType2, demuxerResource2 and demuxerCb arguments
*handle = dmuxOpen(new Demuxer(res2->memAddr, res2->memSize, cb->cbMsgFunc, cb->cbArg));
dmuxOpen(*handle = Emu.GetIdManager().make<Demuxer>(res2->memAddr, res2->memSize, cb->cbMsgFunc, cb->cbArg));
return CELL_OK;
}
@ -859,7 +855,7 @@ s32 cellDmuxClose(u32 handle)
{
cellDmux.Warning("cellDmuxClose(handle=0x%x)", handle);
const auto dmux = Emu.GetIdManager().GetIDData<Demuxer>(handle);
const auto dmux = Emu.GetIdManager().get<Demuxer>(handle);
if (!dmux)
{
@ -881,7 +877,7 @@ s32 cellDmuxClose(u32 handle)
}
if (dmux->dmuxCb) Emu.GetCPU().RemoveThread(dmux->dmuxCb->GetId());
Emu.GetIdManager().RemoveID<Demuxer>(handle);
Emu.GetIdManager().remove<Demuxer>(handle);
return CELL_OK;
}
@ -889,7 +885,7 @@ s32 cellDmuxSetStream(u32 handle, u32 streamAddress, u32 streamSize, bool discon
{
cellDmux.Log("cellDmuxSetStream(handle=0x%x, streamAddress=0x%x, streamSize=%d, discontinuity=%d, userData=0x%llx)", handle, streamAddress, streamSize, discontinuity, userData);
const auto dmux = Emu.GetIdManager().GetIDData<Demuxer>(handle);
const auto dmux = Emu.GetIdManager().get<Demuxer>(handle);
if (!dmux)
{
@ -917,7 +913,7 @@ s32 cellDmuxResetStream(u32 handle)
{
cellDmux.Warning("cellDmuxResetStream(handle=0x%x)", handle);
const auto dmux = Emu.GetIdManager().GetIDData<Demuxer>(handle);
const auto dmux = Emu.GetIdManager().get<Demuxer>(handle);
if (!dmux)
{
@ -932,7 +928,7 @@ s32 cellDmuxResetStreamAndWaitDone(u32 handle)
{
cellDmux.Warning("cellDmuxResetStreamAndWaitDone(handle=0x%x)", handle);
const auto dmux = Emu.GetIdManager().GetIDData<Demuxer>(handle);
const auto dmux = Emu.GetIdManager().get<Demuxer>(handle);
if (!dmux)
{
@ -993,7 +989,7 @@ s32 cellDmuxEnableEs(u32 handle, vm::ptr<const CellCodecEsFilterId> esFilterId,
{
cellDmux.Warning("cellDmuxEnableEs(handle=0x%x, esFilterId=*0x%x, esResourceInfo=*0x%x, esCb=*0x%x, esSpecificInfo=*0x%x, esHandle=*0x%x)", handle, esFilterId, esResourceInfo, esCb, esSpecificInfo, esHandle);
const auto dmux = Emu.GetIdManager().GetIDData<Demuxer>(handle);
const auto dmux = Emu.GetIdManager().get<Demuxer>(handle);
if (!dmux)
{
@ -1006,7 +1002,7 @@ s32 cellDmuxEnableEs(u32 handle, vm::ptr<const CellCodecEsFilterId> esFilterId,
esFilterId->filterIdMajor, esFilterId->filterIdMinor, esFilterId->supplementalInfo1, esFilterId->supplementalInfo2,
esCb->cbEsMsgFunc, esCb->cbArg, esSpecificInfo));
u32 id = Emu.GetIdManager().GetNewID(es);
u32 id = Emu.GetIdManager().add(es);
es->id = id;
*esHandle = id;
@ -1025,7 +1021,7 @@ s32 cellDmuxDisableEs(u32 esHandle)
{
cellDmux.Warning("cellDmuxDisableEs(esHandle=0x%x)", esHandle);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{
@ -1044,7 +1040,7 @@ s32 cellDmuxResetEs(u32 esHandle)
{
cellDmux.Log("cellDmuxResetEs(esHandle=0x%x)", esHandle);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{
@ -1063,7 +1059,7 @@ s32 cellDmuxGetAu(u32 esHandle, vm::ptr<u32> auInfo, vm::ptr<u32> auSpecificInfo
{
cellDmux.Log("cellDmuxGetAu(esHandle=0x%x, auInfo=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfo, auSpecificInfo);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{
@ -1086,7 +1082,7 @@ s32 cellDmuxPeekAu(u32 esHandle, vm::ptr<u32> auInfo, vm::ptr<u32> auSpecificInf
{
cellDmux.Log("cellDmuxPeekAu(esHandle=0x%x, auInfo=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfo, auSpecificInfo);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{
@ -1109,7 +1105,7 @@ s32 cellDmuxGetAuEx(u32 esHandle, vm::ptr<u32> auInfoEx, vm::ptr<u32> auSpecific
{
cellDmux.Log("cellDmuxGetAuEx(esHandle=0x%x, auInfoEx=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfoEx, auSpecificInfo);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{
@ -1132,7 +1128,7 @@ s32 cellDmuxPeekAuEx(u32 esHandle, vm::ptr<u32> auInfoEx, vm::ptr<u32> auSpecifi
{
cellDmux.Log("cellDmuxPeekAuEx(esHandle=0x%x, auInfoEx=**0x%x, auSpecificInfo=**0x%x)", esHandle, auInfoEx, auSpecificInfo);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{
@ -1155,7 +1151,7 @@ s32 cellDmuxReleaseAu(u32 esHandle)
{
cellDmux.Log("cellDmuxReleaseAu(esHandle=0x%x)", esHandle);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{
@ -1173,7 +1169,7 @@ s32 cellDmuxFlushEs(u32 esHandle)
{
cellDmux.Warning("cellDmuxFlushEs(esHandle=0x%x)", esHandle);
const auto es = Emu.GetIdManager().GetIDData<ElementaryStream>(esHandle);
const auto es = Emu.GetIdManager().get<ElementaryStream>(esHandle);
if (!es)
{

View File

@ -210,7 +210,7 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
{
cellFs.Warning("cellFsGetDirectoryEntries(fd=0x%x, entries=*0x%x, entries_size=0x%x, data_count=*0x%x)", fd, entries, entries_size, data_count);
const auto directory = Emu.GetIdManager().GetIDData<vfsDirBase>(fd);
const auto directory = Emu.GetIdManager().get<lv2_dir_t>(fd);
if (!directory)
{
@ -255,7 +255,7 @@ s32 cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 buffer_size,
// TODO: use single sys_fs_fcntl syscall
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file || file->flags & CELL_FS_O_WRONLY)
{
@ -286,7 +286,7 @@ s32 cellFsWriteWithOffset(u32 fd, u64 offset, vm::ptr<const void> buf, u64 data_
// TODO: use single sys_fs_fcntl syscall
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file || !(file->flags & CELL_FS_O_ACCMODE))
{
@ -330,7 +330,7 @@ s32 cellFsStReadInit(u32 fd, vm::ptr<const CellFsRingBuffer> ringbuf)
return CELL_FS_EINVAL;
}
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -368,7 +368,7 @@ s32 cellFsStReadFinish(u32 fd)
{
cellFs.Warning("cellFsStReadFinish(fd=0x%x)", fd);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -391,7 +391,7 @@ s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
{
cellFs.Warning("cellFsStReadGetRingBuf(fd=0x%x, ringbuf=*0x%x)", fd, ringbuf);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -415,7 +415,7 @@ s32 cellFsStReadGetStatus(u32 fd, vm::ptr<u64> status)
{
cellFs.Warning("cellFsStReadGetRingBuf(fd=0x%x, status=*0x%x)", fd, status);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -449,7 +449,7 @@ s32 cellFsStReadGetRegid(u32 fd, vm::ptr<u64> regid)
{
cellFs.Warning("cellFsStReadGetRingBuf(fd=0x%x, regid=*0x%x)", fd, regid);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -470,7 +470,7 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size)
{
cellFs.Warning("cellFsStReadStart(fd=0x%x, offset=0x%llx, size=0x%llx)", fd, offset, size);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -552,7 +552,7 @@ s32 cellFsStReadStop(u32 fd)
{
cellFs.Warning("cellFsStReadStop(fd=0x%x)", fd);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -583,7 +583,7 @@ s32 cellFsStRead(u32 fd, vm::ptr<u8> buf, u64 size, vm::ptr<u64> rsize)
{
cellFs.Warning("cellFsStRead(fd=0x%x, buf=*0x%x, size=0x%llx, rsize=*0x%x)", fd, buf, size, rsize);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -617,7 +617,7 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<u32> addr, vm::ptr<u64> size)
{
cellFs.Warning("cellFsStReadGetCurrentAddr(fd=0x%x, addr=*0x%x, size=*0x%x)", fd, addr, size);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -650,7 +650,7 @@ s32 cellFsStReadPutCurrentAddr(u32 fd, vm::ptr<u8> addr, u64 size)
{
cellFs.Warning("cellFsStReadPutCurrentAddr(fd=0x%x, addr=*0x%x, size=0x%llx)", fd, addr, size);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -677,7 +677,7 @@ s32 cellFsStReadWait(u32 fd, u64 size)
{
cellFs.Warning("cellFsStReadWait(fd=0x%x, size=0x%llx)", fd, size);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -711,7 +711,7 @@ s32 cellFsStReadWaitCallback(u32 fd, u64 size, fs_st_cb_t func)
{
cellFs.Warning("cellFsStReadWaitCallback(fd=0x%x, size=0x%llx, func=*0x%x)", fd, size, func);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -879,7 +879,7 @@ void fsAio(vm::ptr<CellFsAio> aio, bool write, s32 xid, fs_aio_cb_t func)
s32 error = CELL_OK;
u64 result = 0;
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(aio->fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(aio->fd);
if (!file || (!write && file->flags & CELL_FS_O_WRONLY) || (write && !(file->flags & CELL_FS_O_ACCMODE)))
{
@ -931,11 +931,6 @@ s32 cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
{
cellFs.Warning("cellFsAioRead(aio=*0x%x, id=*0x%x, func=*0x%x)", aio, id, func);
if (!Emu.GetIdManager().CheckID<fs_file_t>(aio->fd))
{
return CELL_FS_EBADF;
}
// TODO: detect mount point and send AIO request to the AIO thread of this mount point
const s32 xid = (*id = ++g_fs_aio_id);
@ -949,11 +944,6 @@ s32 cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
{
cellFs.Warning("cellFsAioWrite(aio=*0x%x, id=*0x%x, func=*0x%x)", aio, id, func);
if (!Emu.GetIdManager().CheckID<fs_file_t>(aio->fd))
{
return CELL_FS_EBADF;
}
// TODO: detect mount point and send AIO request to the AIO thread of this mount point
const s32 xid = (*id = ++g_fs_aio_id);
@ -983,7 +973,7 @@ s32 cellFsSetIoBufferFromDefaultContainer(u32 fd, u32 buffer_size, u32 page_type
{
cellFs.Todo("cellFsSetIoBufferFromDefaultContainer(fd=0x%x, buffer_size=%d, page_type=%d)", fd, buffer_size, page_type);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{

View File

@ -48,16 +48,16 @@ s32 cellGifDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellGifDecSrc
{
// Get file descriptor and size
std::shared_ptr<vfsStream> file_s(Emu.GetVFS().OpenFile(src->fileName.get_ptr(), vfsRead));
std::shared_ptr<fs_file_t> file(new fs_file_t(file_s, 0, 0));
if (!file) return CELL_GIFDEC_ERROR_OPEN_FILE;
current_subHandle->fd = Emu.GetIdManager().GetNewID(file, TYPE_FS_FILE);
current_subHandle->fileSize = file->file->GetSize();
if (!file_s) return CELL_GIFDEC_ERROR_OPEN_FILE;
current_subHandle->fd = Emu.GetIdManager().make<lv2_file_t>(file_s, 0, 0);
current_subHandle->fileSize = file_s->GetSize();
break;
}
}
// From now, every u32 subHandle argument is a pointer to a CellGifDecSubHandle struct.
*subHandle = Emu.GetIdManager().GetNewID(current_subHandle);
*subHandle = Emu.GetIdManager().add(current_subHandle);
return CELL_OK;
}
@ -66,7 +66,7 @@ s32 cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo>
{
cellGifDec.Warning("cellGifDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info=*0x%x)", mainHandle, subHandle, info);
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
if (!subHandle_data)
{
@ -88,7 +88,7 @@ s32 cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo>
case se32(CELL_GIFDEC_FILE):
{
auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
file->file->Seek(0);
file->file->Read(buffer.begin(), buffer.size());
break;
@ -120,7 +120,7 @@ s32 cellGifDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellGifD
{
cellGifDec.Warning("cellGifDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam=*0x%x, outParam=*0x%x)", mainHandle, subHandle, inParam, outParam);
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
if (!subHandle_data)
{
@ -154,7 +154,7 @@ s32 cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP;
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
if (!subHandle_data)
{
@ -176,7 +176,7 @@ s32 cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
case se32(CELL_GIFDEC_FILE):
{
auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
file->file->Seek(0);
file->file->Read(gif.ptr(), gif.size());
break;
@ -273,15 +273,15 @@ s32 cellGifDecClose(u32 mainHandle, u32 subHandle)
{
cellGifDec.Warning("cellGifDecClose(mainHandle=0x%x, subHandle=0x%x)", mainHandle, subHandle);
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellGifDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellGifDecSubHandle>(subHandle);
if (!subHandle_data)
{
return CELL_GIFDEC_ERROR_FATAL;
}
Emu.GetIdManager().RemoveID<fs_file_t>(subHandle_data->fd);
Emu.GetIdManager().RemoveID<CellGifDecSubHandle>(subHandle);
Emu.GetIdManager().remove<lv2_file_t>(subHandle_data->fd);
Emu.GetIdManager().remove<CellGifDecSubHandle>(subHandle);
return CELL_OK;
}

View File

@ -54,16 +54,16 @@ s32 cellJpgDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellJpgDecSrc
{
// Get file descriptor and size
std::shared_ptr<vfsStream> file_s(Emu.GetVFS().OpenFile(src->fileName.get_ptr(), vfsRead));
std::shared_ptr<fs_file_t> file(new fs_file_t(file_s, 0, 0));
if (!file) return CELL_JPGDEC_ERROR_OPEN_FILE;
current_subHandle->fd = Emu.GetIdManager().GetNewID(file, TYPE_FS_FILE);
current_subHandle->fileSize = file->file->GetSize();
if (!file_s) return CELL_JPGDEC_ERROR_OPEN_FILE;
current_subHandle->fd = Emu.GetIdManager().make<lv2_file_t>(file_s, 0, 0);
current_subHandle->fileSize = file_s->GetSize();
break;
}
}
// From now, every u32 subHandle argument is a pointer to a CellJpgDecSubHandle struct.
*subHandle = Emu.GetIdManager().GetNewID(current_subHandle);
*subHandle = Emu.GetIdManager().add(current_subHandle);
return CELL_OK;
}
@ -72,15 +72,15 @@ s32 cellJpgDecClose(u32 mainHandle, u32 subHandle)
{
cellJpgDec.Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle=0x%x)", mainHandle, subHandle);
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellJpgDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellJpgDecSubHandle>(subHandle);
if (!subHandle_data)
{
return CELL_JPGDEC_ERROR_FATAL;
}
Emu.GetIdManager().RemoveID<fs_file_t>(subHandle_data->fd);
Emu.GetIdManager().RemoveID<CellJpgDecSubHandle>(subHandle);
Emu.GetIdManager().remove<lv2_file_t>(subHandle_data->fd);
Emu.GetIdManager().remove<CellJpgDecSubHandle>(subHandle);
return CELL_OK;
}
@ -89,7 +89,7 @@ s32 cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo>
{
cellJpgDec.Log("cellJpgDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info=*0x%x)", mainHandle, subHandle, info);
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellJpgDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellJpgDecSubHandle>(subHandle);
if (!subHandle_data)
{
@ -111,7 +111,7 @@ s32 cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo>
case se32(CELL_JPGDEC_FILE):
{
auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
file->file->Seek(0);
file->file->Read(buffer.ptr(), buffer.size());
break;
@ -163,7 +163,7 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_STOP;
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellJpgDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellJpgDecSubHandle>(subHandle);
if (!subHandle_data)
{
@ -185,7 +185,7 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
case se32(CELL_JPGDEC_FILE):
{
auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
file->file->Seek(0);
file->file->Read(jpg.ptr(), jpg.size());
break;
@ -297,7 +297,7 @@ s32 cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellJpgD
{
cellJpgDec.Log("cellJpgDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam=*0x%x, outParam=*0x%x)", mainHandle, subHandle, inParam, outParam);
const auto subHandle_data = Emu.GetIdManager().GetIDData<CellJpgDecSubHandle>(subHandle);
const auto subHandle_data = Emu.GetIdManager().get<CellJpgDecSubHandle>(subHandle);
if (!subHandle_data)
{

View File

@ -86,10 +86,10 @@ s32 pngDecOpen(
{
// Get file descriptor and size
std::shared_ptr<vfsStream> file_s(Emu.GetVFS().OpenFile(src->fileName.get_ptr(), vfsRead));
std::shared_ptr<fs_file_t> file(new fs_file_t(file_s, 0, 0));
if (!file) return CELL_PNGDEC_ERROR_OPEN_FILE;
stream->fd = Emu.GetIdManager().GetNewID(file, TYPE_FS_FILE);
stream->fileSize = file->file->GetSize();
if (!file_s) return CELL_PNGDEC_ERROR_OPEN_FILE;
stream->fd = Emu.GetIdManager().make<lv2_file_t>(file_s, 0, 0);
stream->fileSize = file_s->GetSize();
break;
}
}
@ -115,7 +115,7 @@ s32 pngDecOpen(
s32 pngDecClose(CellPngDecSubHandle stream)
{
Emu.GetIdManager().RemoveID<fs_file_t>(stream->fd);
Emu.GetIdManager().remove<lv2_file_t>(stream->fd);
if (!Memory.Free(stream.addr()))
{
@ -148,7 +148,7 @@ s32 pngReadHeader(
break;
case se32(CELL_PNGDEC_FILE):
{
auto file = Emu.GetIdManager().GetIDData<fs_file_t>(stream->fd);
auto file = Emu.GetIdManager().get<lv2_file_t>(stream->fd);
file->file->Seek(0);
file->file->Read(buffer.begin(), buffer.size());
break;
@ -260,7 +260,7 @@ s32 pngDecodeData(
case se32(CELL_PNGDEC_FILE):
{
auto file = Emu.GetIdManager().GetIDData<fs_file_t>(stream->fd);
auto file = Emu.GetIdManager().get<lv2_file_t>(stream->fd);
file->file->Seek(0);
file->file->Read(png.ptr(), png.size());
break;

View File

@ -3,6 +3,8 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/CB_FUNC.h"
#include "Emu/IdManager.h"
#include "Emu/Event.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/SPUThread.h"
@ -27,16 +29,20 @@ s32 _cellSpursSendSignal(vm::ptr<CellSpursTaskset> taskset, u32 taskID);
s32 spursCreateLv2EventQueue(vm::ptr<CellSpurs> spurs, u32& queue_id, vm::ptr<u8> port, s32 size, u64 name_u64)
{
queue_id = event_queue_create(SYS_SYNC_FIFO, SYS_PPU_QUEUE, name_u64, 0, size);
if (!queue_id)
const auto queue = Emu.GetEventManager().MakeEventQueue(SYS_SYNC_FIFO, SYS_PPU_QUEUE, name_u64, 0, size);
if (!queue) // rough
{
return CELL_EAGAIN; // rough
return CELL_EAGAIN;
}
queue_id = Emu.GetIdManager().add(queue);
if (s32 res = spursAttachLv2EventQueue(spurs, queue_id, port, 1, true))
{
assert(!"spursAttachLv2EventQueue() failed");
}
return CELL_OK;
}
@ -105,7 +111,7 @@ s32 spursInit(
u32 sem;
for (u32 i = 0; i < 0x10; i++)
{
sem = semaphore_create(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuWkl");
sem = Emu.GetIdManager().make<lv2_sema_t>(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuWkl");
assert(sem && ~sem); // should rollback if semaphore creation failed and return the error
spurs->m.wklF1[i].sem = sem;
}
@ -113,12 +119,12 @@ s32 spursInit(
{
for (u32 i = 0; i < 0x10; i++)
{
sem = semaphore_create(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuWkl");
sem = Emu.GetIdManager().make<lv2_sema_t>(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuWkl");
assert(sem && ~sem);
spurs->m.wklF2[i].sem = sem;
}
}
sem = semaphore_create(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuPrv");
sem = Emu.GetIdManager().make<lv2_sema_t>(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuPrv");
assert(sem && ~sem);
spurs->m.semPrv = sem;
spurs->m.unk11 = -1;
@ -186,7 +192,7 @@ s32 spursInit(
}
spurs->m.queue = queue;
u32 port = event_port_create(0);
u32 port = Emu.GetIdManager().make<lv2_event_port_t>(SYS_EVENT_PORT_LOCAL, 0);
assert(port && ~port);
spurs->m.port = port;

View File

@ -304,7 +304,7 @@ struct CellSpursWorkloadFlag
{
be_t<u64> unused0;
be_t<u32> unused1;
atomic_t<u32> flag;
atomic_be_t<u32> flag;
};
typedef void(CellSpursShutdownCompletionEventHook)(vm::ptr<CellSpurs>, u32 wid, vm::ptr<void> arg);
@ -412,7 +412,7 @@ struct CellSpurs
vm::bptr<const void, 1, u64> addr; // Address of the executable
be_t<u64> arg; // spu argument
be_t<u32> size;
atomic_t<u8> uniqueId; // The unique id is the same for all workloads with the same addr
atomic_be_t<u8> uniqueId; // The unique id is the same for all workloads with the same addr
u8 pad[3];
u8 priority[8];
};
@ -436,30 +436,30 @@ struct CellSpurs
// real data
struct
{
atomic_t<u8> wklReadyCount1[0x10]; // 0x00 Number of SPUs requested by each workload (0..15 wids).
atomic_t<u8> wklIdleSpuCountOrReadyCount2[0x10]; // 0x10 SPURS1: Number of idle SPUs requested by each workload (0..15 wids). SPURS2: Number of SPUs requested by each workload (16..31 wids).
atomic_be_t<u8> wklReadyCount1[0x10]; // 0x00 Number of SPUs requested by each workload (0..15 wids).
atomic_be_t<u8> wklIdleSpuCountOrReadyCount2[0x10]; // 0x10 SPURS1: Number of idle SPUs requested by each workload (0..15 wids). SPURS2: Number of SPUs requested by each workload (16..31 wids).
u8 wklCurrentContention[0x10]; // 0x20 Number of SPUs used by each workload. SPURS1: index = wid. SPURS2: packed 4-bit data, index = wid % 16, internal index = wid / 16.
u8 wklPendingContention[0x10]; // 0x30 Number of SPUs that are pending to context switch to the workload. SPURS1: index = wid. SPURS2: packed 4-bit data, index = wid % 16, internal index = wid / 16.
u8 wklMinContention[0x10]; // 0x40 Min SPUs required for each workload. SPURS1: index = wid. SPURS2: Unused.
atomic_t<u8> wklMaxContention[0x10]; // 0x50 Max SPUs that may be allocated to each workload. SPURS1: index = wid. SPURS2: packed 4-bit data, index = wid % 16, internal index = wid / 16.
atomic_be_t<u8> wklMaxContention[0x10]; // 0x50 Max SPUs that may be allocated to each workload. SPURS1: index = wid. SPURS2: packed 4-bit data, index = wid % 16, internal index = wid / 16.
CellSpursWorkloadFlag wklFlag; // 0x60
atomic_t<u16> wklSignal1; // 0x70 (bitset for 0..15 wids)
atomic_t<u8> sysSrvMessage; // 0x72
atomic_be_t<u16> wklSignal1; // 0x70 (bitset for 0..15 wids)
atomic_be_t<u8> sysSrvMessage; // 0x72
u8 spuIdling; // 0x73
u8 flags1; // 0x74 Type is SpursFlags1
u8 sysSrvTraceControl; // 0x75
u8 nSpus; // 0x76
atomic_t<u8> wklFlagReceiver; // 0x77
atomic_t<u16> wklSignal2; // 0x78 (bitset for 16..32 wids)
atomic_be_t<u8> wklFlagReceiver; // 0x77
atomic_be_t<u16> wklSignal2; // 0x78 (bitset for 16..32 wids)
u8 x7A[6]; // 0x7A
atomic_t<u8> wklState1[0x10]; // 0x80 SPURS_WKL_STATE_*
atomic_be_t<u8> wklState1[0x10]; // 0x80 SPURS_WKL_STATE_*
u8 wklStatus1[0x10]; // 0x90
u8 wklEvent1[0x10]; // 0xA0
atomic_t<u32> wklMskA; // 0xB0 - System service - Available workloads (32*u1)
atomic_t<u32> wklMskB; // 0xB4 - System service - Available module id
atomic_be_t<u32> wklMskA; // 0xB0 - System service - Available workloads (32*u1)
atomic_be_t<u32> wklMskB; // 0xB4 - System service - Available module id
u32 xB8; // 0xB8
u8 sysSrvExitBarrier; // 0xBC
atomic_t<u8> sysSrvMsgUpdateWorkload; // 0xBD
atomic_be_t<u8> sysSrvMsgUpdateWorkload; // 0xBD
u8 xBE; // 0xBE
u8 sysSrvMsgTerminate; // 0xBF
u8 sysSrvWorkload[8]; // 0xC0
@ -471,7 +471,7 @@ struct CellSpurs
u8 xCD; // 0xCD
u8 sysSrvMsgUpdateTrace; // 0xCE
u8 xCF; // 0xCF
atomic_t<u8> wklState2[0x10]; // 0xD0 SPURS_WKL_STATE_*
atomic_be_t<u8> wklState2[0x10]; // 0xD0 SPURS_WKL_STATE_*
u8 wklStatus2[0x10]; // 0xE0
u8 wklEvent2[0x10]; // 0xF0
_sub_str1 wklF1[0x10]; // 0x100
@ -495,10 +495,10 @@ struct CellSpurs
u8 unknown3[0xD5C - 0xD54];
be_t<u32> queue; // 0xD5C - Event queue
be_t<u32> port; // 0xD60 - Event port
atomic_t<u8> xD64; // 0xD64 - SPURS handler dirty
atomic_t<u8> xD65; // 0xD65 - SPURS handler waiting
atomic_t<u8> xD66; // 0xD66 - SPURS handler exiting
atomic_t<u32> enableEH; // 0xD68
atomic_be_t<u8> xD64; // 0xD64 - SPURS handler dirty
atomic_be_t<u8> xD65; // 0xD65 - SPURS handler waiting
atomic_be_t<u8> xD66; // 0xD66 - SPURS handler exiting
atomic_be_t<u32> enableEH; // 0xD68
be_t<u32> exception; // 0xD6C
sys_spu_image spuImg; // 0xD70
be_t<u32> flags; // 0xD80
@ -509,7 +509,7 @@ struct CellSpurs
be_t<u32> unk5; // 0xD9C
be_t<u32> revision; // 0xDA0
be_t<u32> sdkVersion; // 0xDA4
atomic_t<u64> spups; // 0xDA8 - SPU port bits
atomic_be_t<u64> spups; // 0xDA8 - SPU port bits
sys_lwmutex_t mutex; // 0xDB0
sys_lwcond_t cond; // 0xDC8
u8 unknown9[0xE00 - 0xDD0];
@ -528,7 +528,7 @@ struct CellSpurs
} c;
};
__forceinline atomic_t<u8>& wklState(const u32 wid)
__forceinline atomic_be_t<u8>& wklState(const u32 wid)
{
if (wid & 0x10)
{

View File

@ -39,11 +39,11 @@ union CellSyncMutex
struct
{
atomic_t<u16> release_count;
atomic_t<u16> acquire_count;
atomic_be_t<u16> release_count;
atomic_be_t<u16> acquire_count;
};
atomic_t<sync_t> sync_var;
atomic_be_t<sync_t> sync_var;
};
static_assert(sizeof(CellSyncMutex) == 4, "CellSyncMutex: wrong size");
@ -56,7 +56,7 @@ struct CellSyncBarrier
be_t<s16> m_count;
};
atomic_t<data_t> data;
atomic_be_t<data_t> data;
};
static_assert(sizeof(CellSyncBarrier) == 4, "CellSyncBarrier: wrong size");
@ -69,7 +69,7 @@ struct CellSyncRwm
be_t<u16> m_writers;
};
atomic_t<data_t> data;
atomic_be_t<data_t> data;
be_t<u32> m_size;
vm::bptr<void, 1, u64> m_buffer;
};
@ -84,7 +84,7 @@ struct CellSyncQueue
be_t<u32> m_v2;
};
atomic_t<data_t> data;
atomic_be_t<data_t> data;
be_t<u32> m_size;
be_t<u32> m_depth;
vm::bptr<u8, 1, u64> m_buffer;
@ -143,14 +143,14 @@ struct CellSyncLFQueue
union // 0x0
{
atomic_t<pop1_t> pop1;
atomic_t<pop3_t> pop3;
atomic_be_t<pop1_t> pop1;
atomic_be_t<pop3_t> pop3;
};
union // 0x8
{
atomic_t<push1_t> push1;
atomic_t<push3_t> push3;
atomic_be_t<push1_t> push1;
atomic_be_t<push3_t> push3;
};
be_t<u32> m_size; // 0x10
@ -159,10 +159,10 @@ struct CellSyncLFQueue
u8 m_bs[4]; // 0x20
be_t<CellSyncQueueDirection> m_direction; // 0x24
be_t<u32> m_v1; // 0x28
atomic_t<u32> init; // 0x2C
atomic_t<push2_t> push2; // 0x30
atomic_be_t<u32> init; // 0x2C
atomic_be_t<push2_t> push2; // 0x30
be_t<u16> m_hs1[15]; // 0x32
atomic_t<pop2_t> pop2; // 0x50
atomic_be_t<pop2_t> pop2; // 0x50
be_t<u16> m_hs2[15]; // 0x52
vm::bptr<void, 1, u64> m_eaSignal; // 0x70
be_t<u32> m_v2; // 0x78

View File

@ -207,12 +207,11 @@ u32 vdecQueryAttr(CellVdecCodecType type, u32 profile, u32 spec_addr /* may be 0
return CELL_OK;
}
u32 vdecOpen(VideoDecoder* vdec_ptr)
void vdecOpen(u32 vdec_id) // TODO: call from the constructor
{
std::shared_ptr<VideoDecoder> sptr(vdec_ptr);
VideoDecoder& vdec = *vdec_ptr;
const auto sptr = Emu.GetIdManager().get<VideoDecoder>(vdec_id);
u32 vdec_id = Emu.GetIdManager().GetNewID(sptr);
VideoDecoder& vdec = *sptr;
vdec.id = vdec_id;
@ -225,9 +224,9 @@ u32 vdecOpen(VideoDecoder* vdec_ptr)
vdec.vdecCb->InitRegs();
vdec.vdecCb->DoRun();
thread_t t(fmt::format("VideoDecoder[0x%x] Thread", vdec_id), [vdec_ptr, sptr]()
thread_t t(fmt::format("VideoDecoder[0x%x] Thread", vdec_id), [sptr]()
{
VideoDecoder& vdec = *vdec_ptr;
VideoDecoder& vdec = *sptr;
VdecTask& task = vdec.task;
while (true)
@ -549,8 +548,6 @@ u32 vdecOpen(VideoDecoder* vdec_ptr)
vdec.is_finished = true;
});
return vdec_id;
}
s32 cellVdecQueryAttr(vm::ptr<const CellVdecType> type, vm::ptr<CellVdecAttr> attr)
@ -571,7 +568,7 @@ s32 cellVdecOpen(vm::ptr<const CellVdecType> type, vm::ptr<const CellVdecResourc
{
cellVdec.Warning("cellVdecOpen(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle);
*handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
vdecOpen(*handle = Emu.GetIdManager().make<VideoDecoder>(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
@ -580,7 +577,7 @@ s32 cellVdecOpenEx(vm::ptr<const CellVdecTypeEx> type, vm::ptr<const CellVdecRes
{
cellVdec.Warning("cellVdecOpenEx(type=*0x%x, res=*0x%x, cb=*0x%x, handle=*0x%x)", type, res, cb, handle);
*handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
vdecOpen(*handle = Emu.GetIdManager().make<VideoDecoder>(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
@ -589,7 +586,7 @@ s32 cellVdecClose(u32 handle)
{
cellVdec.Warning("cellVdecClose(handle=0x%x)", handle);
const auto vdec = Emu.GetIdManager().GetIDData<VideoDecoder>(handle);
const auto vdec = Emu.GetIdManager().get<VideoDecoder>(handle);
if (!vdec)
{
@ -610,7 +607,7 @@ s32 cellVdecClose(u32 handle)
}
if (vdec->vdecCb) Emu.GetCPU().RemoveThread(vdec->vdecCb->GetId());
Emu.GetIdManager().RemoveID<VideoDecoder>(handle);
Emu.GetIdManager().remove<VideoDecoder>(handle);
return CELL_OK;
}
@ -618,7 +615,7 @@ s32 cellVdecStartSeq(u32 handle)
{
cellVdec.Log("cellVdecStartSeq(handle=0x%x)", handle);
const auto vdec = Emu.GetIdManager().GetIDData<VideoDecoder>(handle);
const auto vdec = Emu.GetIdManager().get<VideoDecoder>(handle);
if (!vdec)
{
@ -633,7 +630,7 @@ s32 cellVdecEndSeq(u32 handle)
{
cellVdec.Warning("cellVdecEndSeq(handle=0x%x)", handle);
const auto vdec = Emu.GetIdManager().GetIDData<VideoDecoder>(handle);
const auto vdec = Emu.GetIdManager().get<VideoDecoder>(handle);
if (!vdec)
{
@ -648,7 +645,7 @@ s32 cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::ptr<const CellVdec
{
cellVdec.Log("cellVdecDecodeAu(handle=0x%x, mode=%d, auInfo=*0x%x)", handle, mode, auInfo);
const auto vdec = Emu.GetIdManager().GetIDData<VideoDecoder>(handle);
const auto vdec = Emu.GetIdManager().get<VideoDecoder>(handle);
if (!vdec || mode > CELL_VDEC_DEC_MODE_PB_SKIP)
{
@ -678,7 +675,7 @@ s32 cellVdecGetPicture(u32 handle, vm::ptr<const CellVdecPicFormat> format, vm::
{
cellVdec.Log("cellVdecGetPicture(handle=0x%x, format=*0x%x, outBuff=*0x%x)", handle, format, outBuff);
const auto vdec = Emu.GetIdManager().GetIDData<VideoDecoder>(handle);
const auto vdec = Emu.GetIdManager().get<VideoDecoder>(handle);
if (!vdec || !format)
{
@ -802,7 +799,7 @@ s32 cellVdecGetPicItem(u32 handle, vm::ptr<vm::bptr<CellVdecPicItem>> picItem)
{
cellVdec.Log("cellVdecGetPicItem(handle=0x%x, picItem=**0x%x)", handle, picItem);
const auto vdec = Emu.GetIdManager().GetIDData<VideoDecoder>(handle);
const auto vdec = Emu.GetIdManager().get<VideoDecoder>(handle);
if (!vdec)
{
@ -947,7 +944,7 @@ s32 cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc)
{
cellVdec.Log("cellVdecSetFrameRate(handle=0x%x, frc=0x%x)", handle, frc);
const auto vdec = Emu.GetIdManager().GetIDData<VideoDecoder>(handle);
const auto vdec = Emu.GetIdManager().get<VideoDecoder>(handle);
if (!vdec)
{

View File

@ -27,22 +27,12 @@ s32 cellVpostQueryAttr(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<CellVp
return CELL_OK;
}
u32 vpostOpen(VpostInstance* data)
{
std::shared_ptr<VpostInstance> data_ptr(data);
u32 id = Emu.GetIdManager().GetNewID(data_ptr);
cellVpost.Notice("*** Vpost instance created (to_rgba=%d): id = %d", data->to_rgba, id);
return id;
}
s32 cellVpostOpen(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<const CellVpostResource> resource, vm::ptr<u32> handle)
{
cellVpost.Warning("cellVpostOpen(cfgParam=*0x%x, resource=*0x%x, handle=*0x%x)", cfgParam, resource, handle);
// TODO: check values
*handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV));
*handle = Emu.GetIdManager().make<VpostInstance>(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV);
return CELL_OK;
}
@ -51,7 +41,7 @@ s32 cellVpostOpenEx(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<const Cel
cellVpost.Warning("cellVpostOpenEx(cfgParam=*0x%x, resource=*0x%x, handle=*0x%x)", cfgParam, resource, handle);
// TODO: check values
*handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV));
*handle = Emu.GetIdManager().make<VpostInstance>(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV);
return CELL_OK;
}
@ -59,14 +49,14 @@ s32 cellVpostClose(u32 handle)
{
cellVpost.Warning("cellVpostClose(handle=0x%x)", handle);
const auto vpost = Emu.GetIdManager().GetIDData<VpostInstance>(handle);
const auto vpost = Emu.GetIdManager().get<VpostInstance>(handle);
if (!vpost)
{
return CELL_VPOST_ERROR_C_ARG_HDL_INVALID;
}
Emu.GetIdManager().RemoveID<VpostInstance>(handle);
Emu.GetIdManager().remove<VpostInstance>(handle);
return CELL_OK;
}
@ -74,7 +64,7 @@ s32 cellVpostExec(u32 handle, vm::ptr<const u8> inPicBuff, vm::ptr<const CellVpo
{
cellVpost.Log("cellVpostExec(handle=0x%x, inPicBuff=*0x%x, ctrlParam=*0x%x, outPicBuff=*0x%x, picInfo=*0x%x)", handle, inPicBuff, ctrlParam, outPicBuff, picInfo);
const auto vpost = Emu.GetIdManager().GetIDData<VpostInstance>(handle);
const auto vpost = Emu.GetIdManager().get<VpostInstance>(handle);
if (!vpost)
{

View File

@ -112,12 +112,10 @@ s32 sys_lwmutex_create(vm::ptr<sys_lwmutex_t> lwmutex, vm::ptr<sys_lwmutex_attri
default: sysPrxForUser.Error("sys_lwmutex_create(): invalid protocol (0x%x)", protocol); return CELL_EINVAL;
}
std::shared_ptr<lwmutex_t> lw(new lwmutex_t(protocol, attr->name_u64));
lwmutex->lock_var = { { lwmutex::free, lwmutex::zero } };
lwmutex->attribute = attr->recursive | attr->protocol;
lwmutex->recursive_count = 0;
lwmutex->sleep_queue = Emu.GetIdManager().GetNewID(lw, TYPE_LWMUTEX);
lwmutex->sleep_queue = Emu.GetIdManager().make<lv2_lwmutex_t>(protocol, attr->name_u64);
return CELL_OK;
}
@ -362,9 +360,7 @@ s32 sys_lwcond_create(vm::ptr<sys_lwcond_t> lwcond, vm::ptr<sys_lwmutex_t> lwmut
{
sysPrxForUser.Warning("sys_lwcond_create(lwcond=*0x%x, lwmutex=*0x%x, attr=*0x%x)", lwcond, lwmutex, attr);
std::shared_ptr<lwcond_t> cond(new lwcond_t(attr->name_u64));
lwcond->lwcond_queue = Emu.GetIdManager().GetNewID(cond, TYPE_LWCOND);
lwcond->lwcond_queue = Emu.GetIdManager().make<lv2_lwcond_t>(attr->name_u64);
lwcond->lwmutex = lwmutex;
return CELL_OK;
@ -770,16 +766,14 @@ u32 _sys_heap_create_heap(vm::ptr<const char> name, u32 arg2, u32 arg3, u32 arg4
{
sysPrxForUser.Warning("_sys_heap_create_heap(name=*0x%x, arg2=0x%x, arg3=0x%x, arg4=0x%x)", name, arg2, arg3, arg4);
std::shared_ptr<HeapInfo> heap(new HeapInfo(name.get_ptr()));
return Emu.GetIdManager().GetNewID(heap);
return Emu.GetIdManager().make<HeapInfo>(name.get_ptr());
}
s32 _sys_heap_delete_heap(u32 heap)
{
sysPrxForUser.Warning("_sys_heap_delete_heap(heap=0x%x)", heap);
Emu.GetIdManager().RemoveID<HeapInfo>(heap);
Emu.GetIdManager().remove<HeapInfo>(heap);
return CELL_OK;
}
@ -1169,7 +1163,7 @@ s32 sys_process_get_paramsfo(vm::ptr<char> buffer)
return _sys_process_get_paramsfo(buffer);
}
void sys_spinlock_initialize(vm::ptr<atomic_t<u32>> lock)
void sys_spinlock_initialize(vm::ptr<atomic_be_t<u32>> lock)
{
sysPrxForUser.Log("sys_spinlock_initialize(lock=*0x%x)", lock);
@ -1177,7 +1171,7 @@ void sys_spinlock_initialize(vm::ptr<atomic_t<u32>> lock)
lock->exchange(be_t<u32>::make(0));
}
void sys_spinlock_lock(vm::ptr<atomic_t<u32>> lock)
void sys_spinlock_lock(vm::ptr<atomic_be_t<u32>> lock)
{
sysPrxForUser.Log("sys_spinlock_lock(lock=*0x%x)", lock);
@ -1194,7 +1188,7 @@ void sys_spinlock_lock(vm::ptr<atomic_t<u32>> lock)
}
}
s32 sys_spinlock_trylock(vm::ptr<atomic_t<u32>> lock)
s32 sys_spinlock_trylock(vm::ptr<atomic_be_t<u32>> lock)
{
sysPrxForUser.Log("sys_spinlock_trylock(lock=*0x%x)", lock);
@ -1207,7 +1201,7 @@ s32 sys_spinlock_trylock(vm::ptr<atomic_t<u32>> lock)
return CELL_OK;
}
void sys_spinlock_unlock(vm::ptr<atomic_t<u32>> lock)
void sys_spinlock_unlock(vm::ptr<atomic_be_t<u32>> lock)
{
sysPrxForUser.Log("sys_spinlock_unlock(lock=*0x%x)", lock);
@ -1263,7 +1257,7 @@ void sys_ppu_thread_exit(PPUThread& CPU, u64 val)
std::mutex g_once_mutex;
void sys_ppu_thread_once(PPUThread& CPU, vm::ptr<atomic_t<u32>> once_ctrl, vm::ptr<void()> init)
void sys_ppu_thread_once(PPUThread& CPU, vm::ptr<atomic_be_t<u32>> once_ctrl, vm::ptr<void()> init)
{
sysPrxForUser.Warning("sys_ppu_thread_once(once_ctrl=*0x%x, init=*0x%x)", once_ctrl, init);

View File

@ -125,7 +125,7 @@ u32 sleep_queue_t::signal(u32 protocol)
if (m_waiting.size())
{
res = m_waiting[0];
if (!Emu.GetIdManager().CheckID<CPUThread>(res))
if (!Emu.GetIdManager().check_id<CPUThread>(res))
{
LOG_ERROR(HLE, "sleep_queue_t['%s']::signal(SYS_SYNC_FIFO) failed: invalid thread (%d)", m_name.c_str(), res);
Emu.Pause();

View File

@ -19,7 +19,7 @@ s32 sys_cond_create(vm::ptr<u32> cond_id, u32 mutex_id, vm::ptr<sys_cond_attribu
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<mutex_t>(mutex_id);
const auto mutex = std::move(Emu.GetIdManager().get<lv2_mutex_t>(mutex_id));
if (!mutex)
{
@ -37,9 +37,7 @@ s32 sys_cond_create(vm::ptr<u32> cond_id, u32 mutex_id, vm::ptr<sys_cond_attribu
throw __FUNCTION__;
}
std::shared_ptr<cond_t> cond(new cond_t(mutex, attr->name_u64));
*cond_id = Emu.GetIdManager().GetNewID(cond, TYPE_COND);
*cond_id = Emu.GetIdManager().make<lv2_cond_t>(mutex, attr->name_u64);
return CELL_OK;
}
@ -50,7 +48,7 @@ s32 sys_cond_destroy(u32 cond_id)
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<cond_t>(cond_id);
const auto cond = Emu.GetIdManager().get<lv2_cond_t>(cond_id);
if (!cond)
{
@ -67,7 +65,7 @@ s32 sys_cond_destroy(u32 cond_id)
throw __FUNCTION__;
}
Emu.GetIdManager().RemoveID<cond_t>(cond_id);
Emu.GetIdManager().remove<lv2_cond_t>(cond_id);
return CELL_OK;
}
@ -78,7 +76,7 @@ s32 sys_cond_signal(u32 cond_id)
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<cond_t>(cond_id);
const auto cond = Emu.GetIdManager().get<lv2_cond_t>(cond_id);
if (!cond)
{
@ -101,7 +99,7 @@ s32 sys_cond_signal_all(u32 cond_id)
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<cond_t>(cond_id);
const auto cond = Emu.GetIdManager().get<lv2_cond_t>(cond_id);
if (!cond)
{
@ -124,14 +122,14 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id)
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<cond_t>(cond_id);
const auto cond = Emu.GetIdManager().get<lv2_cond_t>(cond_id);
if (!cond)
{
return CELL_ESRCH;
}
if (!Emu.GetIdManager().CheckID<CPUThread>(thread_id))
if (!Emu.GetIdManager().check_id<CPUThread>(thread_id))
{
return CELL_ESRCH;
}
@ -158,7 +156,7 @@ s32 sys_cond_wait(PPUThread& CPU, u32 cond_id, u64 timeout)
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<cond_t>(cond_id);
const auto cond = Emu.GetIdManager().get<lv2_cond_t>(cond_id);
if (!cond)
{

View File

@ -1,6 +1,6 @@
#pragma once
struct mutex_t;
struct lv2_mutex_t;
struct sys_cond_attribute_t
{
@ -15,10 +15,10 @@ struct sys_cond_attribute_t
};
};
struct cond_t
struct lv2_cond_t
{
const u64 name;
const std::shared_ptr<mutex_t> mutex; // associated mutex
const std::shared_ptr<lv2_mutex_t> mutex; // associated mutex
std::atomic<u32> signaled;
@ -26,7 +26,7 @@ struct cond_t
std::condition_variable cv;
std::unordered_set<u32> waiters;
cond_t(const std::shared_ptr<mutex_t>& mutex, u64 name)
lv2_cond_t(const std::shared_ptr<lv2_mutex_t>& mutex, u64 name)
: mutex(mutex)
, name(name)
, signaled(0)
@ -35,6 +35,8 @@ struct cond_t
}
};
REG_ID_TYPE(lv2_cond_t, 0x86); // SYS_COND_OBJECT
class PPUThread;
// SysCalls

View File

@ -13,15 +13,6 @@
SysCallBase sys_event("sys_event");
u32 event_queue_create(u32 protocol, s32 type, u64 name_u64, u64 event_queue_key, s32 size)
{
std::shared_ptr<event_queue_t> queue(new event_queue_t(protocol, type, name_u64, event_queue_key, size));
Emu.GetEventManager().RegisterKey(queue, event_queue_key);
return Emu.GetIdManager().GetNewID(queue, TYPE_EVENT_QUEUE);
}
s32 sys_event_queue_create(vm::ptr<u32> equeue_id, vm::ptr<sys_event_queue_attr> attr, u64 event_queue_key, s32 size)
{
sys_event.Warning("sys_event_queue_create(equeue_id=*0x%x, attr=*0x%x, event_queue_key=0x%llx, size=%d)", equeue_id, attr, event_queue_key, size);
@ -49,14 +40,14 @@ s32 sys_event_queue_create(vm::ptr<u32> equeue_id, vm::ptr<sys_event_queue_attr>
default: sys_event.Error("sys_event_queue_create(): unknown type (0x%x)", type); return CELL_EINVAL;
}
std::shared_ptr<event_queue_t> queue(new event_queue_t(protocol, type, attr->name_u64, event_queue_key, size));
const auto queue = Emu.GetEventManager().MakeEventQueue(protocol, type, attr->name_u64, event_queue_key, size);
if (!Emu.GetEventManager().RegisterKey(queue, event_queue_key))
if (!queue)
{
return CELL_EEXIST;
}
*equeue_id = Emu.GetIdManager().GetNewID(queue, TYPE_EVENT_QUEUE);
*equeue_id = Emu.GetIdManager().add(queue);
return CELL_OK;
}
@ -67,7 +58,7 @@ s32 sys_event_queue_destroy(u32 equeue_id, s32 mode)
LV2_LOCK;
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(equeue_id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(equeue_id);
if (!queue)
{
@ -95,7 +86,7 @@ s32 sys_event_queue_destroy(u32 equeue_id, s32 mode)
}
Emu.GetEventManager().UnregisterKey(queue->key);
Emu.GetIdManager().RemoveID<event_queue_t>(equeue_id);
Emu.GetIdManager().remove<lv2_event_queue_t>(equeue_id);
return CELL_OK;
}
@ -106,7 +97,7 @@ s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr<sys_event_t> event_array,
LV2_LOCK;
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(equeue_id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(equeue_id);
if (!queue)
{
@ -146,7 +137,7 @@ s32 sys_event_queue_receive(PPUThread& CPU, u32 equeue_id, vm::ptr<sys_event_t>
LV2_LOCK;
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(equeue_id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(equeue_id);
if (!queue)
{
@ -203,7 +194,7 @@ s32 sys_event_queue_drain(u32 equeue_id)
LV2_LOCK;
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(equeue_id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(equeue_id);
if (!queue)
{
@ -215,13 +206,6 @@ s32 sys_event_queue_drain(u32 equeue_id)
return CELL_OK;
}
u32 event_port_create(u64 name)
{
std::shared_ptr<event_port_t> eport(new event_port_t(SYS_EVENT_PORT_LOCAL, name));
return Emu.GetIdManager().GetNewID(eport, TYPE_EVENT_PORT);
}
s32 sys_event_port_create(vm::ptr<u32> eport_id, s32 port_type, u64 name)
{
sys_event.Warning("sys_event_port_create(eport_id=*0x%x, port_type=%d, name=0x%llx)", eport_id, port_type, name);
@ -232,9 +216,7 @@ s32 sys_event_port_create(vm::ptr<u32> eport_id, s32 port_type, u64 name)
return CELL_EINVAL;
}
std::shared_ptr<event_port_t> eport(new event_port_t(port_type, name));
*eport_id = Emu.GetIdManager().GetNewID(eport, TYPE_EVENT_PORT);
*eport_id = Emu.GetIdManager().make<lv2_event_port_t>(port_type, name);
return CELL_OK;
}
@ -245,7 +227,7 @@ s32 sys_event_port_destroy(u32 eport_id)
LV2_LOCK;
const auto port = Emu.GetIdManager().GetIDData<event_port_t>(eport_id);
const auto port = Emu.GetIdManager().get<lv2_event_port_t>(eport_id);
if (!port)
{
@ -257,7 +239,7 @@ s32 sys_event_port_destroy(u32 eport_id)
return CELL_EISCONN;
}
Emu.GetIdManager().RemoveID<event_port_t>(eport_id);
Emu.GetIdManager().remove<lv2_event_port_t>(eport_id);
return CELL_OK;
}
@ -268,8 +250,8 @@ s32 sys_event_port_connect_local(u32 eport_id, u32 equeue_id)
LV2_LOCK;
const auto port = Emu.GetIdManager().GetIDData<event_port_t>(eport_id);
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(equeue_id);
const auto port = Emu.GetIdManager().get<lv2_event_port_t>(eport_id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(equeue_id);
if (!port || !queue)
{
@ -297,7 +279,7 @@ s32 sys_event_port_disconnect(u32 eport_id)
LV2_LOCK;
const auto port = Emu.GetIdManager().GetIDData<event_port_t>(eport_id);
const auto port = Emu.GetIdManager().get<lv2_event_port_t>(eport_id);
if (!port)
{
@ -324,7 +306,7 @@ s32 sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
LV2_LOCK;
const auto port = Emu.GetIdManager().GetIDData<event_port_t>(eport_id);
const auto port = Emu.GetIdManager().get<lv2_event_port_t>(eport_id);
if (!port)
{

View File

@ -69,7 +69,7 @@ struct event_t
}
};
struct event_queue_t
struct lv2_event_queue_t
{
const u32 protocol;
const s32 type;
@ -84,7 +84,7 @@ struct event_queue_t
std::condition_variable cv;
std::atomic<u32> waiters;
event_queue_t(u32 protocol, s32 type, u64 name, u64 key, s32 size)
lv2_event_queue_t(u32 protocol, s32 type, u64 name, u64 key, s32 size)
: protocol(protocol)
, type(type)
, name(name)
@ -108,24 +108,24 @@ struct event_queue_t
}
};
struct event_port_t
REG_ID_TYPE(lv2_event_queue_t, 0x8D); // SYS_EVENT_QUEUE_OBJECT
struct lv2_event_port_t
{
const s32 type; // port type, must be SYS_EVENT_PORT_LOCAL
const u64 name; // passed as event source (generated from id and process id if not set)
std::weak_ptr<event_queue_t> queue; // event queue this port is connected to
std::weak_ptr<lv2_event_queue_t> queue; // event queue this port is connected to
event_port_t(s32 type, u64 name)
lv2_event_port_t(s32 type, u64 name)
: type(type)
, name(name)
{
}
};
class PPUThread;
REG_ID_TYPE(lv2_event_port_t, 0x0E); // SYS_EVENT_PORT_OBJECT
// Aux
u32 event_port_create(u64 name);
u32 event_queue_create(u32 protocol, s32 type, u64 name_u64, u64 event_queue_key, s32 size);
class PPUThread;
// SysCalls
s32 sys_event_queue_create(vm::ptr<u32> equeue_id, vm::ptr<sys_event_queue_attr> attr, u64 event_queue_key, s32 size);

View File

@ -47,9 +47,7 @@ s32 sys_event_flag_create(vm::ptr<u32> id, vm::ptr<sys_event_flag_attr> attr, u6
default: sys_event_flag.Error("sys_event_flag_create(): unknown type (0x%x)", attr->type); return CELL_EINVAL;
}
std::shared_ptr<event_flag_t> ef(new event_flag_t(init, protocol, type, attr->name_u64));
*id = Emu.GetIdManager().GetNewID(ef, TYPE_EVENT_FLAG);
*id = Emu.GetIdManager().make<lv2_event_flag_t>(init, protocol, type, attr->name_u64);
return CELL_OK;
}
@ -60,7 +58,7 @@ s32 sys_event_flag_destroy(u32 id)
LV2_LOCK;
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(id);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(id);
if (!ef)
{
@ -72,7 +70,7 @@ s32 sys_event_flag_destroy(u32 id)
return CELL_EBUSY;
}
Emu.GetIdManager().RemoveID<event_flag_t>(id);
Emu.GetIdManager().remove<lv2_event_flag_t>(id);
return CELL_OK;
}
@ -105,7 +103,7 @@ s32 sys_event_flag_wait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result, u64 t
default: return CELL_EINVAL;
}
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(id);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(id);
if (!ef)
{
@ -212,7 +210,7 @@ s32 sys_event_flag_trywait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result)
default: return CELL_EINVAL;
}
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(id);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(id);
if (!ef)
{
@ -252,7 +250,7 @@ s32 sys_event_flag_set(u32 id, u64 bitptn)
LV2_LOCK;
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(id);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(id);
if (!ef)
{
@ -280,7 +278,7 @@ s32 sys_event_flag_clear(u32 id, u64 bitptn)
LV2_LOCK;
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(id);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(id);
if (!ef)
{
@ -308,7 +306,7 @@ s32 sys_event_flag_cancel(u32 id, vm::ptr<u32> num)
*num = 0;
}
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(id);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(id);
if (!ef)
{
@ -344,7 +342,7 @@ s32 sys_event_flag_get(u32 id, vm::ptr<u64> flags)
return CELL_EFAULT;
}
const auto ef = Emu.GetIdManager().GetIDData<event_flag_t>(id);
const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(id);
if (!ef)
{

View File

@ -27,7 +27,7 @@ struct sys_event_flag_attr
};
};
struct event_flag_t
struct lv2_event_flag_t
{
const u32 protocol;
const s32 type;
@ -40,7 +40,7 @@ struct event_flag_t
std::condition_variable cv;
std::atomic<u32> waiters;
event_flag_t(u64 pattern, u32 protocol, s32 type, u64 name)
lv2_event_flag_t(u64 pattern, u32 protocol, s32 type, u64 name)
: flags(pattern)
, protocol(protocol)
, type(type)
@ -51,6 +51,8 @@ struct event_flag_t
}
};
REG_ID_TYPE(lv2_event_flag_t, 0x98); // SYS_EVENT_FLAG_OBJECT
s32 sys_event_flag_create(vm::ptr<u32> id, vm::ptr<sys_event_flag_attr> attr, u64 init);
s32 sys_event_flag_destroy(u32 id);
s32 sys_event_flag_wait(u32 id, u64 bitptn, u32 mode, vm::ptr<u64> result, u64 timeout);

View File

@ -109,9 +109,7 @@ s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, s32 mode,
return CELL_FS_ENOENT;
}
std::shared_ptr<fs_file_t> file_handler(new fs_file_t(file, mode, flags));
*fd = Emu.GetIdManager().GetNewID(file_handler, TYPE_FS_FILE);
*fd = Emu.GetIdManager().make<lv2_file_t>(file, mode, flags);
return CELL_OK;
}
@ -120,7 +118,7 @@ s32 sys_fs_read(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread)
{
sys_fs.Log("sys_fs_read(fd=0x%x, buf=0x%x, nbytes=0x%llx, nread=0x%x)", fd, buf, nbytes, nread);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file || file->flags & CELL_FS_O_WRONLY)
{
@ -138,7 +136,7 @@ s32 sys_fs_write(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<u64> nwrit
{
sys_fs.Log("sys_fs_write(fd=0x%x, buf=*0x%x, nbytes=0x%llx, nwrite=*0x%x)", fd, buf, nbytes, nwrite);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file || !(file->flags & CELL_FS_O_ACCMODE))
{
@ -158,7 +156,7 @@ s32 sys_fs_close(u32 fd)
{
sys_fs.Log("sys_fs_close(fd=0x%x)", fd);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -167,7 +165,7 @@ s32 sys_fs_close(u32 fd)
// TODO: return CELL_FS_EBUSY if locked
Emu.GetIdManager().RemoveID<fs_file_t>(fd);
Emu.GetIdManager().remove<lv2_file_t>(fd);
return CELL_OK;
}
@ -177,7 +175,7 @@ s32 sys_fs_opendir(vm::ptr<const char> path, vm::ptr<u32> fd)
sys_fs.Warning("sys_fs_opendir(path=*0x%x, fd=*0x%x)", path, fd);
sys_fs.Warning("*** path = '%s'", path.get_ptr());
std::shared_ptr<vfsDirBase> directory(Emu.GetVFS().OpenDir(path.get_ptr()));
std::shared_ptr<lv2_dir_t> directory(Emu.GetVFS().OpenDir(path.get_ptr()));
if (!directory || !directory->IsOpened())
{
@ -185,7 +183,7 @@ s32 sys_fs_opendir(vm::ptr<const char> path, vm::ptr<u32> fd)
return CELL_FS_ENOENT;
}
*fd = Emu.GetIdManager().GetNewID(directory, TYPE_FS_DIR);
*fd = Emu.GetIdManager().add(directory);
return CELL_OK;
}
@ -194,7 +192,7 @@ s32 sys_fs_readdir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<u64> nread)
{
sys_fs.Warning("sys_fs_readdir(fd=0x%x, dir=*0x%x, nread=*0x%x)", fd, dir, nread);
const auto directory = Emu.GetIdManager().GetIDData<vfsDirBase>(fd);
const auto directory = Emu.GetIdManager().get<lv2_dir_t>(fd);
if (!directory)
{
@ -222,14 +220,14 @@ s32 sys_fs_closedir(u32 fd)
{
sys_fs.Log("sys_fs_closedir(fd=0x%x)", fd);
const auto directory = Emu.GetIdManager().GetIDData<vfsDirBase>(fd);
const auto directory = Emu.GetIdManager().get<lv2_dir_t>(fd);
if (!directory)
{
return CELL_FS_EBADF;
}
Emu.GetIdManager().RemoveID<vfsDirBase>(fd);
Emu.GetIdManager().remove<lv2_dir_t>(fd);
return CELL_OK;
}
@ -271,7 +269,7 @@ s32 sys_fs_fstat(u32 fd, vm::ptr<CellFsStat> sb)
{
sys_fs.Warning("sys_fs_fstat(fd=0x%x, sb=*0x%x)", fd, sb);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -420,7 +418,7 @@ s32 sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ptr<u64> pos)
return CELL_FS_EINVAL;
}
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -438,7 +436,7 @@ s32 sys_fs_fget_block_size(u32 fd, vm::ptr<u64> sector_size, vm::ptr<u64> block_
{
sys_fs.Todo("sys_fs_fget_block_size(fd=0x%x, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x, arg5=*0x%x)", fd, sector_size, block_size, arg4, arg5);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file)
{
@ -486,7 +484,7 @@ s32 sys_fs_ftruncate(u32 fd, u64 size)
{
sys_fs.Warning("sys_fs_ftruncate(fd=0x%x, size=0x%llx)", fd, size);
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
const auto file = Emu.GetIdManager().get<lv2_file_t>(fd);
if (!file || !(file->flags & CELL_FS_O_ACCMODE))
{

View File

@ -145,6 +145,8 @@ struct CellFsUtimbuf
#pragma pack(pop)
struct vfsStream;
// Stream Support Status (st_status)
enum : u32
{
@ -163,7 +165,7 @@ struct fs_st_cb_rec_t
u32 pad;
};
struct fs_file_t
struct lv2_file_t
{
const std::shared_ptr<vfsStream> file;
const s32 mode;
@ -172,7 +174,7 @@ struct fs_file_t
std::mutex mutex;
std::condition_variable cv;
atomic_le_t<u32> st_status;
atomic<u32> st_status;
u64 st_ringbuf_size;
u64 st_block_size;
@ -186,9 +188,9 @@ struct fs_file_t
std::atomic<u64> st_total_read;
std::atomic<u64> st_copied;
atomic_le_t<fs_st_cb_rec_t> st_callback;
atomic<fs_st_cb_rec_t> st_callback;
fs_file_t(std::shared_ptr<vfsStream>& file, s32 mode, s32 flags)
lv2_file_t(const std::shared_ptr<vfsStream>& file, s32 mode, s32 flags)
: file(file)
, mode(mode)
, flags(flags)
@ -198,6 +200,14 @@ struct fs_file_t
}
};
REG_ID_TYPE(lv2_file_t, 0x73); // SYS_FS_FD_OBJECT
class vfsDirBase;
using lv2_dir_t = vfsDirBase;
REG_ID_TYPE(lv2_dir_t, 0x73); // SYS_FS_FD_OBJECT
// SysCalls
s32 sys_fs_test(u32 arg1, u32 arg2, vm::ptr<u32> arg3, u32 arg4, vm::ptr<char> arg5, u32 arg6);
s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, s32 mode, vm::ptr<const void> arg, u64 size);

View File

@ -78,8 +78,6 @@ s32 sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u64 intrthread,
return CELL_ESRCH;
}
std::shared_ptr<interrupt_handler_t> handler(new interrupt_handler_t{ it });
PPUThread& ppu = static_cast<PPUThread&>(*it);
{
@ -127,7 +125,7 @@ s32 sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u64 intrthread,
};
}
*ih = Emu.GetIdManager().GetNewID(handler, TYPE_INTR_SERVICE_HANDLE);
*ih = Emu.GetIdManager().make<lv2_int_handler_t>(it);
ppu.Exec();
return CELL_OK;
@ -137,7 +135,7 @@ s32 _sys_interrupt_thread_disestablish(u32 ih, vm::ptr<u64> r13)
{
sys_interrupt.Todo("_sys_interrupt_thread_disestablish(ih=0x%x, r13=*0x%x)", ih, r13);
const auto handler = Emu.GetIdManager().GetIDData<interrupt_handler_t>(ih);
const auto handler = Emu.GetIdManager().get<lv2_int_handler_t>(ih);
if (!handler)
{

View File

@ -2,11 +2,18 @@
class PPUThread;
struct interrupt_handler_t
struct lv2_int_handler_t
{
std::shared_ptr<CPUThread> handler;
lv2_int_handler_t(const std::shared_ptr<CPUThread>& handler)
: handler(handler)
{
}
};
REG_ID_TYPE(lv2_int_handler_t, 0x0B); // SYS_INTR_SERVICE_HANDLE_OBJECT
// SysCalls
s32 sys_interrupt_tag_destroy(u32 intrtag);
s32 sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u64 intrthread, u64 arg);

View File

@ -15,19 +15,15 @@ SysCallBase sys_lwcond("sys_lwcond");
void lwcond_create(sys_lwcond_t& lwcond, sys_lwmutex_t& lwmutex, u64 name)
{
std::shared_ptr<lwcond_t> cond(new lwcond_t(name));
lwcond.lwmutex.set(vm::get_addr(&lwmutex));
lwcond.lwcond_queue = Emu.GetIdManager().GetNewID(cond, TYPE_LWCOND);
lwcond.lwcond_queue = Emu.GetIdManager().make<lv2_lwcond_t>(name);
}
s32 _sys_lwcond_create(vm::ptr<u32> lwcond_id, u32 lwmutex_id, vm::ptr<sys_lwcond_t> control, u64 name, u32 arg5)
{
sys_lwcond.Warning("_sys_lwcond_create(lwcond_id=*0x%x, lwmutex_id=0x%x, control=*0x%x, name=0x%llx, arg5=0x%x)", lwcond_id, lwmutex_id, control, name, arg5);
std::shared_ptr<lwcond_t> cond(new lwcond_t(name));
*lwcond_id = Emu.GetIdManager().GetNewID(cond, TYPE_LWCOND);
*lwcond_id = Emu.GetIdManager().make<lv2_lwcond_t>(name);
return CELL_OK;
}
@ -38,7 +34,7 @@ s32 _sys_lwcond_destroy(u32 lwcond_id)
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<lwcond_t>(lwcond_id);
const auto cond = Emu.GetIdManager().get<lv2_lwcond_t>(lwcond_id);
if (!cond)
{
@ -50,7 +46,7 @@ s32 _sys_lwcond_destroy(u32 lwcond_id)
return CELL_EBUSY;
}
Emu.GetIdManager().RemoveID<lwcond_t>(lwcond_id);
Emu.GetIdManager().remove<lv2_lwcond_t>(lwcond_id);
return CELL_OK;
}
@ -61,8 +57,8 @@ s32 _sys_lwcond_signal(u32 lwcond_id, u32 lwmutex_id, u32 ppu_thread_id, u32 mod
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<lwcond_t>(lwcond_id);
const auto mutex = Emu.GetIdManager().GetIDData<lwmutex_t>(lwmutex_id);
const auto cond = Emu.GetIdManager().get<lv2_lwcond_t>(lwcond_id);
const auto mutex = Emu.GetIdManager().get<lv2_lwmutex_t>(lwmutex_id);
if (!cond || (lwmutex_id && !mutex))
{
@ -122,8 +118,8 @@ s32 _sys_lwcond_signal_all(u32 lwcond_id, u32 lwmutex_id, u32 mode)
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<lwcond_t>(lwcond_id);
const auto mutex = Emu.GetIdManager().GetIDData<lwmutex_t>(lwmutex_id);
const auto cond = Emu.GetIdManager().get<lv2_lwcond_t>(lwcond_id);
const auto mutex = Emu.GetIdManager().get<lv2_lwmutex_t>(lwmutex_id);
if (!cond || (lwmutex_id && !mutex))
{
@ -169,8 +165,8 @@ s32 _sys_lwcond_queue_wait(PPUThread& CPU, u32 lwcond_id, u32 lwmutex_id, u64 ti
LV2_LOCK;
const auto cond = Emu.GetIdManager().GetIDData<lwcond_t>(lwcond_id);
const auto mutex = Emu.GetIdManager().GetIDData<lwmutex_t>(lwmutex_id);
const auto cond = Emu.GetIdManager().get<lv2_lwcond_t>(lwcond_id);
const auto mutex = Emu.GetIdManager().get<lv2_lwmutex_t>(lwmutex_id);
if (!cond || !mutex)
{

View File

@ -17,7 +17,7 @@ struct sys_lwcond_t
be_t<u32> lwcond_queue; // lwcond pseudo-id
};
struct lwcond_t
struct lv2_lwcond_t
{
const u64 name;
@ -28,7 +28,7 @@ struct lwcond_t
std::condition_variable cv;
std::unordered_set<u32> waiters;
lwcond_t(u64 name)
lv2_lwcond_t(u64 name)
: name(name)
, signaled1(0)
, signaled2(0)
@ -37,6 +37,8 @@ struct lwcond_t
}
};
REG_ID_TYPE(lv2_lwcond_t, 0x97); // SYS_LWCOND_OBJECT
// Aux
void lwcond_create(sys_lwcond_t& lwcond, sys_lwmutex_t& lwmutex, u64 name);

View File

@ -14,12 +14,10 @@ SysCallBase sys_lwmutex("sys_lwmutex");
void lwmutex_create(sys_lwmutex_t& lwmutex, bool recursive, u32 protocol, u64 name)
{
std::shared_ptr<lwmutex_t> mutex(new lwmutex_t(protocol, name));
lwmutex.lock_var = { { lwmutex::free, lwmutex::zero } };
lwmutex.attribute = protocol | (recursive ? SYS_SYNC_RECURSIVE : SYS_SYNC_NOT_RECURSIVE);
lwmutex.recursive_count = 0;
lwmutex.sleep_queue = Emu.GetIdManager().GetNewID(mutex, TYPE_LWMUTEX);
lwmutex.sleep_queue = Emu.GetIdManager().make<lv2_lwmutex_t>(protocol, name);
}
s32 _sys_lwmutex_create(vm::ptr<u32> lwmutex_id, u32 protocol, vm::ptr<sys_lwmutex_t> control, u32 arg4, u64 name, u32 arg6)
@ -39,9 +37,7 @@ s32 _sys_lwmutex_create(vm::ptr<u32> lwmutex_id, u32 protocol, vm::ptr<sys_lwmut
sys_lwmutex.Error("_sys_lwmutex_create(): unknown parameters (arg4=0x%x, arg6=0x%x)", arg4, arg6);
}
std::shared_ptr<lwmutex_t> mutex(new lwmutex_t(protocol, name));
*lwmutex_id = Emu.GetIdManager().GetNewID(mutex, TYPE_LWMUTEX);
*lwmutex_id = Emu.GetIdManager().make<lv2_lwmutex_t>(protocol, name);
return CELL_OK;
}
@ -52,7 +48,7 @@ s32 _sys_lwmutex_destroy(u32 lwmutex_id)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<lwmutex_t>(lwmutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_lwmutex_t>(lwmutex_id);
if (!mutex)
{
@ -64,7 +60,7 @@ s32 _sys_lwmutex_destroy(u32 lwmutex_id)
return CELL_EBUSY;
}
Emu.GetIdManager().RemoveID<lwmutex_t>(lwmutex_id);
Emu.GetIdManager().remove<lv2_lwmutex_t>(lwmutex_id);
return CELL_OK;
}
@ -77,7 +73,7 @@ s32 _sys_lwmutex_lock(u32 lwmutex_id, u64 timeout)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<lwmutex_t>(lwmutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_lwmutex_t>(lwmutex_id);
if (!mutex)
{
@ -117,7 +113,7 @@ s32 _sys_lwmutex_trylock(u32 lwmutex_id)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<lwmutex_t>(lwmutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_lwmutex_t>(lwmutex_id);
if (!mutex)
{
@ -140,7 +136,7 @@ s32 _sys_lwmutex_unlock(u32 lwmutex_id)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<lwmutex_t>(lwmutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_lwmutex_t>(lwmutex_id);
if (!mutex)
{

View File

@ -47,15 +47,15 @@ struct sys_lwmutex_t
union
{
atomic_t<sync_var_t> lock_var;
atomic_be_t<sync_var_t> lock_var;
struct
{
atomic_t<u32> owner;
atomic_t<u32> waiter;
atomic_be_t<u32> owner;
atomic_be_t<u32> waiter;
};
atomic_t<u64> all_info;
atomic_be_t<u64> all_info;
};
be_t<u32> attribute;
@ -64,7 +64,7 @@ struct sys_lwmutex_t
be_t<u32> pad;
};
struct lwmutex_t
struct lv2_lwmutex_t
{
const u32 protocol;
const u64 name;
@ -76,7 +76,7 @@ struct lwmutex_t
std::condition_variable cv;
std::atomic<u32> waiters;
lwmutex_t(u32 protocol, u64 name)
lv2_lwmutex_t(u32 protocol, u64 name)
: protocol(protocol)
, name(name)
, signaled(0)
@ -85,6 +85,8 @@ struct lwmutex_t
}
};
REG_ID_TYPE(lv2_lwmutex_t, 0x95); // SYS_LWMUTEX_OBJECT
// Aux
void lwmutex_create(sys_lwmutex_t& lwmutex, bool recursive, u32 protocol, u64 name);

View File

@ -45,7 +45,7 @@ s32 sys_memory_allocate_from_container(u32 size, u32 cid, u32 flags, u32 alloc_a
sys_memory.Log("sys_memory_allocate_from_container(size=0x%x, cid=0x%x, flags=0x%x)", size, cid, flags);
// Check if this container ID is valid.
const auto ct = Emu.GetIdManager().GetIDData<MemoryContainerInfo>(cid);
const auto ct = Emu.GetIdManager().get<MemoryContainerInfo>(cid);
if (!ct)
{
@ -124,11 +124,7 @@ s32 sys_memory_container_create(vm::ptr<u32> cid, u32 yield_size)
return CELL_ENOMEM;
// Wrap the allocated memory in a memory container.
std::shared_ptr<MemoryContainerInfo> ct(new MemoryContainerInfo(addr, yield_size));
u32 id = Emu.GetIdManager().GetNewID(ct, TYPE_MEM);
*cid = id;
sys_memory.Warning("*** memory_container created(addr=0x%llx): id = %d", addr, id);
*cid = Emu.GetIdManager().make<MemoryContainerInfo>(addr, yield_size);
return CELL_OK;
}
@ -138,7 +134,7 @@ s32 sys_memory_container_destroy(u32 cid)
sys_memory.Warning("sys_memory_container_destroy(cid=0x%x)", cid);
// Check if this container ID is valid.
const auto ct = Emu.GetIdManager().GetIDData<MemoryContainerInfo>(cid);
const auto ct = Emu.GetIdManager().get<MemoryContainerInfo>(cid);
if (!ct)
{
@ -147,7 +143,7 @@ s32 sys_memory_container_destroy(u32 cid)
// Release the allocated memory and remove the ID.
Memory.Free(ct->addr);
Emu.GetIdManager().RemoveID<MemoryContainerInfo>(cid);
Emu.GetIdManager().remove<MemoryContainerInfo>(cid);
return CELL_OK;
}
@ -157,7 +153,7 @@ s32 sys_memory_container_get_size(vm::ptr<sys_memory_info_t> mem_info, u32 cid)
sys_memory.Warning("sys_memory_container_get_size(mem_info_addr=0x%x, cid=0x%x)", mem_info.addr(), cid);
// Check if this container ID is valid.
const auto ct = Emu.GetIdManager().GetIDData<MemoryContainerInfo>(cid);
const auto ct = Emu.GetIdManager().get<MemoryContainerInfo>(cid);
if (!ct)
{

View File

@ -77,8 +77,7 @@ s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr<u32> mem_id)
}
// Generate a new mem ID.
std::shared_ptr<mmapper_info> info(new mmapper_info(size, flags));
*mem_id = Emu.GetIdManager().GetNewID(info, TYPE_MEM);
*mem_id = Emu.GetIdManager().make<mmapper_info>(size, flags);
return CELL_OK;
}
@ -89,7 +88,7 @@ s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm:
size, cid, flags, mem_id.addr());
// Check if this container ID is valid.
const auto ct = Emu.GetIdManager().GetIDData<MemoryContainerInfo>(cid);
const auto ct = Emu.GetIdManager().get<MemoryContainerInfo>(cid);
if (!ct)
{
@ -116,8 +115,7 @@ s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm:
ct->size = size;
// Generate a new mem ID.
std::shared_ptr<mmapper_info> info(new mmapper_info(ct->size, flags));
*mem_id = Emu.GetIdManager().GetNewID(info, TYPE_MEM);
*mem_id = Emu.GetIdManager().make<mmapper_info>(ct->size, flags);
return CELL_OK;
}
@ -145,7 +143,7 @@ s32 sys_mmapper_free_memory(u32 mem_id)
sys_mmapper.Warning("sys_mmapper_free_memory(mem_id=0x%x)", mem_id);
// Check if this mem ID is valid.
const auto info = Emu.GetIdManager().GetIDData<mmapper_info>(mem_id);
const auto info = Emu.GetIdManager().get<mmapper_info>(mem_id);
if (!info)
{
@ -153,7 +151,7 @@ s32 sys_mmapper_free_memory(u32 mem_id)
}
// Release the allocated memory and remove the ID.
Emu.GetIdManager().RemoveID<mmapper_info>(mem_id);
Emu.GetIdManager().remove<mmapper_info>(mem_id);
return CELL_OK;
}
@ -163,7 +161,7 @@ s32 sys_mmapper_map_memory(u32 start_addr, u32 mem_id, u64 flags)
sys_mmapper.Warning("sys_mmapper_map_memory(start_addr=0x%x, mem_id=0x%x, flags=0x%llx)", start_addr, mem_id, flags);
// Check if this mem ID is valid.
const auto info = Emu.GetIdManager().GetIDData<mmapper_info>(mem_id);
const auto info = Emu.GetIdManager().get<mmapper_info>(mem_id);
if (!info)
{
@ -186,7 +184,7 @@ s32 sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, u32 alloc_
start_addr, mem_id, flags, alloc_addr);
// Check if this mem ID is valid.
const auto info = Emu.GetIdManager().GetIDData<mmapper_info>(mem_id);
const auto info = Emu.GetIdManager().get<mmapper_info>(mem_id);
if (!info)
{

View File

@ -19,6 +19,8 @@ struct mmapper_info
}
};
REG_ID_TYPE(mmapper_info, 0x08); // SYS_MEM_OBJECT
// SysCalls
s32 sys_mmapper_allocate_address(u32 size, u64 flags, u32 alignment, u32 alloc_addr);
s32 sys_mmapper_allocate_fixed_address();

View File

@ -41,9 +41,7 @@ s32 sys_mutex_create(vm::ptr<u32> mutex_id, vm::ptr<sys_mutex_attribute_t> attr)
return CELL_EINVAL;
}
std::shared_ptr<mutex_t> mutex(new mutex_t(recursive, protocol, attr->name_u64));
*mutex_id = Emu.GetIdManager().GetNewID(mutex, TYPE_MUTEX);
*mutex_id = Emu.GetIdManager().make<lv2_mutex_t>(recursive, protocol, attr->name_u64);
return CELL_OK;
}
@ -54,7 +52,7 @@ s32 sys_mutex_destroy(u32 mutex_id)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<mutex_t>(mutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_mutex_t>(mutex_id);
if (!mutex)
{
@ -77,7 +75,7 @@ s32 sys_mutex_destroy(u32 mutex_id)
return CELL_EPERM;
}
Emu.GetIdManager().RemoveID<mutex_t>(mutex_id);
Emu.GetIdManager().remove<lv2_mutex_t>(mutex_id);
return CELL_OK;
}
@ -90,7 +88,7 @@ s32 sys_mutex_lock(PPUThread& CPU, u32 mutex_id, u64 timeout)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<mutex_t>(mutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_mutex_t>(mutex_id);
if (!mutex)
{
@ -148,7 +146,7 @@ s32 sys_mutex_trylock(PPUThread& CPU, u32 mutex_id)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<mutex_t>(mutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_mutex_t>(mutex_id);
if (!mutex)
{
@ -190,7 +188,7 @@ s32 sys_mutex_unlock(PPUThread& CPU, u32 mutex_id)
LV2_LOCK;
const auto mutex = Emu.GetIdManager().GetIDData<mutex_t>(mutex_id);
const auto mutex = Emu.GetIdManager().get<lv2_mutex_t>(mutex_id);
if (!mutex)
{

View File

@ -17,7 +17,7 @@ struct sys_mutex_attribute_t
};
};
struct mutex_t
struct lv2_mutex_t
{
const bool recursive;
const u32 protocol;
@ -31,7 +31,7 @@ struct mutex_t
std::condition_variable cv;
std::atomic<u32> waiters;
mutex_t(bool recursive, u32 protocol, u64 name)
lv2_mutex_t(bool recursive, u32 protocol, u64 name)
: recursive(recursive)
, protocol(protocol)
, name(name)
@ -42,6 +42,8 @@ struct mutex_t
}
};
REG_ID_TYPE(lv2_mutex_t, 0x85); // SYS_MUTEX_OBJECT
class PPUThread;
// SysCalls

View File

@ -206,81 +206,78 @@ void sys_game_process_exitspawn2(vm::ptr<const char> path, u32 argv_addr, u32 en
s32 sys_process_get_number_of_object(u32 object, vm::ptr<u32> nump)
{
sys_process.Todo("sys_process_get_number_of_object(object=%d, nump_addr=0x%x)",
object, nump.addr());
sys_process.Error("sys_process_get_number_of_object(object=0x%x, nump=*0x%x)", object, nump);
switch(object)
{
case SYS_MEM_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_MEM); break;
case SYS_MUTEX_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_MUTEX); break;
case SYS_COND_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_COND); break;
case SYS_RWLOCK_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_RWLOCK); break;
case SYS_INTR_TAG_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_INTR_TAG); break;
case SYS_INTR_SERVICE_HANDLE_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_INTR_SERVICE_HANDLE); break;
case SYS_EVENT_QUEUE_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_QUEUE); break;
case SYS_EVENT_PORT_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_PORT); break;
case SYS_TRACE_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_TRACE); break;
case SYS_SPUIMAGE_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_SPUIMAGE); break;
case SYS_PRX_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_PRX); break;
case SYS_SPUPORT_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_SPUPORT); break;
case SYS_LWMUTEX_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_LWMUTEX); break;
case SYS_TIMER_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_TIMER); break;
case SYS_SEMAPHORE_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_SEMAPHORE); break;
case SYS_LWCOND_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_LWCOND); break;
case SYS_EVENT_FLAG_OBJECT: *nump = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_FLAG); break;
case SYS_MEM_OBJECT:
case SYS_MUTEX_OBJECT:
case SYS_COND_OBJECT:
case SYS_RWLOCK_OBJECT:
case SYS_INTR_TAG_OBJECT:
case SYS_INTR_SERVICE_HANDLE_OBJECT:
case SYS_EVENT_QUEUE_OBJECT:
case SYS_EVENT_PORT_OBJECT:
case SYS_TRACE_OBJECT:
case SYS_SPUIMAGE_OBJECT:
case SYS_PRX_OBJECT:
case SYS_SPUPORT_OBJECT:
case SYS_LWMUTEX_OBJECT:
case SYS_TIMER_OBJECT:
case SYS_SEMAPHORE_OBJECT:
case SYS_FS_FD_OBJECT:
*nump = Emu.GetIdManager().GetTypeCount(TYPE_FS_FILE) + Emu.GetIdManager().GetTypeCount(TYPE_FS_DIR);
break;
default:
return CELL_EINVAL;
case SYS_LWCOND_OBJECT:
case SYS_EVENT_FLAG_OBJECT:
{
*nump = Emu.GetIdManager().get_count_by_type(object);
return CELL_OK;
}
}
return CELL_OK;
return CELL_EINVAL;
}
s32 sys_process_get_id(u32 object, vm::ptr<u32> buffer, u32 size, vm::ptr<u32> 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());
sys_process.Error("sys_process_get_id(object=0x%x, buffer=*0x%x, size=%d, set_size=*0x%x)", object, buffer, size, set_size);
switch(object)
switch (object)
{
case SYS_MEM_OBJECT:
case SYS_MUTEX_OBJECT:
case SYS_COND_OBJECT:
case SYS_RWLOCK_OBJECT:
case SYS_INTR_TAG_OBJECT:
case SYS_INTR_SERVICE_HANDLE_OBJECT:
case SYS_EVENT_QUEUE_OBJECT:
case SYS_EVENT_PORT_OBJECT:
case SYS_TRACE_OBJECT:
case SYS_SPUIMAGE_OBJECT:
case SYS_PRX_OBJECT:
case SYS_SPUPORT_OBJECT:
case SYS_LWMUTEX_OBJECT:
case SYS_TIMER_OBJECT:
case SYS_SEMAPHORE_OBJECT:
case SYS_FS_FD_OBJECT:
case SYS_LWCOND_OBJECT:
case SYS_EVENT_FLAG_OBJECT:
{
const auto objects = Emu.GetIdManager().get_IDs_by_type(object);
#define ADD_OBJECTS(type) { \
u32 i=0; \
const auto objects = Emu.GetIdManager().GetTypeIDs(type); \
for(auto id=objects.begin(); i<size && id!=objects.end(); id++, i++) \
buffer[i] = *id; \
*set_size = i; \
u32 i = 0;
for (auto id = objects.begin(); i < size && id != objects.end(); id++, i++)
{
buffer[i] = *id;
}
*set_size = i;
return CELL_OK;
}
}
case SYS_MEM_OBJECT: ADD_OBJECTS(TYPE_MEM); break;
case SYS_MUTEX_OBJECT: ADD_OBJECTS(TYPE_MUTEX); break;
case SYS_COND_OBJECT: ADD_OBJECTS(TYPE_COND); break;
case SYS_RWLOCK_OBJECT: ADD_OBJECTS(TYPE_RWLOCK); break;
case SYS_INTR_TAG_OBJECT: ADD_OBJECTS(TYPE_INTR_TAG); break;
case SYS_INTR_SERVICE_HANDLE_OBJECT: ADD_OBJECTS(TYPE_INTR_SERVICE_HANDLE); break;
case SYS_EVENT_QUEUE_OBJECT: ADD_OBJECTS(TYPE_EVENT_QUEUE); break;
case SYS_EVENT_PORT_OBJECT: ADD_OBJECTS(TYPE_EVENT_PORT); break;
case SYS_TRACE_OBJECT: ADD_OBJECTS(TYPE_TRACE); break;
case SYS_SPUIMAGE_OBJECT: ADD_OBJECTS(TYPE_SPUIMAGE); break;
case SYS_PRX_OBJECT: ADD_OBJECTS(TYPE_PRX); break;
case SYS_SPUPORT_OBJECT: ADD_OBJECTS(TYPE_SPUPORT); break;
case SYS_LWMUTEX_OBJECT: ADD_OBJECTS(TYPE_LWMUTEX); break;
case SYS_TIMER_OBJECT: ADD_OBJECTS(TYPE_TIMER); break;
case SYS_SEMAPHORE_OBJECT: ADD_OBJECTS(TYPE_SEMAPHORE); break;
case SYS_FS_FD_OBJECT: ADD_OBJECTS(TYPE_FS_FILE);/*TODO:DIR*/ break;
case SYS_LWCOND_OBJECT: ADD_OBJECTS(TYPE_LWCOND); break;
case SYS_EVENT_FLAG_OBJECT: ADD_OBJECTS(TYPE_EVENT_FLAG); break;
#undef ADD_OBJECTS
default:
return CELL_EINVAL;
}
return CELL_OK;
return CELL_EINVAL;
}
s32 process_is_spu_lock_line_reservation_address(u32 addr, u64 flags)

View File

@ -1,26 +1,26 @@
#pragma once
//Process Local Object
enum
// Process Local Object Type
enum : u32
{
SYS_MEM_OBJECT = (0x08UL),
SYS_MUTEX_OBJECT = (0x85UL),
SYS_COND_OBJECT = (0x86UL),
SYS_RWLOCK_OBJECT = (0x88UL),
SYS_INTR_TAG_OBJECT = (0x0AUL),
SYS_INTR_SERVICE_HANDLE_OBJECT = (0x0BUL),
SYS_EVENT_QUEUE_OBJECT = (0x8DUL),
SYS_EVENT_PORT_OBJECT = (0x0EUL),
SYS_TRACE_OBJECT = (0x21UL),
SYS_SPUIMAGE_OBJECT = (0x22UL),
SYS_PRX_OBJECT = (0x23UL),
SYS_SPUPORT_OBJECT = (0x24UL),
SYS_LWMUTEX_OBJECT = (0x95UL),
SYS_TIMER_OBJECT = (0x11UL),
SYS_SEMAPHORE_OBJECT = (0x96UL),
SYS_FS_FD_OBJECT = (0x73UL),
SYS_LWCOND_OBJECT = (0x97UL),
SYS_EVENT_FLAG_OBJECT = (0x98UL),
SYS_MEM_OBJECT = 0x08,
SYS_MUTEX_OBJECT = 0x85,
SYS_COND_OBJECT = 0x86,
SYS_RWLOCK_OBJECT = 0x88,
SYS_INTR_TAG_OBJECT = 0x0A,
SYS_INTR_SERVICE_HANDLE_OBJECT = 0x0B,
SYS_EVENT_QUEUE_OBJECT = 0x8D,
SYS_EVENT_PORT_OBJECT = 0x0E,
SYS_TRACE_OBJECT = 0x21,
SYS_SPUIMAGE_OBJECT = 0x22,
SYS_PRX_OBJECT = 0x23,
SYS_SPUPORT_OBJECT = 0x24,
SYS_LWMUTEX_OBJECT = 0x95,
SYS_TIMER_OBJECT = 0x11,
SYS_SEMAPHORE_OBJECT = 0x96,
SYS_FS_FD_OBJECT = 0x73,
SYS_LWCOND_OBJECT = 0x97,
SYS_EVENT_FLAG_OBJECT = 0x98,
};
// Auxiliary functions

View File

@ -32,7 +32,7 @@ s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_loa
}
// Create the PRX object and return its id
std::shared_ptr<sys_prx_t> prx(new sys_prx_t());
std::shared_ptr<lv2_prx_t> prx(new lv2_prx_t());
prx->size = (u32)f.GetSize();
prx->address = (u32)Memory.Alloc(prx->size, 4);
prx->path = (const char*)path;
@ -40,8 +40,7 @@ s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_loa
// Load the PRX into memory
f.Read(vm::get_ptr(prx->address), prx->size);
u32 id = Emu.GetIdManager().GetNewID(prx, TYPE_PRX);
return id;
return Emu.GetIdManager().add(prx);
}
s32 sys_prx_load_module_on_memcontainer()
@ -67,7 +66,7 @@ s32 sys_prx_start_module(s32 id, u32 args, u32 argp_addr, vm::ptr<u32> modres, u
sys_prx.Todo("sys_prx_start_module(id=0x%x, 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());
const auto prx = Emu.GetIdManager().GetIDData<sys_prx_t>(id);
const auto prx = Emu.GetIdManager().get<lv2_prx_t>(id);
if (!prx)
{
@ -85,7 +84,7 @@ s32 sys_prx_stop_module(s32 id, u32 args, u32 argp_addr, vm::ptr<u32> modres, u6
sys_prx.Todo("sys_prx_stop_module(id=0x%x, 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());
const auto prx = Emu.GetIdManager().GetIDData<sys_prx_t>(id);
const auto prx = Emu.GetIdManager().get<lv2_prx_t>(id);
if (!prx)
{
@ -103,7 +102,7 @@ s32 sys_prx_unload_module(s32 id, u64 flags, vm::ptr<sys_prx_unload_module_optio
sys_prx.Todo("sys_prx_unload_module(id=0x%x, flags=0x%llx, pOpt=0x%x)", id, flags, pOpt.addr());
// Get the PRX, free the used memory and delete the object and its ID
const auto prx = Emu.GetIdManager().GetIDData<sys_prx_t>(id);
const auto prx = Emu.GetIdManager().get<lv2_prx_t>(id);
if (!prx)
{
@ -111,7 +110,7 @@ s32 sys_prx_unload_module(s32 id, u64 flags, vm::ptr<sys_prx_unload_module_optio
}
Memory.Free(prx->address);
Emu.GetIdManager().RemoveID<sys_prx_t>(id);
Emu.GetIdManager().remove<lv2_prx_t>(id);
return CELL_OK;
}

View File

@ -114,19 +114,21 @@ struct sys_prx_unload_module_option_t
};
// Auxiliary data types
struct sys_prx_t
struct lv2_prx_t
{
u32 size;
u32 address;
std::string path;
bool isStarted;
sys_prx_t()
lv2_prx_t()
: isStarted(false)
{
}
};
REG_ID_TYPE(lv2_prx_t, 0x23); // SYS_PRX_OBJECT
// SysCalls
s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt);
s32 sys_prx_load_module_on_memcontainer();

View File

@ -36,9 +36,7 @@ s32 sys_rwlock_create(vm::ptr<u32> rw_lock_id, vm::ptr<sys_rwlock_attribute_t> a
return CELL_EINVAL;
}
std::shared_ptr<rwlock_t> rwlock(new rwlock_t(attr->protocol, attr->name_u64));
*rw_lock_id = Emu.GetIdManager().GetNewID(rwlock, TYPE_RWLOCK);
*rw_lock_id = Emu.GetIdManager().make<lv2_rwlock_t>(attr->protocol, attr->name_u64);
return CELL_OK;
}
@ -49,7 +47,7 @@ s32 sys_rwlock_destroy(u32 rw_lock_id)
LV2_LOCK;
const auto rwlock = Emu.GetIdManager().GetIDData<rwlock_t>(rw_lock_id);
const auto rwlock = Emu.GetIdManager().get<lv2_rwlock_t>(rw_lock_id);
if (!rwlock)
{
@ -61,7 +59,7 @@ s32 sys_rwlock_destroy(u32 rw_lock_id)
return CELL_EBUSY;
}
Emu.GetIdManager().RemoveID<rwlock_t>(rw_lock_id);
Emu.GetIdManager().remove<lv2_rwlock_t>(rw_lock_id);
return CELL_OK;
}
@ -74,7 +72,7 @@ s32 sys_rwlock_rlock(u32 rw_lock_id, u64 timeout)
LV2_LOCK;
const auto rwlock = Emu.GetIdManager().GetIDData<rwlock_t>(rw_lock_id);
const auto rwlock = Emu.GetIdManager().get<lv2_rwlock_t>(rw_lock_id);
if (!rwlock)
{
@ -113,7 +111,7 @@ s32 sys_rwlock_tryrlock(u32 rw_lock_id)
LV2_LOCK;
const auto rwlock = Emu.GetIdManager().GetIDData<rwlock_t>(rw_lock_id);
const auto rwlock = Emu.GetIdManager().get<lv2_rwlock_t>(rw_lock_id);
if (!rwlock)
{
@ -136,7 +134,7 @@ s32 sys_rwlock_runlock(u32 rw_lock_id)
LV2_LOCK;
const auto rwlock = Emu.GetIdManager().GetIDData<rwlock_t>(rw_lock_id);
const auto rwlock = Emu.GetIdManager().get<lv2_rwlock_t>(rw_lock_id);
if (!rwlock)
{
@ -164,7 +162,7 @@ s32 sys_rwlock_wlock(PPUThread& CPU, u32 rw_lock_id, u64 timeout)
LV2_LOCK;
const auto rwlock = Emu.GetIdManager().GetIDData<rwlock_t>(rw_lock_id);
const auto rwlock = Emu.GetIdManager().get<lv2_rwlock_t>(rw_lock_id);
if (!rwlock)
{
@ -208,7 +206,7 @@ s32 sys_rwlock_trywlock(PPUThread& CPU, u32 rw_lock_id)
LV2_LOCK;
const auto rwlock = Emu.GetIdManager().GetIDData<rwlock_t>(rw_lock_id);
const auto rwlock = Emu.GetIdManager().get<lv2_rwlock_t>(rw_lock_id);
if (!rwlock)
{
@ -236,7 +234,7 @@ s32 sys_rwlock_wunlock(PPUThread& CPU, u32 rw_lock_id)
LV2_LOCK;
const auto rwlock = Emu.GetIdManager().GetIDData<rwlock_t>(rw_lock_id);
const auto rwlock = Emu.GetIdManager().get<lv2_rwlock_t>(rw_lock_id);
if (!rwlock)
{

View File

@ -15,7 +15,7 @@ struct sys_rwlock_attribute_t
};
};
struct rwlock_t
struct lv2_rwlock_t
{
const u32 protocol;
const u64 name;
@ -29,7 +29,7 @@ struct rwlock_t
std::atomic<u32> rwaiters;
std::atomic<u32> wwaiters;
rwlock_t(u32 protocol, u64 name)
lv2_rwlock_t(u32 protocol, u64 name)
: protocol(protocol)
, name(name)
, readers(0)
@ -40,6 +40,8 @@ struct rwlock_t
}
};
REG_ID_TYPE(lv2_rwlock_t, 0x88); // SYS_RWLOCK_OBJECT
// SysCalls
s32 sys_rwlock_create(vm::ptr<u32> rw_lock_id, vm::ptr<sys_rwlock_attribute_t> attr);
s32 sys_rwlock_destroy(u32 rw_lock_id);

View File

@ -12,13 +12,6 @@
SysCallBase sys_semaphore("sys_semaphore");
u32 semaphore_create(s32 initial_val, s32 max_val, u32 protocol, u64 name_u64)
{
std::shared_ptr<semaphore_t> sem(new semaphore_t(protocol, max_val, name_u64, initial_val));
return Emu.GetIdManager().GetNewID(sem, TYPE_SEMAPHORE);
}
s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val)
{
sys_semaphore.Warning("sys_semaphore_create(sem=*0x%x, attr=*0x%x, initial_val=%d, max_val=%d)", sem, attr, initial_val, max_val);
@ -50,7 +43,7 @@ s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute_t> at
return CELL_EINVAL;
}
*sem = semaphore_create(initial_val, max_val, protocol, attr->name_u64);
*sem = Emu.GetIdManager().make<lv2_sema_t>(initial_val, max_val, protocol, attr->name_u64);
return CELL_OK;
}
@ -61,7 +54,7 @@ s32 sys_semaphore_destroy(u32 sem)
LV2_LOCK;
const auto semaphore = Emu.GetIdManager().GetIDData<semaphore_t>(sem);
const auto semaphore = Emu.GetIdManager().get<lv2_sema_t>(sem);
if (!semaphore)
{
@ -73,7 +66,7 @@ s32 sys_semaphore_destroy(u32 sem)
return CELL_EBUSY;
}
Emu.GetIdManager().RemoveID<semaphore_t>(sem);
Emu.GetIdManager().remove<lv2_sema_t>(sem);
return CELL_OK;
}
@ -86,7 +79,7 @@ s32 sys_semaphore_wait(u32 sem, u64 timeout)
LV2_LOCK;
const auto semaphore = Emu.GetIdManager().GetIDData<semaphore_t>(sem);
const auto semaphore = Emu.GetIdManager().get<lv2_sema_t>(sem);
if (!semaphore)
{
@ -125,7 +118,7 @@ s32 sys_semaphore_trywait(u32 sem)
LV2_LOCK;
const auto semaphore = Emu.GetIdManager().GetIDData<semaphore_t>(sem);
const auto semaphore = Emu.GetIdManager().get<lv2_sema_t>(sem);
if (!semaphore)
{
@ -148,7 +141,7 @@ s32 sys_semaphore_post(u32 sem, s32 count)
LV2_LOCK;
const auto semaphore = Emu.GetIdManager().GetIDData<semaphore_t>(sem);
const auto semaphore = Emu.GetIdManager().get<lv2_sema_t>(sem);
if (!semaphore)
{
@ -189,7 +182,7 @@ s32 sys_semaphore_get_value(u32 sem, vm::ptr<s32> count)
LV2_LOCK;
const auto semaphore = Emu.GetIdManager().GetIDData<semaphore_t>(sem);
const auto semaphore = Emu.GetIdManager().get<lv2_sema_t>(sem);
if (!semaphore)
{

View File

@ -15,7 +15,7 @@ struct sys_semaphore_attribute_t
};
};
struct semaphore_t
struct lv2_sema_t
{
const u32 protocol;
const s32 max;
@ -27,7 +27,7 @@ struct semaphore_t
std::condition_variable cv;
std::atomic<u32> waiters;
semaphore_t(u32 protocol, s32 max, u64 name, s32 value)
lv2_sema_t(u32 protocol, s32 max, u64 name, s32 value)
: protocol(protocol)
, max(max)
, name(name)
@ -37,8 +37,7 @@ struct semaphore_t
}
};
// Aux
u32 semaphore_create(s32 initial_val, s32 max_val, u32 protocol, u64 name_u64);
REG_ID_TYPE(lv2_sema_t, 0x96); // SYS_SEMAPHORE_OBJECT
// SysCalls
s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val);

View File

@ -108,7 +108,7 @@ u32 spu_thread_initialize(u32 group_id, u32 spu_num, vm::ptr<sys_spu_image> img,
spu.SetName(name);
spu.m_custom_task = task;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(group_id);
const auto group = Emu.GetIdManager().get<spu_group_t>(group_id);
spu.tg = group;
group->threads[spu_num] = t;
@ -140,7 +140,7 @@ s32 sys_spu_thread_initialize(vm::ptr<u32> thread, u32 group_id, u32 spu_num, vm
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(group_id);
const auto group = Emu.GetIdManager().get<spu_group_t>(group_id);
if (!group)
{
@ -221,9 +221,7 @@ u32 spu_thread_group_create(const std::string& name, u32 num, s32 prio, s32 type
sys_spu.Todo("Unsupported SPU Thread Group type (0x%x)", type);
}
std::shared_ptr<spu_group_t> group(new spu_group_t(name, num, prio, type, container));
return Emu.GetIdManager().GetNewID(group);
return Emu.GetIdManager().make<spu_group_t>(name, num, prio, type, container);
}
s32 sys_spu_thread_group_create(vm::ptr<u32> id, u32 num, s32 prio, vm::ptr<sys_spu_thread_group_attribute> attr)
@ -247,7 +245,7 @@ s32 sys_spu_thread_group_destroy(u32 id)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{
@ -274,7 +272,7 @@ s32 sys_spu_thread_group_destroy(u32 id)
}
group->state = SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED; // hack
Emu.GetIdManager().RemoveID<spu_group_t>(id);
Emu.GetIdManager().remove<spu_group_t>(id);
return CELL_OK;
}
@ -285,7 +283,7 @@ s32 sys_spu_thread_group_start(u32 id)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{
@ -348,7 +346,7 @@ s32 sys_spu_thread_group_suspend(u32 id)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{
@ -403,7 +401,7 @@ s32 sys_spu_thread_group_resume(u32 id)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{
@ -450,7 +448,7 @@ s32 sys_spu_thread_group_yield(u32 id)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{
@ -475,7 +473,7 @@ s32 sys_spu_thread_group_terminate(u32 id, s32 value)
// seems the id can be either SPU Thread Group or SPU Thread
auto thread = Emu.GetCPU().GetThread(id, CPU_THREAD_SPU);
auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group && !thread)
{
@ -540,7 +538,7 @@ s32 sys_spu_thread_group_join(u32 id, vm::ptr<u32> cause, vm::ptr<u32> status)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{
@ -778,8 +776,8 @@ s32 sys_spu_thread_group_connect_event(u32 id, u32 eq, u32 et)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(eq);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(eq);
if (!group || !queue)
{
@ -834,7 +832,7 @@ s32 sys_spu_thread_group_disconnect_event(u32 id, u32 et)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{
@ -898,7 +896,7 @@ s32 sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup)
LV2_LOCK;
const auto t = Emu.GetCPU().GetThread(id, CPU_THREAD_SPU);
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(eq);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(eq);
if (!t || !queue)
{
@ -965,7 +963,7 @@ s32 sys_spu_thread_bind_queue(u32 id, u32 spuq, u32 spuq_num)
LV2_LOCK;
const auto t = Emu.GetCPU().GetThread(id, CPU_THREAD_SPU);
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(spuq);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(spuq);
if (!t || !queue)
{
@ -1038,8 +1036,8 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq, u64 req, vm::
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(eq);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(eq);
if (!group || !queue)
{
@ -1113,7 +1111,7 @@ s32 sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup)
LV2_LOCK;
const auto group = Emu.GetIdManager().GetIDData<spu_group_t>(id);
const auto group = Emu.GetIdManager().get<spu_group_t>(id);
if (!group)
{

View File

@ -157,9 +157,9 @@ struct spu_group_t
std::atomic<u32> join_state; // flags used to detect exit cause
std::condition_variable join_cv; // used to signal waiting PPU thread
std::weak_ptr<event_queue_t> ep_run; // port for SYS_SPU_THREAD_GROUP_EVENT_RUN events
std::weak_ptr<event_queue_t> ep_exception; // TODO: SYS_SPU_THREAD_GROUP_EVENT_EXCEPTION
std::weak_ptr<event_queue_t> ep_sysmodule; // TODO: SYS_SPU_THREAD_GROUP_EVENT_SYSTEM_MODULE
std::weak_ptr<lv2_event_queue_t> ep_run; // port for SYS_SPU_THREAD_GROUP_EVENT_RUN events
std::weak_ptr<lv2_event_queue_t> ep_exception; // TODO: SYS_SPU_THREAD_GROUP_EVENT_EXCEPTION
std::weak_ptr<lv2_event_queue_t> ep_sysmodule; // TODO: SYS_SPU_THREAD_GROUP_EVENT_SYSTEM_MODULE
spu_group_t(std::string name, u32 num, s32 prio, s32 type, u32 ct)
: name(name)

View File

@ -18,7 +18,7 @@ s32 sys_timer_create(vm::ptr<u32> timer_id)
std::shared_ptr<lv2_timer_t> timer(new lv2_timer_t);
thread_t(fmt::format("Timer[0x%x] Thread", (*timer_id = Emu.GetIdManager().GetNewID(timer, TYPE_TIMER))), [timer]()
thread_t(fmt::format("Timer[0x%x] Thread", (*timer_id = Emu.GetIdManager().add(timer))), [timer]() // TODO: call from the constructor
{
LV2_LOCK;
@ -62,7 +62,7 @@ s32 sys_timer_destroy(u32 timer_id)
LV2_LOCK;
const auto timer = Emu.GetIdManager().GetIDData<lv2_timer_t>(timer_id);
const auto timer = Emu.GetIdManager().get<lv2_timer_t>(timer_id);
if (!timer)
{
@ -74,7 +74,7 @@ s32 sys_timer_destroy(u32 timer_id)
return CELL_EISCONN;
}
Emu.GetIdManager().RemoveID<lv2_timer_t>(timer_id);
Emu.GetIdManager().remove<lv2_timer_t>(timer_id);
return CELL_OK;
}
@ -85,7 +85,7 @@ s32 sys_timer_get_information(u32 timer_id, vm::ptr<sys_timer_information_t> inf
LV2_LOCK;
const auto timer = Emu.GetIdManager().GetIDData<lv2_timer_t>(timer_id);
const auto timer = Emu.GetIdManager().get<lv2_timer_t>(timer_id);
if (!timer)
{
@ -108,7 +108,7 @@ s32 _sys_timer_start(u32 timer_id, u64 base_time, u64 period)
LV2_LOCK;
const auto timer = Emu.GetIdManager().GetIDData<lv2_timer_t>(timer_id);
const auto timer = Emu.GetIdManager().get<lv2_timer_t>(timer_id);
if (!timer)
{
@ -160,7 +160,7 @@ s32 sys_timer_stop(u32 timer_id)
LV2_LOCK;
const auto timer = Emu.GetIdManager().GetIDData<lv2_timer_t>(timer_id);
const auto timer = Emu.GetIdManager().get<lv2_timer_t>(timer_id);
if (!timer)
{
@ -178,8 +178,8 @@ s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data
LV2_LOCK;
const auto timer = Emu.GetIdManager().GetIDData<lv2_timer_t>(timer_id);
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(queue_id);
const auto timer = Emu.GetIdManager().get<lv2_timer_t>(timer_id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(queue_id);
if (!timer || !queue)
{
@ -205,7 +205,7 @@ s32 sys_timer_disconnect_event_queue(u32 timer_id)
LV2_LOCK;
const auto timer = Emu.GetIdManager().GetIDData<lv2_timer_t>(timer_id);
const auto timer = Emu.GetIdManager().get<lv2_timer_t>(timer_id);
if (!timer)
{

View File

@ -18,7 +18,7 @@ struct sys_timer_information_t
// "timer_t" conflicts with some definition
struct lv2_timer_t
{
std::weak_ptr<event_queue_t> port; // event queue
std::weak_ptr<lv2_event_queue_t> port; // event queue
u64 source; // event source
u64 data1; // event arg 1
u64 data2; // event arg 2
@ -37,6 +37,8 @@ struct lv2_timer_t
}
};
REG_ID_TYPE(lv2_timer_t, 0x11); // SYS_TIMER_OBJECT
s32 sys_timer_create(vm::ptr<u32> timer_id);
s32 sys_timer_destroy(u32 timer_id);
s32 sys_timer_get_information(u32 timer_id, vm::ptr<sys_timer_information_t> info);

View File

@ -39,7 +39,7 @@ s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 a
else
{
// Check memory container.
const auto ct = Emu.GetIdManager().GetIDData<MemoryContainerInfo>(cid);
const auto ct = Emu.GetIdManager().get<MemoryContainerInfo>(cid);
if (!ct)
{

View File

@ -49,7 +49,7 @@ Emulator::Emulator()
, m_pad_manager(new PadManager())
, m_keyboard_manager(new KeyboardManager())
, m_mouse_manager(new MouseManager())
, m_id_manager(new IdManager())
, m_id_manager(new ID_manager())
, m_gs_manager(new GSManager())
, m_audio_manager(new AudioManager())
, m_callback_manager(new CallbackManager())
@ -326,7 +326,7 @@ void Emulator::Pause()
if (!IsRunning()) return;
SendDbgCommand(DID_PAUSE_EMU);
if (InterlockedCompareExchange((volatile u32*)&m_status, Paused, Running) == Running)
if (__sync_bool_compare_and_swap((volatile u32*)&m_status, Running, Paused))
{
SendDbgCommand(DID_PAUSED_EMU);
@ -396,7 +396,7 @@ void Emulator::Stop()
GetAudioManager().Close();
GetEventManager().Clear();
GetCPU().Close();
GetIdManager().Clear();
GetIdManager().clear();
GetPadManager().Close();
GetKeyboardManager().Close();
GetMouseManager().Close();

View File

@ -14,7 +14,7 @@ class CPUThreadManager;
class PadManager;
class KeyboardManager;
class MouseManager;
class IdManager;
class ID_manager;
class GSManager;
class AudioManager;
class CallbackManager;
@ -84,7 +84,7 @@ class Emulator
PadManager* m_pad_manager;
KeyboardManager* m_keyboard_manager;
MouseManager* m_mouse_manager;
IdManager* m_id_manager;
ID_manager* m_id_manager;
GSManager* m_gs_manager;
AudioManager* m_audio_manager;
CallbackManager* m_callback_manager;
@ -141,7 +141,7 @@ public:
PadManager& GetPadManager() { return *m_pad_manager; }
KeyboardManager& GetKeyboardManager() { return *m_keyboard_manager; }
MouseManager& GetMouseManager() { return *m_mouse_manager; }
IdManager& GetIdManager() { return *m_id_manager; }
ID_manager& GetIdManager() { return *m_id_manager; }
GSManager& GetGSManager() { return *m_gs_manager; }
AudioManager& GetAudioManager() { return *m_audio_manager; }
CallbackManager& GetCallbackManager() { return *m_callback_manager; }

View File

@ -13,6 +13,7 @@
#include "Emu/SysCalls/lv2/sys_cond.h"
#include "Emu/SysCalls/lv2/sys_semaphore.h"
#include "Emu/SysCalls/lv2/sys_event.h"
#include "Emu/SysCalls/lv2/sys_process.h"
#include "KernelExplorer.h"
@ -50,7 +51,6 @@ KernelExplorer::KernelExplorer(wxWindow* parent)
void KernelExplorer::Update()
{
int count;
char name[4096];
m_tree->DeleteAllItems();
@ -77,112 +77,104 @@ void KernelExplorer::Update()
// TODO: FileSystem
// Semaphores
count = Emu.GetIdManager().GetTypeCount(TYPE_SEMAPHORE);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_SEMAPHORE_OBJECT))
{
sprintf(name, "Semaphores (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().GetTypeIDs(TYPE_SEMAPHORE))
for (const auto id : Emu.GetIdManager().get_IDs_by_type(SYS_SEMAPHORE_OBJECT))
{
const auto sem = Emu.GetIdManager().GetIDData<semaphore_t>(id);
const auto sem = Emu.GetIdManager().get<lv2_sema_t>(id);
sprintf(name, "Semaphore: ID = 0x%x '%s', Count = %d, Max Count = %d, Waiters = %d", id, &name64(sem->name), sem->value.load(), sem->max, sem->waiters.load());
m_tree->AppendItem(node, name);
}
}
// Mutexes
count = Emu.GetIdManager().GetTypeCount(TYPE_MUTEX);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_MUTEX_OBJECT))
{
sprintf(name, "Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().GetTypeIDs(TYPE_MUTEX))
for (const auto id : Emu.GetIdManager().get_IDs_by_type(SYS_MUTEX_OBJECT))
{
const auto mutex = Emu.GetIdManager().GetIDData<mutex_t>(id);
const auto mutex = Emu.GetIdManager().get<lv2_mutex_t>(id);
sprintf(name, "Mutex: ID = 0x%x '%s'", id, &name64(mutex->name));
m_tree->AppendItem(node, name);
}
}
// Light Weight Mutexes
count = Emu.GetIdManager().GetTypeCount(TYPE_LWMUTEX);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_LWMUTEX_OBJECT))
{
sprintf(name, "Lightweight Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().GetTypeIDs(TYPE_LWMUTEX))
for (const auto id : Emu.GetIdManager().get_IDs_by_type(SYS_LWMUTEX_OBJECT))
{
const auto lwm = Emu.GetIdManager().GetIDData<lwmutex_t>(id);
const auto lwm = Emu.GetIdManager().get<lv2_lwmutex_t>(id);
sprintf(name, "Lightweight Mutex: ID = 0x%x '%s'", id, &name64(lwm->name));
m_tree->AppendItem(node, name);
}
}
// Condition Variables
count = Emu.GetIdManager().GetTypeCount(TYPE_COND);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_COND_OBJECT))
{
sprintf(name, "Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().GetTypeIDs(TYPE_COND))
for (const auto id : Emu.GetIdManager().get_IDs_by_type(SYS_COND_OBJECT))
{
const auto cond = Emu.GetIdManager().GetIDData<cond_t>(id);
const auto cond = Emu.GetIdManager().get<lv2_cond_t>(id);
sprintf(name, "Condition Variable: ID = 0x%x '%s'", id, &name64(cond->name));
m_tree->AppendItem(node, name);
}
}
// Light Weight Condition Variables
count = Emu.GetIdManager().GetTypeCount(TYPE_LWCOND);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_LWCOND_OBJECT))
{
sprintf(name, "Lightweight Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().GetTypeIDs(TYPE_LWCOND))
for (const auto id : Emu.GetIdManager().get_IDs_by_type(SYS_LWCOND_OBJECT))
{
const auto lwc = Emu.GetIdManager().GetIDData<lwcond_t>(id);
const auto lwc = Emu.GetIdManager().get<lv2_lwcond_t>(id);
sprintf(name, "Lightweight Condition Variable: ID = 0x%x '%s'", id, &name64(lwc->name));
m_tree->AppendItem(node, name);
}
}
// Event Queues
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_QUEUE);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_EVENT_QUEUE_OBJECT))
{
sprintf(name, "Event Queues (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_QUEUE))
for (const auto id : Emu.GetIdManager().get_IDs_by_type(SYS_EVENT_QUEUE_OBJECT))
{
const auto queue = Emu.GetIdManager().GetIDData<event_queue_t>(id);
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(id);
sprintf(name, "Event Queue: ID = 0x%x '%s', Key = %#llx", id, &name64(queue->name), queue->key);
m_tree->AppendItem(node, name);
}
}
// Event Ports
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_PORT);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_EVENT_PORT_OBJECT))
{
sprintf(name, "Event Ports (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_PORT))
for (const auto id : Emu.GetIdManager().get_IDs_by_type(SYS_EVENT_PORT_OBJECT))
{
const auto port = Emu.GetIdManager().GetIDData<event_port_t>(id);
const auto port = Emu.GetIdManager().get<lv2_event_port_t>(id);
sprintf(name, "Event Port: ID = 0x%x, Name = %#llx", id, port->name);
m_tree->AppendItem(node, name);
}
}
// Modules
count = Emu.GetIdManager().GetTypeCount(TYPE_PRX);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_PRX_OBJECT))
{
sprintf(name, "Modules (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
//sprintf(name, "Segment List (%l)", 2 * objects.size()); // TODO: Assuming 2 segments per PRX file is not good
//m_tree->AppendItem(node, name);
for (const auto& id : Emu.GetIdManager().GetTypeIDs(TYPE_PRX))
for (const auto& id : Emu.GetIdManager().get_IDs_by_type(SYS_PRX_OBJECT))
{
sprintf(name, "PRX: ID = 0x%x", id);
m_tree->AppendItem(node, name);
@ -190,12 +182,11 @@ void KernelExplorer::Update()
}
// Memory Containers
count = Emu.GetIdManager().GetTypeCount(TYPE_MEM);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_MEM_OBJECT))
{
sprintf(name, "Memory Containers (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto& id : Emu.GetIdManager().GetTypeIDs(TYPE_MEM))
for (const auto& id : Emu.GetIdManager().get_IDs_by_type(SYS_MEM_OBJECT))
{
sprintf(name, "Memory Container: ID = 0x%x", id);
m_tree->AppendItem(node, name);
@ -203,12 +194,11 @@ void KernelExplorer::Update()
}
// Event Flags
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_FLAG);
if (count)
if (u32 count = Emu.GetIdManager().get_count_by_type(SYS_EVENT_FLAG_OBJECT))
{
sprintf(name, "Event Flags (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto& id : Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_FLAG))
for (const auto& id : Emu.GetIdManager().get_IDs_by_type(SYS_EVENT_FLAG_OBJECT))
{
sprintf(name, "Event Flag: ID = 0x%x", id);
m_tree->AppendItem(node, name);

View File

@ -62,5 +62,9 @@ template<typename T> __forceinline T align(const T addr, int align)
#include "Emu/Memory/atomic.h"
template<typename T> struct ID_type;
#define REG_ID_TYPE(t, id) template<> struct ID_type<t> { static const u32 type = id; }
#define _PRGNAME_ "RPCS3"
#define _PRGVER_ "0.0.0.5"