Merge remote-tracking branch 'remotes/yongbok/tags/mips-20170711' into staging
[qemu/ar7.git] / target / hppa / gdbstub.c
blobc37a56f238e2603a06408c9f8c5eaea3b0fa00c2
1 /*
2 * HPPA gdb server stub
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"
22 #include "cpu.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;
29 target_ulong val;
31 switch (n) {
32 case 0:
33 val = cpu_hppa_get_psw(env);
34 break;
35 case 1 ... 31:
36 val = env->gr[n];
37 break;
38 case 32:
39 val = env->sar;
40 break;
41 case 33:
42 val = env->iaoq_f;
43 break;
44 case 35:
45 val = env->iaoq_b;
46 break;
47 case 59:
48 val = env->cr26;
49 break;
50 case 60:
51 val = env->cr27;
52 break;
53 case 64 ... 127:
54 val = extract64(env->fr[(n - 64) / 2], (n & 1 ? 0 : 32), 32);
55 break;
56 default:
57 if (n < 128) {
58 val = 0;
59 } else {
60 return 0;
62 break;
64 return gdb_get_regl(mem_buf, val);
67 int hppa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
69 HPPACPU *cpu = HPPA_CPU(cs);
70 CPUHPPAState *env = &cpu->env;
71 target_ulong val = ldtul_p(mem_buf);
73 switch (n) {
74 case 0:
75 cpu_hppa_put_psw(env, val);
76 break;
77 case 1 ... 31:
78 env->gr[n] = val;
79 break;
80 case 32:
81 env->sar = val;
82 break;
83 case 33:
84 env->iaoq_f = val;
85 break;
86 case 35:
87 env->iaoq_b = val;
88 break;
89 case 59:
90 env->cr26 = val;
91 break;
92 case 60:
93 env->cr27 = val;
94 break;
95 case 64:
96 env->fr[0] = deposit64(env->fr[0], 32, 32, val);
97 cpu_hppa_loaded_fr0(env);
98 break;
99 case 65 ... 127:
101 uint64_t *fr = &env->fr[(n - 64) / 2];
102 *fr = deposit64(*fr, val, (n & 1 ? 0 : 32), 32);
104 break;
105 default:
106 if (n >= 128) {
107 return 0;
109 break;
111 return sizeof(target_ulong);