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 "gdbstub/helpers.h"
25 * GDB 15 only supports PA1.0 via the remote protocol, and ignores
26 * any provided xml. Which means that any attempt to provide more
27 * data results in "Remote 'g' packet reply is too long".
30 int hppa_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
32 CPUHPPAState
*env
= cpu_env(cs
);
37 val
= cpu_hppa_get_psw(env
);
43 val
= env
->cr
[CR_SAR
];
49 val
= env
->iasq_f
>> 32;
55 val
= env
->iasq_b
>> 32;
58 val
= env
->cr
[CR_EIEM
];
61 val
= env
->cr
[CR_IIR
];
64 val
= env
->cr
[CR_ISR
];
67 val
= env
->cr
[CR_IOR
];
70 val
= env
->cr
[CR_IPSW
];
73 val
= env
->sr
[4] >> 32;
76 val
= env
->sr
[0] >> 32;
79 val
= env
->sr
[1] >> 32;
82 val
= env
->sr
[2] >> 32;
85 val
= env
->sr
[3] >> 32;
88 val
= env
->sr
[5] >> 32;
91 val
= env
->sr
[6] >> 32;
94 val
= env
->sr
[7] >> 32;
100 val
= env
->cr
[CR_PID1
];
103 val
= env
->cr
[CR_PID2
];
106 val
= env
->cr
[CR_SCRCCR
];
109 val
= env
->cr
[CR_PID3
];
112 val
= env
->cr
[CR_PID4
];
136 val
= extract64(env
->fr
[(n
- 64) / 2], (n
& 1 ? 0 : 32), 32);
147 return gdb_get_reg32(mem_buf
, val
);
150 int hppa_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
152 CPUHPPAState
*env
= cpu_env(cs
);
153 uint32_t val
= ldl_p(mem_buf
);
157 cpu_hppa_put_psw(env
, val
);
163 env
->cr
[CR_SAR
] = val
& (hppa_is_pa20(env
) ? 63 : 31);
166 #ifdef CONFIG_USER_ONLY
172 env
->iasq_f
= (uint64_t)val
<< 32;
175 #ifdef CONFIG_USER_ONLY
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
);