SDK crate

psx-rt

Runtime, boot and frame timing

On this page

Use psx-rt in every bare-metal program to supply the entry point, panic handling and runtime support. Keep extern crate psx_rt; in your executable so the runtime is linked. The loader enters _start, which clears .bss, initializes the optional heap and calls your main.

How the crate is organized

Peripherals is the token set for the GPU and SPU DMA channels, the CD-ROM controller and the controller port; Peripherals::take() returns it once and None after that. bios and tty expose target-side kernel calls and debug text. interrupts owns interrupt and VBlank helpers, including queued display flips, and present holds the VBlank-kicked present queue behind the present-queue feature. cache handles instruction-cache maintenance; scratchpad provides regions and scoped scratchpad stacks. heap is available with alloc. Internal mem and builtins modules implement the memory routines and corrected software 64-bit arithmetic used on the target.

Integration notes

The default build has no heap. Enable alloc only when your program needs allocation; its bump allocator is not a general reclaiming allocator. Use the top-level build commands so the linker script, load-delay hazard patcher and stack guard all run. Scratchpad stacks need the documented interrupt contract and a size proof. scratchpad-stack-check adds runtime checks; it does not replace the build-time guard.

Start with hello-tri, then study queued presentation, the present queue and scratchpad stacks.

API, dependencies and source structure

SDK revision 80d1c329e977. Structure, dependencies and features below come from this revision.

The PS1 reference includes all Cargo features. The manifest below shows which features are enabled by default.

Dependencies

  • critical-section (shared repository crate): all targets; optional; features: restore-state-bool
  • psx-hw (shared repository crate): all targets
  • psx-io: all targets

Cargo features

FeatureEnables
allocNo additional dependency features
boot-traceNo additional dependency features
console-diagpsx-io/console-diag
critical-sectiondep:critical-section
defaultruntime
hazard-trampolines-192No additional dependency features
hazard-trampolines-256No additional dependency features
present-queuepsx-io/present-queue
runtimeNo additional dependency features
scratchpad-stack-checkNo additional dependency features
strict-faultsNo additional dependency features

Read the complete manifest and feature comments.

Source layout

The list includes internal implementation and test files. Public modules, types, functions and their signatures are indexed in the API reference above.

15 source and manifest files
  • Cargo.toml
  • src/bios.rs: The runtime's one remaining BIOS entry point: TTY putchar.
  • src/builtins.rs: Corrected software 64-bit integer builtins for the PSX target.
  • src/cache.rs: Instruction-cache invalidation, and the only code in the SDK that touches the cache
  • src/critical_section.rs: Critical sections: run code with CPU interrupts masked.
  • src/diag.rs: Console stop-panel: what a program was doing when it stopped, on screen.
  • src/heap.rs: Bump allocator gated behind the alloc feature.
  • src/interrupts.rs: Minimal interrupt support used by engine-level clocks.
  • src/lib.rs: PS1 bare-metal runtime.
  • src/mem.rs: Hand-scheduled R3000 memcpy / memset / memcmp / bcmp.
  • src/peripherals.rs: The one-per-program set of peripheral ownership tokens.
  • src/present.rs: VBlank-kicked presentation: a one-frame-deep queue between the CPU and the
  • src/scratchpad.rs: The CPU scratchpad, and running code with its stack there.
  • src/tty.rs: TTY output for debug printing.
  • src/wait.rs: Bounded spin waits shared by the VBlank and present-queue waits.