sceNetInet: The firmware's stack check, and GetPspError as it computes it

Every export of pspnet_inet.prx but the address conversions starts with
sceKernelCheckThreadStack(), and fails without doing anything if the
thread has less than 0x1000 bytes of stack free (0xFE0 for socket()):
the socket calls with -1, without setting errno, and Init, Term,
GetErrno, GetPspError and SocketAbort with 0x80410005. Each function's
limit plus its own stack frame comes to that. pspautotests
net/inet/errnothread shows it on a thread with a 4 KB stack.

GetPspError is 0x80010000 | errno, and 0 for no error, rather than a
table of guesses, so 0x80010001 on a thread with no errno record yet
(net/inet/errnothread).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-28 13:41:44 +01:00
1 parent 3f40ddc8db
commit fdbce5fbf2
5 files changed
+51 -94

No files matched your search

-86
View File
@@ -945,92 +945,6 @@ const char *convertInetErrno2str(int error) {
}
}
// FIXME: Some of this might be wrong
int convertInetErrno2PSPError(int error) {
switch (error) {
case ERROR_INET_EINTR:
return SCE_KERNEL_ERROR_ERRNO_DEVICE_BUSY;
case ERROR_INET_EACCES:
return SCE_KERNEL_ERROR_ERRNO_READ_ONLY;
case ERROR_INET_EFAULT:
return SCE_KERNEL_ERROR_ERRNO_ADDR_OUT_OF_MAIN_MEM;
case ERROR_INET_EINVAL:
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
case ERROR_INET_ENOSPC:
return SCE_KERNEL_ERROR_ERRNO_NO_MEMORY;
case ERROR_INET_EPIPE:
return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
case ERROR_INET_ENOMSG:
return SCE_KERNEL_ERROR_ERRNO_NO_MEDIA;
case ERROR_INET_ENOLINK:
return SCE_KERNEL_ERROR_ERRNO_DEVICE_NOT_FOUND;
case ERROR_INET_EPROTO:
return SCE_KERNEL_ERROR_ERRNO_FILE_PROTOCOL;
case ERROR_INET_EBADMSG:
return SCE_KERNEL_ERROR_ERRNO_INVALID_MEDIUM;
case ERROR_INET_EOPNOTSUPP:
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
case ERROR_INET_EPFNOSUPPORT:
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
case ERROR_INET_ECONNRESET:
return SCE_KERNEL_ERROR_ERRNO_CONNECTION_RESET;
case ERROR_INET_ENOBUFS:
return SCE_KERNEL_ERROR_ERRNO_NO_FREE_BUF_SPACE;
case ERROR_INET_EAFNOSUPPORT:
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
case ERROR_INET_EPROTOTYPE:
return SCE_KERNEL_ERROR_ERRNO_FILE_PROTOCOL;
case ERROR_INET_ENOTSOCK:
return SCE_KERNEL_ERROR_ERRNO_INVALID_FILE_DESCRIPTOR;
case ERROR_INET_ENOPROTOOPT:
return SCE_KERNEL_ERROR_ERRNO_FILE_PROTOCOL;
case ERROR_INET_ESHUTDOWN:
return SCE_KERNEL_ERROR_ERRNO_CLOSED;
case ERROR_INET_ECONNREFUSED:
return SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS;
case ERROR_INET_EADDRINUSE:
return SCE_KERNEL_ERROR_ERRNO_FILE_ADDR_IN_USE;
case ERROR_INET_ECONNABORTED:
return SCE_KERNEL_ERROR_ERRNO_CONNECTION_ABORTED;
case ERROR_INET_ENETUNREACH:
return SCE_KERNEL_ERROR_ERRNO_DEVICE_NOT_FOUND;
case ERROR_INET_ENETDOWN:
return SCE_KERNEL_ERROR_ERRNO_CLOSED;
case ERROR_INET_ETIMEDOUT:
return SCE_KERNEL_ERROR_ERRNO_FILE_TIMEOUT;
case ERROR_INET_EHOSTDOWN:
return SCE_KERNEL_ERROR_ERRNO_CLOSED;
case ERROR_INET_EHOSTUNREACH:
return SCE_KERNEL_ERROR_ERRNO_DEVICE_NOT_FOUND;
case ERROR_INET_EALREADY:
return SCE_KERNEL_ERROR_ERRNO_ALREADY;
case ERROR_INET_EMSGSIZE:
return SCE_KERNEL_ERROR_ERRNO_FILE_IS_TOO_BIG;
case ERROR_INET_EPROTONOSUPPORT:
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
case ERROR_INET_ESOCKTNOSUPPORT:
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
case ERROR_INET_EADDRNOTAVAIL:
return SCE_KERNEL_ERROR_ERRNO_ADDRESS_NOT_AVAILABLE;
case ERROR_INET_ENETRESET:
return SCE_KERNEL_ERROR_ERRNO_CONNECTION_RESET;
case ERROR_INET_EISCONN:
return SCE_KERNEL_ERROR_ERRNO_ALREADY; // SCE_KERNEL_ERROR_ERRNO_IS_ALREADY_CONNECTED; // UNO only check for 0x80010077 and 0x80010078
case ERROR_INET_ENOTCONN:
return SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED;
case ERROR_INET_EAGAIN:
return SCE_KERNEL_ERROR_ERRNO_RESOURCE_UNAVAILABLE; // SCE_ERROR_ERRNO_EAGAIN;
#if !defined(_WIN32)
case ERROR_INET_EINPROGRESS:
return SCE_KERNEL_ERROR_ERRNO_IN_PROGRESS;
#endif
}
if (error != 0)
return hleLogError(Log::sceNet, error, "Unknown PSP Error Number (%d)", error);
return error;
}
template <typename I>
std::string num2hex(I w, size_t hex_len = sizeof(I) << 1) {
static const char* digits = "0123456789ABCDEF";