rpcsx/rpcs3/Emu/ARMv7/PSVFuncList.cpp

76 lines
1.8 KiB
C++
Raw Normal View History

#include "stdafx.h"
2015-01-14 20:45:36 +01:00
#include <unordered_map>
2014-12-24 17:09:32 +01:00
#include "Utilities/Log.h"
#include "Emu/System.h"
#include "PSVFuncList.h"
2014-12-01 01:41:01 +01:00
std::vector<psv_func> g_psv_func_list;
2014-12-01 01:41:01 +01:00
void add_psv_func(psv_func& data)
{
2015-01-14 20:45:36 +01:00
// setup special functions (without NIDs)
2014-12-01 01:41:01 +01:00
if (!g_psv_func_list.size())
{
2014-12-01 01:41:01 +01:00
psv_func unimplemented;
2015-01-14 20:45:36 +01:00
unimplemented.nid = 0;
unimplemented.name = "Special function (unimplemented stub)";
unimplemented.func.reset(new psv_func_detail::func_binder<void, ARMv7Thread&>([](ARMv7Thread& CPU){ CPU.m_last_syscall = vm::psv::read32(CPU.PC + 4); throw "Unimplemented function executed"; }));
2014-12-01 01:41:01 +01:00
g_psv_func_list.push_back(unimplemented);
2014-12-01 01:41:01 +01:00
psv_func hle_return;
2015-01-14 20:45:36 +01:00
hle_return.nid = 1;
hle_return.name = "Special function (return from HLE)";
hle_return.func.reset(new psv_func_detail::func_binder<void, ARMv7Thread&>([](ARMv7Thread& CPU){ CPU.FastStop(); }));
2014-12-01 01:41:01 +01:00
g_psv_func_list.push_back(hle_return);
}
g_psv_func_list.push_back(data);
}
psv_func* get_psv_func_by_nid(u32 nid)
{
for (auto& f : g_psv_func_list)
{
2015-01-14 20:45:36 +01:00
if (f.nid == nid && &f - g_psv_func_list.data() >= 2 /* special functions count */)
{
return &f;
}
}
return nullptr;
}
u32 get_psv_func_index(psv_func* func)
{
2014-11-02 02:18:02 +01:00
auto res = func - g_psv_func_list.data();
2014-11-02 02:18:02 +01:00
assert((size_t)res < g_psv_func_list.size());
2014-11-02 02:18:02 +01:00
return (u32)res;
}
void execute_psv_func_by_index(ARMv7Thread& CPU, u32 index)
{
assert(index < g_psv_func_list.size());
2015-01-14 20:45:36 +01:00
auto old_last_syscall = CPU.m_last_syscall;
CPU.m_last_syscall = g_psv_func_list[index].nid;
(*g_psv_func_list[index].func)(CPU);
2015-01-14 20:45:36 +01:00
CPU.m_last_syscall = old_last_syscall;
}
2014-11-06 01:57:34 +01:00
extern psv_log_base sceLibc;
extern psv_log_base sceLibm;
extern psv_log_base sceLibstdcxx;
extern psv_log_base sceLibKernel;
void list_known_psv_modules()
{
sceLibc.Log("");
2014-11-05 17:07:34 +01:00
sceLibm.Log("");
2014-11-04 01:51:26 +01:00
sceLibstdcxx.Log("");
2014-11-05 17:07:34 +01:00
sceLibKernel.Log("");
}