diff --git a/core/libs/prx/libSceVideoOut/src/Event.cpp b/core/libs/prx/libSceVideoOut/src/Event.cpp index fcf64b9e9..01b2b7d79 100644 --- a/core/libs/prx/libSceVideoOut/src/Event.cpp +++ b/core/libs/prx/libSceVideoOut/src/Event.cpp @@ -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(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" { diff --git a/core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp b/core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp index f933db424..9067f586b 100644 --- a/core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp +++ b/core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp @@ -278,7 +278,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(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); @@ -329,7 +329,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(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; diff --git a/core/libs/prx/libkernel/DirectMemory/DirectMemory.hpp b/core/libs/prx/libkernel/DirectMemory/DirectMemory.hpp index ff97aaeb1..4c7f3f477 100644 --- a/core/libs/prx/libkernel/DirectMemory/DirectMemory.hpp +++ b/core/libs/prx/libkernel/DirectMemory/DirectMemory.hpp @@ -4,15 +4,11 @@ #include #include +#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); diff --git a/core/libs/prx/libkernel/Equeue/Equeue.cpp b/core/libs/prx/libkernel/Equeue/Equeue.cpp index 3b9b49b27..e0d4cc3fa 100644 --- a/core/libs/prx/libkernel/Equeue/Equeue.cpp +++ b/core/libs/prx/libkernel/Equeue/Equeue.cpp @@ -70,7 +70,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; @@ -110,7 +110,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 auto deadline = std::chrono::steady_clock::now() + std::chrono::microseconds(micros); @@ -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); @@ -173,7 +173,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) { @@ -196,7 +196,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) { @@ -204,7 +204,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); @@ -218,7 +218,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) { @@ -226,7 +226,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; @@ -248,7 +248,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); } @@ -256,7 +256,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); } @@ -264,7 +264,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); } @@ -272,7 +272,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(std::numeric_limits::max())) { @@ -291,7 +291,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); @@ -303,13 +303,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; } if (timo == nullptr) { *out = owner->WaitForEvents(ev, num, 0); @@ -318,11 +318,11 @@ int APS5_VABI sceKernelWaitEqueue(KernelEqueue eq, KernelEvent* ev, int num, int } else { *out = owner->WaitForEvents(ev, num, *timo); } - 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; } @@ -377,10 +377,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(ts->tv_sec) * 1000000000ULL + diff --git a/core/libs/prx/libkernel/Equeue/Equeue.hpp b/core/libs/prx/libkernel/Equeue/Equeue.hpp index e8571a78e..eed258f92 100644 --- a/core/libs/prx/libkernel/Equeue/Equeue.hpp +++ b/core/libs/prx/libkernel/Equeue/Equeue.hpp @@ -12,6 +12,7 @@ #include "SceTypes.hpp" #include "prx/libc/include/general/VabiMacros.hpp" +#include "prx/libkernel/KernelErrors.hpp" static constexpr int16_t EVFILT_USER = -11; static constexpr int16_t EVFILT_VIDEO_OUT = -13; @@ -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; diff --git a/core/libs/prx/libkernel/File/src/Open.cpp b/core/libs/prx/libkernel/File/src/Open.cpp index d22122583..c12bce199 100644 --- a/core/libs/prx/libkernel/File/src/Open.cpp +++ b/core/libs/prx/libkernel/File/src/Open.cpp @@ -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 @@ -9,8 +10,6 @@ #include #include -static constexpr int SCE_KERNEL_ERROR_ENOENT = -2147352574; - #ifdef _WIN32 #include #include diff --git a/core/libs/prx/libkernel/KernelErrors.hpp b/core/libs/prx/libkernel/KernelErrors.hpp new file mode 100644 index 000000000..b7d37ba4f --- /dev/null +++ b/core/libs/prx/libkernel/KernelErrors.hpp @@ -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(0x80020000u | static_cast(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 diff --git a/core/libs/prx/libkernel/Pthread/src/Attr.cpp b/core/libs/prx/libkernel/Pthread/src/Attr.cpp index 7f71adb80..89db40356 100644 --- a/core/libs/prx/libkernel/Pthread/src/Attr.cpp +++ b/core/libs/prx/libkernel/Pthread/src/Attr.cpp @@ -1,9 +1,9 @@ #include "../include/Pthread.hpp" #include "prx/libc/include/General.hpp" +#include "prx/libkernel/KernelErrors.hpp" #include static constexpr int SCE_OK = 0; -static constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000C; static constexpr std::size_t DEFAULT_STACK_SIZE = 1u << 20; static constexpr int DETACH_JOINABLE = 0; diff --git a/core/libs/prx/libkernel/Pthread/src/Cond.cpp b/core/libs/prx/libkernel/Pthread/src/Cond.cpp index 8d7494f26..7346428f0 100644 --- a/core/libs/prx/libkernel/Pthread/src/Cond.cpp +++ b/core/libs/prx/libkernel/Pthread/src/Cond.cpp @@ -1,11 +1,10 @@ #include "../include/Pthread.hpp" #include "prx/libc/include/General.hpp" +#include "prx/libkernel/KernelErrors.hpp" #include #include static constexpr int SCE_OK = 0; -static constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000C; -static constexpr int SCE_KERNEL_ERROR_ETIMEDOUT = 0x8002003C; extern "C" { diff --git a/core/libs/prx/libkernel/Pthread/src/Mutex.cpp b/core/libs/prx/libkernel/Pthread/src/Mutex.cpp index 2f216474c..8c0223bbb 100644 --- a/core/libs/prx/libkernel/Pthread/src/Mutex.cpp +++ b/core/libs/prx/libkernel/Pthread/src/Mutex.cpp @@ -1,13 +1,11 @@ #include "../include/Pthread.hpp" #include "prx/libc/include/General.hpp" +#include "prx/libkernel/KernelErrors.hpp" #include #include #include static constexpr int SCE_OK = 0; -static constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000C; -static constexpr int SCE_KERNEL_ERROR_EDEADLK = 0x8002000B; -static constexpr int SCE_KERNEL_ERROR_EPERM = 0x80020001; extern "C" { diff --git a/core/libs/prx/libkernel/Pthread/src/Thread.cpp b/core/libs/prx/libkernel/Pthread/src/Thread.cpp index aab144818..578e99dcf 100644 --- a/core/libs/prx/libkernel/Pthread/src/Thread.cpp +++ b/core/libs/prx/libkernel/Pthread/src/Thread.cpp @@ -1,5 +1,6 @@ #include "../include/Pthread.hpp" #include "prx/libc/include/General.hpp" +#include "prx/libkernel/KernelErrors.hpp" #include #include #include @@ -12,7 +13,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; diff --git a/core/libs/prx/libkernel/Semaphore/include/Semaphore.hpp b/core/libs/prx/libkernel/Semaphore/include/Semaphore.hpp index 2ec36278e..d266a5689 100644 --- a/core/libs/prx/libkernel/Semaphore/include/Semaphore.hpp +++ b/core/libs/prx/libkernel/Semaphore/include/Semaphore.hpp @@ -9,12 +9,9 @@ #include "SceTypes.hpp" #include "prx/libc/include/General.hpp" +#include "prx/libkernel/KernelErrors.hpp" constexpr int KERNEL_SEMA_OK = 0; -constexpr int KERNEL_SEMA_ERROR_EINVAL = static_cast(0x80020016); -constexpr int KERNEL_SEMA_ERROR_EACCES = static_cast(0x8002000D); -constexpr int KERNEL_SEMA_ERROR_EBUSY = static_cast(0x80020010); -constexpr int KERNEL_SEMA_ERROR_ETIMEDOUT = static_cast(0x8002003C); struct KernelSemaPrivate { KernelSemaPrivate(std::int32_t initCount, std::int32_t maxCount, std::string name, bool isFifo); diff --git a/core/libs/prx/libkernel/Semaphore/src/Semaphore.cpp b/core/libs/prx/libkernel/Semaphore/src/Semaphore.cpp index de7bb4808..a608aeec1 100644 --- a/core/libs/prx/libkernel/Semaphore/src/Semaphore.cpp +++ b/core/libs/prx/libkernel/Semaphore/src/Semaphore.cpp @@ -27,7 +27,7 @@ int APS5_VABI sceKernelPollSema(KernelSema sem, int need) { std::lock_guard lock(sem->mutex); if (sem->tokenCount < need) { - return KERNEL_SEMA_ERROR_EBUSY; + return SCE_KERNEL_ERROR_EBUSY; } sem->tokenCount -= need; return KERNEL_SEMA_OK; @@ -40,7 +40,7 @@ int APS5_VABI sceKernelSignalSema(KernelSema sem, int count) { std::lock_guard lock(sem->mutex); if (sem->tokenCount + count > sem->maxCount) { - return KERNEL_SEMA_ERROR_EINVAL; + return SCE_KERNEL_ERROR_EINVAL; } sem->tokenCount += count; sem->condition.notify_all(); @@ -65,7 +65,7 @@ int APS5_VABI sceKernelWaitSema(KernelSema sem, int need, KernelUseconds* time) if (time == nullptr) { sem->condition.wait(lock, [&] { return sem->tokenCount >= need || sem->deleted; }); if (sem->deleted) { - return KERNEL_SEMA_ERROR_EACCES; + return SCE_KERNEL_ERROR_EACCES; } sem->tokenCount -= need; return KERNEL_SEMA_OK; @@ -74,10 +74,10 @@ int APS5_VABI sceKernelWaitSema(KernelSema sem, int need, KernelUseconds* time) auto timeout = std::chrono::microseconds(*time); bool acquired = sem->condition.wait_for(lock, timeout, [&] { return sem->tokenCount >= need || sem->deleted; }); 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;