2014-10-18 11:33:48 +00:00
|
|
|
/*
|
|
|
|
* cpu.h
|
|
|
|
*/
|
|
|
|
#ifndef _CPU_H
|
|
|
|
#define _CPU_H
|
|
|
|
|
|
|
|
#ifndef _SETJMP_H
|
|
|
|
#include <setjmp.h>
|
|
|
|
#endif
|
|
|
|
|
2014-10-21 18:41:44 +00:00
|
|
|
class CPU: public Checkpointable {
|
2014-10-18 11:33:48 +00:00
|
|
|
public:
|
|
|
|
virtual void reset () =0;
|
|
|
|
virtual Memory::address run (unsigned instructions) =0;
|
|
|
|
virtual void raise (int level) =0;
|
|
|
|
virtual char *status () =0;
|
|
|
|
|
|
|
|
typedef void (*statfn) (const char *, ...);
|
|
|
|
|
2014-10-21 18:41:44 +00:00
|
|
|
virtual void checkpoint(Stream &s) = 0;
|
|
|
|
virtual void restore(Stream &s) = 0;
|
|
|
|
|
2014-10-31 08:18:15 +00:00
|
|
|
void debug() { _debug = !_debug; }
|
|
|
|
|
2014-10-18 11:33:48 +00:00
|
|
|
protected:
|
|
|
|
CPU (Memory *m, jmp_buf *e, statfn s): _memory(m), _err(e), _status(s){}
|
|
|
|
Memory *_memory;
|
|
|
|
jmp_buf *_err;
|
|
|
|
statfn _status;
|
2014-10-31 08:18:15 +00:00
|
|
|
bool _debug;
|
2014-10-18 11:33:48 +00:00
|
|
|
};
|
|
|
|
#endif
|