[rpcsx-os] Stub sbl_srv device

This commit is contained in:
DH 2023-07-29 23:31:54 +03:00
parent 645e41eed8
commit 29086ea7cd
3 changed files with 59 additions and 0 deletions

View File

@ -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

View File

@ -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 <cstdio>
struct SblSrvFile : public orbis::File {};
struct SblSrvDevice : IoDevice {
orbis::shared_mutex mtx;
orbis::ErrorCode open(orbis::Ref<orbis::File> *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<orbis::File> *file,
const char *path, std::uint32_t flags,
std::uint32_t mode, orbis::Thread *thread) {
auto newFile = orbis::knew<SblSrvFile>();
newFile->device = this;
newFile->ops = &ops;
*file = newFile;
return {};
}
IoDevice *createSblSrvCharacterDevice() { return orbis::knew<SblSrvDevice>(); }

View File

@ -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<orbis::File> stdinFile;