feat(runtime): add host wall clock and administrative UTC timestamps
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

This commit is contained in:
2026-10-13 09:16:15 +01:00
parent 3e39a90083
commit 23dc6fc66d
21 changed files with 603 additions and 51 deletions
+32 -3
View File
@@ -1,14 +1,14 @@
use std::fmt;
use std::sync::Arc;
use prometeu_drivers::MemoryBanks;
use prometeu_drivers::hardware::Hardware;
use prometeu_drivers::{ControlledWallClock, MemoryBanks};
use prometeu_firmware::firmware_state::{AppCrashesStep, ResetStep};
use prometeu_firmware::{BootTarget, Firmware, FirmwareState};
use prometeu_hal::{
AssetBridge, AudioBridge, FrameId, Game2DFrameComposer, InputPlatform, InputSignals,
OwnedRgba8888Frame, RenderBackend, RenderSubmission, RenderSubmissionSink, RenderSubmitError,
RuntimePlatform, TelemetryPlatform,
RuntimePlatform, TelemetryPlatform, WallClock,
};
use prometeu_system::{CrashReport, LatestRenderFrameStore};
@@ -103,6 +103,7 @@ pub struct HeadlessHost {
signals: InputSignals,
boot_attempted: bool,
last_completed_frame: Option<CompletedFrame>,
controlled_wall_clock: Option<Arc<ControlledWallClock>>,
}
#[derive(Debug, Clone, Copy)]
@@ -118,8 +119,21 @@ struct HeadlessPlatform {
impl HeadlessHost {
pub fn new() -> Self {
let clock = Arc::new(ControlledWallClock::default());
Self::with_clock(clock.clone(), Some(clock))
}
/// Supply a host-owned civil clock. The caller retains control of this provider.
pub fn new_with_wall_clock(clock: Arc<dyn WallClock>) -> Self {
Self::with_clock(clock, None)
}
fn with_clock(
clock: Arc<dyn WallClock>,
controlled_wall_clock: Option<Arc<ControlledWallClock>>,
) -> Self {
let memory_banks = Arc::new(MemoryBanks::new());
let hardware = Hardware::new_with_memory_banks(Arc::clone(&memory_banks));
let hardware = Hardware::new_with_memory_banks(Arc::clone(&memory_banks), clock);
let store = LatestRenderFrameStore::default();
Self {
firmware: Firmware::new(None),
@@ -127,9 +141,20 @@ impl HeadlessHost {
signals: InputSignals::default(),
boot_attempted: false,
last_completed_frame: None,
controlled_wall_clock,
}
}
/// Read the same clock supplied to the runtime platform.
pub fn wall_clock(&self) -> &dyn WallClock {
self.platform.wall_clock()
}
/// Native controls for the default clock; custom providers are controlled by their owner.
pub fn controlled_wall_clock(&self) -> Option<&ControlledWallClock> {
self.controlled_wall_clock.as_deref()
}
/// Load `path` and tick until the firmware is in `GameRunning`.
///
/// The transition into `GameRunning` is the last tick. The first game
@@ -384,6 +409,10 @@ impl RenderSubmissionSink for HeadlessPlatform {
}
impl RuntimePlatform for HeadlessPlatform {
fn wall_clock(&self) -> &dyn WallClock {
self.hardware.wall_clock()
}
fn display_size(&self) -> (usize, usize) {
(Hardware::W, Hardware::H)
}