4 * Copyright (c) 2003-2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #include "qemu/osdep.h"
27 #include "monitor/monitor.h"
28 #include "qemu/ctype.h"
29 #include "monitor/hmp-target.h"
30 #include "monitor/hmp.h"
32 static target_long
monitor_get_ccr(Monitor
*mon
, const struct MonitorDef
*md
,
35 CPUArchState
*env
= mon_get_cpu_env(mon
);
40 for (i
= 0; i
< 8; i
++) {
41 u
|= env
->crf
[i
] << (32 - (4 * (i
+ 1)));
47 static target_long
monitor_get_decr(Monitor
*mon
, const struct MonitorDef
*md
,
50 CPUArchState
*env
= mon_get_cpu_env(mon
);
51 return cpu_ppc_load_decr(env
);
54 static target_long
monitor_get_tbu(Monitor
*mon
, const struct MonitorDef
*md
,
57 CPUArchState
*env
= mon_get_cpu_env(mon
);
58 return cpu_ppc_load_tbu(env
);
61 static target_long
monitor_get_tbl(Monitor
*mon
, const struct MonitorDef
*md
,
64 CPUArchState
*env
= mon_get_cpu_env(mon
);
65 return cpu_ppc_load_tbl(env
);
68 void hmp_info_tlb(Monitor
*mon
, const QDict
*qdict
)
70 CPUArchState
*env1
= mon_get_cpu_env(mon
);
73 monitor_printf(mon
, "No CPU available\n");
79 const MonitorDef monitor_defs
[] = {
80 { "fpscr", offsetof(CPUPPCState
, fpscr
) },
81 /* Next instruction pointer */
82 { "nip|pc", offsetof(CPUPPCState
, nip
) },
83 { "lr", offsetof(CPUPPCState
, lr
) },
84 { "ctr", offsetof(CPUPPCState
, ctr
) },
85 { "decr", 0, &monitor_get_decr
, },
86 { "ccr|cr", 0, &monitor_get_ccr
, },
87 /* Machine state register */
88 { "xer", offsetof(CPUPPCState
, xer
) },
89 { "msr", offsetof(CPUPPCState
, msr
) },
90 { "tbu", 0, &monitor_get_tbu
, },
91 { "tbl", 0, &monitor_get_tbl
, },
95 const MonitorDef
*target_monitor_defs(void)
100 static int ppc_cpu_get_reg_num(const char *numstr
, int maxnum
, int *pregnum
)
109 regnum
= strtoul(numstr
, &endptr
, 10);
110 if (*endptr
|| (regnum
>= maxnum
)) {
118 int target_get_monitor_def(CPUState
*cs
, const char *name
, uint64_t *pval
)
121 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
122 CPUPPCState
*env
= &cpu
->env
;
124 /* General purpose registers */
125 if ((qemu_tolower(name
[0]) == 'r') &&
126 ppc_cpu_get_reg_num(name
+ 1, ARRAY_SIZE(env
->gpr
), ®num
)) {
127 *pval
= env
->gpr
[regnum
];
131 /* Floating point registers */
132 if ((qemu_tolower(name
[0]) == 'f') &&
133 ppc_cpu_get_reg_num(name
+ 1, 32, ®num
)) {
134 *pval
= *cpu_fpr_ptr(env
, regnum
);
138 /* Special purpose registers */
139 for (i
= 0; i
< ARRAY_SIZE(env
->spr_cb
); ++i
) {
140 ppc_spr_t
*spr
= &env
->spr_cb
[i
];
142 if (spr
->name
&& (strcasecmp(name
, spr
->name
) == 0)) {
148 /* Segment registers */
149 #if !defined(CONFIG_USER_ONLY)
150 if ((strncasecmp(name
, "sr", 2) == 0) &&
151 ppc_cpu_get_reg_num(name
+ 2, ARRAY_SIZE(env
->sr
), ®num
)) {
152 *pval
= env
->sr
[regnum
];