reimplemented sceKernelReadTsc in proper package and some abi fixes

This commit is contained in:
georgemoralis 2023-10-30 20:22:25 +02:00
parent 61e8919cf1
commit 6f941c277a
7 changed files with 21 additions and 16 deletions

View File

@ -77,7 +77,7 @@ bool FlipQueue::submitFlip(VideoConfigInternal* cfg, s32 index, s64 flip_arg) {
r.cfg = cfg; r.cfg = cfg;
r.index = index; r.index = index;
r.flip_arg = flip_arg; r.flip_arg = flip_arg;
r.submit_tsc = HLE::Libs::LibKernel::sceKernelReadTsc(); r.submit_tsc = Core::Libraries::LibKernel::sceKernelReadTsc();
m_requests.push_back(r); m_requests.push_back(r);
@ -122,7 +122,7 @@ bool FlipQueue::flip(u32 micros) {
request->cfg->m_flip_status.count++; request->cfg->m_flip_status.count++;
request->cfg->m_flip_status.processTime = Core::Libraries::LibKernel::sceKernelGetProcessTime(); request->cfg->m_flip_status.processTime = Core::Libraries::LibKernel::sceKernelGetProcessTime();
request->cfg->m_flip_status.tsc = HLE::Libs::LibKernel::sceKernelReadTsc(); request->cfg->m_flip_status.tsc = Core::Libraries::LibKernel::sceKernelReadTsc();
request->cfg->m_flip_status.submitTsc = request->submit_tsc; request->cfg->m_flip_status.submitTsc = request->submit_tsc;
request->cfg->m_flip_status.flipArg = request->flip_arg; request->cfg->m_flip_status.flipArg = request->flip_arg;
request->cfg->m_flip_status.currentBuffer = request->index; request->cfg->m_flip_status.currentBuffer = request->index;

View File

@ -25,11 +25,7 @@ int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len) {
} }
static PS4_SYSV_ABI void stack_chk_fail() { BREAKPOINT(); } static PS4_SYSV_ABI void stack_chk_fail() { BREAKPOINT(); }
u64 PS4_SYSV_ABI sceKernelReadTsc() {
LARGE_INTEGER c;
QueryPerformanceCounter(&c);
return c.QuadPart;
}
int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) { BREAKPOINT(); } int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) { BREAKPOINT(); }
void LibKernel_Register(SymbolsResolver* sym) { void LibKernel_Register(SymbolsResolver* sym) {
// obj // obj
@ -46,8 +42,6 @@ void LibKernel_Register(SymbolsResolver* sym) {
// misc // misc
LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, CPUManagement::sceKernelIsNeoMode); LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, CPUManagement::sceKernelIsNeoMode);
LIB_FUNCTION("Ou3iL1abvng", "libkernel", 1, "libkernel", 1, 1, stack_chk_fail); LIB_FUNCTION("Ou3iL1abvng", "libkernel", 1, "libkernel", 1, 1, stack_chk_fail);
// time
LIB_FUNCTION("-2IRUCO--PM", "libkernel", 1, "libkernel", 1, 1, sceKernelReadTsc);
// fs // fs
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::sceKernelOpen); LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::sceKernelOpen);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX::open); LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX::open);

View File

@ -6,6 +6,5 @@ void LibKernel_Register(SymbolsResolver* sym);
// functions // functions
u64 PS4_SYSV_ABI sceKernelReadTsc();
int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len); int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len);
}; // namespace HLE::Libs::LibKernel }; // namespace HLE::Libs::LibKernel

View File

@ -1,21 +1,24 @@
#include "time_management.h" #include "time_management.h"
#include <Core/PS4/HLE/Libs.h> #include <Core/PS4/HLE/Libs.h>
#include "Lib/Timer.h"
#include "emuTimer.h" #include "emuTimer.h"
namespace Core::Libraries::LibKernel { namespace Core::Libraries::LibKernel {
u64 sceKernelGetProcessTime() { u64 PS4_SYSV_ABI sceKernelGetProcessTime() {
return static_cast<u64>(Emulator::emuTimer::getTimeMsec() * 1000.0); // return time in microseconds return static_cast<u64>(Emulator::emuTimer::getTimeMsec() * 1000.0); // return time in microseconds
} }
u64 sceKernelGetProcessTimeCounter() { return Emulator::emuTimer::getTimeCounter(); } u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounter() { return Emulator::emuTimer::getTimeCounter(); }
u64 sceKernelGetProcessTimeCounterFrequency() { return Emulator::emuTimer::getTimeFrequency(); } u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounterFrequency() { return Emulator::emuTimer::getTimeFrequency(); }
u64 PS4_SYSV_ABI sceKernelReadTsc() { return Lib::Timer::getQueryPerformanceCounter(); }
void timeSymbolsRegister(SymbolsResolver* sym) { void timeSymbolsRegister(SymbolsResolver* sym) {
LIB_FUNCTION("4J2sUJmuHZQ", "libkernel", 1, "libkernel", 1, 1, sceKernelGetProcessTime); LIB_FUNCTION("4J2sUJmuHZQ", "libkernel", 1, "libkernel", 1, 1, sceKernelGetProcessTime);
LIB_FUNCTION("fgxnMeTNUtY", "libkernel", 1, "libkernel", 1, 1, sceKernelGetProcessTimeCounter); LIB_FUNCTION("fgxnMeTNUtY", "libkernel", 1, "libkernel", 1, 1, sceKernelGetProcessTimeCounter);
LIB_FUNCTION("BNowx2l588E", "libkernel", 1, "libkernel", 1, 1, sceKernelGetProcessTimeCounterFrequency); LIB_FUNCTION("BNowx2l588E", "libkernel", 1, "libkernel", 1, 1, sceKernelGetProcessTimeCounterFrequency);
LIB_FUNCTION("-2IRUCO--PM", "libkernel", 1, "libkernel", 1, 1, sceKernelReadTsc);
} }
} // namespace Core::Libraries::LibKernel } // namespace Core::Libraries::LibKernel

View File

@ -4,7 +4,10 @@
#include "Core/PS4/Loader/SymbolsResolver.h" #include "Core/PS4/Loader/SymbolsResolver.h"
namespace Core::Libraries::LibKernel { namespace Core::Libraries::LibKernel {
u64 sceKernelGetProcessTime(); u64 PS4_SYSV_ABI sceKernelGetProcessTime();
u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounter();
u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounterFrequency();
u64 PS4_SYSV_ABI sceKernelReadTsc();
void timeSymbolsRegister(SymbolsResolver* sym); void timeSymbolsRegister(SymbolsResolver* sym);
} }

View File

@ -101,3 +101,9 @@ u64 Lib::Timer::GetTicks() const {
u64 Lib::Timer::GetFrequency() const { return m_Frequency; } u64 Lib::Timer::GetFrequency() const { return m_Frequency; }
u64 Lib::Timer::getQueryPerformanceCounter() {
LARGE_INTEGER c;
QueryPerformanceCounter(&c);
return c.QuadPart;
}

View File

@ -18,7 +18,7 @@ namespace Lib {
double GetTimeSec() const;// return time in seconds double GetTimeSec() const;// return time in seconds
u64 GetTicks() const;// return time in ticks u64 GetTicks() const;// return time in ticks
u64 GetFrequency() const;// return ticks frequency u64 GetFrequency() const;// return ticks frequency
[[nodiscard]] static u64 getQueryPerformanceCounter();
public: public:
Timer(const Timer&) = delete; Timer(const Timer&) = delete;
Timer& operator=(const Timer&) = delete; Timer& operator=(const Timer&) = delete;