1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* HPPA gdb server stub
*
* Copyright (c) 2016 Richard Henderson <rth@twiddle.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "cpu.h"
#include "exec/gdbstub.h"
int hppa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
{
HPPACPU *cpu = HPPA_CPU(cs);
CPUHPPAState *env = &cpu->env;
target_ureg val;
switch (n) {
case 0:
val = cpu_hppa_get_psw(env);
break;
case 1 ... 31:
val = env->gr[n];
break;
case 32:
val = env->cr[CR_SAR];
break;
case 33:
val = env->iaoq_f;
break;
case 35:
val = env->iaoq_b;
break;
case 59:
val = env->cr[26];
break;
case 60:
val = env->cr[27];
break;
case 64 ... 127:
val = extract64(env->fr[(n - 64) / 2], (n & 1 ? 0 : 32), 32);
break;
default:
if (n < 128) {
val = 0;
} else {
return 0;
}
break;
}
if (TARGET_REGISTER_BITS == 64) {
return gdb_get_reg64(mem_buf, val);
} else {
return gdb_get_reg32(mem_buf, val);
}
}
int hppa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
{
HPPACPU *cpu = HPPA_CPU(cs);
CPUHPPAState *env = &cpu->env;
target_ureg val;
if (TARGET_REGISTER_BITS == 64) {
val = ldq_p(mem_buf);
} else {
val = ldl_p(mem_buf);
}
switch (n) {
case 0:
cpu_hppa_put_psw(env, val);
break;
case 1 ... 31:
env->gr[n] = val;
break;
case 32:
env->cr[CR_SAR] = val;
break;
case 33:
env->iaoq_f = val;
break;
case 35:
env->iaoq_b = val;
break;
case 59:
env->cr[26] = val;
break;
case 60:
env->cr[27] = val;
break;
case 64:
env->fr[0] = deposit64(env->fr[0], 32, 32, val);
cpu_hppa_loaded_fr0(env);
break;
case 65 ... 127:
{
uint64_t *fr = &env->fr[(n - 64) / 2];
*fr = deposit64(*fr, val, (n & 1 ? 0 : 32), 32);
}
break;
default:
if (n >= 128) {
return 0;
}
break;
}
return sizeof(target_ureg);
}
|