mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
plugins: Add register write API
This patch adds a function to the plugins API to allow plugins to write register contents. It also moves the qemu_plugin_read_register function so all the register-related functions are grouped together in the file. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Rowan Hart <rowanbhart@gmail.com> Message-ID: <20250624175351.440780-3-rowanbhart@gmail.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-ID: <20250627112512.1880708-7-alex.bennee@linaro.org>
This commit is contained in:
parent
1bb6403a34
commit
1a92b65859
2 changed files with 56 additions and 24 deletions
|
@ -871,7 +871,8 @@ struct qemu_plugin_register;
|
|||
/**
|
||||
* typedef qemu_plugin_reg_descriptor - register descriptions
|
||||
*
|
||||
* @handle: opaque handle for retrieving value with qemu_plugin_read_register
|
||||
* @handle: opaque handle for retrieving value with qemu_plugin_read_register or
|
||||
* writing value with qemu_plugin_write_register
|
||||
* @name: register name
|
||||
* @feature: optional feature descriptor, can be NULL
|
||||
*/
|
||||
|
@ -893,6 +894,41 @@ typedef struct {
|
|||
QEMU_PLUGIN_API
|
||||
GArray *qemu_plugin_get_registers(void);
|
||||
|
||||
/**
|
||||
* qemu_plugin_read_register() - read register for current vCPU
|
||||
*
|
||||
* @handle: a @qemu_plugin_reg_handle handle
|
||||
* @buf: A GByteArray for the data owned by the plugin
|
||||
*
|
||||
* This function is only available in a context that register read access is
|
||||
* explicitly requested via the QEMU_PLUGIN_CB_R_REGS flag.
|
||||
*
|
||||
* Returns the size of the read register. The content of @buf is in target byte
|
||||
* order. On failure returns -1.
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
int qemu_plugin_read_register(struct qemu_plugin_register *handle,
|
||||
GByteArray *buf);
|
||||
|
||||
/**
|
||||
* qemu_plugin_write_register() - write register for current vCPU
|
||||
*
|
||||
* @handle: a @qemu_plugin_reg_handle handle
|
||||
* @buf: A GByteArray for the data owned by the plugin
|
||||
*
|
||||
* This function is only available in a context that register write access is
|
||||
* explicitly requested via the QEMU_PLUGIN_CB_RW_REGS flag.
|
||||
*
|
||||
* The size of @buf must be at least the size of the requested register.
|
||||
* Attempting to write a register with @buf smaller than the register size
|
||||
* will result in a crash or other undesired behavior.
|
||||
*
|
||||
* Returns the number of bytes written. On failure returns 0.
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
int qemu_plugin_write_register(struct qemu_plugin_register *handle,
|
||||
GByteArray *buf);
|
||||
|
||||
/**
|
||||
* qemu_plugin_read_memory_vaddr() - read from memory using a virtual address
|
||||
*
|
||||
|
@ -915,22 +951,6 @@ QEMU_PLUGIN_API
|
|||
bool qemu_plugin_read_memory_vaddr(uint64_t addr,
|
||||
GByteArray *data, size_t len);
|
||||
|
||||
/**
|
||||
* qemu_plugin_read_register() - read register for current vCPU
|
||||
*
|
||||
* @handle: a @qemu_plugin_reg_handle handle
|
||||
* @buf: A GByteArray for the data owned by the plugin
|
||||
*
|
||||
* This function is only available in a context that register read access is
|
||||
* explicitly requested via the QEMU_PLUGIN_CB_R_REGS flag.
|
||||
*
|
||||
* Returns the size of the read register. The content of @buf is in target byte
|
||||
* order. On failure returns -1.
|
||||
*/
|
||||
QEMU_PLUGIN_API
|
||||
int qemu_plugin_read_register(struct qemu_plugin_register *handle,
|
||||
GByteArray *buf);
|
||||
|
||||
/**
|
||||
* qemu_plugin_scoreboard_new() - alloc a new scoreboard
|
||||
*
|
||||
|
|
|
@ -433,6 +433,25 @@ GArray *qemu_plugin_get_registers(void)
|
|||
return create_register_handles(regs);
|
||||
}
|
||||
|
||||
int qemu_plugin_read_register(struct qemu_plugin_register *reg, GByteArray *buf)
|
||||
{
|
||||
g_assert(current_cpu);
|
||||
|
||||
return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg) - 1);
|
||||
}
|
||||
|
||||
int qemu_plugin_write_register(struct qemu_plugin_register *reg,
|
||||
GByteArray *buf)
|
||||
{
|
||||
g_assert(current_cpu);
|
||||
|
||||
if (buf->len == 0 || qemu_plugin_get_cb_flags() != QEMU_PLUGIN_CB_RW_REGS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return gdb_write_register(current_cpu, buf->data, GPOINTER_TO_INT(reg) - 1);
|
||||
}
|
||||
|
||||
bool qemu_plugin_read_memory_vaddr(uint64_t addr, GByteArray *data, size_t len)
|
||||
{
|
||||
g_assert(current_cpu);
|
||||
|
@ -453,13 +472,6 @@ bool qemu_plugin_read_memory_vaddr(uint64_t addr, GByteArray *data, size_t len)
|
|||
return true;
|
||||
}
|
||||
|
||||
int qemu_plugin_read_register(struct qemu_plugin_register *reg, GByteArray *buf)
|
||||
{
|
||||
g_assert(current_cpu);
|
||||
|
||||
return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg) - 1);
|
||||
}
|
||||
|
||||
struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_size)
|
||||
{
|
||||
return plugin_scoreboard_new(element_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue