2023-11-03 20:41:32 +01:00
|
|
|
#include "io-device.hpp"
|
2024-01-13 18:57:02 +01:00
|
|
|
#include "iodev/mbus_av.hpp"
|
2023-11-03 20:41:32 +01:00
|
|
|
#include "orbis/KernelAllocator.hpp"
|
|
|
|
|
#include "orbis/file.hpp"
|
2024-01-13 18:57:02 +01:00
|
|
|
#include "orbis/thread/Process.hpp"
|
|
|
|
|
#include "orbis/thread/ProcessOps.hpp"
|
2023-12-31 12:30:49 +01:00
|
|
|
#include "orbis/thread/Thread.hpp"
|
2023-11-13 19:38:21 +01:00
|
|
|
#include "orbis/uio.hpp"
|
2023-11-03 20:41:32 +01:00
|
|
|
#include "orbis/utils/Logs.hpp"
|
2023-12-31 12:30:49 +01:00
|
|
|
#include <bits/types/struct_iovec.h>
|
2023-11-03 20:41:32 +01:00
|
|
|
|
|
|
|
|
struct AoutFile : orbis::File {};
|
|
|
|
|
|
|
|
|
|
static orbis::ErrorCode aout_ioctl(orbis::File *file, std::uint64_t request,
|
2023-12-31 12:30:49 +01:00
|
|
|
void *argp, orbis::Thread *thread) {
|
2023-11-03 20:41:32 +01:00
|
|
|
ORBIS_LOG_FATAL("Unhandled aout ioctl", request);
|
2023-12-31 12:30:49 +01:00
|
|
|
thread->where();
|
2023-11-13 19:38:21 +01:00
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static orbis::ErrorCode aout_write(orbis::File *file, orbis::Uio *uio,
|
|
|
|
|
orbis::Thread *) {
|
2023-12-31 12:30:49 +01:00
|
|
|
for (auto entry : std::span(uio->iov, uio->iovcnt)) {
|
|
|
|
|
uio->offset += entry.len;
|
|
|
|
|
}
|
2023-11-03 20:41:32 +01:00
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const orbis::FileOps fileOps = {
|
|
|
|
|
.ioctl = aout_ioctl,
|
2023-11-13 19:38:21 +01:00
|
|
|
.write = aout_write,
|
2023-11-03 20:41:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AoutDevice : IoDevice {
|
|
|
|
|
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
|
|
|
|
std::uint32_t flags, std::uint32_t mode,
|
|
|
|
|
orbis::Thread *thread) override {
|
2023-12-31 12:30:49 +01:00
|
|
|
ORBIS_LOG_FATAL("aout device open", path, flags, mode);
|
2023-11-03 20:41:32 +01:00
|
|
|
auto newFile = orbis::knew<AoutFile>();
|
|
|
|
|
newFile->ops = &fileOps;
|
|
|
|
|
newFile->device = this;
|
2023-12-31 12:30:49 +01:00
|
|
|
thread->where();
|
2023-11-03 20:41:32 +01:00
|
|
|
|
|
|
|
|
*file = newFile;
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IoDevice *createAoutCharacterDevice() { return orbis::knew<AoutDevice>(); }
|