2 * ARM gdb server stub: AArch64 specific functions.
4 * Copyright (c) 2013 SUSE LINUX Products GmbH
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #include "qemu/osdep.h"
22 #include "internals.h"
23 #include "exec/gdbstub.h"
25 int aarch64_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
27 ARMCPU
*cpu
= ARM_CPU(cs
);
28 CPUARMState
*env
= &cpu
->env
;
31 /* Core integer register. */
32 return gdb_get_reg64(mem_buf
, env
->xregs
[n
]);
36 return gdb_get_reg64(mem_buf
, env
->xregs
[31]);
38 return gdb_get_reg64(mem_buf
, env
->pc
);
40 return gdb_get_reg32(mem_buf
, pstate_read(env
));
42 /* Unknown register. */
46 int aarch64_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
48 ARMCPU
*cpu
= ARM_CPU(cs
);
49 CPUARMState
*env
= &cpu
->env
;
55 /* Core integer register. */
68 pstate_write(env
, tmp
);
71 /* Unknown register. */
75 int aarch64_fpu_gdb_get_reg(CPUARMState
*env
, GByteArray
*buf
, int reg
)
80 /* 128 bit FP register - quads are in LE order */
81 uint64_t *q
= aa64_vfp_qreg(env
, reg
);
82 return gdb_get_reg128(buf
, q
[1], q
[0]);
86 return gdb_get_reg32(buf
, vfp_get_fpsr(env
));
89 return gdb_get_reg32(buf
, vfp_get_fpcr(env
));
95 int aarch64_fpu_gdb_set_reg(CPUARMState
*env
, uint8_t *buf
, int reg
)
99 /* 128 bit FP register */
101 uint64_t *q
= aa64_vfp_qreg(env
, reg
);
102 q
[0] = ldq_le_p(buf
);
103 q
[1] = ldq_le_p(buf
+ 8);
108 vfp_set_fpsr(env
, ldl_p(buf
));
112 vfp_set_fpcr(env
, ldl_p(buf
));
119 int arm_gdb_get_svereg(CPUARMState
*env
, GByteArray
*buf
, int reg
)
121 ARMCPU
*cpu
= env_archcpu(env
);
124 /* The first 32 registers are the zregs */
128 for (vq
= 0; vq
< cpu
->sve_max_vq
; vq
++) {
129 len
+= gdb_get_reg128(buf
,
130 env
->vfp
.zregs
[reg
].d
[vq
* 2 + 1],
131 env
->vfp
.zregs
[reg
].d
[vq
* 2]);
136 return gdb_get_reg32(buf
, vfp_get_fpsr(env
));
138 return gdb_get_reg32(buf
, vfp_get_fpcr(env
));
139 /* then 16 predicates and the ffr */
144 for (vq
= 0; vq
< cpu
->sve_max_vq
; vq
= vq
+ 4) {
145 len
+= gdb_get_reg64(buf
, env
->vfp
.pregs
[preg
].p
[vq
/ 4]);
152 * We report in Vector Granules (VG) which is 64bit in a Z reg
153 * while the ZCR works in Vector Quads (VQ) which is 128bit chunks.
155 int vq
= sve_vqm1_for_el(env
, arm_current_el(env
)) + 1;
156 return gdb_get_reg64(buf
, vq
* 2);
159 /* gdbstub asked for something out our range */
160 qemu_log_mask(LOG_UNIMP
, "%s: out of range register %d", __func__
, reg
);
167 int arm_gdb_set_svereg(CPUARMState
*env
, uint8_t *buf
, int reg
)
169 ARMCPU
*cpu
= env_archcpu(env
);
171 /* The first 32 registers are the zregs */
173 /* The first 32 registers are the zregs */
177 uint64_t *p
= (uint64_t *) buf
;
178 for (vq
= 0; vq
< cpu
->sve_max_vq
; vq
++) {
179 env
->vfp
.zregs
[reg
].d
[vq
* 2 + 1] = *p
++;
180 env
->vfp
.zregs
[reg
].d
[vq
* 2] = *p
++;
186 vfp_set_fpsr(env
, *(uint32_t *)buf
);
189 vfp_set_fpcr(env
, *(uint32_t *)buf
);
195 uint64_t *p
= (uint64_t *) buf
;
196 for (vq
= 0; vq
< cpu
->sve_max_vq
; vq
= vq
+ 4) {
197 env
->vfp
.pregs
[preg
].p
[vq
/ 4] = *p
++;
203 /* cannot set vg via gdbstub */
206 /* gdbstub asked for something out our range */