summaryrefslogtreecommitdiffstats
path: root/src/core/memory/freezer.h
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2019-05-30 22:57:23 +0200
committerZach Hilman <zachhilman@gmail.com>2019-06-21 01:22:04 +0200
commitc9983ad9a71c9462319d27c3791e13fae9d73e46 (patch)
treeec416c75834377e975fe4485f06854663db29463 /src/core/memory/freezer.h
parentmemory: Add class to manage and enforce memory freezing (diff)
downloadyuzu-c9983ad9a71c9462319d27c3791e13fae9d73e46.tar
yuzu-c9983ad9a71c9462319d27c3791e13fae9d73e46.tar.gz
yuzu-c9983ad9a71c9462319d27c3791e13fae9d73e46.tar.bz2
yuzu-c9983ad9a71c9462319d27c3791e13fae9d73e46.tar.lz
yuzu-c9983ad9a71c9462319d27c3791e13fae9d73e46.tar.xz
yuzu-c9983ad9a71c9462319d27c3791e13fae9d73e46.tar.zst
yuzu-c9983ad9a71c9462319d27c3791e13fae9d73e46.zip
Diffstat (limited to '')
-rw-r--r--src/core/memory/freezer.h39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/core/memory/freezer.h b/src/core/memory/freezer.h
index 3e271793e..b0c610039 100644
--- a/src/core/memory/freezer.h
+++ b/src/core/memory/freezer.h
@@ -4,14 +4,16 @@
#pragma once
+#include <atomic>
+#include <mutex>
#include <optional>
#include <vector>
#include "common/common_types.h"
-#include "core/core_timing.h"
-namespace Core {
-class System;
-} // namespace Core
+namespace Core::Timing {
+class CoreTiming;
+struct EventType;
+} // namespace Core::Timing
namespace Memory {
@@ -20,27 +22,42 @@ class Freezer {
public:
struct Entry {
VAddr address;
- u8 width;
+ u32 width;
u64 value;
};
- Freezer(Core::Timing::CoreTiming& core_timing);
+ explicit Freezer(Core::Timing::CoreTiming& core_timing);
~Freezer();
+ // Enables or disables the entire memory freezer.
void SetActive(bool active);
+
+ // Returns whether or not the freezer is active.
bool IsActive() const;
+ // Removes all entries from the freezer.
void Clear();
- u64 Freeze(VAddr address, u8 width);
+ // Freezes a value to its current memory address. The value the memory is kept at will be the
+ // value that is read during this function. Width can be 1, 2, 4, or 8 (in bytes).
+ u64 Freeze(VAddr address, u32 width);
+
+ // Unfreezes the memory value at address. If the address isn't frozen, this is a no-op.
void Unfreeze(VAddr address);
- bool IsFrozen(VAddr address);
+ // Returns whether or not the address is frozen.
+ bool IsFrozen(VAddr address) const;
+
+ // Sets the value that address should be frozen to. This doesn't change the width set by using
+ // Freeze(). If the value isn't frozen, this will not freeze it and is thus a no-op.
void SetFrozenValue(VAddr address, u64 value);
- std::optional<Entry> GetEntry(VAddr address);
+ // Returns the entry corresponding to the address if the address is frozen, otherwise
+ // std::nullopt.
+ std::optional<Entry> GetEntry(VAddr address) const;
- std::vector<Entry> GetEntries();
+ // Returns all the entries in the freezer, an empty vector means nothing is frozen.
+ std::vector<Entry> GetEntries() const;
private:
void FrameCallback(u64 userdata, s64 cycles_late);
@@ -48,7 +65,7 @@ private:
std::atomic_bool active{false};
- std::recursive_mutex entries_mutex;
+ mutable std::mutex entries_mutex;
std::vector<Entry> entries;
Core::Timing::EventType* event;