2023-07-26 13:35:40 +02:00
|
|
|
#include "io-device.hpp"
|
|
|
|
|
#include "orbis/KernelAllocator.hpp"
|
2023-07-29 18:53:34 +02:00
|
|
|
#include "orbis/file.hpp"
|
2023-07-26 13:35:40 +02:00
|
|
|
#include "orbis/utils/Logs.hpp"
|
|
|
|
|
|
2023-07-29 18:53:34 +02:00
|
|
|
struct AjmFile : orbis::File {};
|
2023-07-26 13:35:40 +02:00
|
|
|
|
2023-07-29 18:53:34 +02:00
|
|
|
static orbis::ErrorCode ajm_ioctl(orbis::File *file, std::uint64_t request,
|
|
|
|
|
void *argp, orbis::Thread *thread) {
|
2023-07-26 13:35:40 +02:00
|
|
|
|
|
|
|
|
ORBIS_LOG_FATAL("Unhandled AJM ioctl", request);
|
2023-08-01 14:41:00 +02:00
|
|
|
return {};
|
2023-07-26 13:35:40 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-29 18:53:34 +02:00
|
|
|
static const orbis::FileOps fileOps = {
|
|
|
|
|
.ioctl = ajm_ioctl,
|
|
|
|
|
};
|
2023-07-26 13:35:40 +02:00
|
|
|
|
2023-07-29 18:53:34 +02:00
|
|
|
struct AjmDevice : 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 {
|
2023-07-29 18:53:34 +02:00
|
|
|
auto newFile = orbis::knew<AjmFile>();
|
|
|
|
|
newFile->ops = &fileOps;
|
|
|
|
|
newFile->device = this;
|
|
|
|
|
|
|
|
|
|
*file = newFile;
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
};
|
2023-07-26 13:35:40 +02:00
|
|
|
|
2023-07-29 18:53:34 +02:00
|
|
|
IoDevice *createAjmCharacterDevice() { return orbis::knew<AjmDevice>(); }
|