merge rpcsx-gpu and rpcsx-os

initial watchdog implementation
implement gpu -> os events
implement main gfx queue
This commit is contained in:
DH 2024-10-12 05:24:58 +03:00
parent 8e9711e0f6
commit 0c16e294d4
236 changed files with 4649 additions and 4669 deletions

View file

@ -2,6 +2,7 @@
#include "KernelAllocator.hpp"
#include "evf.hpp"
#include "ipmi.hpp"
#include "orbis/note.hpp"
#include "osem.hpp"
#include "thread/types.hpp"
#include "utils/IdMap.hpp"
@ -174,9 +175,12 @@ public:
return getUmtxChainIndexed(1, t, flags, ptr);
}
Ref<EventEmitter> deviceEventEmitter;
Ref<RcBase> shmDevice;
Ref<RcBase> dmemDevice;
Ref<RcBase> blockpoolDevice;
shared_mutex gpuDeviceMtx;
Ref<RcBase> gpuDevice;
uint sdkVersion{};
uint fwSdkVersion{};
uint safeMode{};

View file

@ -1,4 +1,5 @@
#pragma once
#include <compare>
namespace orbis {
enum class ErrorCode : int;
@ -18,5 +19,13 @@ public:
[[nodiscard]] int value() const { return mValue < 0 ? -mValue : mValue; }
[[nodiscard]] bool isError() const { return mValue < 0; }
[[nodiscard]] auto operator<=>(ErrorCode ec) const {
return static_cast<ErrorCode>(value()) <=> ec;
}
[[nodiscard]] auto operator<=>(SysResult other) const {
return value() <=> other.value();
}
};
} // namespace orbis

View file

@ -2,8 +2,8 @@
#include "KernelAllocator.hpp"
#include "orbis-config.hpp"
#include "orbis/utils/Rc.hpp"
#include "utils/SharedMutex.hpp"
#include <mutex>
#include <set>
namespace orbis {
@ -71,6 +71,7 @@ struct KEvent {
ptr<void> udata;
};
struct EventEmitter;
struct KQueue;
struct KNote {
shared_mutex mutex;
@ -80,6 +81,7 @@ struct KNote {
bool enabled = true;
bool triggered = false;
void *linked = nullptr; // TODO: use Ref<>
kvector<Ref<EventEmitter>> emitters;
~KNote();
};
@ -88,6 +90,8 @@ struct EventEmitter : orbis::RcBase {
shared_mutex mutex;
std::set<KNote *, std::less<>, kallocator<KNote *>> notes;
void emit(uint filter, uint fflags = 0, intptr_t data = 0);
void emit(sshort filter, uint fflags = 0, intptr_t data = 0);
void subscribe(KNote *note);
void unsubscribe(KNote *note);
};
} // namespace orbis

View file

@ -46,6 +46,7 @@ struct NamedMemoryRange {
struct Process final {
KernelContext *context = nullptr;
pid_t pid = -1;
int gfxRing = 0;
std::uint64_t hostPid = -1;
sysentvec *sysent = nullptr;
ProcessState state = ProcessState::NEW;

View file

@ -3,7 +3,7 @@
namespace orbis {
using lwpid_t = int32_t;
using pid_t = int64_t;
using pid_t = int32_t;
using uid_t = uint32_t;
using gid_t = uint32_t;

View file

@ -49,11 +49,11 @@ template <typename T> class Ref {
public:
Ref() = default;
Ref(std::nullptr_t) {}
Ref(std::nullptr_t) noexcept {}
template <typename OT>
requires(std::is_base_of_v<T, OT>)
Ref(OT *ref) : m_ref(ref) {
Ref(OT *ref) noexcept : m_ref(ref) {
if (m_ref != nullptr) {
ref->incRef();
}
@ -61,7 +61,7 @@ public:
template <typename OT>
requires(std::is_base_of_v<T, OT>)
Ref(const Ref<OT> &other) : m_ref(other.get()) {
Ref(const Ref<OT> &other) noexcept : m_ref(other.get()) {
if (m_ref != nullptr) {
m_ref->incRef();
}
@ -69,42 +69,42 @@ public:
template <typename OT>
requires(std::is_base_of_v<T, OT>)
Ref(Ref<OT> &&other) : m_ref(other.release()) {}
Ref(Ref<OT> &&other) noexcept : m_ref(other.release()) {}
Ref(const Ref &other) : m_ref(other.get()) {
Ref(const Ref &other) noexcept : m_ref(other.get()) {
if (m_ref != nullptr) {
m_ref->incRef();
}
}
Ref(Ref &&other) : m_ref(other.release()) {}
Ref(Ref &&other) noexcept : m_ref(other.release()) {}
template <typename OT>
requires(std::is_base_of_v<T, OT>)
Ref &operator=(Ref<OT> &&other) {
Ref &operator=(Ref<OT> &&other) noexcept {
other.template cast<T>().swap(*this);
return *this;
}
template <typename OT>
requires(std::is_base_of_v<T, OT>)
Ref &operator=(OT *other) {
Ref &operator=(OT *other) noexcept {
*this = Ref(other);
return *this;
}
template <typename OT>
requires(std::is_base_of_v<T, OT>)
Ref &operator=(const Ref<OT> &other) {
Ref &operator=(const Ref<OT> &other) noexcept {
*this = Ref(other);
return *this;
}
Ref &operator=(const Ref &other) {
Ref &operator=(const Ref &other) noexcept {
*this = Ref(other);
return *this;
}
Ref &operator=(Ref &&other) {
Ref &operator=(Ref &&other) noexcept {
other.swap(*this);
return *this;
}
@ -115,7 +115,7 @@ public:
}
}
void swap(Ref<T> &other) { std::swap(m_ref, other.m_ref); }
void swap(Ref<T> &other) noexcept { std::swap(m_ref, other.m_ref); }
T *get() const { return m_ref; }
T *release() { return std::exchange(m_ref, nullptr); }
T *operator->() const { return m_ref; }
@ -126,10 +126,17 @@ public:
auto operator<=>(const Ref &other) const = default;
template <typename OtherT> Ref<OtherT> cast() {
return Ref<OtherT>(dynamic_cast<OtherT *>(m_ref));
return dynamic_cast<OtherT *>(m_ref);
}
template <typename OtherT> Ref<OtherT> staticCast() {
return Ref<OtherT>(static_cast<OtherT *>(m_ref));
return static_cast<OtherT *>(m_ref);
}
template <typename OtherT> OtherT *rawCast() {
return dynamic_cast<OtherT *>(m_ref);
}
template <typename OtherT> OtherT *rawStaticCast() {
return static_cast<OtherT *>(m_ref);
}
};