mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
std::shared_ptr in IdManager
This commit is contained in:
parent
b2de24db73
commit
d8239a39c9
47 changed files with 654 additions and 622 deletions
|
@ -121,7 +121,7 @@ s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr<const void> pAr
|
|||
{
|
||||
sceLibKernel.Error("sceKernelStartThread(threadId=%d, argSize=%d, pArgBlock_addr=0x%x)", threadId, argSize, pArgBlock.addr());
|
||||
|
||||
CPUThread* t = Emu.GetCPU().GetThread(threadId);
|
||||
std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(threadId);
|
||||
|
||||
if (!t || t->GetType() != CPU_THREAD_ARMv7)
|
||||
{
|
||||
|
@ -129,12 +129,12 @@ s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr<const void> pAr
|
|||
}
|
||||
|
||||
// push arg block onto the stack
|
||||
u32 pos = (static_cast<ARMv7Thread*>(t)->SP -= argSize);
|
||||
u32 pos = (static_cast<ARMv7Thread*>(t.get())->SP -= argSize);
|
||||
memcpy(vm::get_ptr<void>(pos), pArgBlock.get_ptr(), argSize);
|
||||
|
||||
// set SceKernelThreadEntry function arguments
|
||||
static_cast<ARMv7Thread*>(t)->write_gpr(0, argSize);
|
||||
static_cast<ARMv7Thread*>(t)->write_gpr(1, pos);
|
||||
static_cast<ARMv7Thread*>(t.get())->write_gpr(0, argSize);
|
||||
static_cast<ARMv7Thread*>(t.get())->write_gpr(1, pos);
|
||||
|
||||
t->Exec();
|
||||
return SCE_OK;
|
||||
|
|
|
@ -28,28 +28,28 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type)
|
|||
{
|
||||
std::lock_guard<std::mutex> lock(m_mtx_thread);
|
||||
|
||||
CPUThread* new_thread;
|
||||
std::shared_ptr<CPUThread> new_thread;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case CPU_THREAD_PPU:
|
||||
{
|
||||
new_thread = new PPUThread();
|
||||
new_thread.reset(new PPUThread());
|
||||
break;
|
||||
}
|
||||
case CPU_THREAD_SPU:
|
||||
{
|
||||
new_thread = new SPUThread();
|
||||
new_thread.reset(new SPUThread());
|
||||
break;
|
||||
}
|
||||
case CPU_THREAD_RAW_SPU:
|
||||
{
|
||||
new_thread = new RawSPUThread();
|
||||
new_thread.reset(new RawSPUThread());
|
||||
break;
|
||||
}
|
||||
case CPU_THREAD_ARMv7:
|
||||
{
|
||||
new_thread = new ARMv7Thread();
|
||||
new_thread.reset(new ARMv7Thread());
|
||||
break;
|
||||
}
|
||||
default: assert(0);
|
||||
|
@ -58,7 +58,7 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type)
|
|||
new_thread->SetId(Emu.GetIdManager().GetNewID(fmt::Format("%s Thread", new_thread->GetTypeString().c_str()), new_thread));
|
||||
|
||||
m_threads.push_back(new_thread);
|
||||
SendDbgCommand(DID_CREATE_THREAD, new_thread);
|
||||
SendDbgCommand(DID_CREATE_THREAD, new_thread.get());
|
||||
|
||||
return *new_thread;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ void CPUThreadManager::RemoveThread(const u32 id)
|
|||
{
|
||||
std::lock_guard<std::mutex> lock(m_mtx_thread);
|
||||
|
||||
CPUThread* thr = nullptr;
|
||||
std::shared_ptr<CPUThread> thr;
|
||||
u32 thread_index = 0;
|
||||
|
||||
for (u32 i = 0; i < m_threads.size(); ++i)
|
||||
|
@ -80,7 +80,7 @@ void CPUThreadManager::RemoveThread(const u32 id)
|
|||
|
||||
if (thr)
|
||||
{
|
||||
SendDbgCommand(DID_REMOVE_THREAD, thr);
|
||||
SendDbgCommand(DID_REMOVE_THREAD, thr.get());
|
||||
thr->Close();
|
||||
|
||||
m_threads.erase(m_threads.begin() + thread_index);
|
||||
|
@ -106,9 +106,9 @@ s32 CPUThreadManager::GetThreadNumById(CPUThreadType type, u32 id)
|
|||
return -1;
|
||||
}
|
||||
|
||||
CPUThread* CPUThreadManager::GetThread(u32 id)
|
||||
std::shared_ptr<CPUThread> CPUThreadManager::GetThread(u32 id)
|
||||
{
|
||||
CPUThread* res;
|
||||
std::shared_ptr<CPUThread> res;
|
||||
|
||||
if (!id) return nullptr;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ enum CPUThreadType : unsigned char;
|
|||
|
||||
class CPUThreadManager
|
||||
{
|
||||
std::vector<CPUThread*> m_threads;
|
||||
std::vector<std::shared_ptr<CPUThread>> m_threads;
|
||||
std::mutex m_mtx_thread;
|
||||
|
||||
public:
|
||||
|
@ -18,9 +18,9 @@ public:
|
|||
CPUThread& AddThread(CPUThreadType type);
|
||||
void RemoveThread(const u32 id);
|
||||
|
||||
std::vector<CPUThread*>& GetThreads() { return m_threads; }
|
||||
//std::vector<std::shared_ptr<CPUThread>>& GetThreads() { return m_threads; }
|
||||
s32 GetThreadNumById(CPUThreadType type, u32 id);
|
||||
CPUThread* GetThread(u32 id);
|
||||
std::shared_ptr<CPUThread> GetThread(u32 id);
|
||||
RawSPUThread* GetRawSPUThread(u32 num);
|
||||
|
||||
void Exec();
|
||||
|
|
|
@ -39,6 +39,10 @@ SPUThread::SPUThread(CPUThreadType type) : PPCThread(type)
|
|||
assert(type == CPU_THREAD_SPU || type == CPU_THREAD_RAW_SPU);
|
||||
|
||||
group = nullptr;
|
||||
for (auto& p : SPUPs)
|
||||
{
|
||||
p.reset(new EventPort());
|
||||
}
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
@ -138,12 +142,12 @@ void SPUThread::DoClose()
|
|||
}
|
||||
for (u32 i = 0; i < 64; i++)
|
||||
{
|
||||
EventPort& port = SPUPs[i];
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
if (port.eq)
|
||||
std::shared_ptr<EventPort> port = SPUPs[i];
|
||||
std::lock_guard<std::mutex> lock(port->m_mutex);
|
||||
if (port->eq)
|
||||
{
|
||||
port.eq->ports.remove(&port);
|
||||
port.eq = nullptr;
|
||||
port->eq->ports.remove(port);
|
||||
port->eq = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,17 +214,17 @@ void SPUThread::ProcessCmd(u32 cmd, u32 tag, u32 lsa, u64 ea, u32 size)
|
|||
return;
|
||||
}
|
||||
|
||||
SPUThread* spu = (SPUThread*)Emu.GetCPU().GetThread(group->list[num]);
|
||||
std::shared_ptr<CPUThread> spu = Emu.GetCPU().GetThread(group->list[num]);
|
||||
|
||||
u32 addr = (ea & SYS_SPU_THREAD_BASE_MASK) % SYS_SPU_THREAD_OFFSET;
|
||||
if ((addr <= 0x3ffff) && (addr + size <= 0x40000))
|
||||
{
|
||||
// LS access
|
||||
ea = spu->ls_offset + addr;
|
||||
ea = ((SPUThread*)spu.get())->ls_offset + addr;
|
||||
}
|
||||
else if ((cmd & MFC_PUT_CMD) && size == 4 && (addr == SYS_SPU_THREAD_SNR1 || addr == SYS_SPU_THREAD_SNR2))
|
||||
{
|
||||
spu->WriteSNR(SYS_SPU_THREAD_SNR2 == addr, vm::read32(ls_offset + lsa));
|
||||
((SPUThread*)spu.get())->WriteSNR(SYS_SPU_THREAD_SNR2 == addr, vm::read32(ls_offset + lsa));
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -597,7 +601,7 @@ void SPUThread::WriteChannel(u32 ch, const u128& r)
|
|||
}
|
||||
}
|
||||
m_intrtag[2].stat |= 1;
|
||||
if (CPUThread* t = Emu.GetCPU().GetThread(m_intrtag[2].thread))
|
||||
if (std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(m_intrtag[2].thread))
|
||||
{
|
||||
if (t->GetType() == CPU_THREAD_PPU)
|
||||
{
|
||||
|
@ -607,7 +611,7 @@ void SPUThread::WriteChannel(u32 ch, const u128& r)
|
|||
Emu.Pause();
|
||||
return;
|
||||
}
|
||||
PPUThread& ppu = *(PPUThread*)t;
|
||||
PPUThread& ppu = *(PPUThread*)t.get();
|
||||
ppu.GPR[3] = ppu.m_interrupt_arg;
|
||||
ppu.FastCall2(vm::read32(ppu.entry), vm::read32(ppu.entry + 4));
|
||||
}
|
||||
|
@ -634,18 +638,18 @@ void SPUThread::WriteChannel(u32 ch, const u128& r)
|
|||
LOG_NOTICE(Log::SPU, "sys_spu_thread_send_event(spup=%d, data0=0x%x, data1=0x%x)", spup, v & 0x00ffffff, data);
|
||||
}
|
||||
|
||||
EventPort& port = SPUPs[spup];
|
||||
std::shared_ptr<EventPort> port = SPUPs[spup];
|
||||
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
std::lock_guard<std::mutex> lock(port->m_mutex);
|
||||
|
||||
if (!port.eq)
|
||||
if (!port->eq)
|
||||
{
|
||||
LOG_WARNING(Log::SPU, "sys_spu_thread_send_event(spup=%d, data0=0x%x, data1=0x%x): event queue not connected", spup, (v & 0x00ffffff), data);
|
||||
SPU.In_MBox.PushUncond(CELL_ENOTCONN); // TODO: check error passing
|
||||
return;
|
||||
}
|
||||
|
||||
if (!port.eq->events.push(SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (v & 0x00ffffff), data))
|
||||
if (!port->eq->events.push(SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (v & 0x00ffffff), data))
|
||||
{
|
||||
SPU.In_MBox.PushUncond(CELL_EBUSY);
|
||||
return;
|
||||
|
@ -672,18 +676,18 @@ void SPUThread::WriteChannel(u32 ch, const u128& r)
|
|||
LOG_WARNING(Log::SPU, "sys_spu_thread_throw_event(spup=%d, data0=0x%x, data1=0x%x)", spup, v & 0x00ffffff, data);
|
||||
}
|
||||
|
||||
EventPort& port = SPUPs[spup];
|
||||
std::shared_ptr<EventPort> port = SPUPs[spup];
|
||||
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
std::lock_guard<std::mutex> lock(port->m_mutex);
|
||||
|
||||
if (!port.eq)
|
||||
if (!port->eq)
|
||||
{
|
||||
LOG_WARNING(Log::SPU, "sys_spu_thread_throw_event(spup=%d, data0=0x%x, data1=0x%x): event queue not connected", spup, (v & 0x00ffffff), data);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: check passing spup value
|
||||
if (!port.eq->events.push(SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (v & 0x00ffffff), data))
|
||||
if (!port->eq->events.push(SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (v & 0x00ffffff), data))
|
||||
{
|
||||
LOG_WARNING(Log::SPU, "sys_spu_thread_throw_event(spup=%d, data0=0x%x, data1=0x%x) failed (queue is full)", spup, (v & 0x00ffffff), data);
|
||||
return;
|
||||
|
@ -714,7 +718,7 @@ void SPUThread::WriteChannel(u32 ch, const u128& r)
|
|||
LOG_WARNING(Log::SPU, "sys_event_flag_set_bit(id=%d, v=0x%x (flag=%d))", data, v, flag);
|
||||
}
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!Emu.GetIdManager().GetIDData(data, ef))
|
||||
{
|
||||
LOG_ERROR(Log::SPU, "sys_event_flag_set_bit(id=%d, v=0x%x (flag=%d)): EventFlag not found", data, v, flag);
|
||||
|
@ -755,7 +759,7 @@ void SPUThread::WriteChannel(u32 ch, const u128& r)
|
|||
LOG_WARNING(Log::SPU, "sys_event_flag_set_bit_impatient(id=%d, v=0x%x (flag=%d))", data, v, flag);
|
||||
}
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!Emu.GetIdManager().GetIDData(data, ef))
|
||||
{
|
||||
LOG_WARNING(Log::SPU, "sys_event_flag_set_bit_impatient(id=%d, v=0x%x (flag=%d)): EventFlag not found", data, v, flag);
|
||||
|
@ -1073,7 +1077,7 @@ void SPUThread::StopAndSignal(u32 code)
|
|||
LOG_NOTICE(Log::SPU, "sys_spu_thread_receive_event(spuq=0x%x)", spuq);
|
||||
}
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!SPUQs.GetEventQueue(FIX_SPUQ(spuq), eq))
|
||||
{
|
||||
SPU.In_MBox.PushUncond(CELL_EINVAL); // TODO: check error value
|
||||
|
@ -1159,7 +1163,7 @@ void SPUThread::StopAndSignal(u32 code)
|
|||
group->m_exit_status = SPU.Out_MBox.GetValue();
|
||||
for (auto& v : group->list)
|
||||
{
|
||||
if (CPUThread* t = Emu.GetCPU().GetThread(v))
|
||||
if (std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(v))
|
||||
{
|
||||
t->Stop();
|
||||
}
|
||||
|
|
|
@ -283,9 +283,9 @@ public:
|
|||
u64 R_ADDR; // reservation address
|
||||
u64 R_DATA[16]; // lock line data (BE)
|
||||
|
||||
EventPort SPUPs[64]; // SPU Thread Event Ports
|
||||
std::shared_ptr<EventPort> SPUPs[64]; // SPU Thread Event Ports
|
||||
EventManager SPUQs; // SPU Queue Mapping
|
||||
SpuGroupInfo* group; // associated SPU Thread Group (null for raw spu)
|
||||
std::shared_ptr<SpuGroupInfo> group; // associated SPU Thread Group (null for raw spu)
|
||||
|
||||
u64 m_dec_start; // timestamp of writing decrementer value
|
||||
u32 m_dec_value; // written decrementer value
|
||||
|
|
|
@ -23,7 +23,7 @@ bool EventManager::CheckKey(u64 key)
|
|||
return key_map.find(key) != key_map.end();
|
||||
}
|
||||
|
||||
bool EventManager::RegisterKey(EventQueue* data, u64 key)
|
||||
bool EventManager::RegisterKey(std::shared_ptr<EventQueue>& data, u64 key)
|
||||
{
|
||||
if (!key) return true;
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
@ -40,7 +40,7 @@ bool EventManager::RegisterKey(EventQueue* data, u64 key)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EventManager::GetEventQueue(u64 key, EventQueue*& data)
|
||||
bool EventManager::GetEventQueue(u64 key, std::shared_ptr<EventQueue>& data)
|
||||
{
|
||||
data = nullptr;
|
||||
if (!key) return false;
|
||||
|
@ -79,8 +79,7 @@ bool EventManager::SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
EventQueue* eq = f->second;
|
||||
|
||||
eq->events.push(source, d1, d2, d3);
|
||||
|
||||
f->second->events.push(source, d1, d2, d3);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ struct EventQueue;
|
|||
class EventManager
|
||||
{
|
||||
std::mutex m_lock;
|
||||
std::unordered_map<u64, EventQueue*> key_map;
|
||||
std::unordered_map<u64, std::shared_ptr<EventQueue>> key_map;
|
||||
|
||||
public:
|
||||
void Init();
|
||||
void Clear();
|
||||
bool CheckKey(u64 key);
|
||||
bool RegisterKey(EventQueue* data, u64 key);
|
||||
bool GetEventQueue(u64 key, EventQueue*& data);
|
||||
bool RegisterKey(std::shared_ptr<EventQueue>& data, u64 key);
|
||||
bool GetEventQueue(u64 key, std::shared_ptr<EventQueue>& data);
|
||||
bool UnregisterKey(u64 key);
|
||||
bool SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3);
|
||||
};
|
||||
|
|
|
@ -48,14 +48,14 @@ public:
|
|||
m_destr(m_ptr);
|
||||
}
|
||||
|
||||
template<typename T> T* get()
|
||||
template<typename T> std::shared_ptr<T> get()
|
||||
{
|
||||
return (T*)m_ptr;
|
||||
return *(std::shared_ptr<T>*)m_ptr;
|
||||
}
|
||||
|
||||
template<typename T> const T* get() const
|
||||
template<typename T> std::shared_ptr<const T> get() const
|
||||
{
|
||||
return (const T*)m_ptr;
|
||||
return *(std::shared_ptr<const T>*)m_ptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -67,11 +67,11 @@ class ID
|
|||
|
||||
public:
|
||||
template<typename T>
|
||||
ID(const std::string& name, T* data, const IDType type)
|
||||
ID(const std::string& name, std::shared_ptr<T>& data, const IDType type)
|
||||
: m_name(name)
|
||||
, m_type(type)
|
||||
{
|
||||
m_data = new IDData(data, [](void *ptr) -> void { delete (T*)ptr; });
|
||||
m_data = new IDData(new std::shared_ptr<T>(data), [](void *ptr) -> void { delete (std::shared_ptr<T>*)ptr; });
|
||||
}
|
||||
|
||||
ID() : m_data(nullptr)
|
||||
|
@ -85,6 +85,7 @@ public:
|
|||
m_data = other.m_data;
|
||||
other.m_data = nullptr;
|
||||
}
|
||||
|
||||
ID& operator=(ID&& other)
|
||||
{
|
||||
std::swap(m_name,other.m_name);
|
||||
|
@ -159,7 +160,7 @@ public:
|
|||
= char
|
||||
#endif
|
||||
>
|
||||
u32 GetNewID(const std::string& name = "", T* data = nullptr, const IDType type = TYPE_OTHER)
|
||||
u32 GetNewID(const std::string& name = "", std::shared_ptr<T>& data = nullptr, const IDType type = TYPE_OTHER)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mtx_main);
|
||||
|
||||
|
@ -179,7 +180,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
bool GetIDData(const u32 id, T*& result)
|
||||
bool GetIDData(const u32 id, std::shared_ptr<T>& result)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mtx_main);
|
||||
|
||||
|
@ -224,17 +225,17 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
u32 GetTypeCount(IDType type)
|
||||
{
|
||||
if (type < TYPE_OTHER) {
|
||||
return (u32)m_types[type].size();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//u32 GetTypeCount(IDType type)
|
||||
//{
|
||||
// if (type < TYPE_OTHER) {
|
||||
// return (u32)m_types[type].size();
|
||||
// }
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
const std::set<u32>& GetTypeIDs(IDType type)
|
||||
{
|
||||
assert(type < TYPE_OTHER);
|
||||
return m_types[type];
|
||||
}
|
||||
//const std::set<u32>& GetTypeIDs(IDType type)
|
||||
//{
|
||||
// assert(type < TYPE_OTHER);
|
||||
// return m_types[type];
|
||||
//}
|
||||
};
|
||||
|
|
|
@ -95,7 +95,8 @@ public:
|
|||
|
||||
public:
|
||||
bool CheckID(u32 id) const;
|
||||
template<typename T> bool CheckId(u32 id, T*& data)
|
||||
|
||||
template<typename T> bool CheckId(u32 id, std::shared_ptr<T>& data)
|
||||
{
|
||||
ID* id_data;
|
||||
|
||||
|
@ -106,7 +107,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
template<typename T> bool CheckId(u32 id, T*& data, IDType& type)
|
||||
template<typename T> bool CheckId(u32 id, std::shared_ptr<T>& data, IDType& type)
|
||||
{
|
||||
ID* id_data;
|
||||
|
||||
|
@ -117,10 +118,11 @@ public:
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckID(u32 id, ID*& _id) const;
|
||||
|
||||
template<typename T>
|
||||
u32 GetNewId(T* data, IDType type = TYPE_OTHER)
|
||||
u32 GetNewId(std::shared_ptr<T>& data, IDType type = TYPE_OTHER)
|
||||
{
|
||||
return GetIdManager().GetNewID<T>(GetName(), data, type);
|
||||
}
|
||||
|
|
|
@ -216,9 +216,10 @@ next:
|
|||
|
||||
u32 adecOpen(AudioDecoder* data)
|
||||
{
|
||||
std::shared_ptr<AudioDecoder> data_ptr(data);
|
||||
AudioDecoder& adec = *data;
|
||||
|
||||
u32 adec_id = cellAdec->GetNewId(data);
|
||||
u32 adec_id = cellAdec->GetNewId(data_ptr);
|
||||
|
||||
adec.id = adec_id;
|
||||
|
||||
|
@ -231,7 +232,7 @@ u32 adecOpen(AudioDecoder* data)
|
|||
adec.adecCb->InitRegs();
|
||||
adec.adecCb->DoRun();
|
||||
|
||||
thread t("Audio Decoder[" + std::to_string(adec_id) + "] Thread", [&]()
|
||||
thread t("Audio Decoder[" + std::to_string(adec_id) + "] Thread", [&, data_ptr]()
|
||||
{
|
||||
cellAdec->Notice("Audio Decoder thread started");
|
||||
|
||||
|
@ -554,7 +555,7 @@ int cellAdecClose(u32 handle)
|
|||
{
|
||||
cellAdec->Warning("cellAdecClose(handle=%d)", handle);
|
||||
|
||||
AudioDecoder* adec;
|
||||
std::shared_ptr<AudioDecoder> adec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, adec))
|
||||
{
|
||||
return CELL_ADEC_ERROR_ARG;
|
||||
|
@ -582,7 +583,7 @@ int cellAdecStartSeq(u32 handle, u32 param_addr)
|
|||
{
|
||||
cellAdec->Warning("cellAdecStartSeq(handle=%d, param_addr=0x%x)", handle, param_addr);
|
||||
|
||||
AudioDecoder* adec;
|
||||
std::shared_ptr<AudioDecoder> adec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, adec))
|
||||
{
|
||||
return CELL_ADEC_ERROR_ARG;
|
||||
|
@ -634,7 +635,7 @@ int cellAdecEndSeq(u32 handle)
|
|||
{
|
||||
cellAdec->Warning("cellAdecEndSeq(handle=%d)", handle);
|
||||
|
||||
AudioDecoder* adec;
|
||||
std::shared_ptr<AudioDecoder> adec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, adec))
|
||||
{
|
||||
return CELL_ADEC_ERROR_ARG;
|
||||
|
@ -648,7 +649,7 @@ int cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
|
|||
{
|
||||
cellAdec->Log("cellAdecDecodeAu(handle=%d, auInfo_addr=0x%x)", handle, auInfo.addr());
|
||||
|
||||
AudioDecoder* adec;
|
||||
std::shared_ptr<AudioDecoder> adec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, adec))
|
||||
{
|
||||
return CELL_ADEC_ERROR_ARG;
|
||||
|
@ -670,7 +671,7 @@ int cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
|
|||
{
|
||||
cellAdec->Log("cellAdecGetPcm(handle=%d, outBuffer_addr=0x%x)", handle, outBuffer.addr());
|
||||
|
||||
AudioDecoder* adec;
|
||||
std::shared_ptr<AudioDecoder> adec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, adec))
|
||||
{
|
||||
return CELL_ADEC_ERROR_ARG;
|
||||
|
@ -784,7 +785,7 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr<u32> pcmItem_ptr)
|
|||
{
|
||||
cellAdec->Log("cellAdecGetPcmItem(handle=%d, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr.addr());
|
||||
|
||||
AudioDecoder* adec;
|
||||
std::shared_ptr<AudioDecoder> adec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, adec))
|
||||
{
|
||||
return CELL_ADEC_ERROR_ARG;
|
||||
|
|
|
@ -752,11 +752,10 @@ int cellAudioCreateNotifyEventQueue(vm::ptr<u32> id, vm::ptr<u64> key)
|
|||
}
|
||||
event_key = (event_key << 48) | 0x80004d494f323221; // left part: 0x8000, 0x8001, 0x8002 ...
|
||||
|
||||
EventQueue* eq = new EventQueue(SYS_SYNC_FIFO, SYS_PPU_QUEUE, event_key, event_key, 32);
|
||||
std::shared_ptr<EventQueue> eq(new EventQueue(SYS_SYNC_FIFO, SYS_PPU_QUEUE, event_key, event_key, 32));
|
||||
|
||||
if (!Emu.GetEventManager().RegisterKey(eq, event_key))
|
||||
{
|
||||
delete eq;
|
||||
return CELL_AUDIO_ERROR_EVENT_QUEUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -298,9 +298,10 @@ void dmuxQueryEsAttr(u32 info_addr /* may be 0 */, vm::ptr<const CellCodecEsFilt
|
|||
|
||||
u32 dmuxOpen(Demuxer* data)
|
||||
{
|
||||
std::shared_ptr<Demuxer> data_ptr(data);
|
||||
Demuxer& dmux = *data;
|
||||
|
||||
u32 dmux_id = cellDmux->GetNewId(data);
|
||||
u32 dmux_id = cellDmux->GetNewId(data_ptr);
|
||||
|
||||
dmux.id = dmux_id;
|
||||
|
||||
|
@ -313,7 +314,7 @@ u32 dmuxOpen(Demuxer* data)
|
|||
dmux.dmuxCb->InitRegs();
|
||||
dmux.dmuxCb->DoRun();
|
||||
|
||||
thread t("Demuxer[" + std::to_string(dmux_id) + "] Thread", [&]()
|
||||
thread t("Demuxer[" + std::to_string(dmux_id) + "] Thread", [&, data_ptr]()
|
||||
{
|
||||
cellDmux->Notice("Demuxer thread started (mem=0x%x, size=0x%x, cb=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc, dmux.cbArg);
|
||||
|
||||
|
@ -851,7 +852,7 @@ int cellDmuxClose(u32 demuxerHandle)
|
|||
{
|
||||
cellDmux->Warning("cellDmuxClose(demuxerHandle=%d)", demuxerHandle);
|
||||
|
||||
Demuxer* dmux;
|
||||
std::shared_ptr<Demuxer> dmux;
|
||||
if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -881,7 +882,7 @@ int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize
|
|||
cellDmux->Log("cellDmuxSetStream(demuxerHandle=%d, streamAddress=0x%x, streamSize=%d, discontinuity=%d, userData=0x%llx",
|
||||
demuxerHandle, streamAddress, streamSize, discontinuity, userData);
|
||||
|
||||
Demuxer* dmux;
|
||||
std::shared_ptr<Demuxer> dmux;
|
||||
if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -908,7 +909,7 @@ int cellDmuxResetStream(u32 demuxerHandle)
|
|||
{
|
||||
cellDmux->Warning("cellDmuxResetStream(demuxerHandle=%d)", demuxerHandle);
|
||||
|
||||
Demuxer* dmux;
|
||||
std::shared_ptr<Demuxer> dmux;
|
||||
if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -922,7 +923,7 @@ int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle)
|
|||
{
|
||||
cellDmux->Warning("cellDmuxResetStreamAndWaitDone(demuxerHandle=%d)", demuxerHandle);
|
||||
|
||||
Demuxer* dmux;
|
||||
std::shared_ptr<Demuxer> dmux;
|
||||
if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -981,7 +982,7 @@ int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr<const CellCodecEsFilterId> esFil
|
|||
"esSpecificInfo_addr=0x%x, esHandle_addr=0x%x)", demuxerHandle, esFilterId.addr(), esResourceInfo.addr(),
|
||||
esCb.addr(), esSpecificInfo_addr, esHandle.addr());
|
||||
|
||||
Demuxer* dmux;
|
||||
std::shared_ptr<Demuxer> dmux;
|
||||
if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -989,9 +990,9 @@ int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr<const CellCodecEsFilterId> esFil
|
|||
|
||||
// TODO: check esFilterId, esResourceInfo, esCb and esSpecificInfo correctly
|
||||
|
||||
ElementaryStream* es = new ElementaryStream(dmux, esResourceInfo->memAddr, esResourceInfo->memSize,
|
||||
std::shared_ptr<ElementaryStream> es(new ElementaryStream(dmux.get(), esResourceInfo->memAddr, esResourceInfo->memSize,
|
||||
esFilterId->filterIdMajor, esFilterId->filterIdMinor, esFilterId->supplementalInfo1, esFilterId->supplementalInfo2,
|
||||
vm::ptr<CellDmuxCbEsMsg>::make(esCb->cbEsMsgFunc.addr()), esCb->cbArg, esSpecificInfo_addr);
|
||||
vm::ptr<CellDmuxCbEsMsg>::make(esCb->cbEsMsgFunc.addr()), esCb->cbArg, esSpecificInfo_addr));
|
||||
|
||||
u32 id = cellDmux->GetNewId(es);
|
||||
es->id = id;
|
||||
|
@ -1002,7 +1003,7 @@ int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr<const CellCodecEsFilterId> esFil
|
|||
|
||||
DemuxerTask task(dmuxEnableEs);
|
||||
task.es.es = id;
|
||||
task.es.es_ptr = es;
|
||||
task.es.es_ptr = es.get();
|
||||
|
||||
dmux->job.Push(task, &dmux->is_closed);
|
||||
return CELL_OK;
|
||||
|
@ -1012,7 +1013,7 @@ int cellDmuxDisableEs(u32 esHandle)
|
|||
{
|
||||
cellDmux->Warning("cellDmuxDisableEs(esHandle=0x%x)", esHandle);
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1020,7 +1021,7 @@ int cellDmuxDisableEs(u32 esHandle)
|
|||
|
||||
DemuxerTask task(dmuxDisableEs);
|
||||
task.es.es = esHandle;
|
||||
task.es.es_ptr = es;
|
||||
task.es.es_ptr = es.get();
|
||||
|
||||
es->dmux->job.Push(task, &es->dmux->is_closed);
|
||||
return CELL_OK;
|
||||
|
@ -1030,7 +1031,7 @@ int cellDmuxResetEs(u32 esHandle)
|
|||
{
|
||||
cellDmux->Log("cellDmuxResetEs(esHandle=0x%x)", esHandle);
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1038,7 +1039,7 @@ int cellDmuxResetEs(u32 esHandle)
|
|||
|
||||
DemuxerTask task(dmuxResetEs);
|
||||
task.es.es = esHandle;
|
||||
task.es.es_ptr = es;
|
||||
task.es.es_ptr = es.get();
|
||||
|
||||
es->dmux->job.Push(task, &es->dmux->is_closed);
|
||||
return CELL_OK;
|
||||
|
@ -1049,7 +1050,7 @@ int cellDmuxGetAu(u32 esHandle, vm::ptr<u32> auInfo_ptr, vm::ptr<u32> auSpecific
|
|||
cellDmux->Log("cellDmuxGetAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
|
||||
esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr());
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1072,7 +1073,7 @@ int cellDmuxPeekAu(u32 esHandle, vm::ptr<u32> auInfo_ptr, vm::ptr<u32> auSpecifi
|
|||
cellDmux->Log("cellDmuxPeekAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
|
||||
esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr());
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1095,7 +1096,7 @@ int cellDmuxGetAuEx(u32 esHandle, vm::ptr<u32> auInfoEx_ptr, vm::ptr<u32> auSpec
|
|||
cellDmux->Log("cellDmuxGetAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
|
||||
esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr());
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1118,7 +1119,7 @@ int cellDmuxPeekAuEx(u32 esHandle, vm::ptr<u32> auInfoEx_ptr, vm::ptr<u32> auSpe
|
|||
cellDmux->Log("cellDmuxPeekAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
|
||||
esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr());
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1140,7 +1141,7 @@ int cellDmuxReleaseAu(u32 esHandle)
|
|||
{
|
||||
cellDmux->Log("cellDmuxReleaseAu(esHandle=0x%x)", esHandle);
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1157,7 +1158,7 @@ int cellDmuxFlushEs(u32 esHandle)
|
|||
{
|
||||
cellDmux->Warning("cellDmuxFlushEs(esHandle=0x%x)", esHandle);
|
||||
|
||||
ElementaryStream* es;
|
||||
std::shared_ptr<ElementaryStream> es;
|
||||
if (!Emu.GetIdManager().GetIDData(esHandle, es))
|
||||
{
|
||||
return CELL_DMUX_ERROR_ARG;
|
||||
|
@ -1165,7 +1166,7 @@ int cellDmuxFlushEs(u32 esHandle)
|
|||
|
||||
DemuxerTask task(dmuxFlushEs);
|
||||
task.es.es = esHandle;
|
||||
task.es.es_ptr = es;
|
||||
task.es.es_ptr = es.get();
|
||||
|
||||
es->dmux->job.Push(task, &es->dmux->is_closed);
|
||||
return CELL_OK;
|
||||
|
|
|
@ -26,7 +26,7 @@ int cellGifDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellGifDecSrc
|
|||
cellGifDec->Warning("cellGifDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)",
|
||||
mainHandle, subHandle.addr(), src.addr(), openInfo.addr());
|
||||
|
||||
CellGifDecSubHandle *current_subHandle = new CellGifDecSubHandle;
|
||||
std::shared_ptr<CellGifDecSubHandle> current_subHandle(new CellGifDecSubHandle);
|
||||
current_subHandle->fd = 0;
|
||||
current_subHandle->src = *src;
|
||||
|
||||
|
@ -62,7 +62,7 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo>
|
|||
cellGifDec->Warning("cellGifDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)",
|
||||
mainHandle, subHandle, info.addr());
|
||||
|
||||
CellGifDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellGifDecSubHandle> subHandle_data;
|
||||
if(!cellGifDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_GIFDEC_ERROR_FATAL;
|
||||
|
||||
|
@ -112,7 +112,7 @@ int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellGifD
|
|||
cellGifDec->Warning("cellGifDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
|
||||
mainHandle, subHandle, inParam.addr(), outParam.addr());
|
||||
|
||||
CellGifDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellGifDecSubHandle> subHandle_data;
|
||||
if(!cellGifDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_GIFDEC_ERROR_FATAL;
|
||||
|
||||
|
@ -144,7 +144,7 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
|
|||
|
||||
dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP;
|
||||
|
||||
CellGifDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellGifDecSubHandle> subHandle_data;
|
||||
if(!cellGifDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_GIFDEC_ERROR_FATAL;
|
||||
|
||||
|
@ -259,7 +259,7 @@ int cellGifDecClose(u32 mainHandle, u32 subHandle)
|
|||
cellGifDec->Warning("cellGifDecClose(mainHandle=0x%x, subHandle=0x%x)",
|
||||
mainHandle, subHandle);
|
||||
|
||||
CellGifDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellGifDecSubHandle> subHandle_data;
|
||||
if(!cellGifDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_GIFDEC_ERROR_FATAL;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ int cellJpgDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellJpgDecSrc
|
|||
cellJpgDec->Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)",
|
||||
mainHandle, subHandle.addr(), src.addr(), openInfo.addr());
|
||||
|
||||
CellJpgDecSubHandle *current_subHandle = new CellJpgDecSubHandle;
|
||||
std::shared_ptr<CellJpgDecSubHandle> current_subHandle(new CellJpgDecSubHandle);
|
||||
|
||||
current_subHandle->fd = 0;
|
||||
current_subHandle->src = *src;
|
||||
|
@ -68,7 +68,7 @@ int cellJpgDecClose(u32 mainHandle, u32 subHandle)
|
|||
cellJpgDec->Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle=0x%x)",
|
||||
mainHandle, subHandle);
|
||||
|
||||
CellJpgDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellJpgDecSubHandle> subHandle_data;
|
||||
if(!cellJpgDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_JPGDEC_ERROR_FATAL;
|
||||
|
||||
|
@ -82,7 +82,7 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo>
|
|||
{
|
||||
cellJpgDec->Log("cellJpgDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)", mainHandle, subHandle, info.addr());
|
||||
|
||||
CellJpgDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellJpgDecSubHandle> subHandle_data;
|
||||
if(!cellJpgDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_JPGDEC_ERROR_FATAL;
|
||||
|
||||
|
@ -151,7 +151,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::pt
|
|||
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
|
||||
|
||||
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_STOP;
|
||||
CellJpgDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellJpgDecSubHandle> subHandle_data;
|
||||
if(!cellJpgDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_JPGDEC_ERROR_FATAL;
|
||||
|
||||
|
@ -281,7 +281,7 @@ int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellJpgD
|
|||
cellJpgDec->Log("cellJpgDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
|
||||
mainHandle, subHandle, inParam.addr(), outParam.addr());
|
||||
|
||||
CellJpgDecSubHandle* subHandle_data;
|
||||
std::shared_ptr<CellJpgDecSubHandle> subHandle_data;
|
||||
if(!cellJpgDec->CheckId(subHandle, subHandle_data))
|
||||
return CELL_JPGDEC_ERROR_FATAL;
|
||||
|
||||
|
|
|
@ -206,9 +206,10 @@ u32 vdecQueryAttr(CellVdecCodecType type, u32 profile, u32 spec_addr /* may be 0
|
|||
|
||||
u32 vdecOpen(VideoDecoder* data)
|
||||
{
|
||||
std::shared_ptr<VideoDecoder> data_ptr(data);
|
||||
VideoDecoder& vdec = *data;
|
||||
|
||||
u32 vdec_id = cellVdec->GetNewId(data);
|
||||
u32 vdec_id = cellVdec->GetNewId(data_ptr);
|
||||
|
||||
vdec.id = vdec_id;
|
||||
|
||||
|
@ -221,7 +222,7 @@ u32 vdecOpen(VideoDecoder* data)
|
|||
vdec.vdecCb->InitRegs();
|
||||
vdec.vdecCb->DoRun();
|
||||
|
||||
thread t("Video Decoder[" + std::to_string(vdec_id) + "] Thread", [&]()
|
||||
thread t("Video Decoder[" + std::to_string(vdec_id) + "] Thread", [&, data_ptr]()
|
||||
{
|
||||
cellVdec->Notice("Video Decoder thread started");
|
||||
|
||||
|
@ -590,7 +591,7 @@ int cellVdecClose(u32 handle)
|
|||
{
|
||||
cellVdec->Warning("cellVdecClose(handle=%d)", handle);
|
||||
|
||||
VideoDecoder* vdec;
|
||||
std::shared_ptr<VideoDecoder> vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
{
|
||||
return CELL_VDEC_ERROR_ARG;
|
||||
|
@ -618,7 +619,7 @@ int cellVdecStartSeq(u32 handle)
|
|||
{
|
||||
cellVdec->Log("cellVdecStartSeq(handle=%d)", handle);
|
||||
|
||||
VideoDecoder* vdec;
|
||||
std::shared_ptr<VideoDecoder> vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
{
|
||||
return CELL_VDEC_ERROR_ARG;
|
||||
|
@ -632,7 +633,7 @@ int cellVdecEndSeq(u32 handle)
|
|||
{
|
||||
cellVdec->Warning("cellVdecEndSeq(handle=%d)", handle);
|
||||
|
||||
VideoDecoder* vdec;
|
||||
std::shared_ptr<VideoDecoder> vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
{
|
||||
return CELL_VDEC_ERROR_ARG;
|
||||
|
@ -646,7 +647,7 @@ int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::ptr<const CellVdec
|
|||
{
|
||||
cellVdec->Log("cellVdecDecodeAu(handle=%d, mode=0x%x, auInfo_addr=0x%x)", handle, mode, auInfo.addr());
|
||||
|
||||
VideoDecoder* vdec;
|
||||
std::shared_ptr<VideoDecoder> vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
{
|
||||
return CELL_VDEC_ERROR_ARG;
|
||||
|
@ -670,7 +671,7 @@ int cellVdecGetPicture(u32 handle, vm::ptr<const CellVdecPicFormat> format, vm::
|
|||
{
|
||||
cellVdec->Log("cellVdecGetPicture(handle=%d, format_addr=0x%x, outBuff_addr=0x%x)", handle, format.addr(), outBuff.addr());
|
||||
|
||||
VideoDecoder* vdec;
|
||||
std::shared_ptr<VideoDecoder> vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
{
|
||||
return CELL_VDEC_ERROR_ARG;
|
||||
|
@ -726,7 +727,7 @@ int cellVdecGetPicItem(u32 handle, vm::ptr<u32> picItem_ptr)
|
|||
{
|
||||
cellVdec->Log("cellVdecGetPicItem(handle=%d, picItem_ptr_addr=0x%x)", handle, picItem_ptr.addr());
|
||||
|
||||
VideoDecoder* vdec;
|
||||
std::shared_ptr<VideoDecoder> vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
{
|
||||
return CELL_VDEC_ERROR_ARG;
|
||||
|
@ -871,7 +872,7 @@ int cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc)
|
|||
{
|
||||
cellVdec->Log("cellVdecSetFrameRate(handle=%d, frc=0x%x)", handle, frc);
|
||||
|
||||
VideoDecoder* vdec;
|
||||
std::shared_ptr<VideoDecoder> vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
{
|
||||
return CELL_VDEC_ERROR_ARG;
|
||||
|
|
|
@ -28,7 +28,8 @@ int cellVpostQueryAttr(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<CellVp
|
|||
|
||||
u32 vpostOpen(VpostInstance* data)
|
||||
{
|
||||
u32 id = cellVpost->GetNewId(data);
|
||||
std::shared_ptr<VpostInstance> data_ptr(data);
|
||||
u32 id = cellVpost->GetNewId(data_ptr);
|
||||
|
||||
cellVpost->Notice("*** Vpost instance created (to_rgba=%d): id = %d", data->to_rgba, id);
|
||||
|
||||
|
@ -59,7 +60,7 @@ int cellVpostClose(u32 handle)
|
|||
{
|
||||
cellVpost->Warning("cellVpostClose(handle=0x%x)", handle);
|
||||
|
||||
VpostInstance* vpost;
|
||||
std::shared_ptr<VpostInstance> vpost;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vpost))
|
||||
{
|
||||
return CELL_VPOST_ERROR_C_ARG_HDL_INVALID;
|
||||
|
@ -75,7 +76,7 @@ int cellVpostExec(u32 handle, vm::ptr<const u8> inPicBuff, vm::ptr<const CellVpo
|
|||
cellVpost->Log("cellVpostExec(handle=0x%x, inPicBuff_addr=0x%x, ctrlParam_addr=0x%x, outPicBuff_addr=0x%x, picInfo_addr=0x%x)",
|
||||
handle, inPicBuff.addr(), ctrlParam.addr(), outPicBuff.addr(), picInfo.addr());
|
||||
|
||||
VpostInstance* vpost;
|
||||
std::shared_ptr<VpostInstance> vpost;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vpost))
|
||||
{
|
||||
return CELL_VPOST_ERROR_E_ARG_HDL_INVALID;
|
||||
|
|
|
@ -33,7 +33,8 @@ int _sys_heap_create_heap(const u32 heap_addr, const u32 align, const u32 size)
|
|||
{
|
||||
sysPrxForUser->Warning("_sys_heap_create_heap(heap_addr=0x%x, align=0x%x, size=0x%x)", heap_addr, align, size);
|
||||
|
||||
u32 heap_id = sysPrxForUser->GetNewId(new HeapInfo(heap_addr, align, size));
|
||||
std::shared_ptr<HeapInfo> heap(new HeapInfo(heap_addr, align, size));
|
||||
u32 heap_id = sysPrxForUser->GetNewId(heap);
|
||||
sysPrxForUser->Warning("*** sys_heap created: id = %d", heap_id);
|
||||
return heap_id;
|
||||
}
|
||||
|
@ -42,7 +43,7 @@ u32 _sys_heap_malloc(const u32 heap_id, const u32 size)
|
|||
{
|
||||
sysPrxForUser->Warning("_sys_heap_malloc(heap_id=%d, size=0x%x)", heap_id, size);
|
||||
|
||||
HeapInfo* heap;
|
||||
std::shared_ptr<HeapInfo> heap;
|
||||
if(!sysPrxForUser->CheckId(heap_id, heap)) return CELL_ESRCH;
|
||||
|
||||
return (u32)Memory.Alloc(size, 1);
|
||||
|
@ -52,7 +53,7 @@ u32 _sys_heap_memalign(u32 heap_id, u32 align, u32 size)
|
|||
{
|
||||
sysPrxForUser->Warning("_sys_heap_memalign(heap_id=%d, align=0x%x, size=0x%x)", heap_id, align, size);
|
||||
|
||||
HeapInfo* heap;
|
||||
std::shared_ptr<HeapInfo> heap;
|
||||
if(!sysPrxForUser->CheckId(heap_id, heap)) return CELL_ESRCH;
|
||||
|
||||
return (u32)Memory.Alloc(size, align);
|
||||
|
|
|
@ -168,7 +168,7 @@ void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void (*)(vm::ptr
|
|||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsFileBase* orig_file;
|
||||
std::shared_ptr<vfsFileBase> orig_file;
|
||||
if (!sys_fs->CheckId(fd, orig_file))
|
||||
{
|
||||
sys_fs->Error("Wrong fd (%s)", fd);
|
||||
|
@ -178,7 +178,7 @@ void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void (*)(vm::ptr
|
|||
|
||||
u64 nbytes = aio->size;
|
||||
|
||||
vfsStream& file = *(vfsStream*)orig_file;
|
||||
vfsStream& file = *(vfsStream*)orig_file.get();
|
||||
const u64 old_pos = file.Tell();
|
||||
file.Seek((u64)aio->offset);
|
||||
|
||||
|
@ -220,7 +220,7 @@ int cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<u32> aio_id, vm::ptr<void(*)(v
|
|||
return CELL_ENXIO;
|
||||
}
|
||||
|
||||
vfsFileBase* orig_file;
|
||||
std::shared_ptr<vfsFileBase> orig_file;
|
||||
u32 fd = aio->fd;
|
||||
|
||||
if (!sys_fs->CheckId(fd, orig_file))
|
||||
|
|
|
@ -35,8 +35,9 @@
|
|||
|
||||
#include "SysCalls.h"
|
||||
|
||||
namespace detail{
|
||||
template<> bool CheckId(u32 id, ID*& _id,const std::string &name)
|
||||
namespace detail
|
||||
{
|
||||
bool CheckIdID(u32 id, ID*& _id, const std::string &name)
|
||||
{
|
||||
return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->GetName() == name;
|
||||
}
|
||||
|
@ -143,8 +144,8 @@ static func_caller* sc_table[kSyscallTableLength] =
|
|||
null_func,//bind_func(_sys_lwmutex_create), //95 (0x05F) // internal, used by sys_lwmutex_create
|
||||
null_func,//bind_func(_sys_lwmutex_destroy), //96 (0x060) // internal, used by sys_lwmutex_destroy
|
||||
null_func,//bind_func(_sys_lwmutex_lock), //97 (0x061) // internal, used by sys_lwmutex_lock
|
||||
null_func,//bind_func(_sys_lwmutex_trylock), //98 (0x062) // internal, used by sys_lwmutex_unlock
|
||||
null_func,//bind_func(_sys_lwmutex_unlock), //99 (0x063) // internal, used by sys_lwmutex_trylock
|
||||
null_func,//bind_func(_sys_lwmutex_???lock), //98 (0x062) // internal, used by sys_lwmutex_unlock
|
||||
null_func,//bind_func(_sys_lwmutex_???lock), //99 (0x063) // internal, used by sys_lwmutex_trylock
|
||||
bind_func(sys_mutex_create), //100 (0x064)
|
||||
bind_func(sys_mutex_destroy), //101 (0x065)
|
||||
bind_func(sys_mutex_lock), //102 (0x066)
|
||||
|
|
|
@ -7,16 +7,17 @@
|
|||
|
||||
class SysCallBase;
|
||||
|
||||
namespace detail{
|
||||
template<typename T> bool CheckId(u32 id, T*& data,const std::string &name)
|
||||
namespace detail
|
||||
{
|
||||
bool CheckIdID(u32 id, ID*& _id, const std::string& name);
|
||||
|
||||
template<typename T> bool CheckId(u32 id, std::shared_ptr<T>& data, const std::string& name)
|
||||
{
|
||||
ID* id_data;
|
||||
if(!CheckId(id, id_data,name)) return false;
|
||||
if(!CheckIdID(id, id_data, name)) return false;
|
||||
data = id_data->GetData()->get<T>();
|
||||
return true;
|
||||
}
|
||||
|
||||
template<> bool CheckId<ID>(u32 id, ID*& _id,const std::string &name);
|
||||
}
|
||||
|
||||
class SysCallBase : public LogBase
|
||||
|
@ -44,13 +45,13 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
bool CheckId(u32 id, T*& data) const
|
||||
bool CheckId(u32 id, std::shared_ptr<T>& data) const
|
||||
{
|
||||
return detail::CheckId(id,data,GetName());
|
||||
return detail::CheckId(id, data, GetName());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
u32 GetNewId(T* data, IDType type = TYPE_OTHER)
|
||||
u32 GetNewId(std::shared_ptr<T>& data, IDType type = TYPE_OTHER)
|
||||
{
|
||||
return GetIdManager().GetNewID<T>(GetName(), data, type);
|
||||
}
|
||||
|
|
|
@ -100,11 +100,10 @@ s32 cellFsOpen(vm::ptr<const char> path, s32 flags, vm::ptr<be_t<u32>> fd, vm::p
|
|||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
vfsFileBase* stream = Emu.GetVFS().OpenFile(_path, o_mode);
|
||||
std::shared_ptr<vfsFileBase> stream(Emu.GetVFS().OpenFile(_path, o_mode));
|
||||
|
||||
if (!stream || !stream->IsOpened())
|
||||
{
|
||||
delete stream;
|
||||
sys_fs->Error("\"%s\" not found! flags: 0x%08x", path.get_ptr(), flags);
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
@ -123,7 +122,7 @@ s32 cellFsRead(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<be_t<u64>> nread)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -146,7 +145,7 @@ s32 cellFsWrite(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<u64> nwrite
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
if (nbytes != (u32)nbytes) return CELL_ENOMEM;
|
||||
|
@ -178,10 +177,9 @@ s32 cellFsOpendir(vm::ptr<const char> path, vm::ptr<u32> fd)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsDirBase* dir = Emu.GetVFS().OpenDir(path.get_ptr());
|
||||
std::shared_ptr<vfsDirBase> dir(Emu.GetVFS().OpenDir(path.get_ptr()));
|
||||
if (!dir || !dir->IsOpened())
|
||||
{
|
||||
delete dir;
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
|
@ -195,7 +193,7 @@ s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<u64> nread)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsDirBase* directory;
|
||||
std::shared_ptr<vfsDirBase> directory;
|
||||
if (!sys_fs->CheckId(fd, directory))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -277,7 +275,7 @@ s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
|
|||
LV2_LOCK(0);
|
||||
|
||||
IDType type;
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE)
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -427,7 +425,7 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos)
|
|||
}
|
||||
|
||||
IDType type;
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE)
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -442,7 +440,7 @@ s32 cellFsFtruncate(u32 fd, u64 size)
|
|||
LV2_LOCK(0);
|
||||
|
||||
IDType type;
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE)
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -505,7 +503,7 @@ s32 cellFsFGetBlockSize(u32 fd, vm::ptr<u64> sector_size, vm::ptr<u64> block_siz
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -549,7 +547,7 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsDirBase* directory;
|
||||
std::shared_ptr<vfsDirBase> directory;
|
||||
if (!sys_fs->CheckId(fd, directory))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -587,7 +585,7 @@ s32 cellFsStReadInit(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -614,7 +612,7 @@ s32 cellFsStReadFinish(u32 fd)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -630,7 +628,7 @@ s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -647,7 +645,7 @@ s32 cellFsStReadGetStatus(u32 fd, vm::ptr<u64> status)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -662,7 +660,7 @@ s32 cellFsStReadGetRegid(u32 fd, vm::ptr<u64> regid)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -677,7 +675,7 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -693,7 +691,7 @@ s32 cellFsStReadStop(u32 fd)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -708,7 +706,7 @@ s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr<u64> rsize)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -729,7 +727,7 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<u32> addr, vm::ptr<u64> size)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -742,7 +740,7 @@ s32 cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -755,7 +753,7 @@ s32 cellFsStReadWait(u32 fd, u64 size)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -768,7 +766,7 @@ s32 cellFsStReadWaitCallback(u32 fd, u64 size, vm::ptr<void (*)(int xfd, u64 xsi
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
std::shared_ptr<vfsFileBase> file;
|
||||
if (!sys_fs->CheckId(fd, file))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
|
|
@ -65,19 +65,21 @@ u32 sleep_queue_t::pop(u32 protocol)
|
|||
u32 sel = 0;
|
||||
for (u32 i = 0; i < list.size(); i++)
|
||||
{
|
||||
CPUThread* t = Emu.GetCPU().GetThread(list[i]);
|
||||
if (!t)
|
||||
if (std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(list[i]))
|
||||
{
|
||||
u64 prio = t->GetPrio();
|
||||
if (prio < highest_prio)
|
||||
{
|
||||
highest_prio = prio;
|
||||
sel = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list[i] = 0;
|
||||
sel = i;
|
||||
break;
|
||||
}
|
||||
u64 prio = t->GetPrio();
|
||||
if (prio < highest_prio)
|
||||
{
|
||||
highest_prio = prio;
|
||||
sel = i;
|
||||
}
|
||||
}
|
||||
u32 res = list[sel];
|
||||
list.erase(list.begin() + sel);
|
||||
|
|
|
@ -27,13 +27,13 @@ s32 sys_cond_create(vm::ptr<u32> cond_id, u32 mutex_id, vm::ptr<sys_cond_attribu
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
Mutex* mutex;
|
||||
std::shared_ptr<Mutex> mutex;
|
||||
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
Cond* cond = new Cond(mutex, attr->name_u64);
|
||||
std::shared_ptr<Cond> cond(new Cond(mutex, attr->name_u64));
|
||||
const u32 id = sys_cond.GetNewId(cond, TYPE_COND);
|
||||
*cond_id = id;
|
||||
mutex->cond_count++;
|
||||
|
@ -49,7 +49,7 @@ s32 sys_cond_destroy(u32 cond_id)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
Cond* cond;
|
||||
std::shared_ptr<Cond> cond;
|
||||
if (!Emu.GetIdManager().GetIDData(cond_id, cond))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -70,13 +70,13 @@ s32 sys_cond_signal(u32 cond_id)
|
|||
{
|
||||
sys_cond.Log("sys_cond_signal(cond_id=%d)", cond_id);
|
||||
|
||||
Cond* cond;
|
||||
std::shared_ptr<Cond> cond;
|
||||
if (!Emu.GetIdManager().GetIDData(cond_id, cond))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
Mutex* mutex = cond->mutex;
|
||||
std::shared_ptr<Mutex> mutex = cond->mutex;
|
||||
|
||||
if (u32 target = cond->queue.pop(mutex->protocol))
|
||||
{
|
||||
|
@ -95,13 +95,13 @@ s32 sys_cond_signal_all(u32 cond_id)
|
|||
{
|
||||
sys_cond.Log("sys_cond_signal_all(cond_id=%d)", cond_id);
|
||||
|
||||
Cond* cond;
|
||||
std::shared_ptr<Cond> cond;
|
||||
if (!Emu.GetIdManager().GetIDData(cond_id, cond))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
Mutex* mutex = cond->mutex;
|
||||
std::shared_ptr<Mutex> mutex = cond->mutex;
|
||||
|
||||
while (u32 target = cond->queue.pop(mutex->protocol))
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id)
|
|||
{
|
||||
sys_cond.Log("sys_cond_signal_to(cond_id=%d, thread_id=%d)", cond_id, thread_id);
|
||||
|
||||
Cond* cond;
|
||||
std::shared_ptr<Cond> cond;
|
||||
if (!Emu.GetIdManager().GetIDData(cond_id, cond))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -137,7 +137,7 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id)
|
|||
return CELL_EPERM;
|
||||
}
|
||||
|
||||
Mutex* mutex = cond->mutex;
|
||||
std::shared_ptr<Mutex> mutex = cond->mutex;
|
||||
|
||||
u32 target = thread_id;
|
||||
{
|
||||
|
@ -156,13 +156,13 @@ s32 sys_cond_wait(PPUThread& CPU, u32 cond_id, u64 timeout)
|
|||
{
|
||||
sys_cond.Log("sys_cond_wait(cond_id=%d, timeout=%lld)", cond_id, timeout);
|
||||
|
||||
Cond* cond;
|
||||
std::shared_ptr<Cond> cond;
|
||||
if (!Emu.GetIdManager().GetIDData(cond_id, cond))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
Mutex* mutex = cond->mutex;
|
||||
std::shared_ptr<Mutex> mutex = cond->mutex;
|
||||
|
||||
const u32 tid = CPU.GetId();
|
||||
if (mutex->owner.read_sync() != tid)
|
||||
|
@ -172,8 +172,8 @@ s32 sys_cond_wait(PPUThread& CPU, u32 cond_id, u64 timeout)
|
|||
|
||||
cond->queue.push(tid, mutex->protocol);
|
||||
|
||||
auto old_recursive = mutex->recursive;
|
||||
mutex->recursive = 0;
|
||||
auto old_recursive = mutex->recursive_count.load();
|
||||
mutex->recursive_count = 0;
|
||||
if (!mutex->owner.compare_and_swap_test(tid, mutex->queue.pop(mutex->protocol)))
|
||||
{
|
||||
assert(!"sys_cond_wait() failed");
|
||||
|
@ -225,7 +225,7 @@ s32 sys_cond_wait(PPUThread& CPU, u32 cond_id, u64 timeout)
|
|||
}
|
||||
}
|
||||
|
||||
mutex->recursive = old_recursive;
|
||||
mutex->recursive_count = old_recursive;
|
||||
cond->signal.Pop(cond_id /* unused result */, nullptr);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ struct sys_cond_attribute
|
|||
|
||||
struct Cond
|
||||
{
|
||||
Mutex* mutex; // associated with mutex
|
||||
std::shared_ptr<Mutex> mutex; // associated with mutex
|
||||
SQueue<u32, 32> signal;
|
||||
sleep_queue_t queue;
|
||||
|
||||
Cond(Mutex* mutex, u64 name)
|
||||
Cond(std::shared_ptr<Mutex>& mutex, u64 name)
|
||||
: mutex(mutex)
|
||||
, queue(name)
|
||||
{
|
||||
|
|
|
@ -14,11 +14,10 @@ SysCallBase sys_event("sys_event");
|
|||
|
||||
u32 event_queue_create(u32 protocol, s32 type, u64 name_u64, u64 event_queue_key, s32 size)
|
||||
{
|
||||
EventQueue* eq = new EventQueue(protocol, type, name_u64, event_queue_key, size);
|
||||
std::shared_ptr<EventQueue> eq(new EventQueue(protocol, type, name_u64, event_queue_key, size));
|
||||
|
||||
if (event_queue_key && !Emu.GetEventManager().RegisterKey(eq, event_queue_key))
|
||||
{
|
||||
delete eq;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -73,7 +72,7 @@ s32 sys_event_queue_destroy(u32 equeue_id, int mode)
|
|||
{
|
||||
sys_event.Todo("sys_event_queue_destroy(equeue_id=%d, mode=0x%x)", equeue_id, mode);
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!Emu.GetIdManager().GetIDData(equeue_id, eq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -119,7 +118,7 @@ s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr<sys_event_data> event_arra
|
|||
sys_event.Todo("sys_event_queue_tryreceive(equeue_id=%d, event_array_addr=0x%x, size=%d, number_addr=0x%x)",
|
||||
equeue_id, event_array.addr(), size, number.addr());
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!Emu.GetIdManager().GetIDData(equeue_id, eq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -159,7 +158,7 @@ s32 sys_event_queue_receive(u32 equeue_id, vm::ptr<sys_event_data> dummy_event,
|
|||
sys_event.Log("sys_event_queue_receive(equeue_id=%d, dummy_event_addr=0x%x, timeout=%lld)",
|
||||
equeue_id, dummy_event.addr(), timeout);
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!Emu.GetIdManager().GetIDData(equeue_id, eq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -236,7 +235,7 @@ s32 sys_event_queue_drain(u32 equeue_id)
|
|||
{
|
||||
sys_event.Log("sys_event_queue_drain(equeue_id=%d)", equeue_id);
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!Emu.GetIdManager().GetIDData(equeue_id, eq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -249,7 +248,7 @@ s32 sys_event_queue_drain(u32 equeue_id)
|
|||
|
||||
u32 event_port_create(u64 name)
|
||||
{
|
||||
EventPort* eport = new EventPort();
|
||||
std::shared_ptr<EventPort> eport(new EventPort());
|
||||
u32 id = sys_event.GetNewId(eport, TYPE_EVENT_PORT);
|
||||
eport->name = name ? name : ((u64)process_getpid() << 32) | (u64)id;
|
||||
sys_event.Warning("*** sys_event_port created: id = %d", id);
|
||||
|
@ -275,7 +274,7 @@ s32 sys_event_port_destroy(u32 eport_id)
|
|||
{
|
||||
sys_event.Warning("sys_event_port_destroy(eport_id=%d)", eport_id);
|
||||
|
||||
EventPort* eport;
|
||||
std::shared_ptr<EventPort> eport;
|
||||
if (!Emu.GetIdManager().GetIDData(eport_id, eport))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -301,7 +300,7 @@ s32 sys_event_port_connect_local(u32 eport_id, u32 equeue_id)
|
|||
{
|
||||
sys_event.Warning("sys_event_port_connect_local(eport_id=%d, equeue_id=%d)", eport_id, equeue_id);
|
||||
|
||||
EventPort* eport;
|
||||
std::shared_ptr<EventPort> eport;
|
||||
if (!Emu.GetIdManager().GetIDData(eport_id, eport))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -318,7 +317,7 @@ s32 sys_event_port_connect_local(u32 eport_id, u32 equeue_id)
|
|||
return CELL_EISCONN;
|
||||
}
|
||||
|
||||
EventQueue* equeue;
|
||||
std::shared_ptr<EventQueue> equeue;
|
||||
if (!Emu.GetIdManager().GetIDData(equeue_id, equeue))
|
||||
{
|
||||
sys_event.Error("sys_event_port_connect_local: event_queue(%d) not found!", equeue_id);
|
||||
|
@ -339,7 +338,7 @@ s32 sys_event_port_disconnect(u32 eport_id)
|
|||
{
|
||||
sys_event.Warning("sys_event_port_disconnect(eport_id=%d)", eport_id);
|
||||
|
||||
EventPort* eport;
|
||||
std::shared_ptr<EventPort> eport;
|
||||
if (!Emu.GetIdManager().GetIDData(eport_id, eport))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -366,7 +365,7 @@ s32 sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
|
|||
sys_event.Log("sys_event_port_send(eport_id=%d, data1=0x%llx, data2=0x%llx, data3=0x%llx)",
|
||||
eport_id, data1, data2, data3);
|
||||
|
||||
EventPort* eport;
|
||||
std::shared_ptr<EventPort> eport;
|
||||
if (!Emu.GetIdManager().GetIDData(eport_id, eport))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -374,7 +373,7 @@ s32 sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
|
|||
|
||||
std::lock_guard<std::mutex> lock(eport->m_mutex);
|
||||
|
||||
EventQueue* eq = eport->eq;
|
||||
std::shared_ptr<EventQueue> eq = eport->eq;
|
||||
if (!eq)
|
||||
{
|
||||
return CELL_ENOTCONN;
|
||||
|
|
|
@ -56,7 +56,7 @@ struct EventQueue;
|
|||
struct EventPort
|
||||
{
|
||||
u64 name; // generated or user-specified code that is passed to sys_event_data struct
|
||||
EventQueue* eq; // event queue this port has been connected to
|
||||
std::shared_ptr<EventQueue> eq; // event queue this port has been connected to
|
||||
std::mutex m_mutex; // may be locked until the event sending is finished
|
||||
|
||||
EventPort(u64 name = 0)
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
|
||||
class EventPortList
|
||||
{
|
||||
std::vector<EventPort*> data;
|
||||
std::vector<std::shared_ptr<EventPort>> data;
|
||||
std::mutex m_mutex;
|
||||
|
||||
public:
|
||||
|
@ -167,18 +167,18 @@ public:
|
|||
data.clear();
|
||||
}
|
||||
|
||||
void add(EventPort* port)
|
||||
void add(std::shared_ptr<EventPort>& port)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
data.push_back(port);
|
||||
}
|
||||
|
||||
void remove(EventPort* port)
|
||||
void remove(std::shared_ptr<EventPort>& port)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
for (u32 i = 0; i < data.size(); i++)
|
||||
{
|
||||
if (data[i] == port)
|
||||
if (data[i].get() == port.get())
|
||||
{
|
||||
data.erase(data.begin() + i);
|
||||
return;
|
||||
|
|
|
@ -74,7 +74,8 @@ s32 sys_event_flag_create(vm::ptr<u32> eflag_id, vm::ptr<sys_event_flag_attr> at
|
|||
default: return CELL_EINVAL;
|
||||
}
|
||||
|
||||
u32 id = sys_event_flag.GetNewId(new EventFlag(init, (u32)attr->protocol, (int)attr->type), TYPE_EVENT_FLAG);
|
||||
std::shared_ptr<EventFlag> ef(new EventFlag(init, (u32)attr->protocol, (int)attr->type));
|
||||
u32 id = sys_event_flag.GetNewId(ef, TYPE_EVENT_FLAG);
|
||||
*eflag_id = id;
|
||||
sys_event_flag.Warning("*** event_flag created [%s] (protocol=0x%x, type=0x%x): id = %d",
|
||||
std::string(attr->name, 8).c_str(), (u32)attr->protocol, (int)attr->type, id);
|
||||
|
@ -86,7 +87,7 @@ s32 sys_event_flag_destroy(u32 eflag_id)
|
|||
{
|
||||
sys_event_flag.Warning("sys_event_flag_destroy(eflag_id=%d)", eflag_id);
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH;
|
||||
|
||||
if (ef->waiters.size()) // ???
|
||||
|
@ -121,7 +122,7 @@ s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr<u64> result,
|
|||
default: return CELL_EINVAL;
|
||||
}
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH;
|
||||
|
||||
const u32 tid = GetCurrentPPUThread().GetId();
|
||||
|
@ -255,7 +256,7 @@ s32 sys_event_flag_trywait(u32 eflag_id, u64 bitptn, u32 mode, vm::ptr<u64> resu
|
|||
default: return CELL_EINVAL;
|
||||
}
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH;
|
||||
|
||||
std::lock_guard<std::mutex> lock(ef->mutex);
|
||||
|
@ -289,7 +290,7 @@ s32 sys_event_flag_set(u32 eflag_id, u64 bitptn)
|
|||
{
|
||||
sys_event_flag.Log("sys_event_flag_set(eflag_id=%d, bitptn=0x%llx)", eflag_id, bitptn);
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH;
|
||||
|
||||
std::lock_guard<std::mutex> lock(ef->mutex);
|
||||
|
@ -306,7 +307,7 @@ s32 sys_event_flag_clear(u32 eflag_id, u64 bitptn)
|
|||
{
|
||||
sys_event_flag.Log("sys_event_flag_clear(eflag_id=%d, bitptn=0x%llx)", eflag_id, bitptn);
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH;
|
||||
|
||||
std::lock_guard<std::mutex> lock(ef->mutex);
|
||||
|
@ -318,7 +319,7 @@ s32 sys_event_flag_cancel(u32 eflag_id, vm::ptr<u32> num)
|
|||
{
|
||||
sys_event_flag.Log("sys_event_flag_cancel(eflag_id=%d, num_addr=0x%x)", eflag_id, num.addr());
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH;
|
||||
|
||||
std::vector<u32> tids;
|
||||
|
@ -362,7 +363,7 @@ s32 sys_event_flag_get(u32 eflag_id, vm::ptr<u64> flags)
|
|||
return CELL_EFAULT;
|
||||
}
|
||||
|
||||
EventFlag* ef;
|
||||
std::shared_ptr<EventFlag> ef;
|
||||
if (!sys_event_flag.CheckId(eflag_id, ef)) return CELL_ESRCH;
|
||||
|
||||
*flags = ef->flags.read_sync();
|
||||
|
|
|
@ -60,7 +60,7 @@ s32 sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u64 intrthread,
|
|||
return CELL_ESTAT;
|
||||
}
|
||||
|
||||
CPUThread* it = Emu.GetCPU().GetThread(intrthread);
|
||||
std::shared_ptr<CPUThread> it = Emu.GetCPU().GetThread(intrthread);
|
||||
if (!it)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -80,7 +80,7 @@ s32 sys_interrupt_thread_disestablish(u32 ih)
|
|||
{
|
||||
sys_interrupt.Todo("sys_interrupt_thread_disestablish(ih=%d)", ih);
|
||||
|
||||
CPUThread* it = Emu.GetCPU().GetThread(ih);
|
||||
std::shared_ptr<CPUThread> it = Emu.GetCPU().GetThread(ih);
|
||||
if (!it)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
|
|
@ -17,7 +17,8 @@ s32 lwcond_create(sys_lwcond_t& lwcond, sys_lwmutex_t& lwmutex, u64 name_u64)
|
|||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
u32 id = sys_lwcond.GetNewId(new Lwcond(name_u64), TYPE_LWCOND);
|
||||
std::shared_ptr<Lwcond> lw(new Lwcond(name_u64));
|
||||
u32 id = sys_lwcond.GetNewId(lw, TYPE_LWCOND);
|
||||
u32 addr = Memory.RealToVirtualAddr(&lwmutex);
|
||||
lwcond.lwmutex.set(addr);
|
||||
lwcond.lwcond_queue = id;
|
||||
|
@ -48,7 +49,7 @@ s32 sys_lwcond_destroy(vm::ptr<sys_lwcond_t> lwcond)
|
|||
|
||||
u32 id = lwcond->lwcond_queue;
|
||||
|
||||
Lwcond* lw;
|
||||
std::shared_ptr<Lwcond> lw;
|
||||
if (!Emu.GetIdManager().GetIDData(id, lw))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -68,7 +69,7 @@ s32 sys_lwcond_signal(vm::ptr<sys_lwcond_t> lwcond)
|
|||
{
|
||||
sys_lwcond.Log("sys_lwcond_signal(lwcond_addr=0x%x)", lwcond.addr());
|
||||
|
||||
Lwcond* lw;
|
||||
std::shared_ptr<Lwcond> lw;
|
||||
if (!Emu.GetIdManager().GetIDData((u32)lwcond->lwcond_queue, lw))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -94,7 +95,7 @@ s32 sys_lwcond_signal_all(vm::ptr<sys_lwcond_t> lwcond)
|
|||
{
|
||||
sys_lwcond.Log("sys_lwcond_signal_all(lwcond_addr=0x%x)", lwcond.addr());
|
||||
|
||||
Lwcond* lw;
|
||||
std::shared_ptr<Lwcond> lw;
|
||||
if (!Emu.GetIdManager().GetIDData((u32)lwcond->lwcond_queue, lw))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -120,7 +121,7 @@ s32 sys_lwcond_signal_to(vm::ptr<sys_lwcond_t> lwcond, u32 ppu_thread_id)
|
|||
{
|
||||
sys_lwcond.Log("sys_lwcond_signal_to(lwcond_addr=0x%x, ppu_thread_id=%d)", lwcond.addr(), ppu_thread_id);
|
||||
|
||||
Lwcond* lw;
|
||||
std::shared_ptr<Lwcond> lw;
|
||||
if (!Emu.GetIdManager().GetIDData((u32)lwcond->lwcond_queue, lw))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -154,7 +155,7 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
|
|||
{
|
||||
sys_lwcond.Log("sys_lwcond_wait(lwcond_addr=0x%x, timeout=%lld)", lwcond.addr(), timeout);
|
||||
|
||||
Lwcond* lw;
|
||||
std::shared_ptr<Lwcond> lw;
|
||||
if (!Emu.GetIdManager().GetIDData((u32)lwcond->lwcond_queue, lw))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -164,8 +165,8 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
|
|||
u32 tid_le = CPU.GetId();
|
||||
be_t<u32> tid = be_t<u32>::make(tid_le);
|
||||
|
||||
sleep_queue_t* sq = nullptr;
|
||||
if (!Emu.GetIdManager().GetIDData((u32)mutex->sleep_queue, sq) && mutex->attribute.ToBE() != se32(SYS_SYNC_RETRY))
|
||||
std::shared_ptr<sleep_queue_t> sq;
|
||||
if (!Emu.GetIdManager().GetIDData((u32)mutex->sleep_queue, sq))
|
||||
{
|
||||
sys_lwcond.Warning("sys_lwcond_wait(id=%d): associated mutex had invalid sleep queue (%d)",
|
||||
(u32)lwcond->lwcond_queue, (u32)mutex->sleep_queue);
|
||||
|
@ -179,8 +180,8 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
|
|||
|
||||
lw->queue.push(tid_le, mutex->attribute);
|
||||
|
||||
auto old_recursive = mutex->recursive_count;
|
||||
mutex->recursive_count = 0;
|
||||
auto old_recursive = mutex->recursive_count.read_relaxed();
|
||||
mutex->recursive_count.exchange(be_t<u32>::make(0));
|
||||
|
||||
be_t<u32> target = be_t<u32>::make(sq->pop(mutex->attribute));
|
||||
if (!mutex->owner.compare_and_swap_test(tid, target))
|
||||
|
@ -254,7 +255,7 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
|
|||
}
|
||||
}
|
||||
|
||||
mutex->recursive_count = old_recursive;
|
||||
mutex->recursive_count.exchange(old_recursive);
|
||||
lw->signal.Pop(tid_le /* unused result */, nullptr);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,13 @@ s32 lwmutex_create(sys_lwmutex_t& lwmutex, u32 protocol, u32 recursive, u64 name
|
|||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
std::shared_ptr<sleep_queue_t> sq(new sleep_queue_t(name_u64));
|
||||
|
||||
lwmutex.owner.write_relaxed(be_t<u32>::make(0));
|
||||
lwmutex.waiter.write_relaxed(be_t<u32>::make(~0));
|
||||
lwmutex.attribute = protocol | recursive;
|
||||
lwmutex.recursive_count = 0;
|
||||
u32 sq_id = sys_lwmutex.GetNewId(new sleep_queue_t(name_u64), TYPE_LWMUTEX);
|
||||
lwmutex.recursive_count.write_relaxed(be_t<u32>::make(0));
|
||||
u32 sq_id = sys_lwmutex.GetNewId(sq, TYPE_LWMUTEX);
|
||||
lwmutex.sleep_queue = sq_id;
|
||||
|
||||
std::string name((const char*)&name_u64, 8);
|
||||
|
@ -101,17 +103,24 @@ s32 sys_lwmutex_t::trylock(be_t<u32> tid)
|
|||
{
|
||||
if (attribute.ToBE() == se32(0xDEADBEEF)) return CELL_EINVAL;
|
||||
|
||||
if (!Emu.GetIdManager().CheckID(sleep_queue))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
const be_t<u32> old_owner = owner.read_sync();
|
||||
|
||||
if (old_owner == tid)
|
||||
{
|
||||
if (attribute.ToBE() & se32(SYS_SYNC_RECURSIVE))
|
||||
{
|
||||
recursive_count += 1;
|
||||
if (!recursive_count.ToBE())
|
||||
auto rv = recursive_count.read_relaxed();
|
||||
if (!~(rv++).ToBE())
|
||||
{
|
||||
return CELL_EKRESOURCE;
|
||||
}
|
||||
|
||||
recursive_count.exchange(rv);
|
||||
return CELL_OK;
|
||||
}
|
||||
else
|
||||
|
@ -125,7 +134,7 @@ s32 sys_lwmutex_t::trylock(be_t<u32> tid)
|
|||
return CELL_EBUSY;
|
||||
}
|
||||
|
||||
recursive_count = 1;
|
||||
recursive_count.exchange(be_t<u32>::make(1));
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -136,16 +145,18 @@ s32 sys_lwmutex_t::unlock(be_t<u32> tid)
|
|||
return CELL_EPERM;
|
||||
}
|
||||
|
||||
if (!recursive_count || (recursive_count.ToBE() != se32(1) && (attribute.ToBE() & se32(SYS_SYNC_NOT_RECURSIVE))))
|
||||
auto rv = recursive_count.read_relaxed();
|
||||
if (!rv.ToBE() || (rv.ToBE() != se32(1) && (attribute.ToBE() & se32(SYS_SYNC_NOT_RECURSIVE))))
|
||||
{
|
||||
sys_lwmutex.Error("sys_lwmutex_t::unlock(%d): wrong recursive value fixed (%d)", (u32)sleep_queue, (u32)recursive_count);
|
||||
recursive_count = 1;
|
||||
sys_lwmutex.Error("sys_lwmutex_t::unlock(%d): wrong recursive value fixed (%d)", (u32)sleep_queue, (u32)rv);
|
||||
rv = 1;
|
||||
}
|
||||
|
||||
recursive_count -= 1;
|
||||
if (!recursive_count.ToBE())
|
||||
rv--;
|
||||
recursive_count.exchange(rv);
|
||||
if (!rv.ToBE())
|
||||
{
|
||||
sleep_queue_t* sq;
|
||||
std::shared_ptr<sleep_queue_t> sq;
|
||||
if (!Emu.GetIdManager().GetIDData(sleep_queue, sq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -168,7 +179,7 @@ s32 sys_lwmutex_t::lock(be_t<u32> tid, u64 timeout)
|
|||
default: return res;
|
||||
}
|
||||
|
||||
sleep_queue_t* sq;
|
||||
std::shared_ptr<sleep_queue_t> sq;
|
||||
if (!Emu.GetIdManager().GetIDData(sleep_queue, sq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -205,6 +216,6 @@ s32 sys_lwmutex_t::lock(be_t<u32> tid, u64 timeout)
|
|||
}
|
||||
}
|
||||
|
||||
recursive_count = 1;
|
||||
recursive_count.exchange(be_t<u32>::make(1));
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ struct sys_lwmutex_t
|
|||
atomic_t<u32> owner;
|
||||
atomic_t<u32> waiter; // currently not used
|
||||
be_t<u32> attribute;
|
||||
be_t<u32> recursive_count;
|
||||
atomic_t<u32> recursive_count;
|
||||
be_t<u32> sleep_queue;
|
||||
be_t<u32> pad;
|
||||
|
||||
|
|
|
@ -43,7 +43,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.
|
||||
MemoryContainerInfo* ct;
|
||||
std::shared_ptr<MemoryContainerInfo> ct;
|
||||
if (!sys_memory.CheckId(cid, ct))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -119,7 +119,7 @@ s32 sys_memory_container_create(vm::ptr<u32> cid, u32 yield_size)
|
|||
return CELL_ENOMEM;
|
||||
|
||||
// Wrap the allocated memory in a memory container.
|
||||
MemoryContainerInfo *ct = new MemoryContainerInfo(addr, yield_size);
|
||||
std::shared_ptr<MemoryContainerInfo> ct(new MemoryContainerInfo(addr, yield_size));
|
||||
u32 id = sys_memory.GetNewId(ct, TYPE_MEM);
|
||||
*cid = id;
|
||||
|
||||
|
@ -133,7 +133,7 @@ s32 sys_memory_container_destroy(u32 cid)
|
|||
sys_memory.Warning("sys_memory_container_destroy(cid=%d)", cid);
|
||||
|
||||
// Check if this container ID is valid.
|
||||
MemoryContainerInfo* ct;
|
||||
std::shared_ptr<MemoryContainerInfo> ct;
|
||||
if (!sys_memory.CheckId(cid, ct))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -149,7 +149,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=%d)", mem_info.addr(), cid);
|
||||
|
||||
// Check if this container ID is valid.
|
||||
MemoryContainerInfo* ct;
|
||||
std::shared_ptr<MemoryContainerInfo> ct;
|
||||
if (!sys_memory.CheckId(cid, ct))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr<u32> mem_id)
|
|||
}
|
||||
|
||||
// Generate a new mem ID.
|
||||
*mem_id = sys_mmapper.GetNewId(new mmapper_info(size, flags));
|
||||
std::shared_ptr<mmapper_info> info(new mmapper_info(size, flags));
|
||||
*mem_id = sys_mmapper.GetNewId(info);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -86,7 +87,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.
|
||||
MemoryContainerInfo* ct;
|
||||
std::shared_ptr<MemoryContainerInfo> ct;
|
||||
if(!sys_mmapper.CheckId(cid, ct))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -110,7 +111,8 @@ s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm:
|
|||
ct->size = size;
|
||||
|
||||
// Generate a new mem ID.
|
||||
*mem_id = sys_mmapper.GetNewId(new mmapper_info(ct->size, flags), TYPE_MEM);
|
||||
std::shared_ptr<mmapper_info> info(new mmapper_info(ct->size, flags));
|
||||
*mem_id = sys_mmapper.GetNewId(info, TYPE_MEM);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -138,7 +140,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.
|
||||
mmapper_info* info;
|
||||
std::shared_ptr<mmapper_info> info;
|
||||
if(!sys_mmapper.CheckId(mem_id, info))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -153,7 +155,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.
|
||||
mmapper_info* info;
|
||||
std::shared_ptr<mmapper_info> info;
|
||||
if(!sys_mmapper.CheckId(mem_id, info))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -173,7 +175,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.
|
||||
mmapper_info* info;
|
||||
std::shared_ptr<mmapper_info> info;
|
||||
if(!sys_mmapper.CheckId(mem_id, info))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ Mutex::~Mutex()
|
|||
{
|
||||
if (u32 tid = owner.read_sync())
|
||||
{
|
||||
sys_mutex.Notice("Mutex(%d) was owned by thread %d (recursive=%d)", id, tid, recursive);
|
||||
sys_mutex.Notice("Mutex(%d) was owned by thread %d (recursive=%d)", id, tid, recursive_count.load());
|
||||
}
|
||||
|
||||
if (!queue.m_mutex.try_lock()) return;
|
||||
|
@ -61,7 +61,7 @@ s32 sys_mutex_create(PPUThread& CPU, vm::ptr<u32> mutex_id, vm::ptr<sys_mutex_at
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
Mutex* mutex = new Mutex((u32)attr->protocol, is_recursive, attr->name_u64);
|
||||
std::shared_ptr<Mutex> mutex(new Mutex((u32)attr->protocol, is_recursive, attr->name_u64));
|
||||
const u32 id = sys_mutex.GetNewId(mutex, TYPE_MUTEX);
|
||||
mutex->id.exchange(id);
|
||||
*mutex_id = id;
|
||||
|
@ -80,7 +80,7 @@ s32 sys_mutex_destroy(PPUThread& CPU, u32 mutex_id)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
Mutex* mutex;
|
||||
std::shared_ptr<Mutex> mutex;
|
||||
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -120,7 +120,7 @@ s32 sys_mutex_lock(PPUThread& CPU, u32 mutex_id, u64 timeout)
|
|||
{
|
||||
sys_mutex.Log("sys_mutex_lock(mutex_id=%d, timeout=%lld)", mutex_id, timeout);
|
||||
|
||||
Mutex* mutex;
|
||||
std::shared_ptr<Mutex> mutex;
|
||||
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -132,10 +132,11 @@ s32 sys_mutex_lock(PPUThread& CPU, u32 mutex_id, u64 timeout)
|
|||
{
|
||||
if (mutex->is_recursive)
|
||||
{
|
||||
if (!++mutex->recursive)
|
||||
if (!~mutex->recursive_count)
|
||||
{
|
||||
return CELL_EKRESOURCE;
|
||||
}
|
||||
mutex->recursive_count++;
|
||||
return CELL_OK;
|
||||
}
|
||||
else
|
||||
|
@ -146,7 +147,7 @@ s32 sys_mutex_lock(PPUThread& CPU, u32 mutex_id, u64 timeout)
|
|||
|
||||
if (mutex->owner.compare_and_swap_test(0, tid))
|
||||
{
|
||||
mutex->recursive = 1;
|
||||
mutex->recursive_count = 1;
|
||||
CPU.owned_mutexes++;
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -182,7 +183,7 @@ s32 sys_mutex_lock(PPUThread& CPU, u32 mutex_id, u64 timeout)
|
|||
}
|
||||
}
|
||||
|
||||
mutex->recursive = 1;
|
||||
mutex->recursive_count = 1;
|
||||
CPU.owned_mutexes++;
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -191,7 +192,7 @@ s32 sys_mutex_trylock(PPUThread& CPU, u32 mutex_id)
|
|||
{
|
||||
sys_mutex.Log("sys_mutex_trylock(mutex_id=%d)", mutex_id);
|
||||
|
||||
Mutex* mutex;
|
||||
std::shared_ptr<Mutex> mutex;
|
||||
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -203,10 +204,11 @@ s32 sys_mutex_trylock(PPUThread& CPU, u32 mutex_id)
|
|||
{
|
||||
if (mutex->is_recursive)
|
||||
{
|
||||
if (!++mutex->recursive)
|
||||
if (!~mutex->recursive_count)
|
||||
{
|
||||
return CELL_EKRESOURCE;
|
||||
}
|
||||
mutex->recursive_count++;
|
||||
return CELL_OK;
|
||||
}
|
||||
else
|
||||
|
@ -220,7 +222,7 @@ s32 sys_mutex_trylock(PPUThread& CPU, u32 mutex_id)
|
|||
return CELL_EBUSY;
|
||||
}
|
||||
|
||||
mutex->recursive = 1;
|
||||
mutex->recursive_count = 1;
|
||||
CPU.owned_mutexes++;
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -229,7 +231,7 @@ s32 sys_mutex_unlock(PPUThread& CPU, u32 mutex_id)
|
|||
{
|
||||
sys_mutex.Log("sys_mutex_unlock(mutex_id=%d)", mutex_id);
|
||||
|
||||
Mutex* mutex;
|
||||
std::shared_ptr<Mutex> mutex;
|
||||
if (!Emu.GetIdManager().GetIDData(mutex_id, mutex))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -242,13 +244,13 @@ s32 sys_mutex_unlock(PPUThread& CPU, u32 mutex_id)
|
|||
return CELL_EPERM;
|
||||
}
|
||||
|
||||
if (!mutex->recursive || (mutex->recursive != 1 && !mutex->is_recursive))
|
||||
if (!mutex->recursive_count || (mutex->recursive_count != 1 && !mutex->is_recursive))
|
||||
{
|
||||
sys_mutex.Error("sys_mutex_unlock(%d): wrong recursive value fixed (%d)", mutex_id, mutex->recursive);
|
||||
mutex->recursive = 1;
|
||||
sys_mutex.Error("sys_mutex_unlock(%d): wrong recursive value fixed (%d)", mutex_id, mutex->recursive_count.load());
|
||||
mutex->recursive_count = 1;
|
||||
}
|
||||
|
||||
if (!--mutex->recursive)
|
||||
if (!--mutex->recursive_count)
|
||||
{
|
||||
if (!mutex->owner.compare_and_swap_test(tid, mutex->queue.pop(mutex->protocol)))
|
||||
{
|
||||
|
|
|
@ -20,9 +20,9 @@ struct Mutex
|
|||
{
|
||||
atomic_le_t<u32> id;
|
||||
atomic_le_t<u32> owner;
|
||||
sleep_queue_t queue;
|
||||
u32 recursive; // recursive locks count
|
||||
std::atomic<u32> recursive_count; // recursive locks count
|
||||
std::atomic<u32> cond_count; // count of condition variables associated
|
||||
sleep_queue_t queue;
|
||||
|
||||
const u32 protocol;
|
||||
const bool is_recursive;
|
||||
|
|
|
@ -51,7 +51,7 @@ s32 sys_ppu_thread_join(u64 thread_id, vm::ptr<u64> vptr)
|
|||
{
|
||||
sys_ppu_thread.Warning("sys_ppu_thread_join(thread_id=%lld, vptr_addr=0x%x)", thread_id, vptr.addr());
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if(!thr) return CELL_ESRCH;
|
||||
|
||||
while (thr->IsAlive())
|
||||
|
@ -72,7 +72,7 @@ s32 sys_ppu_thread_detach(u64 thread_id)
|
|||
{
|
||||
sys_ppu_thread.Todo("sys_ppu_thread_detach(thread_id=%lld)", thread_id);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if(!thr) return CELL_ESRCH;
|
||||
|
||||
if(!thr->IsJoinable())
|
||||
|
@ -93,7 +93,7 @@ s32 sys_ppu_thread_set_priority(u64 thread_id, s32 prio)
|
|||
{
|
||||
sys_ppu_thread.Log("sys_ppu_thread_set_priority(thread_id=%lld, prio=%d)", thread_id, prio);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if(!thr) return CELL_ESRCH;
|
||||
|
||||
thr->SetPrio(prio);
|
||||
|
@ -105,7 +105,7 @@ s32 sys_ppu_thread_get_priority(u64 thread_id, u32 prio_addr)
|
|||
{
|
||||
sys_ppu_thread.Log("sys_ppu_thread_get_priority(thread_id=%lld, prio_addr=0x%x)", thread_id, prio_addr);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if(!thr) return CELL_ESRCH;
|
||||
|
||||
vm::write32(prio_addr, (s32)thr->GetPrio());
|
||||
|
@ -127,7 +127,7 @@ s32 sys_ppu_thread_stop(u64 thread_id)
|
|||
{
|
||||
sys_ppu_thread.Warning("sys_ppu_thread_stop(thread_id=%lld)", thread_id);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if(!thr) return CELL_ESRCH;
|
||||
|
||||
thr->Stop();
|
||||
|
@ -139,7 +139,7 @@ s32 sys_ppu_thread_restart(u64 thread_id)
|
|||
{
|
||||
sys_ppu_thread.Warning("sys_ppu_thread_restart(thread_id=%lld)", thread_id);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if(!thr) return CELL_ESRCH;
|
||||
|
||||
thr->Stop();
|
||||
|
@ -233,7 +233,7 @@ s32 sys_ppu_thread_rename(u64 thread_id, vm::ptr<const char> name)
|
|||
{
|
||||
sys_ppu_thread.Log("sys_ppu_thread_rename(thread_id=%d, name_addr=0x%x('%s'))", thread_id, name.addr(), name.get_ptr());
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if (!thr) {
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
|
|
@ -196,31 +196,31 @@ 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.Warning("sys_process_get_number_of_object(object=%d, nump_addr=0x%x)",
|
||||
sys_process.Todo("sys_process_get_number_of_object(object=%d, nump_addr=0x%x)",
|
||||
object, nump.addr());
|
||||
|
||||
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_FS_FD_OBJECT:
|
||||
*nump = Emu.GetIdManager().GetTypeCount(TYPE_FS_FILE) + Emu.GetIdManager().GetTypeCount(TYPE_FS_DIR);
|
||||
break;
|
||||
//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_FS_FD_OBJECT:
|
||||
// *nump = Emu.GetIdManager().GetTypeCount(TYPE_FS_FILE) + Emu.GetIdManager().GetTypeCount(TYPE_FS_DIR);
|
||||
// break;
|
||||
|
||||
default:
|
||||
return CELL_EINVAL;
|
||||
|
@ -245,24 +245,24 @@ s32 sys_process_get_id(u32 object, vm::ptr<u32> buffer, u32 size, vm::ptr<u32> s
|
|||
*set_size = i; \
|
||||
}
|
||||
|
||||
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;
|
||||
//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
|
||||
|
||||
|
|
|
@ -31,7 +31,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
|
||||
sys_prx_t* prx = new sys_prx_t();
|
||||
std::shared_ptr<sys_prx_t> prx(new sys_prx_t());
|
||||
prx->size = (u32)f.GetSize();
|
||||
prx->address = (u32)Memory.Alloc(prx->size, 4);
|
||||
prx->path = (const char*)path;
|
||||
|
@ -66,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=%d, args=%d, argp_addr=0x%x, modres_addr=0x%x, flags=0x%llx, pOpt=0x%x)",
|
||||
id, args, argp_addr, modres.addr(), flags, pOpt.addr());
|
||||
|
||||
sys_prx_t* prx;
|
||||
std::shared_ptr<sys_prx_t> prx;
|
||||
if (!Emu.GetIdManager().GetIDData(id, prx))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -81,7 +81,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=%d, args=%d, argp_addr=0x%x, modres_addr=0x%x, flags=0x%llx, pOpt=0x%x)",
|
||||
id, args, argp_addr, modres.addr(), flags, pOpt.addr());
|
||||
|
||||
sys_prx_t* prx;
|
||||
std::shared_ptr<sys_prx_t> prx;
|
||||
if (!Emu.GetIdManager().GetIDData(id, prx))
|
||||
return CELL_ESRCH;
|
||||
|
||||
|
@ -96,7 +96,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=%d, flags=0x%llx, pOpt=0x%x)", id, flags, pOpt.addr());
|
||||
|
||||
// Get the PRX, free the used memory and delete the object and its ID
|
||||
sys_prx_t* prx;
|
||||
std::shared_ptr<sys_prx_t> prx;
|
||||
if (!Emu.GetIdManager().GetIDData(id, prx))
|
||||
return CELL_ESRCH;
|
||||
Memory.Free(prx->address);
|
||||
|
|
|
@ -32,7 +32,8 @@ s32 sys_rwlock_create(vm::ptr<u32> rw_lock_id, vm::ptr<sys_rwlock_attribute_t> a
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
u32 id = sys_rwlock.GetNewId(new RWLock((u32)attr->attr_protocol, attr->name_u64), TYPE_RWLOCK);
|
||||
std::shared_ptr<RWLock> rw(new RWLock((u32)attr->attr_protocol, attr->name_u64));
|
||||
u32 id = sys_rwlock.GetNewId(rw, TYPE_RWLOCK);
|
||||
*rw_lock_id = id;
|
||||
|
||||
sys_rwlock.Warning("*** rwlock created [%s] (protocol=0x%x): id = %d",
|
||||
|
@ -45,7 +46,7 @@ s32 sys_rwlock_destroy(u32 rw_lock_id)
|
|||
{
|
||||
sys_rwlock.Warning("sys_rwlock_destroy(rw_lock_id=%d)", rw_lock_id);
|
||||
|
||||
RWLock* rw;
|
||||
std::shared_ptr<RWLock> rw;
|
||||
if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH;
|
||||
|
||||
std::lock_guard<std::mutex> lock(rw->m_lock);
|
||||
|
@ -61,7 +62,7 @@ s32 sys_rwlock_rlock(u32 rw_lock_id, u64 timeout)
|
|||
{
|
||||
sys_rwlock.Log("sys_rwlock_rlock(rw_lock_id=%d, timeout=%lld)", rw_lock_id, timeout);
|
||||
|
||||
RWLock* rw;
|
||||
std::shared_ptr<RWLock> rw;
|
||||
if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH;
|
||||
const u32 tid = GetCurrentPPUThread().GetId();
|
||||
|
||||
|
@ -98,7 +99,7 @@ s32 sys_rwlock_tryrlock(u32 rw_lock_id)
|
|||
{
|
||||
sys_rwlock.Log("sys_rwlock_tryrlock(rw_lock_id=%d)", rw_lock_id);
|
||||
|
||||
RWLock* rw;
|
||||
std::shared_ptr<RWLock> rw;
|
||||
if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH;
|
||||
|
||||
if (!rw->rlock_trylock(GetCurrentPPUThread().GetId())) return CELL_EBUSY;
|
||||
|
@ -110,7 +111,7 @@ s32 sys_rwlock_runlock(u32 rw_lock_id)
|
|||
{
|
||||
sys_rwlock.Log("sys_rwlock_runlock(rw_lock_id=%d)", rw_lock_id);
|
||||
|
||||
RWLock* rw;
|
||||
std::shared_ptr<RWLock> rw;
|
||||
if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH;
|
||||
|
||||
if (!rw->rlock_unlock(GetCurrentPPUThread().GetId())) return CELL_EPERM;
|
||||
|
@ -122,7 +123,7 @@ s32 sys_rwlock_wlock(u32 rw_lock_id, u64 timeout)
|
|||
{
|
||||
sys_rwlock.Log("sys_rwlock_wlock(rw_lock_id=%d, timeout=%lld)", rw_lock_id, timeout);
|
||||
|
||||
RWLock* rw;
|
||||
std::shared_ptr<RWLock> rw;
|
||||
if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH;
|
||||
const u32 tid = GetCurrentPPUThread().GetId();
|
||||
|
||||
|
@ -161,7 +162,7 @@ s32 sys_rwlock_trywlock(u32 rw_lock_id)
|
|||
{
|
||||
sys_rwlock.Log("sys_rwlock_trywlock(rw_lock_id=%d)", rw_lock_id);
|
||||
|
||||
RWLock* rw;
|
||||
std::shared_ptr<RWLock> rw;
|
||||
if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH;
|
||||
const u32 tid = GetCurrentPPUThread().GetId();
|
||||
|
||||
|
@ -176,7 +177,7 @@ s32 sys_rwlock_wunlock(u32 rw_lock_id)
|
|||
{
|
||||
sys_rwlock.Log("sys_rwlock_wunlock(rw_lock_id=%d)", rw_lock_id);
|
||||
|
||||
RWLock* rw;
|
||||
std::shared_ptr<RWLock> rw;
|
||||
if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH;
|
||||
|
||||
if (!rw->wlock_unlock(GetCurrentPPUThread().GetId())) return CELL_EPERM;
|
||||
|
|
|
@ -16,8 +16,9 @@ u32 semaphore_create(s32 initial_count, s32 max_count, u32 protocol, u64 name_u6
|
|||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
std::shared_ptr<Semaphore> sem(new Semaphore(initial_count, max_count, protocol, name_u64));
|
||||
const std::string name((const char*)&name_u64, 8);
|
||||
const u32 id = sys_semaphore.GetNewId(new Semaphore(initial_count, max_count, protocol, name_u64), TYPE_SEMAPHORE);
|
||||
const u32 id = sys_semaphore.GetNewId(sem, TYPE_SEMAPHORE);
|
||||
sys_semaphore.Notice("*** semaphore created [%s] (protocol=0x%x): id = %d", name.c_str(), protocol, id);
|
||||
Emu.GetSyncPrimManager().AddSemaphoreData(id, name, initial_count, max_count);
|
||||
return id;
|
||||
|
@ -69,7 +70,7 @@ s32 sys_semaphore_destroy(u32 sem_id)
|
|||
|
||||
LV2_LOCK(0);
|
||||
|
||||
Semaphore* sem;
|
||||
std::shared_ptr<Semaphore> sem;
|
||||
if (!Emu.GetIdManager().GetIDData(sem_id, sem))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -89,7 +90,7 @@ s32 sys_semaphore_wait(u32 sem_id, u64 timeout)
|
|||
{
|
||||
sys_semaphore.Log("sys_semaphore_wait(sem_id=%d, timeout=%lld)", sem_id, timeout);
|
||||
|
||||
Semaphore* sem;
|
||||
std::shared_ptr<Semaphore> sem;
|
||||
if (!Emu.GetIdManager().GetIDData(sem_id, sem))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -142,7 +143,7 @@ s32 sys_semaphore_trywait(u32 sem_id)
|
|||
{
|
||||
sys_semaphore.Log("sys_semaphore_trywait(sem_id=%d)", sem_id);
|
||||
|
||||
Semaphore* sem;
|
||||
std::shared_ptr<Semaphore> sem;
|
||||
if (!Emu.GetIdManager().GetIDData(sem_id, sem))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -165,7 +166,7 @@ s32 sys_semaphore_post(u32 sem_id, s32 count)
|
|||
{
|
||||
sys_semaphore.Log("sys_semaphore_post(sem_id=%d, count=%d)", sem_id, count);
|
||||
|
||||
Semaphore* sem;
|
||||
std::shared_ptr<Semaphore> sem;
|
||||
if (!Emu.GetIdManager().GetIDData(sem_id, sem))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -216,12 +217,13 @@ s32 sys_semaphore_get_value(u32 sem_id, vm::ptr<s32> count)
|
|||
{
|
||||
sys_semaphore.Log("sys_semaphore_get_value(sem_id=%d, count_addr=0x%x)", sem_id, count.addr());
|
||||
|
||||
if (count.addr() == NULL) {
|
||||
sys_semaphore.Error("sys_semaphore_get_value(): invalid memory access (count=0x%x)", count.addr());
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
if (!count)
|
||||
{
|
||||
sys_semaphore.Error("sys_semaphore_get_value(): invalid memory access (count=0x%x)", count.addr());
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
|
||||
Semaphore* sem;
|
||||
std::shared_ptr<Semaphore> sem;
|
||||
if (!Emu.GetIdManager().GetIDData(sem_id, sem))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
|
|
@ -78,7 +78,7 @@ s32 sys_spu_image_open(vm::ptr<sys_spu_image> img, vm::ptr<const char> path)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
SPUThread* spu_thread_initialize(SpuGroupInfo* group, u32 spu_num, sys_spu_image& img, const std::string& name, u32 option, u64 a1, u64 a2, u64 a3, u64 a4, std::function<void(SPUThread&)> task)
|
||||
SPUThread* spu_thread_initialize(std::shared_ptr<SpuGroupInfo>& group, u32 spu_num, sys_spu_image& img, const std::string& name, u32 option, u64 a1, u64 a2, u64 a3, u64 a4, std::function<void(SPUThread&)> task)
|
||||
{
|
||||
if (option)
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ s32 sys_spu_thread_initialize(vm::ptr<u32> thread, u32 group, u32 spu_num, vm::p
|
|||
sys_spu.Warning("sys_spu_thread_initialize(thread_addr=0x%x, group=0x%x, spu_num=%d, img_addr=0x%x, attr_addr=0x%x, arg_addr=0x%x)",
|
||||
thread.addr(), group, spu_num, img.addr(), attr.addr(), arg.addr());
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if(!Emu.GetIdManager().GetIDData(group, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -150,14 +150,14 @@ s32 sys_spu_thread_set_argument(u32 id, vm::ptr<sys_spu_thread_argument> arg)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_set_argument(id=%d, arg_addr=0x%x)", id, arg.addr());
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
SPUThread& spu = *(SPUThread*)thr;
|
||||
SPUThread& spu = *(SPUThread*)thr.get();
|
||||
|
||||
spu.GPR[3] = u128::from64(0, arg->arg1);
|
||||
spu.GPR[4] = u128::from64(0, arg->arg2);
|
||||
|
@ -171,7 +171,7 @@ s32 sys_spu_thread_get_exit_status(u32 id, vm::ptr<u32> status)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_get_exit_status(id=%d, status_addr=0x%x)", id, status.addr());
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ s32 sys_spu_thread_get_exit_status(u32 id, vm::ptr<u32> status)
|
|||
}
|
||||
|
||||
u32 res;
|
||||
if (!(*(SPUThread*)thr).SPU.Out_MBox.Pop(res) || !thr->IsStopped())
|
||||
if (!(*(SPUThread*)thr.get()).SPU.Out_MBox.Pop(res) || !thr->IsStopped())
|
||||
{
|
||||
return CELL_ESTAT;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ s32 sys_spu_thread_group_destroy(u32 id)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_group_destroy(id=%d)", id);
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if(!Emu.GetIdManager().GetIDData(id, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -215,10 +215,10 @@ s32 sys_spu_thread_group_destroy(u32 id)
|
|||
for (u32 i = 0; i < group_info->list.size(); i++)
|
||||
{
|
||||
// TODO: disconnect all event ports
|
||||
CPUThread* t = Emu.GetCPU().GetThread(group_info->list[i]);
|
||||
std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(group_info->list[i]);
|
||||
if (t)
|
||||
{
|
||||
Memory.Free(((SPUThread*)t)->GetOffset());
|
||||
Memory.Free(((SPUThread*)t.get())->GetOffset());
|
||||
Emu.GetCPU().RemoveThread(group_info->list[i]);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ s32 sys_spu_thread_group_start(u32 id)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_group_start(id=%d)", id);
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if(!Emu.GetIdManager().GetIDData(id, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -252,10 +252,10 @@ s32 sys_spu_thread_group_start(u32 id)
|
|||
|
||||
for (u32 i = 0; i < group_info->list.size(); i++)
|
||||
{
|
||||
CPUThread* t = Emu.GetCPU().GetThread(group_info->list[i]);
|
||||
std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(group_info->list[i]);
|
||||
if (t)
|
||||
{
|
||||
((SPUThread*)t)->SPU.Status.SetValue(SPU_STATUS_RUNNING);
|
||||
((SPUThread*)t.get())->SPU.Status.SetValue(SPU_STATUS_RUNNING);
|
||||
t->Exec();
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ s32 sys_spu_thread_group_suspend(u32 id)
|
|||
{
|
||||
sys_spu.Log("sys_spu_thread_group_suspend(id=%d)", id);
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if(!Emu.GetIdManager().GetIDData(id, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -291,7 +291,7 @@ s32 sys_spu_thread_group_suspend(u32 id)
|
|||
|
||||
for (u32 i = 0; i < group_info->list.size(); i++)
|
||||
{
|
||||
if (CPUThread* t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
if (std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
{
|
||||
t->Pause();
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ s32 sys_spu_thread_group_resume(u32 id)
|
|||
{
|
||||
sys_spu.Log("sys_spu_thread_group_resume(id=%d)", id);
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if(!Emu.GetIdManager().GetIDData(id, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -344,7 +344,7 @@ s32 sys_spu_thread_group_resume(u32 id)
|
|||
|
||||
for (u32 i = 0; i < group_info->list.size(); i++)
|
||||
{
|
||||
if (CPUThread* t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
if (std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
{
|
||||
t->Resume();
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ s32 sys_spu_thread_group_yield(u32 id)
|
|||
{
|
||||
sys_spu.Error("sys_spu_thread_group_yield(id=%d)", id);
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if (!Emu.GetIdManager().GetIDData(id, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -405,7 +405,7 @@ s32 sys_spu_thread_group_terminate(u32 id, int value)
|
|||
{
|
||||
sys_spu.Error("sys_spu_thread_group_terminate(id=%d, value=%d)", id, value);
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if (!Emu.GetIdManager().GetIDData(id, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -425,9 +425,9 @@ s32 sys_spu_thread_group_terminate(u32 id, int value)
|
|||
//SET BUSY
|
||||
for (u32 i = 0; i < group_info->list.size(); i++)
|
||||
{
|
||||
if (CPUThread* t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
if (std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
{
|
||||
((SPUThread*)t)->SPU.Status.SetValue(SPU_STATUS_STOPPED);
|
||||
((SPUThread*)t.get())->SPU.Status.SetValue(SPU_STATUS_STOPPED);
|
||||
t->Stop();
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ s32 sys_spu_thread_group_terminate(u32 id, int value)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
SpuGroupInfo* spu_thread_group_create(const std::string& name, u32 num, s32 prio, s32 type, u32 container)
|
||||
std::shared_ptr<SpuGroupInfo> spu_thread_group_create(const std::string& name, u32 num, s32 prio, s32 type, u32 container)
|
||||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
|
@ -449,7 +449,7 @@ SpuGroupInfo* spu_thread_group_create(const std::string& name, u32 num, s32 prio
|
|||
sys_spu.Todo("Unsupported SPU Thread Group type (0x%x)", type);
|
||||
}
|
||||
|
||||
auto group = new SpuGroupInfo(name, num, prio, type, container);
|
||||
std::shared_ptr<SpuGroupInfo> group(new SpuGroupInfo(name, num, prio, type, container));
|
||||
const u32 _id = sys_spu.GetNewId(group);
|
||||
group->m_id = _id;
|
||||
sys_spu.Notice("*** SPU Thread Group created [%s] (num=%d, prio=%d, type=0x%x, container=%d): id=%d",
|
||||
|
@ -475,7 +475,7 @@ s32 sys_spu_thread_group_join(u32 id, vm::ptr<u32> cause, vm::ptr<u32> status)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_group_join(id=%d, cause_addr=0x%x, status_addr=0x%x)", id, cause.addr(), status.addr());
|
||||
|
||||
SpuGroupInfo* group_info;
|
||||
std::shared_ptr<SpuGroupInfo> group_info;
|
||||
if(!Emu.GetIdManager().GetIDData(id, group_info))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -489,11 +489,11 @@ s32 sys_spu_thread_group_join(u32 id, vm::ptr<u32> cause, vm::ptr<u32> status)
|
|||
bool all_threads_exit = true;
|
||||
for (u32 i = 0; i < group_info->list.size(); i++)
|
||||
{
|
||||
while (CPUThread* t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
while (std::shared_ptr<CPUThread> t = Emu.GetCPU().GetThread(group_info->list[i]))
|
||||
{
|
||||
if (!t->IsAlive())
|
||||
{
|
||||
if (((SPUThread*)t)->SPU.Status.GetValue() != SPU_STATUS_STOPPED_BY_STOP)
|
||||
if (((SPUThread*)t.get())->SPU.Status.GetValue() != SPU_STATUS_STOPPED_BY_STOP)
|
||||
{
|
||||
all_threads_exit = false;
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ s32 sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type)
|
|||
sys_spu.Log("sys_spu_thread_write_ls(id=%d, address=0x%x, value=0x%llx, type=0x%x)",
|
||||
id, address, value, type);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
|
@ -567,10 +567,10 @@ s32 sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type)
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case 1: (*(SPUThread*)thr).WriteLS8(address, (u8)value); return CELL_OK;
|
||||
case 2: (*(SPUThread*)thr).WriteLS16(address, (u16)value); return CELL_OK;
|
||||
case 4: (*(SPUThread*)thr).WriteLS32(address, (u32)value); return CELL_OK;
|
||||
case 8: (*(SPUThread*)thr).WriteLS64(address, value); return CELL_OK;
|
||||
case 1: (*(SPUThread*)thr.get()).WriteLS8(address, (u8)value); return CELL_OK;
|
||||
case 2: (*(SPUThread*)thr.get()).WriteLS16(address, (u16)value); return CELL_OK;
|
||||
case 4: (*(SPUThread*)thr.get()).WriteLS32(address, (u32)value); return CELL_OK;
|
||||
case 8: (*(SPUThread*)thr.get()).WriteLS64(address, value); return CELL_OK;
|
||||
default: return CELL_EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ s32 sys_spu_thread_read_ls(u32 id, u32 address, vm::ptr<u64> value, u32 type)
|
|||
sys_spu.Log("sys_spu_thread_read_ls(id=%d, address=0x%x, value_addr=0x%x, type=0x%x)",
|
||||
id, address, value.addr(), type);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
|
@ -599,10 +599,10 @@ s32 sys_spu_thread_read_ls(u32 id, u32 address, vm::ptr<u64> value, u32 type)
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case 1: *value = (*(SPUThread*)thr).ReadLS8(address); return CELL_OK;
|
||||
case 2: *value = (*(SPUThread*)thr).ReadLS16(address); return CELL_OK;
|
||||
case 4: *value = (*(SPUThread*)thr).ReadLS32(address); return CELL_OK;
|
||||
case 8: *value = (*(SPUThread*)thr).ReadLS64(address); return CELL_OK;
|
||||
case 1: *value = (*(SPUThread*)thr.get()).ReadLS8(address); return CELL_OK;
|
||||
case 2: *value = (*(SPUThread*)thr.get()).ReadLS16(address); return CELL_OK;
|
||||
case 4: *value = (*(SPUThread*)thr.get()).ReadLS32(address); return CELL_OK;
|
||||
case 8: *value = (*(SPUThread*)thr.get()).ReadLS64(address); return CELL_OK;
|
||||
default: return CELL_EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -611,14 +611,14 @@ s32 sys_spu_thread_write_spu_mb(u32 id, u32 value)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_write_spu_mb(id=%d, value=0x%x)", id, value);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
(*(SPUThread*)thr).SPU.In_MBox.PushUncond(value);
|
||||
(*(SPUThread*)thr.get()).SPU.In_MBox.PushUncond(value);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ s32 sys_spu_thread_set_spu_cfg(u32 id, u64 value)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_set_spu_cfg(id=%d, value=0x%x)", id, value);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
|
@ -639,7 +639,7 @@ s32 sys_spu_thread_set_spu_cfg(u32 id, u64 value)
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
(*(SPUThread*)thr).cfg.value = value;
|
||||
(*(SPUThread*)thr.get()).cfg.value = value;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -648,14 +648,14 @@ s32 sys_spu_thread_get_spu_cfg(u32 id, vm::ptr<u64> value)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_get_spu_cfg(id=%d, value_addr=0x%x)", id, value.addr());
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
*value = (*(SPUThread*)thr).cfg.value;
|
||||
*value = (*(SPUThread*)thr.get()).cfg.value;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -663,7 +663,8 @@ s32 sys_spu_thread_get_spu_cfg(u32 id, vm::ptr<u64> value)
|
|||
s32 sys_spu_thread_write_snr(u32 id, u32 number, u32 value)
|
||||
{
|
||||
sys_spu.Log("sys_spu_thread_write_snr(id=%d, number=%d, value=0x%x)", id, number, value);
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
|
@ -675,7 +676,7 @@ s32 sys_spu_thread_write_snr(u32 id, u32 number, u32 value)
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
(*(SPUThread*)thr).WriteSNR(number ? true : false, value);
|
||||
(*(SPUThread*)thr.get()).WriteSNR(number ? true : false, value);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -706,14 +707,14 @@ s32 sys_spu_thread_connect_event(u32 id, u32 eq_id, u32 et, u8 spup)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_connect_event(id=%d, eq_id=%d, event_type=0x%x, spup=%d)", id, eq_id, et, spup);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!Emu.GetIdManager().GetIDData(eq_id, eq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -733,19 +734,19 @@ s32 sys_spu_thread_connect_event(u32 id, u32 eq_id, u32 et, u8 spup)
|
|||
|
||||
// TODO: check if can receive these events
|
||||
|
||||
SPUThread& spu = *(SPUThread*)thr;
|
||||
SPUThread& spu = *(SPUThread*)thr.get();
|
||||
|
||||
EventPort& port = spu.SPUPs[spup];
|
||||
std::shared_ptr<EventPort> port = spu.SPUPs[spup];
|
||||
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
std::lock_guard<std::mutex> lock(port->m_mutex);
|
||||
|
||||
if (port.eq)
|
||||
if (port->eq)
|
||||
{
|
||||
return CELL_EISCONN;
|
||||
}
|
||||
|
||||
eq->ports.add(&port);
|
||||
port.eq = eq;
|
||||
eq->ports.add(port);
|
||||
port->eq = eq;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -754,7 +755,7 @@ s32 sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_disconnect_event(id=%d, event_type=0x%x, spup=%d)", id, et, spup);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
|
@ -773,19 +774,19 @@ s32 sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup)
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
SPUThread& spu = *(SPUThread*)thr;
|
||||
SPUThread& spu = *(SPUThread*)thr.get();
|
||||
|
||||
EventPort& port = spu.SPUPs[spup];
|
||||
std::shared_ptr<EventPort> port = spu.SPUPs[spup];
|
||||
|
||||
std::lock_guard<std::mutex> lock(port.m_mutex);
|
||||
std::lock_guard<std::mutex> lock(port->m_mutex);
|
||||
|
||||
if (!port.eq)
|
||||
if (!port->eq)
|
||||
{
|
||||
return CELL_ENOTCONN;
|
||||
}
|
||||
|
||||
port.eq->ports.remove(&port);
|
||||
port.eq = nullptr;
|
||||
port->eq->ports.remove(port);
|
||||
port->eq = nullptr;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -794,7 +795,7 @@ s32 sys_spu_thread_bind_queue(u32 id, u32 eq_id, u32 spuq_num)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_bind_queue(id=%d, equeue_id=%d, spuq_num=0x%x)", id, eq_id, spuq_num);
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!Emu.GetIdManager().GetIDData(eq_id, eq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -805,14 +806,14 @@ s32 sys_spu_thread_bind_queue(u32 id, u32 eq_id, u32 spuq_num)
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
if (!(*(SPUThread*)thr).SPUQs.RegisterKey(eq, FIX_SPUQ(spuq_num)))
|
||||
if (!(*(SPUThread*)thr.get()).SPUQs.RegisterKey(eq, FIX_SPUQ(spuq_num)))
|
||||
{
|
||||
return CELL_EBUSY;
|
||||
}
|
||||
|
@ -824,14 +825,14 @@ s32 sys_spu_thread_unbind_queue(u32 id, u32 spuq_num)
|
|||
{
|
||||
sys_spu.Warning("sys_spu_thread_unbind_queue(id=0x%x, spuq_num=0x%x)", id, spuq_num);
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(id);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(id);
|
||||
|
||||
if(!thr || thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
if (!(*(SPUThread*)thr).SPUQs.UnregisterKey(FIX_SPUQ(spuq_num)))
|
||||
if (!(*(SPUThread*)thr.get()).SPUQs.UnregisterKey(FIX_SPUQ(spuq_num)))
|
||||
{
|
||||
return CELL_ESRCH; // may be CELL_EINVAL
|
||||
}
|
||||
|
@ -844,7 +845,7 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, v
|
|||
sys_spu.Warning("sys_spu_thread_group_connect_event_all_threads(id=%d, eq_id=%d, req=0x%llx, spup_addr=0x%x)",
|
||||
id, eq_id, req, spup.addr());
|
||||
|
||||
EventQueue* eq;
|
||||
std::shared_ptr<EventQueue> eq;
|
||||
if (!Emu.GetIdManager().GetIDData(eq_id, eq))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
|
@ -855,23 +856,23 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, v
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
SpuGroupInfo* group;
|
||||
std::shared_ptr<SpuGroupInfo> group;
|
||||
if (!Emu.GetIdManager().GetIDData(id, group))
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
std::vector<SPUThread*> threads;
|
||||
std::vector<std::shared_ptr<CPUThread>> threads;
|
||||
for (auto& v : group->list)
|
||||
{
|
||||
if (!v) continue;
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(v);
|
||||
std::shared_ptr<CPUThread> thr = Emu.GetCPU().GetThread(v);
|
||||
if (thr->GetType() != CPU_THREAD_SPU)
|
||||
{
|
||||
sys_spu.Error("sys_spu_thread_group_connect_event_all_threads(): CELL_ESTAT (wrong thread type)");
|
||||
return CELL_ESTAT;
|
||||
}
|
||||
threads.push_back((SPUThread*)thr);
|
||||
threads.push_back(thr);
|
||||
}
|
||||
|
||||
if (threads.size() != group->m_count)
|
||||
|
@ -885,22 +886,22 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, v
|
|||
bool found = true;
|
||||
if (req & (1ull << i))
|
||||
{
|
||||
for (auto& t : threads) t->SPUPs[i].m_mutex.lock();
|
||||
for (auto& t : threads) ((SPUThread*)t.get())->SPUPs[i]->m_mutex.lock();
|
||||
|
||||
for (auto& t : threads) if (t->SPUPs[i].eq) found = false;
|
||||
for (auto& t : threads) if (((SPUThread*)t.get())->SPUPs[i]->eq) found = false;
|
||||
|
||||
if (found)
|
||||
{
|
||||
for (auto& t : threads)
|
||||
{
|
||||
eq->ports.add(&(t->SPUPs[i]));
|
||||
t->SPUPs[i].eq = eq;
|
||||
eq->ports.add(((SPUThread*)t.get())->SPUPs[i]);
|
||||
((SPUThread*)t.get())->SPUPs[i]->eq = eq;
|
||||
}
|
||||
sys_spu.Warning("*** spup -> %d", i);
|
||||
*spup = (u8)i;
|
||||
}
|
||||
|
||||
for (auto& t : threads) t->SPUPs[i].m_mutex.unlock();
|
||||
for (auto& t : threads) ((SPUThread*)t.get())->SPUPs[i]->m_mutex.unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -161,8 +161,8 @@ u32 LoadSpuImage(vfsStream& stream, u32& spu_ep);
|
|||
|
||||
// Aux
|
||||
s32 spu_image_import(sys_spu_image& img, u32 src, u32 type);
|
||||
SpuGroupInfo* spu_thread_group_create(const std::string& name, u32 num, s32 prio, s32 type, u32 container);
|
||||
SPUThread* spu_thread_initialize(SpuGroupInfo* group, u32 spu_num, sys_spu_image& img, const std::string& name, u32 option, u64 a1, u64 a2, u64 a3, u64 a4, std::function<void(SPUThread&)> task = nullptr);
|
||||
std::shared_ptr<SpuGroupInfo> spu_thread_group_create(const std::string& name, u32 num, s32 prio, s32 type, u32 container);
|
||||
SPUThread* spu_thread_initialize(std::shared_ptr<SpuGroupInfo>& group, u32 spu_num, sys_spu_image& img, const std::string& name, u32 option, u64 a1, u64 a2, u64 a3, u64 a4, std::function<void(SPUThread&)> task = nullptr);
|
||||
|
||||
// SysCalls
|
||||
s32 sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu);
|
||||
|
|
|
@ -13,7 +13,8 @@ s32 sys_timer_create(vm::ptr<u32> timer_id)
|
|||
{
|
||||
sys_timer.Warning("sys_timer_create(timer_id_addr=0x%x)", timer_id.addr());
|
||||
|
||||
*timer_id = sys_timer.GetNewId(new timer, TYPE_TIMER);
|
||||
std::shared_ptr<timer> timer_data(new timer);
|
||||
*timer_id = sys_timer.GetNewId(timer_data, TYPE_TIMER);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -31,7 +32,7 @@ s32 sys_timer_get_information(u32 timer_id, vm::ptr<sys_timer_information_t> inf
|
|||
{
|
||||
sys_timer.Warning("sys_timer_get_information(timer_id=%d, info_addr=0x%x)", timer_id, info.addr());
|
||||
|
||||
timer* timer_data = nullptr;
|
||||
std::shared_ptr<timer> timer_data = nullptr;
|
||||
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
|
||||
|
||||
*info = timer_data->timer_information_t;
|
||||
|
@ -42,7 +43,7 @@ s32 sys_timer_start(u32 timer_id, s64 base_time, u64 period)
|
|||
{
|
||||
sys_timer.Warning("sys_timer_start_periodic_absolute(timer_id=%d, basetime=%lld, period=%llu)", timer_id, base_time, period);
|
||||
|
||||
timer* timer_data = nullptr;
|
||||
std::shared_ptr<timer> timer_data = nullptr;
|
||||
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
|
||||
|
||||
if(timer_data->timer_information_t.timer_state != SYS_TIMER_STATE_STOP) return CELL_EBUSY;
|
||||
|
@ -66,7 +67,7 @@ s32 sys_timer_stop(u32 timer_id)
|
|||
{
|
||||
sys_timer.Todo("sys_timer_stop()");
|
||||
|
||||
timer* timer_data = nullptr;
|
||||
std::shared_ptr<timer> timer_data = nullptr;
|
||||
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
|
||||
|
||||
timer_data->timer_information_t.timer_state = SYS_TIMER_STATE_STOP;
|
||||
|
@ -78,8 +79,8 @@ s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data
|
|||
sys_timer.Warning("sys_timer_connect_event_queue(timer_id=%d, queue_id=%d, name=%llu, data1=%llu, data2=%llu)",
|
||||
timer_id, queue_id, name, data1, data2);
|
||||
|
||||
timer* timer_data = nullptr;
|
||||
EventQueue* equeue = nullptr;
|
||||
std::shared_ptr<timer> timer_data = nullptr;
|
||||
std::shared_ptr<EventQueue> equeue = nullptr;
|
||||
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
|
||||
if(!sys_timer.CheckId(queue_id, equeue)) return CELL_ESRCH;
|
||||
|
||||
|
@ -92,7 +93,7 @@ s32 sys_timer_disconnect_event_queue(u32 timer_id)
|
|||
{
|
||||
sys_timer.Todo("sys_timer_disconnect_event_queue(timer_id=%d)", timer_id);
|
||||
|
||||
timer* timer_data = nullptr;
|
||||
std::shared_ptr<timer> timer_data = nullptr;
|
||||
if(!sys_timer.CheckId(timer_id, timer_data)) return CELL_ESRCH;
|
||||
|
||||
//TODO: ?
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "sys_vm.h"
|
||||
|
||||
SysCallBase sys_vm("sys_vm");
|
||||
MemoryContainerInfo* current_ct;
|
||||
std::shared_ptr<MemoryContainerInfo> current_ct;
|
||||
|
||||
s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 addr)
|
||||
{
|
||||
|
@ -33,12 +33,12 @@ s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 a
|
|||
if(cid == SYS_MEMORY_CONTAINER_ID_INVALID)
|
||||
{
|
||||
// Create a new MemoryContainerInfo to act as default container with vsize.
|
||||
current_ct = new MemoryContainerInfo(new_addr, vsize);
|
||||
current_ct.reset(new MemoryContainerInfo(new_addr, vsize));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check memory container.
|
||||
MemoryContainerInfo* ct;
|
||||
std::shared_ptr<MemoryContainerInfo> ct;
|
||||
if(!sys_vm.CheckId(cid, ct)) return CELL_ESRCH;
|
||||
|
||||
current_ct = ct;
|
||||
|
|
|
@ -103,41 +103,41 @@ void Emulator::SetTitleID(const std::string& id)
|
|||
|
||||
void Emulator::CheckStatus()
|
||||
{
|
||||
std::vector<CPUThread *>& threads = GetCPU().GetThreads();
|
||||
if (!threads.size())
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
//auto& threads = GetCPU().GetThreads();
|
||||
//if (!threads.size())
|
||||
//{
|
||||
// Stop();
|
||||
// return;
|
||||
//}
|
||||
|
||||
bool IsAllPaused = true;
|
||||
for (u32 i = 0; i < threads.size(); ++i)
|
||||
{
|
||||
if (threads[i]->IsPaused()) continue;
|
||||
IsAllPaused = false;
|
||||
break;
|
||||
}
|
||||
//bool IsAllPaused = true;
|
||||
//for (u32 i = 0; i < threads.size(); ++i)
|
||||
//{
|
||||
// if (threads[i]->IsPaused()) continue;
|
||||
// IsAllPaused = false;
|
||||
// break;
|
||||
//}
|
||||
|
||||
if(IsAllPaused)
|
||||
{
|
||||
//ConLog.Warning("all paused!");
|
||||
Pause();
|
||||
return;
|
||||
}
|
||||
//if(IsAllPaused)
|
||||
//{
|
||||
// //ConLog.Warning("all paused!");
|
||||
// Pause();
|
||||
// return;
|
||||
//}
|
||||
|
||||
bool IsAllStoped = true;
|
||||
for (u32 i = 0; i < threads.size(); ++i)
|
||||
{
|
||||
if (threads[i]->IsStopped()) continue;
|
||||
IsAllStoped = false;
|
||||
break;
|
||||
}
|
||||
//bool IsAllStoped = true;
|
||||
//for (u32 i = 0; i < threads.size(); ++i)
|
||||
//{
|
||||
// if (threads[i]->IsStopped()) continue;
|
||||
// IsAllStoped = false;
|
||||
// break;
|
||||
//}
|
||||
|
||||
if (IsAllStoped)
|
||||
{
|
||||
//ConLog.Warning("all stoped!");
|
||||
Pause(); //Stop();
|
||||
}
|
||||
//if (IsAllStoped)
|
||||
//{
|
||||
// //ConLog.Warning("all stoped!");
|
||||
// Pause(); //Stop();
|
||||
//}
|
||||
}
|
||||
|
||||
bool Emulator::BootGame(const std::string& path, bool direct, int device)
|
||||
|
|
|
@ -108,13 +108,12 @@ void InterpreterDisAsmFrame::UpdateUnitList()
|
|||
{
|
||||
m_choice_units->Freeze();
|
||||
m_choice_units->Clear();
|
||||
auto& thrs = Emu.GetCPU().GetThreads();
|
||||
//auto& thrs = Emu.GetCPU().GetThreads();
|
||||
|
||||
for(uint i=0; i<thrs.size(); ++i)
|
||||
{
|
||||
if (thrs[i]->GetType() != CPU_THREAD_ARMv7)
|
||||
m_choice_units->Append(thrs[i]->GetFName(), thrs[i]);
|
||||
}
|
||||
//for (auto& t : thrs)
|
||||
//{
|
||||
// m_choice_units->Append(t->GetFName(), t.get());
|
||||
//}
|
||||
|
||||
m_choice_units->Thaw();
|
||||
}
|
||||
|
|
|
@ -53,200 +53,200 @@ void KernelExplorer::Update()
|
|||
// TODO: FileSystem
|
||||
|
||||
// Semaphores
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_SEMAPHORE);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Semaphores (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_SEMAPHORE);
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "Semaphore: ID = 0x%08x '%s', Count = %d, Max Count = %d", id, Emu.GetSyncPrimManager().GetSemaphoreData(id).name.c_str(),
|
||||
Emu.GetSyncPrimManager().GetSemaphoreData(id).count, Emu.GetSyncPrimManager().GetSemaphoreData(id).max_count);
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_SEMAPHORE);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Semaphores (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_SEMAPHORE);
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "Semaphore: ID = 0x%08x '%s', Count = %d, Max Count = %d", id, Emu.GetSyncPrimManager().GetSemaphoreData(id).name.c_str(),
|
||||
// Emu.GetSyncPrimManager().GetSemaphoreData(id).count, Emu.GetSyncPrimManager().GetSemaphoreData(id).max_count);
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Mutexes
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_MUTEX);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Mutexes (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MUTEX);
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "Mutex: ID = 0x%08x '%s'", id, Emu.GetSyncPrimManager().GetSyncPrimName(TYPE_MUTEX, id).c_str());
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_MUTEX);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Mutexes (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MUTEX);
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "Mutex: ID = 0x%08x '%s'", id, Emu.GetSyncPrimManager().GetSyncPrimName(TYPE_MUTEX, id).c_str());
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Light Weight Mutexes
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_LWMUTEX);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Light Weight Mutexes (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWMUTEX);
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "LW Mutex: ID = 0x%08x '%s', Owner Thread ID = 0x%08x - %s", id, Emu.GetSyncPrimManager().GetLwMutexData(id).name.c_str(),
|
||||
Emu.GetSyncPrimManager().GetLwMutexData(id).owner_id, Emu.GetSyncPrimManager().GetLwMutexData(id).status.c_str());
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_LWMUTEX);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Light Weight Mutexes (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWMUTEX);
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "LW Mutex: ID = 0x%08x '%s', Owner Thread ID = 0x%08x - %s", id, Emu.GetSyncPrimManager().GetLwMutexData(id).name.c_str(),
|
||||
// Emu.GetSyncPrimManager().GetLwMutexData(id).owner_id, Emu.GetSyncPrimManager().GetLwMutexData(id).status.c_str());
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Condition Variables
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_COND);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Condition Variables (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_COND);
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "Condition Variable: ID = 0x%08x '%s'", id, Emu.GetSyncPrimManager().GetSyncPrimName(TYPE_COND, id).c_str());
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_COND);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Condition Variables (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_COND);
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "Condition Variable: ID = 0x%08x '%s'", id, Emu.GetSyncPrimManager().GetSyncPrimName(TYPE_COND, id).c_str());
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Light Weight Condition Variables
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_LWCOND);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Light Weight Condition Variables (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWCOND);
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_LWCOND);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Light Weight Condition Variables (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWCOND);
|
||||
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "LW Condition Variable: ID = 0x%08x '%s'", id, Emu.GetSyncPrimManager().GetSyncPrimName(TYPE_LWCOND, id).c_str());
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "LW Condition Variable: ID = 0x%08x '%s'", id, Emu.GetSyncPrimManager().GetSyncPrimName(TYPE_LWCOND, id).c_str());
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Event Queues
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_QUEUE);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Event Queues (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_QUEUE);
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "Event Queue: ID = 0x%08x", id);
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_QUEUE);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Event Queues (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_QUEUE);
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "Event Queue: ID = 0x%08x", id);
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Modules
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_PRX);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Modules (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_PRX);
|
||||
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 : objects)
|
||||
{
|
||||
sprintf(name, "PRX: ID = 0x%08x", id);
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_PRX);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Modules (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_PRX);
|
||||
// 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 : objects)
|
||||
// {
|
||||
// sprintf(name, "PRX: ID = 0x%08x", id);
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Memory Containers
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_MEM);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Memory Containers (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MEM);
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "Memory Container: ID = 0x%08x", id);
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_MEM);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Memory Containers (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MEM);
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "Memory Container: ID = 0x%08x", id);
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Event Flags
|
||||
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_FLAG);
|
||||
if (count)
|
||||
{
|
||||
sprintf(name, "Event Flags (%d)", count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_FLAG);
|
||||
for (const auto& id : objects)
|
||||
{
|
||||
sprintf(name, "Event Flag: ID = 0x%08x", id);
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
//count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_FLAG);
|
||||
//if (count)
|
||||
//{
|
||||
// sprintf(name, "Event Flags (%d)", count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
// const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_FLAG);
|
||||
// for (const auto& id : objects)
|
||||
// {
|
||||
// sprintf(name, "Event Flag: ID = 0x%08x", id);
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
//}
|
||||
|
||||
// PPU / SPU / RawSPU threads
|
||||
{
|
||||
// TODO: add mutexes owners
|
||||
|
||||
const auto& objects = Emu.GetCPU().GetThreads();
|
||||
//const auto& objects = Emu.GetCPU().GetThreads();
|
||||
u32 ppu_threads_count = 0;
|
||||
u32 spu_threads_count = 0;
|
||||
u32 raw_spu_threads_count = 0;
|
||||
for (const auto& thread : objects)
|
||||
{
|
||||
if (thread->GetType() == CPU_THREAD_PPU)
|
||||
ppu_threads_count++;
|
||||
//for (const auto& thread : objects)
|
||||
//{
|
||||
// if (thread->GetType() == CPU_THREAD_PPU)
|
||||
// ppu_threads_count++;
|
||||
|
||||
if (thread->GetType() == CPU_THREAD_SPU)
|
||||
spu_threads_count++;
|
||||
// if (thread->GetType() == CPU_THREAD_SPU)
|
||||
// spu_threads_count++;
|
||||
|
||||
if (thread->GetType() == CPU_THREAD_RAW_SPU)
|
||||
raw_spu_threads_count++;
|
||||
}
|
||||
// if (thread->GetType() == CPU_THREAD_RAW_SPU)
|
||||
// raw_spu_threads_count++;
|
||||
//}
|
||||
|
||||
if (ppu_threads_count)
|
||||
{
|
||||
sprintf(name, "PPU Threads (%d)", ppu_threads_count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
//if (ppu_threads_count)
|
||||
//{
|
||||
// sprintf(name, "PPU Threads (%d)", ppu_threads_count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
|
||||
for (const auto& thread : objects)
|
||||
{
|
||||
if (thread->GetType() == CPU_THREAD_PPU)
|
||||
{
|
||||
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (const auto& thread : objects)
|
||||
// {
|
||||
// if (thread->GetType() == CPU_THREAD_PPU)
|
||||
// {
|
||||
// sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
if (spu_threads_count)
|
||||
{
|
||||
sprintf(name, "SPU Threads (%d)", spu_threads_count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
//if (spu_threads_count)
|
||||
//{
|
||||
// sprintf(name, "SPU Threads (%d)", spu_threads_count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
|
||||
for (const auto& thread : objects)
|
||||
{
|
||||
if (thread->GetType() == CPU_THREAD_SPU)
|
||||
{
|
||||
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (const auto& thread : objects)
|
||||
// {
|
||||
// if (thread->GetType() == CPU_THREAD_SPU)
|
||||
// {
|
||||
// sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
if (raw_spu_threads_count)
|
||||
{
|
||||
sprintf(name, "RawSPU Threads (%d)", raw_spu_threads_count);
|
||||
const auto& node = m_tree->AppendItem(root, name);
|
||||
//if (raw_spu_threads_count)
|
||||
//{
|
||||
// sprintf(name, "RawSPU Threads (%d)", raw_spu_threads_count);
|
||||
// const auto& node = m_tree->AppendItem(root, name);
|
||||
|
||||
for (const auto& thread : objects)
|
||||
{
|
||||
if (thread->GetType() == CPU_THREAD_RAW_SPU)
|
||||
{
|
||||
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
|
||||
m_tree->AppendItem(node, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (const auto& thread : objects)
|
||||
// {
|
||||
// if (thread->GetType() == CPU_THREAD_RAW_SPU)
|
||||
// {
|
||||
// sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
|
||||
// m_tree->AppendItem(node, name);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue