Commit 5ce2b34b authored by Benoit Perrot's avatar Benoit Perrot
Browse files

2006-01-08 Benoît Perrot <benoit@lrde.epita.fr>

	Control coprocessor has the system library

	* src/vm/cp0.hh, src/vm/cp0.hxx:
	(set_system_library) New.
	(raise_syscall) Invoke system library if any.
	* src/vm/cpu.hh, src/vm/cpu.hxx:
	(set_system_library) Remove.
	* src/vm/cpu.cc:
	(syscall) Raise a syscall exception through cp0.
	* src/vm/virtual_machine.hh, src/vm/virtual_machine.hxx:
	(get_cp0) New non-const accessor.
	(set_system_library) Remove.
	* src/vm-tasks.cc:
	Access cp0 to set system library.
parent ccb4add9
2006-01-08 Benot Perrot <benoit@lrde.epita.fr>
Control coprocessor has the system library
* src/vm/cp0.hh, src/vm/cp0.hxx:
(set_system_library) New.
(raise_syscall) Invoke system library if any.
* src/vm/cpu.hh, src/vm/cpu.hxx:
(set_system_library) Remove.
* src/vm/cpu.cc:
(syscall) Raise a syscall exception through cp0.
* src/vm/virtual_machine.hh, src/vm/virtual_machine.hxx:
(get_cp0) New non-const accessor.
(set_system_library) Remove.
* src/vm-tasks.cc:
Access cp0 to set system library.
2006-01-08 Benot Perrot <benoit@lrde.epita.fr> 2006-01-08 Benot Perrot <benoit@lrde.epita.fr>
Do not call exit_set inside control coprocessor Do not call exit_set inside control coprocessor
......
...@@ -72,7 +72,7 @@ namespace vm ...@@ -72,7 +72,7 @@ namespace vm
vm::VirtualMachine vm; vm::VirtualMachine vm;
vm.get_cpu().set_check_callee_save(check_callee_save_p); vm.get_cpu().set_check_callee_save(check_callee_save_p);
vm.get_cpu().set_trace(trace_exec_p); vm.get_cpu().set_trace(trace_exec_p);
vm.set_system_library(system_library); vm.get_cp0().set_system_library(system_library);
vm.load_program(* parse::tasks::program); vm.load_program(* parse::tasks::program);
if (exit_status != exit_success) if (exit_status != exit_success)
exit(exit_status); exit(exit_status);
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#ifndef VM_CP0_HH #ifndef VM_CP0_HH
# define VM_CP0_HH # define VM_CP0_HH
# include "vm/fwd.hh"
namespace inst { class Register; } namespace inst { class Register; }
namespace vm namespace vm
...@@ -94,13 +96,14 @@ namespace vm ...@@ -94,13 +96,14 @@ namespace vm
/** \name Constructor and destructor /** \name Constructor and destructor
\{ */ \{ */
public: public:
Cp0(); Cp0(Cpu &cpu);
/** \} */ /** \} */
public: public:
/// Reset the CPU (set registers to zero) /// Reset the CPU (set registers to zero)
void reset(); void reset();
void set_system_library(SystemLibrary *l);
/** \name Explicit register accessors /** \name Explicit register accessors
\{ */ \{ */
...@@ -132,16 +135,22 @@ namespace vm ...@@ -132,16 +135,22 @@ namespace vm
/// Raise an address error on load exception /// Raise an address error on load exception
void raise_addr_store(); void raise_addr_store();
void raise_syscall();
void set_fatal_exception(); void set_fatal_exception();
bool fatal_exception() const; bool fatal_exception() const;
/** \} */ /** \} */
protected: protected:
Cpu &cpu_;
bool fatal_exception_; bool fatal_exception_;
/// Dedicated registers (32 bits) /// Dedicated registers (32 bits)
register_type registers[32]; register_type registers[32];
SystemLibrary *system_library_;
}; };
} // namespace vm } // namespace vm
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
# define VM_CP0_HXX # define VM_CP0_HXX
# include "vm/cp0.hh" # include "vm/cp0.hh"
# include "vm/system_library.hh"
# include "inst/register.hh" # include "inst/register.hh"
...@@ -30,7 +31,9 @@ namespace vm ...@@ -30,7 +31,9 @@ namespace vm
// //
inline inline
Cp0::Cp0() Cp0::Cp0(Cpu &cpu):
cpu_(cpu),
system_library_(0)
{ {
reset(); reset();
} }
...@@ -45,6 +48,12 @@ namespace vm ...@@ -45,6 +48,12 @@ namespace vm
fatal_exception_ = false; fatal_exception_ = false;
} }
inline void
Cp0::set_system_library(SystemLibrary *l)
{
system_library_ = l;
}
// //
inline void inline void
Cp0::set_count(Cp0::register_type r) Cp0::set_count(Cp0::register_type r)
...@@ -99,6 +108,13 @@ namespace vm ...@@ -99,6 +108,13 @@ namespace vm
fatal_exception_ = true; fatal_exception_ = true;
} }
inline void
Cp0::raise_syscall()
{
precondition(system_library_);
system_library_->invoke(cpu_);
}
// //
inline void inline void
Cp0::set_fatal_exception() Cp0::set_fatal_exception()
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "vm/cpu.hh" #include "vm/cpu.hh"
#include "vm/cp0.hh" #include "vm/cp0.hh"
#include "vm/system_library.hh"
#include "inst/all.hh" #include "inst/all.hh"
#include "inst/int_exp.hh" #include "inst/int_exp.hh"
...@@ -33,7 +32,6 @@ namespace vm ...@@ -33,7 +32,6 @@ namespace vm
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
Cpu::Cpu(Mmu &mmu, Cp0 &cp0): Cpu::Cpu(Mmu &mmu, Cp0 &cp0):
mmu_(mmu), cp0_(cp0), mmu_(mmu), cp0_(cp0),
system_library_(0),
check_callee_save_p_(false), check_callee_save_p_(false),
trace_p_(false), trace_p_(false),
bubble_(new inst::Sll(inst::Register(inst::Register::general, Cpu::zero), bubble_(new inst::Sll(inst::Register(inst::Register::general, Cpu::zero),
...@@ -684,8 +682,7 @@ namespace vm ...@@ -684,8 +682,7 @@ namespace vm
void void
Cpu::visit(const inst::Syscall&) Cpu::visit(const inst::Syscall&)
{ {
precondition(system_library_); cp0_.raise_syscall();
system_library_->invoke(*this);
} }
} // namespace vm } // namespace vm
...@@ -128,8 +128,6 @@ namespace vm ...@@ -128,8 +128,6 @@ namespace vm
Cp0 &get_cp0(); Cp0 &get_cp0();
public: public:
void set_system_library(SystemLibrary *l);
unsigned get_instruction_counter(inst::Inst::format_type format) const; unsigned get_instruction_counter(inst::Inst::format_type format) const;
const std::vector<register_type> &get_call_stack() const; const std::vector<register_type> &get_call_stack() const;
...@@ -224,8 +222,6 @@ namespace vm ...@@ -224,8 +222,6 @@ namespace vm
/// Special Program Counter. /// Special Program Counter.
register_type pc_; register_type pc_;
SystemLibrary *system_library_;
/// Unlimited registers. /// Unlimited registers.
misc::Table<int, register_type> unlimited_; misc::Table<int, register_type> unlimited_;
......
...@@ -141,12 +141,6 @@ namespace vm ...@@ -141,12 +141,6 @@ namespace vm
return cp0_; return cp0_;
} }
inline void
Cpu::set_system_library(SystemLibrary *l)
{
system_library_ = l;
}
// //
inline void inline void
Cpu::call() Cpu::call()
......
...@@ -69,8 +69,6 @@ namespace vm ...@@ -69,8 +69,6 @@ namespace vm
/// Load a program into memory. /// Load a program into memory.
void load_program(const inst::Program &program); void load_program(const inst::Program &program);
void set_system_library(SystemLibrary *l);
public: public:
/// Execute a program. /// Execute a program.
void execute(); void execute();
...@@ -98,6 +96,7 @@ namespace vm ...@@ -98,6 +96,7 @@ namespace vm
status_type get_status() const; status_type get_status() const;
const Cp0 &get_cp0() const; const Cp0 &get_cp0() const;
Cp0 &get_cp0();
const Cpu &get_cpu() const; const Cpu &get_cpu() const;
Cpu &get_cpu(); Cpu &get_cpu();
......
...@@ -33,6 +33,7 @@ namespace vm ...@@ -33,6 +33,7 @@ namespace vm
mode_(mode), mode_(mode),
status_(stop), status_(stop),
mmu_(cp0_, memory_), mmu_(cp0_, memory_),
cp0_(cpu_),
cpu_(mmu_, cp0_) cpu_(mmu_, cp0_)
{ {
} }
...@@ -45,13 +46,6 @@ namespace vm ...@@ -45,13 +46,6 @@ namespace vm
ostr << cpu_; ostr << cpu_;
} }
//
inline void
VirtualMachine::set_system_library(SystemLibrary *l)
{
cpu_.set_system_library(l);
}
// //
inline const std::vector<register_type> & inline const std::vector<register_type> &
VirtualMachine::get_call_stack() const VirtualMachine::get_call_stack() const
...@@ -86,6 +80,11 @@ namespace vm ...@@ -86,6 +80,11 @@ namespace vm
{ {
return cp0_; return cp0_;
} }
inline Cp0 &
VirtualMachine::get_cp0()
{
return cp0_;
}
inline const Cpu & inline const Cpu &
VirtualMachine::get_cpu() const VirtualMachine::get_cpu() const
......
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