virtual_machine.hxx 2.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2006 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nolimips is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef VM_VIRTUAL_MACHINE_HXX
# define VM_VIRTUAL_MACHINE_HXX

# include "misc/contract.hh"
# include "misc/has.hh"

namespace inst { class Program; }

namespace vm
{

  //
  inline
  VirtualMachine::VirtualMachine(mode_type mode):
    mode_(mode),
    status_(stop),
    mmu_(cp0_, memory_),
36
    cp0_(cpu_),
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
    cpu_(mmu_, cp0_)
  {
  }

  //
  inline void
  VirtualMachine::write(std::ostream& ostr) const
  {
    // FIXME: print the whole cpu, and cp0.
    ostr << cpu_;
  }

  //
  inline const std::vector<register_type> &
  VirtualMachine::get_call_stack() const
  {
    return cpu_.get_call_stack();
  }

  //
  inline void
  VirtualMachine::set_runnable()
  {
    status_ = run;
    mode_ = normal;
  }

  inline void
  VirtualMachine::set_run_next()
  {
    status_ = run;
    mode_ = step;
  }

  inline VirtualMachine::status_type
  VirtualMachine::get_status() const
  {
    return status_;
  }

  //
  inline const Cp0 &
  VirtualMachine::get_cp0() const
  {
    return cp0_;
  }
83
84
85
86
87
  inline Cp0 &
  VirtualMachine::get_cp0()
  {
    return cp0_;
  }
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

  inline const Cpu &
  VirtualMachine::get_cpu() const
  {
    return cpu_;
  }
  inline Cpu &
  VirtualMachine::get_cpu()
  {
    return cpu_;
  }

  //
  inline std::ostream&
  operator<<(std::ostream &os, const VirtualMachine &vm)
  {
    vm.write(os);
    return os;
  }

} // namespace vm

#endif // !VM_VIRTUAL_MACHINE_HH