2023-11-11 18:27:01 +01:00
|
|
|
#include "io-device.hpp"
|
|
|
|
|
#include "orbis/KernelAllocator.hpp"
|
|
|
|
|
#include "orbis/file.hpp"
|
|
|
|
|
#include "orbis/utils/Logs.hpp"
|
|
|
|
|
|
|
|
|
|
struct DevCtlFile : orbis::File {};
|
|
|
|
|
|
|
|
|
|
static orbis::ErrorCode devctl_ioctl(orbis::File *file, std::uint64_t request,
|
|
|
|
|
void *argp, orbis::Thread *thread) {
|
|
|
|
|
|
|
|
|
|
ORBIS_LOG_FATAL("Unhandled devctl ioctl", request);
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const orbis::FileOps fileOps = {
|
|
|
|
|
.ioctl = devctl_ioctl,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct DevCtlDevice : IoDevice {
|
2024-01-13 18:57:02 +01:00
|
|
|
orbis::kstring data;
|
2023-11-11 18:27:01 +01:00
|
|
|
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<DevCtlFile>();
|
|
|
|
|
newFile->ops = &fileOps;
|
|
|
|
|
newFile->device = this;
|
|
|
|
|
|
|
|
|
|
*file = newFile;
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IoDevice *createDevCtlCharacterDevice() { return orbis::knew<DevCtlDevice>(); }
|