implements PLN-0058
This commit is contained in:
@@ -153,7 +153,7 @@ impl HostRunner {
|
||||
let mut firmware = Firmware::new(cap_config);
|
||||
if let Some(root) = &fs_root {
|
||||
let backend = HostDirBackend::new(root);
|
||||
firmware.os.mount_fs(Box::new(backend));
|
||||
firmware.os.fs().mount(Box::new(backend));
|
||||
}
|
||||
|
||||
Self {
|
||||
@@ -203,8 +203,8 @@ impl HostRunner {
|
||||
}
|
||||
}
|
||||
|
||||
fn machine_running(&self) -> bool {
|
||||
!self.firmware.os.vm_runtime.paused && !self.debugger.waiting_for_start
|
||||
fn machine_running(&mut self) -> bool {
|
||||
!self.firmware.os.vm().paused() && !self.debugger.waiting_for_start
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ impl ApplicationHandler for HostRunner {
|
||||
|
||||
WindowEvent::RedrawRequested => {
|
||||
let overlay_snapshot =
|
||||
self.overlay_enabled.then(|| capture_snapshot(&self.stats, &self.firmware));
|
||||
self.overlay_enabled.then(|| capture_snapshot(&self.stats, &mut self.firmware));
|
||||
|
||||
// Get Pixels directly from the field (not via helper that gets the entire &mut self)
|
||||
let pixels = self.pixels.as_mut().expect("pixels not initialized");
|
||||
@@ -320,25 +320,25 @@ impl ApplicationHandler for HostRunner {
|
||||
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
|
||||
let was_debugger_connected = self.debugger.stream.is_some();
|
||||
let was_waiting_for_start = self.debugger.waiting_for_start;
|
||||
let was_paused = self.firmware.os.vm_runtime.paused;
|
||||
let was_paused = self.firmware.os.vm().paused();
|
||||
|
||||
// 1. Process pending debug commands from the network.
|
||||
self.debugger.check_commands(&mut self.firmware, &mut self.hardware);
|
||||
|
||||
// Sync inspection mode state. This is host-owned overlay/debugger control,
|
||||
// not a guest-visible debug ABI switch.
|
||||
self.firmware.os.vm_runtime.inspection_active =
|
||||
self.overlay_enabled || self.debugger.stream.is_some();
|
||||
self.firmware
|
||||
.os
|
||||
.vm()
|
||||
.set_inspection_active(self.overlay_enabled || self.debugger.stream.is_some());
|
||||
|
||||
// 2. Maintain filesystem connection if it was lost (e.g., directory removed).
|
||||
if let Some(root) = &self.fs_root {
|
||||
use prometeu_system::fs::FsState;
|
||||
if matches!(self.firmware.os.fs_state, FsState::Unmounted | FsState::Error(_))
|
||||
&& std::path::Path::new(root).exists()
|
||||
{
|
||||
let backend = HostDirBackend::new(root);
|
||||
self.firmware.os.mount_fs(Box::new(backend));
|
||||
}
|
||||
// 2. Maintain a filesystem connection if it was lost (e.g., directory removed).
|
||||
if let Some(root) = &self.fs_root
|
||||
&& self.firmware.os.fs().needs_mount()
|
||||
&& std::path::Path::new(root).exists()
|
||||
{
|
||||
let backend = HostDirBackend::new(root);
|
||||
self.firmware.os.fs().mount(Box::new(backend));
|
||||
}
|
||||
|
||||
// 3. Timing Management (The heart of determinism).
|
||||
@@ -362,13 +362,13 @@ impl ApplicationHandler for HostRunner {
|
||||
// Unless the debugger is waiting for a 'start' command, advance the system.
|
||||
if !self.debugger.waiting_for_start {
|
||||
self.firmware.tick(&self.input.signals, &mut self.hardware);
|
||||
self.stats.record_host_cpu_time(self.firmware.os.vm_runtime.last_frame_cpu_time_us);
|
||||
self.stats.record_host_cpu_time(self.firmware.os.vm().last_frame_cpu_time_us());
|
||||
}
|
||||
|
||||
// Sync pause state with audio.
|
||||
// We do this AFTER firmware.tick to avoid MasterPause/Resume commands
|
||||
// being cleared by the OS if a new logical frame starts in this tick.
|
||||
let is_paused = self.firmware.os.vm_runtime.paused || self.debugger.waiting_for_start;
|
||||
let is_paused = self.firmware.os.vm().paused() || self.debugger.waiting_for_start;
|
||||
if is_paused != self.last_paused_state {
|
||||
self.last_paused_state = is_paused;
|
||||
let cmd =
|
||||
@@ -383,11 +383,11 @@ impl ApplicationHandler for HostRunner {
|
||||
self.stats.record_frame();
|
||||
}
|
||||
|
||||
self.presentation.note_published_frame(self.firmware.os.vm_runtime.logical_frame_index);
|
||||
self.presentation.note_published_frame(self.firmware.os.vm().logical_frame_index());
|
||||
|
||||
if was_debugger_connected != self.debugger.stream.is_some()
|
||||
|| was_waiting_for_start != self.debugger.waiting_for_start
|
||||
|| was_paused != self.firmware.os.vm_runtime.paused
|
||||
|| was_paused != self.firmware.os.vm().paused()
|
||||
{
|
||||
self.invalidate_host_surface();
|
||||
}
|
||||
@@ -396,14 +396,14 @@ impl ApplicationHandler for HostRunner {
|
||||
self.audio.update_stats(&mut self.stats);
|
||||
|
||||
// Update technical statistics displayed in the window title.
|
||||
self.stats.update(now, self.window, &self.hardware, &self.firmware);
|
||||
self.stats.update(now, self.window, &self.hardware, &mut self.firmware);
|
||||
|
||||
// Synchronize system logs to the host console.
|
||||
let last_seq = self.log_sink.last_seq().unwrap_or(u64::MAX);
|
||||
let new_events = if last_seq == u64::MAX {
|
||||
self.firmware.os.log_service.get_recent(4096)
|
||||
self.firmware.os.recent_logs(4096)
|
||||
} else {
|
||||
self.firmware.os.log_service.get_after(last_seq)
|
||||
self.firmware.os.logs_after(last_seq)
|
||||
};
|
||||
self.log_sink.process_events(new_events);
|
||||
|
||||
@@ -813,7 +813,7 @@ mod tests {
|
||||
stream.write_all(b"{\"type\":\"pause\"}\n").expect("Should write pause");
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
runner.debugger.check_commands(&mut runner.firmware, &mut runner.hardware);
|
||||
assert!(runner.firmware.os.vm_runtime.paused, "VM should be paused");
|
||||
assert!(runner.firmware.os.vm().paused(), "VM should be paused");
|
||||
}
|
||||
|
||||
// 2. Disconnect (stream goes out of scope)
|
||||
@@ -821,7 +821,7 @@ mod tests {
|
||||
runner.debugger.check_commands(&mut runner.firmware, &mut runner.hardware);
|
||||
|
||||
// 3. Check if unpaused
|
||||
assert!(!runner.firmware.os.vm_runtime.paused, "VM should have unpaused after disconnect");
|
||||
assert!(!runner.firmware.os.vm().paused(), "VM should have unpaused after disconnect");
|
||||
assert!(!runner.debugger.waiting_for_start, "VM should have left waiting_for_start state");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user