Nugget
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | List of all members
psyqo::SIO0Bus Class Reference

Ownership arbiter for the SIO0 serial bus. More...

#include <psyqo/sio0-bus.hh>

Classes

struct  Lock
 RAII helper that owns the bus for the lifetime of the object. More...
 

Static Public Member Functions

static void acquire ()
 Takes ownership of the bus for the calling transaction.
 
static void release ()
 Releases one level of ownership taken by acquire.
 
static bool owned ()
 Returns whether the bus is currently owned by a card transaction.
 

Detailed Description

Ownership arbiter for the SIO0 serial bus.

The controller (pad) and the memory card share a single SIO0 bus and cannot drive it at the same time: two owners clocking the line at once corrupt each other's transfers. A memory card transaction can span several frames (the card introduces multi-thousand-cycle gaps before some of its acknowledges), so it must own the bus for its WHOLE duration, not just one byte or one sector at a time.

This is that lock. A memory card operation takes it for the entire transaction; AdvancedPad (and SimplePad) consult owned() each frame and skip polling while it is held, so the pad never touches the bus mid-card-op. The count is re-entrant: a filesystem operation holds it across all of its sector transfers even though each blocking sector transfer also takes it.

There is a single bus, so the state is static; only one transaction is ever in flight. It is only ever mutated from the main thread (operations start and end synchronously); the asynchronous transfer engine itself does not touch it, so no IRQ-context mutation occurs.

Member Function Documentation

◆ acquire()

static void psyqo::SIO0Bus::acquire ( )
inlinestatic

Takes ownership of the bus for the calling transaction.

◆ owned()

static bool psyqo::SIO0Bus::owned ( )
inlinestatic

Returns whether the bus is currently owned by a card transaction.

◆ release()

static void psyqo::SIO0Bus::release ( )
inlinestatic

Releases one level of ownership taken by acquire.


The documentation for this class was generated from the following file: