mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
[orbis-kernel] WIP new io device implementation
Not used yet
This commit is contained in:
parent
679bf94b5c
commit
855b7ab75c
56
orbis-kernel/include/orbis/file.hpp
Normal file
56
orbis-kernel/include/orbis/file.hpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "error/ErrorCode.hpp"
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
namespace orbis {
|
||||
struct File;
|
||||
struct KNote;
|
||||
struct Thread;
|
||||
struct Stat;
|
||||
struct Uio;
|
||||
|
||||
struct FileOps {
|
||||
std::int32_t flags;
|
||||
ErrorCode (*ioctl)(File *file, std::uint64_t request, void *argp,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*rdwr)(File *file, Uio *uio, Thread *thread) = nullptr;
|
||||
ErrorCode (*close)(File *file, Thread *thread) = nullptr;
|
||||
ErrorCode (*lseek)(File *file, std::uint64_t *offset, std::uint32_t whence,
|
||||
Thread *thread) = nullptr;
|
||||
|
||||
ErrorCode (*truncate)(File *file, std::uint64_t len,
|
||||
Thread *thread) = nullptr;
|
||||
|
||||
ErrorCode (*poll)(File *file, std::uint32_t events, Thread *thread) = nullptr;
|
||||
|
||||
ErrorCode (*kqfilter)(File *file, KNote *kn, Thread *thread) = nullptr;
|
||||
|
||||
ErrorCode (*stat)(File *file, Stat *sb, Thread *thread) = nullptr;
|
||||
|
||||
// TODO: chown
|
||||
// TODO: chmod
|
||||
|
||||
ErrorCode (*mmap)(File *file, void **address, std::uint64_t size,
|
||||
std::int32_t prot, std::int32_t flags, std::int64_t offset,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*munmap)(File *file, void **address, std::uint64_t size,
|
||||
Thread *thread) = nullptr;
|
||||
};
|
||||
|
||||
struct File {
|
||||
FileOps *ops;
|
||||
Ref<RcBase> device;
|
||||
std::atomic<unsigned> refs{0};
|
||||
|
||||
void incRef() { refs.fetch_add(1, std::memory_order::acquire); }
|
||||
|
||||
void decRef() {
|
||||
if (refs.fetch_sub(1, std::memory_order::release) == 1) {
|
||||
kdelete(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace orbis
|
||||
26
orbis-kernel/include/orbis/stat.hpp
Normal file
26
orbis-kernel/include/orbis/stat.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include "orbis-config.hpp"
|
||||
#include "time.hpp"
|
||||
|
||||
namespace orbis {
|
||||
struct Stat {
|
||||
uint32_t dev; // inode's device
|
||||
uint32_t ino; // inode's number
|
||||
uint16_t mode; // inode protection mode
|
||||
uint16_t nlink; // number of hard links
|
||||
uint32_t uid; // user ID of the file's owner
|
||||
uint32_t gid; // group ID of the file's group
|
||||
uint32_t rdev; // device type
|
||||
timespec atim; // time of last access
|
||||
timespec mtim; // time of last data modification
|
||||
timespec ctim; // time of last file status change
|
||||
off_t size; // file size, in bytes
|
||||
int64_t blocks; // blocks allocated for file
|
||||
uint32_t blksize; // optimal blocksize for I/O
|
||||
uint32_t flags; // user defined flags for file
|
||||
uint32_t gen; // file generation number
|
||||
int32_t lspare;
|
||||
timespec birthtim; // time of file creation
|
||||
};
|
||||
} // namespace orbis
|
||||
29
orbis-kernel/include/orbis/uio.hpp
Normal file
29
orbis-kernel/include/orbis/uio.hpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace orbis {
|
||||
struct IoVec {
|
||||
void *base; // Base address
|
||||
std::uint64_t len; // Length
|
||||
};
|
||||
|
||||
enum class UioRw : std::uint8_t { Read, Write };
|
||||
|
||||
// Segment flag values
|
||||
enum class UioSeg : std::uint8_t {
|
||||
UserSpace, // from user data space
|
||||
SysSpace, // from system space
|
||||
NoCopy // don't copy, already in object
|
||||
};
|
||||
|
||||
struct Uio {
|
||||
std::uint64_t offset;
|
||||
IoVec *iov;
|
||||
std::int32_t iovcnt;
|
||||
std::int32_t resid;
|
||||
UioSeg segflg;
|
||||
UioRw rw;
|
||||
void *td;
|
||||
};
|
||||
} // namespace orbis
|
||||
Loading…
Reference in a new issue