RAMpage FI experiment, WIP

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1621 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
hsc
2012-09-12 14:14:05 +00:00
parent b327b49a4e
commit 095adbc7e5
7 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,98 @@
#include <iostream>
// getpid
#include <sys/types.h>
#include <unistd.h>
#include "util/Logger.hpp"
#include "experiment.hpp"
#include "campaign.hpp"
#include "sal/SALConfig.hpp"
#include "sal/SALInst.hpp"
#include "sal/Memory.hpp"
#include "sal/Listener.hpp"
#define LOCAL 1
using namespace std;
using namespace fail;
/*
// Check if configuration dependencies are satisfied:
#if !defined(CONFIG_EVENT_BREAKPOINTS) || !defined(CONFIG_SR_RESTORE) || \
!defined(CONFIG_SR_SAVE) || !defined(CONFIG_EVENT_TRAP)
#error This experiment needs: breakpoints, traps, save, and restore. Enable these in the configuration.
#endif
*/
bool RAMpageExperiment::run()
{
Logger log("RAMpage", false);
address_t addr1 = 1024*1024*62+3;
int bit1 = 3;
address_t addr2 = 1024*1024*63+8;
int bit2 = 5;
// not implemented yet for QEMU:
//simulator.restore("rampage-cext-started");
// TODO: Timeout
// TODO: Serial
MemWriteListener l_mem1(addr1);
MemoryManager& mm = simulator.getMemoryManager();
while (true) {
simulator.addListener(&l_mem1);
simulator.resume();
unsigned char data = mm.getByte(addr1);
#if 1
//data |= 1 << bit1; // stuck-to-1
mm.setByte(addr1, data);
#elif 0
data &= ~(1 << bit1); // stuck-to-0
mm.setByte(addr1, data);
#elif 0
data &= ~(1 << bit2); // coupling bit2 := bit1
data |= ((data & (1 << bit1)) != 0) << bit2;
mm.setByte(addr1, data);
#elif 0
data &= ~(1 << bit2); // coupling bit2 := !bit1
data |= ((data & (1 << bit1)) == 0) << bit2;
mm.setByte(addr1, data);
#elif 0
unsigned char data2 = mm.getByte(addr2);
data2 &= ~(1 << bit2); // coupling addr2:bit2 := !addr1:bit1
data2 |= ((data & (1 << bit1)) == 0) << bit2;
mm.setByte(addr2, data2);
#endif
log << "access to addr 0x" << std::hex << addr1 << ", FI!" << endl;
}
/*
MemWriteListener l_mem2(addr2);
log << "startup" << endl;
simulator.addListener(&l_mem1);
simulator.addListener(&l_mem2);
while (true) {
MemWriteListener *l = static_cast<MemWriteListener*>(simulator.resume());
simulator.addListener(l);
address_t target;
if (l == &l_mem1) {
target = addr2;
} else {
target = addr1;
}
unsigned char data = simulator.getMemoryManager().getByte(l->getWatchAddress());
data ^= (
}
*/
return true;
}