Commit 4e5012c9 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

	* src/vm/memory.hh, src/vm/mmu.hh, src/vm/cpu.cc,
	* src/vm/virtual_machine.cc:
	Implement reset() method.
	* src/vm/virtual_machine.hh, src/vm/virtual_machine.hh:
	Keep and reload the main offset of loaded program.
parent 7691c8d0
2004-07-14 Benot Perrot <benoit@lrde.epita.fr>
* src/vm/memory.hh, src/vm/mmu.hh, src/vm/cpu.cc,
* src/vm/virtual_machine.cc:
Implement reset() method.
* src/vm/virtual_machine.hh, src/vm/virtual_machine.hh:
Keep and reload the main offset of loaded program.
2004-07-14 Benot Perrot <benoit@lrde.epita.fr>
* src/vm/virtual_machine.hh: Move the implementation of
......
......@@ -69,6 +69,7 @@ namespace vm
// Initialize special registers to 0.
lo_ = 0;
hi_ = 0;
pc_ = 0;
// Initialize pipeline with nops
for (unsigned i = 0; i < 6; ++i)
......
......@@ -53,6 +53,12 @@ namespace vm
}
/** \} */
/// Reset the memory
void reset()
{
// DO NOT zero-ify the memory
}
protected:
int translate(int offset) const
{
......
......@@ -40,6 +40,12 @@ namespace vm
{}
/** \} */
/// Reset the mmu
void reset()
{
// Nothing to do?
}
/** \name Proxy for memory data access.
\{ */
public:
......
......@@ -24,27 +24,37 @@ namespace vm
void
VirtualMachine::reset()
{
memory_.reset();
mmu_.reset();
cp0_.reset();
cpu_.reset();
}
void
VirtualMachine::load_program(const inst::Program &program)
{
reset();
if (! program.text_section ().has_label(inst::Label("main")))
{
std::cerr << "No `main' label in assembly file." << std::endl;
exit_set(exit_runtime);
return;
}
main_offset_ = program.text_section().get_offset(inst::Label("main"));
mmu_.data_store(program.data_section());
mmu_.inst_store(program.text_section());
cpu_.set_pc(program.text_section ().get_offset(inst::Label("main")));
}
void
VirtualMachine::execute()
{
// FIXME: precondition on loaded program
// FIXME: VirtualMachine::reset()?
cp0_.reset();
cpu_.reset();
// FIXME: precondition on loaded program
cpu_.set_pc(main_offset_);
while (!cpu_.get_halt())
{
cpu_.step();
......@@ -55,9 +65,14 @@ namespace vm
void
VirtualMachine::execute(bool trace_p)
{
// FIXME: VirtualMachine::reset()?
cp0_.reset();
cpu_.reset();
if (status_ == stop)
return;
cpu_.set_pc(main_offset_);
cpu_.set_trace(trace_p);
while (status_ == run)
{
......
......@@ -86,6 +86,8 @@ namespace vm
public:
/// Load a program into memory.
void load_program(const inst::Program& program);
protected:
int main_offset_; // FIXME: Must disappear!
public:
/// Execute a program.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment