Overview
TheProcessor class manages PowerPC code execution, module loading, and interrupt request level (IRQL) handling for the Xbox 360 emulation runtime.
Class Definition
Construction
Processor()
Constructs a new Processor instance.memory- Pointer to the Memory systemexport_resolver- Pointer to the export resolver for kernel functions
Initialization
PreLaunch()
Runs pre-launch logic after modules and threads are initialized.Module Management
AddModule()
Adds a loaded module to the processor.module- Unique pointer to the module to add
true on success, false if the module couldn’t be added
GetModule()
Retrieves a module by name.name- Name of the module to retrieve
nullptr if not found
GetModules()
Gets a list of all loaded modules.Code Execution
Execute()
Executes PowerPC code at the specified address.thread_state- Thread state for execution contextaddress- Guest address to begin execution
true on successful execution
ExecuteRaw()
Executes raw PowerPC code without setup overhead.thread_state- Thread state for execution contextaddress- Guest address to begin execution
true on successful execution
Execute() with Arguments
Executes a function at the specified address with arguments.thread_state- Thread state for execution contextaddress- Guest address of function to callargs- Array of arguments to pass to the functionarg_count- Number of arguments in the array
ExecuteInterrupt()
Executes code as an interrupt handler.thread_state- Thread state for execution contextaddress- Guest address of interrupt handlerargs- Array of argumentsarg_count- Number of arguments
Interrupt Request Level (IRQL)
IRQL controls interrupt priority. Higher IRQL values prevent lower-priority interrupts from firing. This matches Xbox 360 kernel behavior.
RaiseIrql()
Raises the processor’s IRQL to a new level.new_value- New IRQL level (must be >= current IRQL)
LowerIrql()
Lowers the processor’s IRQL to a previous level.old_value- Previous IRQL value (must be less than or equal to current IRQL)
current_irql()
Gets the current IRQL level.Function Table Management
InitializeFunctionTable()
Initializes the function dispatch table for recompiled code.code_base- Base address of executable code sectioncode_size- Size of code sectionimage_base- Base address of loaded imageimage_size- Total image size
true on success
SetFunction()
Registers a host function for a guest address in the function table.guest_address- Guest address to mapfunc- Host function pointer
GetFunction()
Retrieves the registered host function for a guest address.guest_address- Guest address to lookup
nullptr if not registered
HasFunctionTable()
Checks if the function table has been initialized.true if initialized
Thread Management
OnThreadCreated()
Called when a new thread is created.handle- Thread handlethread_state- Pointer to thread statethread- Pointer to thread object
OnThreadExit()
Called when a thread exits.thread_id- ID of exiting thread
OnThreadDestroyed()
Called when a thread is destroyed.thread_id- ID of destroyed thread
State Management
Save()
Saves the processor state to a byte stream.stream- Byte stream to write to
true on success
Restore()
Restores the processor state from a byte stream.stream- Byte stream to read from
true on success
Properties
memory()
Gets the associated Memory instance.export_resolver()
Gets the associated ExportResolver.execution_state()
Gets the current execution state.Enumerations
Irql
Interrupt Request Level values:PASSIVE- Normal execution, all interrupts allowedAPC- APCs blockedDISPATCH- Thread dispatching blockedDPC- Deferred procedure calls active