From 9865be85af3d5ae3f6ce2b455d056e2086c8398f Mon Sep 17 00:00:00 2001 From: DH Date: Mon, 30 Oct 2023 22:03:38 +0300 Subject: [PATCH] [rpcsx-os] stub /dev/mbus and /dev/notification* --- orbis-kernel/src/sys/sys_generic.cpp | 2 +- rpcsx-os/CMakeLists.txt | 2 ++ rpcsx-os/io-devices.hpp | 2 ++ rpcsx-os/iodev/gc.cpp | 2 +- rpcsx-os/iodev/mbus.cpp | 35 +++++++++++++++++++++++++ rpcsx-os/iodev/notification.cpp | 38 ++++++++++++++++++++++++++++ rpcsx-os/main.cpp | 21 +++++++++++++-- 7 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 rpcsx-os/iodev/mbus.cpp create mode 100644 rpcsx-os/iodev/notification.cpp diff --git a/orbis-kernel/src/sys/sys_generic.cpp b/orbis-kernel/src/sys/sys_generic.cpp index 970dcb281..b678540ab 100644 --- a/orbis-kernel/src/sys/sys_generic.cpp +++ b/orbis-kernel/src/sys/sys_generic.cpp @@ -415,7 +415,7 @@ static std::string ioctlToString(unsigned long arg) { orbis::SysResult orbis::sys_ioctl(Thread *thread, sint fd, ulong com, caddr_t data) { auto str = ioctlToString(com); - ORBIS_LOG_WARNING(__FUNCTION__, fd, com, str); + // ORBIS_LOG_WARNING(__FUNCTION__, fd, com, str); Ref file = thread->tproc->fileDescriptors.get(fd); if (file == nullptr) { return ErrorCode::BADF; diff --git a/rpcsx-os/CMakeLists.txt b/rpcsx-os/CMakeLists.txt index 901548110..b51c0ade5 100644 --- a/rpcsx-os/CMakeLists.txt +++ b/rpcsx-os/CMakeLists.txt @@ -17,6 +17,8 @@ add_executable(rpcsx-os iodev/hmd_mmap.cpp iodev/hmd_snsr.cpp iodev/icc_configuration.cpp + iodev/mbus.cpp + iodev/notification.cpp iodev/npdrm.cpp iodev/null.cpp iodev/rng.cpp diff --git a/rpcsx-os/io-devices.hpp b/rpcsx-os/io-devices.hpp index 9e6abb37c..4d5c4989a 100644 --- a/rpcsx-os/io-devices.hpp +++ b/rpcsx-os/io-devices.hpp @@ -23,3 +23,5 @@ IoDevice *createShmDevice(); IoDevice *createBlockPoolDevice(); IoDevice *createUrandomCharacterDevice(); IoDevice *createCameraCharacterDevice(); +IoDevice *createNotificationCharacterDevice(int index); +IoDevice *createMBusCharacterDevice(); diff --git a/rpcsx-os/iodev/gc.cpp b/rpcsx-os/iodev/gc.cpp index c3b57867c..fbeab5568 100644 --- a/rpcsx-os/iodev/gc.cpp +++ b/rpcsx-os/iodev/gc.cpp @@ -87,7 +87,7 @@ static orbis::ErrorCode gc_ioctl(orbis::File *file, std::uint64_t request, auto args = reinterpret_cast(argp); - ORBIS_LOG_ERROR("gc ioctl 0xc0088101\n", args->arg0, args->arg1); + ORBIS_LOG_ERROR("gc ioctl 0xc0088101", args->arg0, args->arg1); break; } diff --git a/rpcsx-os/iodev/mbus.cpp b/rpcsx-os/iodev/mbus.cpp new file mode 100644 index 000000000..37d5324c4 --- /dev/null +++ b/rpcsx-os/iodev/mbus.cpp @@ -0,0 +1,35 @@ +#include "io-device.hpp" +#include "orbis/KernelAllocator.hpp" +#include "orbis/file.hpp" +#include "orbis/utils/Logs.hpp" + +struct MBusFile : orbis::File {}; +struct MBusDevice : IoDevice { + orbis::ErrorCode open(orbis::Ref *file, const char *path, + std::uint32_t flags, std::uint32_t mode, + orbis::Thread *thread) override; +}; + +static orbis::ErrorCode mbus_ioctl(orbis::File *file, std::uint64_t request, + void *argp, orbis::Thread *thread) { + + ORBIS_LOG_FATAL("Unhandled mbus ioctl", request); + return {}; +} + +static const orbis::FileOps fileOps = { + .ioctl = mbus_ioctl, +}; + +orbis::ErrorCode MBusDevice::open(orbis::Ref *file, const char *path, + std::uint32_t flags, std::uint32_t mode, + orbis::Thread *thread) { + auto newFile = orbis::knew(); + newFile->ops = &fileOps; + newFile->device = this; + + *file = newFile; + return {}; +} + +IoDevice *createMBusCharacterDevice() { return orbis::knew(); } diff --git a/rpcsx-os/iodev/notification.cpp b/rpcsx-os/iodev/notification.cpp new file mode 100644 index 000000000..1c6d23a81 --- /dev/null +++ b/rpcsx-os/iodev/notification.cpp @@ -0,0 +1,38 @@ +#include "io-device.hpp" +#include "orbis/KernelAllocator.hpp" +#include "orbis/file.hpp" +#include "orbis/utils/Logs.hpp" + +struct NotificationFile : orbis::File {}; +struct NotificationDevice : IoDevice { + int index; + + NotificationDevice(int index) : index(index) {} + orbis::ErrorCode open(orbis::Ref *file, const char *path, + std::uint32_t flags, std::uint32_t mode, + orbis::Thread *thread) override; +}; + +static orbis::ErrorCode notification_ioctl(orbis::File *file, std::uint64_t request, + void *argp, orbis::Thread *thread) { + + ORBIS_LOG_FATAL("Unhandled notification ioctl", request); + return {}; +} + +static const orbis::FileOps fileOps = { + .ioctl = notification_ioctl, +}; + +orbis::ErrorCode NotificationDevice::open(orbis::Ref *file, const char *path, + std::uint32_t flags, std::uint32_t mode, + orbis::Thread *thread) { + auto newFile = orbis::knew(); + newFile->ops = &fileOps; + newFile->device = this; + + *file = newFile; + return {}; +} + +IoDevice *createNotificationCharacterDevice(int index) { return orbis::knew(index); } diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index 1d5b40549..bb56fd332 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -322,6 +322,9 @@ static int ps4Exec(orbis::Thread *mainThread, auto dmem1 = createDmemCharacterDevice(1); orbis::g_context.dmemDevice = dmem1; + auto stdoutFd = ::open("stdout.txt", O_CREAT | O_TRUNC | O_WRONLY, 0666); + auto stderrFd = ::open("stderr.txt", O_CREAT | O_TRUNC | O_WRONLY, 0666); + rx::vfs::addDevice("dmem0", createDmemCharacterDevice(0)); rx::vfs::addDevice("npdrm", createNpdrmCharacterDevice()); rx::vfs::addDevice("icc_configuration", createIccConfigurationCharacterDevice()); @@ -329,8 +332,11 @@ static int ps4Exec(orbis::Thread *mainThread, rx::vfs::addDevice("camera", createCameraCharacterDevice()); rx::vfs::addDevice("dmem1", dmem1); rx::vfs::addDevice("dmem2", createDmemCharacterDevice(2)); - rx::vfs::addDevice("stdout", createFdWrapDevice(STDOUT_FILENO)); - rx::vfs::addDevice("stderr", createFdWrapDevice(STDERR_FILENO)); + rx::vfs::addDevice("stdout", createFdWrapDevice(stdoutFd)); + rx::vfs::addDevice("stderr", createFdWrapDevice(stderrFd)); + rx::vfs::addDevice("deci_stdin", createFdWrapDevice(STDIN_FILENO)); + rx::vfs::addDevice("deci_stdout", createFdWrapDevice(stdoutFd)); + rx::vfs::addDevice("deci_stderr", createFdWrapDevice(stderrFd)); rx::vfs::addDevice("stdin", createFdWrapDevice(STDIN_FILENO)); rx::vfs::addDevice("zero", createZeroCharacterDevice()); rx::vfs::addDevice("null", createNullCharacterDevice()); @@ -346,6 +352,13 @@ static int ps4Exec(orbis::Thread *mainThread, rx::vfs::addDevice("sbl_srv", createSblSrvCharacterDevice()); rx::vfs::addDevice("ajm", createAjmCharacterDevice()); rx::vfs::addDevice("urandom", createUrandomCharacterDevice()); + rx::vfs::addDevice("mbus", createMBusCharacterDevice()); + rx::vfs::addDevice("notification0", createNotificationCharacterDevice(0)); + rx::vfs::addDevice("notification1", createNotificationCharacterDevice(1)); + rx::vfs::addDevice("notification2", createNotificationCharacterDevice(2)); + rx::vfs::addDevice("notification3", createNotificationCharacterDevice(3)); + rx::vfs::addDevice("notification4", createNotificationCharacterDevice(4)); + rx::vfs::addDevice("notification5", createNotificationCharacterDevice(5)); orbis::Ref stdinFile; orbis::Ref stdoutFile; @@ -387,6 +400,10 @@ static int ps4Exec(orbis::Thread *mainThread, // *reinterpret_cast( // reinterpret_cast(libkernel->base) + 0x6c2e4) = ~0; + *reinterpret_cast( + reinterpret_cast(libkernel->base) + 0x71300) = ~0; + + StackWriter stack{reinterpret_cast(mainThread->stackEnd)}; for (auto elem : argv) {