mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb
Align the parameters of gdb_get_reg_cb and gdb_set_reg_cb with the gdb_read_register and gdb_write_register members of CPUClass to allow to unify the logic to access registers of the core and coprocessors in the future. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-6-777047380591@daynix.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20240227144335.1196131-11-alex.bennee@linaro.org>
This commit is contained in:
parent
c494f8f529
commit
66260159a7
14 changed files with 238 additions and 93 deletions
|
@ -108,8 +108,11 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
|
|||
return length;
|
||||
}
|
||||
|
||||
static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n)
|
||||
static int riscv_gdb_get_fpu(CPUState *cs, GByteArray *buf, int n)
|
||||
{
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
|
||||
if (n < 32) {
|
||||
if (env->misa_ext & RVD) {
|
||||
return gdb_get_reg64(buf, env->fpr[n]);
|
||||
|
@ -121,8 +124,11 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)
|
||||
static int riscv_gdb_set_fpu(CPUState *cs, uint8_t *mem_buf, int n)
|
||||
{
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
|
||||
if (n < 32) {
|
||||
env->fpr[n] = ldq_p(mem_buf); /* always 64-bit */
|
||||
return sizeof(uint64_t);
|
||||
|
@ -130,9 +136,11 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_get_vector(CPURISCVState *env, GByteArray *buf, int n)
|
||||
static int riscv_gdb_get_vector(CPUState *cs, GByteArray *buf, int n)
|
||||
{
|
||||
uint16_t vlenb = riscv_cpu_cfg(env)->vlenb;
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
uint16_t vlenb = cpu->cfg.vlenb;
|
||||
if (n < 32) {
|
||||
int i;
|
||||
int cnt = 0;
|
||||
|
@ -146,9 +154,11 @@ static int riscv_gdb_get_vector(CPURISCVState *env, GByteArray *buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_set_vector(CPURISCVState *env, uint8_t *mem_buf, int n)
|
||||
static int riscv_gdb_set_vector(CPUState *cs, uint8_t *mem_buf, int n)
|
||||
{
|
||||
uint16_t vlenb = riscv_cpu_cfg(env)->vlenb;
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
uint16_t vlenb = cpu->cfg.vlenb;
|
||||
if (n < 32) {
|
||||
int i;
|
||||
for (i = 0; i < vlenb; i += 8) {
|
||||
|
@ -160,8 +170,11 @@ static int riscv_gdb_set_vector(CPURISCVState *env, uint8_t *mem_buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n)
|
||||
static int riscv_gdb_get_csr(CPUState *cs, GByteArray *buf, int n)
|
||||
{
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
|
||||
if (n < CSR_TABLE_SIZE) {
|
||||
target_ulong val = 0;
|
||||
int result;
|
||||
|
@ -174,8 +187,11 @@ static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n)
|
||||
static int riscv_gdb_set_csr(CPUState *cs, uint8_t *mem_buf, int n)
|
||||
{
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
|
||||
if (n < CSR_TABLE_SIZE) {
|
||||
target_ulong val = ldtul_p(mem_buf);
|
||||
int result;
|
||||
|
@ -188,25 +204,31 @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n)
|
||||
static int riscv_gdb_get_virtual(CPUState *cs, GByteArray *buf, int n)
|
||||
{
|
||||
if (n == 0) {
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
return gdb_get_regl(buf, 0);
|
||||
#else
|
||||
return gdb_get_regl(buf, cs->priv);
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
|
||||
return gdb_get_regl(buf, env->priv);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int riscv_gdb_set_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n)
|
||||
static int riscv_gdb_set_virtual(CPUState *cs, uint8_t *mem_buf, int n)
|
||||
{
|
||||
if (n == 0) {
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
cs->priv = ldtul_p(mem_buf) & 0x3;
|
||||
if (cs->priv == PRV_RESERVED) {
|
||||
cs->priv = PRV_S;
|
||||
RISCVCPU *cpu = RISCV_CPU(cs);
|
||||
CPURISCVState *env = &cpu->env;
|
||||
|
||||
env->priv = ldtul_p(mem_buf) & 0x3;
|
||||
if (env->priv == PRV_RESERVED) {
|
||||
env->priv = PRV_S;
|
||||
}
|
||||
#endif
|
||||
return sizeof(target_ulong);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue