rpcsx/rpcsx-os/iodev/dipsw.cpp

64 lines
1.7 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/utils/Logs.hpp"
2023-06-23 02:28:14 +02:00
#include <cstdio>
2023-07-06 18:16:25 +02:00
struct DipswDevice : public IoDevice {};
2023-06-23 02:28:14 +02:00
2023-07-06 18:16:25 +02:00
struct DipswInstance : public IoDeviceInstance {};
2023-06-23 02:28:14 +02:00
static std::int64_t dipsw_instance_ioctl(IoDeviceInstance *instance,
std::uint64_t request, void *argp) {
if (request == 0x40048806) { // is connected?
ORBIS_LOG_ERROR("dipsw ioctl 0x40048806", argp);
2023-06-23 02:28:14 +02:00
*reinterpret_cast<std::uint32_t *>(argp) = 0;
return 0;
}
// 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 0;
}
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 0;
}
ORBIS_LOG_FATAL("Unhandled dipsw ioctl", request);
2023-07-06 18:16:25 +02:00
std::fflush(stdout);
2023-06-23 02:28:14 +02:00
//__builtin_trap();
return 0;
}
static std::int32_t dipsw_device_open(IoDevice *device,
orbis::Ref<IoDeviceInstance> *instance,
const char *path, std::uint32_t flags,
std::uint32_t mode) {
auto *newInstance = orbis::knew<DipswInstance>();
2023-06-23 02:28:14 +02:00
newInstance->ioctl = dipsw_instance_ioctl;
io_device_instance_init(device, newInstance);
*instance = newInstance;
return 0;
}
IoDevice *createDipswCharacterDevice() {
auto *newDevice = orbis::knew<DipswDevice>();
2023-06-23 02:28:14 +02:00
newDevice->open = dipsw_device_open;
return newDevice;
}