Overview
The PPU (PowerPC Processor Unit) is the main 64-bit PowerPC processor in the PlayStation 3’s Cell Broadband Engine. It runs the primary application code and coordinates work with the six available SPUs.The PPU is a dual-threaded PowerPC 64-bit processor running at 3.2 GHz with VMX (AltiVec) SIMD extensions.
PPU Type System
PSL1GHT provides a comprehensive type system for PPU development inppu-types.h:
Basic Types
ppu/include/ppu-types.h
Volatile Types
For hardware register access and concurrent programming:ppu/include/ppu-types.h
System Types
ppu/include/ppu-types.h
LV2 Syscall Mechanism
PSL1GHT provides inline syscall wrappers that directly invoke PlayStation 3 system calls using the PowerPCsc (system call) instruction.
Syscall Macros
Theppu-lv2.h header defines macros for making system calls with 0-8 parameters:
ppu/include/ppu-lv2.h
Understanding the Syscall Mechanism
Understanding the Syscall Mechanism
- Registers r3-r10: Used for passing up to 8 parameters
- Register r11: Contains the syscall number
- sc instruction: PowerPC system call instruction that transitions to hypervisor mode
- Return value: Result is returned in register r3 (p1)
- Clobbered registers: Listed in the clobber list to inform the compiler
Return Value Handling
ppu/include/ppu-lv2.h
PPU Library Structure
The PPU libraries are organized into logical modules:Core System Headers
ppu-types.h
Basic type definitions and system types
ppu-lv2.h
Low-level syscall interface macros
ppu-asm.h
Assembly utilities and inline functions
LV2 System Services (lv2/)
Low-level system call wrappers:
lv2/memory.h- Memory mapper functionslv2/spu.h- SPU image and thread managementlv2/mutex.h- Mutex primitiveslv2/cond.h- Condition variableslv2/process.h- Process management
High-Level System APIs (sys/)
Higher-level APIs built on LV2 syscalls:
sys/memory.h- Memory allocation and managementsys/spu.h- SPU thread and group managementsys/thread.h- PPU threadingsys/event_queue.h- Event queues for synchronizationsys/file.h- File I/O operations
Subsystem Libraries
RSX Graphics
rsx/ - Reality Synthesizer graphicsAudio
audio/ - Audio output and mixingNetworking
net/, http/, ssl/ - Network stackSystem Utilities
sysutil/ - System dialogs and utilitiesFunction Pointer Descriptors
PowerPC 64-bit ABI uses function descriptors for indirect calls:ppu/include/ppu-types.h
Alignment Requirements
The Cell architecture has strict alignment requirements:ppu/include/ppu-types.h
Usage Example
Compiler Flags
The PPU toolchain uses specific optimization flags defined inppu_rules:
ppu_rules
Compiler Flag Explanations
Compiler Flag Explanations
- -mhard-float: Use hardware floating-point instructions
- -fmodulo-sched: Enable modulo scheduling for loops (Cell optimization)
- -ffunction-sections: Place each function in its own section
- -fdata-sections: Place each data item in its own section
- These enable better dead code elimination and smaller executables
Best Practices
Use System Types
Always use PSL1GHT system types (
u32, s64, etc.) instead of standard C types for consistency.Respect Alignment
Use
SPU_ALIGNMENT and STACK_ALIGN macros when allocating buffers for SPU DMA transfers.See Also
SPU Programming
Learn about programming the Synergistic Processing Units
Memory Management
Understand memory allocation and management
Build System
Set up your build environment
API Reference
Complete API documentation