diff --git a/rpcsx-os/CMakeLists.txt b/rpcsx-os/CMakeLists.txt index 32f9b3bfc..87f497f70 100644 --- a/rpcsx-os/CMakeLists.txt +++ b/rpcsx-os/CMakeLists.txt @@ -15,6 +15,7 @@ add_executable(rpcsx-os iodev/hmd_snsr.cpp iodev/null.cpp iodev/rng.cpp + iodev/sbl_srv.cpp iodev/shm.cpp iodev/zero.cpp diff --git a/rpcsx-os/iodev/sbl_srv.cpp b/rpcsx-os/iodev/sbl_srv.cpp new file mode 100644 index 000000000..8bdda8d3d --- /dev/null +++ b/rpcsx-os/iodev/sbl_srv.cpp @@ -0,0 +1,57 @@ +#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 "orbis/utils/SharedMutex.hpp" +#include "vm.hpp" +#include + +struct SblSrvFile : public orbis::File {}; + +struct SblSrvDevice : IoDevice { + orbis::shared_mutex mtx; + orbis::ErrorCode open(orbis::Ref *file, const char *path, + std::uint32_t flags, std::uint32_t mode, + orbis::Thread *thread) override; +}; + +static orbis::ErrorCode sbl_srv_ioctl(orbis::File *file, std::uint64_t request, + void *argp, orbis::Thread *thread) { + ORBIS_LOG_FATAL("Unhandled sbl_srv ioctl", request); + thread->where(); + return {}; +} + +static orbis::ErrorCode sbl_srv_mmap(orbis::File *file, void **address, + std::uint64_t size, std::int32_t prot, + std::int32_t flags, std::int64_t offset, + orbis::Thread *thread) { + ORBIS_LOG_FATAL("sbl_srv mmap", address, size, offset); + auto result = rx::vm::map(*address, size, prot, flags); + + if (result == (void *)-1) { + return orbis::ErrorCode::INVAL; // TODO + } + + *address = result; + return {}; +} + +static const orbis::FileOps ops = { + .ioctl = sbl_srv_ioctl, + .mmap = sbl_srv_mmap, +}; + +orbis::ErrorCode SblSrvDevice::open(orbis::Ref *file, + const char *path, std::uint32_t flags, + std::uint32_t mode, orbis::Thread *thread) { + auto newFile = orbis::knew(); + newFile->device = this; + newFile->ops = &ops; + *file = newFile; + return {}; +} + +IoDevice *createSblSrvCharacterDevice() { return orbis::knew(); } diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index bb21bdb0a..d8128a81d 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -322,6 +322,7 @@ static int ps4Exec(orbis::Thread *mainThread, rx::vfs::mount("/dev/hid", createHidCharacterDevice()); rx::vfs::mount("/dev/gc", createGcCharacterDevice()); rx::vfs::mount("/dev/rng", createRngCharacterDevice()); + rx::vfs::mount("/dev/sbl_srv", createSblSrvCharacterDevice()); rx::vfs::mount("/dev/ajm", createAjmCharacterDevice()); orbis::Ref stdinFile;