]>
Commit | Line | Data |
---|---|---|
0980bfab AF |
1 | /* |
2 | * PowerPC 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 | /* Old gdb always expects FP registers. Newer (xml-aware) gdb only | |
22 | * expects whatever the target description contains. Due to a | |
23 | * historical mishap the FP registers appear in between core integer | |
24 | * regs and PC, MSR, CR, and so forth. We hack round this by giving the | |
25 | * FP regs zero size when talking to a newer gdb. | |
26 | */ | |
27 | ||
28 | static int cpu_gdb_read_register(CPUPPCState *env, uint8_t *mem_buf, int n) | |
29 | { | |
30 | if (n < 32) { | |
31 | /* gprs */ | |
32 | GET_REGL(env->gpr[n]); | |
33 | } else if (n < 64) { | |
34 | /* fprs */ | |
35 | if (gdb_has_xml) { | |
36 | return 0; | |
37 | } | |
38 | stfq_p(mem_buf, env->fpr[n-32]); | |
39 | return 8; | |
40 | } else { | |
41 | switch (n) { | |
42 | case 64: | |
43 | GET_REGL(env->nip); | |
44 | case 65: | |
45 | GET_REGL(env->msr); | |
46 | case 66: | |
47 | { | |
48 | uint32_t cr = 0; | |
49 | int i; | |
50 | for (i = 0; i < 8; i++) { | |
51 | cr |= env->crf[i] << (32 - ((i + 1) * 4)); | |
52 | } | |
53 | GET_REG32(cr); | |
54 | } | |
55 | case 67: | |
56 | GET_REGL(env->lr); | |
57 | case 68: | |
58 | GET_REGL(env->ctr); | |
59 | case 69: | |
60 | GET_REGL(env->xer); | |
61 | case 70: | |
62 | { | |
63 | if (gdb_has_xml) { | |
64 | return 0; | |
65 | } | |
66 | GET_REG32(env->fpscr); | |
67 | } | |
68 | } | |
69 | } | |
70 | return 0; | |
71 | } | |
72 | ||
73 | static int cpu_gdb_write_register(CPUPPCState *env, uint8_t *mem_buf, int n) | |
74 | { | |
75 | if (n < 32) { | |
76 | /* gprs */ | |
77 | env->gpr[n] = ldtul_p(mem_buf); | |
78 | return sizeof(target_ulong); | |
79 | } else if (n < 64) { | |
80 | /* fprs */ | |
81 | if (gdb_has_xml) { | |
82 | return 0; | |
83 | } | |
84 | env->fpr[n-32] = ldfq_p(mem_buf); | |
85 | return 8; | |
86 | } else { | |
87 | switch (n) { | |
88 | case 64: | |
89 | env->nip = ldtul_p(mem_buf); | |
90 | return sizeof(target_ulong); | |
91 | case 65: | |
92 | ppc_store_msr(env, ldtul_p(mem_buf)); | |
93 | return sizeof(target_ulong); | |
94 | case 66: | |
95 | { | |
96 | uint32_t cr = ldl_p(mem_buf); | |
97 | int i; | |
98 | for (i = 0; i < 8; i++) { | |
99 | env->crf[i] = (cr >> (32 - ((i + 1) * 4))) & 0xF; | |
100 | } | |
101 | return 4; | |
102 | } | |
103 | case 67: | |
104 | env->lr = ldtul_p(mem_buf); | |
105 | return sizeof(target_ulong); | |
106 | case 68: | |
107 | env->ctr = ldtul_p(mem_buf); | |
108 | return sizeof(target_ulong); | |
109 | case 69: | |
110 | env->xer = ldtul_p(mem_buf); | |
111 | return sizeof(target_ulong); | |
112 | case 70: | |
113 | /* fpscr */ | |
114 | if (gdb_has_xml) { | |
115 | return 0; | |
116 | } | |
117 | store_fpscr(env, ldtul_p(mem_buf), 0xffffffff); | |
118 | return sizeof(target_ulong); | |
119 | } | |
120 | } | |
121 | return 0; | |
122 | } |