33 : ram(config_, name, description, size)
39 const DeviceConfig& config_,
const char* header_,
bool* loaded)
40 : schedulable(
std::in_place, config_.getReactor().getRTScheduler(), *this)
42 , ram(config, name,
"sram", size)
49 const DeviceConfig& config_,
const char* header_,
bool* loaded)
50 : schedulable(
std::in_place, config_.getReactor().getRTScheduler(), *this)
52 , ram(config, name, description, size)
67 if (schedulable && !schedulable->isPendingRT()) {
68 schedulable->scheduleRT(5000000);
70 assert(addr <
size());
71 ram.
write(addr, value);
76 if (schedulable && !schedulable->isPendingRT()) {
77 schedulable->scheduleRT(5000000);
79 assert((addr + aSize) <=
size());
83void SRAM::load(
bool* loaded)
86 if (loaded) *loaded =
false;
93 size_t length = strlen(header);
94 VLA(
char, buf, length);
100 loadedFilename = file.getURL();
101 if (loaded) *loaded =
true;
104 "Warning no correct SRAM file: ", filename);
106 }
catch (FileNotFoundException& ) {
108 "SRAM file ", filename,
" not found, "
109 "assuming blank SRAM content.");
110 }
catch (FileException& e) {
112 "Couldn't load SRAM ", filename,
113 " (",
e.getMessage(),
").");
117void SRAM::save()
const
125 auto length = strlen(header);
126 file.write(std::span{header,
length});
129 file.write(std::span{ram.
begin(), ram.
end()});
130 }
catch (FileException& e) {
132 "Couldn't save SRAM ", filename,
133 " (",
e.getMessage(),
").");
137void SRAM::SRAMSchedulable::executeRT()
142template<
typename Archive>
145 ar.serialize(
"ram", ram);
void printInfo(std::string_view message)
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)
bool equal(InputRange1 &&range1, InputRange2 &&range2, Pred pred={}, Proj1 proj1={}, Proj2 proj2={})
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
#define VLA(TYPE, NAME, LENGTH)