mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-03 11:11:14 +00:00
thermosphere: add singleton define
This commit is contained in:
parent
c99a77a0c3
commit
b21c75b22b
5 changed files with 12 additions and 22 deletions
|
@ -26,3 +26,11 @@
|
||||||
|
|
||||||
#include "preprocessor.h"
|
#include "preprocessor.h"
|
||||||
#include "debug_log.h"
|
#include "debug_log.h"
|
||||||
|
|
||||||
|
#define SINGLETON(cl) \
|
||||||
|
NON_COPYABLE(cl);\
|
||||||
|
NON_MOVEABLE(cl);\
|
||||||
|
private:\
|
||||||
|
static cl instance;\
|
||||||
|
public:\
|
||||||
|
static cl &GetInstance() { return instance; }
|
||||||
|
|
|
@ -21,14 +21,10 @@
|
||||||
namespace ams::hvisor {
|
namespace ams::hvisor {
|
||||||
|
|
||||||
class HwBreakpointManager final : public HwStopPointManager {
|
class HwBreakpointManager final : public HwStopPointManager {
|
||||||
|
SINGLETON(HwBreakpointManager);
|
||||||
protected:
|
protected:
|
||||||
virtual bool FindPredicate(const cpu::DebugRegisterPair &pair, uintptr_t addr, size_t, cpu::DebugRegisterPair::LoadStoreControl) const;
|
virtual bool FindPredicate(const cpu::DebugRegisterPair &pair, uintptr_t addr, size_t, cpu::DebugRegisterPair::LoadStoreControl) const;
|
||||||
|
|
||||||
private:
|
|
||||||
static HwBreakpointManager instance;
|
|
||||||
public:
|
|
||||||
static HwBreakpointManager &GetInstance() { return instance; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void ReloadOnAllCores() const;
|
virtual void ReloadOnAllCores() const;
|
||||||
static void ReloadOnAllCoresSgiHandler();
|
static void ReloadOnAllCoresSgiHandler();
|
||||||
|
|
|
@ -25,11 +25,9 @@
|
||||||
namespace ams::hvisor {
|
namespace ams::hvisor {
|
||||||
|
|
||||||
class IrqManager final {
|
class IrqManager final {
|
||||||
NON_COPYABLE(IrqManager);
|
SINGLETON(IrqManager);
|
||||||
NON_MOVEABLE(IrqManager);
|
|
||||||
friend class VirtualGic;
|
friend class VirtualGic;
|
||||||
private:
|
private:
|
||||||
static IrqManager instance;
|
|
||||||
static constexpr u8 hostPriority = 0;
|
static constexpr u8 hostPriority = 0;
|
||||||
static constexpr u8 guestPriority = 1;
|
static constexpr u8 guestPriority = 1;
|
||||||
|
|
||||||
|
@ -92,8 +90,6 @@ namespace ams::hvisor {
|
||||||
gicd->sgir = GicV2Distributor::ForwardToAllOthers << 24 | id;
|
gicd->sgir = GicV2Distributor::ForwardToAllOthers << 24 | id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IrqManager &GetInstance() { return instance; }
|
|
||||||
|
|
||||||
static void HandleInterrupt(ExceptionStackFrame *frame);
|
static void HandleInterrupt(ExceptionStackFrame *frame);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -24,8 +24,7 @@
|
||||||
namespace ams::hvisor {
|
namespace ams::hvisor {
|
||||||
|
|
||||||
class SwBreakpointManager {
|
class SwBreakpointManager {
|
||||||
NON_COPYABLE(SwBreakpointManager);
|
SINGLETON(SwBreakpointManager);
|
||||||
NON_MOVEABLE(SwBreakpointManager);
|
|
||||||
private:
|
private:
|
||||||
struct Breakpoint {
|
struct Breakpoint {
|
||||||
uintptr_t address;
|
uintptr_t address;
|
||||||
|
@ -35,8 +34,6 @@ namespace ams::hvisor {
|
||||||
bool applied;
|
bool applied;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
|
||||||
static SwBreakpointManager instance;
|
|
||||||
private:
|
private:
|
||||||
mutable RecursiveSpinlock m_lock{};
|
mutable RecursiveSpinlock m_lock{};
|
||||||
std::atomic<bool> m_triedToApplyOrRevertBreakpoint{};
|
std::atomic<bool> m_triedToApplyOrRevertBreakpoint{};
|
||||||
|
@ -55,9 +52,6 @@ namespace ams::hvisor {
|
||||||
bool Apply(size_t id);
|
bool Apply(size_t id);
|
||||||
bool Revert(size_t id);
|
bool Revert(size_t id);
|
||||||
|
|
||||||
public:
|
|
||||||
static SwBreakpointManager &GetInstance() { return instance; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int Add(uintptr_t addr, bool persistent);
|
int Add(uintptr_t addr, bool persistent);
|
||||||
int Remove(uintptr_t addr, bool keepPersistent);
|
int Remove(uintptr_t addr, bool keepPersistent);
|
||||||
|
|
|
@ -21,14 +21,10 @@
|
||||||
namespace ams::hvisor {
|
namespace ams::hvisor {
|
||||||
|
|
||||||
class WatchpointManager final : public HwStopPointManager {
|
class WatchpointManager final : public HwStopPointManager {
|
||||||
|
SINGLETON(WatchpointManager);
|
||||||
protected:
|
protected:
|
||||||
virtual bool FindPredicate(const cpu::DebugRegisterPair &pair, uintptr_t addr, size_t size, cpu::DebugRegisterPair::LoadStoreControl direction) const;
|
virtual bool FindPredicate(const cpu::DebugRegisterPair &pair, uintptr_t addr, size_t size, cpu::DebugRegisterPair::LoadStoreControl direction) const;
|
||||||
|
|
||||||
private:
|
|
||||||
static WatchpointManager instance;
|
|
||||||
public:
|
|
||||||
static WatchpointManager &GetInstance() { return instance; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void ReloadOnAllCores() const;
|
virtual void ReloadOnAllCores() const;
|
||||||
static void ReloadOnAllCoresSgiHandler();
|
static void ReloadOnAllCoresSgiHandler();
|
||||||
|
|
Loading…
Reference in a new issue