Merge pull request #779 from Nekotekina/master

SC_FUNC fix
This commit is contained in:
Alexandro Sánchez Bach 2014-08-26 19:54:17 +02:00
commit 0b52abeaf8
112 changed files with 572 additions and 757 deletions

View file

@ -2,6 +2,7 @@
#include "rpcs3/Ini.h"
#include "AutoPause.h"
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
#include "Emu/System.h"
using namespace Debug;

View file

@ -183,3 +183,87 @@ template<typename T, typename T1, T1 value> struct _se<be_t<T>, T1, value> : pub
#define se16(x) _se<u16, decltype(x), x>::value
#define se32(x) _se<u32, decltype(x), x>::value
#define se64(x) _se<u64, decltype(x), x>::value
template<typename T> __forceinline static u8 Read8(T& f)
{
u8 ret;
f.Read(&ret, sizeof(ret));
return ret;
}
template<typename T> __forceinline static u16 Read16(T& f)
{
be_t<u16> ret;
f.Read(&ret, sizeof(ret));
return ret;
}
template<typename T> __forceinline static u32 Read32(T& f)
{
be_t<u32> ret;
f.Read(&ret, sizeof(ret));
return ret;
}
template<typename T> __forceinline static u64 Read64(T& f)
{
be_t<u64> ret;
f.Read(&ret, sizeof(ret));
return ret;
}
template<typename T> __forceinline static u16 Read16LE(T& f)
{
u16 ret;
f.Read(&ret, sizeof(ret));
return ret;
}
template<typename T> __forceinline static u32 Read32LE(T& f)
{
u32 ret;
f.Read(&ret, sizeof(ret));
return ret;
}
template<typename T> __forceinline static u64 Read64LE(T& f)
{
u64 ret;
f.Read(&ret, sizeof(ret));
return ret;
}
template<typename T> __forceinline static void Write8(T& f, const u8 data)
{
f.Write(&data, sizeof(data));
}
template<typename T> __forceinline static void Write16LE(T& f, const u16 data)
{
f.Write(&data, sizeof(data));
}
template<typename T> __forceinline static void Write32LE(T& f, const u32 data)
{
f.Write(&data, sizeof(data));
}
template<typename T> __forceinline static void Write64LE(T& f, const u64 data)
{
f.Write(&data, sizeof(data));
}
template<typename T> __forceinline static void Write16(T& f, const u16 data)
{
Write16LE(f, re16(data));
}
template<typename T> __forceinline static void Write32(T& f, const u32 data)
{
Write32LE(f, re32(data));
}
template<typename T> __forceinline static void Write64(T& f, const u64 data)
{
Write64LE(f, re64(data));
}

View file

@ -12,6 +12,8 @@
#include <thread>
#include <set>
#include <array>
#include "Thread.h"
#include "rFile.h"
using namespace Log;

View file

@ -1,5 +1,7 @@
#pragma once
#include <atomic>
bool SM_IsAborted();
void SM_Sleep();
size_t SM_GetCurrentThreadId();

View file

@ -1,5 +1,8 @@
#pragma once
#include <mutex>
#include <condition_variable>
class SSemaphore
{
const u32 m_max;

View file

@ -1,7 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Thread.h"
thread_local NamedThreadBase* g_tls_this_thread = nullptr;
@ -27,6 +24,17 @@ void NamedThreadBase::SetThreadName(const std::string& name)
m_name = name;
}
void NamedThreadBase::WaitForAnySignal() // wait 1 ms for something
{
std::unique_lock<std::mutex> lock(m_signal_mtx);
m_signal_cv.wait_for(lock, std::chrono::milliseconds(1));
}
void NamedThreadBase::Notify() // wake up waiting thread or nothing
{
m_signal_cv.notify_one();
}
ThreadBase::ThreadBase(const std::string& name)
: NamedThreadBase(name)
, m_executor(nullptr)
@ -40,7 +48,8 @@ ThreadBase::~ThreadBase()
if(IsAlive())
Stop(false);
safe_delete(m_executor);
delete m_executor;
m_executor = nullptr;
}
void ThreadBase::Start()
@ -57,18 +66,7 @@ void ThreadBase::Start()
SetCurrentNamedThread(this);
g_thread_count++;
try
{
Task();
}
catch (const std::string& e)
{
LOG_ERROR(GENERAL, "Exception: %s", e.c_str());
}
catch (const char* e)
{
LOG_ERROR(GENERAL, "Exception: %s", e);
}
Task();
m_alive = false;
g_thread_count--;
@ -144,15 +142,7 @@ void thread::start(std::function<void()> func)
SetCurrentNamedThread(&info);
g_thread_count++;
try
{
func();
}
catch(...)
{
LOG_ERROR(HLE, "Crash :(");
//std::terminate();
}
func();
g_thread_count--;
});

View file

@ -1,11 +1,9 @@
#pragma once
#include <functional>
#include <thread>
#include <vector>
#include <mutex>
#include <atomic>
#include <condition_variable>
//#include <Utilities/SSemaphore.h>
static std::thread::id main_thread;
@ -35,16 +33,9 @@ public:
virtual std::string GetThreadName() const;
virtual void SetThreadName(const std::string& name);
void WaitForAnySignal() // wait 1 ms for something
{
std::unique_lock<std::mutex> lock(m_signal_mtx);
m_signal_cv.wait_for(lock, std::chrono::milliseconds(1));
}
void WaitForAnySignal();
void Notify() // wake up waiting thread or nothing
{
m_signal_cv.notify_one();
}
void Notify();
};
NamedThreadBase* GetCurrentNamedThread();
@ -89,132 +80,4 @@ public:
void detach();
void join();
bool joinable() const;
};
template<typename T> class MTPacketBuffer
{
protected:
volatile bool m_busy;
volatile u32 m_put, m_get;
std::vector<u8> m_buffer;
u32 m_max_buffer_size;
mutable std::recursive_mutex m_cs_main;
void CheckBusy()
{
m_busy = m_put >= m_max_buffer_size;
}
public:
MTPacketBuffer(u32 max_buffer_size)
: m_max_buffer_size(max_buffer_size)
{
Flush();
}
~MTPacketBuffer()
{
Flush();
}
void Flush()
{
std::lock_guard<std::recursive_mutex> lock(m_cs_main);
m_put = m_get = 0;
m_buffer.clear();
m_busy = false;
}
private:
virtual void _push(const T& v) = 0;
virtual T _pop() = 0;
public:
void Push(const T& v)
{
std::lock_guard<std::recursive_mutex> lock(m_cs_main);
_push(v);
}
T Pop()
{
std::lock_guard<std::recursive_mutex> lock(m_cs_main);
return _pop();
}
bool HasNewPacket() const { std::lock_guard<std::recursive_mutex> lock(m_cs_main); return m_put != m_get; }
bool IsBusy() const { return m_busy; }
};
/*
class StepThread : public ThreadBase
{
wxSemaphore m_main_sem;
wxSemaphore m_destroy_sem;
volatile bool m_exit;
protected:
StepThread(const std::string& name = "Unknown StepThread")
: ThreadBase(true, name)
, m_exit(false)
{
}
virtual ~StepThread() throw()
{
}
private:
virtual void Task()
{
m_exit = false;
while(!TestDestroy())
{
m_main_sem.Wait();
if(TestDestroy() || m_exit) break;
Step();
}
while(!TestDestroy()) std::this_thread::sleep_for(std::chrono::milliseconds(0));
if(m_destroy_sem.TryWait() != wxSEMA_NO_ERROR) m_destroy_sem.Post();
}
virtual void Step()=0;
public:
void DoStep()
{
if(IsRunning()) m_main_sem.Post();
}
void WaitForExit()
{
if(TestDestroy()) m_destroy_sem.Wait();
}
void WaitForNextStep()
{
if(!IsRunning()) return;
while(m_main_sem.TryWait() != wxSEMA_NO_ERROR) std::this_thread::sleep_for(std::chrono::milliseconds(0));
}
void Exit(bool wait = false)
{
if(!IsAlive()) return;
if(m_main_sem.TryWait() != wxSEMA_NO_ERROR)
{
m_exit = true;
m_main_sem.Post();
}
Delete();
if(wait) WaitForExit();
}
};
*/
};

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Log.h"
#include <wx/dir.h>
#include "rFile.h"
#ifdef _WIN32
// Maybe in StrFmt?

View file

@ -3,6 +3,7 @@
#include "key_vault.h"
#include "unedat.h"
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
void generate_key(int crypto_mode, int version, unsigned char *key_final, unsigned char *iv_final, unsigned char *key, unsigned char *iv)
{

View file

@ -7,6 +7,7 @@
#include <wx/progdlg.h>
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
// Decryption.
bool CheckHeader(rFile& pkg_f, PKGHeader* m_header)

View file

@ -45,4 +45,6 @@ struct PKGEntry
be_t<u32> pad; // Padding (zeros)
};
class rFile;
extern int Unpack(rFile& dec_pkg_f, std::string src, std::string dst);

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
#include "aes.h"
#include "sha1.h"
#include "utils.h"

View file

@ -1,5 +1,7 @@
#pragma once
#include "Utilities/rFile.h"
struct WAVHeader
{
struct RIFFHeader

View file

@ -324,40 +324,51 @@ void CPUThread::Task()
// TODO: linux version
#endif
while (true)
try
{
int status = ThreadStatus();
if (status == CPUThread_Stopped || status == CPUThread_Break)
while (true)
{
break;
}
int status = ThreadStatus();
if (status == CPUThread_Sleeping)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
Step();
//if (PC - 0x13ED4 < 0x288) trace.push_back(PC);
NextPc(m_dec->DecodeMemory(PC + m_offset));
if (status == CPUThread_Step)
{
m_is_step = false;
break;
}
for (uint i = 0; i < bp.size(); ++i)
{
if (bp[i] == PC)
if (status == CPUThread_Stopped || status == CPUThread_Break)
{
Emu.Pause();
break;
}
if (status == CPUThread_Sleeping)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
Step();
//if (PC - 0x13ED4 < 0x288) trace.push_back(PC);
NextPc(m_dec->DecodeMemory(PC + m_offset));
if (status == CPUThread_Step)
{
m_is_step = false;
break;
}
for (uint i = 0; i < bp.size(); ++i)
{
if (bp[i] == PC)
{
Emu.Pause();
break;
}
}
}
}
catch (const std::string& e)
{
LOG_ERROR(GENERAL, "Exception: %s", e.c_str());
}
catch (const char* e)
{
LOG_ERROR(GENERAL, "Exception: %s", e);
}
for (auto& v : trace) LOG_NOTICE(PPU, "PC = 0x%llx", v);

View file

@ -1,5 +1,7 @@
#pragma once
#include "Utilities/Thread.h"
enum CPUThreadType :unsigned char
{
CPU_THREAD_PPU,

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/DbgCommand.h"
#include "Emu/IdManager.h"
#include "CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/SPUThread.h"

View file

@ -1,4 +1,7 @@
#pragma once
#include <mutex>
class CPUThread;
class RawSPUThread;
enum CPUThreadType : unsigned char;

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "PPUProgramCompiler.h"
#include "Utilities/rFile.h"
using namespace PPU_instr;

View file

@ -13,7 +13,7 @@
#include <thread>
#include <cmath>
extern gcmInfo gcm_info;
//extern gcmInfo gcm_info;
PPUThread& GetCurrentPPUThread()
{

View file

@ -23,6 +23,26 @@ static const char* spu_reg_name[128] =
"$120", "$121", "$122", "$123", "$124", "$125", "$126", "$127",
};
static const char* spu_spreg_name[128] =
{
"$sp0", "$sp1", "$sp2", "$sp3", "$sp4", "$sp5", "$sp6", "$sp7",
"$sp8", "$sp9", "$sp10", "$sp11", "$sp12", "$sp13", "$sp14", "$sp15",
"$sp16", "$sp17", "$sp18", "$sp19", "$sp20", "$sp21", "$sp22", "$sp23",
"$sp24", "$sp25", "$sp26", "$sp27", "$sp28", "$sp29", "$sp30", "$sp31",
"$sp32", "$sp33", "$sp34", "$sp35", "$sp36", "$sp37", "$sp38", "$sp39",
"$sp40", "$sp41", "$sp42", "$sp43", "$sp44", "$sp45", "$sp46", "$sp47",
"$sp48", "$sp49", "$sp50", "$sp51", "$sp52", "$sp53", "$sp54", "$sp55",
"$sp56", "$sp57", "$sp58", "$sp59", "$sp60", "$sp61", "$sp62", "$sp63",
"$sp64", "$sp65", "$sp66", "$sp67", "$sp68", "$sp69", "$sp70", "$sp71",
"$sp72", "$sp73", "$sp74", "$sp75", "$sp76", "$sp77", "$sp78", "$sp79",
"$sp80", "$sp81", "$sp82", "$sp83", "$sp84", "$sp85", "$sp86", "$sp87",
"$sp88", "$sp89", "$sp90", "$sp91", "$sp92", "$sp93", "$sp94", "$sp95",
"$sp96", "$sp97", "$sp98", "$sp99", "$sp100", "$sp101", "$sp102", "$sp103",
"$sp104", "$sp105", "$sp106", "$sp107", "$sp108", "$sp109", "$sp110", "$sp111",
"$sp112", "$sp113", "$sp114", "$sp115", "$sp116", "$sp117", "$sp118", "$sp119",
"$sp120", "$sp121", "$sp122", "$sp123", "$sp124", "$sp125", "$sp126", "$sp127",
};
static const char* spu_ch_name[128] =
{
"$SPU_RdEventStat", "$SPU_WrEventMask", "$SPU_WrEventAck", "$SPU_RdSigNotify1",
@ -134,7 +154,7 @@ private:
}
void MFSPR(u32 rt, u32 sa)
{
DisAsm("mfspr", spu_reg_name[rt], spu_reg_name[sa]);
DisAsm("mfspr", spu_reg_name[rt], spu_spreg_name[sa]);
}
void RDCH(u32 rt, u32 ra)
{
@ -258,7 +278,7 @@ private:
}
void MTSPR(u32 rt, u32 sa)
{
DisAsm("mtspr", spu_reg_name[rt], spu_reg_name[sa]);
DisAsm("mtspr", spu_spreg_name[sa], spu_reg_name[rt]);
}
void WRCH(u32 ra, u32 rt)
{

View file

@ -2,6 +2,7 @@
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Utilities/rFile.h"
#include "Emu/SysCalls/lv2/sys_time.h"

View file

@ -4,17 +4,19 @@
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/ErrorCodes.h"
#include "Emu/SysCalls/lv2/sys_spu.h"
#include "Emu/SysCalls/lv2/sys_event_flag.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include "Emu/Event.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/SPUDisAsm.h"
#include "Emu/Cell/SPUThread.h"
#include "Emu/Cell/SPUDecoder.h"
#include "Emu/Cell/SPUInterpreter.h"
#include "Emu/Cell/SPUDisAsm.h"
#include "Emu/Cell/SPURecompiler.h"
#include <cfenv>

View file

@ -1,5 +1,6 @@
#pragma once
#include "Emu/SysCalls/lv2/sys_event.h"
#include <unordered_map>
class EventManager
{

View file

@ -2,6 +2,7 @@
#include <memory>
#include "VFS.h"
#include "vfsDirBase.h"
#include "Emu/HDD/HDD.h"
#include "vfsDeviceLocalFile.h"
#include "Ini.h"

View file

@ -1,6 +1,9 @@
#pragma once
#include "vfsDevice.h"
class vfsDevice;
struct vfsFileBase;
class vfsDirBase;
enum vfsOpenMode : u8;
enum vfsDeviceType
{

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include <algorithm>
#include "vfsDevice.h"
#include "Utilities/rFile.h"
vfsDevice::vfsDevice(const std::string& ps3_path, const std::string& local_path)
: m_ps3_path(ps3_path)

View file

@ -1,6 +1,8 @@
#pragma once
#include "vfsFileBase.h"
#include "vfsDirBase.h"
#include <mutex>
struct vfsFileBase;
class vfsDirBase;
class vfsDevice
{

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "VFS.h"
#include "vfsDir.h"
vfsDir::vfsDir()

View file

@ -1,4 +1,5 @@
#pragma once
#include <memory>
#include "vfsDirBase.h"
class vfsDir : public vfsDirBase

View file

@ -1,5 +1,5 @@
#include "stdafx.h"
#include "vfsDevice.h"
#include "Utilities/rFile.h"
#include "vfsDirBase.h"
vfsDirBase::vfsDirBase(vfsDevice* device)

View file

@ -1,5 +1,7 @@
#pragma once
class vfsDevice;
enum DirEntryFlags
{
DirEntry_TypeDir = 0x1,

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "VFS.h"
#include "vfsFile.h"
vfsFile::vfsFile()

View file

@ -1,4 +1,5 @@
#pragma once
#include <memory>
#include "vfsFileBase.h"
class vfsFile : public vfsFileBase

View file

@ -1,7 +1,7 @@
#pragma once
#include "vfsStream.h"
enum vfsOpenMode
enum vfsOpenMode : u8
{
vfsRead = 0x1,
vfsWrite = 0x2,

View file

@ -1,5 +1,6 @@
#pragma once
#include "vfsDirBase.h"
#include "Utilities/rFile.h"
class vfsLocalDir : public vfsDirBase
{

View file

@ -1,5 +1,6 @@
#pragma once
#include "vfsFileBase.h"
#include "Utilities/rFile.h"
class vfsLocalFile : public vfsFileBase
{

View file

@ -1,4 +1,5 @@
#pragma once
#include <mutex>
#include <unordered_map>
#include <set>

View file

@ -1,7 +1,6 @@
#pragma once
#include "Emu/Io/KeyboardHandler.h"
#include <cstring> //for memset
class NullKeyboardHandler final : public KeyboardHandlerBase
{

View file

@ -1,7 +1,6 @@
#pragma once
#include "Emu/Io/MouseHandler.h"
#include <cstring> //for memset
class NullMouseHandler final : public MouseHandlerBase
{

View file

@ -1,7 +1,6 @@
#pragma once
#include "Emu/Io/PadHandler.h"
#include <cstring> //for memset
class NullPadHandler final : public PadHandlerBase
{

View file

@ -183,6 +183,38 @@ void MemoryBase::Close()
#endif
}
void MemoryBase::WriteMMIO32(u32 addr, const u32 data)
{
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Write32(addr, data))
{
return;
}
}
*(u32*)((u8*)GetBaseAddr() + addr) = re32(data); // provoke error
}
u32 MemoryBase::ReadMMIO32(u32 addr)
{
u32 res;
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Read32(addr, &res))
{
return res;
}
}
res = re32(*(u32*)((u8*)GetBaseAddr() + addr)); // provoke error
return res;
}
bool MemoryBase::Map(const u64 dst_addr, const u64 src_addr, const u32 size)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);

View file

@ -199,20 +199,7 @@ public:
}
}
__noinline void WriteMMIO32(u32 addr, const u32 data)
{
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Write32(addr, data))
{
return;
}
}
*(u32*)((u8*)GetBaseAddr() + addr) = re32(data); // provoke error
}
__noinline void WriteMMIO32(u32 addr, const u32 data);
template<typename T> void Write32(T addr, const u32 data)
{
@ -286,22 +273,7 @@ public:
}
}
__noinline u32 ReadMMIO32(u32 addr)
{
u32 res;
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Read32(addr, &res))
{
return res;
}
}
res = re32(*(u32*)((u8*)GetBaseAddr() + addr)); // provoke error
return res;
}
__noinline u32 ReadMMIO32(u32 addr);
template<typename T> u32 Read32(T addr)
{
@ -782,6 +754,10 @@ public:
{
}
mem_class_t() : m_addr(0)
{
}
template<typename T> u32 operator += (T right)
{
mem_t<T>& m((mem_t<T>&)*this);

View file

@ -3,6 +3,7 @@
#define PAGE_4K(x) (x + 4095) & ~(4095)
#include <memory>
#include <mutex>
#include <emmintrin.h>
struct MemInfo

View file

@ -1,6 +1,7 @@
#pragma once
#include "GLShaderParam.h"
#include "Emu/RSX/RSXFragmentProgram.h"
#include "Utilities/Thread.h"
struct GLFragmentDecompilerThread : public ThreadBase
{

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/rPlatform.h" // only for rImage
#include "Utilities/rFile.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"

View file

@ -1,6 +1,7 @@
#pragma once
#include "GLShaderParam.h"
#include "Emu/RSX/RSXVertexProgram.h"
#include "Utilities/Thread.h"
struct GLVertexDecompilerThread : public ThreadBase
{

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "GSManager.h"
#include "GSRender.h"
GSLock::GSLock(GSRender& renderer, GSLockType type)

View file

@ -8,6 +8,7 @@
#include <stack>
#include <set> // For tracking a list of used gcm commands
#include "Utilities/SSemaphore.h"
#include "Utilities/Thread.h"
enum Method
{

View file

@ -48,6 +48,7 @@ extern Module *cellSail;
extern void cellSpurs_init();
extern Module *cellSpurs;
extern void cellSync_init();
extern void cellSync_load();
extern Module *cellSync;
extern void cellSysmodule_init();
extern Module *cellSysmodule;
@ -81,8 +82,10 @@ extern void sceNpTus_unload();
extern void sceNpTus_init();
extern Module *sceNpTus;
extern void sysPrxForUser_init();
extern void sysPrxForUser_load();
extern Module *sysPrxForUser;
extern void sys_fs_init();
extern void sys_fs_load();
extern Module *sys_fs;
extern void sys_io_init();
extern Module *sys_io;
@ -250,7 +253,7 @@ void ModuleManager::init()
cellSpurs = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000a, cellSpurs_init);
cellSync = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("cellSync", cellSync_init);
m_mod_init.emplace_back("cellSync", cellSync_init, cellSync_load, nullptr);
cellSysutil = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0015, cellSysutil_init);
cellSysutilAp = static_cast <Module*>(&(m_mod_init.back())) + 1;
@ -278,9 +281,9 @@ void ModuleManager::init()
sceNpTus = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0045, sceNpTus_init, nullptr, sceNpTus_unload);
sysPrxForUser = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back("sysPrxForUser", sysPrxForUser_init);
m_mod_init.emplace_back("sysPrxForUser", sysPrxForUser_init, sysPrxForUser_load, nullptr);
sys_fs = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x000e, sys_fs_init);
m_mod_init.emplace_back(0x000e, sys_fs_init, sys_fs_load, nullptr);
sys_io = static_cast <Module*>(&(m_mod_init.back())) + 1;
m_mod_init.emplace_back(0x0017, sys_io_init);
sys_net = static_cast <Module*>(&(m_mod_init.back())) + 1;

View file

@ -1,5 +1,6 @@
#pragma once
#include "Emu/SysCalls/SC_FUNC.h"
#include "Emu/IdManager.h"
#include "ErrorCodes.h"
#include "LogBase.h"
@ -140,7 +141,6 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
{
if (!ops[0]) return;
//TODO: track down where this is supposed to be deleted
SFunc* sf = new SFunc;
sf->ptr = (void *)func;
sf->func = bind_func(func);

View file

@ -12,6 +12,7 @@ extern "C"
#include "libswresample/swresample.h"
}
#include "Emu/CPU/CPUThreadManager.h"
#include "cellPamf.h"
#include "cellAdec.h"
@ -34,6 +35,9 @@ AudioDecoder::AudioDecoder(AudioCodecType type, u32 addr, u32 size, u32 func, u3
, ctx(nullptr)
, fmt(nullptr)
{
av_register_all();
avcodec_register_all();
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_ATRAC3P);
if (!codec)
{
@ -823,7 +827,4 @@ void cellAdec_init()
REG_FUNC(cellAdec, cellAdecDecodeAu);
REG_FUNC(cellAdec, cellAdecGetPcm);
REG_FUNC(cellAdec, cellAdecGetPcmItem);
av_register_all();
avcodec_register_all();
}

View file

@ -7,7 +7,7 @@
#include "Utilities/SQueue.h"
#include "Emu/Event.h"
#include "Emu/SysCalls/lv2/sys_time.h"
//#include "Emu/Audio/AudioManager.h"
#include "Emu/Audio/AudioManager.h"
#include "Emu/Audio/AudioDumper.h"
#include "Emu/Audio/cellAudio.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "cellPamf.h"
#include "cellDmux.h"

View file

@ -4,6 +4,7 @@
#include "Emu/SysCalls/Modules.h"
#include "Utilities/rMsgBox.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFile.h"
#include "Loader/PSF.h"
#include "cellGame.h"

View file

@ -5,6 +5,7 @@
#include "sysPrxForUser.h"
//#include "Emu/RSX/GCM.h"
#include "Emu/RSX/GSManager.h"
//#include "Emu/SysCalls/lv2/sys_process.h"
#include "cellGcmSys.h"

View file

@ -5,6 +5,7 @@
#include "cellSysutil.h"
#include "Emu/RSX/sysutil_video.h"
#include "Emu/RSX/GSManager.h"
#include "cellResc.h"
Module *cellResc = nullptr;

View file

@ -3,6 +3,8 @@
#define roundup(x,a) (((x)+(a)-1)&(~((a)-1)))
#define SEVIRITY 80.f
#include "Emu/RSX/GCM.h"
enum
{
CELL_RESC_ERROR_NOT_INITIALIZED = 0x80210301,

View file

@ -2217,7 +2217,10 @@ void cellSync_init()
cellSync->AddFunc(0xe1bc7add, _cellSyncLFQueuePopBody);
cellSync->AddFunc(0xe9bf2110, _cellSyncLFQueueGetPushPointer);
cellSync->AddFunc(0xfe74e8e7, _cellSyncLFQueueCompletePopPointer);
}
void cellSync_load()
{
#ifdef PRX_DEBUG
CallAfter([]()
{

View file

@ -9,6 +9,9 @@
#include "Loader/PSF.h"
#include "Emu/Audio/sysutil_audio.h"
#include "Emu/RSX/sysutil_video.h"
#include "Emu/RSX/GSManager.h"
#include "Emu/Audio/AudioManager.h"
#include "Emu/FS/VFS.h"
#include "cellMsgDialog.h"
#include "cellGame.h"
#include "cellSysutil.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFile.h"
#include "Emu/FS/vfsDir.h"
#include "Loader/PSF.h"

View file

@ -3,6 +3,8 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFileBase.h"
#include "cellUserInfo.h"
//void cellUserInfo_init();

View file

@ -12,6 +12,7 @@ extern "C"
#include "libavutil/imgutils.h"
}
#include "Emu/CPU/CPUThreadManager.h"
#include "cellPamf.h"
#include "cellVdec.h"
@ -34,6 +35,9 @@ VideoDecoder::VideoDecoder(CellVdecCodecType type, u32 profile, u32 addr, u32 si
, ctx(nullptr)
, vdecCb(nullptr)
{
av_register_all();
avcodec_register_all();
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_H264);
if (!codec)
{
@ -807,7 +811,4 @@ void cellVdec_init()
cellVdec->AddFunc(0x807c861a, cellVdecGetPicture);
cellVdec->AddFunc(0x17c702b9, cellVdecGetPicItem);
cellVdec->AddFunc(0xe13ef6fc, cellVdecSetFrameRate);
av_register_all();
avcodec_register_all();
}

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Audio/cellAudio.h"
#include "libmixer.h"

View file

@ -3,6 +3,8 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/VFS.h"
#include "Utilities/rFile.h"
#include "Emu/FS/vfsDir.h"
#include "Crypto/unedat.h"
#include "sceNp.h"

View file

@ -7,7 +7,9 @@
#include "Utilities/rXml.h"
#include "Loader/TRP.h"
#include "Loader/TROPUSR.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsDir.h"
#include "Emu/FS/vfsFileBase.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include "sceNp.h"
#include "sceNpTrophy.h"

View file

@ -397,11 +397,6 @@ void sysPrxForUser_init()
REG_FUNC(sysPrxForUser, _sys_strncpy);
sysPrxForUser->AddFunc(0xe75c40f2, _unnamed_E75C40F2); // real name is unknown
spu_printf_agcb = 0;
spu_printf_dgcb = 0;
spu_printf_atcb = 0;
spu_printf_dtcb = 0;
REG_FUNC(sysPrxForUser, _sys_spu_printf_initialize);
REG_FUNC(sysPrxForUser, _sys_spu_printf_finalize);
REG_FUNC(sysPrxForUser, _sys_spu_printf_attach_group);
@ -411,3 +406,11 @@ void sysPrxForUser_init()
REG_FUNC(sysPrxForUser, _sys_printf);
}
void sysPrxForUser_load()
{
spu_printf_agcb = 0;
spu_printf_dgcb = 0;
spu_printf_atcb = 0;
spu_printf_dtcb = 0;
}

View file

@ -3,6 +3,8 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFileBase.h"
#include "Emu/SysCalls/lv2/lv2Fs.h"
Module *sys_fs = nullptr;
@ -312,6 +314,9 @@ void sys_fs_init()
sys_fs->AddFunc(0x81f33783, cellFsStReadPutCurrentAddr);
sys_fs->AddFunc(0x8f71c5b2, cellFsStReadWait);
sys_fs->AddFunc(0x866f6aec, cellFsStReadWaitCallback);
}
void sys_fs_load()
{
aio_init = false;
}

View file

@ -1,414 +1,159 @@
#pragma once
#include "Emu/Cell/PPUThread.h"
#define RESULT(x) CPU.GPR[3] = (x)
class func_caller
{
public:
virtual void operator()() = 0;
};
template<bool is_in_sp, bool is_fp, bool is_ptr, typename T, int i>
struct get_arg;
template<typename T, int i>
struct get_arg<false, false, false, T, i> // not fp, not ptr, 1..8
namespace detail
{
static __forceinline T func(PPUThread& CPU) { return (T&)CPU.GPR[i + 2]; }
};
enum bind_arg_type
{
ARG_GENERAL,
ARG_FLOAT,
ARG_VECTOR,
ARG_STACK,
};
template<bool is_fp, typename T, int i>
struct get_arg<false, is_fp, true, T, i> // ptr, 1..8
{
static_assert(i == 0, "Invalid function argument type: pointer");
static __forceinline T func(PPUThread& CPU) { return nullptr; }
};
template<typename T, bind_arg_type type, int g_count, int f_count, int v_count>
struct bind_arg;
template<bool is_in_sp, typename T, int i>
struct get_arg<is_in_sp, true, false, T, i> // fp, 1..12
{
static __forceinline T func(PPUThread& CPU) { return CPU.FPR[i]; }
};
template<typename T, int g_count, int f_count, int v_count>
struct bind_arg<T, ARG_GENERAL, g_count, f_count, v_count>
{
static __forceinline T func(PPUThread& CPU) { return (T&)CPU.GPR[g_count + 2]; }
};
template<typename T, int i>
struct get_arg<true, false, false, T, i> // not fp, not ptr, 9..12
{
static __forceinline T func(PPUThread& CPU) { u64 res = CPU.GetStackArg(i); return (T&)res; }
};
template<typename T, int g_count, int f_count, int v_count>
struct bind_arg<T, ARG_FLOAT, g_count, f_count, v_count>
{
static __forceinline T func(PPUThread& CPU) { return (T&)CPU.FPR[f_count]; }
};
template<bool is_fp, typename T, int i>
struct get_arg<true, is_fp, true, T, i> // ptr, 9..12
{
static_assert(i == 0, "Invalid function argument type: pointer");
static __forceinline T func(PPUThread& CPU) { return nullptr; }
};
template<typename T, int g_count, int f_count, int v_count>
struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count>
{
static_assert(v_count == 0, "ARG_VECTOR not supported");
static __forceinline T func(PPUThread& CPU) { return T(); }
};
#define ARG(n) get_arg<((n) > 8), std::is_floating_point<T##n>::value, std::is_pointer<T##n>::value, T##n, n>::func(CPU)
template<typename T, int g_count, int f_count, int v_count>
struct bind_arg<T, ARG_STACK, g_count, f_count, v_count>
{
static __forceinline T func(PPUThread& CPU) { return CPU.GetStackArg(8 + std::max(g_count - 8, 0) + std::max(f_count - 12, 0)); }
};
template<typename TR>
class binder_func_0 : public func_caller
{
typedef TR (*func_t)();
const func_t m_call;
template<typename T>
struct bind_result
{
static __forceinline void func(PPUThread& CPU, T value)
{
static_assert(!std::is_pointer<T>::value, "Invalid function result type: pointer");
if (std::is_floating_point<T>::value)
{
(T&)CPU.FPR[1] = value;
}
else
{
(T&)CPU.GPR[3] = value;
}
}
};
public:
binder_func_0(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call()); }
};
template <typename RT, typename F, typename Tuple, bool Done, int Total, int... N>
struct call_impl
{
static __forceinline RT call(F f, Tuple && t)
{
return call_impl<RT, F, Tuple, Total == 1 + sizeof...(N), Total, N..., sizeof...(N)>::call(f, std::forward<Tuple>(t));
}
};
template<>
class binder_func_0<void> : public func_caller
{
typedef void (*func_t)();
const func_t m_call;
template <typename RT, typename F, typename Tuple, int Total, int... N>
struct call_impl<RT, F, Tuple, true, Total, N...>
{
static __forceinline RT call(F f, Tuple && t)
{
return f(std::get<N>(std::forward<Tuple>(t))...);
}
};
public:
binder_func_0(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(); }
};
template <typename RT, typename F, typename Tuple>
static __forceinline RT call(F f, Tuple && t)
{
typedef typename std::decay<Tuple>::type ttype;
return detail::call_impl<RT, F, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value>::call(f, std::forward<Tuple>(t));
}
template<typename TR, typename T1>
class binder_func_1 : public func_caller
{
typedef TR (*func_t)(T1);
const func_t m_call;
template<int g_count, int f_count, int v_count>
static __forceinline std::tuple<> iterate(PPUThread& CPU)
{
return std::tuple<>();
}
public:
binder_func_1(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1))); }
};
template<int g_count, int f_count, int v_count, typename T, typename... A>
static __forceinline std::tuple<T, A...> iterate(PPUThread& CPU)
{
// TODO: check calculations
const bind_arg_type t = std::is_floating_point<T>::value
? ((f_count >= 12) ? ARG_STACK : ARG_FLOAT)
: ((g_count >= 8) ? ARG_STACK : ARG_GENERAL);
const int g = g_count + (std::is_floating_point<T>::value ? 0 : 1);
const int f = f_count + (std::is_floating_point<T>::value ? 1 : 0);
const int v = v_count; // TODO: vector arguments support (if possible)
static_assert(!v_count, "ARG_VECTOR not supported");
static_assert(!std::is_pointer<T>::value, "Invalid function argument type: pointer");
return std::tuple_cat<std::tuple<T>, std::tuple<A...>>(std::tuple<T>(bind_arg<T, t, g, f, v>::func(CPU)), iterate<g, f, v, A...>(CPU));
}
template<typename T1>
class binder_func_1<void, T1> : public func_caller
{
typedef void (*func_t)(T1);
const func_t m_call;
template<typename RT, typename... TA>
class func_binder;
public:
binder_func_1(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1)); }
};
template<typename... TA>
class func_binder<void, TA...> : public func_caller
{
typedef void(*func_t)(TA...);
const func_t m_call;
template<typename TR, typename T1, typename T2>
class binder_func_2 : public func_caller
{
typedef TR (*func_t)(T1, T2);
const func_t m_call;
public:
func_binder(func_t call)
: func_caller()
, m_call(call)
{
}
public:
binder_func_2(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2))); }
};
virtual void operator()()
{
declCPU();
call<void>(m_call, iterate<0, 0, 0, TA...>(CPU));
}
};
template<typename T1, typename T2>
class binder_func_2<void, T1, T2> : public func_caller
{
typedef void (*func_t)(T1, T2);
const func_t m_call;
template<typename TR, typename... TA>
class func_binder : public func_caller
{
typedef TR(*func_t)(TA...);
const func_t m_call;
public:
binder_func_2(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2)); }
};
public:
func_binder(func_t call)
: func_caller()
, m_call(call)
{
}
template<typename TR, typename T1, typename T2, typename T3>
class binder_func_3 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3);
const func_t m_call;
public:
binder_func_3(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3))); }
};
template<typename T1, typename T2, typename T3>
class binder_func_3<void, T1, T2, T3> : public func_caller
{
typedef void (*func_t)(T1, T2, T3);
const func_t m_call;
public:
binder_func_3(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4>
class binder_func_4 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4);
const func_t m_call;
public:
binder_func_4(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4))); }
};
template<typename T1, typename T2, typename T3, typename T4>
class binder_func_4<void, T1, T2, T3, T4> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4);
const func_t m_call;
public:
binder_func_4(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5>
class binder_func_5 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5);
const func_t m_call;
public:
binder_func_5(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5>
class binder_func_5<void, T1, T2, T3, T4, T5> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5);
const func_t m_call;
public:
binder_func_5(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
class binder_func_6 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5, T6);
const func_t m_call;
public:
binder_func_6(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
class binder_func_6<void, T1, T2, T3, T4, T5, T6> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5, T6);
const func_t m_call;
public:
binder_func_6(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
class binder_func_7 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5, T6, T7);
const func_t m_call;
public:
binder_func_7(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
class binder_func_7<void, T1, T2, T3, T4, T5, T6, T7> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5, T6, T7);
const func_t m_call;
public:
binder_func_7(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
class binder_func_8 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8);
const func_t m_call;
public:
binder_func_8(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
class binder_func_8<void, T1, T2, T3, T4, T5, T6, T7, T8> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8);
const func_t m_call;
public:
binder_func_8(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
class binder_func_9 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
const func_t m_call;
public:
binder_func_9(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
class binder_func_9<void, T1, T2, T3, T4, T5, T6, T7, T8, T9> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
const func_t m_call;
public:
binder_func_9(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
class binder_func_10 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10);
const func_t m_call;
public:
binder_func_10(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
class binder_func_10<void, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10);
const func_t m_call;
public:
binder_func_10(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
class binder_func_11 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11);
const func_t m_call;
public:
binder_func_11(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10), ARG(11))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
class binder_func_11<void, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11);
const func_t m_call;
public:
binder_func_11(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10), ARG(11)); }
};
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12>
class binder_func_12 : public func_caller
{
typedef TR (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12);
const func_t m_call;
public:
binder_func_12(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); RESULT(m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10), ARG(11), ARG(12))); }
};
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12>
class binder_func_12<void, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : public func_caller
{
typedef void (*func_t)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12);
const func_t m_call;
public:
binder_func_12(func_t call) : func_caller(), m_call(call) {}
virtual void operator()() { declCPU(); m_call(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10), ARG(11), ARG(12)); }
};
#undef ARG
template<typename TR>
func_caller* bind_func(TR (*call)())
{
return new binder_func_0<TR>(call);
virtual void operator()()
{
declCPU();
bind_result<TR>::func(CPU, call<TR>(m_call, iterate<0, 0, 0, TA...>(CPU)));
}
};
}
template<typename TR, typename T1>
func_caller* bind_func(TR (*call)(T1))
template<typename TR, typename... TA>
func_caller* bind_func(TR(*call)(TA...))
{
return new binder_func_1<TR, T1>(call);
}
template<typename TR, typename T1, typename T2>
func_caller* bind_func(TR (*call)(T1, T2))
{
return new binder_func_2<TR, T1, T2>(call);
}
template<typename TR, typename T1, typename T2, typename T3>
func_caller* bind_func(TR (*call)(T1, T2, T3))
{
return new binder_func_3<TR, T1, T2, T3>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4))
{
return new binder_func_4<TR, T1, T2, T3, T4>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5))
{
return new binder_func_5<TR, T1, T2, T3, T4, T5>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5, T6))
{
return new binder_func_6<TR, T1, T2, T3, T4, T5, T6>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5, T6, T7))
{
return new binder_func_7<TR, T1, T2, T3, T4, T5, T6, T7>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5, T6, T7, T8))
{
return new binder_func_8<TR, T1, T2, T3, T4, T5, T6, T7, T8>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5, T6, T7, T8, T9))
{
return new binder_func_9<TR, T1, T2, T3, T4, T5, T6, T7, T8, T9>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10))
{
return new binder_func_10<TR, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11))
{
return new binder_func_11<TR, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(call);
}
template<typename TR, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12>
func_caller* bind_func(TR (*call)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12))
{
return new binder_func_12<TR, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(call);
}
return new detail::func_binder<TR, TA...>(call);
}

View file

@ -193,6 +193,10 @@ void StaticFuncManager::StaticExecute(u32 code)
void StaticFuncManager::StaticFinalize()
{
for (SFunc *s : m_static_funcs_list)
{
delete s;
}
m_static_funcs_list.clear();
}
@ -208,9 +212,6 @@ SFunc *StaticFuncManager::operator[](size_t i)
StaticFuncManager::~StaticFuncManager()
{
for (SFunc *s : m_static_funcs_list)
{
delete s;
}
StaticFinalize();
}

View file

@ -924,7 +924,7 @@ void default_syscall()
case 988:
LOG_WARNING(HLE, "SysCall 988! r3: 0x%llx, r4: 0x%llx, pc: 0x%llx",
CPU.GPR[3], CPU.GPR[4], CPU.PC);
RESULT(0);
CPU.GPR[3] = 0;
return;
case 999:
@ -940,7 +940,7 @@ void default_syscall()
}
LOG_ERROR(HLE, "Unknown syscall: %d - %08x", code, code);
RESULT(0);
CPU.GPR[3] = 0;
return;
}
@ -963,7 +963,7 @@ void SysCalls::DoSyscall(u32 code)
LOG_ERROR(HLE, "TODO: %s", GetHLEFuncName(code).c_str());
declCPU();
RESULT(0);
CPU.GPR[3] = 0;
}
IdManager& SysCallBase::GetIdManager() const

