class Cradare2::Platform::PS2::VUProfiler

Overview

PS2 EE/VU1 memory & cycle profiling bridge inspecting VU1 Micro-Memory (0x11008000), VU1 Data Memory (0x1100C000), and pipeline stall hazards over r2pipe, GDB RSP, or byte slices.

Defined in:

cradare2/platform/ps2/vu_profiler.cr

Constant Summary

FDIV_DIV_LATENCY = 7
FDIV_RSQRT_LATENCY = 13
FMAC_LATENCY = 4
ILW_LATENCY = 4
LOAD_LATENCY = 4
LOWER_NOP_CANONICAL = 2147484476_u32
UPPER_NOP_CANONICAL = 767_u32

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_bytes(micro_bytes : Bytes, data_bytes : Bytes = Bytes.empty) : self #

[View source]
def self.from_gdb(gdb : Gdb::Client) : self #

[View source]
def self.new(client : Client) #

[View source]
def self.new(gdb : Gdb::Client) #

[View source]
def self.new(micro_buffer : Bytes = Bytes.empty, data_buffer : Bytes = Bytes.empty) #

[View source]

Class Method Detail

def self.decode_instruction(lower_word : UInt32, upper_word : UInt32, pc : UInt32 = 0_u32, base_addr : UInt64 = Registers::VU1_MICRO_MEM) : VUInstruction #

Decodes a single 64-bit Dual-Issue VU1 Microinstruction (lower_word in bits 0..31, upper_word in bits 32..63).


[View source]
def self.format_broadcast(bc : UInt8) : String #

[View source]
def self.format_dest_mask(mask : UInt8) : String #

Formats a 4-bit destination mask (0b1000=x, 0b0100=y, 0b0010=z, 0b0001=w) into a suffix string.


[View source]
def self.format_vf(idx : UInt8) : String #

[View source]
def self.format_vi(idx : UInt8) : String #

[View source]

Instance Method Detail

def analyze_hazards(instructions : Array(VUInstruction), xgkick_min_separation : Int32 = @xgkick_min_separation) : Array(VUStallHazard) #

Analyzes a sequence of decoded VUInstructions for PS2 VU1 pipeline stall hazards and register conflicts.


[View source]
def client : Client | Nil #

[View source]
def data_base : UInt64 #

[View source]
def data_base=(data_base : UInt64) #

[View source]
def data_buffer : Bytes #

[View source]
def data_buffer=(data_buffer : Bytes) #

[View source]
def data_qw_count : Int32 #

[View source]
def data_qw_count=(data_qw_count : Int32) #

[View source]
def data_qw_offset : Int32 #

[View source]
def data_qw_offset=(data_qw_offset : Int32) #

[View source]
def decode_microprogram(bytes : Bytes, start_pc : UInt32 = @start_pc, max_instructions : Int32 = @max_instructions, stop_on_e_bit : Bool = @stop_on_e_bit, base_addr : UInt64 = @micro_base) : Array(VUInstruction) #

Decodes a binary slice of 64-bit VU1 microinstructions (8 bytes each, little-endian).


[View source]
def decode_quadwords(bytes : Bytes, qw_offset : Int32 = 0, base_addr : UInt64 = @data_base) : Array(VUQuadword) #

Decodes a slice of bytes into 128-bit VUQuadword entries (x, y, z, w floats & ix, iy, iz, iw uint32s).


[View source]
def dissect_xgkick_packet(qw_offset : Int32, max_items : Int32 = 32) : Array(GifDissector::GifItemInfo) #

Dissects a GS GIF packet prepared for XGKICK at quadword offset qw_offset in VU1 Data Memory (0x1100C000).


[View source]
def gdb : Gdb::Client | Nil #

[View source]
def inspect_data_memory(qw_offset : Int32 = @data_qw_offset, qw_count : Int32 = @data_qw_count) : VUMemorySnapshot #

Inspects VU1 Data Memory (0x1100C000), VIF1 double-buffer registers, and EE timers over r2pipe/GDB.


[View source]
def max_instructions : Int32 #

[View source]
def max_instructions=(max_instructions : Int32) #

[View source]
def measure_ee_cycles(&) : UInt32 #

Measures elapsed Emotion Engine Hardware Timer 0 (0x10000000) bus cycles around a block.


[View source]
def micro_base : UInt64 #

[View source]
def micro_base=(micro_base : UInt64) #

[View source]
def micro_buffer : Bytes #

[View source]
def micro_buffer=(micro_buffer : Bytes) #

[View source]
def profile(start_pc : UInt32 = @start_pc, max_instructions : Int32 = @max_instructions) : VUProfileReport #

Reads VU1 Micro-Memory (0x11008000) over r2pipe/GDB and profiles the microprogram.


[View source]
def profile_bytes(micro_bytes : Bytes, start_pc : UInt32 = @start_pc, max_instructions : Int32 = @max_instructions, stop_on_e_bit : Bool = @stop_on_e_bit) : VUProfileReport #

Profiles a binary slice of VU1 micro-memory instructions and computes cycle counts, stalls, IPC, and frame budgets.


[View source]
def read_bytes(address : UInt64, length : Int32) : Bytes #

Unified memory reader across r2pipe (Client), GDB RSP (Gdb::Client), or local buffers.


[View source]
def read_data_memory(offset_bytes : Int32 = 0, size : Int32 = 1024) : Bytes #

Reads raw bytes from VU1 Data Memory (0x1100C000 + offset_bytes).


[View source]
def read_micro_memory(offset_bytes : Int32 = 0, size : Int32 = 2048) : Bytes #

Reads raw bytes from VU1 Micro-Memory (0x11008000 + offset_bytes).


[View source]
def read_u32(address : UInt64) : UInt32 #

Reads a 32-bit unsigned integer in PlayStation 2 little-endian byte order.


[View source]
def start_pc : UInt32 #

[View source]
def start_pc=(start_pc : UInt32) #

[View source]
def stop_on_e_bit : Bool #

[View source]
def stop_on_e_bit=(stop_on_e_bit : Bool) #

[View source]
def xgkick_min_separation : Int32 #

[View source]
def xgkick_min_separation=(xgkick_min_separation : Int32) #

[View source]