Add thread save and restore processor context
This commit is contained in:
committed by
François Autin
parent
0c3af96b78
commit
26b75ffe8d
@ -2,7 +2,6 @@ use std::{ops::{Add, Sub}, io::Write};
|
||||
|
||||
use crate::simulator::print;
|
||||
|
||||
use super::{decode::{Instruction, decode}};
|
||||
use super::{decode::{Instruction, decode}, interrupt::Interrupt};
|
||||
use super::global::*;
|
||||
use std::fs::File;
|
||||
@ -74,15 +73,10 @@ pub struct Machine {
|
||||
pub sp: usize,
|
||||
pub int_reg : Register<i64>,
|
||||
pub fp_reg : Register<f32>,
|
||||
<<<<<<< HEAD
|
||||
pub main_memory : Vec<u8>,
|
||||
pub shiftmask : [u64 ; 64],
|
||||
pub registers_trace : String // for tests
|
||||
=======
|
||||
pub main_memory : [u8 ; MEM_SIZE],
|
||||
pub shiftmask : [u64 ; 64],
|
||||
pub interrupt: Interrupt,
|
||||
>>>>>>> 8c6ef4e (Implemente finish (not finished yet), fix ucontext for windows)
|
||||
pub registers_trace : String, // for tests
|
||||
pub interrupt: Interrupt
|
||||
// futur taille à calculer int memSize = g_cfg->NumPhysPages * g_cfg->PageSize;
|
||||
//creer une struct cfg(configuration) qui s'initialise avec valeur dans un fichier cfg
|
||||
}
|
||||
@ -105,21 +99,14 @@ impl Machine {
|
||||
sp: 0,
|
||||
int_reg : Register::<i64>::init(),
|
||||
fp_reg : Register::<f32>::init(),
|
||||
<<<<<<< HEAD
|
||||
main_memory : vec![0; MEM_SIZE],
|
||||
main_memory : [0; MEM_SIZE],
|
||||
shiftmask,
|
||||
interrupt: Interrupt::new(),
|
||||
registers_trace : String::from("")
|
||||
};
|
||||
|
||||
ret.int_reg.set_reg(10, -1);
|
||||
ret
|
||||
=======
|
||||
main_memory : [0 ; MEM_SIZE],
|
||||
shiftmask,
|
||||
interrupt: Interrupt::new()
|
||||
}
|
||||
|
||||
>>>>>>> 8c6ef4e (Implemente finish (not finished yet), fix ucontext for windows)
|
||||
ret
|
||||
}
|
||||
|
||||
/// Read from main memory of the machine
|
||||
@ -690,6 +677,21 @@ impl Machine {
|
||||
println!();
|
||||
}
|
||||
|
||||
pub fn read_int_register(&self, index: usize) -> i64 {
|
||||
self.int_reg.get_reg(index)
|
||||
}
|
||||
|
||||
pub fn read_fp_register(&self, index: usize) -> f32 {
|
||||
self.fp_reg.get_reg(index)
|
||||
}
|
||||
|
||||
pub fn write_int_register(&mut self, index: usize, value: i64) {
|
||||
self.int_reg.set_reg(index, value);
|
||||
}
|
||||
|
||||
pub fn write_fp_register(&mut self, index: usize, value: f32) {
|
||||
self.fp_reg.set_reg(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user