mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
implement unix socket ops
implement cross process dmem support implement ipmi try send message implement sys_batch_map store saves to game directory (.rpcsx subfolder) fix get dir entries added uvd & vce devices
This commit is contained in:
parent
a6211b514f
commit
6e25f347d3
39 changed files with 1526 additions and 294 deletions
9
orbis-kernel/include/orbis/SocketAddress.hpp
Normal file
9
orbis-kernel/include/orbis/SocketAddress.hpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
namespace orbis {
|
||||
struct SocketAddress {
|
||||
unsigned char len;
|
||||
unsigned char family;
|
||||
char data[14];
|
||||
};
|
||||
} // namespace orbis
|
||||
|
|
@ -14,6 +14,9 @@ struct KNote;
|
|||
struct Thread;
|
||||
struct Stat;
|
||||
struct Uio;
|
||||
struct SocketAddress;
|
||||
struct msghdr;
|
||||
struct sf_hdtr;
|
||||
|
||||
struct FileOps {
|
||||
std::int32_t flags;
|
||||
|
|
@ -41,6 +44,33 @@ struct FileOps {
|
|||
Thread *thread) = nullptr;
|
||||
ErrorCode (*munmap)(File *file, void **address, std::uint64_t size,
|
||||
Thread *thread) = nullptr;
|
||||
|
||||
ErrorCode (*bind)(orbis::File *file, SocketAddress *address,
|
||||
std::size_t addressLen, Thread *thread) = nullptr;
|
||||
ErrorCode (*listen)(orbis::File *file, int backlog, Thread *thread) = nullptr;
|
||||
ErrorCode (*accept)(orbis::File *file, SocketAddress *address,
|
||||
std::uint32_t *addressLen, Thread *thread) = nullptr;
|
||||
ErrorCode (*connect)(orbis::File *file, SocketAddress *address,
|
||||
std::uint32_t addressLen, Thread *thread) = nullptr;
|
||||
ErrorCode (*sendto)(orbis::File *file, const void *buf, size_t len,
|
||||
sint flags, caddr_t to, sint tolen,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*sendmsg)(orbis::File *file, msghdr *msg, sint flags,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*recvfrom)(orbis::File *file, void *buf, size_t len,
|
||||
sint flags, SocketAddress *from, uint32_t *fromlenaddr,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*recvmsg)(orbis::File *file, msghdr *msg, sint flags,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*shutdown)(orbis::File *file, sint how, Thread *thread) = nullptr;
|
||||
ErrorCode (*setsockopt)(orbis::File *file, sint level, sint name,
|
||||
const void *val, sint valsize,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*getsockopt)(orbis::File *file, sint level, sint name, void *val,
|
||||
sint *avalsize, Thread *thread) = nullptr;
|
||||
ErrorCode (*sendfile)(orbis::File *file, sint fd, off_t offset, size_t nbytes,
|
||||
ptr<struct sf_hdtr> hdtr, ptr<off_t> sbytes, sint flags,
|
||||
Thread *thread) = nullptr;
|
||||
};
|
||||
|
||||
struct File : RcBase {
|
||||
|
|
@ -49,6 +79,7 @@ struct File : RcBase {
|
|||
const FileOps *ops = nullptr;
|
||||
Ref<RcBase> device;
|
||||
std::uint64_t nextOff = 0;
|
||||
int hostFd = -1;
|
||||
utils::kvector<Dirent> dirEntries;
|
||||
};
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ struct IpmiSession : RcBase {
|
|||
EventFlag evf{0, 0};
|
||||
shared_cv connectCv;
|
||||
bool expectedOutput = false; // TODO: verify
|
||||
bool connected = false; // TODO: implement more states
|
||||
sint connectionStatus{0};
|
||||
};
|
||||
|
||||
|
|
@ -152,8 +151,16 @@ SysResult sysIpmiSendConnectResult(Thread *thread, ptr<uint> result, uint kid,
|
|||
ptr<void> params, uint64_t paramsSz);
|
||||
SysResult sysIpmiSessionRespondSync(Thread *thread, ptr<uint> result, uint kid,
|
||||
ptr<void> params, uint64_t paramsSz);
|
||||
SysResult sysIpmiClientGetMessage(Thread *thread, ptr<uint> result, uint kid,
|
||||
ptr<void> params, uint64_t paramsSz);
|
||||
SysResult sysIpmiClientTryGetMessage(Thread *thread, ptr<uint> result, uint kid,
|
||||
ptr<void> params, uint64_t paramsSz);
|
||||
SysResult sysIpmiSessionTrySendMessage(Thread *thread, ptr<uint> result,
|
||||
uint kid, ptr<void> params,
|
||||
uint64_t paramsSz);
|
||||
SysResult sysIpmiClientDisconnect(Thread *thread, ptr<uint> result,
|
||||
uint kid, ptr<void> params,
|
||||
uint64_t paramsSz);
|
||||
SysResult sysIpmiSessionGetClientPid(Thread *thread, ptr<uint> result, uint kid,
|
||||
ptr<void> params, uint64_t paramsSz);
|
||||
SysResult sysIpmiClientInvokeSyncMethod(Thread *thread, ptr<uint> result,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <set>
|
||||
|
||||
namespace orbis {
|
||||
|
||||
struct File;
|
||||
static constexpr auto kEvFiltRead = -1;
|
||||
static constexpr auto kEvFiltWrite = -2;
|
||||
static constexpr auto kEvFiltAio = -3;
|
||||
|
|
@ -75,6 +75,7 @@ struct KQueue;
|
|||
struct KNote {
|
||||
shared_mutex mutex;
|
||||
Ref<KQueue> queue;
|
||||
Ref<File> file;
|
||||
KEvent event{};
|
||||
bool enabled = true;
|
||||
bool triggered = false;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ struct timespec;
|
|||
struct Stat;
|
||||
struct stack_t;
|
||||
struct IoVec;
|
||||
struct BatchMapEntry;
|
||||
|
||||
SysResult nosys(Thread *thread);
|
||||
|
||||
|
|
@ -53,13 +54,13 @@ SysResult sys_recvmsg(Thread *thread, sint s, ptr<struct msghdr> msg,
|
|||
SysResult sys_sendmsg(Thread *thread, sint s, ptr<struct msghdr> msg,
|
||||
sint flags);
|
||||
SysResult sys_recvfrom(Thread *thread, sint s, caddr_t buf, size_t len,
|
||||
sint flags, ptr<struct sockaddr> from,
|
||||
sint flags, ptr<SocketAddress> from,
|
||||
ptr<uint32_t> fromlenaddr);
|
||||
SysResult sys_accept(Thread *thread, sint s, ptr<struct sockaddr> from,
|
||||
SysResult sys_accept(Thread *thread, sint s, ptr<SocketAddress> from,
|
||||
ptr<uint32_t> fromlenaddr);
|
||||
SysResult sys_getpeername(Thread *thread, sint fdes, ptr<struct sockaddr> asa,
|
||||
SysResult sys_getpeername(Thread *thread, sint fdes, ptr<SocketAddress> asa,
|
||||
ptr<uint32_t> alen);
|
||||
SysResult sys_getsockname(Thread *thread, sint fdes, ptr<struct sockaddr> asa,
|
||||
SysResult sys_getsockname(Thread *thread, sint fdes, ptr<SocketAddress> asa,
|
||||
ptr<uint32_t> alen);
|
||||
SysResult sys_access(Thread *thread, ptr<char> path, sint flags);
|
||||
SysResult sys_chflags(Thread *thread, ptr<char> path, sint flags);
|
||||
|
|
@ -634,7 +635,8 @@ SysResult sys_evf_cancel(Thread *thread, sint id, uint64_t value,
|
|||
ptr<sint> pNumWaitThreads);
|
||||
SysResult sys_query_memory_protection(Thread *thread, ptr<void> address,
|
||||
ptr<MemoryProtection> protection);
|
||||
SysResult sys_batch_map(Thread *thread /* TODO */);
|
||||
SysResult sys_batch_map(Thread *thread, sint unk, sint flags, ptr<BatchMapEntry> entries,
|
||||
sint entriesCount, ptr<sint> processedCount);
|
||||
SysResult sys_osem_create(Thread *thread, ptr<const char[32]> name, uint attrs,
|
||||
sint initCount, sint maxCount);
|
||||
SysResult sys_osem_delete(Thread *thread, sint id);
|
||||
|
|
@ -720,7 +722,8 @@ SysResult sys_get_proc_type_info(Thread *thread, ptr<sint> destProcessInfo);
|
|||
SysResult sys_get_resident_count(Thread *thread, pid_t pid);
|
||||
SysResult sys_prepare_to_suspend_process(Thread *thread, pid_t pid);
|
||||
SysResult sys_get_resident_fmem_count(Thread *thread, pid_t pid);
|
||||
SysResult sys_thr_get_name(Thread *thread, lwpid_t lwpid);
|
||||
SysResult sys_thr_get_name(Thread *thread, lwpid_t lwpid, char *buf,
|
||||
size_t buflen);
|
||||
SysResult sys_set_gpo(Thread *thread /* TODO */);
|
||||
SysResult sys_get_paging_stats_of_all_objects(Thread *thread /* TODO */);
|
||||
SysResult sys_test_debug_rwmem(Thread *thread /* TODO */);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ struct ProcessOps {
|
|||
SysResult (*blockpool_unmap)(Thread *thread, caddr_t addr, size_t len);
|
||||
SysResult (*socket)(Thread *thread, ptr<const char> name, sint domain,
|
||||
sint type, sint protocol, Ref<File> *file);
|
||||
SysResult (*socketpair)(Thread *thread, sint domain, sint type, sint protocol,
|
||||
Ref<File> *a, Ref<File> *b);
|
||||
SysResult (*shm_unlink)(Thread *thread, const char *path);
|
||||
SysResult (*dynlib_get_obj_member)(Thread *thread, ModuleHandle handle,
|
||||
uint64_t index, ptr<ptr<void>> addrp);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <span>
|
||||
|
||||
namespace orbis {
|
||||
struct IoVec {
|
||||
|
|
@ -25,5 +28,27 @@ struct Uio {
|
|||
UioSeg segflg;
|
||||
UioRw rw;
|
||||
void *td;
|
||||
|
||||
std::size_t write(const void *data, std::size_t size) {
|
||||
auto pos = reinterpret_cast<const std::byte *>(data);
|
||||
auto end = pos + size;
|
||||
|
||||
for (auto vec : std::span(iov, iovcnt)) {
|
||||
if (pos >= end) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto nextPos = std::min(pos + vec.len, end);
|
||||
std::memcpy(vec.base, pos, nextPos - pos);
|
||||
pos = nextPos;
|
||||
}
|
||||
|
||||
return size - (end - pos);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::size_t write(const T &object) {
|
||||
return write(&object, sizeof(T));
|
||||
}
|
||||
};
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct RcBase {
|
|||
void incRef() {
|
||||
if (!_total_size)
|
||||
std::abort();
|
||||
if (references.fetch_add(1, std::memory_order::relaxed) > 512) {
|
||||
if (references.fetch_add(1, std::memory_order::relaxed) > 4096) {
|
||||
assert(!"too many references");
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ public:
|
|||
template <typename OT>
|
||||
requires(std::is_base_of_v<T, OT>)
|
||||
Ref &operator=(Ref<OT> &&other) {
|
||||
other.swap(*this);
|
||||
other.template cast<T>().swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue