mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-26 20:15:03 +00:00
kernel: Moved some functions to time
This commit is contained in:
parent
bd66ecfff2
commit
6a686df402
@ -820,65 +820,6 @@ int PS4_SYSV_ABI posix_pthread_mutexattr_setprotocol(ScePthreadMutexattr* attr,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, SceKernelTimespec* tp) {
|
|
||||||
if (tp == nullptr) {
|
|
||||||
return SCE_KERNEL_ERROR_EFAULT;
|
|
||||||
}
|
|
||||||
clockid_t pclock_id = CLOCK_REALTIME;
|
|
||||||
switch (clock_id) {
|
|
||||||
case 0:
|
|
||||||
pclock_id = CLOCK_REALTIME;
|
|
||||||
break;
|
|
||||||
case 13:
|
|
||||||
case 4:
|
|
||||||
pclock_id = CLOCK_MONOTONIC;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
timespec t{};
|
|
||||||
int result = clock_gettime(pclock_id, &t);
|
|
||||||
tp->tv_sec = t.tv_sec;
|
|
||||||
tp->tv_nsec = t.tv_nsec;
|
|
||||||
if (result == 0) {
|
|
||||||
return SCE_OK;
|
|
||||||
}
|
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI clock_gettime(s32 clock_id, SceKernelTimespec* time) {
|
|
||||||
int result = sceKernelClockGettime(clock_id, time);
|
|
||||||
if (result < 0) {
|
|
||||||
UNREACHABLE(); // TODO return posix error code
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelNanosleep(const SceKernelTimespec* rqtp, SceKernelTimespec* rmtp) {
|
|
||||||
|
|
||||||
if (rqtp == nullptr) {
|
|
||||||
return SCE_KERNEL_ERROR_EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0) {
|
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 nanos = rqtp->tv_sec * 1000000000 + rqtp->tv_nsec;
|
|
||||||
std::this_thread::sleep_for(std::chrono::nanoseconds(nanos));
|
|
||||||
if (rmtp != nullptr) {
|
|
||||||
UNREACHABLE(); // not supported yet
|
|
||||||
}
|
|
||||||
return SCE_OK;
|
|
||||||
}
|
|
||||||
int PS4_SYSV_ABI nanosleep(const SceKernelTimespec* rqtp, SceKernelTimespec* rmtp) {
|
|
||||||
int result = sceKernelNanosleep(rqtp, rmtp);
|
|
||||||
if (result < 0) {
|
|
||||||
UNREACHABLE(); // TODO return posix error code
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
static int pthread_copy_attributes(ScePthreadAttr* dst, const ScePthreadAttr* src) {
|
static int pthread_copy_attributes(ScePthreadAttr* dst, const ScePthreadAttr* src) {
|
||||||
if (dst == nullptr || *dst == nullptr || src == nullptr || *src == nullptr) {
|
if (dst == nullptr || *dst == nullptr || src == nullptr || *src == nullptr) {
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return SCE_KERNEL_ERROR_EINVAL;
|
||||||
@ -1288,10 +1229,6 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
|
|||||||
posix_pthread_mutexattr_setprotocol);
|
posix_pthread_mutexattr_setprotocol);
|
||||||
LIB_FUNCTION("HF7lK46xzjY", "libScePosix", 1, "libkernel", 1, 1,
|
LIB_FUNCTION("HF7lK46xzjY", "libScePosix", 1, "libkernel", 1, 1,
|
||||||
posix_pthread_mutexattr_destroy);
|
posix_pthread_mutexattr_destroy);
|
||||||
LIB_FUNCTION("QBi7HCK03hw", "libkernel", 1, "libkernel", 1, 1, sceKernelClockGettime);
|
|
||||||
LIB_FUNCTION("lLMT9vJAck0", "libkernel", 1, "libkernel", 1, 1, clock_gettime);
|
|
||||||
LIB_FUNCTION("lLMT9vJAck0", "libScePosix", 1, "libkernel", 1, 1, clock_gettime);
|
|
||||||
LIB_FUNCTION("yS8U2TGCe1A", "libScePosix", 1, "libkernel", 1, 1, nanosleep);
|
|
||||||
|
|
||||||
// openorbis weird functions
|
// openorbis weird functions
|
||||||
LIB_FUNCTION("7H0iTOciTLo", "libkernel", 1, "libkernel", 1, 1, posix_pthread_mutex_lock);
|
LIB_FUNCTION("7H0iTOciTLo", "libkernel", 1, "libkernel", 1, 1, posix_pthread_mutex_lock);
|
||||||
|
@ -41,11 +41,6 @@ using OrbisPthreadRwlockattr = PthreadRwLockAttrInernal*;
|
|||||||
|
|
||||||
using pthreadEntryFunc = PS4_SYSV_ABI void* (*)(void*);
|
using pthreadEntryFunc = PS4_SYSV_ABI void* (*)(void*);
|
||||||
|
|
||||||
struct SceKernelTimespec {
|
|
||||||
int64_t tv_sec;
|
|
||||||
int64_t tv_nsec;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PthreadInternal {
|
struct PthreadInternal {
|
||||||
u8 reserved[4096];
|
u8 reserved[4096];
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -51,8 +51,57 @@ u32 PS4_SYSV_ABI sceKernelSleep(u32 seconds) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_nanosleep(timespec* requested_time, timespec* remaining) {
|
int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) {
|
||||||
return nanosleep(requested_time, remaining);
|
if (tp == nullptr) {
|
||||||
|
return SCE_KERNEL_ERROR_EFAULT;
|
||||||
|
}
|
||||||
|
clockid_t pclock_id = CLOCK_REALTIME;
|
||||||
|
switch (clock_id) {
|
||||||
|
case 0:
|
||||||
|
pclock_id = CLOCK_REALTIME;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
case 4:
|
||||||
|
pclock_id = CLOCK_MONOTONIC;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
timespec t{};
|
||||||
|
int result = clock_gettime(pclock_id, &t);
|
||||||
|
tp->tv_sec = t.tv_sec;
|
||||||
|
tp->tv_nsec = t.tv_nsec;
|
||||||
|
if (result == 0) {
|
||||||
|
return SCE_OK;
|
||||||
|
}
|
||||||
|
return SCE_KERNEL_ERROR_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PS4_SYSV_ABI clock_gettime(s32 clock_id, OrbisKernelTimespec* time) {
|
||||||
|
int result = sceKernelClockGettime(clock_id, time);
|
||||||
|
if (result < 0) {
|
||||||
|
UNREACHABLE(); // TODO return posix error code
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PS4_SYSV_ABI posix_nanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTimespec* rmtp) {
|
||||||
|
const auto* request = reinterpret_cast<const timespec*>(rqtp);
|
||||||
|
auto* remain = reinterpret_cast<timespec*>(rmtp);
|
||||||
|
return nanosleep(request, remain);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PS4_SYSV_ABI sceKernelNanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTimespec* rmtp) {
|
||||||
|
if (!rqtp || !rmtp) {
|
||||||
|
return SCE_KERNEL_ERROR_EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rqtp->tv_sec < 0 || rqtp->tv_nsec < 0) {
|
||||||
|
return SCE_KERNEL_ERROR_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return posix_nanosleep(rqtp, rmtp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelGettimeofday(OrbisKernelTimeval* tp) {
|
int PS4_SYSV_ABI sceKernelGettimeofday(OrbisKernelTimeval* tp) {
|
||||||
@ -97,6 +146,9 @@ void timeSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("-ZR+hG7aDHw", "libkernel", 1, "libkernel", 1, 1, sceKernelSleep);
|
LIB_FUNCTION("-ZR+hG7aDHw", "libkernel", 1, "libkernel", 1, 1, sceKernelSleep);
|
||||||
LIB_FUNCTION("0wu33hunNdE", "libScePosix", 1, "libkernel", 1, 1, sceKernelSleep);
|
LIB_FUNCTION("0wu33hunNdE", "libScePosix", 1, "libkernel", 1, 1, sceKernelSleep);
|
||||||
LIB_FUNCTION("yS8U2TGCe1A", "libkernel", 1, "libkernel", 1, 1, posix_nanosleep);
|
LIB_FUNCTION("yS8U2TGCe1A", "libkernel", 1, "libkernel", 1, 1, posix_nanosleep);
|
||||||
|
LIB_FUNCTION("QBi7HCK03hw", "libkernel", 1, "libkernel", 1, 1, sceKernelClockGettime);
|
||||||
|
LIB_FUNCTION("lLMT9vJAck0", "libkernel", 1, "libkernel", 1, 1, clock_gettime);
|
||||||
|
LIB_FUNCTION("lLMT9vJAck0", "libScePosix", 1, "libkernel", 1, 1, clock_gettime);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
||||||
|
@ -12,8 +12,8 @@ class SymbolsResolver;
|
|||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
|
|
||||||
struct OrbisKernelTimeval {
|
struct OrbisKernelTimeval {
|
||||||
u64 tv_sec;
|
s64 tv_sec;
|
||||||
u64 tv_usec;
|
s64 tv_usec;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrbisKernelTimezone {
|
struct OrbisKernelTimezone {
|
||||||
@ -21,6 +21,11 @@ struct OrbisKernelTimezone {
|
|||||||
s32 tz_dsttime;
|
s32 tz_dsttime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OrbisKernelTimespec {
|
||||||
|
s64 tv_sec;
|
||||||
|
s64 tv_nsec;
|
||||||
|
};
|
||||||
|
|
||||||
u64 PS4_SYSV_ABI sceKernelGetTscFrequency();
|
u64 PS4_SYSV_ABI sceKernelGetTscFrequency();
|
||||||
u64 PS4_SYSV_ABI sceKernelGetProcessTime();
|
u64 PS4_SYSV_ABI sceKernelGetProcessTime();
|
||||||
u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounter();
|
u64 PS4_SYSV_ABI sceKernelGetProcessTimeCounter();
|
||||||
|
Loading…
Reference in New Issue
Block a user