Skip to content

Commit

Permalink
ps5: add hdd devices
Browse files Browse the repository at this point in the history
stub nsid1.ctl and a53io devices
  • Loading branch information
DHrpcs3 committed Nov 21, 2024
1 parent c3edcfe commit 8797cf8
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rpcsx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_executable(rpcsx
audio/AudioDevice.cpp
audio/AlsaDevice.cpp

iodev/a53io.cpp
iodev/ajm.cpp
iodev/blockpool.cpp
iodev/bt.cpp
Expand All @@ -31,6 +32,7 @@ add_executable(rpcsx
iodev/metadbg.cpp
iodev/notification.cpp
iodev/npdrm.cpp
iodev/nsid_ctl.cpp
iodev/null.cpp
iodev/rng.cpp
iodev/sbl_srv.cpp
Expand Down
2 changes: 2 additions & 0 deletions rpcsx/io-devices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ IoDevice *createScreenShotCharacterDevice();
IoDevice *createLvdCtlCharacterDevice();
IoDevice *createIccPowerCharacterDevice();
IoDevice *createCaymanRegCharacterDevice();
IoDevice *createA53IoCharacterDevice();
IoDevice *createNsidCtlCharacterDevice();
42 changes: 42 additions & 0 deletions rpcsx/iodev/a53io.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "io-device.hpp"
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"
#include <chrono>
#include <thread>

struct A53IoFile : orbis::File {};

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

ORBIS_LOG_FATAL("Unhandled a53io ioctl", request);
return {};
}
static orbis::ErrorCode a53io_read(orbis::File *file, orbis::Uio *uio,
orbis::Thread *thread) {
ORBIS_LOG_TODO(__FUNCTION__);

std::this_thread::sleep_for(std::chrono::days(1));
return {};
}

static const orbis::FileOps fileOps = {
.ioctl = a53io_ioctl,
.read = a53io_read,
};

struct A53IoDevice : 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<A53IoFile>();
newFile->ops = &fileOps;
newFile->device = this;

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

IoDevice *createA53IoCharacterDevice() { return orbis::knew<A53IoDevice>(); }
51 changes: 51 additions & 0 deletions rpcsx/iodev/nsid_ctl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "io-device.hpp"
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"
#include "vfs.hpp"
#include "../io-devices.hpp"
#include <chrono>
#include <thread>

struct NsidCtlFile : orbis::File {};

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

if (request == 0x20003102) {
ORBIS_LOG_ERROR(__FUNCTION__, "create ssd0 device");
vfs::addDevice("ssd0", createHddCharacterDevice(0x100000000));
} else {
ORBIS_LOG_FATAL("Unhandled nsid_ctl ioctl", request);
}


return {};
}
static orbis::ErrorCode nsid_ctl_read(orbis::File *file, orbis::Uio *uio,
orbis::Thread *thread) {
ORBIS_LOG_TODO(__FUNCTION__);

std::this_thread::sleep_for(std::chrono::days(1));
return {};
}

static const orbis::FileOps fileOps = {
.ioctl = nsid_ctl_ioctl,
.read = nsid_ctl_read,
};

struct NsidCtlDevice : 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<NsidCtlFile>();
newFile->ops = &fileOps;
newFile->device = this;

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

IoDevice *createNsidCtlCharacterDevice() { return orbis::knew<NsidCtlDevice>(); }
20 changes: 20 additions & 0 deletions rpcsx/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,26 @@ static void guestInitDev() {
if (orbis::g_context.fwType == orbis::FwType::Ps5) {
vfs::addDevice("iccnvs4", createIccPowerCharacterDevice());
vfs::addDevice("ajmi", createAjmCharacterDevice());
vfs::addDevice("ssd0", createHddCharacterDevice(0x100000000));
vfs::addDevice("nsid1.ctl", createNsidCtlCharacterDevice());
vfs::addDevice("ssd0.swapx2", createHddCharacterDevice(0x100000000));
vfs::addDevice("ssd0.bd_rvlist", createHddCharacterDevice(1048576));
vfs::addDevice("ssd0.system", createHddCharacterDevice(671088640));
vfs::addDevice("ssd0.system_ex", createHddCharacterDevice(1610612736));
vfs::addDevice("ssd0.system_b", createHddCharacterDevice(671088640));
vfs::addDevice("ssd0.system_ex_b", createHddCharacterDevice(1610612736));
vfs::addDevice("ssd0.preinst", createHddCharacterDevice(155189248));
vfs::addDevice("ssd0.app_temp0", createHddCharacterDevice(1073741824));
// vfs::addDevice("ssd0.app_temp1", createHddCharacterDevice(1073741824));
vfs::addDevice("ssd0.system_data", createHddCharacterDevice(8589934592));
vfs::addDevice("ssd0.update", createHddCharacterDevice(4294967296));
vfs::addDevice("ssd0.swap", createHddCharacterDevice(8589934592));
vfs::addDevice("ssd0.app_swap", createHddCharacterDevice(15032385536));
vfs::addDevice("ssd0.hibernation", createHddCharacterDevice(3623878656));
vfs::addDevice("ssd0.user", createHddCharacterDevice(-41630302208)); /// ?????
vfs::addDevice("ssd0.user_bfs", createHddCharacterDevice(0x100000000));
vfs::addDevice("bfs/ctl", createHddCharacterDevice(0x100000000));
vfs::addDevice("a53io", createA53IoCharacterDevice());
}

// mbus->emitEvent({
Expand Down

0 comments on commit 8797cf8

Please sign in to comment.