Skip to content

Feature Request: API for accessing emulator registers within events #7

@logantgt

Description

@logantgt

Goal

This issue aims to discuss the design of an API that would allow for access to the data stored in the registers of an emulated processor, and a mechanism to read those registers while the processor is in some desired state (for example, the program counter having reached a desirable piece of code).

Forgive anything that's not especially clear - I know what kind of functionality would be useful to have in this API but I don't know how it should look in the spec!

Applications

A lot of these suggestions are based around the needs of my particular application, and while I think the functionality could be applied to a lot of different scenarios, bare in mind I'm probably not considering every possible use case, and this issue may require more input. For the sake of getting this done I am only proposing a minimal set of features.

Access to register values at certain points in the emulated program makes it possible to extract useful arbitrary data from an emulated application for further processing in an external application. For one example, this is useful in "text hooking" applications where strings (usually in a language foreign to the user) are copied out of memory and sent to a translation service. The current utilities that interact with emulators in this way are overly complicated and often break with simple ABI changes.

Proposals

  • A pair of message/answers to ask/receive details about what processors are available to be interacted with through PINE.

For the sake of discussion, a Processor represents a state machine that contains an arbitrary amount of labelled values (typically registers). An emulator should offer access to at least one Processor (ideally the application processor that is associated with executing game code).

The answer should include the name of the processor, the width of its registers as an 8 bit integer, and all the valid register names that can be accessed. PCSX2 could offer an answer like this as a null terminated C string;

 ee:zero,at,v0,v1,a0,a1,a2,a3,t0,t1,t2,t3,t4,t5,t6,t7,s0,s1,s2,s3,s4,s5,s6,s7,t8,t9,k0,k1,gp,sp,fp,ra,pc,hi,lo

where the first byte is the width of the registers (32 dec = SPACE in ascii).

PCSX2 implementation consideration; PS2 registers are seen as 128 bits wide during SIMD operations, pointers are 32 bit, should PINE simply offer the lowest 32 bits of each register?

  • A pair of message/answers to request/receive the value of a register inside of a Processor.

This should have a very simple interface, a request might have an argument like ee:a1 to read the value of the A1 register in the PS2's Emotion Engine. Consider the ability to write to registers in the future?

  • A set of message/answers to establish, notify, and acknowledge handling of blocking events raised when the program counter of a given processor reaches the address of a given instruction (these could be called "instruction events").

The event API has been mentioned in the draft specification but is not yet implemented.

An "instruction event" should be registered using a known Processor and memory address where desired code is located. Once a registered event is raised, the emulator should pause execution. PINE will notify the client of the raised event, and respond to any read/write requests made by the client. The client program must send a special acknowledgement that the raised event was handled before emulation may resume.

  • A pair of message/answers to request/receive an array of bytes from emulator memory, starting at a given address and reading to a certain length. Self explanatory, would make life easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions