2012-11-15 01:39:56 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "ErrorCodes.h"
|
2014-07-21 19:58:03 +04:00
|
|
|
#include "LogBase.h"
|
2014-08-25 18:56:13 +04:00
|
|
|
#include "Emu/IdManager.h"
|
2014-07-11 00:16:19 +10:00
|
|
|
|
2012-11-15 01:39:56 +02:00
|
|
|
//#define SYSCALLS_DEBUG
|
|
|
|
|
|
2014-02-23 17:52:52 +01:00
|
|
|
class SysCallBase;
|
|
|
|
|
|
|
|
|
|
namespace detail{
|
|
|
|
|
template<typename T> bool CheckId(u32 id, T*& data,const std::string &name)
|
|
|
|
|
{
|
|
|
|
|
ID* id_data;
|
|
|
|
|
if(!CheckId(id, id_data,name)) return false;
|
2014-10-01 12:45:43 +03:00
|
|
|
data = id_data->GetData()->get<T>();
|
2014-02-23 17:52:52 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> bool CheckId<ID>(u32 id, ID*& _id,const std::string &name);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 19:58:03 +04:00
|
|
|
class SysCallBase : public LogBase
|
2013-06-30 11:46:29 +03:00
|
|
|
{
|
|
|
|
|
private:
|
2014-02-02 22:47:17 +02:00
|
|
|
std::string m_module_name;
|
2013-06-30 11:46:29 +03:00
|
|
|
//u32 m_id;
|
2014-08-22 20:36:27 +04:00
|
|
|
IdManager& GetIdManager() const;
|
2013-06-30 11:46:29 +03:00
|
|
|
|
|
|
|
|
public:
|
2014-02-02 22:47:17 +02:00
|
|
|
SysCallBase(const std::string& name/*, u32 id*/)
|
2013-06-30 11:46:29 +03:00
|
|
|
: m_module_name(name)
|
|
|
|
|
//, m_id(id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 19:58:03 +04:00
|
|
|
virtual const std::string& GetName() const override
|
2013-06-30 11:46:29 +03:00
|
|
|
{
|
2014-07-21 19:58:03 +04:00
|
|
|
return m_module_name;
|
2012-11-15 01:39:56 +02:00
|
|
|
}
|
2013-06-30 11:46:29 +03:00
|
|
|
|
|
|
|
|
bool CheckId(u32 id) const
|
|
|
|
|
{
|
2014-10-01 12:45:43 +03:00
|
|
|
return GetIdManager().CheckID(id) && GetIdManager().GetID(id).GetName() == GetName();
|
2013-06-30 11:46:29 +03:00
|
|
|
}
|
|
|
|
|
|
2014-08-31 16:12:09 -04:00
|
|
|
template<typename T>
|
|
|
|
|
bool CheckId(u32 id, T*& data) const
|
2013-06-30 11:46:29 +03:00
|
|
|
{
|
2014-02-23 17:52:52 +01:00
|
|
|
return detail::CheckId(id,data,GetName());
|
2014-01-19 05:14:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
2014-07-26 05:31:46 +02:00
|
|
|
u32 GetNewId(T* data, IDType type = TYPE_OTHER)
|
2013-06-30 11:46:29 +03:00
|
|
|
{
|
2014-08-22 20:36:27 +04:00
|
|
|
return GetIdManager().GetNewID<T>(GetName(), data, type);
|
2013-06-30 11:46:29 +03:00
|
|
|
}
|
2014-08-24 00:40:04 +04:00
|
|
|
|
|
|
|
|
bool RemoveId(u32 id);
|
2012-11-15 01:39:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern bool dump_enable;
|
|
|
|
|
|
2014-09-16 21:46:22 +04:00
|
|
|
class PPUThread;
|
|
|
|
|
|
2012-11-15 01:39:56 +02:00
|
|
|
class SysCalls
|
|
|
|
|
{
|
|
|
|
|
public:
|
2014-09-16 21:46:22 +04:00
|
|
|
static void DoSyscall(PPUThread& CPU, u32 code);
|
2014-06-07 18:08:14 +03:00
|
|
|
static std::string GetHLEFuncName(const u32 fid);
|
2012-11-15 01:39:56 +02:00
|
|
|
};
|