mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #27 from QDarkRex/refactor/kernel-error-header
refactor(kernel): share SCE kernel error codes through KernelErrors.hpp
This commit is contained in:
@@ -72,7 +72,7 @@ static int registerVideoOutEvent(int handle, KernelEqueue eq, int16_t eventKind,
|
||||
e->event.data = 0;
|
||||
};
|
||||
const int result = EqueueAddEvent_nid_postfix(eq, event);
|
||||
if (result == EQUEUE_ERROR_EBADF) {
|
||||
if (result == SCE_KERNEL_ERROR_EBADF) {
|
||||
throw std::runtime_error(std::string(__func__) + ": VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE");
|
||||
}
|
||||
if (result != EQUEUE_OK) throw std::runtime_error("VideoOut: event registration failed");
|
||||
@@ -99,10 +99,10 @@ static int deleteVideoOutEvent(int handle, KernelEqueue eq, int16_t eventKind) {
|
||||
events->erase(std::remove_if(events->begin(), events->end(), [eq](const EventRegistration& r) { return r.eq == eq; }), events->end());
|
||||
}
|
||||
const int result = EqueueDeleteEvent_nid_postfix(eq, static_cast<uintptr_t>(eventKind), EVFILT_VIDEO_OUT);
|
||||
if (result == EQUEUE_ERROR_EBADF) {
|
||||
if (result == SCE_KERNEL_ERROR_EBADF) {
|
||||
throw std::runtime_error(std::string(__func__) + ": VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE");
|
||||
}
|
||||
return (result == EQUEUE_ERROR_ENOENT) ? 0 : result;
|
||||
return (result == SCE_KERNEL_ERROR_ENOENT) ? 0 : result;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -301,7 +301,7 @@ bool VideoOutDriver::close(int handle) {
|
||||
const auto removeEvents = [](const auto& events, int kind) {
|
||||
for (const auto& event : events) {
|
||||
const auto result = EqueueDeleteEvent_nid_postfix(event.eq, static_cast<uintptr_t>(kind), EVFILT_VIDEO_OUT);
|
||||
require(result == EQUEUE_OK || result == EQUEUE_ERROR_EBADF || result == EQUEUE_ERROR_ENOENT, "event removal during close failed");
|
||||
require(result == EQUEUE_OK || result == SCE_KERNEL_ERROR_EBADF || result == SCE_KERNEL_ERROR_ENOENT, "event removal during close failed");
|
||||
}
|
||||
};
|
||||
removeEvents(cfg->flipEvents, VIDEO_OUT_EVENT_FLIP);
|
||||
@@ -357,7 +357,7 @@ void VideoOutDriver::triggerEvents(VideoOutConfig& cfg, int eventKind, void* tri
|
||||
for (auto it = events->begin(); it != events->end();) {
|
||||
require(it->generation == cfg.generation, "stale event registration");
|
||||
const auto result = EqueueTriggerEvent_nid_postfix(it->eq, static_cast<uintptr_t>(eventKind), EVFILT_VIDEO_OUT, triggerData);
|
||||
if (result == EQUEUE_ERROR_EBADF || result == EQUEUE_ERROR_ENOENT) it = events->erase(it);
|
||||
if (result == SCE_KERNEL_ERROR_EBADF || result == SCE_KERNEL_ERROR_ENOENT) it = events->erase(it);
|
||||
else {
|
||||
require(result == EQUEUE_OK, "event delivery failed");
|
||||
++it;
|
||||
|
||||
@@ -4,15 +4,11 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
|
||||
static constexpr size_t DIRECT_MEMORY_SIZE = 13824ULL * 1024 * 1024;
|
||||
static constexpr size_t PS5_PAGE_SIZE = 0x4000;
|
||||
|
||||
static constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016;
|
||||
static constexpr int SCE_KERNEL_ERROR_EAGAIN = 0x80020023;
|
||||
static constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000C;
|
||||
static constexpr int SCE_KERNEL_ERROR_EACCES = 0x8002000D;
|
||||
static constexpr int SCE_KERNEL_ERROR_EFAULT = 0x8002000E;
|
||||
|
||||
int DirectMemoryAlloc(int64_t searchStart, int64_t searchEnd, size_t len, size_t alignment, int64_t* physOut);
|
||||
void DirectMemoryFree(int64_t start, size_t len);
|
||||
int DoMapDirect(void** addr, size_t len, int prot, int flags, int64_t physStart, size_t alignment);
|
||||
|
||||
@@ -71,7 +71,7 @@ bool KernelEqueuePrivate::NextTimerWaitMicros(uint64_t nowNs, uint32_t* out) con
|
||||
int KernelEqueuePrivate::GetTriggeredEvents(KernelEvent* ev, int num) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
TriggerExpiredTimers(MonotonicNs());
|
||||
int ret = 0;
|
||||
@@ -111,7 +111,7 @@ int KernelEqueuePrivate::GetTriggeredEvents(KernelEvent* ev, int num) {
|
||||
int KernelEqueuePrivate::WaitForEvents(KernelEvent* ev, int num, uint32_t micros) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
const std::uint64_t deadline = TimedWait::DeadlineNanos(micros);
|
||||
for (;;) {
|
||||
@@ -148,7 +148,7 @@ int KernelEqueuePrivate::WaitForEvents(KernelEvent* ev, int num, uint32_t micros
|
||||
return ret;
|
||||
}
|
||||
if (m_closed) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
if (micros == 0) {
|
||||
m_cond.Wait(lock);
|
||||
@@ -168,7 +168,7 @@ int KernelEqueuePrivate::WaitForEvents(KernelEvent* ev, int num, uint32_t micros
|
||||
int KernelEqueuePrivate::AddEvent(const KernelEqueueEvent& event) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
auto it = std::find_if(m_events.begin(), m_events.end(),
|
||||
[ident = event.event.ident, filter = event.event.filter](const auto& e) {
|
||||
@@ -191,7 +191,7 @@ int KernelEqueuePrivate::AddEvent(const KernelEqueueEvent& event) {
|
||||
int KernelEqueuePrivate::TriggerEvent(uintptr_t ident, int16_t filter, void* triggerData) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
auto it = std::find_if(m_events.begin(), m_events.end(),
|
||||
[ident, filter](const auto& e) {
|
||||
@@ -199,7 +199,7 @@ int KernelEqueuePrivate::TriggerEvent(uintptr_t ident, int16_t filter, void* tri
|
||||
}
|
||||
);
|
||||
if (it == m_events.end()) {
|
||||
return EQUEUE_ERROR_ENOENT;
|
||||
return SCE_KERNEL_ERROR_ENOENT;
|
||||
}
|
||||
if (it->filter.triggerFunc != nullptr) {
|
||||
it->filter.triggerFunc(&*it, triggerData);
|
||||
@@ -213,7 +213,7 @@ int KernelEqueuePrivate::TriggerEvent(uintptr_t ident, int16_t filter, void* tri
|
||||
int KernelEqueuePrivate::DeleteEvent(uintptr_t ident, int16_t filter) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
auto it = std::find_if(m_events.begin(), m_events.end(),
|
||||
[ident, filter](const auto& e) {
|
||||
@@ -221,7 +221,7 @@ int KernelEqueuePrivate::DeleteEvent(uintptr_t ident, int16_t filter) {
|
||||
}
|
||||
);
|
||||
if (it == m_events.end()) {
|
||||
return EQUEUE_ERROR_ENOENT;
|
||||
return SCE_KERNEL_ERROR_ENOENT;
|
||||
}
|
||||
if (it->filter.deleteEventFunc != nullptr) {
|
||||
auto owner = it->filter.owner;
|
||||
@@ -243,7 +243,7 @@ KernelEqueueRef EqueuePin_nid_postfix(KernelEqueue eq) {
|
||||
int APS5_VABI EqueueAddEvent_nid_postfix(KernelEqueue eq, const KernelEqueueEvent& event) {
|
||||
auto owner = EqueuePin_nid_postfix(eq);
|
||||
if (!owner) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
return owner->AddEvent(event);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ int APS5_VABI EqueueAddEvent_nid_postfix(KernelEqueue eq, const KernelEqueueEven
|
||||
int APS5_VABI EqueueTriggerEvent_nid_postfix(KernelEqueue eq, uintptr_t ident, int16_t filter, void* triggerData) {
|
||||
auto owner = EqueuePin_nid_postfix(eq);
|
||||
if (!owner) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
return owner->TriggerEvent(ident, filter, triggerData);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ int APS5_VABI EqueueTriggerEvent_nid_postfix(KernelEqueue eq, uintptr_t ident, i
|
||||
int APS5_VABI EqueueDeleteEvent_nid_postfix(KernelEqueue eq, uintptr_t ident, int16_t filter) {
|
||||
auto owner = EqueuePin_nid_postfix(eq);
|
||||
if (!owner) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
return owner->DeleteEvent(ident, filter);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ int APS5_VABI EqueueDeleteEvent_nid_postfix(KernelEqueue eq, uintptr_t ident, in
|
||||
|
||||
int APS5_VABI sceKernelCreateEqueue(KernelEqueue* eq, const char* name) {
|
||||
if (eq == nullptr || name == nullptr) {
|
||||
return EQUEUE_ERROR_EINVAL;
|
||||
return SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
std::unique_lock lock(g_equeueMutex);
|
||||
if (g_nextEqueue > static_cast<uint64_t>(std::numeric_limits<KernelEqueue>::max())) {
|
||||
@@ -286,7 +286,7 @@ int APS5_VABI sceKernelDeleteEqueue(KernelEqueue eq) {
|
||||
std::unique_lock lock(g_equeueMutex);
|
||||
auto it = g_equeues.find(eq);
|
||||
if (it == g_equeues.end()) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
owner = std::move(it->second);
|
||||
g_equeues.erase(it);
|
||||
@@ -298,13 +298,13 @@ int APS5_VABI sceKernelDeleteEqueue(KernelEqueue eq) {
|
||||
int APS5_VABI sceKernelWaitEqueue(KernelEqueue eq, KernelEvent* ev, int num, int* out, const KernelUseconds* timo) {
|
||||
auto owner = EqueuePin_nid_postfix(eq);
|
||||
if (!owner) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
if (ev == nullptr) {
|
||||
return EQUEUE_ERROR_EFAULT;
|
||||
return SCE_KERNEL_ERROR_EFAULT;
|
||||
}
|
||||
if (num < 1 || out == nullptr) {
|
||||
return EQUEUE_ERROR_EINVAL;
|
||||
return SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
const auto waitStart = std::chrono::steady_clock::now();
|
||||
if (timo == nullptr) {
|
||||
@@ -317,11 +317,11 @@ int APS5_VABI sceKernelWaitEqueue(KernelEqueue eq, KernelEvent* ev, int num, int
|
||||
if (timo == nullptr || *timo != 0) {
|
||||
KernelTraceWait_nid_postfix("equeue", __builtin_return_address(0), static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now() - waitStart).count()), *out == 0);
|
||||
}
|
||||
if (*out == EQUEUE_ERROR_EBADF) {
|
||||
return EQUEUE_ERROR_EBADF;
|
||||
if (*out == SCE_KERNEL_ERROR_EBADF) {
|
||||
return SCE_KERNEL_ERROR_EBADF;
|
||||
}
|
||||
if (*out == 0) {
|
||||
return EQUEUE_ERROR_ETIMEDOUT;
|
||||
return SCE_KERNEL_ERROR_ETIMEDOUT;
|
||||
}
|
||||
return EQUEUE_OK;
|
||||
}
|
||||
@@ -376,10 +376,10 @@ int APS5_VABI sceKernelDeleteUserEvent(KernelEqueue eq, int id) {
|
||||
|
||||
int APS5_VABI sceKernelAddHRTimerEvent(KernelEqueue eq, int id, const KernelTimespec* ts, void* udata) {
|
||||
if (ts == nullptr) {
|
||||
return EQUEUE_ERROR_EFAULT;
|
||||
return SCE_KERNEL_ERROR_EFAULT;
|
||||
}
|
||||
if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000LL) {
|
||||
return EQUEUE_ERROR_EINVAL;
|
||||
return SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
const uint64_t delayNs =
|
||||
static_cast<uint64_t>(ts->tv_sec) * 1000000000ULL +
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/general/VabiMacros.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#include "prx/libkernel/Time/include/TimedWait.hpp"
|
||||
|
||||
static constexpr int16_t EVFILT_USER = -11;
|
||||
@@ -23,11 +24,6 @@ static constexpr uint16_t EV_CLEAR = 0x0020;
|
||||
static constexpr uint16_t EV_ERROR = 0x4000;
|
||||
|
||||
static constexpr int EQUEUE_OK = 0;
|
||||
static constexpr int EQUEUE_ERROR_EBADF = 0x80020009;
|
||||
static constexpr int EQUEUE_ERROR_EFAULT = 0x8002000E;
|
||||
static constexpr int EQUEUE_ERROR_EINVAL = 0x80020016;
|
||||
static constexpr int EQUEUE_ERROR_ENOENT = 0x80020002;
|
||||
static constexpr int EQUEUE_ERROR_ETIMEDOUT = 0x8002003C;
|
||||
|
||||
struct KernelEqueueEvent;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "prx/libkernel/File/include/NativeStat.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include "prx/libkernel/File/include/File.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#include "SceTypes.hpp"
|
||||
|
||||
#include <cerrno>
|
||||
@@ -9,8 +10,6 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
static constexpr int SCE_KERNEL_ERROR_ENOENT = -2147352574;
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBKERNEL_KERNELERRORS_HPP
|
||||
#define CORE_LIBS_PRX_LIBKERNEL_KERNELERRORS_HPP
|
||||
|
||||
constexpr int SceKernelError(int errnoValue) {
|
||||
return static_cast<int>(0x80020000u | static_cast<unsigned>(errnoValue));
|
||||
}
|
||||
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPERM = SceKernelError(1);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOENT = SceKernelError(2);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ESRCH = SceKernelError(3);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EINTR = SceKernelError(4);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EIO = SceKernelError(5);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENXIO = SceKernelError(6);
|
||||
inline constexpr int SCE_KERNEL_ERROR_E2BIG = SceKernelError(7);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOEXEC = SceKernelError(8);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EBADF = SceKernelError(9);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ECHILD = SceKernelError(10);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EDEADLK = SceKernelError(11);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOMEM = SceKernelError(12);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EACCES = SceKernelError(13);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EFAULT = SceKernelError(14);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOTBLK = SceKernelError(15);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EBUSY = SceKernelError(16);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EEXIST = SceKernelError(17);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EXDEV = SceKernelError(18);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENODEV = SceKernelError(19);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOTDIR = SceKernelError(20);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EISDIR = SceKernelError(21);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EINVAL = SceKernelError(22);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENFILE = SceKernelError(23);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EMFILE = SceKernelError(24);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOTTY = SceKernelError(25);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ETXTBSY = SceKernelError(26);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EFBIG = SceKernelError(27);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOSPC = SceKernelError(28);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ESPIPE = SceKernelError(29);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EROFS = SceKernelError(30);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EMLINK = SceKernelError(31);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPIPE = SceKernelError(32);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EDOM = SceKernelError(33);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ERANGE = SceKernelError(34);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EAGAIN = SceKernelError(35);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EINPROGRESS = SceKernelError(36);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EALREADY = SceKernelError(37);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOTSOCK = SceKernelError(38);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EDESTADDRREQ = SceKernelError(39);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EMSGSIZE = SceKernelError(40);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPROTOTYPE = SceKernelError(41);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOPROTOOPT = SceKernelError(42);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPROTONOSUPPORT = SceKernelError(43);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ESOCKTNOSUPPORT = SceKernelError(44);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EOPNOTSUPP = SceKernelError(45);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPFNOSUPPORT = SceKernelError(46);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EAFNOSUPPORT = SceKernelError(47);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EADDRINUSE = SceKernelError(48);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EADDRNOTAVAIL = SceKernelError(49);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENETDOWN = SceKernelError(50);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENETUNREACH = SceKernelError(51);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENETRESET = SceKernelError(52);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ECONNABORTED = SceKernelError(53);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ECONNRESET = SceKernelError(54);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOBUFS = SceKernelError(55);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EISCONN = SceKernelError(56);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOTCONN = SceKernelError(57);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ESHUTDOWN = SceKernelError(58);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ETOOMANYREFS = SceKernelError(59);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ETIMEDOUT = SceKernelError(60);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ECONNREFUSED = SceKernelError(61);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ELOOP = SceKernelError(62);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENAMETOOLONG = SceKernelError(63);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EHOSTDOWN = SceKernelError(64);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EHOSTUNREACH = SceKernelError(65);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOTEMPTY = SceKernelError(66);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPROCLIM = SceKernelError(67);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EUSERS = SceKernelError(68);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EDQUOT = SceKernelError(69);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ESTALE = SceKernelError(70);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EREMOTE = SceKernelError(71);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EBADRPC = SceKernelError(72);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ERPCMISMATCH = SceKernelError(73);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPROGUNAVAIL = SceKernelError(74);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPROGMISMATCH = SceKernelError(75);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPROCUNAVAIL = SceKernelError(76);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOLCK = SceKernelError(77);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOSYS = SceKernelError(78);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EFTYPE = SceKernelError(79);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EAUTH = SceKernelError(80);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENEEDAUTH = SceKernelError(81);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EIDRM = SceKernelError(82);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOMSG = SceKernelError(83);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EOVERFLOW = SceKernelError(84);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ECANCELED = SceKernelError(85);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EILSEQ = SceKernelError(86);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOATTR = SceKernelError(87);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EDOOFUS = SceKernelError(88);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EBADMSG = SceKernelError(89);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EMULTIHOP = SceKernelError(90);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOLINK = SceKernelError(91);
|
||||
inline constexpr int SCE_KERNEL_ERROR_EPROTO = SceKernelError(92);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ENOTCAPABLE = SceKernelError(93);
|
||||
inline constexpr int SCE_KERNEL_ERROR_ECAPMODE = SceKernelError(94);
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "prx/libkernel/Pthread/include/Pthread.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
static constexpr int SCE_OK = 0;
|
||||
static constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016;
|
||||
static constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000C;
|
||||
|
||||
static constexpr std::size_t DEFAULT_STACK_SIZE = 1u << 20;
|
||||
static constexpr int DETACH_JOINABLE = 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "../include/Pthread.hpp"
|
||||
#include "../include/ThreadLifecycle.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#include "prx/libc/include/CpuTopology.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
@@ -19,7 +20,6 @@
|
||||
#endif
|
||||
|
||||
static constexpr int SCE_OK = 0;
|
||||
static constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016;
|
||||
|
||||
static constexpr std::size_t DEFAULT_STACK_SIZE = 1u << 20;
|
||||
static constexpr int DETACH_DETACHED = 1;
|
||||
|
||||
@@ -8,13 +8,10 @@
|
||||
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#include "prx/libkernel/Time/include/TimedWait.hpp"
|
||||
|
||||
constexpr int KERNEL_SEMA_OK = 0;
|
||||
constexpr int KERNEL_SEMA_ERROR_EINVAL = static_cast<int>(0x80020016);
|
||||
constexpr int KERNEL_SEMA_ERROR_EACCES = static_cast<int>(0x8002000D);
|
||||
constexpr int KERNEL_SEMA_ERROR_EBUSY = static_cast<int>(0x80020010);
|
||||
constexpr int KERNEL_SEMA_ERROR_ETIMEDOUT = static_cast<int>(0x8002003C);
|
||||
|
||||
struct KernelSemaPrivate {
|
||||
KernelSemaPrivate(std::int32_t initCount, std::int32_t maxCount, std::string name, bool isFifo);
|
||||
|
||||
@@ -29,7 +29,7 @@ int APS5_VABI sceKernelPollSema(KernelSema sem, int need) {
|
||||
|
||||
std::lock_guard<std::mutex> lock(sem->mutex);
|
||||
if (sem->tokenCount < need) {
|
||||
return KERNEL_SEMA_ERROR_EBUSY;
|
||||
return SCE_KERNEL_ERROR_EBUSY;
|
||||
}
|
||||
sem->tokenCount -= need;
|
||||
return KERNEL_SEMA_OK;
|
||||
@@ -42,7 +42,7 @@ int APS5_VABI sceKernelSignalSema(KernelSema sem, int count) {
|
||||
|
||||
std::lock_guard<std::mutex> lock(sem->mutex);
|
||||
if (sem->tokenCount + count > sem->maxCount) {
|
||||
return KERNEL_SEMA_ERROR_EINVAL;
|
||||
return SCE_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
sem->tokenCount += count;
|
||||
sem->condition.NotifyAll();
|
||||
@@ -72,7 +72,7 @@ int APS5_VABI sceKernelWaitSema(KernelSema sem, int need, KernelUseconds* time)
|
||||
sem->condition.Wait(lock, [&] { return sem->tokenCount >= need || sem->deleted; });
|
||||
traceWait(false);
|
||||
if (sem->deleted) {
|
||||
return KERNEL_SEMA_ERROR_EACCES;
|
||||
return SCE_KERNEL_ERROR_EACCES;
|
||||
}
|
||||
sem->tokenCount -= need;
|
||||
return KERNEL_SEMA_OK;
|
||||
@@ -81,10 +81,10 @@ int APS5_VABI sceKernelWaitSema(KernelSema sem, int need, KernelUseconds* time)
|
||||
const bool acquired = sem->condition.WaitUntil(lock, TimedWait::DeadlineNanos(*time), [&] { return sem->tokenCount >= need || sem->deleted; });
|
||||
traceWait(!acquired);
|
||||
if (sem->deleted) {
|
||||
return KERNEL_SEMA_ERROR_EACCES;
|
||||
return SCE_KERNEL_ERROR_EACCES;
|
||||
}
|
||||
if (!acquired) {
|
||||
return KERNEL_SEMA_ERROR_ETIMEDOUT;
|
||||
return SCE_KERNEL_ERROR_ETIMEDOUT;
|
||||
}
|
||||
sem->tokenCount -= need;
|
||||
return KERNEL_SEMA_OK;
|
||||
|
||||
Reference in New Issue
Block a user