mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
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
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
#include "io-device.hpp"
|
|
#include "orbis/KernelAllocator.hpp"
|
|
#include "orbis/error/ErrorCode.hpp"
|
|
#include "orbis/file.hpp"
|
|
#include "orbis/thread/Thread.hpp"
|
|
#include "orbis/utils/Logs.hpp"
|
|
#include <fcntl.h>
|
|
#include <sys/mman.h>
|
|
|
|
struct ShmDevice : IoDevice {
|
|
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
|
std::uint32_t flags, std::uint32_t mode,
|
|
orbis::Thread *thread) override;
|
|
orbis::ErrorCode unlink(const char *path, bool recursive,
|
|
orbis::Thread *thread) override;
|
|
};
|
|
|
|
static std::string realShmPath(const char *path) {
|
|
std::string name = "/rpcsx-";
|
|
if (path[0] == '/') {
|
|
name += path + 1;
|
|
} else {
|
|
name += path;
|
|
}
|
|
|
|
for (auto pos = name.find('/', 1); pos != std::string::npos;
|
|
pos = name.find('/', pos + 1)) {
|
|
name[pos] = '$';
|
|
}
|
|
|
|
return name;
|
|
}
|
|
|
|
orbis::ErrorCode ShmDevice::open(orbis::Ref<orbis::File> *file,
|
|
const char *path, std::uint32_t flags,
|
|
std::uint32_t mode, orbis::Thread *thread) {
|
|
ORBIS_LOG_WARNING("shm_open", path, flags, mode);
|
|
auto name = realShmPath(path);
|
|
auto realFlags = O_RDWR; // TODO
|
|
|
|
if (flags & 0x200) {
|
|
realFlags |= O_CREAT;
|
|
}
|
|
|
|
int fd = shm_open(name.c_str(), realFlags, S_IRUSR | S_IWUSR);
|
|
if (fd < 0) {
|
|
return convertErrno();
|
|
}
|
|
|
|
auto hostFile = createHostFile(fd, this, true);
|
|
*file = hostFile;
|
|
return {};
|
|
}
|
|
|
|
orbis::ErrorCode ShmDevice::unlink(const char *path, bool recursive,
|
|
orbis::Thread *thread) {
|
|
ORBIS_LOG_WARNING("shm_unlink", path);
|
|
auto name = realShmPath(path);
|
|
|
|
if (shm_unlink(name.c_str())) {
|
|
return convertErrno();
|
|
}
|
|
|
|
return{};
|
|
}
|
|
IoDevice *createShmDevice() { return orbis::knew<ShmDevice>(); }
|