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