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.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/>.
20 #include "qemu/osdep.h"
22 #include "exec/gdbstub.h"
24 int hppa_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
26 HPPACPU
*cpu
= HPPA_CPU(cs
);
27 CPUHPPAState
*env
= &cpu
->env
;
32 val
= cpu_hppa_get_psw(env
);
38 val
= env
->cr
[CR_SAR
];
44 val
= env
->iasq_f
>> 32;
50 val
= env
->iasq_b
>> 32;
53 val
= env
->cr
[CR_EIEM
];
56 val
= env
->cr
[CR_IIR
];
59 val
= env
->cr
[CR_ISR
];
62 val
= env
->cr
[CR_IOR
];
65 val
= env
->cr
[CR_IPSW
];
68 val
= env
->sr
[4] >> 32;
71 val
= env
->sr
[0] >> 32;
74 val
= env
->sr
[1] >> 32;
77 val
= env
->sr
[2] >> 32;
80 val
= env
->sr
[3] >> 32;
83 val
= env
->sr
[5] >> 32;
86 val
= env
->sr
[6] >> 32;
89 val
= env
->sr
[7] >> 32;
95 val
= env
->cr
[CR_PID1
];
98 val
= env
->cr
[CR_PID2
];
101 val
= env
->cr
[CR_SCRCCR
];
104 val
= env
->cr
[CR_PID3
];
107 val
= env
->cr
[CR_PID4
];
131 val
= extract64(env
->fr
[(n
- 64) / 2], (n
& 1 ? 0 : 32), 32);
142 if (TARGET_REGISTER_BITS
== 64) {
143 return gdb_get_reg64(mem_buf
, val
);
145 return gdb_get_reg32(mem_buf
, val
);
149 int hppa_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
151 HPPACPU
*cpu
= HPPA_CPU(cs
);
152 CPUHPPAState
*env
= &cpu
->env
;
155 if (TARGET_REGISTER_BITS
== 64) {
156 val
= ldq_p(mem_buf
);
158 val
= ldl_p(mem_buf
);
163 cpu_hppa_put_psw(env
, val
);
169 env
->cr
[CR_SAR
] = val
;
175 env
->iasq_f
= (uint64_t)val
<< 32;
181 env
->iasq_b
= (uint64_t)val
<< 32;
184 env
->cr
[CR_EIEM
] = val
;
187 env
->cr
[CR_IIR
] = val
;
190 env
->cr
[CR_ISR
] = val
;
193 env
->cr
[CR_IOR
] = val
;
196 env
->cr
[CR_IPSW
] = val
;
199 env
->sr
[4] = (uint64_t)val
<< 32;
202 env
->sr
[0] = (uint64_t)val
<< 32;
205 env
->sr
[1] = (uint64_t)val
<< 32;
208 env
->sr
[2] = (uint64_t)val
<< 32;
211 env
->sr
[3] = (uint64_t)val
<< 32;
214 env
->sr
[5] = (uint64_t)val
<< 32;
217 env
->sr
[6] = (uint64_t)val
<< 32;
220 env
->sr
[7] = (uint64_t)val
<< 32;
223 env
->cr
[CR_RC
] = val
;
226 env
->cr
[CR_PID1
] = val
;
227 cpu_hppa_change_prot_id(env
);
230 env
->cr
[CR_PID2
] = val
;
231 cpu_hppa_change_prot_id(env
);
234 env
->cr
[CR_SCRCCR
] = val
;
237 env
->cr
[CR_PID3
] = val
;
238 cpu_hppa_change_prot_id(env
);
241 env
->cr
[CR_PID4
] = val
;
242 cpu_hppa_change_prot_id(env
);
266 env
->fr
[0] = deposit64(env
->fr
[0], 32, 32, val
);
267 cpu_hppa_loaded_fr0(env
);
271 uint64_t *fr
= &env
->fr
[(n
- 64) / 2];
272 *fr
= deposit64(*fr
, (n
& 1 ? 0 : 32), 32, val
);
281 return sizeof(target_ureg
);