]>
Commit | Line | Data |
---|---|---|
61766fe9 RH |
1 | /* |
2 | * HPPA gdb server stub | |
3 | * | |
4 | * Copyright (c) 2016 Richard Henderson <[email protected]> | |
5 | * | |
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. | |
10 | * | |
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. | |
15 | * | |
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/>. | |
18 | */ | |
19 | ||
20 | #include "qemu/osdep.h" | |
21 | #include "qemu-common.h" | |
22 | #include "cpu.h" | |
23 | #include "exec/gdbstub.h" | |
24 | ||
25 | int hppa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) | |
26 | { | |
27 | HPPACPU *cpu = HPPA_CPU(cs); | |
28 | CPUHPPAState *env = &cpu->env; | |
29 | target_ulong val; | |
30 | ||
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; | |
61 | } | |
62 | break; | |
63 | } | |
64 | return gdb_get_regl(mem_buf, val); | |
65 | } | |
66 | ||
67 | int hppa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | |
68 | { | |
69 | HPPACPU *cpu = HPPA_CPU(cs); | |
70 | CPUHPPAState *env = &cpu->env; | |
71 | target_ulong val = ldtul_p(mem_buf); | |
72 | ||
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; | |
6836a8fb | 88 | break; |
61766fe9 RH |
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: | |
100 | { | |
101 | uint64_t *fr = &env->fr[(n - 64) / 2]; | |
102 | *fr = deposit64(*fr, val, (n & 1 ? 0 : 32), 32); | |
103 | } | |
104 | break; | |
105 | default: | |
106 | if (n >= 128) { | |
107 | return 0; | |
108 | } | |
109 | break; | |
110 | } | |
111 | return sizeof(target_ulong); | |
112 | } |