Exp: Base system for the real time systems lecture
Change-Id: I3e5b8c6e60b57e6ec03500e9ee109fd5fb322cb2
This commit is contained in:
committed by
Gerrit Code Review
parent
4c7fcae6ad
commit
8f0db45dfe
20
src/experiments/ezs-logger/CMakeLists.txt
Normal file
20
src/experiments/ezs-logger/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
set(EXPERIMENT_NAME ezs-logger)
|
||||||
|
set(EXPERIMENT_TYPE EZSLogger)
|
||||||
|
configure_file(../instantiate-experiment.ah.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/instantiate-${EXPERIMENT_NAME}.ah @ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
## Setup desired protobuf descriptions HERE ##
|
||||||
|
set(MY_PROTOS
|
||||||
|
)
|
||||||
|
|
||||||
|
set(MY_CAMPAIGN_SRCS
|
||||||
|
experiment.hpp
|
||||||
|
experiment.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
## Build library
|
||||||
|
add_library(fail-${EXPERIMENT_NAME} ${MY_CAMPAIGN_SRCS})
|
||||||
|
add_dependencies(fail-${EXPERIMENT_NAME} fail-comm)
|
||||||
|
target_link_libraries(fail-${EXPERIMENT_NAME})
|
||||||
|
|
||||||
99
src/experiments/ezs-logger/experiment.cc
Normal file
99
src/experiments/ezs-logger/experiment.cc
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "experiment.hpp"
|
||||||
|
#include "sal/SALConfig.hpp"
|
||||||
|
#include "sal/SALInst.hpp"
|
||||||
|
#include "sal/Memory.hpp"
|
||||||
|
#include "sal/Listener.hpp"
|
||||||
|
|
||||||
|
#include "sal/bochs/BochsListener.hpp"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "../plugins/realtimelogger/RealtimeLogger.hpp"
|
||||||
|
#include "../plugins/signalgenerator/SignalGenerator.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace fail;
|
||||||
|
|
||||||
|
// Check if configuration dependencies are satisfied:
|
||||||
|
#if !defined(CONFIG_EVENT_MEMREAD) || !defined(CONFIG_EVENT_MEMWRITE)
|
||||||
|
#error This experiment needs: MemRead and MemWrite. Enable these in the configuration.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void EZSLogger::setupLog(const ElfSymbol & target, const string& prefix)
|
||||||
|
{
|
||||||
|
|
||||||
|
if( target.getAddress() == 0 ){
|
||||||
|
m_log << target << " Memory address not found. " << std::endl;
|
||||||
|
simulator.terminate(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *u = getenv("USER");
|
||||||
|
if (u == NULL){
|
||||||
|
m_log << "Username not found :(" << std::endl;
|
||||||
|
simulator.terminate(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set output path to /tmp/'prefix'-<USERNAME>.dac */
|
||||||
|
std::string outputfile = "/tmp/" + prefix + "-" + std::string(u) + ".txt";
|
||||||
|
|
||||||
|
// TODO delete rl. object sometimes?
|
||||||
|
RealtimeLogger *rl = new RealtimeLogger(target, outputfile);
|
||||||
|
|
||||||
|
simulator.addFlow(rl);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EZSLogger::run()
|
||||||
|
{
|
||||||
|
m_log << "STARTING EZS Logger" << endl;
|
||||||
|
|
||||||
|
ElfReader m_elf;
|
||||||
|
|
||||||
|
// Invalidate Hpet by setting COUNTER_CLK_PERIOD > 0x05f5E100
|
||||||
|
// Segfaults...
|
||||||
|
// MemoryManager &mm = simulator.getMemoryManager();
|
||||||
|
// uint64_t hpet_cap_reg = 0xffffffff00000000ULL;
|
||||||
|
// mm.setBytes(0xFED00000, sizeof(hpet_cap_reg), &hpet_cap_reg);
|
||||||
|
|
||||||
|
//! Setup RealtimeLogger instances:
|
||||||
|
setupLog(m_elf.getSymbol("ezs_tracer_register"), "ezs-trace");
|
||||||
|
setupLog(m_elf.getSymbol("ezs_dac_out_register"), "ezs-dac");
|
||||||
|
|
||||||
|
//! Setup Superimposed sine waves: @see Sine::SineParams_t
|
||||||
|
Sine::SineParamsList_t plist;
|
||||||
|
plist.push_back(Sine::SineParams_t(2,0.7));
|
||||||
|
plist.push_back(Sine::SineParams_t(10,0.3));
|
||||||
|
//! Initialize and install signal generator @see SignalGenerator
|
||||||
|
const ElfSymbol & s_adc = m_elf.getSymbol("ezs_adc_in_register");
|
||||||
|
SignalGenerator siggen(s_adc, new Sine(plist));
|
||||||
|
simulator.addFlow(&siggen);
|
||||||
|
|
||||||
|
|
||||||
|
//! Let the SUT know, we are in Bochs.
|
||||||
|
const ElfSymbol & s_bochsid = m_elf.getSymbol("FAILBOCHSID");
|
||||||
|
m_log << "FAILBOCHSID @ " << s_bochsid << std::endl;
|
||||||
|
|
||||||
|
MemAccessListener l_bochsid(s_bochsid);
|
||||||
|
MemoryManager & mm = simulator.getMemoryManager();
|
||||||
|
uint32_t bochsid = 42;
|
||||||
|
|
||||||
|
//! Simulate forever.
|
||||||
|
while(true) {
|
||||||
|
if(s_bochsid.getAddress() != 0){
|
||||||
|
simulator.addListenerAndResume(&l_bochsid);
|
||||||
|
mm.setBytes(s_bochsid.getAddress(), sizeof(bochsid), &bochsid);
|
||||||
|
} else {
|
||||||
|
simulator.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Explicitly terminate, or the simulator will continue to run.
|
||||||
|
simulator.terminate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
38
src/experiments/ezs-logger/experiment.hpp
Normal file
38
src/experiments/ezs-logger/experiment.hpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef __EZS_LOGGER_EXPERIMENT_HPP__
|
||||||
|
#define __EZS_LOGGER_EXPERIMENT_HPP__
|
||||||
|
|
||||||
|
|
||||||
|
#include "sal/SALInst.hpp"
|
||||||
|
#include "efw/ExperimentFlow.hpp"
|
||||||
|
#include "util/Logger.hpp"
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include "util/ElfReader.hpp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief Base system for EZS realtime lecture
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class
|
||||||
|
* @brief Experiment implementation
|
||||||
|
*/
|
||||||
|
class EZSLogger : public fail::ExperimentFlow {
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
|
fail::Logger m_log; //! debug output
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Tiniy little helper to setup a RealtimeLogger instance
|
||||||
|
*/
|
||||||
|
void setupLog(const fail::ElfSymbol & target, const std::string& prefix);
|
||||||
|
|
||||||
|
public:
|
||||||
|
EZSLogger() : m_log("EZSLogger", false) {}
|
||||||
|
|
||||||
|
bool run();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user