# <kind> <name|address>
#   hle     replace with hle_<name> (src/runtime); the translated body stays as <fn>_orig
#   savectx the function returns twice (its callers keep a jump buffer)
#   entry   extra function entry the analysis cannot see
#   noentry drop a false-positive entry
#   idle    head of a spin-wait loop: its back-edge blocks the host thread until an event
#           is due instead of spinning (the loop can only end through an interrupt)

# OS context switching runs on host fibers (src/runtime/threads.cpp)
savectx OSSaveContext
hle     OSSaveContext
hle     OSLoadContext
hle     OSInitContext

# The runtime library's memcpy (a byte loop): native within MEM1 (src/runtime/hle_os.cpp)
hle     memcpy

# The SDK's audio sample rate converter check: timed with the host's clock, it never passes under
# arm64 translation (Android's x86_64 emulators) (src/runtime/hle_os.cpp)
hle     AISrcInit

# Debug output and fatal paths (src/runtime/hle_os.cpp)
hle     OSReport
hle     PPCHalt
hle     OSPanic

# 2003 SDK memory protection: the BAT setup runs in real mode (rfi in and out); the runtime
# maps memory itself, so it is left out (src/runtime/hle_os.cpp)
hle     RealMode

# OS idle loop in __OSReschedule: no runnable thread, interrupts enabled, spins on
# RunQueueBits until an interrupt handler readies a thread (bl OSEnableInterrupts at 80023E24;
# lwz r0,RunQueueBits(r13); cmplwi; beq back - the same code as Rebel Strike's 800260C0)
idle    80023E28

# The game module (shared/mgso.rel) must be linked where the recompiler linked it (src/runtime/hle_game.cpp)
hle     OSLink

# The SDK's VM library: SDR1 is set in real mode (rfi in and out); the runtime sets it directly
# (src/runtime/hle_os.cpp). Page faults go to VMDsiHandler (src/runtime/vm.cpp), reached in the
# game only through the patched DSI vector and an rfi: an entry of its own.
hle     VMSetSdr1
entry   VMDsiHandler

# A GX FIFO manager thread (context 8020C120, started at boot at 8004BED8): forever "work
# (8004BEF0: polls the CPU / GP FIFO pointers, 800410FC, and swaps buffers when the GPU caught
# up), then OSYieldThread". What it polls only changes after an interrupt or a timed hardware
# event, so between passes it waits for one: each pass was a full context save and load here,
# most of the game thread's time (profile, the opening), and the game thread never idled.
idle    8004BEE4

# Widescreen: the game's views projected (and culled) for the display aspect (src/runtime/hle_game.cpp)
hle     MakeProjection

# The codec's background: the frame on screen copied on the GPU (src/runtime/hle_game.cpp)
hle     XfbToTexture

# The disc change: the drive model swaps to the disc the game asks for (src/runtime/hle_game.cpp, hw.cpp)
hle     DVDChangeDiskAsync

# The crawl view's dark ring: one full-screen layer in widescreen, or left out (src/runtime/hle_game.cpp)
hle     OverlayDraw

# Psycho Mantis reads the memory card: the games and saves he finds as set (src/runtime/hle_game.cpp)
hle     MantisReadCard

# Pass the torture: the torture's own life kept full while the cheat is on (src/runtime/hle_game.cpp)
hle     TortureUpdate

# Radar in alert mode: the radar's update sees the phase as sneaking during an alert (src/runtime/hle_game.cpp)
hle     RadarUpdate
