Skip to main content

rustyn64_core/
lib.rs

1//! `rustyn64-core` — the Bus + the fractional master-clock lockstep scheduler.
2//!
3//! The single crate that knows about every chip; it owns the [`Bus`] (all
4//! mutable state) and the [`System`] run loop, implements each chip's narrow
5//! bus trait, and re-exports the chip crates' public types so downstream
6//! consumers (`rustyn64-frontend`, `rustyn64-test-harness`) depend on
7//! `rustyn64-core`, not the chip crates directly. See `docs/architecture.md`.
8//!
9//! `#![no_std]` + `alloc`; the determinism contract (no system time / OS RNG /
10//! thread scheduling) is enforced here — the scheduler is one timeline.
11
12#![no_std]
13#![forbid(unsafe_code)]
14#![warn(missing_docs)]
15
16extern crate alloc;
17
18pub mod boot;
19pub mod bus;
20/// The fast path's hand-off enumeration and run report (ADR 0012 §2).
21///
22/// Present only with a fast path compiled in — `fast-scheduler` or `fast-exec` —
23/// so a default build gains nothing at all. ADR 0011 §1 by construction, the same
24/// way [`scheduler::System::run_until_fast`] is a separate entry point rather than
25/// a branch.
26///
27/// Shared by both modes because [`fastpath::FastRunReport`] answers the same
28/// question for each — did the fast path engage, and where did it hand back — even
29/// though the two are graded by different predicates (ADR 0013 §1).
30#[cfg(any(feature = "fast-scheduler", feature = "fast-exec"))]
31pub mod fastpath;
32pub mod scheduler;
33pub mod vi;
34
35// Re-export the chip crates (the public surface). Downstream consumers reach
36// the chip types through these aliases (e.g. `rustyn64_core::rustyn64_cpu::Cpu`).
37pub use rustyn64_audio as rustyn64_audio_crate;
38pub use rustyn64_cart as rustyn64_cart_crate;
39pub use rustyn64_cpu as rustyn64_cpu_crate;
40pub use rustyn64_rdp as rustyn64_rdp_crate;
41pub use rustyn64_rsp as rustyn64_rsp_crate;
42
43// Friendly short aliases for the chip crates.
44pub use rustyn64_audio as audio;
45pub use rustyn64_cart as cart;
46pub use rustyn64_cpu as cpu;
47pub use rustyn64_rdp as rdp;
48pub use rustyn64_rsp as rsp;
49
50pub use bus::{Bus, MiInterrupt, RDRAM_SIZE, RcpRegs};
51pub use scheduler::{
52    COUNT_DIVIDER, CPU_DIVIDER, CPU_HZ, MASTER_HZ, PHASE_PERIOD, PIF_DIVIDER, RCP_DIVIDER, RCP_HZ,
53    SI_DIVIDER, System,
54};
55pub use vi::Vi;
56
57/// Returns the crate version string.
58#[must_use]
59pub const fn version() -> &'static str {
60    env!("CARGO_PKG_VERSION")
61}