[rpcsx-os] implement shm

This commit is contained in:
DH 2023-07-29 22:46:28 +03:00
parent d52a53cfcd
commit 645e41eed8
28 changed files with 187 additions and 47 deletions

View file

@ -124,6 +124,8 @@ public:
return getUmtxChainIndexed(1, t, flags, ptr);
}
Ref<RcBase> shmDevice;
private:
mutable pthread_mutex_t m_heap_mtx;
void *m_heap_next = this + 1;

View file

@ -32,8 +32,11 @@ struct ProcessOps {
SysResult (*open)(Thread *thread, ptr<const char> path, sint flags, sint mode,
Ref<File> *file);
SysResult (*shm_open)(Thread *thread, const char *path, sint flags, sint mode,
Ref<File> *file);
SysResult (*socket)(Thread *thread, ptr<const char> name, sint domain,
sint type, sint protocol, Ref<File> *file);
SysResult (*shm_unlink)(Thread *thread, const char *path);
SysResult (*dynlib_get_obj_member)(Thread *thread, ModuleHandle handle,
uint64_t index, ptr<ptr<void>> addrp);
SysResult (*dynlib_dlsym)(Thread *thread, ModuleHandle handle,

View file

@ -17,10 +17,6 @@ orbis::SysResult orbis::sys_fcntl(Thread *thread, sint fd, sint cmd,
}
orbis::SysResult orbis::sys_close(Thread *thread, sint fd) {
ORBIS_LOG_NOTICE(__FUNCTION__, fd);
if (fd == 0) {
return {}; // FIXME: remove when shm would be implemented
}
if (thread->tproc->fileDescriptors.close(fd)) {
return {};
}

View file

@ -275,10 +275,6 @@ orbis::SysResult orbis::sys_pwritev(Thread *thread, sint fd, ptr<IoVec> iovp,
return {};
}
orbis::SysResult orbis::sys_ftruncate(Thread *thread, sint fd, off_t length) {
ORBIS_LOG_WARNING(__FUNCTION__, fd, length);
if (fd == 0) {
return {}; // FIXME: remove when shm implemented
}
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
if (file == nullptr) {
return ErrorCode::BADF;

View file

@ -1,6 +1,5 @@
#include "orbis-config.hpp"
#include "sys/sysproto.hpp"
#include "utils/Logs.hpp"
orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr<const char> path,
sint flags, mode_t mode) {
@ -10,9 +9,19 @@ orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr<const char> path,
return result;
}
ORBIS_LOG_TODO(__FUNCTION__, _name, flags, mode);
return {};
if (auto shm_open = thread->tproc->ops->shm_open) {
Ref<File> file;
auto result = shm_open(thread, path, flags, mode, &file);
if (result.isError()) {
return result;
}
thread->retval[0] = thread->tproc->fileDescriptors.insert(file);
return {};
}
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_shm_unlink(Thread *thread, ptr<const char> path) {
char _name[256];
if (auto result = ureadString(_name, sizeof(_name), path);
@ -20,6 +29,16 @@ orbis::SysResult orbis::sys_shm_unlink(Thread *thread, ptr<const char> path) {
return result;
}
ORBIS_LOG_TODO(__FUNCTION__, _name);
return {};
if (auto shm_unlink = thread->tproc->ops->shm_unlink) {
Ref<File> file;
auto result = shm_unlink(thread, path);
if (result.isError()) {
return result;
}
thread->retval[0] = thread->tproc->fileDescriptors.insert(file);
return {};
}
return ErrorCode::NOSYS;
}