master
c 90 lines 2.32 KB
Raw
1 /*
2 * Alpha gdb server stub
3 *
4 * Copyright (c) 2003-2005 Fabrice Bellard
5 * Copyright (c) 2013 SUSE LINUX Products GmbH
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 */
20 #include "qemu/osdep.h"
21 #include "cpu.h"
22 #include "gdbstub/helpers.h"
23
24 int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
25 {
26 CPUAlphaState *env = cpu_env(cs);
27 uint64_t val;
28 CPU_DoubleU d;
29
30 switch (n) {
31 case 0 ... 30:
32 val = cpu_alpha_load_gr(env, n);
33 break;
34 case 31: /* zero register */
35 val = 0;
36 break;
37 case 32 ... 62:
38 d.d = env->fir[n - 32];
39 val = d.ll;
40 break;
41 case 63:
42 val = cpu_alpha_load_fpcr(env);
43 break;
44 case 64:
45 val = env->pc;
46 break;
47 case 65: /* former Virtual Register (reserved as unassigned) */
48 val = 0;
49 break;
50 case 66: /* PALcode Memory Slot */
51 val = env->unique;
52 break;
53 default:
54 return 0;
55 }
56 return gdb_get_reg64(mem_buf, val);
57 }
58
59 int alpha_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
60 {
61 CPUAlphaState *env = cpu_env(cs);
62 uint64_t tmp = ldq_le_p(mem_buf);
63 CPU_DoubleU d;
64
65 switch (n) {
66 case 0 ... 30:
67 cpu_alpha_store_gr(env, n, tmp);
68 break;
69 case 31: /* zero register */
70 break;
71 case 32 ... 62:
72 d.ll = tmp;
73 env->fir[n - 32] = d.d;
74 break;
75 case 63:
76 cpu_alpha_store_fpcr(env, tmp);
77 break;
78 case 64:
79 env->pc = tmp;
80 break;
81 case 65: /* former Virtual Register (reserved as unassigned) */
82 break;
83 case 66: /* PALcode Memory Slot */
84 env->unique = tmp;
85 break;
86 default:
87 return 0;
88 }
89 return 8;
90 }