]> git.proxmox.com Git - qemu.git/blob - target-cris/gdbstub.c
target-cris: Move cpu_gdb_{read,write}_register()
[qemu.git] / target-cris / gdbstub.c
1 /*
2 * CRIS 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 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
21 static int
22 read_register_crisv10(CPUCRISState *env, uint8_t *mem_buf, int n)
23 {
24 if (n < 15) {
25 GET_REG32(env->regs[n]);
26 }
27
28 if (n == 15) {
29 GET_REG32(env->pc);
30 }
31
32 if (n < 32) {
33 switch (n) {
34 case 16:
35 GET_REG8(env->pregs[n - 16]);
36 case 17:
37 GET_REG8(env->pregs[n - 16]);
38 case 20:
39 case 21:
40 GET_REG16(env->pregs[n - 16]);
41 default:
42 if (n >= 23) {
43 GET_REG32(env->pregs[n - 16]);
44 }
45 break;
46 }
47 }
48 return 0;
49 }
50
51 static int cpu_gdb_read_register(CPUCRISState *env, uint8_t *mem_buf, int n)
52 {
53 uint8_t srs;
54
55 if (env->pregs[PR_VR] < 32) {
56 return read_register_crisv10(env, mem_buf, n);
57 }
58
59 srs = env->pregs[PR_SRS];
60 if (n < 16) {
61 GET_REG32(env->regs[n]);
62 }
63
64 if (n >= 21 && n < 32) {
65 GET_REG32(env->pregs[n - 16]);
66 }
67 if (n >= 33 && n < 49) {
68 GET_REG32(env->sregs[srs][n - 33]);
69 }
70 switch (n) {
71 case 16:
72 GET_REG8(env->pregs[0]);
73 case 17:
74 GET_REG8(env->pregs[1]);
75 case 18:
76 GET_REG32(env->pregs[2]);
77 case 19:
78 GET_REG8(srs);
79 case 20:
80 GET_REG16(env->pregs[4]);
81 case 32:
82 GET_REG32(env->pc);
83 }
84
85 return 0;
86 }
87
88 static int cpu_gdb_write_register(CPUCRISState *env, uint8_t *mem_buf, int n)
89 {
90 uint32_t tmp;
91
92 if (n > 49) {
93 return 0;
94 }
95
96 tmp = ldl_p(mem_buf);
97
98 if (n < 16) {
99 env->regs[n] = tmp;
100 }
101
102 if (n >= 21 && n < 32) {
103 env->pregs[n - 16] = tmp;
104 }
105
106 /* FIXME: Should support function regs be writable? */
107 switch (n) {
108 case 16:
109 return 1;
110 case 17:
111 return 1;
112 case 18:
113 env->pregs[PR_PID] = tmp;
114 break;
115 case 19:
116 return 1;
117 case 20:
118 return 2;
119 case 32:
120 env->pc = tmp;
121 break;
122 }
123
124 return 4;
125 }