rpcsx/rpcsx-os/iodev/dipsw.cpp

76 lines
1.9 KiB
C++
Raw Normal View History

2023-06-23 02:28:14 +02:00
#include "io-device.hpp"
2023-07-04 18:19:17 +02:00
#include "orbis/KernelAllocator.hpp"
#include "orbis/file.hpp"
#include "orbis/utils/Logs.hpp"
#include "orbis/thread/Thread.hpp"
2023-06-23 02:28:14 +02:00
struct DipswFile : public orbis::File {};
2023-06-23 02:28:14 +02:00
static orbis::ErrorCode dipsw_ioctl(orbis::File *file, std::uint64_t request,
void *argp, orbis::Thread *thread) {
if (request == 0x40048806) { // isDevelopmentMode
ORBIS_LOG_ERROR("dipsw ioctl isDevelopmentMode", argp);
2023-06-23 02:28:14 +02:00
*reinterpret_cast<std::uint32_t *>(argp) = 0;
return {};
2023-06-23 02:28:14 +02:00
}
if (request == 0x40048807) {
ORBIS_LOG_ERROR("dipsw ioctl 0x40048807", argp);
*reinterpret_cast<std::uint32_t *>(argp) = 1;
return {};
}
2023-06-23 02:28:14 +02:00
// 0x40088808
// 0x40088809
if (request == 0x40088808) {
ORBIS_LOG_ERROR("dipsw ioctl 0x40088808", argp);
2023-06-23 02:28:14 +02:00
*reinterpret_cast<std::uint32_t *>(argp) = 1;
return {};
2023-06-23 02:28:14 +02:00
}
2023-07-04 18:19:17 +02:00
// 0x8010880a
2023-06-23 02:28:14 +02:00
if (request == 0x8010880a) { // write data? used on initilization
struct Args {
std::uint64_t address;
std::uint64_t size;
};
auto args = reinterpret_cast<Args *>(argp);
ORBIS_LOG_ERROR("dipsw ioctl 0x8010880a", args->address, args->size);
2023-06-23 02:28:14 +02:00
return {};
2023-06-23 02:28:14 +02:00
}
if (request == 0xc0088803) {
// TODO
*reinterpret_cast<std::uint32_t *>(argp) = 0;
return{};
}
ORBIS_LOG_FATAL("Unhandled dipsw ioctl", request);
thread->where();
2023-06-23 02:28:14 +02:00
//__builtin_trap();
return {};
2023-06-23 02:28:14 +02:00
}
static const orbis::FileOps ops = {
.ioctl = dipsw_ioctl,
};
struct DipswDevice : public IoDevice {
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
2023-07-29 21:46:28 +02:00
std::uint32_t flags, std::uint32_t mode,
orbis::Thread *thread) override {
auto newFile = orbis::knew<DipswFile>();
newFile->device = this;
newFile->ops = &ops;
*file = newFile;
return {};
}
};
2023-06-23 02:28:14 +02:00
IoDevice *createDipswCharacterDevice() { return orbis::knew<DipswDevice>(); }