32 : ram(config_, name, description, size)
37 const DeviceConfig& config_,
const char* header_,
bool* loaded)
38 : schedulable(
std::in_place, config_.getReactor().getRTScheduler(), *this)
40 , ram(config, name,
"sram", size)
47 const DeviceConfig& config_,
const char* header_,
bool* loaded)
48 : schedulable(
std::in_place, config_.getReactor().getRTScheduler(), *this)
50 , ram(config, name, description, size)
58 if (schedulable && schedulable->isPendingRT()) {
59 schedulable->cancelRT();
66 if (schedulable && !schedulable->isPendingRT()) {
67 schedulable->scheduleRT(5000000);
69 assert(addr <
size());
70 ram.
write(addr, value);
75 if (schedulable && !schedulable->isPendingRT()) {
76 schedulable->scheduleRT(5000000);
78 assert((addr + aSize) <=
size());
82void SRAM::load(
bool* loaded)
85 if (loaded) *loaded =
false;
92 size_t length = strlen(header);
93 VLA(
char, buf, length);
99 if (loaded) *loaded =
true;
102 "Warning no correct SRAM file: ", filename);
104 }
catch (FileNotFoundException& ) {
106 }
catch (FileException& e) {
108 "Couldn't load SRAM ", filename,
109 " (",
e.getMessage(),
").");
113void SRAM::save()
const
121 auto length = strlen(header);
122 file.write(std::span{header,
length});
125 file.write(std::span{ram.
begin(), ram.
end()});
126 }
catch (FileException& e) {
128 "Couldn't save SRAM ", filename,
129 " (",
e.getMessage(),
").");
133void SRAM::SRAMSchedulable::executeRT()
138template<
typename Archive>
141 ar.serialize(
"ram", ram);
void printWarning(std::string_view message)
MSXCliComm & getCliComm() const
const FileContext & getFileContext() const
std::string_view getChildData(std::string_view name) const
const XMLElement * getXML() const
std::string resolveCreate(std::string_view filename) const
SRAM(size_t size, const XMLElement &xml, DontLoadTag)
void write(size_t addr, byte value)
void serialize(Archive &ar, unsigned version)
void memset(size_t addr, byte c, size_t size)
void write(size_t addr, byte value)
std::span< byte > getWriteBackdoor()
T length(const vecN< N, T > &x)
This file implemented 3 utility functions:
constexpr void fill(ForwardRange &&range, const T &value)
constexpr bool equal(InputRange1 &&range1, InputRange2 &&range2, Pred pred={}, Proj1 proj1={}, Proj2 proj2={})
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
#define VLA(TYPE, NAME, LENGTH)