View file

@ -1,6 +1,7 @@
#pragma once
#include "ErrorCodes.h"
#include "LogBase.h"
#include "Emu/IdManager.h"
//#define SYSCALLS_DEBUG

View file

@ -4,6 +4,7 @@
//#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFile.h"
#include "Emu/FS/vfsDir.h"
#include "lv2Fs.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "sys_cond.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/RawSPUThread.h"
#include "sys_interrupt.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "sys_lwmutex.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "sys_mutex.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "sys_ppu_thread.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFile.h"
#include "Crypto/unself.h"
#include "sys_prx.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUThread.h"
#include "sys_semaphore.h"
#include "sys_time.h"

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include <thread>
#include "sys_spinlock.h"
SysCallBase sys_spinlock("sys_spinlock");

View file

@ -1,5 +1,7 @@
#pragma once
#include <atomic>
// SysCalls
void sys_spinlock_initialize(mem_ptr_t<std::atomic<be_t<u32>>> lock);
void sys_spinlock_lock(mem_ptr_t<std::atomic<be_t<u32>>> lock);

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/RawSPUThread.h"
#include "Emu/FS/vfsFile.h"
#include "Loader/ELF.h"

View file

@ -1,5 +1,7 @@
#pragma once
#include <atomic>
enum
{
SYS_SPU_THREAD_GROUP_TYPE_NORMAL = 0x00,

View file

@ -4,6 +4,7 @@
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/Event.h"
#include <thread>
#include "sys_timer.h"
SysCallBase sys_timer("sys_timer");

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
@ -13,6 +14,15 @@
#include "Emu/FS/vfsDeviceLocalFile.h"
#include "Emu/DbgCommand.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/IdManager.h"
#include "Emu/Io/Pad.h"
#include "Emu/Io/Keyboard.h"
#include "Emu/Io/Mouse.h"
#include "Emu/RSX/GSManager.h"
#include "Emu/Audio/AudioManager.h"
#include "Emu/FS/VFS.h"
#include "Loader/PSF.h"
#include "../Crypto/unself.h"
@ -34,13 +44,37 @@ Emulator::Emulator()
, m_mode(DisAsm)
, m_rsx_callback(0)
, m_ppu_callback_thr(0)
, m_thread_manager(new CPUThreadManager())
, m_pad_manager(new PadManager())
, m_keyboard_manager(new KeyboardManager())
, m_mouse_manager(new MouseManager())
, m_id_manager(new IdManager())
, m_gs_manager(new GSManager())
, m_audio_manager(new AudioManager())
, m_callback_manager(new CallbackManager())
, m_event_manager(new EventManager())
, m_sfunc_manager(new StaticFuncManager())
, m_module_manager(new ModuleManager())
, m_thread_manager(new CPUThreadManager())
, m_vfs(new VFS())
{
}
Emulator::~Emulator()
{
delete m_thread_manager;
delete m_pad_manager;
delete m_keyboard_manager;
delete m_mouse_manager;
delete m_id_manager;
delete m_gs_manager;
delete m_audio_manager;
delete m_callback_manager;
delete m_event_manager;
delete m_sfunc_manager;
delete m_module_manager;
delete m_vfs;
}
void Emulator::Init()
{
while(m_modules_init.size())
@ -156,13 +190,13 @@ void Emulator::Load()
LOG_NOTICE(LOADER, "Loading '%s'...", m_path.c_str());
GetInfo().Reset();
m_vfs.Init(m_path);
GetVFS().Init(m_path);
LOG_NOTICE(LOADER, " "); //used to be skip_line
LOG_NOTICE(LOADER, "Mount info:");
for(uint i=0; i<m_vfs.m_devices.size(); ++i)
for(uint i=0; i<GetVFS().m_devices.size(); ++i)
{
LOG_NOTICE(LOADER, "%s -> %s", m_vfs.m_devices[i]->GetPs3Path().c_str(), m_vfs.m_devices[i]->GetLocalPath().c_str());
LOG_NOTICE(LOADER, "%s -> %s", GetVFS().m_devices[i]->GetPs3Path().c_str(), GetVFS().m_devices[i]->GetLocalPath().c_str());
}
LOG_NOTICE(LOADER, " ");//used to be skip_line
@ -435,7 +469,7 @@ void Emulator::Stop()
m_break_points.clear();
m_marked_points.clear();
m_vfs.UnMountAll();
GetVFS().UnMountAll();
GetGSManager().Close();
GetAudioManager().Close();

View file

@ -1,13 +1,8 @@
#pragma once
#include <atomic>
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Io/Pad.h"
#include "Emu/Io/Keyboard.h"
#include "Emu/Io/Mouse.h"
#include "Emu/RSX/GSManager.h"
#include "Emu/Audio/AudioManager.h"
#include "Emu/FS/VFS.h"
#include <memory>
#include <vector>
#include "Loader/Loader.h"
enum Status
@ -18,9 +13,19 @@ enum Status
Ready,
};
class CPUThreadManager;
class PadManager;
class KeyboardManager;
class MouseManager;
class IdManager;
class GSManager;
class AudioManager;
struct CallbackManager;
class CPUThread;
class EventManager;
class ModuleManager;
class StaticFuncManager;
struct VFS;
struct EmuInfo
{
@ -85,20 +90,19 @@ class Emulator
std::vector<u64> m_break_points;
std::vector<u64> m_marked_points;
CPUThreadManager *m_thread_manager;
PadManager m_pad_manager;
KeyboardManager m_keyboard_manager;
MouseManager m_mouse_manager;
IdManager m_id_manager;
GSManager m_gs_manager;
AudioManager m_audio_manager;
CallbackManager m_callback_manager;
CPUThreadManager* m_thread_manager;
PadManager* m_pad_manager;
KeyboardManager* m_keyboard_manager;
MouseManager* m_mouse_manager;
IdManager* m_id_manager;
GSManager* m_gs_manager;
AudioManager* m_audio_manager;
CallbackManager* m_callback_manager;
CPUThread* m_ppu_callback_thr;
std::unique_ptr<EventManager> m_event_manager;
std::unique_ptr<StaticFuncManager> m_sfunc_manager;
std::unique_ptr<ModuleManager> m_module_manager;
VFS m_vfs;
EventManager* m_event_manager;
StaticFuncManager* m_sfunc_manager;
ModuleManager* m_module_manager;
VFS* m_vfs;
EmuInfo m_info;
@ -110,20 +114,21 @@ public:
s32 m_sdk_version;
Emulator();
~Emulator();
void Init();
void SetPath(const std::string& path, const std::string& elf_path = "");
void SetTitleID(const std::string& id);
CPUThreadManager& GetCPU() { return *m_thread_manager; }
PadManager& GetPadManager() { return m_pad_manager; }
KeyboardManager& GetKeyboardManager() { return m_keyboard_manager; }
MouseManager& GetMouseManager() { return m_mouse_manager; }
IdManager& GetIdManager() { return m_id_manager; }
GSManager& GetGSManager() { return m_gs_manager; }
AudioManager& GetAudioManager() { return m_audio_manager; }
CallbackManager& GetCallbackManager() { return m_callback_manager; }
VFS& GetVFS() { return m_vfs; }
PadManager& GetPadManager() { return *m_pad_manager; }
KeyboardManager& GetKeyboardManager() { return *m_keyboard_manager; }
MouseManager& GetMouseManager() { return *m_mouse_manager; }
IdManager& GetIdManager() { return *m_id_manager; }
GSManager& GetGSManager() { return *m_gs_manager; }
AudioManager& GetAudioManager() { return *m_audio_manager; }
CallbackManager& GetCallbackManager() { return *m_callback_manager; }
VFS& GetVFS() { return *m_vfs; }
std::vector<u64>& GetBreakPoints() { return m_break_points; }
std::vector<u64>& GetMarkedPoints() { return m_marked_points; }
CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; }

View file

@ -5,6 +5,7 @@
#include <fstream>
#include <vector>
#include <mutex>
#include <atomic>
#include "Ini.h"
#include "Utilities/Log.h"

View file

@ -6,6 +6,7 @@
#include "rpcs3.h"
#include "Debugger.h"
#include "InterpreterDisAsm.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPCThread.h"

View file

@ -4,6 +4,7 @@
#include "Emu/System.h"
#include "DisAsmFrame.h"
#include "Emu/FS/vfsLocalFile.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPCThread.h"
#include "Gui/DisAsmFrame.h"
#include "Emu/Cell/PPUDecoder.h"

View file

@ -1,8 +1,10 @@
#include "stdafx.h"
#include "Utilities/AutoPause.h"
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsDir.h"
#include "Emu/FS/vfsFile.h"
#include "GameViewer.h"

View file

@ -4,6 +4,7 @@
#include "Emu/System.h"
#include "rpcs3.h"
#include "InterpreterDisAsm.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/Cell/PPUDecoder.h"
#include "Emu/Cell/PPUDisAsm.h"
#include "Emu/Cell/SPUDecoder.h"

View file

@ -3,6 +3,7 @@
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "KernelExplorer.h"
KernelExplorer::KernelExplorer(wxWindow* parent)

View file

@ -7,7 +7,8 @@
#include "RSXDebugger.h"
#include "Emu/RSX/sysutil_video.h"
#include "Emu/RSX/GCM.h"
#include "Emu/RSX/GSManager.h"
//#include "Emu/RSX/GCM.h"
#include "MemoryViewer.h"

View file

@ -1,4 +1,5 @@
#pragma once
#include "Emu/FS/VFS.h"
class VFSEntrySettingsDialog : public wxDialog
{

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Emu/FS/vfsStream.h"
#include "ELF.h"
void Elf_Ehdr::Show()

View file

@ -1,5 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
#include "Emu/FS/vfsStream.h"
#include "Emu/Memory/Memory.h"
#include "ELF32.h"

View file

@ -1,6 +1,9 @@
#pragma once
#include "Loader.h"
struct vfsStream;
class rFile;
struct Elf32_Ehdr
{
u32 e_magic;

View file

@ -1,5 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
#include "Emu/FS/vfsStream.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"

View file

@ -1,6 +1,9 @@
#pragma once
#include "Loader.h"
struct vfsStream;
class rFile;
struct Elf64_Ehdr
{
u32 e_magic;

View file

@ -1,5 +1,7 @@
#pragma once
#include "Emu/FS/vfsFileBase.h"
struct vfsFileBase;
class rFile;
#ifdef _DEBUG
//#define LOADER_DEBUG
@ -38,84 +40,6 @@ enum ShdrFlag
SHF_MASKPROC = 0xf0000000,
};
__forceinline static u8 Read8(vfsStream& f)
{
u8 ret;
f.Read(&ret, sizeof(u8));
return ret;
}
__forceinline static u16 Read16(vfsStream& f)
{
return ((u16)Read8(f) << 8) | (u16)Read8(f);
}
__forceinline static u32 Read32(vfsStream& f)
{
return (Read16(f) << 16) | Read16(f);
}
__forceinline static u64 Read64(vfsStream& f)
{
return ((u64)Read32(f) << 32) | (u64)Read32(f);
}
__forceinline static u16 Read16LE(vfsStream& f)
{
return ((u16)Read8(f) | ((u16)Read8(f) << 8));
}
__forceinline static u32 Read32LE(vfsStream& f)
{
return Read16LE(f) | (Read16LE(f) << 16);
}
__forceinline static u64 Read64LE(vfsStream& f)
{
return ((u64)Read32LE(f) | (u64)Read32LE(f) << 32);
}
__forceinline static void Write8(rFile& f, const u8 data)
{
f.Write(&data, 1);
}
__forceinline static void Write16(rFile& f, const u16 data)
{
Write8(f, data >> 8);
Write8(f, data);
}
__forceinline static void Write32(rFile& f, const u32 data)
{
Write16(f, data >> 16);
Write16(f, data);
}
__forceinline static void Write64(rFile& f, const u64 data)
{
Write32(f, data >> 32);
Write32(f, data);
}
__forceinline static void Write16LE(rFile& f, const u16 data)
{
Write8(f, data);
Write8(f, data >> 8);
}
__forceinline static void Write32LE(rFile& f, const u32 data)
{
Write16LE(f, data);
Write16LE(f, data >> 16);
}
__forceinline static void Write64LE(rFile& f, const u64 data)
{
Write32LE(f, data);
Write32LE(f, data >> 32);
}
const std::string Ehdr_DataToString(const u8 data);
const std::string Ehdr_TypeToString(const u16 type);
const std::string Ehdr_OS_ABIToString(const u8 os_abi);

Some files were not shown because too many files have changed in this diff Show more