2023-10-31 12:22:22 +01:00
|
|
|
#include "io-device.hpp"
|
|
|
|
|
#include "orbis/KernelAllocator.hpp"
|
|
|
|
|
#include "orbis/file.hpp"
|
2024-01-13 18:57:02 +01:00
|
|
|
#include "orbis/thread/Thread.hpp"
|
2023-10-31 12:22:22 +01:00
|
|
|
#include "orbis/utils/Logs.hpp"
|
|
|
|
|
|
|
|
|
|
struct CdFile : orbis::File {};
|
|
|
|
|
|
|
|
|
|
static orbis::ErrorCode cd_ioctl(orbis::File *file, std::uint64_t request,
|
2024-01-13 18:57:02 +01:00
|
|
|
void *argp, orbis::Thread *thread) {
|
|
|
|
|
if (request == 0xc4a81602) {
|
|
|
|
|
(*(std::uint32_t *)((char *)argp + 0x54)) = 1;
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::hours(120));
|
|
|
|
|
return {};
|
|
|
|
|
}
|
2023-10-31 12:22:22 +01:00
|
|
|
|
|
|
|
|
ORBIS_LOG_FATAL("Unhandled cd ioctl", request);
|
2024-01-13 18:57:02 +01:00
|
|
|
thread->where();
|
2023-10-31 12:22:22 +01:00
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const orbis::FileOps fileOps = {
|
|
|
|
|
.ioctl = cd_ioctl,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CdDevice : 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<CdFile>();
|
|
|
|
|
newFile->ops = &fileOps;
|
|
|
|
|
newFile->device = this;
|
|
|
|
|
|
|
|
|
|
*file = newFile;
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IoDevice *createCdCharacterDevice() { return orbis::knew<CdDevice>(); }
|