xref: /openbmc/qemu/target/alpha/gdbstub.c (revision f2a4459d)
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 32 ... 62:
35         d.d = env->fir[n - 32];
36         val = d.ll;
37         break;
38     case 63:
39         val = cpu_alpha_load_fpcr(env);
40         break;
41     case 64:
42         val = env->pc;
43         break;
44     case 66:
45         val = env->unique;
46         break;
47     case 31:
48     case 65:
49         /* 31 really is the zero register; 65 is unassigned in the
50            gdb protocol, but is still required to occupy 8 bytes. */
51         val = 0;
52         break;
53     default:
54         return 0;
55     }
56     return gdb_get_regl(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     target_ulong tmp = ldtul_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 32 ... 62:
70         d.ll = tmp;
71         env->fir[n - 32] = d.d;
72         break;
73     case 63:
74         cpu_alpha_store_fpcr(env, tmp);
75         break;
76     case 64:
77         env->pc = tmp;
78         break;
79     case 66:
80         env->unique = tmp;
81         break;
82     case 31:
83     case 65:
84         /* 31 really is the zero register; 65 is unassigned in the
85            gdb protocol, but is still required to occupy 8 bytes. */
86         break;
87     default:
88         return 0;
89     }
90     return 8;
91 }
92