Skip to content

Commit

Permalink
[rpcsx-os] stub aout, av_control, hdmi, mbus_av, scanin devices
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Nov 3, 2023
1 parent 7eeeaf1 commit a9d385d
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 2 deletions.
5 changes: 5 additions & 0 deletions rpcsx-os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ add_executable(rpcsx-os
iodev/urandom.cpp
iodev/xpt.cpp
iodev/zero.cpp
iodev/aout.cpp
iodev/av_control.cpp
iodev/hdmi.cpp
iodev/mbus_av.cpp
iodev/scanin.cpp

main.cpp
backtrace.cpp
Expand Down
5 changes: 5 additions & 0 deletions rpcsx-os/io-devices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ IoDevice *createXptCharacterDevice();
IoDevice *createCdCharacterDevice();
IoDevice *createMetaDbgCharacterDevice();
IoDevice *createHddCharacterDevice();
IoDevice *createAoutCharacterDevice();
IoDevice *createAVControlCharacterDevice();
IoDevice *createHDMICharacterDevice();
IoDevice *createMBusAVCharacterDevice();
IoDevice *createScaninCharacterDevice();
32 changes: 32 additions & 0 deletions rpcsx-os/iodev/aout.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "io-device.hpp"
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"

struct AoutFile : orbis::File {};

static orbis::ErrorCode aout_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {

ORBIS_LOG_FATAL("Unhandled aout ioctl", request);
return {};
}

static const orbis::FileOps fileOps = {
.ioctl = aout_ioctl,
};

struct AoutDevice : IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override {
auto newFile = orbis::knew<AoutFile>();
newFile->ops = &fileOps;
newFile->device = this;

*file = newFile;
return {};
}
};

IoDevice *createAoutCharacterDevice() { return orbis::knew<AoutDevice>(); }
32 changes: 32 additions & 0 deletions rpcsx-os/iodev/av_control.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "io-device.hpp"
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"

struct AVControlFile : orbis::File {};

static orbis::ErrorCode av_control_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {

ORBIS_LOG_FATAL("Unhandled av_control ioctl", request);
return {};
}

static const orbis::FileOps fileOps = {
.ioctl = av_control_ioctl,
};

struct AVControlDevice : IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override {
auto newFile = orbis::knew<AVControlFile>();
newFile->ops = &fileOps;
newFile->device = this;

*file = newFile;
return {};
}
};

IoDevice *createAVControlCharacterDevice() { return orbis::knew<AVControlDevice>(); }
32 changes: 32 additions & 0 deletions rpcsx-os/iodev/hdmi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "io-device.hpp"
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"

struct HDMIFile : orbis::File {};

static orbis::ErrorCode hdmi_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {

ORBIS_LOG_FATAL("Unhandled hdmi ioctl", request);
return {};
}

static const orbis::FileOps fileOps = {
.ioctl = hdmi_ioctl,
};

struct HDMIDevice : IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override {
auto newFile = orbis::knew<HDMIFile>();
newFile->ops = &fileOps;
newFile->device = this;

*file = newFile;
return {};
}
};

IoDevice *createHDMICharacterDevice() { return orbis::knew<HDMIDevice>(); }
32 changes: 32 additions & 0 deletions rpcsx-os/iodev/mbus_av.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "io-device.hpp"
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"

struct MBusAVFile : orbis::File {};

static orbis::ErrorCode mbus_av_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {

ORBIS_LOG_FATAL("Unhandled mbus_av ioctl", request);
return {};
}

static const orbis::FileOps fileOps = {
.ioctl = mbus_av_ioctl,
};

struct MBusAVDevice : IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override {
auto newFile = orbis::knew<MBusAVFile>();
newFile->ops = &fileOps;
newFile->device = this;

*file = newFile;
return {};
}
};

IoDevice *createMBusAVCharacterDevice() { return orbis::knew<MBusAVDevice>(); }
32 changes: 32 additions & 0 deletions rpcsx-os/iodev/scanin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "io-device.hpp"
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"

struct ScaninFile : orbis::File {};

static orbis::ErrorCode scanin_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {

ORBIS_LOG_FATAL("Unhandled scanin ioctl", request);
return {};
}

static const orbis::FileOps fileOps = {
.ioctl = scanin_ioctl,
};

struct ScaninDevice : IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override {
auto newFile = orbis::knew<ScaninFile>();
newFile->ops = &fileOps;
newFile->device = this;

*file = newFile;
return {};
}
};

IoDevice *createScaninCharacterDevice() { return orbis::knew<ScaninDevice>(); }
5 changes: 5 additions & 0 deletions rpcsx-os/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ static void ps4InitDev() {
rx::vfs::addDevice("notification3", createNotificationCharacterDevice(3));
rx::vfs::addDevice("notification4", createNotificationCharacterDevice(4));
rx::vfs::addDevice("notification5", createNotificationCharacterDevice(5));
rx::vfs::addDevice("aout0", createAoutCharacterDevice());
rx::vfs::addDevice("av_control", createAVControlCharacterDevice());
rx::vfs::addDevice("hdmi", createHDMICharacterDevice());
rx::vfs::addDevice("mbus_av", createMBusAVCharacterDevice());
rx::vfs::addDevice("scanin", createScaninCharacterDevice());

orbis::g_context.shmDevice = createShmDevice();
orbis::g_context.blockpoolDevice = createBlockPoolDevice();
Expand Down
4 changes: 2 additions & 2 deletions rpcsx-os/orbis-kernel-config/orbis-config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ uwriteRaw(ptr<void> userAddress, const void *kernelAddress, size_t size) {
return {};
}

template <typename T> [[nodiscard]] ErrorCode uread(T &result, ptr<T> pointer) {
template <typename T> [[nodiscard]] ErrorCode uread(T &result, ptr<const T> pointer) {
return ureadRaw(&result, pointer, sizeof(T));
}

Expand All @@ -90,7 +90,7 @@ template <typename T, typename U>
}

template <typename T>
[[nodiscard]] ErrorCode uread(T *result, ptr<T> pointer, std::size_t count) {
[[nodiscard]] ErrorCode uread(T *result, ptr<const T> pointer, std::size_t count) {
return ureadRaw(&result, pointer, sizeof(T) * count);
}

Expand Down

0 comments on commit a9d385d

Please sign in to comment.