mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Ensures randomised memory contents at startup.
This commit is contained in:
parent
535747e3f2
commit
5630141ad7
@ -33,6 +33,7 @@
|
|||||||
#include "../../../Analyser/Static/Macintosh/Target.hpp"
|
#include "../../../Analyser/Static/Macintosh/Target.hpp"
|
||||||
|
|
||||||
#include "../../Utility/MemoryPacker.hpp"
|
#include "../../Utility/MemoryPacker.hpp"
|
||||||
|
#include "../../Utility/MemoryFuzzer.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -100,6 +101,9 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
|||||||
roms[0]->resize(rom_size);
|
roms[0]->resize(rom_size);
|
||||||
Memory::PackBigEndian16(*roms[0], rom_);
|
Memory::PackBigEndian16(*roms[0], rom_);
|
||||||
|
|
||||||
|
// Randomise memory contents.
|
||||||
|
Memory::Fuzz(ram_, sizeof(ram_));
|
||||||
|
|
||||||
// Attach the drives to the IWM.
|
// Attach the drives to the IWM.
|
||||||
iwm_.iwm.set_drive(0, &drives_[0]);
|
iwm_.iwm.set_drive(0, &drives_[0]);
|
||||||
iwm_.iwm.set_drive(1, &drives_[1]);
|
iwm_.iwm.set_drive(1, &drives_[1]);
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#ifndef RealTimeClock_hpp
|
#ifndef RealTimeClock_hpp
|
||||||
#define RealTimeClock_hpp
|
#define RealTimeClock_hpp
|
||||||
|
|
||||||
|
#include "../../Utility/MemoryFuzzer.hpp"
|
||||||
|
|
||||||
namespace Apple {
|
namespace Apple {
|
||||||
namespace Macintosh {
|
namespace Macintosh {
|
||||||
|
|
||||||
@ -21,6 +23,12 @@ namespace Macintosh {
|
|||||||
*/
|
*/
|
||||||
class RealTimeClock {
|
class RealTimeClock {
|
||||||
public:
|
public:
|
||||||
|
RealTimeClock() {
|
||||||
|
// TODO: this should persist, if possible, rather than
|
||||||
|
// being randomly initialised.
|
||||||
|
Memory::Fuzz(data_, sizeof(data_));
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Advances the clock by 1 second.
|
Advances the clock by 1 second.
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ void Memory::Fuzz(uint8_t *buffer, std::size_t size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Memory::Fuzz(uint16_t *buffer, std::size_t size) {
|
||||||
|
Fuzz(reinterpret_cast<uint8_t *>(buffer), size * sizeof(uint16_t));
|
||||||
|
}
|
||||||
|
|
||||||
void Memory::Fuzz(std::vector<uint8_t> &buffer) {
|
void Memory::Fuzz(std::vector<uint8_t> &buffer) {
|
||||||
Fuzz(buffer.data(), buffer.size());
|
Fuzz(buffer.data(), buffer.size());
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ namespace Memory {
|
|||||||
/// Stores @c size random bytes from @c buffer onwards.
|
/// Stores @c size random bytes from @c buffer onwards.
|
||||||
void Fuzz(uint8_t *buffer, std::size_t size);
|
void Fuzz(uint8_t *buffer, std::size_t size);
|
||||||
|
|
||||||
|
/// Stores @c size random 16-bit words from @c buffer onwards.
|
||||||
|
void Fuzz(uint16_t *buffer, std::size_t size);
|
||||||
|
|
||||||
/// Replaces all existing vector contents with random bytes.
|
/// Replaces all existing vector contents with random bytes.
|
||||||
void Fuzz(std::vector<uint8_t> &buffer);
|
void Fuzz(std::vector<uint8_t> &buffer);
|
||||||
|
|
||||||
|
@ -3132,6 +3132,7 @@
|
|||||||
4B9378E222A199C600973513 /* Audio.cpp */,
|
4B9378E222A199C600973513 /* Audio.cpp */,
|
||||||
4BB4BFAC22A33DE50069048D /* DriveSpeedAccumulator.cpp */,
|
4BB4BFAC22A33DE50069048D /* DriveSpeedAccumulator.cpp */,
|
||||||
4BCE0058227CFFCA000CA200 /* Macintosh.cpp */,
|
4BCE0058227CFFCA000CA200 /* Macintosh.cpp */,
|
||||||
|
4B0C956F22A74E880015A8F6 /* SonyDrive.cpp */,
|
||||||
4BCE005E227D39AB000CA200 /* Video.cpp */,
|
4BCE005E227D39AB000CA200 /* Video.cpp */,
|
||||||
4B9378E322A199C600973513 /* Audio.hpp */,
|
4B9378E322A199C600973513 /* Audio.hpp */,
|
||||||
4BB4BFAA22A300710069048D /* DeferredAudio.hpp */,
|
4BB4BFAA22A300710069048D /* DeferredAudio.hpp */,
|
||||||
@ -3139,9 +3140,8 @@
|
|||||||
4BDB3D8522833321002D3CEE /* Keyboard.hpp */,
|
4BDB3D8522833321002D3CEE /* Keyboard.hpp */,
|
||||||
4BCE0059227CFFCA000CA200 /* Macintosh.hpp */,
|
4BCE0059227CFFCA000CA200 /* Macintosh.hpp */,
|
||||||
4BD0692B22828A2D00D2A54F /* RealTimeClock.hpp */,
|
4BD0692B22828A2D00D2A54F /* RealTimeClock.hpp */,
|
||||||
4BCE005F227D39AB000CA200 /* Video.hpp */,
|
|
||||||
4B0C956F22A74E880015A8F6 /* SonyDrive.cpp */,
|
|
||||||
4B0C957022A74E880015A8F6 /* SonyDrive.hpp */,
|
4B0C957022A74E880015A8F6 /* SonyDrive.hpp */,
|
||||||
|
4BCE005F227D39AB000CA200 /* Video.hpp */,
|
||||||
);
|
);
|
||||||
path = Macintosh;
|
path = Macintosh;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
Loading…
Reference in New Issue
Block a user