openMSX
CheckedRam.hh
Go to the documentation of this file.
1#ifndef CHECKEDRAM_HH
2#define CHECKEDRAM_HH
3
4#include "Ram.hh"
5#include "TclCallback.hh"
6#include "CacheLine.hh"
7#include "Observer.hh"
8#include "openmsx.hh"
9#include <vector>
10#include <bitset>
11
12namespace openmsx {
13
14class DeviceConfig;
15class MSXCPU;
16class Setting;
17
27class CheckedRam final : private Observer<Setting>
28{
29public:
30 CheckedRam(const DeviceConfig& config, const std::string& name,
31 static_string_view description, size_t size);
33
34 [[nodiscard]] byte read(size_t addr);
35 [[nodiscard]] byte peek(size_t addr) const { return ram[addr]; }
36 void write(size_t addr, byte value);
37
38 [[nodiscard]] const byte* getReadCacheLine(size_t addr) const;
39 [[nodiscard]] byte* getWriteCacheLine(size_t addr);
40 [[nodiscard]] byte* getRWCacheLines(size_t addr, size_t size);
41
42 [[nodiscard]] size_t size() const { return ram.size(); }
43 void clear();
44
51 [[nodiscard]] Ram& getUncheckedRam() { return ram; }
52
53 // TODO
54 //template<typename Archive>
55 //void serialize(Archive& ar, unsigned version);
56
57private:
58 void init();
59
60 // Observer<Setting>
61 void update(const Setting& setting) noexcept override;
62
63private:
64 std::vector<bool> completely_initialized_cacheline;
65 std::vector<std::bitset<CacheLine::SIZE>> uninitialized;
66 Ram ram;
67 MSXCPU& msxcpu;
68 TclCallback umrCallback;
69};
70
71} // namespace openmsx
72
73#endif
BaseSetting * setting
This class keeps track of which bytes in the Ram have been written to.
Definition CheckedRam.hh:28
byte * getWriteCacheLine(size_t addr)
Definition CheckedRam.cc:45
Ram & getUncheckedRam()
Give access to the unchecked Ram.
Definition CheckedRam.hh:51
size_t size() const
Definition CheckedRam.hh:42
void write(size_t addr, byte value)
Definition CheckedRam.cc:64
byte peek(size_t addr) const
Definition CheckedRam.hh:35
const byte * getReadCacheLine(size_t addr) const
Definition CheckedRam.cc:39
byte * getRWCacheLines(size_t addr, size_t size)
Definition CheckedRam.cc:51
byte read(size_t addr)
Definition CheckedRam.cc:28
Generic Gang-of-Four Observer class, templatized edition.
Definition Observer.hh:10
auto size() const
Definition Ram.hh:44
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11