4 * Copyright (c) 2016 Richard Henderson <rth@twiddle.net>
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 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/>.
20 #include "qemu/osdep.h"
21 #include "qemu-common.h"
23 #include "exec/gdbstub.h"
25 int hppa_cpu_gdb_read_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
27 HPPACPU
*cpu
= HPPA_CPU(cs
);
28 CPUHPPAState
*env
= &cpu
->env
;
33 val
= cpu_hppa_get_psw(env
);
39 val
= env
->cr
[CR_SAR
];
45 val
= env
->iasq_f
>> 32;
51 val
= env
->iasq_b
>> 32;
54 val
= env
->cr
[CR_EIEM
];
57 val
= env
->cr
[CR_IIR
];
60 val
= env
->cr
[CR_ISR
];
63 val
= env
->cr
[CR_IOR
];
66 val
= env
->cr
[CR_IPSW
];
69 val
= env
->sr
[4] >> 32;
72 val
= env
->sr
[0] >> 32;
75 val
= env
->sr
[1] >> 32;
78 val
= env
->sr
[2] >> 32;
81 val
= env
->sr
[3] >> 32;
84 val
= env
->sr
[5] >> 32;
87 val
= env
->sr
[6] >> 32;
90 val
= env
->sr
[7] >> 32;
102 val
= env
->cr
[CR_SCRCCR
];
132 val
= extract64(env
->fr
[(n
- 64) / 2], (n
& 1 ? 0 : 32), 32);
143 if (TARGET_REGISTER_BITS
== 64) {
144 return gdb_get_reg64(mem_buf
, val
);
146 return gdb_get_reg32(mem_buf
, val
);
150 int hppa_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
152 HPPACPU
*cpu
= HPPA_CPU(cs
);
153 CPUHPPAState
*env
= &cpu
->env
;
156 if (TARGET_REGISTER_BITS
== 64) {
157 val
= ldq_p(mem_buf
);
159 val
= ldl_p(mem_buf
);
164 cpu_hppa_put_psw(env
, val
);
170 env
->cr
[CR_SAR
] = val
;
176 env
->iasq_f
= (uint64_t)val
<< 32;
182 env
->iasq_b
= (uint64_t)val
<< 32;
185 env
->cr
[CR_EIEM
] = val
;
188 env
->cr
[CR_IIR
] = val
;
191 env
->cr
[CR_ISR
] = val
;
194 env
->cr
[CR_IOR
] = val
;
197 env
->cr
[CR_IPSW
] = val
;
200 env
->sr
[4] = (uint64_t)val
<< 32;
203 env
->sr
[0] = (uint64_t)val
<< 32;
206 env
->sr
[1] = (uint64_t)val
<< 32;
209 env
->sr
[2] = (uint64_t)val
<< 32;
212 env
->sr
[3] = (uint64_t)val
<< 32;
215 env
->sr
[5] = (uint64_t)val
<< 32;
218 env
->sr
[6] = (uint64_t)val
<< 32;
221 env
->sr
[7] = (uint64_t)val
<< 32;
224 env
->cr
[CR_RC
] = val
;
233 env
->cr
[CR_SCRCCR
] = val
;
263 env
->fr
[0] = deposit64(env
->fr
[0], 32, 32, val
);
264 cpu_hppa_loaded_fr0(env
);
268 uint64_t *fr
= &env
->fr
[(n
- 64) / 2];
269 *fr
= deposit64(*fr
, val
, (n
& 1 ? 0 : 32), 32);
278 return sizeof(target_ureg
);