Skip to content

Commit

Permalink
add hmd2 devices stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Nov 24, 2024
1 parent c46b391 commit 8c5bde7
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rpcsx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ add_executable(rpcsx
iodev/hmd_cmd.cpp
iodev/hmd_mmap.cpp
iodev/hmd_snsr.cpp
iodev/hmd2_cmd.cpp
iodev/hmd2_imu.cpp
iodev/hmd2_gen_data.cpp
iodev/hmd2_gaze.cpp
iodev/icc_configuration.cpp
iodev/mbus.cpp
iodev/metadbg.cpp
Expand Down
4 changes: 4 additions & 0 deletions rpcsx/io-devices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ IoDevice *createIccPowerCharacterDevice();
IoDevice *createCaymanRegCharacterDevice();
IoDevice *createA53IoCharacterDevice();
IoDevice *createNsidCtlCharacterDevice();
IoDevice *createHmd2CmdCharacterDevice();
IoDevice *createHmd2ImuCharacterDevice();
IoDevice *createHmd2GazeCharacterDevice();
IoDevice *createHmd2GenDataCharacterDevice();
32 changes: 32 additions & 0 deletions rpcsx/iodev/hmd2_cmd.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/utils/Logs.hpp"

struct Hmd2CmdDevice : public IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override;
};
struct Hmd2CmdFile : public orbis::File {};

static orbis::ErrorCode hmd2_cmd_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {
ORBIS_LOG_FATAL("Unhandled hmd2_cmd ioctl", request);
return {};
}

static const orbis::FileOps ops = {
.ioctl = hmd2_cmd_ioctl,
};

orbis::ErrorCode Hmd2CmdDevice::open(orbis::Ref<orbis::File> *file,
const char *path, std::uint32_t flags,
std::uint32_t mode, orbis::Thread *thread) {
auto newFile = orbis::knew<Hmd2CmdFile>();
newFile->device = this;
newFile->ops = &ops;
*file = newFile;
return {};
}

IoDevice *createHmd2CmdCharacterDevice() { return orbis::knew<Hmd2CmdDevice>(); }
32 changes: 32 additions & 0 deletions rpcsx/iodev/hmd2_gaze.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/utils/Logs.hpp"

struct Hmd2GazeDevice : public IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override;
};
struct Hmd2GazeFile : public orbis::File {};

static orbis::ErrorCode hmd2_gaze_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {
ORBIS_LOG_FATAL("Unhandled hmd2_gaze ioctl", request);
return {};
}

static const orbis::FileOps ops = {
.ioctl = hmd2_gaze_ioctl,
};

orbis::ErrorCode Hmd2GazeDevice::open(orbis::Ref<orbis::File> *file,
const char *path, std::uint32_t flags,
std::uint32_t mode, orbis::Thread *thread) {
auto newFile = orbis::knew<Hmd2GazeFile>();
newFile->device = this;
newFile->ops = &ops;
*file = newFile;
return {};
}

IoDevice *createHmd2GazeCharacterDevice() { return orbis::knew<Hmd2GazeDevice>(); }
32 changes: 32 additions & 0 deletions rpcsx/iodev/hmd2_gen_data.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/utils/Logs.hpp"

struct Hmd2GenDataDevice : public IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override;
};
struct Hmd2GenDataFile : public orbis::File {};

static orbis::ErrorCode hmd2_gen_data_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {
ORBIS_LOG_FATAL("Unhandled hmd2_gen_data ioctl", request);
return {};
}

static const orbis::FileOps ops = {
.ioctl = hmd2_gen_data_ioctl,
};

orbis::ErrorCode Hmd2GenDataDevice::open(orbis::Ref<orbis::File> *file,
const char *path, std::uint32_t flags,
std::uint32_t mode, orbis::Thread *thread) {
auto newFile = orbis::knew<Hmd2GenDataFile>();
newFile->device = this;
newFile->ops = &ops;
*file = newFile;
return {};
}

IoDevice *createHmd2GenDataCharacterDevice() { return orbis::knew<Hmd2GenDataDevice>(); }
32 changes: 32 additions & 0 deletions rpcsx/iodev/hmd2_imu.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/utils/Logs.hpp"

struct Hmd2ImuDevice : public IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override;
};
struct Hmd2ImuFile : public orbis::File {};

static orbis::ErrorCode hmd2_imu_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {
ORBIS_LOG_FATAL("Unhandled hmd2_imu ioctl", request);
return {};
}

static const orbis::FileOps ops = {
.ioctl = hmd2_imu_ioctl,
};

orbis::ErrorCode Hmd2ImuDevice::open(orbis::Ref<orbis::File> *file,
const char *path, std::uint32_t flags,
std::uint32_t mode, orbis::Thread *thread) {
auto newFile = orbis::knew<Hmd2ImuFile>();
newFile->device = this;
newFile->ops = &ops;
*file = newFile;
return {};
}

IoDevice *createHmd2ImuCharacterDevice() { return orbis::knew<Hmd2ImuDevice>(); }
6 changes: 6 additions & 0 deletions rpcsx/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,13 @@ static void guestInitDev() {
vfs::addDevice("ssd0.user", createHddCharacterDevice(-41630302208)); /// ?????
vfs::addDevice("ssd0.user_bfs", createHddCharacterDevice(0x100000000));
vfs::addDevice("bfs/ctl", createHddCharacterDevice(0x100000000));
vfs::addDevice("md2", createHddCharacterDevice(0x100000000));
vfs::addDevice("a53io", createA53IoCharacterDevice());

vfs::addDevice("hmd2_cmd", createHmd2CmdCharacterDevice());
vfs::addDevice("hmd2_imu", createHmd2ImuCharacterDevice());
vfs::addDevice("hmd2_gaze", createHmd2GazeCharacterDevice());
vfs::addDevice("hmd2_gen_data", createHmd2GenDataCharacterDevice());
}

// mbus->emitEvent({
Expand Down

0 comments on commit 8c5bde7

Please sign in to comment.