Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Module periph

Module periph 

Source
Expand description

Zero-size ownership tokens for peripherals with shared state.

One token exists per device whose state two drivers could otherwise fight over: the GPU’s DMA channel (an in-flight linked-list walk and a GP0 write interleave), the ordering-table clear, MDEC and SPU channels, the CD-ROM controller (three drivers program it) and the controller port (pads and memory cards share it). An API that drives one of them takes the token by &mut, so the borrow checker sees the conflict. The tokens are empty, so passing them costs nothing at run time.

Get the whole set once with psx_rt::Peripherals::take(). Who owns what:

TokenOwnerOthers borrow it as
GpuDmapsx_gpu::GpuGpu::dma_mut, Gpu::from_dma_mut
Cdthe program, or cd::reader::SectorReader / cd::xa::Player while one exists&mut Cd methods (command, play_track, …), SectorReader::cd_mut
ControllerPortthe program&mut ControllerPort into psx_pad polls and psx_mc::HardwareCard
SpuDmapsx_spu::SpuSpu::upload_adpcm
MdecDmapsx_fmv::mdec::Mdecits methods
OrderingTableClearDmathe programOrderingTableClearDma::clear_table, OrderingTable::clear_with_dma

A token is a logic guard, not a memory-safety one: the SDK’s DMA APIs prove buffer lifetimes through references and slices whether or not a token is involved. That is why GpuDma::steal and friends are unsafe only in the “you are breaking an ownership invariant” sense. The deprecated free functions that predate the tokens steal one per call.

Structs§

Cd
The CD-ROM controller and DMA channel 3.
ControllerPort
The controller and memory-card port.
GpuDma
DMA channel 2 (RAM to GP0, and GPUREAD to RAM) and the GP0 command stream it feeds.
MdecDma
DMA channels 0 and 1, into and out of the MDEC.
OrderingTableClearDma
DMA channel 6, the ordering-table clear.
SpuDma
DMA channel 4 (RAM to SPU RAM and back) and the SPU transfer port.