diff options
| author | 2019-06-07 11:11:11 -0400 | |
|---|---|---|
| committer | 2019-06-20 19:22:53 -0400 | |
| commit | ed82fa3a91fc84f7f906b898d8f71e15fb42c16e (patch) | |
| tree | 4cacf3974405b80f64b5108481ea198fd08f4aee /src/core/tools/freezer.h | |
| parent | freezer: Add documentation for methods (diff) | |
| download | yuzu-ed82fa3a91fc84f7f906b898d8f71e15fb42c16e.tar.gz yuzu-ed82fa3a91fc84f7f906b898d8f71e15fb42c16e.tar.xz yuzu-ed82fa3a91fc84f7f906b898d8f71e15fb42c16e.zip | |
core: Move Freezer class to tools namespace
Diffstat (limited to 'src/core/tools/freezer.h')
| -rw-r--r-- | src/core/tools/freezer.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/core/tools/freezer.h b/src/core/tools/freezer.h new file mode 100644 index 000000000..5edd049c1 --- /dev/null +++ b/src/core/tools/freezer.h | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <atomic> | ||
| 8 | #include <mutex> | ||
| 9 | #include <optional> | ||
| 10 | #include <vector> | ||
| 11 | #include "common/common_types.h" | ||
| 12 | |||
| 13 | namespace Core::Timing { | ||
| 14 | class CoreTiming; | ||
| 15 | struct EventType; | ||
| 16 | } // namespace Core::Timing | ||
| 17 | |||
| 18 | namespace Tools { | ||
| 19 | |||
| 20 | // A class that will effectively freeze memory values. | ||
| 21 | class Freezer { | ||
| 22 | public: | ||
| 23 | struct Entry { | ||
| 24 | VAddr address; | ||
| 25 | u32 width; | ||
| 26 | u64 value; | ||
| 27 | }; | ||
| 28 | |||
| 29 | explicit Freezer(Core::Timing::CoreTiming& core_timing); | ||
| 30 | ~Freezer(); | ||
| 31 | |||
| 32 | // Enables or disables the entire memory freezer. | ||
| 33 | void SetActive(bool active); | ||
| 34 | |||
| 35 | // Returns whether or not the freezer is active. | ||
| 36 | bool IsActive() const; | ||
| 37 | |||
| 38 | // Removes all entries from the freezer. | ||
| 39 | void Clear(); | ||
| 40 | |||
| 41 | // Freezes a value to its current memory address. The value the memory is kept at will be the | ||
| 42 | // value that is read during this function. Width can be 1, 2, 4, or 8 (in bytes). | ||
| 43 | u64 Freeze(VAddr address, u32 width); | ||
| 44 | |||
| 45 | // Unfreezes the memory value at address. If the address isn't frozen, this is a no-op. | ||
| 46 | void Unfreeze(VAddr address); | ||
| 47 | |||
| 48 | // Returns whether or not the address is frozen. | ||
| 49 | bool IsFrozen(VAddr address) const; | ||
| 50 | |||
| 51 | // Sets the value that address should be frozen to. This doesn't change the width set by using | ||
| 52 | // Freeze(). If the value isn't frozen, this will not freeze it and is thus a no-op. | ||
| 53 | void SetFrozenValue(VAddr address, u64 value); | ||
| 54 | |||
| 55 | // Returns the entry corresponding to the address if the address is frozen, otherwise | ||
| 56 | // std::nullopt. | ||
| 57 | std::optional<Entry> GetEntry(VAddr address) const; | ||
| 58 | |||
| 59 | // Returns all the entries in the freezer, an empty vector means nothing is frozen. | ||
| 60 | std::vector<Entry> GetEntries() const; | ||
| 61 | |||
| 62 | private: | ||
| 63 | void FrameCallback(u64 userdata, s64 cycles_late); | ||
| 64 | void FillEntryReads(); | ||
| 65 | |||
| 66 | std::atomic_bool active{false}; | ||
| 67 | |||
| 68 | mutable std::mutex entries_mutex; | ||
| 69 | std::vector<Entry> entries; | ||
| 70 | |||
| 71 | Core::Timing::EventType* event; | ||
| 72 | Core::Timing::CoreTiming& core_timing; | ||
| 73 | }; | ||
| 74 | |||
| 75 | } // namespace Tools | ||