mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
[rpcsx-os] Use orbis::File instead of IoDeviceInstance
This commit is contained in:
parent
c29aada46a
commit
84b2419241
43 changed files with 1626 additions and 1161 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <deque>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
|
@ -46,7 +47,9 @@ using kunmap =
|
|||
std::unordered_map<K, T, Hash, Pred, kallocator<std::pair<const K, T>>>;
|
||||
} // namespace utils
|
||||
|
||||
template <typename T, typename... Args> T *knew(Args &&...args) {
|
||||
template <typename T, typename... Args>
|
||||
requires(std::is_constructible_v<T, Args...>)
|
||||
T *knew(Args &&...args) {
|
||||
auto loc = static_cast<T *>(utils::kalloc(sizeof(T), alignof(T)));
|
||||
auto res = std::construct_at(loc, std::forward<Args>(args)...);
|
||||
if constexpr (requires(T *t) { t->_total_size = sizeof(T); })
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "error/ErrorCode.hpp"
|
||||
#include <atomic>
|
||||
#include "utils/Rc.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace orbis {
|
||||
|
|
@ -16,10 +16,8 @@ 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 (*read)(File *file, Uio *uio, Thread *thread) = nullptr;
|
||||
ErrorCode (*write)(File *file, Uio *uio, Thread *thread) = nullptr;
|
||||
|
||||
ErrorCode (*truncate)(File *file, std::uint64_t len,
|
||||
Thread *thread) = nullptr;
|
||||
|
|
@ -40,17 +38,10 @@ struct FileOps {
|
|||
Thread *thread) = nullptr;
|
||||
};
|
||||
|
||||
struct File final {
|
||||
FileOps *ops;
|
||||
struct File : RcBase {
|
||||
shared_mutex mtx;
|
||||
const FileOps *ops = nullptr;
|
||||
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);
|
||||
}
|
||||
}
|
||||
std::uint64_t nextOff = 0;
|
||||
};
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ struct KEvent;
|
|||
struct timespec;
|
||||
struct Stat;
|
||||
struct stack_t;
|
||||
struct IoVec;
|
||||
|
||||
SysResult nosys(Thread *thread);
|
||||
|
||||
|
|
@ -126,10 +127,8 @@ SysResult sys_gettimeofday(Thread *thread, ptr<orbis::timeval> tp,
|
|||
SysResult sys_getrusage(Thread *thread, sint who, ptr<struct rusage> rusage);
|
||||
SysResult sys_getsockopt(Thread *thread, sint s, sint level, sint name,
|
||||
caddr_t val, ptr<sint> avalsize);
|
||||
SysResult sys_readv(Thread *thread, sint fd, ptr<struct iovec> iovp,
|
||||
uint iovcnt);
|
||||
SysResult sys_writev(Thread *thread, sint fd, ptr<struct iovec> iovp,
|
||||
uint iovcnt);
|
||||
SysResult sys_readv(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt);
|
||||
SysResult sys_writev(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt);
|
||||
SysResult sys_settimeofday(Thread *thread, ptr<struct timeval> tp,
|
||||
ptr<orbis::timezone> tzp);
|
||||
SysResult sys_fchown(Thread *thread, sint fd, sint uid, sint gid);
|
||||
|
|
@ -249,10 +248,10 @@ SysResult sys_lutimes(Thread *thread, ptr<char> path, ptr<struct timeval> tptr);
|
|||
SysResult sys_nstat(Thread *thread, ptr<char> path, ptr<struct nstat> ub);
|
||||
SysResult sys_nfstat(Thread *thread, sint fd, ptr<struct nstat> sb);
|
||||
SysResult sys_nlstat(Thread *thread, ptr<char> path, ptr<struct nstat> ub);
|
||||
SysResult sys_preadv(Thread *thread, sint fd, ptr<struct iovec> iovp,
|
||||
uint iovcnt, off_t offset);
|
||||
SysResult sys_pwritev(Thread *thread, sint fd, ptr<struct iovec> iovp,
|
||||
uint iovcnt, off_t offset);
|
||||
SysResult sys_preadv(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt,
|
||||
off_t offset);
|
||||
SysResult sys_pwritev(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt,
|
||||
off_t offset);
|
||||
SysResult sys_fhopen(Thread *thread, ptr<const struct fhandle> u_fhp,
|
||||
sint flags);
|
||||
SysResult sys_fhstat(Thread *thread, ptr<const struct fhandle> u_fhp,
|
||||
|
|
@ -361,8 +360,7 @@ SysResult sys_eaccess(Thread *thread, ptr<char> path, sint flags);
|
|||
SysResult sys_afs3_syscall(Thread *thread, slong syscall, slong param1,
|
||||
slong param2, slong param3, slong param4,
|
||||
slong param5, slong param6);
|
||||
SysResult sys_nmount(Thread *thread, ptr<struct iovec> iovp, uint iovcnt,
|
||||
sint flags);
|
||||
SysResult sys_nmount(Thread *thread, ptr<IoVec> iovp, uint iovcnt, sint flags);
|
||||
SysResult sys___mac_get_proc(Thread *thread, ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_set_proc(Thread *thread, ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_get_fd(Thread *thread, sint fd, ptr<struct mac> mac_p);
|
||||
|
|
@ -494,14 +492,14 @@ SysResult sys_sctp_generic_sendmsg(Thread *thread, sint sd, caddr_t msg,
|
|||
sint mlen, caddr_t to, __socklen_t tolen,
|
||||
ptr<struct sctp_sndrcvinfo> sinfo,
|
||||
sint flags);
|
||||
SysResult sys_sctp_generic_sendmsg_iov(Thread *thread, sint sd,
|
||||
ptr<struct iovec> iov, sint iovlen,
|
||||
caddr_t to, __socklen_t tolen,
|
||||
SysResult sys_sctp_generic_sendmsg_iov(Thread *thread, sint sd, ptr<IoVec> iov,
|
||||
sint iovlen, caddr_t to,
|
||||
__socklen_t tolen,
|
||||
ptr<struct sctp_sndrcvinfo> sinfo,
|
||||
sint flags);
|
||||
SysResult sys_sctp_generic_recvmsg(Thread *thread, sint sd,
|
||||
ptr<struct iovec> iov, sint iovlen,
|
||||
caddr_t from, __socklen_t fromlen,
|
||||
SysResult sys_sctp_generic_recvmsg(Thread *thread, sint sd, ptr<IoVec> iov,
|
||||
sint iovlen, caddr_t from,
|
||||
__socklen_t fromlen,
|
||||
ptr<struct sctp_sndrcvinfo> sinfo,
|
||||
sint flags);
|
||||
SysResult sys_pread(Thread *thread, sint fd, ptr<void> buf, size_t nbyte,
|
||||
|
|
@ -557,9 +555,9 @@ SysResult sys_symlinkat(Thread *thread, ptr<char> path1, sint fd,
|
|||
SysResult sys_unlinkat(Thread *thread, sint fd, ptr<char> path, sint flag);
|
||||
SysResult sys_posix_openpt(Thread *thread, sint flags);
|
||||
SysResult sys_gssd_syscall(Thread *thread, ptr<char> path);
|
||||
SysResult sys_jail_get(Thread *thread, ptr<struct iovec> iovp, uint iovcnt,
|
||||
SysResult sys_jail_get(Thread *thread, ptr<IoVec> iovp, uint iovcnt,
|
||||
sint flags);
|
||||
SysResult sys_jail_set(Thread *thread, ptr<struct iovec> iovp, uint iovcnt,
|
||||
SysResult sys_jail_set(Thread *thread, ptr<IoVec> iovp, uint iovcnt,
|
||||
sint flags);
|
||||
SysResult sys_jail_remove(Thread *thread, sint jid);
|
||||
SysResult sys_closefrom(Thread *thread, sint lowfd);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@
|
|||
#include "../thread/Thread.hpp"
|
||||
#include "../thread/types.hpp"
|
||||
#include "ProcessState.hpp"
|
||||
#include "orbis/file.hpp"
|
||||
#include "orbis/module/Module.hpp"
|
||||
#include "orbis/utils/IdMap.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace orbis {
|
||||
class KernelContext;
|
||||
struct Thread;
|
||||
|
|
@ -61,7 +60,7 @@ struct Process final {
|
|||
utils::RcIdMap<Semaphore, sint, 4097, 1> semMap;
|
||||
utils::RcIdMap<Module, ModuleHandle> modulesMap;
|
||||
utils::OwningIdMap<Thread, lwpid_t> threadsMap;
|
||||
utils::RcIdMap<utils::RcBase, sint> fileDescriptors;
|
||||
utils::RcIdMap<orbis::File, sint> fileDescriptors;
|
||||
|
||||
// Named objects for debugging
|
||||
utils::shared_mutex namedObjMutex;
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@
|
|||
#include "../module/ModuleHandle.hpp"
|
||||
#include "../thread/types.hpp"
|
||||
#include "orbis-config.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
|
||||
namespace orbis {
|
||||
struct Thread;
|
||||
struct Module;
|
||||
struct timespec;
|
||||
struct File;
|
||||
|
||||
struct ProcessOps {
|
||||
SysResult (*mmap)(Thread *thread, caddr_t addr, size_t len, sint prot,
|
||||
|
|
@ -28,22 +30,10 @@ struct ProcessOps {
|
|||
SysResult (*virtual_query)(Thread *thread, ptr<const void> addr, sint flags,
|
||||
ptr<void> info, ulong infoSize);
|
||||
|
||||
SysResult (*open)(Thread *thread, ptr<const char> path, sint flags,
|
||||
sint mode);
|
||||
SysResult (*open)(Thread *thread, ptr<const char> path, sint flags, sint mode,
|
||||
Ref<File> *file);
|
||||
SysResult (*socket)(Thread *thread, ptr<const char> name, sint domain,
|
||||
sint type, sint protocol);
|
||||
SysResult (*close)(Thread *thread, sint fd);
|
||||
SysResult (*ioctl)(Thread *thread, sint fd, ulong com, caddr_t argp);
|
||||
SysResult (*write)(Thread *thread, sint fd, ptr<const void> data, ulong size);
|
||||
SysResult (*read)(Thread *thread, sint fd, ptr<void> data, ulong size);
|
||||
SysResult (*pread)(Thread *thread, sint fd, ptr<void> data, ulong size,
|
||||
ulong offset);
|
||||
SysResult (*pwrite)(Thread *thread, sint fd, ptr<const void> data, ulong size,
|
||||
ulong offset);
|
||||
SysResult (*lseek)(Thread *thread, sint fd, ulong offset, sint whence);
|
||||
SysResult (*ftruncate)(Thread *thread, sint fd, off_t length);
|
||||
SysResult (*truncate)(Thread *thread, ptr<const char> path, off_t length);
|
||||
|
||||
sint type, sint protocol, Ref<File> *file);
|
||||
SysResult (*dynlib_get_obj_member)(Thread *thread, ModuleHandle handle,
|
||||
uint64_t index, ptr<ptr<void>> addrp);
|
||||
SysResult (*dynlib_dlsym)(Thread *thread, ModuleHandle handle,
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ enum class UioSeg : std::uint8_t {
|
|||
struct Uio {
|
||||
std::uint64_t offset;
|
||||
IoVec *iov;
|
||||
std::int32_t iovcnt;
|
||||
std::int32_t resid;
|
||||
std::uint32_t iovcnt;
|
||||
std::int64_t resid;
|
||||
UioSeg segflg;
|
||||
UioRw rw;
|
||||
void *td;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
#include <atomic>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
namespace orbis {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue