mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-06 08:40:28 +01:00
[orbis-kernel] implement sys_socket and sys_socketpair
stub sys_nmount, sys_wait4, sys_getsid, sys_settimeofday, sys_bind, sys_listen, sys_accept, sys_setsockopt, sys_getsockopt Reduce log spam of sys__umtx_op
This commit is contained in:
parent
5fa1da7830
commit
87baff1fa5
|
|
@ -1,4 +1,7 @@
|
|||
#include "sys/sysproto.hpp"
|
||||
#include "utils/Logs.hpp"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
orbis::SysResult orbis::sys_exit(Thread *thread, sint status) {
|
||||
if (auto exit = thread->tproc->ops->exit) {
|
||||
|
|
@ -13,5 +16,8 @@ orbis::SysResult orbis::sys_abort2(Thread *thread, ptr<const char> why,
|
|||
}
|
||||
orbis::SysResult orbis::sys_wait4(Thread *thread, sint pid, ptr<sint> status,
|
||||
sint options, ptr<struct rusage> rusage) {
|
||||
return ErrorCode::NOSYS;
|
||||
// TODO
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, pid, status, options, rusage);
|
||||
std::this_thread::sleep_for(std::chrono::days(1));
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ orbis::SysResult orbis::sys_getpgid(Thread *thread, pid_t pid) {
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_getsid(Thread *thread, pid_t pid) {
|
||||
return ErrorCode::NOSYS;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_getuid(Thread *thread) { return ErrorCode::NOSYS; }
|
||||
orbis::SysResult orbis::sys_geteuid(Thread *thread) { return ErrorCode::NOSYS; }
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ orbis::SysResult orbis::sys_gettimeofday(Thread *thread, ptr<orbis::timeval> tp,
|
|||
}
|
||||
orbis::SysResult orbis::sys_settimeofday(Thread *thread, ptr<struct timeval> tp,
|
||||
ptr<orbis::timezone> tzp) {
|
||||
return ErrorCode::NOSYS;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_getitimer(Thread *thread, uint which,
|
||||
ptr<struct itimerval> itv) {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,43 @@
|
|||
#include "pipe.hpp"
|
||||
#include "sys/sysproto.hpp"
|
||||
#include "utils/Logs.hpp"
|
||||
#include <chrono>
|
||||
#include <sys/socket.h>
|
||||
#include <thread>
|
||||
|
||||
orbis::SysResult orbis::sys_socket(Thread *thread, sint domain, sint type,
|
||||
sint protocol) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, domain, type, protocol);
|
||||
if (auto socket = thread->tproc->ops->socket) {
|
||||
Ref<File> file;
|
||||
auto result = socket(thread, nullptr, domain, type, protocol, &file);
|
||||
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
auto fd = thread->tproc->fileDescriptors.insert(file);
|
||||
ORBIS_LOG_WARNING("Socket opened", fd);
|
||||
thread->retval[0] = fd;
|
||||
return {};
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_bind(Thread *thread, sint s, caddr_t name,
|
||||
sint namelen) {
|
||||
return ErrorCode::NOSYS;
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, s, name, namelen);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_listen(Thread *thread, sint s, sint backlog) {
|
||||
return ErrorCode::NOSYS;
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, s, backlog);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_accept(Thread *thread, sint s,
|
||||
ptr<struct sockaddr> from,
|
||||
ptr<uint32_t> fromlenaddr) {
|
||||
return ErrorCode::NOSYS;
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, s, from, fromlenaddr);
|
||||
std::this_thread::sleep_for(std::chrono::days(1));
|
||||
return SysResult::notAnError(ErrorCode::WOULDBLOCK);
|
||||
}
|
||||
orbis::SysResult orbis::sys_connect(Thread *thread, sint s, caddr_t name,
|
||||
sint namelen) {
|
||||
|
|
@ -22,12 +45,20 @@ orbis::SysResult orbis::sys_connect(Thread *thread, sint s, caddr_t name,
|
|||
}
|
||||
orbis::SysResult orbis::sys_socketpair(Thread *thread, sint domain, sint type,
|
||||
sint protocol, ptr<sint> rsv) {
|
||||
return ErrorCode::NOSYS;
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, domain, type, protocol, rsv);
|
||||
|
||||
auto pipe = createPipe();
|
||||
auto a = thread->tproc->fileDescriptors.insert(pipe);
|
||||
auto b = thread->tproc->fileDescriptors.insert(pipe);
|
||||
if (auto errc = uwrite(rsv, a); errc != ErrorCode{}) {
|
||||
return errc;
|
||||
}
|
||||
return uwrite(rsv + 1, b);
|
||||
}
|
||||
orbis::SysResult orbis::sys_sendto(Thread *thread, sint s, caddr_t buf,
|
||||
size_t len, sint flags, caddr_t to,
|
||||
sint tolen) {
|
||||
return ErrorCode::NOSYS;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_sendmsg(Thread *thread, sint s,
|
||||
ptr<struct msghdr> msg, sint flags) {
|
||||
|
|
@ -48,12 +79,14 @@ orbis::SysResult orbis::sys_shutdown(Thread *thread, sint s, sint how) {
|
|||
}
|
||||
orbis::SysResult orbis::sys_setsockopt(Thread *thread, sint s, sint level,
|
||||
sint name, caddr_t val, sint valsize) {
|
||||
return ErrorCode::NOSYS;
|
||||
ORBIS_LOG_TODO(__FUNCTION__, s, level, name, val, valsize);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_getsockopt(Thread *thread, sint s, sint level,
|
||||
sint name, caddr_t val,
|
||||
ptr<sint> avalsize) {
|
||||
return ErrorCode::NOSYS;
|
||||
ORBIS_LOG_TODO(__FUNCTION__, s, level, name, val, avalsize);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_getsockname(Thread *thread, sint fdes,
|
||||
ptr<struct sockaddr> asa,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ orbis::SysResult orbis::sys__umtx_op(Thread *thread, ptr<void> obj, sint op,
|
|||
ORBIS_LOG_TRACE(__FUNCTION__, obj, op, val, uaddr1, uaddr2);
|
||||
if (reinterpret_cast<std::uintptr_t>(obj) - 0x10000 > 0xff'fffe'ffff)
|
||||
return ErrorCode::FAULT;
|
||||
auto with_timeout = [&](auto op, bool loop = true) -> orbis::ErrorCode {
|
||||
auto with_timeout = [&](auto op, bool loop = true) -> SysResult {
|
||||
timespec *ts = nullptr;
|
||||
timespec timeout{};
|
||||
if (uaddr2 != nullptr) {
|
||||
|
|
@ -59,8 +59,15 @@ orbis::SysResult orbis::sys__umtx_op(Thread *thread, ptr<void> obj, sint op,
|
|||
usec += (timeout.nsec + 999) / 1000;
|
||||
if (usec >= UINT64_MAX)
|
||||
usec = -2;
|
||||
if (!loop)
|
||||
return op(usec);
|
||||
|
||||
if (!loop) {
|
||||
if (auto result = op(usec); result != ErrorCode::TIMEDOUT) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return SysResult::notAnError(ErrorCode::TIMEDOUT);
|
||||
}
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
std::uint64_t udiff = 0;
|
||||
while (true) {
|
||||
|
|
@ -70,7 +77,7 @@ orbis::SysResult orbis::sys__umtx_op(Thread *thread, ptr<void> obj, sint op,
|
|||
std::chrono::steady_clock::now() - start)
|
||||
.count();
|
||||
if (udiff >= usec)
|
||||
return ErrorCode::TIMEDOUT;
|
||||
return SysResult::notAnError(ErrorCode::TIMEDOUT);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "sys/sysproto.hpp"
|
||||
#include "uio.hpp"
|
||||
#include "utils/Logs.hpp"
|
||||
|
||||
orbis::SysResult orbis::sys_mount(Thread *thread, ptr<char> type,
|
||||
ptr<char> path, sint flags, caddr_t data) {
|
||||
|
|
@ -10,5 +12,17 @@ orbis::SysResult orbis::sys_unmount(Thread *thread, ptr<char> path,
|
|||
}
|
||||
orbis::SysResult orbis::sys_nmount(Thread *thread, ptr<IoVec> iovp, uint iovcnt,
|
||||
sint flags) {
|
||||
return ErrorCode::NOSYS;
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, iovp, iovcnt, flags);
|
||||
|
||||
for (auto it = iovp; it < iovp + iovcnt; it += 2) {
|
||||
IoVec a{}, b{};
|
||||
uread(a, it);
|
||||
uread(b, it + 1);
|
||||
|
||||
std::string aSv((char *)a.base, a.len);
|
||||
std::string bSv((char *)b.base, b.len);
|
||||
|
||||
std::fprintf(stderr, "%s: '%s':'%s'\n", __FUNCTION__, aSv.c_str(), bSv.c_str());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue