From 24e8c776ee6d8b4eefc90d00947c2a16cde460e2 Mon Sep 17 00:00:00 2001 From: mohanson Date: Wed, 28 Feb 2024 11:23:00 +0800 Subject: [PATCH] Let snapshots stores the load_reservation_address --- src/snapshot.rs | 6 +++++- src/snapshot2.rs | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/snapshot.rs b/src/snapshot.rs index 6172a28c..ec42379d 100644 --- a/src/snapshot.rs +++ b/src/snapshot.rs @@ -32,12 +32,14 @@ pub struct Snapshot { pub page_indices: Vec, pub page_flags: Vec, pub pages: Vec>, + pub load_reservation_address: u64, } pub fn make_snapshot(machine: &mut T) -> Result { let mut snap = Snapshot { version: machine.version(), pc: machine.pc().to_u64(), + load_reservation_address: machine.memory().lr().to_u64(), ..Default::default() }; for (i, v) in machine.registers().iter().enumerate() { @@ -92,6 +94,8 @@ pub fn resume(machine: &mut T, snapshot: &Snapshot) -> Result<() machine.memory_mut().store_bytes(addr_from, &page[..])?; machine.memory_mut().set_flag(page_index, page_flag)?; } - + machine + .memory_mut() + .set_lr(&T::REG::from_u64(snapshot.load_reservation_address)); Ok(()) } diff --git a/src/snapshot2.rs b/src/snapshot2.rs index 708434d4..8d8188cf 100644 --- a/src/snapshot2.rs +++ b/src/snapshot2.rs @@ -96,6 +96,9 @@ impl> Snapshot2Context { machine.memory_mut().set_flag(page, *flag)?; } } + machine + .memory_mut() + .set_lr(&M::REG::from_u64(snapshot.load_reservation_address)); Ok(()) } @@ -204,6 +207,7 @@ impl> Snapshot2Context { pc: machine.pc().to_u64(), cycles: machine.cycles(), max_cycles: machine.max_cycles(), + load_reservation_address: machine.memory().lr().to_u64(), }) } @@ -261,4 +265,5 @@ pub struct Snapshot2 { pub pc: u64, pub cycles: u64, pub max_cycles: u64, + pub load_reservation_address: u64, }