Kernel mode
Full hardware access on custom firmware
Enable the kernel feature and declare your module with module_kernel!. It sets module attribute 0x1000 and starts psp_main on a kernel thread.
src/main.rs
#![no_std]
#![no_main]
psp::module_kernel!("MyKernelApp", 1, 0);
fn psp_main() {
psp::callback::setup_exit_callback().unwrap();
// Kernel-only: Media Engine clock
let me_mhz = unsafe {
psp::sys::scePowerGetMeClockFrequency()
};
psp::dprintln!("ME clock: {}MHz", me_mhz);
}
Unlocks
- Media Engine boot and task execution (
psp::me)
- Memory-mapped register I/O (
psp::hw), GPIO, Syscon and Sysreg
- Syscall hooking for CFW plugins (
psp::hook, sctrlHEN*)
- NAND flash, SIRCS infrared and USB bus-driver syscalls
- CPU exception handler registration
Requires custom firmware such as ARK-4 or PRO. In PPSSPP the module loads, but kernel-only calls may return errors.
Standard library experimental
Use std on the PSP
With the std feature, cargo psp overlays a PSP platform layer onto your rust-src and rebuilds the standard library with -Z build-std.
src/main.rs
#![feature(restricted_std)]
#![no_main]
psp::module!("std_hello", 1, 0);
fn psp_main() {
psp::callback::setup_exit_callback().unwrap();
let greeting = String::from("Hello from std!");
let names = vec!["sajattack", "overdrivenpotato"];
for name in names {
psp::dprintln!("{greeting} Hi, {name}.");
}
}
Standard library support on PSP
| std API | Backed by |
String, Vec, collections | PSP memory allocator |
std::thread | sceKernelCreateThread |
Mutex / Condvar | Lightweight mutexes / event flags |
std::time | System time and RTC ticks |
std::fs, stdio | sceIo*, kernel stdout/stderr |
std::net, std::process | Unsupported |
Use psp = { git = "…", features = ["std"] }. cargo psp detects the feature; RUST_PSP_BUILD_STD=1 forces a std build. Output goes to target/mipsel-sony-psp-std/.
The PSP overlay ships in the rust-psp repository, and cargo psp finds it next to your psp dependency, so it always matches the revision you build against. See docs/std.md.