00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <iostream>
00027 #include <cstdlib>
00028 #include "specialmem.h"
00029 #include "avrerror.h"
00030
00031 using namespace std;
00032
00033 RWWriteToFile::RWWriteToFile(TraceValueRegister *registry,
00034 const string &tracename,
00035 const string &filename):
00036 RWMemoryMember(registry, tracename),
00037 os(filename=="-" ? cout : ofs)
00038 {
00039 if(filename != "-")
00040 ofs.open(filename.c_str());
00041 }
00042
00043 void RWWriteToFile::set(unsigned char val) {
00044 os << val;
00045 os.flush();
00046 }
00047
00048 unsigned char RWWriteToFile::get() const {
00049 cerr << "Invalid read access to RWWriteToFile register." << endl;
00050 return 0;
00051 }
00052
00053 RWReadFromFile::RWReadFromFile(TraceValueRegister *registry,
00054 const string &tracename,
00055 const string &filename):
00056 RWMemoryMember(registry, tracename),
00057 is((filename=="-") ? cin : ifs)
00058 {
00059 if(filename != "-")
00060 ifs.open(filename.c_str());
00061 }
00062
00063 void RWReadFromFile::set(unsigned char val) {
00064 cerr << "Invalid write access to RWWriteToFile register with value " << val << "." << endl;
00065 }
00066
00067 unsigned char RWReadFromFile::get() const {
00068 char val;
00069 is.get(val);
00070 return val;
00071 }
00072
00073
00074 RWExit::RWExit(TraceValueRegister *registry,
00075 const std::string &tracename) :
00076 RWMemoryMember(registry, tracename) {}
00077
00078
00079 void RWExit::set(unsigned char c) {
00080 cerr << "Exiting at simulated program request" << endl;
00081 sysConHandler.ExitApplication(c);
00082 }
00083
00084 unsigned char RWExit::get() const {
00085 cerr << "Exiting at simulated program request" << endl;
00086 sysConHandler.ExitApplication(0);
00087 return 0;
00088 }
00089
00090 RWAbort::RWAbort(TraceValueRegister *registry,
00091 const std::string &tracename) :
00092 RWMemoryMember(registry, tracename) {}
00093
00094 void RWAbort::set(unsigned char c) {
00095 cerr << "Aborting at simulated program request" << endl;
00096 sysConHandler.AbortApplication(c);
00097 }
00098
00099 unsigned char RWAbort::get() const {
00100 cerr << "Aborting at simulated program request" << endl;
00101 sysConHandler.AbortApplication(0);
00102 return 0;
00103 }
00104