root / monitor.c @ 4870852c
History | View | Annotate | Download (88 kB)
1 | 9dc39cba | bellard | /*
|
---|---|---|---|
2 | 9dc39cba | bellard | * QEMU monitor
|
3 | 5fafdf24 | ths | *
|
4 | 9dc39cba | bellard | * Copyright (c) 2003-2004 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | 9dc39cba | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 9dc39cba | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 9dc39cba | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 9dc39cba | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 9dc39cba | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 9dc39cba | bellard | * furnished to do so, subject to the following conditions:
|
12 | 9dc39cba | bellard | *
|
13 | 9dc39cba | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 9dc39cba | bellard | * all copies or substantial portions of the Software.
|
15 | 9dc39cba | bellard | *
|
16 | 9dc39cba | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 9dc39cba | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 9dc39cba | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 9dc39cba | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 9dc39cba | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 9dc39cba | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 9dc39cba | bellard | * THE SOFTWARE.
|
23 | 9dc39cba | bellard | */
|
24 | 511d2b14 | blueswir1 | #include <dirent.h> |
25 | 87ecb68b | pbrook | #include "hw/hw.h" |
26 | 87ecb68b | pbrook | #include "hw/usb.h" |
27 | 87ecb68b | pbrook | #include "hw/pcmcia.h" |
28 | 87ecb68b | pbrook | #include "hw/pc.h" |
29 | 87ecb68b | pbrook | #include "hw/pci.h" |
30 | 87ecb68b | pbrook | #include "gdbstub.h" |
31 | 87ecb68b | pbrook | #include "net.h" |
32 | 87ecb68b | pbrook | #include "qemu-char.h" |
33 | 87ecb68b | pbrook | #include "sysemu.h" |
34 | 376253ec | aliguori | #include "monitor.h" |
35 | 376253ec | aliguori | #include "readline.h" |
36 | 87ecb68b | pbrook | #include "console.h" |
37 | 87ecb68b | pbrook | #include "block.h" |
38 | 87ecb68b | pbrook | #include "audio/audio.h" |
39 | 9307c4c1 | bellard | #include "disas.h" |
40 | df751fa8 | aliguori | #include "balloon.h" |
41 | c8256f9d | balrog | #include "qemu-timer.h" |
42 | 5bb7910a | aliguori | #include "migration.h" |
43 | 7ba1e619 | aliguori | #include "kvm.h" |
44 | 76655d6d | aliguori | #include "acl.h" |
45 | 6a5bd307 | ths | |
46 | 9dc39cba | bellard | //#define DEBUG
|
47 | 81d0912d | bellard | //#define DEBUG_COMPLETION
|
48 | 9dc39cba | bellard | |
49 | 9307c4c1 | bellard | /*
|
50 | 9307c4c1 | bellard | * Supported types:
|
51 | 5fafdf24 | ths | *
|
52 | 9307c4c1 | bellard | * 'F' filename
|
53 | 81d0912d | bellard | * 'B' block device name
|
54 | 9307c4c1 | bellard | * 's' string (accept optional quote)
|
55 | 92a31b1f | bellard | * 'i' 32 bit integer
|
56 | 92a31b1f | bellard | * 'l' target long (32 or 64 bit)
|
57 | 9307c4c1 | bellard | * '/' optional gdb-like print format (like "/10x")
|
58 | 9307c4c1 | bellard | *
|
59 | 9307c4c1 | bellard | * '?' optional type (for 'F', 's' and 'i')
|
60 | 9307c4c1 | bellard | *
|
61 | 9307c4c1 | bellard | */
|
62 | 9307c4c1 | bellard | |
63 | 376253ec | aliguori | typedef struct mon_cmd_t { |
64 | 9dc39cba | bellard | const char *name; |
65 | 9307c4c1 | bellard | const char *args_type; |
66 | a5f1b965 | blueswir1 | void *handler;
|
67 | 9dc39cba | bellard | const char *params; |
68 | 9dc39cba | bellard | const char *help; |
69 | 376253ec | aliguori | } mon_cmd_t; |
70 | 9dc39cba | bellard | |
71 | 87127161 | aliguori | struct Monitor {
|
72 | 87127161 | aliguori | CharDriverState *chr; |
73 | 731b0364 | aliguori | int flags;
|
74 | 731b0364 | aliguori | int suspend_cnt;
|
75 | 731b0364 | aliguori | uint8_t outbuf[1024];
|
76 | 731b0364 | aliguori | int outbuf_index;
|
77 | 731b0364 | aliguori | ReadLineState *rs; |
78 | 731b0364 | aliguori | CPUState *mon_cpu; |
79 | 731b0364 | aliguori | BlockDriverCompletionFunc *password_completion_cb; |
80 | 731b0364 | aliguori | void *password_opaque;
|
81 | 87127161 | aliguori | LIST_ENTRY(Monitor) entry; |
82 | 87127161 | aliguori | }; |
83 | 87127161 | aliguori | |
84 | 87127161 | aliguori | static LIST_HEAD(mon_list, Monitor) mon_list;
|
85 | 7e2515e8 | bellard | |
86 | 376253ec | aliguori | static const mon_cmd_t mon_cmds[]; |
87 | 376253ec | aliguori | static const mon_cmd_t info_cmds[]; |
88 | 9dc39cba | bellard | |
89 | 87127161 | aliguori | Monitor *cur_mon = NULL;
|
90 | 376253ec | aliguori | |
91 | 731b0364 | aliguori | static void monitor_command_cb(Monitor *mon, const char *cmdline, |
92 | 731b0364 | aliguori | void *opaque);
|
93 | 83ab7950 | aliguori | |
94 | 731b0364 | aliguori | static void monitor_read_command(Monitor *mon, int show_prompt) |
95 | 731b0364 | aliguori | { |
96 | 731b0364 | aliguori | readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL); |
97 | 731b0364 | aliguori | if (show_prompt)
|
98 | 731b0364 | aliguori | readline_show_prompt(mon->rs); |
99 | 731b0364 | aliguori | } |
100 | 6a00d601 | bellard | |
101 | cde76ee1 | aliguori | static int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, |
102 | cde76ee1 | aliguori | void *opaque)
|
103 | bb5fc20f | aliguori | { |
104 | cde76ee1 | aliguori | if (mon->rs) {
|
105 | cde76ee1 | aliguori | readline_start(mon->rs, "Password: ", 1, readline_func, opaque); |
106 | cde76ee1 | aliguori | /* prompt is printed on return from the command handler */
|
107 | cde76ee1 | aliguori | return 0; |
108 | cde76ee1 | aliguori | } else {
|
109 | cde76ee1 | aliguori | monitor_printf(mon, "terminal does not support password prompting\n");
|
110 | cde76ee1 | aliguori | return -ENOTTY;
|
111 | cde76ee1 | aliguori | } |
112 | bb5fc20f | aliguori | } |
113 | bb5fc20f | aliguori | |
114 | 376253ec | aliguori | void monitor_flush(Monitor *mon)
|
115 | 7e2515e8 | bellard | { |
116 | 731b0364 | aliguori | if (mon && mon->outbuf_index != 0 && mon->chr->focus == 0) { |
117 | 731b0364 | aliguori | qemu_chr_write(mon->chr, mon->outbuf, mon->outbuf_index); |
118 | 731b0364 | aliguori | mon->outbuf_index = 0;
|
119 | 7e2515e8 | bellard | } |
120 | 7e2515e8 | bellard | } |
121 | 7e2515e8 | bellard | |
122 | 7e2515e8 | bellard | /* flush at every end of line or if the buffer is full */
|
123 | 376253ec | aliguori | static void monitor_puts(Monitor *mon, const char *str) |
124 | 7e2515e8 | bellard | { |
125 | 60fe76f3 | ths | char c;
|
126 | 731b0364 | aliguori | |
127 | 731b0364 | aliguori | if (!mon)
|
128 | 731b0364 | aliguori | return;
|
129 | 731b0364 | aliguori | |
130 | 7e2515e8 | bellard | for(;;) {
|
131 | 7e2515e8 | bellard | c = *str++; |
132 | 7e2515e8 | bellard | if (c == '\0') |
133 | 7e2515e8 | bellard | break;
|
134 | 7ba1260a | bellard | if (c == '\n') |
135 | 731b0364 | aliguori | mon->outbuf[mon->outbuf_index++] = '\r';
|
136 | 731b0364 | aliguori | mon->outbuf[mon->outbuf_index++] = c; |
137 | 731b0364 | aliguori | if (mon->outbuf_index >= (sizeof(mon->outbuf) - 1) |
138 | 731b0364 | aliguori | || c == '\n')
|
139 | 376253ec | aliguori | monitor_flush(mon); |
140 | 7e2515e8 | bellard | } |
141 | 7e2515e8 | bellard | } |
142 | 7e2515e8 | bellard | |
143 | 376253ec | aliguori | void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) |
144 | 9dc39cba | bellard | { |
145 | 81d0912d | bellard | char buf[4096]; |
146 | 81d0912d | bellard | vsnprintf(buf, sizeof(buf), fmt, ap);
|
147 | 376253ec | aliguori | monitor_puts(mon, buf); |
148 | 9dc39cba | bellard | } |
149 | 9dc39cba | bellard | |
150 | 376253ec | aliguori | void monitor_printf(Monitor *mon, const char *fmt, ...) |
151 | 9dc39cba | bellard | { |
152 | 7e2515e8 | bellard | va_list ap; |
153 | 7e2515e8 | bellard | va_start(ap, fmt); |
154 | 376253ec | aliguori | monitor_vprintf(mon, fmt, ap); |
155 | 7e2515e8 | bellard | va_end(ap); |
156 | 9dc39cba | bellard | } |
157 | 9dc39cba | bellard | |
158 | 376253ec | aliguori | void monitor_print_filename(Monitor *mon, const char *filename) |
159 | fef30743 | ths | { |
160 | fef30743 | ths | int i;
|
161 | fef30743 | ths | |
162 | fef30743 | ths | for (i = 0; filename[i]; i++) { |
163 | 28a76be8 | aliguori | switch (filename[i]) {
|
164 | 28a76be8 | aliguori | case ' ': |
165 | 28a76be8 | aliguori | case '"': |
166 | 28a76be8 | aliguori | case '\\': |
167 | 28a76be8 | aliguori | monitor_printf(mon, "\\%c", filename[i]);
|
168 | 28a76be8 | aliguori | break;
|
169 | 28a76be8 | aliguori | case '\t': |
170 | 28a76be8 | aliguori | monitor_printf(mon, "\\t");
|
171 | 28a76be8 | aliguori | break;
|
172 | 28a76be8 | aliguori | case '\r': |
173 | 28a76be8 | aliguori | monitor_printf(mon, "\\r");
|
174 | 28a76be8 | aliguori | break;
|
175 | 28a76be8 | aliguori | case '\n': |
176 | 28a76be8 | aliguori | monitor_printf(mon, "\\n");
|
177 | 28a76be8 | aliguori | break;
|
178 | 28a76be8 | aliguori | default:
|
179 | 28a76be8 | aliguori | monitor_printf(mon, "%c", filename[i]);
|
180 | 28a76be8 | aliguori | break;
|
181 | 28a76be8 | aliguori | } |
182 | fef30743 | ths | } |
183 | fef30743 | ths | } |
184 | fef30743 | ths | |
185 | 7fe48483 | bellard | static int monitor_fprintf(FILE *stream, const char *fmt, ...) |
186 | 7fe48483 | bellard | { |
187 | 7fe48483 | bellard | va_list ap; |
188 | 7fe48483 | bellard | va_start(ap, fmt); |
189 | 376253ec | aliguori | monitor_vprintf((Monitor *)stream, fmt, ap); |
190 | 7fe48483 | bellard | va_end(ap); |
191 | 7fe48483 | bellard | return 0; |
192 | 7fe48483 | bellard | } |
193 | 7fe48483 | bellard | |
194 | 9dc39cba | bellard | static int compare_cmd(const char *name, const char *list) |
195 | 9dc39cba | bellard | { |
196 | 9dc39cba | bellard | const char *p, *pstart; |
197 | 9dc39cba | bellard | int len;
|
198 | 9dc39cba | bellard | len = strlen(name); |
199 | 9dc39cba | bellard | p = list; |
200 | 9dc39cba | bellard | for(;;) {
|
201 | 9dc39cba | bellard | pstart = p; |
202 | 9dc39cba | bellard | p = strchr(p, '|');
|
203 | 9dc39cba | bellard | if (!p)
|
204 | 9dc39cba | bellard | p = pstart + strlen(pstart); |
205 | 9dc39cba | bellard | if ((p - pstart) == len && !memcmp(pstart, name, len))
|
206 | 9dc39cba | bellard | return 1; |
207 | 9dc39cba | bellard | if (*p == '\0') |
208 | 9dc39cba | bellard | break;
|
209 | 9dc39cba | bellard | p++; |
210 | 9dc39cba | bellard | } |
211 | 9dc39cba | bellard | return 0; |
212 | 9dc39cba | bellard | } |
213 | 9dc39cba | bellard | |
214 | 376253ec | aliguori | static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds, |
215 | 376253ec | aliguori | const char *prefix, const char *name) |
216 | 9dc39cba | bellard | { |
217 | 376253ec | aliguori | const mon_cmd_t *cmd;
|
218 | 9dc39cba | bellard | |
219 | 9dc39cba | bellard | for(cmd = cmds; cmd->name != NULL; cmd++) { |
220 | 9dc39cba | bellard | if (!name || !strcmp(name, cmd->name))
|
221 | 376253ec | aliguori | monitor_printf(mon, "%s%s %s -- %s\n", prefix, cmd->name,
|
222 | 376253ec | aliguori | cmd->params, cmd->help); |
223 | 9dc39cba | bellard | } |
224 | 9dc39cba | bellard | } |
225 | 9dc39cba | bellard | |
226 | 376253ec | aliguori | static void help_cmd(Monitor *mon, const char *name) |
227 | 9dc39cba | bellard | { |
228 | 9dc39cba | bellard | if (name && !strcmp(name, "info")) { |
229 | 376253ec | aliguori | help_cmd_dump(mon, info_cmds, "info ", NULL); |
230 | 9dc39cba | bellard | } else {
|
231 | 376253ec | aliguori | help_cmd_dump(mon, mon_cmds, "", name);
|
232 | f193c797 | bellard | if (name && !strcmp(name, "log")) { |
233 | 8662d656 | blueswir1 | const CPULogItem *item;
|
234 | 376253ec | aliguori | monitor_printf(mon, "Log items (comma separated):\n");
|
235 | 376253ec | aliguori | monitor_printf(mon, "%-10s %s\n", "none", "remove all logs"); |
236 | f193c797 | bellard | for(item = cpu_log_items; item->mask != 0; item++) { |
237 | 376253ec | aliguori | monitor_printf(mon, "%-10s %s\n", item->name, item->help);
|
238 | f193c797 | bellard | } |
239 | f193c797 | bellard | } |
240 | 9dc39cba | bellard | } |
241 | 9dc39cba | bellard | } |
242 | 9dc39cba | bellard | |
243 | 376253ec | aliguori | static void do_commit(Monitor *mon, const char *device) |
244 | 9dc39cba | bellard | { |
245 | 7954c734 | bellard | int i, all_devices;
|
246 | 2dc7b602 | balrog | |
247 | 7954c734 | bellard | all_devices = !strcmp(device, "all");
|
248 | e4bcb14c | ths | for (i = 0; i < nb_drives; i++) { |
249 | 5fafdf24 | ths | if (all_devices ||
|
250 | e4bcb14c | ths | !strcmp(bdrv_get_device_name(drives_table[i].bdrv), device)) |
251 | e4bcb14c | ths | bdrv_commit(drives_table[i].bdrv); |
252 | 9dc39cba | bellard | } |
253 | 9dc39cba | bellard | } |
254 | 9dc39cba | bellard | |
255 | 376253ec | aliguori | static void do_info(Monitor *mon, const char *item) |
256 | 9dc39cba | bellard | { |
257 | 376253ec | aliguori | const mon_cmd_t *cmd;
|
258 | 376253ec | aliguori | void (*handler)(Monitor *);
|
259 | 9dc39cba | bellard | |
260 | 9307c4c1 | bellard | if (!item)
|
261 | 9dc39cba | bellard | goto help;
|
262 | 9dc39cba | bellard | for(cmd = info_cmds; cmd->name != NULL; cmd++) { |
263 | 5fafdf24 | ths | if (compare_cmd(item, cmd->name))
|
264 | 9dc39cba | bellard | goto found;
|
265 | 9dc39cba | bellard | } |
266 | 9dc39cba | bellard | help:
|
267 | 376253ec | aliguori | help_cmd(mon, "info");
|
268 | 9dc39cba | bellard | return;
|
269 | 9dc39cba | bellard | found:
|
270 | a5f1b965 | blueswir1 | handler = cmd->handler; |
271 | 376253ec | aliguori | handler(mon); |
272 | 9dc39cba | bellard | } |
273 | 9dc39cba | bellard | |
274 | 376253ec | aliguori | static void do_info_version(Monitor *mon) |
275 | 9bc9d1c7 | bellard | { |
276 | 4a19f1ec | pbrook | monitor_printf(mon, "%s\n", QEMU_VERSION QEMU_PKGVERSION);
|
277 | 9bc9d1c7 | bellard | } |
278 | 9bc9d1c7 | bellard | |
279 | 376253ec | aliguori | static void do_info_name(Monitor *mon) |
280 | c35734b2 | ths | { |
281 | c35734b2 | ths | if (qemu_name)
|
282 | 376253ec | aliguori | monitor_printf(mon, "%s\n", qemu_name);
|
283 | c35734b2 | ths | } |
284 | c35734b2 | ths | |
285 | bf4f74c0 | aurel32 | #if defined(TARGET_I386)
|
286 | 376253ec | aliguori | static void do_info_hpet(Monitor *mon) |
287 | 16b29ae1 | aliguori | { |
288 | 376253ec | aliguori | monitor_printf(mon, "HPET is %s by QEMU\n",
|
289 | 376253ec | aliguori | (no_hpet) ? "disabled" : "enabled"); |
290 | 16b29ae1 | aliguori | } |
291 | bf4f74c0 | aurel32 | #endif
|
292 | 16b29ae1 | aliguori | |
293 | 376253ec | aliguori | static void do_info_uuid(Monitor *mon) |
294 | a36e69dd | ths | { |
295 | 376253ec | aliguori | monitor_printf(mon, UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1], |
296 | 376253ec | aliguori | qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], |
297 | 376253ec | aliguori | qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], |
298 | 376253ec | aliguori | qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], |
299 | 376253ec | aliguori | qemu_uuid[14], qemu_uuid[15]); |
300 | a36e69dd | ths | } |
301 | a36e69dd | ths | |
302 | 6a00d601 | bellard | /* get the current CPU defined by the user */
|
303 | 9596ebb7 | pbrook | static int mon_set_cpu(int cpu_index) |
304 | 6a00d601 | bellard | { |
305 | 6a00d601 | bellard | CPUState *env; |
306 | 6a00d601 | bellard | |
307 | 6a00d601 | bellard | for(env = first_cpu; env != NULL; env = env->next_cpu) { |
308 | 6a00d601 | bellard | if (env->cpu_index == cpu_index) {
|
309 | 731b0364 | aliguori | cur_mon->mon_cpu = env; |
310 | 6a00d601 | bellard | return 0; |
311 | 6a00d601 | bellard | } |
312 | 6a00d601 | bellard | } |
313 | 6a00d601 | bellard | return -1; |
314 | 6a00d601 | bellard | } |
315 | 6a00d601 | bellard | |
316 | 9596ebb7 | pbrook | static CPUState *mon_get_cpu(void) |
317 | 6a00d601 | bellard | { |
318 | 731b0364 | aliguori | if (!cur_mon->mon_cpu) {
|
319 | 6a00d601 | bellard | mon_set_cpu(0);
|
320 | 6a00d601 | bellard | } |
321 | d154615d | aliguori | cpu_synchronize_state(cur_mon->mon_cpu, 0);
|
322 | 731b0364 | aliguori | return cur_mon->mon_cpu;
|
323 | 6a00d601 | bellard | } |
324 | 6a00d601 | bellard | |
325 | 376253ec | aliguori | static void do_info_registers(Monitor *mon) |
326 | 9307c4c1 | bellard | { |
327 | 6a00d601 | bellard | CPUState *env; |
328 | 6a00d601 | bellard | env = mon_get_cpu(); |
329 | 6a00d601 | bellard | if (!env)
|
330 | 6a00d601 | bellard | return;
|
331 | 9307c4c1 | bellard | #ifdef TARGET_I386
|
332 | 376253ec | aliguori | cpu_dump_state(env, (FILE *)mon, monitor_fprintf, |
333 | d24b15a8 | bellard | X86_DUMP_FPU); |
334 | 9307c4c1 | bellard | #else
|
335 | 376253ec | aliguori | cpu_dump_state(env, (FILE *)mon, monitor_fprintf, |
336 | 7fe48483 | bellard | 0);
|
337 | 9307c4c1 | bellard | #endif
|
338 | 9307c4c1 | bellard | } |
339 | 9307c4c1 | bellard | |
340 | 376253ec | aliguori | static void do_info_cpus(Monitor *mon) |
341 | 6a00d601 | bellard | { |
342 | 6a00d601 | bellard | CPUState *env; |
343 | 6a00d601 | bellard | |
344 | 6a00d601 | bellard | /* just to set the default cpu if not already done */
|
345 | 6a00d601 | bellard | mon_get_cpu(); |
346 | 6a00d601 | bellard | |
347 | 6a00d601 | bellard | for(env = first_cpu; env != NULL; env = env->next_cpu) { |
348 | d154615d | aliguori | cpu_synchronize_state(env, 0);
|
349 | 376253ec | aliguori | monitor_printf(mon, "%c CPU #%d:",
|
350 | 731b0364 | aliguori | (env == mon->mon_cpu) ? '*' : ' ', |
351 | 376253ec | aliguori | env->cpu_index); |
352 | 6a00d601 | bellard | #if defined(TARGET_I386)
|
353 | 376253ec | aliguori | monitor_printf(mon, " pc=0x" TARGET_FMT_lx,
|
354 | 376253ec | aliguori | env->eip + env->segs[R_CS].base); |
355 | e80e1cc4 | bellard | #elif defined(TARGET_PPC)
|
356 | 376253ec | aliguori | monitor_printf(mon, " nip=0x" TARGET_FMT_lx, env->nip);
|
357 | ba3c64fb | bellard | #elif defined(TARGET_SPARC)
|
358 | 376253ec | aliguori | monitor_printf(mon, " pc=0x" TARGET_FMT_lx " npc=0x" TARGET_FMT_lx, |
359 | 376253ec | aliguori | env->pc, env->npc); |
360 | ead9360e | ths | #elif defined(TARGET_MIPS)
|
361 | 376253ec | aliguori | monitor_printf(mon, " PC=0x" TARGET_FMT_lx, env->active_tc.PC);
|
362 | ce5232c5 | bellard | #endif
|
363 | ead9360e | ths | if (env->halted)
|
364 | 376253ec | aliguori | monitor_printf(mon, " (halted)");
|
365 | 376253ec | aliguori | monitor_printf(mon, "\n");
|
366 | 6a00d601 | bellard | } |
367 | 6a00d601 | bellard | } |
368 | 6a00d601 | bellard | |
369 | 376253ec | aliguori | static void do_cpu_set(Monitor *mon, int index) |
370 | 6a00d601 | bellard | { |
371 | 6a00d601 | bellard | if (mon_set_cpu(index) < 0) |
372 | 376253ec | aliguori | monitor_printf(mon, "Invalid CPU index\n");
|
373 | 6a00d601 | bellard | } |
374 | 6a00d601 | bellard | |
375 | 376253ec | aliguori | static void do_info_jit(Monitor *mon) |
376 | e3db7226 | bellard | { |
377 | 376253ec | aliguori | dump_exec_info((FILE *)mon, monitor_fprintf); |
378 | e3db7226 | bellard | } |
379 | e3db7226 | bellard | |
380 | 376253ec | aliguori | static void do_info_history(Monitor *mon) |
381 | aa455485 | bellard | { |
382 | aa455485 | bellard | int i;
|
383 | 7e2515e8 | bellard | const char *str; |
384 | 3b46e624 | ths | |
385 | cde76ee1 | aliguori | if (!mon->rs)
|
386 | cde76ee1 | aliguori | return;
|
387 | 7e2515e8 | bellard | i = 0;
|
388 | 7e2515e8 | bellard | for(;;) {
|
389 | 731b0364 | aliguori | str = readline_get_history(mon->rs, i); |
390 | 7e2515e8 | bellard | if (!str)
|
391 | 7e2515e8 | bellard | break;
|
392 | 376253ec | aliguori | monitor_printf(mon, "%d: '%s'\n", i, str);
|
393 | 8e3a9fd2 | bellard | i++; |
394 | aa455485 | bellard | } |
395 | aa455485 | bellard | } |
396 | aa455485 | bellard | |
397 | 76a66253 | j_mayer | #if defined(TARGET_PPC)
|
398 | 76a66253 | j_mayer | /* XXX: not implemented in other targets */
|
399 | 376253ec | aliguori | static void do_info_cpu_stats(Monitor *mon) |
400 | 76a66253 | j_mayer | { |
401 | 76a66253 | j_mayer | CPUState *env; |
402 | 76a66253 | j_mayer | |
403 | 76a66253 | j_mayer | env = mon_get_cpu(); |
404 | 376253ec | aliguori | cpu_dump_statistics(env, (FILE *)mon, &monitor_fprintf, 0);
|
405 | 76a66253 | j_mayer | } |
406 | 76a66253 | j_mayer | #endif
|
407 | 76a66253 | j_mayer | |
408 | 376253ec | aliguori | static void do_quit(Monitor *mon) |
409 | 9dc39cba | bellard | { |
410 | 9dc39cba | bellard | exit(0);
|
411 | 9dc39cba | bellard | } |
412 | 9dc39cba | bellard | |
413 | 376253ec | aliguori | static int eject_device(Monitor *mon, BlockDriverState *bs, int force) |
414 | 9dc39cba | bellard | { |
415 | 9dc39cba | bellard | if (bdrv_is_inserted(bs)) {
|
416 | 9dc39cba | bellard | if (!force) {
|
417 | 9dc39cba | bellard | if (!bdrv_is_removable(bs)) {
|
418 | 376253ec | aliguori | monitor_printf(mon, "device is not removable\n");
|
419 | 9dc39cba | bellard | return -1; |
420 | 9dc39cba | bellard | } |
421 | 9dc39cba | bellard | if (bdrv_is_locked(bs)) {
|
422 | 376253ec | aliguori | monitor_printf(mon, "device is locked\n");
|
423 | 9dc39cba | bellard | return -1; |
424 | 9dc39cba | bellard | } |
425 | 9dc39cba | bellard | } |
426 | 9dc39cba | bellard | bdrv_close(bs); |
427 | 9dc39cba | bellard | } |
428 | 9dc39cba | bellard | return 0; |
429 | 9dc39cba | bellard | } |
430 | 9dc39cba | bellard | |
431 | 376253ec | aliguori | static void do_eject(Monitor *mon, int force, const char *filename) |
432 | 9dc39cba | bellard | { |
433 | 9dc39cba | bellard | BlockDriverState *bs; |
434 | 9dc39cba | bellard | |
435 | 9307c4c1 | bellard | bs = bdrv_find(filename); |
436 | 9dc39cba | bellard | if (!bs) {
|
437 | 376253ec | aliguori | monitor_printf(mon, "device not found\n");
|
438 | 9dc39cba | bellard | return;
|
439 | 9dc39cba | bellard | } |
440 | 376253ec | aliguori | eject_device(mon, bs, force); |
441 | 9dc39cba | bellard | } |
442 | 9dc39cba | bellard | |
443 | 376253ec | aliguori | static void do_change_block(Monitor *mon, const char *device, |
444 | 376253ec | aliguori | const char *filename, const char *fmt) |
445 | 9dc39cba | bellard | { |
446 | 9dc39cba | bellard | BlockDriverState *bs; |
447 | 2ecea9b8 | aurel32 | BlockDriver *drv = NULL;
|
448 | 9dc39cba | bellard | |
449 | 9307c4c1 | bellard | bs = bdrv_find(device); |
450 | 9dc39cba | bellard | if (!bs) {
|
451 | 376253ec | aliguori | monitor_printf(mon, "device not found\n");
|
452 | 9dc39cba | bellard | return;
|
453 | 9dc39cba | bellard | } |
454 | 2ecea9b8 | aurel32 | if (fmt) {
|
455 | 2ecea9b8 | aurel32 | drv = bdrv_find_format(fmt); |
456 | 2ecea9b8 | aurel32 | if (!drv) {
|
457 | 376253ec | aliguori | monitor_printf(mon, "invalid format %s\n", fmt);
|
458 | 2ecea9b8 | aurel32 | return;
|
459 | 2ecea9b8 | aurel32 | } |
460 | 2ecea9b8 | aurel32 | } |
461 | 376253ec | aliguori | if (eject_device(mon, bs, 0) < 0) |
462 | 9dc39cba | bellard | return;
|
463 | 2ecea9b8 | aurel32 | bdrv_open2(bs, filename, 0, drv);
|
464 | 376253ec | aliguori | monitor_read_bdrv_key_start(mon, bs, NULL, NULL); |
465 | bb5fc20f | aliguori | } |
466 | bb5fc20f | aliguori | |
467 | 376253ec | aliguori | static void change_vnc_password_cb(Monitor *mon, const char *password, |
468 | 376253ec | aliguori | void *opaque)
|
469 | bb5fc20f | aliguori | { |
470 | bb5fc20f | aliguori | if (vnc_display_password(NULL, password) < 0) |
471 | 376253ec | aliguori | monitor_printf(mon, "could not set VNC server password\n");
|
472 | bb5fc20f | aliguori | |
473 | 731b0364 | aliguori | monitor_read_command(mon, 1);
|
474 | 9dc39cba | bellard | } |
475 | 9dc39cba | bellard | |
476 | 376253ec | aliguori | static void do_change_vnc(Monitor *mon, const char *target, const char *arg) |
477 | e25a5822 | ths | { |
478 | 70848515 | ths | if (strcmp(target, "passwd") == 0 || |
479 | 28a76be8 | aliguori | strcmp(target, "password") == 0) { |
480 | 28a76be8 | aliguori | if (arg) {
|
481 | bb5fc20f | aliguori | char password[9]; |
482 | 28a76be8 | aliguori | strncpy(password, arg, sizeof(password));
|
483 | 28a76be8 | aliguori | password[sizeof(password) - 1] = '\0'; |
484 | 376253ec | aliguori | change_vnc_password_cb(mon, password, NULL);
|
485 | bb5fc20f | aliguori | } else {
|
486 | 376253ec | aliguori | monitor_read_password(mon, change_vnc_password_cb, NULL);
|
487 | bb5fc20f | aliguori | } |
488 | 70848515 | ths | } else {
|
489 | 28a76be8 | aliguori | if (vnc_display_open(NULL, target) < 0) |
490 | 376253ec | aliguori | monitor_printf(mon, "could not start VNC server on %s\n", target);
|
491 | 70848515 | ths | } |
492 | e25a5822 | ths | } |
493 | e25a5822 | ths | |
494 | 376253ec | aliguori | static void do_change(Monitor *mon, const char *device, const char *target, |
495 | 376253ec | aliguori | const char *arg) |
496 | e25a5822 | ths | { |
497 | e25a5822 | ths | if (strcmp(device, "vnc") == 0) { |
498 | 28a76be8 | aliguori | do_change_vnc(mon, target, arg); |
499 | e25a5822 | ths | } else {
|
500 | 28a76be8 | aliguori | do_change_block(mon, device, target, arg); |
501 | e25a5822 | ths | } |
502 | e25a5822 | ths | } |
503 | e25a5822 | ths | |
504 | 376253ec | aliguori | static void do_screen_dump(Monitor *mon, const char *filename) |
505 | 59a983b9 | bellard | { |
506 | 95219897 | pbrook | vga_hw_screen_dump(filename); |
507 | 59a983b9 | bellard | } |
508 | 59a983b9 | bellard | |
509 | 376253ec | aliguori | static void do_logfile(Monitor *mon, const char *filename) |
510 | e735b91c | pbrook | { |
511 | e735b91c | pbrook | cpu_set_log_filename(filename); |
512 | e735b91c | pbrook | } |
513 | e735b91c | pbrook | |
514 | 376253ec | aliguori | static void do_log(Monitor *mon, const char *items) |
515 | f193c797 | bellard | { |
516 | f193c797 | bellard | int mask;
|
517 | 3b46e624 | ths | |
518 | 9307c4c1 | bellard | if (!strcmp(items, "none")) { |
519 | f193c797 | bellard | mask = 0;
|
520 | f193c797 | bellard | } else {
|
521 | 9307c4c1 | bellard | mask = cpu_str_to_log_mask(items); |
522 | f193c797 | bellard | if (!mask) {
|
523 | 376253ec | aliguori | help_cmd(mon, "log");
|
524 | f193c797 | bellard | return;
|
525 | f193c797 | bellard | } |
526 | f193c797 | bellard | } |
527 | f193c797 | bellard | cpu_set_log(mask); |
528 | f193c797 | bellard | } |
529 | f193c797 | bellard | |
530 | 1b530a6d | aurel32 | static void do_singlestep(Monitor *mon, const char *option) |
531 | 1b530a6d | aurel32 | { |
532 | 1b530a6d | aurel32 | if (!option || !strcmp(option, "on")) { |
533 | 1b530a6d | aurel32 | singlestep = 1;
|
534 | 1b530a6d | aurel32 | } else if (!strcmp(option, "off")) { |
535 | 1b530a6d | aurel32 | singlestep = 0;
|
536 | 1b530a6d | aurel32 | } else {
|
537 | 1b530a6d | aurel32 | monitor_printf(mon, "unexpected option %s\n", option);
|
538 | 1b530a6d | aurel32 | } |
539 | 1b530a6d | aurel32 | } |
540 | 1b530a6d | aurel32 | |
541 | 376253ec | aliguori | static void do_stop(Monitor *mon) |
542 | 8a7ddc38 | bellard | { |
543 | 8a7ddc38 | bellard | vm_stop(EXCP_INTERRUPT); |
544 | 8a7ddc38 | bellard | } |
545 | 8a7ddc38 | bellard | |
546 | bb5fc20f | aliguori | static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs); |
547 | c0f4ce77 | aliguori | |
548 | 376253ec | aliguori | struct bdrv_iterate_context {
|
549 | 376253ec | aliguori | Monitor *mon; |
550 | 376253ec | aliguori | int err;
|
551 | 376253ec | aliguori | }; |
552 | 376253ec | aliguori | |
553 | 376253ec | aliguori | static void do_cont(Monitor *mon) |
554 | 8a7ddc38 | bellard | { |
555 | 376253ec | aliguori | struct bdrv_iterate_context context = { mon, 0 }; |
556 | c0f4ce77 | aliguori | |
557 | 376253ec | aliguori | bdrv_iterate(encrypted_bdrv_it, &context); |
558 | c0f4ce77 | aliguori | /* only resume the vm if all keys are set and valid */
|
559 | 376253ec | aliguori | if (!context.err)
|
560 | c0f4ce77 | aliguori | vm_start(); |
561 | 8a7ddc38 | bellard | } |
562 | 8a7ddc38 | bellard | |
563 | bb5fc20f | aliguori | static void bdrv_key_cb(void *opaque, int err) |
564 | bb5fc20f | aliguori | { |
565 | 376253ec | aliguori | Monitor *mon = opaque; |
566 | 376253ec | aliguori | |
567 | bb5fc20f | aliguori | /* another key was set successfully, retry to continue */
|
568 | bb5fc20f | aliguori | if (!err)
|
569 | 376253ec | aliguori | do_cont(mon); |
570 | bb5fc20f | aliguori | } |
571 | bb5fc20f | aliguori | |
572 | bb5fc20f | aliguori | static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs) |
573 | bb5fc20f | aliguori | { |
574 | 376253ec | aliguori | struct bdrv_iterate_context *context = opaque;
|
575 | bb5fc20f | aliguori | |
576 | 376253ec | aliguori | if (!context->err && bdrv_key_required(bs)) {
|
577 | 376253ec | aliguori | context->err = -EBUSY; |
578 | 376253ec | aliguori | monitor_read_bdrv_key_start(context->mon, bs, bdrv_key_cb, |
579 | 376253ec | aliguori | context->mon); |
580 | bb5fc20f | aliguori | } |
581 | bb5fc20f | aliguori | } |
582 | bb5fc20f | aliguori | |
583 | 67b915a5 | bellard | #ifdef CONFIG_GDBSTUB
|
584 | 59030a8c | aliguori | static void do_gdbserver(Monitor *mon, const char *device) |
585 | 59030a8c | aliguori | { |
586 | 59030a8c | aliguori | if (!device)
|
587 | 59030a8c | aliguori | device = "tcp::" DEFAULT_GDBSTUB_PORT;
|
588 | 59030a8c | aliguori | if (gdbserver_start(device) < 0) { |
589 | 59030a8c | aliguori | monitor_printf(mon, "Could not open gdbserver on device '%s'\n",
|
590 | 59030a8c | aliguori | device); |
591 | 59030a8c | aliguori | } else if (strcmp(device, "none") == 0) { |
592 | 36556b20 | aliguori | monitor_printf(mon, "Disabled gdbserver\n");
|
593 | 8a7ddc38 | bellard | } else {
|
594 | 59030a8c | aliguori | monitor_printf(mon, "Waiting for gdb connection on device '%s'\n",
|
595 | 59030a8c | aliguori | device); |
596 | 8a7ddc38 | bellard | } |
597 | 8a7ddc38 | bellard | } |
598 | 67b915a5 | bellard | #endif
|
599 | 8a7ddc38 | bellard | |
600 | 376253ec | aliguori | static void monitor_printc(Monitor *mon, int c) |
601 | 9307c4c1 | bellard | { |
602 | 376253ec | aliguori | monitor_printf(mon, "'");
|
603 | 9307c4c1 | bellard | switch(c) {
|
604 | 9307c4c1 | bellard | case '\'': |
605 | 376253ec | aliguori | monitor_printf(mon, "\\'");
|
606 | 9307c4c1 | bellard | break;
|
607 | 9307c4c1 | bellard | case '\\': |
608 | 376253ec | aliguori | monitor_printf(mon, "\\\\");
|
609 | 9307c4c1 | bellard | break;
|
610 | 9307c4c1 | bellard | case '\n': |
611 | 376253ec | aliguori | monitor_printf(mon, "\\n");
|
612 | 9307c4c1 | bellard | break;
|
613 | 9307c4c1 | bellard | case '\r': |
614 | 376253ec | aliguori | monitor_printf(mon, "\\r");
|
615 | 9307c4c1 | bellard | break;
|
616 | 9307c4c1 | bellard | default:
|
617 | 9307c4c1 | bellard | if (c >= 32 && c <= 126) { |
618 | 376253ec | aliguori | monitor_printf(mon, "%c", c);
|
619 | 9307c4c1 | bellard | } else {
|
620 | 376253ec | aliguori | monitor_printf(mon, "\\x%02x", c);
|
621 | 9307c4c1 | bellard | } |
622 | 9307c4c1 | bellard | break;
|
623 | 9307c4c1 | bellard | } |
624 | 376253ec | aliguori | monitor_printf(mon, "'");
|
625 | 9307c4c1 | bellard | } |
626 | 9307c4c1 | bellard | |
627 | 376253ec | aliguori | static void memory_dump(Monitor *mon, int count, int format, int wsize, |
628 | 7743e588 | blueswir1 | target_phys_addr_t addr, int is_physical)
|
629 | 9307c4c1 | bellard | { |
630 | 6a00d601 | bellard | CPUState *env; |
631 | 9307c4c1 | bellard | int nb_per_line, l, line_size, i, max_digits, len;
|
632 | 9307c4c1 | bellard | uint8_t buf[16];
|
633 | 9307c4c1 | bellard | uint64_t v; |
634 | 9307c4c1 | bellard | |
635 | 9307c4c1 | bellard | if (format == 'i') { |
636 | 9307c4c1 | bellard | int flags;
|
637 | 9307c4c1 | bellard | flags = 0;
|
638 | 6a00d601 | bellard | env = mon_get_cpu(); |
639 | 6a00d601 | bellard | if (!env && !is_physical)
|
640 | 6a00d601 | bellard | return;
|
641 | 9307c4c1 | bellard | #ifdef TARGET_I386
|
642 | 4c27ba27 | bellard | if (wsize == 2) { |
643 | 9307c4c1 | bellard | flags = 1;
|
644 | 4c27ba27 | bellard | } else if (wsize == 4) { |
645 | 4c27ba27 | bellard | flags = 0;
|
646 | 4c27ba27 | bellard | } else {
|
647 | 6a15fd12 | bellard | /* as default we use the current CS size */
|
648 | 4c27ba27 | bellard | flags = 0;
|
649 | 6a15fd12 | bellard | if (env) {
|
650 | 6a15fd12 | bellard | #ifdef TARGET_X86_64
|
651 | 5fafdf24 | ths | if ((env->efer & MSR_EFER_LMA) &&
|
652 | 6a15fd12 | bellard | (env->segs[R_CS].flags & DESC_L_MASK)) |
653 | 6a15fd12 | bellard | flags = 2;
|
654 | 6a15fd12 | bellard | else
|
655 | 6a15fd12 | bellard | #endif
|
656 | 6a15fd12 | bellard | if (!(env->segs[R_CS].flags & DESC_B_MASK))
|
657 | 6a15fd12 | bellard | flags = 1;
|
658 | 6a15fd12 | bellard | } |
659 | 4c27ba27 | bellard | } |
660 | 4c27ba27 | bellard | #endif
|
661 | 376253ec | aliguori | monitor_disas(mon, env, addr, count, is_physical, flags); |
662 | 9307c4c1 | bellard | return;
|
663 | 9307c4c1 | bellard | } |
664 | 9307c4c1 | bellard | |
665 | 9307c4c1 | bellard | len = wsize * count; |
666 | 9307c4c1 | bellard | if (wsize == 1) |
667 | 9307c4c1 | bellard | line_size = 8;
|
668 | 9307c4c1 | bellard | else
|
669 | 9307c4c1 | bellard | line_size = 16;
|
670 | 9307c4c1 | bellard | nb_per_line = line_size / wsize; |
671 | 9307c4c1 | bellard | max_digits = 0;
|
672 | 9307c4c1 | bellard | |
673 | 9307c4c1 | bellard | switch(format) {
|
674 | 9307c4c1 | bellard | case 'o': |
675 | 9307c4c1 | bellard | max_digits = (wsize * 8 + 2) / 3; |
676 | 9307c4c1 | bellard | break;
|
677 | 9307c4c1 | bellard | default:
|
678 | 9307c4c1 | bellard | case 'x': |
679 | 9307c4c1 | bellard | max_digits = (wsize * 8) / 4; |
680 | 9307c4c1 | bellard | break;
|
681 | 9307c4c1 | bellard | case 'u': |
682 | 9307c4c1 | bellard | case 'd': |
683 | 9307c4c1 | bellard | max_digits = (wsize * 8 * 10 + 32) / 33; |
684 | 9307c4c1 | bellard | break;
|
685 | 9307c4c1 | bellard | case 'c': |
686 | 9307c4c1 | bellard | wsize = 1;
|
687 | 9307c4c1 | bellard | break;
|
688 | 9307c4c1 | bellard | } |
689 | 9307c4c1 | bellard | |
690 | 9307c4c1 | bellard | while (len > 0) { |
691 | 7743e588 | blueswir1 | if (is_physical)
|
692 | 376253ec | aliguori | monitor_printf(mon, TARGET_FMT_plx ":", addr);
|
693 | 7743e588 | blueswir1 | else
|
694 | 376253ec | aliguori | monitor_printf(mon, TARGET_FMT_lx ":", (target_ulong)addr);
|
695 | 9307c4c1 | bellard | l = len; |
696 | 9307c4c1 | bellard | if (l > line_size)
|
697 | 9307c4c1 | bellard | l = line_size; |
698 | 9307c4c1 | bellard | if (is_physical) {
|
699 | 9307c4c1 | bellard | cpu_physical_memory_rw(addr, buf, l, 0);
|
700 | 9307c4c1 | bellard | } else {
|
701 | 6a00d601 | bellard | env = mon_get_cpu(); |
702 | 6a00d601 | bellard | if (!env)
|
703 | 6a00d601 | bellard | break;
|
704 | c8f79b67 | aliguori | if (cpu_memory_rw_debug(env, addr, buf, l, 0) < 0) { |
705 | 376253ec | aliguori | monitor_printf(mon, " Cannot access memory\n");
|
706 | c8f79b67 | aliguori | break;
|
707 | c8f79b67 | aliguori | } |
708 | 9307c4c1 | bellard | } |
709 | 5fafdf24 | ths | i = 0;
|
710 | 9307c4c1 | bellard | while (i < l) {
|
711 | 9307c4c1 | bellard | switch(wsize) {
|
712 | 9307c4c1 | bellard | default:
|
713 | 9307c4c1 | bellard | case 1: |
714 | 9307c4c1 | bellard | v = ldub_raw(buf + i); |
715 | 9307c4c1 | bellard | break;
|
716 | 9307c4c1 | bellard | case 2: |
717 | 9307c4c1 | bellard | v = lduw_raw(buf + i); |
718 | 9307c4c1 | bellard | break;
|
719 | 9307c4c1 | bellard | case 4: |
720 | 92a31b1f | bellard | v = (uint32_t)ldl_raw(buf + i); |
721 | 9307c4c1 | bellard | break;
|
722 | 9307c4c1 | bellard | case 8: |
723 | 9307c4c1 | bellard | v = ldq_raw(buf + i); |
724 | 9307c4c1 | bellard | break;
|
725 | 9307c4c1 | bellard | } |
726 | 376253ec | aliguori | monitor_printf(mon, " ");
|
727 | 9307c4c1 | bellard | switch(format) {
|
728 | 9307c4c1 | bellard | case 'o': |
729 | 376253ec | aliguori | monitor_printf(mon, "%#*" PRIo64, max_digits, v);
|
730 | 9307c4c1 | bellard | break;
|
731 | 9307c4c1 | bellard | case 'x': |
732 | 376253ec | aliguori | monitor_printf(mon, "0x%0*" PRIx64, max_digits, v);
|
733 | 9307c4c1 | bellard | break;
|
734 | 9307c4c1 | bellard | case 'u': |
735 | 376253ec | aliguori | monitor_printf(mon, "%*" PRIu64, max_digits, v);
|
736 | 9307c4c1 | bellard | break;
|
737 | 9307c4c1 | bellard | case 'd': |
738 | 376253ec | aliguori | monitor_printf(mon, "%*" PRId64, max_digits, v);
|
739 | 9307c4c1 | bellard | break;
|
740 | 9307c4c1 | bellard | case 'c': |
741 | 376253ec | aliguori | monitor_printc(mon, v); |
742 | 9307c4c1 | bellard | break;
|
743 | 9307c4c1 | bellard | } |
744 | 9307c4c1 | bellard | i += wsize; |
745 | 9307c4c1 | bellard | } |
746 | 376253ec | aliguori | monitor_printf(mon, "\n");
|
747 | 9307c4c1 | bellard | addr += l; |
748 | 9307c4c1 | bellard | len -= l; |
749 | 9307c4c1 | bellard | } |
750 | 9307c4c1 | bellard | } |
751 | 9307c4c1 | bellard | |
752 | 92a31b1f | bellard | #if TARGET_LONG_BITS == 64 |
753 | 92a31b1f | bellard | #define GET_TLONG(h, l) (((uint64_t)(h) << 32) | (l)) |
754 | 92a31b1f | bellard | #else
|
755 | 92a31b1f | bellard | #define GET_TLONG(h, l) (l)
|
756 | 92a31b1f | bellard | #endif
|
757 | 92a31b1f | bellard | |
758 | 376253ec | aliguori | static void do_memory_dump(Monitor *mon, int count, int format, int size, |
759 | 92a31b1f | bellard | uint32_t addrh, uint32_t addrl) |
760 | 9307c4c1 | bellard | { |
761 | 92a31b1f | bellard | target_long addr = GET_TLONG(addrh, addrl); |
762 | 376253ec | aliguori | memory_dump(mon, count, format, size, addr, 0);
|
763 | 9307c4c1 | bellard | } |
764 | 9307c4c1 | bellard | |
765 | 7743e588 | blueswir1 | #if TARGET_PHYS_ADDR_BITS > 32 |
766 | 7743e588 | blueswir1 | #define GET_TPHYSADDR(h, l) (((uint64_t)(h) << 32) | (l)) |
767 | 7743e588 | blueswir1 | #else
|
768 | 7743e588 | blueswir1 | #define GET_TPHYSADDR(h, l) (l)
|
769 | 7743e588 | blueswir1 | #endif
|
770 | 7743e588 | blueswir1 | |
771 | 376253ec | aliguori | static void do_physical_memory_dump(Monitor *mon, int count, int format, |
772 | 376253ec | aliguori | int size, uint32_t addrh, uint32_t addrl)
|
773 | 92a31b1f | bellard | |
774 | 9307c4c1 | bellard | { |
775 | 7743e588 | blueswir1 | target_phys_addr_t addr = GET_TPHYSADDR(addrh, addrl); |
776 | 376253ec | aliguori | memory_dump(mon, count, format, size, addr, 1);
|
777 | 9307c4c1 | bellard | } |
778 | 9307c4c1 | bellard | |
779 | 376253ec | aliguori | static void do_print(Monitor *mon, int count, int format, int size, |
780 | 376253ec | aliguori | unsigned int valh, unsigned int vall) |
781 | 9307c4c1 | bellard | { |
782 | 7743e588 | blueswir1 | target_phys_addr_t val = GET_TPHYSADDR(valh, vall); |
783 | 7743e588 | blueswir1 | #if TARGET_PHYS_ADDR_BITS == 32 |
784 | 9307c4c1 | bellard | switch(format) {
|
785 | 9307c4c1 | bellard | case 'o': |
786 | 376253ec | aliguori | monitor_printf(mon, "%#o", val);
|
787 | 9307c4c1 | bellard | break;
|
788 | 9307c4c1 | bellard | case 'x': |
789 | 376253ec | aliguori | monitor_printf(mon, "%#x", val);
|
790 | 9307c4c1 | bellard | break;
|
791 | 9307c4c1 | bellard | case 'u': |
792 | 376253ec | aliguori | monitor_printf(mon, "%u", val);
|
793 | 9307c4c1 | bellard | break;
|
794 | 9307c4c1 | bellard | default:
|
795 | 9307c4c1 | bellard | case 'd': |
796 | 376253ec | aliguori | monitor_printf(mon, "%d", val);
|
797 | 9307c4c1 | bellard | break;
|
798 | 9307c4c1 | bellard | case 'c': |
799 | 376253ec | aliguori | monitor_printc(mon, val); |
800 | 9307c4c1 | bellard | break;
|
801 | 9307c4c1 | bellard | } |
802 | 92a31b1f | bellard | #else
|
803 | 92a31b1f | bellard | switch(format) {
|
804 | 92a31b1f | bellard | case 'o': |
805 | 376253ec | aliguori | monitor_printf(mon, "%#" PRIo64, val);
|
806 | 92a31b1f | bellard | break;
|
807 | 92a31b1f | bellard | case 'x': |
808 | 376253ec | aliguori | monitor_printf(mon, "%#" PRIx64, val);
|
809 | 92a31b1f | bellard | break;
|
810 | 92a31b1f | bellard | case 'u': |
811 | 376253ec | aliguori | monitor_printf(mon, "%" PRIu64, val);
|
812 | 92a31b1f | bellard | break;
|
813 | 92a31b1f | bellard | default:
|
814 | 92a31b1f | bellard | case 'd': |
815 | 376253ec | aliguori | monitor_printf(mon, "%" PRId64, val);
|
816 | 92a31b1f | bellard | break;
|
817 | 92a31b1f | bellard | case 'c': |
818 | 376253ec | aliguori | monitor_printc(mon, val); |
819 | 92a31b1f | bellard | break;
|
820 | 92a31b1f | bellard | } |
821 | 92a31b1f | bellard | #endif
|
822 | 376253ec | aliguori | monitor_printf(mon, "\n");
|
823 | 9307c4c1 | bellard | } |
824 | 9307c4c1 | bellard | |
825 | 376253ec | aliguori | static void do_memory_save(Monitor *mon, unsigned int valh, unsigned int vall, |
826 | b371dc59 | bellard | uint32_t size, const char *filename) |
827 | b371dc59 | bellard | { |
828 | b371dc59 | bellard | FILE *f; |
829 | b371dc59 | bellard | target_long addr = GET_TLONG(valh, vall); |
830 | b371dc59 | bellard | uint32_t l; |
831 | b371dc59 | bellard | CPUState *env; |
832 | b371dc59 | bellard | uint8_t buf[1024];
|
833 | b371dc59 | bellard | |
834 | b371dc59 | bellard | env = mon_get_cpu(); |
835 | b371dc59 | bellard | if (!env)
|
836 | b371dc59 | bellard | return;
|
837 | b371dc59 | bellard | |
838 | b371dc59 | bellard | f = fopen(filename, "wb");
|
839 | b371dc59 | bellard | if (!f) {
|
840 | 376253ec | aliguori | monitor_printf(mon, "could not open '%s'\n", filename);
|
841 | b371dc59 | bellard | return;
|
842 | b371dc59 | bellard | } |
843 | b371dc59 | bellard | while (size != 0) { |
844 | b371dc59 | bellard | l = sizeof(buf);
|
845 | b371dc59 | bellard | if (l > size)
|
846 | b371dc59 | bellard | l = size; |
847 | b371dc59 | bellard | cpu_memory_rw_debug(env, addr, buf, l, 0);
|
848 | b371dc59 | bellard | fwrite(buf, 1, l, f);
|
849 | b371dc59 | bellard | addr += l; |
850 | b371dc59 | bellard | size -= l; |
851 | b371dc59 | bellard | } |
852 | b371dc59 | bellard | fclose(f); |
853 | b371dc59 | bellard | } |
854 | b371dc59 | bellard | |
855 | 376253ec | aliguori | static void do_physical_memory_save(Monitor *mon, unsigned int valh, |
856 | 376253ec | aliguori | unsigned int vall, uint32_t size, |
857 | 376253ec | aliguori | const char *filename) |
858 | a8bdf7a6 | aurel32 | { |
859 | a8bdf7a6 | aurel32 | FILE *f; |
860 | a8bdf7a6 | aurel32 | uint32_t l; |
861 | a8bdf7a6 | aurel32 | uint8_t buf[1024];
|
862 | 339dea27 | aurel32 | target_phys_addr_t addr = GET_TPHYSADDR(valh, vall); |
863 | a8bdf7a6 | aurel32 | |
864 | a8bdf7a6 | aurel32 | f = fopen(filename, "wb");
|
865 | a8bdf7a6 | aurel32 | if (!f) {
|
866 | 376253ec | aliguori | monitor_printf(mon, "could not open '%s'\n", filename);
|
867 | a8bdf7a6 | aurel32 | return;
|
868 | a8bdf7a6 | aurel32 | } |
869 | a8bdf7a6 | aurel32 | while (size != 0) { |
870 | a8bdf7a6 | aurel32 | l = sizeof(buf);
|
871 | a8bdf7a6 | aurel32 | if (l > size)
|
872 | a8bdf7a6 | aurel32 | l = size; |
873 | a8bdf7a6 | aurel32 | cpu_physical_memory_rw(addr, buf, l, 0);
|
874 | a8bdf7a6 | aurel32 | fwrite(buf, 1, l, f);
|
875 | a8bdf7a6 | aurel32 | fflush(f); |
876 | a8bdf7a6 | aurel32 | addr += l; |
877 | a8bdf7a6 | aurel32 | size -= l; |
878 | a8bdf7a6 | aurel32 | } |
879 | a8bdf7a6 | aurel32 | fclose(f); |
880 | a8bdf7a6 | aurel32 | } |
881 | a8bdf7a6 | aurel32 | |
882 | 376253ec | aliguori | static void do_sum(Monitor *mon, uint32_t start, uint32_t size) |
883 | e4cf1adc | bellard | { |
884 | e4cf1adc | bellard | uint32_t addr; |
885 | e4cf1adc | bellard | uint8_t buf[1];
|
886 | e4cf1adc | bellard | uint16_t sum; |
887 | e4cf1adc | bellard | |
888 | e4cf1adc | bellard | sum = 0;
|
889 | e4cf1adc | bellard | for(addr = start; addr < (start + size); addr++) {
|
890 | e4cf1adc | bellard | cpu_physical_memory_rw(addr, buf, 1, 0); |
891 | e4cf1adc | bellard | /* BSD sum algorithm ('sum' Unix command) */
|
892 | e4cf1adc | bellard | sum = (sum >> 1) | (sum << 15); |
893 | e4cf1adc | bellard | sum += buf[0];
|
894 | e4cf1adc | bellard | } |
895 | 376253ec | aliguori | monitor_printf(mon, "%05d\n", sum);
|
896 | e4cf1adc | bellard | } |
897 | e4cf1adc | bellard | |
898 | a3a91a35 | bellard | typedef struct { |
899 | a3a91a35 | bellard | int keycode;
|
900 | a3a91a35 | bellard | const char *name; |
901 | a3a91a35 | bellard | } KeyDef; |
902 | a3a91a35 | bellard | |
903 | a3a91a35 | bellard | static const KeyDef key_defs[] = { |
904 | a3a91a35 | bellard | { 0x2a, "shift" }, |
905 | a3a91a35 | bellard | { 0x36, "shift_r" }, |
906 | 3b46e624 | ths | |
907 | a3a91a35 | bellard | { 0x38, "alt" }, |
908 | a3a91a35 | bellard | { 0xb8, "alt_r" }, |
909 | 2ba27c7f | ths | { 0x64, "altgr" }, |
910 | 2ba27c7f | ths | { 0xe4, "altgr_r" }, |
911 | a3a91a35 | bellard | { 0x1d, "ctrl" }, |
912 | a3a91a35 | bellard | { 0x9d, "ctrl_r" }, |
913 | a3a91a35 | bellard | |
914 | a3a91a35 | bellard | { 0xdd, "menu" }, |
915 | a3a91a35 | bellard | |
916 | a3a91a35 | bellard | { 0x01, "esc" }, |
917 | a3a91a35 | bellard | |
918 | a3a91a35 | bellard | { 0x02, "1" }, |
919 | a3a91a35 | bellard | { 0x03, "2" }, |
920 | a3a91a35 | bellard | { 0x04, "3" }, |
921 | a3a91a35 | bellard | { 0x05, "4" }, |
922 | a3a91a35 | bellard | { 0x06, "5" }, |
923 | a3a91a35 | bellard | { 0x07, "6" }, |
924 | a3a91a35 | bellard | { 0x08, "7" }, |
925 | a3a91a35 | bellard | { 0x09, "8" }, |
926 | a3a91a35 | bellard | { 0x0a, "9" }, |
927 | a3a91a35 | bellard | { 0x0b, "0" }, |
928 | 64866c3d | bellard | { 0x0c, "minus" }, |
929 | 64866c3d | bellard | { 0x0d, "equal" }, |
930 | a3a91a35 | bellard | { 0x0e, "backspace" }, |
931 | a3a91a35 | bellard | |
932 | a3a91a35 | bellard | { 0x0f, "tab" }, |
933 | a3a91a35 | bellard | { 0x10, "q" }, |
934 | a3a91a35 | bellard | { 0x11, "w" }, |
935 | a3a91a35 | bellard | { 0x12, "e" }, |
936 | a3a91a35 | bellard | { 0x13, "r" }, |
937 | a3a91a35 | bellard | { 0x14, "t" }, |
938 | a3a91a35 | bellard | { 0x15, "y" }, |
939 | a3a91a35 | bellard | { 0x16, "u" }, |
940 | a3a91a35 | bellard | { 0x17, "i" }, |
941 | a3a91a35 | bellard | { 0x18, "o" }, |
942 | a3a91a35 | bellard | { 0x19, "p" }, |
943 | a3a91a35 | bellard | |
944 | a3a91a35 | bellard | { 0x1c, "ret" }, |
945 | a3a91a35 | bellard | |
946 | a3a91a35 | bellard | { 0x1e, "a" }, |
947 | a3a91a35 | bellard | { 0x1f, "s" }, |
948 | a3a91a35 | bellard | { 0x20, "d" }, |
949 | a3a91a35 | bellard | { 0x21, "f" }, |
950 | a3a91a35 | bellard | { 0x22, "g" }, |
951 | a3a91a35 | bellard | { 0x23, "h" }, |
952 | a3a91a35 | bellard | { 0x24, "j" }, |
953 | a3a91a35 | bellard | { 0x25, "k" }, |
954 | a3a91a35 | bellard | { 0x26, "l" }, |
955 | a3a91a35 | bellard | |
956 | a3a91a35 | bellard | { 0x2c, "z" }, |
957 | a3a91a35 | bellard | { 0x2d, "x" }, |
958 | a3a91a35 | bellard | { 0x2e, "c" }, |
959 | a3a91a35 | bellard | { 0x2f, "v" }, |
960 | a3a91a35 | bellard | { 0x30, "b" }, |
961 | a3a91a35 | bellard | { 0x31, "n" }, |
962 | a3a91a35 | bellard | { 0x32, "m" }, |
963 | 9155fc45 | aurel32 | { 0x33, "comma" }, |
964 | 9155fc45 | aurel32 | { 0x34, "dot" }, |
965 | 9155fc45 | aurel32 | { 0x35, "slash" }, |
966 | 3b46e624 | ths | |
967 | 4d3b6f6e | balrog | { 0x37, "asterisk" }, |
968 | 4d3b6f6e | balrog | |
969 | a3a91a35 | bellard | { 0x39, "spc" }, |
970 | 00ffa62a | bellard | { 0x3a, "caps_lock" }, |
971 | a3a91a35 | bellard | { 0x3b, "f1" }, |
972 | a3a91a35 | bellard | { 0x3c, "f2" }, |
973 | a3a91a35 | bellard | { 0x3d, "f3" }, |
974 | a3a91a35 | bellard | { 0x3e, "f4" }, |
975 | a3a91a35 | bellard | { 0x3f, "f5" }, |
976 | a3a91a35 | bellard | { 0x40, "f6" }, |
977 | a3a91a35 | bellard | { 0x41, "f7" }, |
978 | a3a91a35 | bellard | { 0x42, "f8" }, |
979 | a3a91a35 | bellard | { 0x43, "f9" }, |
980 | a3a91a35 | bellard | { 0x44, "f10" }, |
981 | 00ffa62a | bellard | { 0x45, "num_lock" }, |
982 | a3a91a35 | bellard | { 0x46, "scroll_lock" }, |
983 | a3a91a35 | bellard | |
984 | 64866c3d | bellard | { 0xb5, "kp_divide" }, |
985 | 64866c3d | bellard | { 0x37, "kp_multiply" }, |
986 | 0cfec834 | ths | { 0x4a, "kp_subtract" }, |
987 | 64866c3d | bellard | { 0x4e, "kp_add" }, |
988 | 64866c3d | bellard | { 0x9c, "kp_enter" }, |
989 | 64866c3d | bellard | { 0x53, "kp_decimal" }, |
990 | f2289cb6 | balrog | { 0x54, "sysrq" }, |
991 | 64866c3d | bellard | |
992 | 64866c3d | bellard | { 0x52, "kp_0" }, |
993 | 64866c3d | bellard | { 0x4f, "kp_1" }, |
994 | 64866c3d | bellard | { 0x50, "kp_2" }, |
995 | 64866c3d | bellard | { 0x51, "kp_3" }, |
996 | 64866c3d | bellard | { 0x4b, "kp_4" }, |
997 | 64866c3d | bellard | { 0x4c, "kp_5" }, |
998 | 64866c3d | bellard | { 0x4d, "kp_6" }, |
999 | 64866c3d | bellard | { 0x47, "kp_7" }, |
1000 | 64866c3d | bellard | { 0x48, "kp_8" }, |
1001 | 64866c3d | bellard | { 0x49, "kp_9" }, |
1002 | 3b46e624 | ths | |
1003 | a3a91a35 | bellard | { 0x56, "<" }, |
1004 | a3a91a35 | bellard | |
1005 | a3a91a35 | bellard | { 0x57, "f11" }, |
1006 | a3a91a35 | bellard | { 0x58, "f12" }, |
1007 | a3a91a35 | bellard | |
1008 | a3a91a35 | bellard | { 0xb7, "print" }, |
1009 | a3a91a35 | bellard | |
1010 | a3a91a35 | bellard | { 0xc7, "home" }, |
1011 | a3a91a35 | bellard | { 0xc9, "pgup" }, |
1012 | a3a91a35 | bellard | { 0xd1, "pgdn" }, |
1013 | a3a91a35 | bellard | { 0xcf, "end" }, |
1014 | a3a91a35 | bellard | |
1015 | a3a91a35 | bellard | { 0xcb, "left" }, |
1016 | a3a91a35 | bellard | { 0xc8, "up" }, |
1017 | a3a91a35 | bellard | { 0xd0, "down" }, |
1018 | a3a91a35 | bellard | { 0xcd, "right" }, |
1019 | a3a91a35 | bellard | |
1020 | a3a91a35 | bellard | { 0xd2, "insert" }, |
1021 | a3a91a35 | bellard | { 0xd3, "delete" }, |
1022 | c0b5b109 | blueswir1 | #if defined(TARGET_SPARC) && !defined(TARGET_SPARC64)
|
1023 | c0b5b109 | blueswir1 | { 0xf0, "stop" }, |
1024 | c0b5b109 | blueswir1 | { 0xf1, "again" }, |
1025 | c0b5b109 | blueswir1 | { 0xf2, "props" }, |
1026 | c0b5b109 | blueswir1 | { 0xf3, "undo" }, |
1027 | c0b5b109 | blueswir1 | { 0xf4, "front" }, |
1028 | c0b5b109 | blueswir1 | { 0xf5, "copy" }, |
1029 | c0b5b109 | blueswir1 | { 0xf6, "open" }, |
1030 | c0b5b109 | blueswir1 | { 0xf7, "paste" }, |
1031 | c0b5b109 | blueswir1 | { 0xf8, "find" }, |
1032 | c0b5b109 | blueswir1 | { 0xf9, "cut" }, |
1033 | c0b5b109 | blueswir1 | { 0xfa, "lf" }, |
1034 | c0b5b109 | blueswir1 | { 0xfb, "help" }, |
1035 | c0b5b109 | blueswir1 | { 0xfc, "meta_l" }, |
1036 | c0b5b109 | blueswir1 | { 0xfd, "meta_r" }, |
1037 | c0b5b109 | blueswir1 | { 0xfe, "compose" }, |
1038 | c0b5b109 | blueswir1 | #endif
|
1039 | a3a91a35 | bellard | { 0, NULL }, |
1040 | a3a91a35 | bellard | }; |
1041 | a3a91a35 | bellard | |
1042 | a3a91a35 | bellard | static int get_keycode(const char *key) |
1043 | a3a91a35 | bellard | { |
1044 | a3a91a35 | bellard | const KeyDef *p;
|
1045 | 64866c3d | bellard | char *endp;
|
1046 | 64866c3d | bellard | int ret;
|
1047 | a3a91a35 | bellard | |
1048 | a3a91a35 | bellard | for(p = key_defs; p->name != NULL; p++) { |
1049 | a3a91a35 | bellard | if (!strcmp(key, p->name))
|
1050 | a3a91a35 | bellard | return p->keycode;
|
1051 | a3a91a35 | bellard | } |
1052 | 64866c3d | bellard | if (strstart(key, "0x", NULL)) { |
1053 | 64866c3d | bellard | ret = strtoul(key, &endp, 0);
|
1054 | 64866c3d | bellard | if (*endp == '\0' && ret >= 0x01 && ret <= 0xff) |
1055 | 64866c3d | bellard | return ret;
|
1056 | 64866c3d | bellard | } |
1057 | a3a91a35 | bellard | return -1; |
1058 | a3a91a35 | bellard | } |
1059 | a3a91a35 | bellard | |
1060 | c8256f9d | balrog | #define MAX_KEYCODES 16 |
1061 | c8256f9d | balrog | static uint8_t keycodes[MAX_KEYCODES];
|
1062 | c8256f9d | balrog | static int nb_pending_keycodes; |
1063 | c8256f9d | balrog | static QEMUTimer *key_timer;
|
1064 | c8256f9d | balrog | |
1065 | c8256f9d | balrog | static void release_keys(void *opaque) |
1066 | c8256f9d | balrog | { |
1067 | c8256f9d | balrog | int keycode;
|
1068 | c8256f9d | balrog | |
1069 | c8256f9d | balrog | while (nb_pending_keycodes > 0) { |
1070 | c8256f9d | balrog | nb_pending_keycodes--; |
1071 | c8256f9d | balrog | keycode = keycodes[nb_pending_keycodes]; |
1072 | c8256f9d | balrog | if (keycode & 0x80) |
1073 | c8256f9d | balrog | kbd_put_keycode(0xe0);
|
1074 | c8256f9d | balrog | kbd_put_keycode(keycode | 0x80);
|
1075 | c8256f9d | balrog | } |
1076 | c8256f9d | balrog | } |
1077 | c8256f9d | balrog | |
1078 | 376253ec | aliguori | static void do_sendkey(Monitor *mon, const char *string, int has_hold_time, |
1079 | 376253ec | aliguori | int hold_time)
|
1080 | a3a91a35 | bellard | { |
1081 | 3401c0d9 | balrog | char keyname_buf[16]; |
1082 | 3401c0d9 | balrog | char *separator;
|
1083 | 3401c0d9 | balrog | int keyname_len, keycode, i;
|
1084 | 3401c0d9 | balrog | |
1085 | c8256f9d | balrog | if (nb_pending_keycodes > 0) { |
1086 | c8256f9d | balrog | qemu_del_timer(key_timer); |
1087 | c8256f9d | balrog | release_keys(NULL);
|
1088 | c8256f9d | balrog | } |
1089 | c8256f9d | balrog | if (!has_hold_time)
|
1090 | c8256f9d | balrog | hold_time = 100;
|
1091 | c8256f9d | balrog | i = 0;
|
1092 | 3401c0d9 | balrog | while (1) { |
1093 | 3401c0d9 | balrog | separator = strchr(string, '-');
|
1094 | 3401c0d9 | balrog | keyname_len = separator ? separator - string : strlen(string); |
1095 | 3401c0d9 | balrog | if (keyname_len > 0) { |
1096 | 3401c0d9 | balrog | pstrcpy(keyname_buf, sizeof(keyname_buf), string);
|
1097 | 3401c0d9 | balrog | if (keyname_len > sizeof(keyname_buf) - 1) { |
1098 | 376253ec | aliguori | monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf);
|
1099 | 3401c0d9 | balrog | return;
|
1100 | a3a91a35 | bellard | } |
1101 | c8256f9d | balrog | if (i == MAX_KEYCODES) {
|
1102 | 376253ec | aliguori | monitor_printf(mon, "too many keys\n");
|
1103 | 3401c0d9 | balrog | return;
|
1104 | 3401c0d9 | balrog | } |
1105 | 3401c0d9 | balrog | keyname_buf[keyname_len] = 0;
|
1106 | 3401c0d9 | balrog | keycode = get_keycode(keyname_buf); |
1107 | 3401c0d9 | balrog | if (keycode < 0) { |
1108 | 376253ec | aliguori | monitor_printf(mon, "unknown key: '%s'\n", keyname_buf);
|
1109 | 3401c0d9 | balrog | return;
|
1110 | 3401c0d9 | balrog | } |
1111 | c8256f9d | balrog | keycodes[i++] = keycode; |
1112 | a3a91a35 | bellard | } |
1113 | 3401c0d9 | balrog | if (!separator)
|
1114 | a3a91a35 | bellard | break;
|
1115 | 3401c0d9 | balrog | string = separator + 1;
|
1116 | a3a91a35 | bellard | } |
1117 | c8256f9d | balrog | nb_pending_keycodes = i; |
1118 | a3a91a35 | bellard | /* key down events */
|
1119 | c8256f9d | balrog | for (i = 0; i < nb_pending_keycodes; i++) { |
1120 | a3a91a35 | bellard | keycode = keycodes[i]; |
1121 | a3a91a35 | bellard | if (keycode & 0x80) |
1122 | a3a91a35 | bellard | kbd_put_keycode(0xe0);
|
1123 | a3a91a35 | bellard | kbd_put_keycode(keycode & 0x7f);
|
1124 | a3a91a35 | bellard | } |
1125 | c8256f9d | balrog | /* delayed key up events */
|
1126 | f227f17d | balrog | qemu_mod_timer(key_timer, qemu_get_clock(vm_clock) + |
1127 | f227f17d | balrog | muldiv64(ticks_per_sec, hold_time, 1000));
|
1128 | a3a91a35 | bellard | } |
1129 | a3a91a35 | bellard | |
1130 | 13224a87 | bellard | static int mouse_button_state; |
1131 | 13224a87 | bellard | |
1132 | 376253ec | aliguori | static void do_mouse_move(Monitor *mon, const char *dx_str, const char *dy_str, |
1133 | 13224a87 | bellard | const char *dz_str) |
1134 | 13224a87 | bellard | { |
1135 | 13224a87 | bellard | int dx, dy, dz;
|
1136 | 13224a87 | bellard | dx = strtol(dx_str, NULL, 0); |
1137 | 13224a87 | bellard | dy = strtol(dy_str, NULL, 0); |
1138 | 13224a87 | bellard | dz = 0;
|
1139 | 5fafdf24 | ths | if (dz_str)
|
1140 | 13224a87 | bellard | dz = strtol(dz_str, NULL, 0); |
1141 | 13224a87 | bellard | kbd_mouse_event(dx, dy, dz, mouse_button_state); |
1142 | 13224a87 | bellard | } |
1143 | 13224a87 | bellard | |
1144 | 376253ec | aliguori | static void do_mouse_button(Monitor *mon, int button_state) |
1145 | 13224a87 | bellard | { |
1146 | 13224a87 | bellard | mouse_button_state = button_state; |
1147 | 13224a87 | bellard | kbd_mouse_event(0, 0, 0, mouse_button_state); |
1148 | 13224a87 | bellard | } |
1149 | 13224a87 | bellard | |
1150 | 376253ec | aliguori | static void do_ioport_read(Monitor *mon, int count, int format, int size, |
1151 | 376253ec | aliguori | int addr, int has_index, int index) |
1152 | 3440557b | bellard | { |
1153 | 3440557b | bellard | uint32_t val; |
1154 | 3440557b | bellard | int suffix;
|
1155 | 3440557b | bellard | |
1156 | 3440557b | bellard | if (has_index) {
|
1157 | 3440557b | bellard | cpu_outb(NULL, addr & 0xffff, index & 0xff); |
1158 | 3440557b | bellard | addr++; |
1159 | 3440557b | bellard | } |
1160 | 3440557b | bellard | addr &= 0xffff;
|
1161 | 3440557b | bellard | |
1162 | 3440557b | bellard | switch(size) {
|
1163 | 3440557b | bellard | default:
|
1164 | 3440557b | bellard | case 1: |
1165 | 3440557b | bellard | val = cpu_inb(NULL, addr);
|
1166 | 3440557b | bellard | suffix = 'b';
|
1167 | 3440557b | bellard | break;
|
1168 | 3440557b | bellard | case 2: |
1169 | 3440557b | bellard | val = cpu_inw(NULL, addr);
|
1170 | 3440557b | bellard | suffix = 'w';
|
1171 | 3440557b | bellard | break;
|
1172 | 3440557b | bellard | case 4: |
1173 | 3440557b | bellard | val = cpu_inl(NULL, addr);
|
1174 | 3440557b | bellard | suffix = 'l';
|
1175 | 3440557b | bellard | break;
|
1176 | 3440557b | bellard | } |
1177 | 376253ec | aliguori | monitor_printf(mon, "port%c[0x%04x] = %#0*x\n",
|
1178 | 376253ec | aliguori | suffix, addr, size * 2, val);
|
1179 | 3440557b | bellard | } |
1180 | a3a91a35 | bellard | |
1181 | 3b4366de | blueswir1 | /* boot_set handler */
|
1182 | 3b4366de | blueswir1 | static QEMUBootSetHandler *qemu_boot_set_handler = NULL; |
1183 | 3b4366de | blueswir1 | static void *boot_opaque; |
1184 | 3b4366de | blueswir1 | |
1185 | 3b4366de | blueswir1 | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque) |
1186 | 3b4366de | blueswir1 | { |
1187 | 3b4366de | blueswir1 | qemu_boot_set_handler = func; |
1188 | 3b4366de | blueswir1 | boot_opaque = opaque; |
1189 | 3b4366de | blueswir1 | } |
1190 | 3b4366de | blueswir1 | |
1191 | 376253ec | aliguori | static void do_boot_set(Monitor *mon, const char *bootdevice) |
1192 | 0ecdffbb | aurel32 | { |
1193 | 0ecdffbb | aurel32 | int res;
|
1194 | 0ecdffbb | aurel32 | |
1195 | 0ecdffbb | aurel32 | if (qemu_boot_set_handler) {
|
1196 | 3b4366de | blueswir1 | res = qemu_boot_set_handler(boot_opaque, bootdevice); |
1197 | 0ecdffbb | aurel32 | if (res == 0) |
1198 | 376253ec | aliguori | monitor_printf(mon, "boot device list now set to %s\n",
|
1199 | 376253ec | aliguori | bootdevice); |
1200 | 0ecdffbb | aurel32 | else
|
1201 | 376253ec | aliguori | monitor_printf(mon, "setting boot device list failed with "
|
1202 | 376253ec | aliguori | "error %i\n", res);
|
1203 | 0ecdffbb | aurel32 | } else {
|
1204 | 376253ec | aliguori | monitor_printf(mon, "no function defined to set boot device list for "
|
1205 | 376253ec | aliguori | "this architecture\n");
|
1206 | 0ecdffbb | aurel32 | } |
1207 | 0ecdffbb | aurel32 | } |
1208 | 0ecdffbb | aurel32 | |
1209 | 376253ec | aliguori | static void do_system_reset(Monitor *mon) |
1210 | e4f9082b | bellard | { |
1211 | e4f9082b | bellard | qemu_system_reset_request(); |
1212 | e4f9082b | bellard | } |
1213 | e4f9082b | bellard | |
1214 | 376253ec | aliguori | static void do_system_powerdown(Monitor *mon) |
1215 | 3475187d | bellard | { |
1216 | 3475187d | bellard | qemu_system_powerdown_request(); |
1217 | 3475187d | bellard | } |
1218 | 3475187d | bellard | |
1219 | b86bda5b | bellard | #if defined(TARGET_I386)
|
1220 | 376253ec | aliguori | static void print_pte(Monitor *mon, uint32_t addr, uint32_t pte, uint32_t mask) |
1221 | b86bda5b | bellard | { |
1222 | 376253ec | aliguori | monitor_printf(mon, "%08x: %08x %c%c%c%c%c%c%c%c\n",
|
1223 | 376253ec | aliguori | addr, |
1224 | 376253ec | aliguori | pte & mask, |
1225 | 376253ec | aliguori | pte & PG_GLOBAL_MASK ? 'G' : '-', |
1226 | 376253ec | aliguori | pte & PG_PSE_MASK ? 'P' : '-', |
1227 | 376253ec | aliguori | pte & PG_DIRTY_MASK ? 'D' : '-', |
1228 | 376253ec | aliguori | pte & PG_ACCESSED_MASK ? 'A' : '-', |
1229 | 376253ec | aliguori | pte & PG_PCD_MASK ? 'C' : '-', |
1230 | 376253ec | aliguori | pte & PG_PWT_MASK ? 'T' : '-', |
1231 | 376253ec | aliguori | pte & PG_USER_MASK ? 'U' : '-', |
1232 | 376253ec | aliguori | pte & PG_RW_MASK ? 'W' : '-'); |
1233 | b86bda5b | bellard | } |
1234 | b86bda5b | bellard | |
1235 | 376253ec | aliguori | static void tlb_info(Monitor *mon) |
1236 | b86bda5b | bellard | { |
1237 | 6a00d601 | bellard | CPUState *env; |
1238 | b86bda5b | bellard | int l1, l2;
|
1239 | b86bda5b | bellard | uint32_t pgd, pde, pte; |
1240 | b86bda5b | bellard | |
1241 | 6a00d601 | bellard | env = mon_get_cpu(); |
1242 | 6a00d601 | bellard | if (!env)
|
1243 | 6a00d601 | bellard | return;
|
1244 | 6a00d601 | bellard | |
1245 | b86bda5b | bellard | if (!(env->cr[0] & CR0_PG_MASK)) { |
1246 | 376253ec | aliguori | monitor_printf(mon, "PG disabled\n");
|
1247 | b86bda5b | bellard | return;
|
1248 | b86bda5b | bellard | } |
1249 | b86bda5b | bellard | pgd = env->cr[3] & ~0xfff; |
1250 | b86bda5b | bellard | for(l1 = 0; l1 < 1024; l1++) { |
1251 | b86bda5b | bellard | cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4); |
1252 | b86bda5b | bellard | pde = le32_to_cpu(pde); |
1253 | b86bda5b | bellard | if (pde & PG_PRESENT_MASK) {
|
1254 | b86bda5b | bellard | if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { |
1255 | 376253ec | aliguori | print_pte(mon, (l1 << 22), pde, ~((1 << 20) - 1)); |
1256 | b86bda5b | bellard | } else {
|
1257 | b86bda5b | bellard | for(l2 = 0; l2 < 1024; l2++) { |
1258 | 5fafdf24 | ths | cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, |
1259 | b86bda5b | bellard | (uint8_t *)&pte, 4);
|
1260 | b86bda5b | bellard | pte = le32_to_cpu(pte); |
1261 | b86bda5b | bellard | if (pte & PG_PRESENT_MASK) {
|
1262 | 376253ec | aliguori | print_pte(mon, (l1 << 22) + (l2 << 12), |
1263 | 5fafdf24 | ths | pte & ~PG_PSE_MASK, |
1264 | b86bda5b | bellard | ~0xfff);
|
1265 | b86bda5b | bellard | } |
1266 | b86bda5b | bellard | } |
1267 | b86bda5b | bellard | } |
1268 | b86bda5b | bellard | } |
1269 | b86bda5b | bellard | } |
1270 | b86bda5b | bellard | } |
1271 | b86bda5b | bellard | |
1272 | 376253ec | aliguori | static void mem_print(Monitor *mon, uint32_t *pstart, int *plast_prot, |
1273 | b86bda5b | bellard | uint32_t end, int prot)
|
1274 | b86bda5b | bellard | { |
1275 | 9746b15b | bellard | int prot1;
|
1276 | 9746b15b | bellard | prot1 = *plast_prot; |
1277 | 9746b15b | bellard | if (prot != prot1) {
|
1278 | b86bda5b | bellard | if (*pstart != -1) { |
1279 | 376253ec | aliguori | monitor_printf(mon, "%08x-%08x %08x %c%c%c\n",
|
1280 | 376253ec | aliguori | *pstart, end, end - *pstart, |
1281 | 376253ec | aliguori | prot1 & PG_USER_MASK ? 'u' : '-', |
1282 | 376253ec | aliguori | 'r',
|
1283 | 376253ec | aliguori | prot1 & PG_RW_MASK ? 'w' : '-'); |
1284 | b86bda5b | bellard | } |
1285 | b86bda5b | bellard | if (prot != 0) |
1286 | b86bda5b | bellard | *pstart = end; |
1287 | b86bda5b | bellard | else
|
1288 | b86bda5b | bellard | *pstart = -1;
|
1289 | b86bda5b | bellard | *plast_prot = prot; |
1290 | b86bda5b | bellard | } |
1291 | b86bda5b | bellard | } |
1292 | b86bda5b | bellard | |
1293 | 376253ec | aliguori | static void mem_info(Monitor *mon) |
1294 | b86bda5b | bellard | { |
1295 | 6a00d601 | bellard | CPUState *env; |
1296 | b86bda5b | bellard | int l1, l2, prot, last_prot;
|
1297 | b86bda5b | bellard | uint32_t pgd, pde, pte, start, end; |
1298 | b86bda5b | bellard | |
1299 | 6a00d601 | bellard | env = mon_get_cpu(); |
1300 | 6a00d601 | bellard | if (!env)
|
1301 | 6a00d601 | bellard | return;
|
1302 | 6a00d601 | bellard | |
1303 | b86bda5b | bellard | if (!(env->cr[0] & CR0_PG_MASK)) { |
1304 | 376253ec | aliguori | monitor_printf(mon, "PG disabled\n");
|
1305 | b86bda5b | bellard | return;
|
1306 | b86bda5b | bellard | } |
1307 | b86bda5b | bellard | pgd = env->cr[3] & ~0xfff; |
1308 | b86bda5b | bellard | last_prot = 0;
|
1309 | b86bda5b | bellard | start = -1;
|
1310 | b86bda5b | bellard | for(l1 = 0; l1 < 1024; l1++) { |
1311 | b86bda5b | bellard | cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4); |
1312 | b86bda5b | bellard | pde = le32_to_cpu(pde); |
1313 | b86bda5b | bellard | end = l1 << 22;
|
1314 | b86bda5b | bellard | if (pde & PG_PRESENT_MASK) {
|
1315 | b86bda5b | bellard | if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { |
1316 | b86bda5b | bellard | prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK); |
1317 | 376253ec | aliguori | mem_print(mon, &start, &last_prot, end, prot); |
1318 | b86bda5b | bellard | } else {
|
1319 | b86bda5b | bellard | for(l2 = 0; l2 < 1024; l2++) { |
1320 | 5fafdf24 | ths | cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, |
1321 | b86bda5b | bellard | (uint8_t *)&pte, 4);
|
1322 | b86bda5b | bellard | pte = le32_to_cpu(pte); |
1323 | b86bda5b | bellard | end = (l1 << 22) + (l2 << 12); |
1324 | b86bda5b | bellard | if (pte & PG_PRESENT_MASK) {
|
1325 | b86bda5b | bellard | prot = pte & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK); |
1326 | b86bda5b | bellard | } else {
|
1327 | b86bda5b | bellard | prot = 0;
|
1328 | b86bda5b | bellard | } |
1329 | 376253ec | aliguori | mem_print(mon, &start, &last_prot, end, prot); |
1330 | b86bda5b | bellard | } |
1331 | b86bda5b | bellard | } |
1332 | b86bda5b | bellard | } else {
|
1333 | b86bda5b | bellard | prot = 0;
|
1334 | 376253ec | aliguori | mem_print(mon, &start, &last_prot, end, prot); |
1335 | b86bda5b | bellard | } |
1336 | b86bda5b | bellard | } |
1337 | b86bda5b | bellard | } |
1338 | b86bda5b | bellard | #endif
|
1339 | b86bda5b | bellard | |
1340 | 7c664e2f | aurel32 | #if defined(TARGET_SH4)
|
1341 | 7c664e2f | aurel32 | |
1342 | 376253ec | aliguori | static void print_tlb(Monitor *mon, int idx, tlb_t *tlb) |
1343 | 7c664e2f | aurel32 | { |
1344 | 376253ec | aliguori | monitor_printf(mon, " tlb%i:\t"
|
1345 | 376253ec | aliguori | "asid=%hhu vpn=%x\tppn=%x\tsz=%hhu size=%u\t"
|
1346 | 376253ec | aliguori | "v=%hhu shared=%hhu cached=%hhu prot=%hhu "
|
1347 | 376253ec | aliguori | "dirty=%hhu writethrough=%hhu\n",
|
1348 | 376253ec | aliguori | idx, |
1349 | 376253ec | aliguori | tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size, |
1350 | 376253ec | aliguori | tlb->v, tlb->sh, tlb->c, tlb->pr, |
1351 | 376253ec | aliguori | tlb->d, tlb->wt); |
1352 | 7c664e2f | aurel32 | } |
1353 | 7c664e2f | aurel32 | |
1354 | 376253ec | aliguori | static void tlb_info(Monitor *mon) |
1355 | 7c664e2f | aurel32 | { |
1356 | 7c664e2f | aurel32 | CPUState *env = mon_get_cpu(); |
1357 | 7c664e2f | aurel32 | int i;
|
1358 | 7c664e2f | aurel32 | |
1359 | 376253ec | aliguori | monitor_printf (mon, "ITLB:\n");
|
1360 | 7c664e2f | aurel32 | for (i = 0 ; i < ITLB_SIZE ; i++) |
1361 | 376253ec | aliguori | print_tlb (mon, i, &env->itlb[i]); |
1362 | 376253ec | aliguori | monitor_printf (mon, "UTLB:\n");
|
1363 | 7c664e2f | aurel32 | for (i = 0 ; i < UTLB_SIZE ; i++) |
1364 | 376253ec | aliguori | print_tlb (mon, i, &env->utlb[i]); |
1365 | 7c664e2f | aurel32 | } |
1366 | 7c664e2f | aurel32 | |
1367 | 7c664e2f | aurel32 | #endif
|
1368 | 7c664e2f | aurel32 | |
1369 | 376253ec | aliguori | static void do_info_kqemu(Monitor *mon) |
1370 | 0f4c6415 | bellard | { |
1371 | 640f42e4 | blueswir1 | #ifdef CONFIG_KQEMU
|
1372 | 6a00d601 | bellard | CPUState *env; |
1373 | 0f4c6415 | bellard | int val;
|
1374 | 0f4c6415 | bellard | val = 0;
|
1375 | 6a00d601 | bellard | env = mon_get_cpu(); |
1376 | 6a00d601 | bellard | if (!env) {
|
1377 | 376253ec | aliguori | monitor_printf(mon, "No cpu initialized yet");
|
1378 | 6a00d601 | bellard | return;
|
1379 | 6a00d601 | bellard | } |
1380 | 6a00d601 | bellard | val = env->kqemu_enabled; |
1381 | 376253ec | aliguori | monitor_printf(mon, "kqemu support: ");
|
1382 | 5f1ce948 | bellard | switch(val) {
|
1383 | 5f1ce948 | bellard | default:
|
1384 | 5f1ce948 | bellard | case 0: |
1385 | 376253ec | aliguori | monitor_printf(mon, "disabled\n");
|
1386 | 5f1ce948 | bellard | break;
|
1387 | 5f1ce948 | bellard | case 1: |
1388 | 376253ec | aliguori | monitor_printf(mon, "enabled for user code\n");
|
1389 | 5f1ce948 | bellard | break;
|
1390 | 5f1ce948 | bellard | case 2: |
1391 | 376253ec | aliguori | monitor_printf(mon, "enabled for user and kernel code\n");
|
1392 | 5f1ce948 | bellard | break;
|
1393 | 5f1ce948 | bellard | } |
1394 | 0f4c6415 | bellard | #else
|
1395 | 376253ec | aliguori | monitor_printf(mon, "kqemu support: not compiled\n");
|
1396 | 0f4c6415 | bellard | #endif
|
1397 | 5fafdf24 | ths | } |
1398 | 0f4c6415 | bellard | |
1399 | 376253ec | aliguori | static void do_info_kvm(Monitor *mon) |
1400 | 7ba1e619 | aliguori | { |
1401 | 7ba1e619 | aliguori | #ifdef CONFIG_KVM
|
1402 | 376253ec | aliguori | monitor_printf(mon, "kvm support: ");
|
1403 | 7ba1e619 | aliguori | if (kvm_enabled())
|
1404 | 376253ec | aliguori | monitor_printf(mon, "enabled\n");
|
1405 | 7ba1e619 | aliguori | else
|
1406 | 376253ec | aliguori | monitor_printf(mon, "disabled\n");
|
1407 | 7ba1e619 | aliguori | #else
|
1408 | 376253ec | aliguori | monitor_printf(mon, "kvm support: not compiled\n");
|
1409 | 7ba1e619 | aliguori | #endif
|
1410 | 7ba1e619 | aliguori | } |
1411 | 7ba1e619 | aliguori | |
1412 | 030ea37b | aliguori | static void do_info_numa(Monitor *mon) |
1413 | 030ea37b | aliguori | { |
1414 | b28b6230 | aliguori | int i;
|
1415 | 030ea37b | aliguori | CPUState *env; |
1416 | 030ea37b | aliguori | |
1417 | 030ea37b | aliguori | monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
|
1418 | 030ea37b | aliguori | for (i = 0; i < nb_numa_nodes; i++) { |
1419 | 030ea37b | aliguori | monitor_printf(mon, "node %d cpus:", i);
|
1420 | 030ea37b | aliguori | for (env = first_cpu; env != NULL; env = env->next_cpu) { |
1421 | 030ea37b | aliguori | if (env->numa_node == i) {
|
1422 | 030ea37b | aliguori | monitor_printf(mon, " %d", env->cpu_index);
|
1423 | 030ea37b | aliguori | } |
1424 | 030ea37b | aliguori | } |
1425 | 030ea37b | aliguori | monitor_printf(mon, "\n");
|
1426 | 030ea37b | aliguori | monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i, |
1427 | 030ea37b | aliguori | node_mem[i] >> 20);
|
1428 | 030ea37b | aliguori | } |
1429 | 030ea37b | aliguori | } |
1430 | 030ea37b | aliguori | |
1431 | 5f1ce948 | bellard | #ifdef CONFIG_PROFILER
|
1432 | 5f1ce948 | bellard | |
1433 | 5f1ce948 | bellard | int64_t kqemu_time; |
1434 | 5f1ce948 | bellard | int64_t qemu_time; |
1435 | 5f1ce948 | bellard | int64_t kqemu_exec_count; |
1436 | 5f1ce948 | bellard | int64_t dev_time; |
1437 | 5f1ce948 | bellard | int64_t kqemu_ret_int_count; |
1438 | 5f1ce948 | bellard | int64_t kqemu_ret_excp_count; |
1439 | 5f1ce948 | bellard | int64_t kqemu_ret_intr_count; |
1440 | 5f1ce948 | bellard | |
1441 | 376253ec | aliguori | static void do_info_profile(Monitor *mon) |
1442 | 5f1ce948 | bellard | { |
1443 | 5f1ce948 | bellard | int64_t total; |
1444 | 5f1ce948 | bellard | total = qemu_time; |
1445 | 5f1ce948 | bellard | if (total == 0) |
1446 | 5f1ce948 | bellard | total = 1;
|
1447 | 376253ec | aliguori | monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n", |
1448 | 376253ec | aliguori | dev_time, dev_time / (double)ticks_per_sec);
|
1449 | 376253ec | aliguori | monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n", |
1450 | 376253ec | aliguori | qemu_time, qemu_time / (double)ticks_per_sec);
|
1451 | 376253ec | aliguori | monitor_printf(mon, "kqemu time %" PRId64 " (%0.3f %0.1f%%) count=%" |
1452 | 376253ec | aliguori | PRId64 " int=%" PRId64 " excp=%" PRId64 " intr=%" |
1453 | 376253ec | aliguori | PRId64 "\n",
|
1454 | 376253ec | aliguori | kqemu_time, kqemu_time / (double)ticks_per_sec,
|
1455 | 376253ec | aliguori | kqemu_time / (double)total * 100.0, |
1456 | 376253ec | aliguori | kqemu_exec_count, |
1457 | 376253ec | aliguori | kqemu_ret_int_count, |
1458 | 376253ec | aliguori | kqemu_ret_excp_count, |
1459 | 376253ec | aliguori | kqemu_ret_intr_count); |
1460 | 5f1ce948 | bellard | qemu_time = 0;
|
1461 | 5f1ce948 | bellard | kqemu_time = 0;
|
1462 | 5f1ce948 | bellard | kqemu_exec_count = 0;
|
1463 | 5f1ce948 | bellard | dev_time = 0;
|
1464 | 5f1ce948 | bellard | kqemu_ret_int_count = 0;
|
1465 | 5f1ce948 | bellard | kqemu_ret_excp_count = 0;
|
1466 | 5f1ce948 | bellard | kqemu_ret_intr_count = 0;
|
1467 | 640f42e4 | blueswir1 | #ifdef CONFIG_KQEMU
|
1468 | 5f1ce948 | bellard | kqemu_record_dump(); |
1469 | 5f1ce948 | bellard | #endif
|
1470 | 5f1ce948 | bellard | } |
1471 | 5f1ce948 | bellard | #else
|
1472 | 376253ec | aliguori | static void do_info_profile(Monitor *mon) |
1473 | 5f1ce948 | bellard | { |
1474 | 376253ec | aliguori | monitor_printf(mon, "Internal profiler not compiled\n");
|
1475 | 5f1ce948 | bellard | } |
1476 | 5f1ce948 | bellard | #endif
|
1477 | 5f1ce948 | bellard | |
1478 | ec36b695 | bellard | /* Capture support */
|
1479 | ec36b695 | bellard | static LIST_HEAD (capture_list_head, CaptureState) capture_head;
|
1480 | ec36b695 | bellard | |
1481 | 376253ec | aliguori | static void do_info_capture(Monitor *mon) |
1482 | ec36b695 | bellard | { |
1483 | ec36b695 | bellard | int i;
|
1484 | ec36b695 | bellard | CaptureState *s; |
1485 | ec36b695 | bellard | |
1486 | ec36b695 | bellard | for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) { |
1487 | 376253ec | aliguori | monitor_printf(mon, "[%d]: ", i);
|
1488 | ec36b695 | bellard | s->ops.info (s->opaque); |
1489 | ec36b695 | bellard | } |
1490 | ec36b695 | bellard | } |
1491 | ec36b695 | bellard | |
1492 | 376253ec | aliguori | static void do_stop_capture(Monitor *mon, int n) |
1493 | ec36b695 | bellard | { |
1494 | ec36b695 | bellard | int i;
|
1495 | ec36b695 | bellard | CaptureState *s; |
1496 | ec36b695 | bellard | |
1497 | ec36b695 | bellard | for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) { |
1498 | ec36b695 | bellard | if (i == n) {
|
1499 | ec36b695 | bellard | s->ops.destroy (s->opaque); |
1500 | ec36b695 | bellard | LIST_REMOVE (s, entries); |
1501 | ec36b695 | bellard | qemu_free (s); |
1502 | ec36b695 | bellard | return;
|
1503 | ec36b695 | bellard | } |
1504 | ec36b695 | bellard | } |
1505 | ec36b695 | bellard | } |
1506 | ec36b695 | bellard | |
1507 | ec36b695 | bellard | #ifdef HAS_AUDIO
|
1508 | 376253ec | aliguori | static void do_wav_capture(Monitor *mon, const char *path, |
1509 | 376253ec | aliguori | int has_freq, int freq, |
1510 | 376253ec | aliguori | int has_bits, int bits, |
1511 | 376253ec | aliguori | int has_channels, int nchannels) |
1512 | ec36b695 | bellard | { |
1513 | ec36b695 | bellard | CaptureState *s; |
1514 | ec36b695 | bellard | |
1515 | ec36b695 | bellard | s = qemu_mallocz (sizeof (*s));
|
1516 | ec36b695 | bellard | |
1517 | ec36b695 | bellard | freq = has_freq ? freq : 44100;
|
1518 | ec36b695 | bellard | bits = has_bits ? bits : 16;
|
1519 | ec36b695 | bellard | nchannels = has_channels ? nchannels : 2;
|
1520 | ec36b695 | bellard | |
1521 | ec36b695 | bellard | if (wav_start_capture (s, path, freq, bits, nchannels)) {
|
1522 | 376253ec | aliguori | monitor_printf(mon, "Faied to add wave capture\n");
|
1523 | ec36b695 | bellard | qemu_free (s); |
1524 | ec36b695 | bellard | } |
1525 | ec36b695 | bellard | LIST_INSERT_HEAD (&capture_head, s, entries); |
1526 | ec36b695 | bellard | } |
1527 | ec36b695 | bellard | #endif
|
1528 | ec36b695 | bellard | |
1529 | dc1c0b74 | aurel32 | #if defined(TARGET_I386)
|
1530 | 376253ec | aliguori | static void do_inject_nmi(Monitor *mon, int cpu_index) |
1531 | dc1c0b74 | aurel32 | { |
1532 | dc1c0b74 | aurel32 | CPUState *env; |
1533 | dc1c0b74 | aurel32 | |
1534 | dc1c0b74 | aurel32 | for (env = first_cpu; env != NULL; env = env->next_cpu) |
1535 | dc1c0b74 | aurel32 | if (env->cpu_index == cpu_index) {
|
1536 | dc1c0b74 | aurel32 | cpu_interrupt(env, CPU_INTERRUPT_NMI); |
1537 | dc1c0b74 | aurel32 | break;
|
1538 | dc1c0b74 | aurel32 | } |
1539 | dc1c0b74 | aurel32 | } |
1540 | dc1c0b74 | aurel32 | #endif
|
1541 | dc1c0b74 | aurel32 | |
1542 | 376253ec | aliguori | static void do_info_status(Monitor *mon) |
1543 | 6f9c5ee7 | aurel32 | { |
1544 | 1b530a6d | aurel32 | if (vm_running) {
|
1545 | 1b530a6d | aurel32 | if (singlestep) {
|
1546 | 1b530a6d | aurel32 | monitor_printf(mon, "VM status: running (single step mode)\n");
|
1547 | 1b530a6d | aurel32 | } else {
|
1548 | 1b530a6d | aurel32 | monitor_printf(mon, "VM status: running\n");
|
1549 | 1b530a6d | aurel32 | } |
1550 | 1b530a6d | aurel32 | } else
|
1551 | 376253ec | aliguori | monitor_printf(mon, "VM status: paused\n");
|
1552 | 6f9c5ee7 | aurel32 | } |
1553 | 6f9c5ee7 | aurel32 | |
1554 | 6f9c5ee7 | aurel32 | |
1555 | 376253ec | aliguori | static void do_balloon(Monitor *mon, int value) |
1556 | df751fa8 | aliguori | { |
1557 | df751fa8 | aliguori | ram_addr_t target = value; |
1558 | df751fa8 | aliguori | qemu_balloon(target << 20);
|
1559 | df751fa8 | aliguori | } |
1560 | df751fa8 | aliguori | |
1561 | 376253ec | aliguori | static void do_info_balloon(Monitor *mon) |
1562 | df751fa8 | aliguori | { |
1563 | df751fa8 | aliguori | ram_addr_t actual; |
1564 | df751fa8 | aliguori | |
1565 | df751fa8 | aliguori | actual = qemu_balloon_status(); |
1566 | bd322087 | aliguori | if (kvm_enabled() && !kvm_has_sync_mmu())
|
1567 | 376253ec | aliguori | monitor_printf(mon, "Using KVM without synchronous MMU, "
|
1568 | 376253ec | aliguori | "ballooning disabled\n");
|
1569 | bd322087 | aliguori | else if (actual == 0) |
1570 | 376253ec | aliguori | monitor_printf(mon, "Ballooning not activated in VM\n");
|
1571 | df751fa8 | aliguori | else
|
1572 | 376253ec | aliguori | monitor_printf(mon, "balloon: actual=%d\n", (int)(actual >> 20)); |
1573 | df751fa8 | aliguori | } |
1574 | df751fa8 | aliguori | |
1575 | 76655d6d | aliguori | static void do_acl(Monitor *mon, |
1576 | 76655d6d | aliguori | const char *command, |
1577 | 28a76be8 | aliguori | const char *aclname, |
1578 | 28a76be8 | aliguori | const char *match, |
1579 | 28a76be8 | aliguori | int has_index,
|
1580 | 28a76be8 | aliguori | int index)
|
1581 | 76655d6d | aliguori | { |
1582 | 76655d6d | aliguori | qemu_acl *acl; |
1583 | 76655d6d | aliguori | |
1584 | 76655d6d | aliguori | acl = qemu_acl_find(aclname); |
1585 | 76655d6d | aliguori | if (!acl) {
|
1586 | 28a76be8 | aliguori | monitor_printf(mon, "acl: unknown list '%s'\n", aclname);
|
1587 | 28a76be8 | aliguori | return;
|
1588 | 76655d6d | aliguori | } |
1589 | 76655d6d | aliguori | |
1590 | 76655d6d | aliguori | if (strcmp(command, "show") == 0) { |
1591 | 28a76be8 | aliguori | int i = 0; |
1592 | 28a76be8 | aliguori | qemu_acl_entry *entry; |
1593 | 28a76be8 | aliguori | monitor_printf(mon, "policy: %s\n",
|
1594 | 76655d6d | aliguori | acl->defaultDeny ? "deny" : "allow"); |
1595 | 28a76be8 | aliguori | TAILQ_FOREACH(entry, &acl->entries, next) { |
1596 | 28a76be8 | aliguori | i++; |
1597 | 28a76be8 | aliguori | monitor_printf(mon, "%d: %s %s\n", i,
|
1598 | 76655d6d | aliguori | entry->deny ? "deny" : "allow", |
1599 | 76655d6d | aliguori | entry->match); |
1600 | 28a76be8 | aliguori | } |
1601 | 76655d6d | aliguori | } else if (strcmp(command, "reset") == 0) { |
1602 | 28a76be8 | aliguori | qemu_acl_reset(acl); |
1603 | 28a76be8 | aliguori | monitor_printf(mon, "acl: removed all rules\n");
|
1604 | 76655d6d | aliguori | } else if (strcmp(command, "policy") == 0) { |
1605 | 28a76be8 | aliguori | if (!match) {
|
1606 | 28a76be8 | aliguori | monitor_printf(mon, "acl: missing policy parameter\n");
|
1607 | 28a76be8 | aliguori | return;
|
1608 | 28a76be8 | aliguori | } |
1609 | 28a76be8 | aliguori | |
1610 | 28a76be8 | aliguori | if (strcmp(match, "allow") == 0) { |
1611 | 28a76be8 | aliguori | acl->defaultDeny = 0;
|
1612 | 28a76be8 | aliguori | monitor_printf(mon, "acl: policy set to 'allow'\n");
|
1613 | 28a76be8 | aliguori | } else if (strcmp(match, "deny") == 0) { |
1614 | 28a76be8 | aliguori | acl->defaultDeny = 1;
|
1615 | 28a76be8 | aliguori | monitor_printf(mon, "acl: policy set to 'deny'\n");
|
1616 | 28a76be8 | aliguori | } else {
|
1617 | 28a76be8 | aliguori | monitor_printf(mon, "acl: unknown policy '%s', expected 'deny' or 'allow'\n", match);
|
1618 | 28a76be8 | aliguori | } |
1619 | 76655d6d | aliguori | } else if ((strcmp(command, "allow") == 0) || |
1620 | 28a76be8 | aliguori | (strcmp(command, "deny") == 0)) { |
1621 | 28a76be8 | aliguori | int deny = strcmp(command, "deny") == 0 ? 1 : 0; |
1622 | 28a76be8 | aliguori | int ret;
|
1623 | 28a76be8 | aliguori | |
1624 | 28a76be8 | aliguori | if (!match) {
|
1625 | 28a76be8 | aliguori | monitor_printf(mon, "acl: missing match parameter\n");
|
1626 | 28a76be8 | aliguori | return;
|
1627 | 28a76be8 | aliguori | } |
1628 | 28a76be8 | aliguori | |
1629 | 28a76be8 | aliguori | if (has_index)
|
1630 | 28a76be8 | aliguori | ret = qemu_acl_insert(acl, deny, match, index); |
1631 | 28a76be8 | aliguori | else
|
1632 | 28a76be8 | aliguori | ret = qemu_acl_append(acl, deny, match); |
1633 | 28a76be8 | aliguori | if (ret < 0) |
1634 | 28a76be8 | aliguori | monitor_printf(mon, "acl: unable to add acl entry\n");
|
1635 | 28a76be8 | aliguori | else
|
1636 | 28a76be8 | aliguori | monitor_printf(mon, "acl: added rule at position %d\n", ret);
|
1637 | 76655d6d | aliguori | } else if (strcmp(command, "remove") == 0) { |
1638 | 28a76be8 | aliguori | int ret;
|
1639 | 28a76be8 | aliguori | |
1640 | 28a76be8 | aliguori | if (!match) {
|
1641 | 28a76be8 | aliguori | monitor_printf(mon, "acl: missing match parameter\n");
|
1642 | 28a76be8 | aliguori | return;
|
1643 | 28a76be8 | aliguori | } |
1644 | 28a76be8 | aliguori | |
1645 | 28a76be8 | aliguori | ret = qemu_acl_remove(acl, match); |
1646 | 28a76be8 | aliguori | if (ret < 0) |
1647 | 28a76be8 | aliguori | monitor_printf(mon, "acl: no matching acl entry\n");
|
1648 | 28a76be8 | aliguori | else
|
1649 | 28a76be8 | aliguori | monitor_printf(mon, "acl: removed rule at position %d\n", ret);
|
1650 | 76655d6d | aliguori | } else {
|
1651 | 28a76be8 | aliguori | monitor_printf(mon, "acl: unknown command '%s'\n", command);
|
1652 | 76655d6d | aliguori | } |
1653 | 76655d6d | aliguori | } |
1654 | 76655d6d | aliguori | |
1655 | d2c639d6 | blueswir1 | /* Please update qemu-doc.texi when adding or changing commands */
|
1656 | 376253ec | aliguori | static const mon_cmd_t mon_cmds[] = { |
1657 | 376253ec | aliguori | { "help|?", "s?", help_cmd, |
1658 | 9dc39cba | bellard | "[cmd]", "show the help" }, |
1659 | 5fafdf24 | ths | { "commit", "s", do_commit, |
1660 | 7954c734 | bellard | "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" }, |
1661 | 9307c4c1 | bellard | { "info", "s?", do_info, |
1662 | cd33feec | aliguori | "[subcommand]", "show various information about the system state" }, |
1663 | 9307c4c1 | bellard | { "q|quit", "", do_quit, |
1664 | 9dc39cba | bellard | "", "quit the emulator" }, |
1665 | 81d0912d | bellard | { "eject", "-fB", do_eject, |
1666 | e598752a | ths | "[-f] device", "eject a removable medium (use -f to force it)" }, |
1667 | 2ecea9b8 | aurel32 | { "change", "BFs?", do_change, |
1668 | 2ecea9b8 | aurel32 | "device filename [format]", "change a removable medium, optional format" }, |
1669 | 5fafdf24 | ths | { "screendump", "F", do_screen_dump, |
1670 | 59a983b9 | bellard | "filename", "save screen into PPM image 'filename'" }, |
1671 | 788228c0 | balrog | { "logfile", "F", do_logfile, |
1672 | e735b91c | pbrook | "filename", "output logs to 'filename'" }, |
1673 | 9307c4c1 | bellard | { "log", "s", do_log, |
1674 | 5fafdf24 | ths | "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, |
1675 | faea38e7 | bellard | { "savevm", "s?", do_savevm, |
1676 | cd33feec | aliguori | "[tag|id]", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" }, |
1677 | faea38e7 | bellard | { "loadvm", "s", do_loadvm, |
1678 | 5fafdf24 | ths | "tag|id", "restore a VM snapshot from its tag or id" }, |
1679 | faea38e7 | bellard | { "delvm", "s", do_delvm, |
1680 | 5fafdf24 | ths | "tag|id", "delete a VM snapshot from its tag or id" }, |
1681 | 1b530a6d | aurel32 | { "singlestep", "s?", do_singlestep, |
1682 | 1b530a6d | aurel32 | "[on|off]", "run emulation in singlestep mode or switch to normal mode", }, |
1683 | 5fafdf24 | ths | { "stop", "", do_stop, |
1684 | 9307c4c1 | bellard | "", "stop emulation", }, |
1685 | 5fafdf24 | ths | { "c|cont", "", do_cont, |
1686 | 9307c4c1 | bellard | "", "resume emulation", }, |
1687 | 67b915a5 | bellard | #ifdef CONFIG_GDBSTUB
|
1688 | 5fafdf24 | ths | { "gdbserver", "s?", do_gdbserver, |
1689 | cd33feec | aliguori | "[device]", "start gdbserver on given device (default 'tcp::1234'), stop with 'none'", }, |
1690 | 67b915a5 | bellard | #endif
|
1691 | 5fafdf24 | ths | { "x", "/l", do_memory_dump, |
1692 | 9307c4c1 | bellard | "/fmt addr", "virtual memory dump starting at 'addr'", }, |
1693 | 5fafdf24 | ths | { "xp", "/l", do_physical_memory_dump, |
1694 | 9307c4c1 | bellard | "/fmt addr", "physical memory dump starting at 'addr'", }, |
1695 | 5fafdf24 | ths | { "p|print", "/l", do_print, |
1696 | 9307c4c1 | bellard | "/fmt expr", "print expression value (use $reg for CPU register access)", }, |
1697 | 5fafdf24 | ths | { "i", "/ii.", do_ioport_read, |
1698 | 3440557b | bellard | "/fmt addr", "I/O port read" }, |
1699 | 3440557b | bellard | |
1700 | c8256f9d | balrog | { "sendkey", "si?", do_sendkey, |
1701 | c8256f9d | balrog | "keys [hold_ms]", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)" }, |
1702 | 5fafdf24 | ths | { "system_reset", "", do_system_reset, |
1703 | e4f9082b | bellard | "", "reset the system" }, |
1704 | 5fafdf24 | ths | { "system_powerdown", "", do_system_powerdown, |
1705 | 3475187d | bellard | "", "send system power down event" }, |
1706 | 5fafdf24 | ths | { "sum", "ii", do_sum, |
1707 | e4cf1adc | bellard | "addr size", "compute the checksum of a memory region" }, |
1708 | a594cfbf | bellard | { "usb_add", "s", do_usb_add, |
1709 | a594cfbf | bellard | "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" }, |
1710 | a594cfbf | bellard | { "usb_del", "s", do_usb_del, |
1711 | a594cfbf | bellard | "device", "remove USB device 'bus.addr'" }, |
1712 | 5fafdf24 | ths | { "cpu", "i", do_cpu_set, |
1713 | 6a00d601 | bellard | "index", "set the default CPU" }, |
1714 | 5fafdf24 | ths | { "mouse_move", "sss?", do_mouse_move, |
1715 | 13224a87 | bellard | "dx dy [dz]", "send mouse move events" }, |
1716 | 5fafdf24 | ths | { "mouse_button", "i", do_mouse_button, |
1717 | 13224a87 | bellard | "state", "change mouse button state (1=L, 2=M, 4=R)" }, |
1718 | 455204eb | ths | { "mouse_set", "i", do_mouse_set, |
1719 | 455204eb | ths | "index", "set which mouse device receives events" }, |
1720 | ec36b695 | bellard | #ifdef HAS_AUDIO
|
1721 | ec36b695 | bellard | { "wavcapture", "si?i?i?", do_wav_capture, |
1722 | cd33feec | aliguori | "path [frequency [bits [channels]]]",
|
1723 | ec36b695 | bellard | "capture audio to a wave file (default frequency=44100 bits=16 channels=2)" },
|
1724 | ec36b695 | bellard | #endif
|
1725 | d2c639d6 | blueswir1 | { "stopcapture", "i", do_stop_capture, |
1726 | d2c639d6 | blueswir1 | "capture index", "stop capture" }, |
1727 | 5fafdf24 | ths | { "memsave", "lis", do_memory_save, |
1728 | b371dc59 | bellard | "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, |
1729 | a8bdf7a6 | aurel32 | { "pmemsave", "lis", do_physical_memory_save, |
1730 | a8bdf7a6 | aurel32 | "addr size file", "save to disk physical memory dump starting at 'addr' of size 'size'", }, |
1731 | 0ecdffbb | aurel32 | { "boot_set", "s", do_boot_set, |
1732 | 0ecdffbb | aurel32 | "bootdevice", "define new values for the boot device list" }, |
1733 | dc1c0b74 | aurel32 | #if defined(TARGET_I386)
|
1734 | dc1c0b74 | aurel32 | { "nmi", "i", do_inject_nmi, |
1735 | dc1c0b74 | aurel32 | "cpu", "inject an NMI on the given CPU", }, |
1736 | dc1c0b74 | aurel32 | #endif
|
1737 | 5bb7910a | aliguori | { "migrate", "-ds", do_migrate, |
1738 | 5bb7910a | aliguori | "[-d] uri", "migrate to URI (using -d to not wait for completion)" }, |
1739 | 5bb7910a | aliguori | { "migrate_cancel", "", do_migrate_cancel, |
1740 | 5bb7910a | aliguori | "", "cancel the current VM migration" }, |
1741 | 5bb7910a | aliguori | { "migrate_set_speed", "s", do_migrate_set_speed, |
1742 | 5bb7910a | aliguori | "value", "set maximum speed (in bytes) for migrations" }, |
1743 | 6f338c34 | aliguori | #if defined(TARGET_I386)
|
1744 | 6f338c34 | aliguori | { "drive_add", "ss", drive_hot_add, "pci_addr=[[<domain>:]<bus>:]<slot>\n" |
1745 | 6f338c34 | aliguori | "[file=file][,if=type][,bus=n]\n"
|
1746 | 6f338c34 | aliguori | "[,unit=m][,media=d][index=i]\n"
|
1747 | 6f338c34 | aliguori | "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
|
1748 | 6f338c34 | aliguori | "[snapshot=on|off][,cache=on|off]",
|
1749 | 6f338c34 | aliguori | "add drive to PCI storage controller" },
|
1750 | 6f338c34 | aliguori | { "pci_add", "sss", pci_device_hot_add, "pci_addr=auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" }, |
1751 | 6f338c34 | aliguori | { "pci_del", "s", pci_device_hot_remove, "pci_addr=[[<domain>:]<bus>:]<slot>", "hot remove PCI device" }, |
1752 | a66b11bf | aliguori | #endif
|
1753 | 5c8be678 | aliguori | { "host_net_add", "ss?", net_host_device_add, |
1754 | 5c8be678 | aliguori | "tap|user|socket|vde|dump [options]", "add host VLAN client" }, |
1755 | 6f338c34 | aliguori | { "host_net_remove", "is", net_host_device_remove, |
1756 | 6f338c34 | aliguori | "vlan_id name", "remove host VLAN client" }, |
1757 | d4ebe193 | aliguori | #ifdef CONFIG_SLIRP
|
1758 | d4ebe193 | aliguori | { "host_net_redir", "s", net_slirp_redir, |
1759 | d4ebe193 | aliguori | "[tcp|udp]:host-port:[guest-host]:guest-port", "redirect TCP or UDP connections from host to guest (requires -net user)" }, |
1760 | d4ebe193 | aliguori | #endif
|
1761 | df751fa8 | aliguori | { "balloon", "i", do_balloon, |
1762 | df751fa8 | aliguori | "target", "request VM to change it's memory allocation (in MB)" }, |
1763 | f029bd94 | aliguori | { "set_link", "ss", do_set_link, |
1764 | cd33feec | aliguori | "name up|down", "change the link status of a network adapter" }, |
1765 | cd33feec | aliguori | { "acl", "sss?i?", do_acl, "<command> <aclname> [<match> [<index>]]\n", |
1766 | 76655d6d | aliguori | "acl show vnc.username\n"
|
1767 | 76655d6d | aliguori | "acl policy vnc.username deny\n"
|
1768 | 76655d6d | aliguori | "acl allow vnc.username fred\n"
|
1769 | 76655d6d | aliguori | "acl deny vnc.username bob\n"
|
1770 | 76655d6d | aliguori | "acl reset vnc.username\n" },
|
1771 | 5fafdf24 | ths | { NULL, NULL, }, |
1772 | 9dc39cba | bellard | }; |
1773 | 9dc39cba | bellard | |
1774 | d2c639d6 | blueswir1 | /* Please update qemu-doc.texi when adding or changing commands */
|
1775 | 376253ec | aliguori | static const mon_cmd_t info_cmds[] = { |
1776 | 9bc9d1c7 | bellard | { "version", "", do_info_version, |
1777 | d2c639d6 | blueswir1 | "", "show the version of QEMU" }, |
1778 | 9307c4c1 | bellard | { "network", "", do_info_network, |
1779 | 9dc39cba | bellard | "", "show the network state" }, |
1780 | 5ccfae10 | aliguori | { "chardev", "", qemu_chr_info, |
1781 | 5ccfae10 | aliguori | "", "show the character devices" }, |
1782 | 376253ec | aliguori | { "block", "", bdrv_info, |
1783 | 9dc39cba | bellard | "", "show the block devices" }, |
1784 | 376253ec | aliguori | { "blockstats", "", bdrv_info_stats, |
1785 | a36e69dd | ths | "", "show block device statistics" }, |
1786 | 9307c4c1 | bellard | { "registers", "", do_info_registers, |
1787 | 9307c4c1 | bellard | "", "show the cpu registers" }, |
1788 | 6a00d601 | bellard | { "cpus", "", do_info_cpus, |
1789 | 6a00d601 | bellard | "", "show infos for each CPU" }, |
1790 | aa455485 | bellard | { "history", "", do_info_history, |
1791 | aa455485 | bellard | "", "show the command line history", }, |
1792 | 4a0fb71e | bellard | { "irq", "", irq_info, |
1793 | 4a0fb71e | bellard | "", "show the interrupts statistics (if available)", }, |
1794 | 4c27ba27 | bellard | { "pic", "", pic_info, |
1795 | 4c27ba27 | bellard | "", "show i8259 (PIC) state", }, |
1796 | 86e0c048 | bellard | { "pci", "", pci_info, |
1797 | 86e0c048 | bellard | "", "show PCI info", }, |
1798 | 7c664e2f | aurel32 | #if defined(TARGET_I386) || defined(TARGET_SH4)
|
1799 | b86bda5b | bellard | { "tlb", "", tlb_info, |
1800 | b86bda5b | bellard | "", "show virtual to physical memory mappings", }, |
1801 | 7c664e2f | aurel32 | #endif
|
1802 | 7c664e2f | aurel32 | #if defined(TARGET_I386)
|
1803 | b86bda5b | bellard | { "mem", "", mem_info, |
1804 | b86bda5b | bellard | "", "show the active virtual memory mappings", }, |
1805 | 16b29ae1 | aliguori | { "hpet", "", do_info_hpet, |
1806 | 16b29ae1 | aliguori | "", "show state of HPET", }, |
1807 | b86bda5b | bellard | #endif
|
1808 | e3db7226 | bellard | { "jit", "", do_info_jit, |
1809 | e3db7226 | bellard | "", "show dynamic compiler info", }, |
1810 | 0f4c6415 | bellard | { "kqemu", "", do_info_kqemu, |
1811 | d2c639d6 | blueswir1 | "", "show KQEMU information", }, |
1812 | 7ba1e619 | aliguori | { "kvm", "", do_info_kvm, |
1813 | d2c639d6 | blueswir1 | "", "show KVM information", }, |
1814 | 030ea37b | aliguori | { "numa", "", do_info_numa, |
1815 | 030ea37b | aliguori | "", "show NUMA information", }, |
1816 | a594cfbf | bellard | { "usb", "", usb_info, |
1817 | a594cfbf | bellard | "", "show guest USB devices", }, |
1818 | a594cfbf | bellard | { "usbhost", "", usb_host_info, |
1819 | a594cfbf | bellard | "", "show host USB devices", }, |
1820 | 5f1ce948 | bellard | { "profile", "", do_info_profile, |
1821 | 5f1ce948 | bellard | "", "show profiling information", }, |
1822 | ec36b695 | bellard | { "capture", "", do_info_capture, |
1823 | 17100159 | bellard | "", "show capture information" }, |
1824 | faea38e7 | bellard | { "snapshots", "", do_info_snapshots, |
1825 | 17100159 | bellard | "", "show the currently saved VM snapshots" }, |
1826 | 6f9c5ee7 | aurel32 | { "status", "", do_info_status, |
1827 | 6f9c5ee7 | aurel32 | "", "show the current VM status (running|paused)" }, |
1828 | 201a51fc | balrog | { "pcmcia", "", pcmcia_info, |
1829 | 201a51fc | balrog | "", "show guest PCMCIA status" }, |
1830 | 455204eb | ths | { "mice", "", do_info_mice, |
1831 | 455204eb | ths | "", "show which guest mouse is receiving events" }, |
1832 | a9ce8590 | bellard | { "vnc", "", do_info_vnc, |
1833 | a9ce8590 | bellard | "", "show the vnc server status"}, |
1834 | c35734b2 | ths | { "name", "", do_info_name, |
1835 | c35734b2 | ths | "", "show the current VM name" }, |
1836 | f1f23ad5 | blueswir1 | { "uuid", "", do_info_uuid, |
1837 | f1f23ad5 | blueswir1 | "", "show the current VM UUID" }, |
1838 | 76a66253 | j_mayer | #if defined(TARGET_PPC)
|
1839 | 76a66253 | j_mayer | { "cpustats", "", do_info_cpu_stats, |
1840 | 76a66253 | j_mayer | "", "show CPU statistics", }, |
1841 | 76a66253 | j_mayer | #endif
|
1842 | 31a60e22 | blueswir1 | #if defined(CONFIG_SLIRP)
|
1843 | 31a60e22 | blueswir1 | { "slirp", "", do_info_slirp, |
1844 | 31a60e22 | blueswir1 | "", "show SLIRP statistics", }, |
1845 | 31a60e22 | blueswir1 | #endif
|
1846 | 5bb7910a | aliguori | { "migrate", "", do_info_migrate, "", "show migration status" }, |
1847 | df751fa8 | aliguori | { "balloon", "", do_info_balloon, |
1848 | df751fa8 | aliguori | "", "show balloon information" }, |
1849 | 9dc39cba | bellard | { NULL, NULL, }, |
1850 | 9dc39cba | bellard | }; |
1851 | 9dc39cba | bellard | |
1852 | 9307c4c1 | bellard | /*******************************************************************/
|
1853 | 9307c4c1 | bellard | |
1854 | 9307c4c1 | bellard | static const char *pch; |
1855 | 9307c4c1 | bellard | static jmp_buf expr_env;
|
1856 | 9307c4c1 | bellard | |
1857 | 92a31b1f | bellard | #define MD_TLONG 0 |
1858 | 92a31b1f | bellard | #define MD_I32 1 |
1859 | 92a31b1f | bellard | |
1860 | 9307c4c1 | bellard | typedef struct MonitorDef { |
1861 | 9307c4c1 | bellard | const char *name; |
1862 | 9307c4c1 | bellard | int offset;
|
1863 | 8662d656 | blueswir1 | target_long (*get_value)(const struct MonitorDef *md, int val); |
1864 | 92a31b1f | bellard | int type;
|
1865 | 9307c4c1 | bellard | } MonitorDef; |
1866 | 9307c4c1 | bellard | |
1867 | 57206fd4 | bellard | #if defined(TARGET_I386)
|
1868 | 8662d656 | blueswir1 | static target_long monitor_get_pc (const struct MonitorDef *md, int val) |
1869 | 57206fd4 | bellard | { |
1870 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1871 | 6a00d601 | bellard | if (!env)
|
1872 | 6a00d601 | bellard | return 0; |
1873 | 6a00d601 | bellard | return env->eip + env->segs[R_CS].base;
|
1874 | 57206fd4 | bellard | } |
1875 | 57206fd4 | bellard | #endif
|
1876 | 57206fd4 | bellard | |
1877 | a541f297 | bellard | #if defined(TARGET_PPC)
|
1878 | 8662d656 | blueswir1 | static target_long monitor_get_ccr (const struct MonitorDef *md, int val) |
1879 | a541f297 | bellard | { |
1880 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1881 | a541f297 | bellard | unsigned int u; |
1882 | a541f297 | bellard | int i;
|
1883 | a541f297 | bellard | |
1884 | 6a00d601 | bellard | if (!env)
|
1885 | 6a00d601 | bellard | return 0; |
1886 | 6a00d601 | bellard | |
1887 | a541f297 | bellard | u = 0;
|
1888 | a541f297 | bellard | for (i = 0; i < 8; i++) |
1889 | 28a76be8 | aliguori | u |= env->crf[i] << (32 - (4 * i)); |
1890 | a541f297 | bellard | |
1891 | a541f297 | bellard | return u;
|
1892 | a541f297 | bellard | } |
1893 | a541f297 | bellard | |
1894 | 8662d656 | blueswir1 | static target_long monitor_get_msr (const struct MonitorDef *md, int val) |
1895 | a541f297 | bellard | { |
1896 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1897 | 6a00d601 | bellard | if (!env)
|
1898 | 6a00d601 | bellard | return 0; |
1899 | 0411a972 | j_mayer | return env->msr;
|
1900 | a541f297 | bellard | } |
1901 | a541f297 | bellard | |
1902 | 8662d656 | blueswir1 | static target_long monitor_get_xer (const struct MonitorDef *md, int val) |
1903 | a541f297 | bellard | { |
1904 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1905 | 6a00d601 | bellard | if (!env)
|
1906 | 6a00d601 | bellard | return 0; |
1907 | 3d7b417e | aurel32 | return env->xer;
|
1908 | a541f297 | bellard | } |
1909 | 9fddaa0c | bellard | |
1910 | 8662d656 | blueswir1 | static target_long monitor_get_decr (const struct MonitorDef *md, int val) |
1911 | 9fddaa0c | bellard | { |
1912 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1913 | 6a00d601 | bellard | if (!env)
|
1914 | 6a00d601 | bellard | return 0; |
1915 | 6a00d601 | bellard | return cpu_ppc_load_decr(env);
|
1916 | 9fddaa0c | bellard | } |
1917 | 9fddaa0c | bellard | |
1918 | 8662d656 | blueswir1 | static target_long monitor_get_tbu (const struct MonitorDef *md, int val) |
1919 | 9fddaa0c | bellard | { |
1920 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1921 | 6a00d601 | bellard | if (!env)
|
1922 | 6a00d601 | bellard | return 0; |
1923 | 6a00d601 | bellard | return cpu_ppc_load_tbu(env);
|
1924 | 9fddaa0c | bellard | } |
1925 | 9fddaa0c | bellard | |
1926 | 8662d656 | blueswir1 | static target_long monitor_get_tbl (const struct MonitorDef *md, int val) |
1927 | 9fddaa0c | bellard | { |
1928 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1929 | 6a00d601 | bellard | if (!env)
|
1930 | 6a00d601 | bellard | return 0; |
1931 | 6a00d601 | bellard | return cpu_ppc_load_tbl(env);
|
1932 | 9fddaa0c | bellard | } |
1933 | a541f297 | bellard | #endif
|
1934 | a541f297 | bellard | |
1935 | e95c8d51 | bellard | #if defined(TARGET_SPARC)
|
1936 | 7b936c0c | bellard | #ifndef TARGET_SPARC64
|
1937 | 8662d656 | blueswir1 | static target_long monitor_get_psr (const struct MonitorDef *md, int val) |
1938 | e95c8d51 | bellard | { |
1939 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1940 | 6a00d601 | bellard | if (!env)
|
1941 | 6a00d601 | bellard | return 0; |
1942 | 6a00d601 | bellard | return GET_PSR(env);
|
1943 | e95c8d51 | bellard | } |
1944 | 7b936c0c | bellard | #endif
|
1945 | e95c8d51 | bellard | |
1946 | 8662d656 | blueswir1 | static target_long monitor_get_reg(const struct MonitorDef *md, int val) |
1947 | e95c8d51 | bellard | { |
1948 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
1949 | 6a00d601 | bellard | if (!env)
|
1950 | 6a00d601 | bellard | return 0; |
1951 | 6a00d601 | bellard | return env->regwptr[val];
|
1952 | e95c8d51 | bellard | } |
1953 | e95c8d51 | bellard | #endif
|
1954 | e95c8d51 | bellard | |
1955 | 8662d656 | blueswir1 | static const MonitorDef monitor_defs[] = { |
1956 | 9307c4c1 | bellard | #ifdef TARGET_I386
|
1957 | 57206fd4 | bellard | |
1958 | 57206fd4 | bellard | #define SEG(name, seg) \
|
1959 | 92a31b1f | bellard | { name, offsetof(CPUState, segs[seg].selector), NULL, MD_I32 },\
|
1960 | 57206fd4 | bellard | { name ".base", offsetof(CPUState, segs[seg].base) },\
|
1961 | 92a31b1f | bellard | { name ".limit", offsetof(CPUState, segs[seg].limit), NULL, MD_I32 }, |
1962 | 57206fd4 | bellard | |
1963 | 9307c4c1 | bellard | { "eax", offsetof(CPUState, regs[0]) }, |
1964 | 9307c4c1 | bellard | { "ecx", offsetof(CPUState, regs[1]) }, |
1965 | 9307c4c1 | bellard | { "edx", offsetof(CPUState, regs[2]) }, |
1966 | 9307c4c1 | bellard | { "ebx", offsetof(CPUState, regs[3]) }, |
1967 | 9307c4c1 | bellard | { "esp|sp", offsetof(CPUState, regs[4]) }, |
1968 | 9307c4c1 | bellard | { "ebp|fp", offsetof(CPUState, regs[5]) }, |
1969 | 9307c4c1 | bellard | { "esi", offsetof(CPUState, regs[6]) }, |
1970 | 01038d2a | bellard | { "edi", offsetof(CPUState, regs[7]) }, |
1971 | 92a31b1f | bellard | #ifdef TARGET_X86_64
|
1972 | 92a31b1f | bellard | { "r8", offsetof(CPUState, regs[8]) }, |
1973 | 92a31b1f | bellard | { "r9", offsetof(CPUState, regs[9]) }, |
1974 | 92a31b1f | bellard | { "r10", offsetof(CPUState, regs[10]) }, |
1975 | 92a31b1f | bellard | { "r11", offsetof(CPUState, regs[11]) }, |
1976 | 92a31b1f | bellard | { "r12", offsetof(CPUState, regs[12]) }, |
1977 | 92a31b1f | bellard | { "r13", offsetof(CPUState, regs[13]) }, |
1978 | 92a31b1f | bellard | { "r14", offsetof(CPUState, regs[14]) }, |
1979 | 92a31b1f | bellard | { "r15", offsetof(CPUState, regs[15]) }, |
1980 | 92a31b1f | bellard | #endif
|
1981 | 9307c4c1 | bellard | { "eflags", offsetof(CPUState, eflags) },
|
1982 | 57206fd4 | bellard | { "eip", offsetof(CPUState, eip) },
|
1983 | 57206fd4 | bellard | SEG("cs", R_CS)
|
1984 | 57206fd4 | bellard | SEG("ds", R_DS)
|
1985 | 57206fd4 | bellard | SEG("es", R_ES)
|
1986 | 01038d2a | bellard | SEG("ss", R_SS)
|
1987 | 57206fd4 | bellard | SEG("fs", R_FS)
|
1988 | 57206fd4 | bellard | SEG("gs", R_GS)
|
1989 | 57206fd4 | bellard | { "pc", 0, monitor_get_pc, }, |
1990 | a541f297 | bellard | #elif defined(TARGET_PPC)
|
1991 | ff937dba | j_mayer | /* General purpose registers */
|
1992 | a541f297 | bellard | { "r0", offsetof(CPUState, gpr[0]) }, |
1993 | a541f297 | bellard | { "r1", offsetof(CPUState, gpr[1]) }, |
1994 | a541f297 | bellard | { "r2", offsetof(CPUState, gpr[2]) }, |
1995 | a541f297 | bellard | { "r3", offsetof(CPUState, gpr[3]) }, |
1996 | a541f297 | bellard | { "r4", offsetof(CPUState, gpr[4]) }, |
1997 | a541f297 | bellard | { "r5", offsetof(CPUState, gpr[5]) }, |
1998 | a541f297 | bellard | { "r6", offsetof(CPUState, gpr[6]) }, |
1999 | a541f297 | bellard | { "r7", offsetof(CPUState, gpr[7]) }, |
2000 | a541f297 | bellard | { "r8", offsetof(CPUState, gpr[8]) }, |
2001 | a541f297 | bellard | { "r9", offsetof(CPUState, gpr[9]) }, |
2002 | a541f297 | bellard | { "r10", offsetof(CPUState, gpr[10]) }, |
2003 | a541f297 | bellard | { "r11", offsetof(CPUState, gpr[11]) }, |
2004 | a541f297 | bellard | { "r12", offsetof(CPUState, gpr[12]) }, |
2005 | a541f297 | bellard | { "r13", offsetof(CPUState, gpr[13]) }, |
2006 | a541f297 | bellard | { "r14", offsetof(CPUState, gpr[14]) }, |
2007 | a541f297 | bellard | { "r15", offsetof(CPUState, gpr[15]) }, |
2008 | a541f297 | bellard | { "r16", offsetof(CPUState, gpr[16]) }, |
2009 | a541f297 | bellard | { "r17", offsetof(CPUState, gpr[17]) }, |
2010 | a541f297 | bellard | { "r18", offsetof(CPUState, gpr[18]) }, |
2011 | a541f297 | bellard | { "r19", offsetof(CPUState, gpr[19]) }, |
2012 | a541f297 | bellard | { "r20", offsetof(CPUState, gpr[20]) }, |
2013 | a541f297 | bellard | { "r21", offsetof(CPUState, gpr[21]) }, |
2014 | a541f297 | bellard | { "r22", offsetof(CPUState, gpr[22]) }, |
2015 | a541f297 | bellard | { "r23", offsetof(CPUState, gpr[23]) }, |
2016 | a541f297 | bellard | { "r24", offsetof(CPUState, gpr[24]) }, |
2017 | a541f297 | bellard | { "r25", offsetof(CPUState, gpr[25]) }, |
2018 | a541f297 | bellard | { "r26", offsetof(CPUState, gpr[26]) }, |
2019 | a541f297 | bellard | { "r27", offsetof(CPUState, gpr[27]) }, |
2020 | a541f297 | bellard | { "r28", offsetof(CPUState, gpr[28]) }, |
2021 | a541f297 | bellard | { "r29", offsetof(CPUState, gpr[29]) }, |
2022 | a541f297 | bellard | { "r30", offsetof(CPUState, gpr[30]) }, |
2023 | a541f297 | bellard | { "r31", offsetof(CPUState, gpr[31]) }, |
2024 | ff937dba | j_mayer | /* Floating point registers */
|
2025 | ff937dba | j_mayer | { "f0", offsetof(CPUState, fpr[0]) }, |
2026 | ff937dba | j_mayer | { "f1", offsetof(CPUState, fpr[1]) }, |
2027 | ff937dba | j_mayer | { "f2", offsetof(CPUState, fpr[2]) }, |
2028 | ff937dba | j_mayer | { "f3", offsetof(CPUState, fpr[3]) }, |
2029 | ff937dba | j_mayer | { "f4", offsetof(CPUState, fpr[4]) }, |
2030 | ff937dba | j_mayer | { "f5", offsetof(CPUState, fpr[5]) }, |
2031 | ff937dba | j_mayer | { "f6", offsetof(CPUState, fpr[6]) }, |
2032 | ff937dba | j_mayer | { "f7", offsetof(CPUState, fpr[7]) }, |
2033 | ff937dba | j_mayer | { "f8", offsetof(CPUState, fpr[8]) }, |
2034 | ff937dba | j_mayer | { "f9", offsetof(CPUState, fpr[9]) }, |
2035 | ff937dba | j_mayer | { "f10", offsetof(CPUState, fpr[10]) }, |
2036 | ff937dba | j_mayer | { "f11", offsetof(CPUState, fpr[11]) }, |
2037 | ff937dba | j_mayer | { "f12", offsetof(CPUState, fpr[12]) }, |
2038 | ff937dba | j_mayer | { "f13", offsetof(CPUState, fpr[13]) }, |
2039 | ff937dba | j_mayer | { "f14", offsetof(CPUState, fpr[14]) }, |
2040 | ff937dba | j_mayer | { "f15", offsetof(CPUState, fpr[15]) }, |
2041 | ff937dba | j_mayer | { "f16", offsetof(CPUState, fpr[16]) }, |
2042 | ff937dba | j_mayer | { "f17", offsetof(CPUState, fpr[17]) }, |
2043 | ff937dba | j_mayer | { "f18", offsetof(CPUState, fpr[18]) }, |
2044 | ff937dba | j_mayer | { "f19", offsetof(CPUState, fpr[19]) }, |
2045 | ff937dba | j_mayer | { "f20", offsetof(CPUState, fpr[20]) }, |
2046 | ff937dba | j_mayer | { "f21", offsetof(CPUState, fpr[21]) }, |
2047 | ff937dba | j_mayer | { "f22", offsetof(CPUState, fpr[22]) }, |
2048 | ff937dba | j_mayer | { "f23", offsetof(CPUState, fpr[23]) }, |
2049 | ff937dba | j_mayer | { "f24", offsetof(CPUState, fpr[24]) }, |
2050 | ff937dba | j_mayer | { "f25", offsetof(CPUState, fpr[25]) }, |
2051 | ff937dba | j_mayer | { "f26", offsetof(CPUState, fpr[26]) }, |
2052 | ff937dba | j_mayer | { "f27", offsetof(CPUState, fpr[27]) }, |
2053 | ff937dba | j_mayer | { "f28", offsetof(CPUState, fpr[28]) }, |
2054 | ff937dba | j_mayer | { "f29", offsetof(CPUState, fpr[29]) }, |
2055 | ff937dba | j_mayer | { "f30", offsetof(CPUState, fpr[30]) }, |
2056 | ff937dba | j_mayer | { "f31", offsetof(CPUState, fpr[31]) }, |
2057 | ff937dba | j_mayer | { "fpscr", offsetof(CPUState, fpscr) },
|
2058 | ff937dba | j_mayer | /* Next instruction pointer */
|
2059 | 57206fd4 | bellard | { "nip|pc", offsetof(CPUState, nip) },
|
2060 | a541f297 | bellard | { "lr", offsetof(CPUState, lr) },
|
2061 | a541f297 | bellard | { "ctr", offsetof(CPUState, ctr) },
|
2062 | 9fddaa0c | bellard | { "decr", 0, &monitor_get_decr, }, |
2063 | a541f297 | bellard | { "ccr", 0, &monitor_get_ccr, }, |
2064 | ff937dba | j_mayer | /* Machine state register */
|
2065 | a541f297 | bellard | { "msr", 0, &monitor_get_msr, }, |
2066 | a541f297 | bellard | { "xer", 0, &monitor_get_xer, }, |
2067 | 9fddaa0c | bellard | { "tbu", 0, &monitor_get_tbu, }, |
2068 | 9fddaa0c | bellard | { "tbl", 0, &monitor_get_tbl, }, |
2069 | ff937dba | j_mayer | #if defined(TARGET_PPC64)
|
2070 | ff937dba | j_mayer | /* Address space register */
|
2071 | ff937dba | j_mayer | { "asr", offsetof(CPUState, asr) },
|
2072 | ff937dba | j_mayer | #endif
|
2073 | ff937dba | j_mayer | /* Segment registers */
|
2074 | a541f297 | bellard | { "sdr1", offsetof(CPUState, sdr1) },
|
2075 | a541f297 | bellard | { "sr0", offsetof(CPUState, sr[0]) }, |
2076 | a541f297 | bellard | { "sr1", offsetof(CPUState, sr[1]) }, |
2077 | a541f297 | bellard | { "sr2", offsetof(CPUState, sr[2]) }, |
2078 | a541f297 | bellard | { "sr3", offsetof(CPUState, sr[3]) }, |
2079 | a541f297 | bellard | { "sr4", offsetof(CPUState, sr[4]) }, |
2080 | a541f297 | bellard | { "sr5", offsetof(CPUState, sr[5]) }, |
2081 | a541f297 | bellard | { "sr6", offsetof(CPUState, sr[6]) }, |
2082 | a541f297 | bellard | { "sr7", offsetof(CPUState, sr[7]) }, |
2083 | a541f297 | bellard | { "sr8", offsetof(CPUState, sr[8]) }, |
2084 | a541f297 | bellard | { "sr9", offsetof(CPUState, sr[9]) }, |
2085 | a541f297 | bellard | { "sr10", offsetof(CPUState, sr[10]) }, |
2086 | a541f297 | bellard | { "sr11", offsetof(CPUState, sr[11]) }, |
2087 | a541f297 | bellard | { "sr12", offsetof(CPUState, sr[12]) }, |
2088 | a541f297 | bellard | { "sr13", offsetof(CPUState, sr[13]) }, |
2089 | a541f297 | bellard | { "sr14", offsetof(CPUState, sr[14]) }, |
2090 | a541f297 | bellard | { "sr15", offsetof(CPUState, sr[15]) }, |
2091 | a541f297 | bellard | /* Too lazy to put BATs and SPRs ... */
|
2092 | e95c8d51 | bellard | #elif defined(TARGET_SPARC)
|
2093 | e95c8d51 | bellard | { "g0", offsetof(CPUState, gregs[0]) }, |
2094 | e95c8d51 | bellard | { "g1", offsetof(CPUState, gregs[1]) }, |
2095 | e95c8d51 | bellard | { "g2", offsetof(CPUState, gregs[2]) }, |
2096 | e95c8d51 | bellard | { "g3", offsetof(CPUState, gregs[3]) }, |
2097 | e95c8d51 | bellard | { "g4", offsetof(CPUState, gregs[4]) }, |
2098 | e95c8d51 | bellard | { "g5", offsetof(CPUState, gregs[5]) }, |
2099 | e95c8d51 | bellard | { "g6", offsetof(CPUState, gregs[6]) }, |
2100 | e95c8d51 | bellard | { "g7", offsetof(CPUState, gregs[7]) }, |
2101 | e95c8d51 | bellard | { "o0", 0, monitor_get_reg }, |
2102 | e95c8d51 | bellard | { "o1", 1, monitor_get_reg }, |
2103 | e95c8d51 | bellard | { "o2", 2, monitor_get_reg }, |
2104 | e95c8d51 | bellard | { "o3", 3, monitor_get_reg }, |
2105 | e95c8d51 | bellard | { "o4", 4, monitor_get_reg }, |
2106 | e95c8d51 | bellard | { "o5", 5, monitor_get_reg }, |
2107 | e95c8d51 | bellard | { "o6", 6, monitor_get_reg }, |
2108 | e95c8d51 | bellard | { "o7", 7, monitor_get_reg }, |
2109 | e95c8d51 | bellard | { "l0", 8, monitor_get_reg }, |
2110 | e95c8d51 | bellard | { "l1", 9, monitor_get_reg }, |
2111 | e95c8d51 | bellard | { "l2", 10, monitor_get_reg }, |
2112 | e95c8d51 | bellard | { "l3", 11, monitor_get_reg }, |
2113 | e95c8d51 | bellard | { "l4", 12, monitor_get_reg }, |
2114 | e95c8d51 | bellard | { "l5", 13, monitor_get_reg }, |
2115 | e95c8d51 | bellard | { "l6", 14, monitor_get_reg }, |
2116 | e95c8d51 | bellard | { "l7", 15, monitor_get_reg }, |
2117 | e95c8d51 | bellard | { "i0", 16, monitor_get_reg }, |
2118 | e95c8d51 | bellard | { "i1", 17, monitor_get_reg }, |
2119 | e95c8d51 | bellard | { "i2", 18, monitor_get_reg }, |
2120 | e95c8d51 | bellard | { "i3", 19, monitor_get_reg }, |
2121 | e95c8d51 | bellard | { "i4", 20, monitor_get_reg }, |
2122 | e95c8d51 | bellard | { "i5", 21, monitor_get_reg }, |
2123 | e95c8d51 | bellard | { "i6", 22, monitor_get_reg }, |
2124 | e95c8d51 | bellard | { "i7", 23, monitor_get_reg }, |
2125 | e95c8d51 | bellard | { "pc", offsetof(CPUState, pc) },
|
2126 | e95c8d51 | bellard | { "npc", offsetof(CPUState, npc) },
|
2127 | e95c8d51 | bellard | { "y", offsetof(CPUState, y) },
|
2128 | 7b936c0c | bellard | #ifndef TARGET_SPARC64
|
2129 | e95c8d51 | bellard | { "psr", 0, &monitor_get_psr, }, |
2130 | e95c8d51 | bellard | { "wim", offsetof(CPUState, wim) },
|
2131 | 7b936c0c | bellard | #endif
|
2132 | e95c8d51 | bellard | { "tbr", offsetof(CPUState, tbr) },
|
2133 | e95c8d51 | bellard | { "fsr", offsetof(CPUState, fsr) },
|
2134 | e95c8d51 | bellard | { "f0", offsetof(CPUState, fpr[0]) }, |
2135 | e95c8d51 | bellard | { "f1", offsetof(CPUState, fpr[1]) }, |
2136 | e95c8d51 | bellard | { "f2", offsetof(CPUState, fpr[2]) }, |
2137 | e95c8d51 | bellard | { "f3", offsetof(CPUState, fpr[3]) }, |
2138 | e95c8d51 | bellard | { "f4", offsetof(CPUState, fpr[4]) }, |
2139 | e95c8d51 | bellard | { "f5", offsetof(CPUState, fpr[5]) }, |
2140 | e95c8d51 | bellard | { "f6", offsetof(CPUState, fpr[6]) }, |
2141 | e95c8d51 | bellard | { "f7", offsetof(CPUState, fpr[7]) }, |
2142 | e95c8d51 | bellard | { "f8", offsetof(CPUState, fpr[8]) }, |
2143 | e95c8d51 | bellard | { "f9", offsetof(CPUState, fpr[9]) }, |
2144 | e95c8d51 | bellard | { "f10", offsetof(CPUState, fpr[10]) }, |
2145 | e95c8d51 | bellard | { "f11", offsetof(CPUState, fpr[11]) }, |
2146 | e95c8d51 | bellard | { "f12", offsetof(CPUState, fpr[12]) }, |
2147 | e95c8d51 | bellard | { "f13", offsetof(CPUState, fpr[13]) }, |
2148 | e95c8d51 | bellard | { "f14", offsetof(CPUState, fpr[14]) }, |
2149 | e95c8d51 | bellard | { "f15", offsetof(CPUState, fpr[15]) }, |
2150 | e95c8d51 | bellard | { "f16", offsetof(CPUState, fpr[16]) }, |
2151 | e95c8d51 | bellard | { "f17", offsetof(CPUState, fpr[17]) }, |
2152 | e95c8d51 | bellard | { "f18", offsetof(CPUState, fpr[18]) }, |
2153 | e95c8d51 | bellard | { "f19", offsetof(CPUState, fpr[19]) }, |
2154 | e95c8d51 | bellard | { "f20", offsetof(CPUState, fpr[20]) }, |
2155 | e95c8d51 | bellard | { "f21", offsetof(CPUState, fpr[21]) }, |
2156 | e95c8d51 | bellard | { "f22", offsetof(CPUState, fpr[22]) }, |
2157 | e95c8d51 | bellard | { "f23", offsetof(CPUState, fpr[23]) }, |
2158 | e95c8d51 | bellard | { "f24", offsetof(CPUState, fpr[24]) }, |
2159 | e95c8d51 | bellard | { "f25", offsetof(CPUState, fpr[25]) }, |
2160 | e95c8d51 | bellard | { "f26", offsetof(CPUState, fpr[26]) }, |
2161 | e95c8d51 | bellard | { "f27", offsetof(CPUState, fpr[27]) }, |
2162 | e95c8d51 | bellard | { "f28", offsetof(CPUState, fpr[28]) }, |
2163 | e95c8d51 | bellard | { "f29", offsetof(CPUState, fpr[29]) }, |
2164 | e95c8d51 | bellard | { "f30", offsetof(CPUState, fpr[30]) }, |
2165 | e95c8d51 | bellard | { "f31", offsetof(CPUState, fpr[31]) }, |
2166 | 7b936c0c | bellard | #ifdef TARGET_SPARC64
|
2167 | 7b936c0c | bellard | { "f32", offsetof(CPUState, fpr[32]) }, |
2168 | 7b936c0c | bellard | { "f34", offsetof(CPUState, fpr[34]) }, |
2169 | 7b936c0c | bellard | { "f36", offsetof(CPUState, fpr[36]) }, |
2170 | 7b936c0c | bellard | { "f38", offsetof(CPUState, fpr[38]) }, |
2171 | 7b936c0c | bellard | { "f40", offsetof(CPUState, fpr[40]) }, |
2172 | 7b936c0c | bellard | { "f42", offsetof(CPUState, fpr[42]) }, |
2173 | 7b936c0c | bellard | { "f44", offsetof(CPUState, fpr[44]) }, |
2174 | 7b936c0c | bellard | { "f46", offsetof(CPUState, fpr[46]) }, |
2175 | 7b936c0c | bellard | { "f48", offsetof(CPUState, fpr[48]) }, |
2176 | 7b936c0c | bellard | { "f50", offsetof(CPUState, fpr[50]) }, |
2177 | 7b936c0c | bellard | { "f52", offsetof(CPUState, fpr[52]) }, |
2178 | 7b936c0c | bellard | { "f54", offsetof(CPUState, fpr[54]) }, |
2179 | 7b936c0c | bellard | { "f56", offsetof(CPUState, fpr[56]) }, |
2180 | 7b936c0c | bellard | { "f58", offsetof(CPUState, fpr[58]) }, |
2181 | 7b936c0c | bellard | { "f60", offsetof(CPUState, fpr[60]) }, |
2182 | 7b936c0c | bellard | { "f62", offsetof(CPUState, fpr[62]) }, |
2183 | 7b936c0c | bellard | { "asi", offsetof(CPUState, asi) },
|
2184 | 7b936c0c | bellard | { "pstate", offsetof(CPUState, pstate) },
|
2185 | 7b936c0c | bellard | { "cansave", offsetof(CPUState, cansave) },
|
2186 | 7b936c0c | bellard | { "canrestore", offsetof(CPUState, canrestore) },
|
2187 | 7b936c0c | bellard | { "otherwin", offsetof(CPUState, otherwin) },
|
2188 | 7b936c0c | bellard | { "wstate", offsetof(CPUState, wstate) },
|
2189 | 7b936c0c | bellard | { "cleanwin", offsetof(CPUState, cleanwin) },
|
2190 | 7b936c0c | bellard | { "fprs", offsetof(CPUState, fprs) },
|
2191 | 7b936c0c | bellard | #endif
|
2192 | 9307c4c1 | bellard | #endif
|
2193 | 9307c4c1 | bellard | { NULL },
|
2194 | 9307c4c1 | bellard | }; |
2195 | 9307c4c1 | bellard | |
2196 | 376253ec | aliguori | static void expr_error(Monitor *mon, const char *msg) |
2197 | 9dc39cba | bellard | { |
2198 | 376253ec | aliguori | monitor_printf(mon, "%s\n", msg);
|
2199 | 9307c4c1 | bellard | longjmp(expr_env, 1);
|
2200 | 9307c4c1 | bellard | } |
2201 | 9307c4c1 | bellard | |
2202 | 6a00d601 | bellard | /* return 0 if OK, -1 if not found, -2 if no CPU defined */
|
2203 | 92a31b1f | bellard | static int get_monitor_def(target_long *pval, const char *name) |
2204 | 9307c4c1 | bellard | { |
2205 | 8662d656 | blueswir1 | const MonitorDef *md;
|
2206 | 92a31b1f | bellard | void *ptr;
|
2207 | 92a31b1f | bellard | |
2208 | 9307c4c1 | bellard | for(md = monitor_defs; md->name != NULL; md++) { |
2209 | 9307c4c1 | bellard | if (compare_cmd(name, md->name)) {
|
2210 | 9307c4c1 | bellard | if (md->get_value) {
|
2211 | e95c8d51 | bellard | *pval = md->get_value(md, md->offset); |
2212 | 9307c4c1 | bellard | } else {
|
2213 | 6a00d601 | bellard | CPUState *env = mon_get_cpu(); |
2214 | 6a00d601 | bellard | if (!env)
|
2215 | 6a00d601 | bellard | return -2; |
2216 | 6a00d601 | bellard | ptr = (uint8_t *)env + md->offset; |
2217 | 92a31b1f | bellard | switch(md->type) {
|
2218 | 92a31b1f | bellard | case MD_I32:
|
2219 | 92a31b1f | bellard | *pval = *(int32_t *)ptr; |
2220 | 92a31b1f | bellard | break;
|
2221 | 92a31b1f | bellard | case MD_TLONG:
|
2222 | 92a31b1f | bellard | *pval = *(target_long *)ptr; |
2223 | 92a31b1f | bellard | break;
|
2224 | 92a31b1f | bellard | default:
|
2225 | 92a31b1f | bellard | *pval = 0;
|
2226 | 92a31b1f | bellard | break;
|
2227 | 92a31b1f | bellard | } |
2228 | 9307c4c1 | bellard | } |
2229 | 9307c4c1 | bellard | return 0; |
2230 | 9307c4c1 | bellard | } |
2231 | 9307c4c1 | bellard | } |
2232 | 9307c4c1 | bellard | return -1; |
2233 | 9307c4c1 | bellard | } |
2234 | 9307c4c1 | bellard | |
2235 | 9307c4c1 | bellard | static void next(void) |
2236 | 9307c4c1 | bellard | { |
2237 | 9307c4c1 | bellard | if (pch != '\0') { |
2238 | 9307c4c1 | bellard | pch++; |
2239 | cd390083 | blueswir1 | while (qemu_isspace(*pch))
|
2240 | 9307c4c1 | bellard | pch++; |
2241 | 9307c4c1 | bellard | } |
2242 | 9307c4c1 | bellard | } |
2243 | 9307c4c1 | bellard | |
2244 | 376253ec | aliguori | static int64_t expr_sum(Monitor *mon);
|
2245 | 9307c4c1 | bellard | |
2246 | 376253ec | aliguori | static int64_t expr_unary(Monitor *mon)
|
2247 | 9307c4c1 | bellard | { |
2248 | c2efc95d | blueswir1 | int64_t n; |
2249 | 9307c4c1 | bellard | char *p;
|
2250 | 6a00d601 | bellard | int ret;
|
2251 | 9307c4c1 | bellard | |
2252 | 9307c4c1 | bellard | switch(*pch) {
|
2253 | 9307c4c1 | bellard | case '+': |
2254 | 9307c4c1 | bellard | next(); |
2255 | 376253ec | aliguori | n = expr_unary(mon); |
2256 | 9307c4c1 | bellard | break;
|
2257 | 9307c4c1 | bellard | case '-': |
2258 | 9307c4c1 | bellard | next(); |
2259 | 376253ec | aliguori | n = -expr_unary(mon); |
2260 | 9307c4c1 | bellard | break;
|
2261 | 9307c4c1 | bellard | case '~': |
2262 | 9307c4c1 | bellard | next(); |
2263 | 376253ec | aliguori | n = ~expr_unary(mon); |
2264 | 9307c4c1 | bellard | break;
|
2265 | 9307c4c1 | bellard | case '(': |
2266 | 9307c4c1 | bellard | next(); |
2267 | 376253ec | aliguori | n = expr_sum(mon); |
2268 | 9307c4c1 | bellard | if (*pch != ')') { |
2269 | 376253ec | aliguori | expr_error(mon, "')' expected");
|
2270 | 9307c4c1 | bellard | } |
2271 | 9307c4c1 | bellard | next(); |
2272 | 9307c4c1 | bellard | break;
|
2273 | 81d0912d | bellard | case '\'': |
2274 | 81d0912d | bellard | pch++; |
2275 | 81d0912d | bellard | if (*pch == '\0') |
2276 | 376253ec | aliguori | expr_error(mon, "character constant expected");
|
2277 | 81d0912d | bellard | n = *pch; |
2278 | 81d0912d | bellard | pch++; |
2279 | 81d0912d | bellard | if (*pch != '\'') |
2280 | 376253ec | aliguori | expr_error(mon, "missing terminating \' character");
|
2281 | 81d0912d | bellard | next(); |
2282 | 81d0912d | bellard | break;
|
2283 | 9307c4c1 | bellard | case '$': |
2284 | 9307c4c1 | bellard | { |
2285 | 9307c4c1 | bellard | char buf[128], *q; |
2286 | 69b34976 | ths | target_long reg=0;
|
2287 | 3b46e624 | ths | |
2288 | 9307c4c1 | bellard | pch++; |
2289 | 9307c4c1 | bellard | q = buf; |
2290 | 9307c4c1 | bellard | while ((*pch >= 'a' && *pch <= 'z') || |
2291 | 9307c4c1 | bellard | (*pch >= 'A' && *pch <= 'Z') || |
2292 | 9307c4c1 | bellard | (*pch >= '0' && *pch <= '9') || |
2293 | 57206fd4 | bellard | *pch == '_' || *pch == '.') { |
2294 | 9307c4c1 | bellard | if ((q - buf) < sizeof(buf) - 1) |
2295 | 9307c4c1 | bellard | *q++ = *pch; |
2296 | 9307c4c1 | bellard | pch++; |
2297 | 9307c4c1 | bellard | } |
2298 | cd390083 | blueswir1 | while (qemu_isspace(*pch))
|
2299 | 9307c4c1 | bellard | pch++; |
2300 | 9307c4c1 | bellard | *q = 0;
|
2301 | 7743e588 | blueswir1 | ret = get_monitor_def(®, buf); |
2302 | 6a00d601 | bellard | if (ret == -1) |
2303 | 376253ec | aliguori | expr_error(mon, "unknown register");
|
2304 | 5fafdf24 | ths | else if (ret == -2) |
2305 | 376253ec | aliguori | expr_error(mon, "no cpu defined");
|
2306 | 7743e588 | blueswir1 | n = reg; |
2307 | 9307c4c1 | bellard | } |
2308 | 9307c4c1 | bellard | break;
|
2309 | 9307c4c1 | bellard | case '\0': |
2310 | 376253ec | aliguori | expr_error(mon, "unexpected end of expression");
|
2311 | 9307c4c1 | bellard | n = 0;
|
2312 | 9307c4c1 | bellard | break;
|
2313 | 9307c4c1 | bellard | default:
|
2314 | 7743e588 | blueswir1 | #if TARGET_PHYS_ADDR_BITS > 32 |
2315 | 4f4fbf77 | bellard | n = strtoull(pch, &p, 0);
|
2316 | 4f4fbf77 | bellard | #else
|
2317 | 9307c4c1 | bellard | n = strtoul(pch, &p, 0);
|
2318 | 4f4fbf77 | bellard | #endif
|
2319 | 9307c4c1 | bellard | if (pch == p) {
|
2320 | 376253ec | aliguori | expr_error(mon, "invalid char in expression");
|
2321 | 9307c4c1 | bellard | } |
2322 | 9307c4c1 | bellard | pch = p; |
2323 | cd390083 | blueswir1 | while (qemu_isspace(*pch))
|
2324 | 9307c4c1 | bellard | pch++; |
2325 | 9307c4c1 | bellard | break;
|
2326 | 9307c4c1 | bellard | } |
2327 | 9307c4c1 | bellard | return n;
|
2328 | 9307c4c1 | bellard | } |
2329 | 9307c4c1 | bellard | |
2330 | 9307c4c1 | bellard | |
2331 | 376253ec | aliguori | static int64_t expr_prod(Monitor *mon)
|
2332 | 9307c4c1 | bellard | { |
2333 | c2efc95d | blueswir1 | int64_t val, val2; |
2334 | 92a31b1f | bellard | int op;
|
2335 | 3b46e624 | ths | |
2336 | 376253ec | aliguori | val = expr_unary(mon); |
2337 | 9307c4c1 | bellard | for(;;) {
|
2338 | 9307c4c1 | bellard | op = *pch; |
2339 | 9307c4c1 | bellard | if (op != '*' && op != '/' && op != '%') |
2340 | 9307c4c1 | bellard | break;
|
2341 | 9307c4c1 | bellard | next(); |
2342 | 376253ec | aliguori | val2 = expr_unary(mon); |
2343 | 9307c4c1 | bellard | switch(op) {
|
2344 | 9307c4c1 | bellard | default:
|
2345 | 9307c4c1 | bellard | case '*': |
2346 | 9307c4c1 | bellard | val *= val2; |
2347 | 9307c4c1 | bellard | break;
|
2348 | 9307c4c1 | bellard | case '/': |
2349 | 9307c4c1 | bellard | case '%': |
2350 | 5fafdf24 | ths | if (val2 == 0) |
2351 | 376253ec | aliguori | expr_error(mon, "division by zero");
|
2352 | 9307c4c1 | bellard | if (op == '/') |
2353 | 9307c4c1 | bellard | val /= val2; |
2354 | 9307c4c1 | bellard | else
|
2355 | 9307c4c1 | bellard | val %= val2; |
2356 | 9307c4c1 | bellard | break;
|
2357 | 9307c4c1 | bellard | } |
2358 | 9307c4c1 | bellard | } |
2359 | 9307c4c1 | bellard | return val;
|
2360 | 9307c4c1 | bellard | } |
2361 | 9307c4c1 | bellard | |
2362 | 376253ec | aliguori | static int64_t expr_logic(Monitor *mon)
|
2363 | 9307c4c1 | bellard | { |
2364 | c2efc95d | blueswir1 | int64_t val, val2; |
2365 | 92a31b1f | bellard | int op;
|
2366 | 9307c4c1 | bellard | |
2367 | 376253ec | aliguori | val = expr_prod(mon); |
2368 | 9307c4c1 | bellard | for(;;) {
|
2369 | 9307c4c1 | bellard | op = *pch; |
2370 | 9307c4c1 | bellard | if (op != '&' && op != '|' && op != '^') |
2371 | 9307c4c1 | bellard | break;
|
2372 | 9307c4c1 | bellard | next(); |
2373 | 376253ec | aliguori | val2 = expr_prod(mon); |
2374 | 9307c4c1 | bellard | switch(op) {
|
2375 | 9307c4c1 | bellard | default:
|
2376 | 9307c4c1 | bellard | case '&': |
2377 | 9307c4c1 | bellard | val &= val2; |
2378 | 9307c4c1 | bellard | break;
|
2379 | 9307c4c1 | bellard | case '|': |
2380 | 9307c4c1 | bellard | val |= val2; |
2381 | 9307c4c1 | bellard | break;
|
2382 | 9307c4c1 | bellard | case '^': |
2383 | 9307c4c1 | bellard | val ^= val2; |
2384 | 9307c4c1 | bellard | break;
|
2385 | 9307c4c1 | bellard | } |
2386 | 9307c4c1 | bellard | } |
2387 | 9307c4c1 | bellard | return val;
|
2388 | 9307c4c1 | bellard | } |
2389 | 9307c4c1 | bellard | |
2390 | 376253ec | aliguori | static int64_t expr_sum(Monitor *mon)
|
2391 | 9307c4c1 | bellard | { |
2392 | c2efc95d | blueswir1 | int64_t val, val2; |
2393 | 92a31b1f | bellard | int op;
|
2394 | 9307c4c1 | bellard | |
2395 | 376253ec | aliguori | val = expr_logic(mon); |
2396 | 9307c4c1 | bellard | for(;;) {
|
2397 | 9307c4c1 | bellard | op = *pch; |
2398 | 9307c4c1 | bellard | if (op != '+' && op != '-') |
2399 | 9307c4c1 | bellard | break;
|
2400 | 9307c4c1 | bellard | next(); |
2401 | 376253ec | aliguori | val2 = expr_logic(mon); |
2402 | 9307c4c1 | bellard | if (op == '+') |
2403 | 9307c4c1 | bellard | val += val2; |
2404 | 9307c4c1 | bellard | else
|
2405 | 9307c4c1 | bellard | val -= val2; |
2406 | 9307c4c1 | bellard | } |
2407 | 9307c4c1 | bellard | return val;
|
2408 | 9307c4c1 | bellard | } |
2409 | 9307c4c1 | bellard | |
2410 | 376253ec | aliguori | static int get_expr(Monitor *mon, int64_t *pval, const char **pp) |
2411 | 9307c4c1 | bellard | { |
2412 | 9307c4c1 | bellard | pch = *pp; |
2413 | 9307c4c1 | bellard | if (setjmp(expr_env)) {
|
2414 | 9307c4c1 | bellard | *pp = pch; |
2415 | 9307c4c1 | bellard | return -1; |
2416 | 9307c4c1 | bellard | } |
2417 | cd390083 | blueswir1 | while (qemu_isspace(*pch))
|
2418 | 9307c4c1 | bellard | pch++; |
2419 | 376253ec | aliguori | *pval = expr_sum(mon); |
2420 | 9307c4c1 | bellard | *pp = pch; |
2421 | 9307c4c1 | bellard | return 0; |
2422 | 9307c4c1 | bellard | } |
2423 | 9307c4c1 | bellard | |
2424 | 9307c4c1 | bellard | static int get_str(char *buf, int buf_size, const char **pp) |
2425 | 9307c4c1 | bellard | { |
2426 | 9307c4c1 | bellard | const char *p; |
2427 | 9307c4c1 | bellard | char *q;
|
2428 | 9307c4c1 | bellard | int c;
|
2429 | 9307c4c1 | bellard | |
2430 | 81d0912d | bellard | q = buf; |
2431 | 9307c4c1 | bellard | p = *pp; |
2432 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2433 | 9307c4c1 | bellard | p++; |
2434 | 9307c4c1 | bellard | if (*p == '\0') { |
2435 | 9307c4c1 | bellard | fail:
|
2436 | 81d0912d | bellard | *q = '\0';
|
2437 | 9307c4c1 | bellard | *pp = p; |
2438 | 9307c4c1 | bellard | return -1; |
2439 | 9307c4c1 | bellard | } |
2440 | 9307c4c1 | bellard | if (*p == '\"') { |
2441 | 9307c4c1 | bellard | p++; |
2442 | 9307c4c1 | bellard | while (*p != '\0' && *p != '\"') { |
2443 | 9307c4c1 | bellard | if (*p == '\\') { |
2444 | 9307c4c1 | bellard | p++; |
2445 | 9307c4c1 | bellard | c = *p++; |
2446 | 9307c4c1 | bellard | switch(c) {
|
2447 | 9307c4c1 | bellard | case 'n': |
2448 | 9307c4c1 | bellard | c = '\n';
|
2449 | 9307c4c1 | bellard | break;
|
2450 | 9307c4c1 | bellard | case 'r': |
2451 | 9307c4c1 | bellard | c = '\r';
|
2452 | 9307c4c1 | bellard | break;
|
2453 | 9307c4c1 | bellard | case '\\': |
2454 | 9307c4c1 | bellard | case '\'': |
2455 | 9307c4c1 | bellard | case '\"': |
2456 | 9307c4c1 | bellard | break;
|
2457 | 9307c4c1 | bellard | default:
|
2458 | 9307c4c1 | bellard | qemu_printf("unsupported escape code: '\\%c'\n", c);
|
2459 | 9307c4c1 | bellard | goto fail;
|
2460 | 9307c4c1 | bellard | } |
2461 | 9307c4c1 | bellard | if ((q - buf) < buf_size - 1) { |
2462 | 9307c4c1 | bellard | *q++ = c; |
2463 | 9307c4c1 | bellard | } |
2464 | 9307c4c1 | bellard | } else {
|
2465 | 9307c4c1 | bellard | if ((q - buf) < buf_size - 1) { |
2466 | 9307c4c1 | bellard | *q++ = *p; |
2467 | 9307c4c1 | bellard | } |
2468 | 9307c4c1 | bellard | p++; |
2469 | 9307c4c1 | bellard | } |
2470 | 9307c4c1 | bellard | } |
2471 | 9307c4c1 | bellard | if (*p != '\"') { |
2472 | 5b60212f | bellard | qemu_printf("unterminated string\n");
|
2473 | 9307c4c1 | bellard | goto fail;
|
2474 | 9307c4c1 | bellard | } |
2475 | 9307c4c1 | bellard | p++; |
2476 | 9307c4c1 | bellard | } else {
|
2477 | cd390083 | blueswir1 | while (*p != '\0' && !qemu_isspace(*p)) { |
2478 | 9307c4c1 | bellard | if ((q - buf) < buf_size - 1) { |
2479 | 9307c4c1 | bellard | *q++ = *p; |
2480 | 9307c4c1 | bellard | } |
2481 | 9307c4c1 | bellard | p++; |
2482 | 9307c4c1 | bellard | } |
2483 | 9307c4c1 | bellard | } |
2484 | 81d0912d | bellard | *q = '\0';
|
2485 | 9307c4c1 | bellard | *pp = p; |
2486 | 9307c4c1 | bellard | return 0; |
2487 | 9307c4c1 | bellard | } |
2488 | 9307c4c1 | bellard | |
2489 | 9307c4c1 | bellard | static int default_fmt_format = 'x'; |
2490 | 9307c4c1 | bellard | static int default_fmt_size = 4; |
2491 | 9307c4c1 | bellard | |
2492 | 9307c4c1 | bellard | #define MAX_ARGS 16 |
2493 | 9307c4c1 | bellard | |
2494 | 376253ec | aliguori | static void monitor_handle_command(Monitor *mon, const char *cmdline) |
2495 | 9307c4c1 | bellard | { |
2496 | 9307c4c1 | bellard | const char *p, *pstart, *typestr; |
2497 | 9307c4c1 | bellard | char *q;
|
2498 | 9307c4c1 | bellard | int c, nb_args, len, i, has_arg;
|
2499 | 376253ec | aliguori | const mon_cmd_t *cmd;
|
2500 | 9307c4c1 | bellard | char cmdname[256]; |
2501 | 9307c4c1 | bellard | char buf[1024]; |
2502 | 9307c4c1 | bellard | void *str_allocated[MAX_ARGS];
|
2503 | 9307c4c1 | bellard | void *args[MAX_ARGS];
|
2504 | 376253ec | aliguori | void (*handler_0)(Monitor *mon);
|
2505 | 376253ec | aliguori | void (*handler_1)(Monitor *mon, void *arg0); |
2506 | 376253ec | aliguori | void (*handler_2)(Monitor *mon, void *arg0, void *arg1); |
2507 | 376253ec | aliguori | void (*handler_3)(Monitor *mon, void *arg0, void *arg1, void *arg2); |
2508 | 376253ec | aliguori | void (*handler_4)(Monitor *mon, void *arg0, void *arg1, void *arg2, |
2509 | 376253ec | aliguori | void *arg3);
|
2510 | 376253ec | aliguori | void (*handler_5)(Monitor *mon, void *arg0, void *arg1, void *arg2, |
2511 | 376253ec | aliguori | void *arg3, void *arg4); |
2512 | 376253ec | aliguori | void (*handler_6)(Monitor *mon, void *arg0, void *arg1, void *arg2, |
2513 | 376253ec | aliguori | void *arg3, void *arg4, void *arg5); |
2514 | 376253ec | aliguori | void (*handler_7)(Monitor *mon, void *arg0, void *arg1, void *arg2, |
2515 | 376253ec | aliguori | void *arg3, void *arg4, void *arg5, void *arg6); |
2516 | 9dc39cba | bellard | |
2517 | 9dc39cba | bellard | #ifdef DEBUG
|
2518 | 376253ec | aliguori | monitor_printf(mon, "command='%s'\n", cmdline);
|
2519 | 9dc39cba | bellard | #endif
|
2520 | 3b46e624 | ths | |
2521 | 9307c4c1 | bellard | /* extract the command name */
|
2522 | 9dc39cba | bellard | p = cmdline; |
2523 | 9307c4c1 | bellard | q = cmdname; |
2524 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2525 | 9307c4c1 | bellard | p++; |
2526 | 9307c4c1 | bellard | if (*p == '\0') |
2527 | 9307c4c1 | bellard | return;
|
2528 | 9307c4c1 | bellard | pstart = p; |
2529 | cd390083 | blueswir1 | while (*p != '\0' && *p != '/' && !qemu_isspace(*p)) |
2530 | 9307c4c1 | bellard | p++; |
2531 | 9307c4c1 | bellard | len = p - pstart; |
2532 | 9307c4c1 | bellard | if (len > sizeof(cmdname) - 1) |
2533 | 9307c4c1 | bellard | len = sizeof(cmdname) - 1; |
2534 | 9307c4c1 | bellard | memcpy(cmdname, pstart, len); |
2535 | 9307c4c1 | bellard | cmdname[len] = '\0';
|
2536 | 3b46e624 | ths | |
2537 | 9307c4c1 | bellard | /* find the command */
|
2538 | 376253ec | aliguori | for(cmd = mon_cmds; cmd->name != NULL; cmd++) { |
2539 | 5fafdf24 | ths | if (compare_cmd(cmdname, cmd->name))
|
2540 | 9307c4c1 | bellard | goto found;
|
2541 | 9307c4c1 | bellard | } |
2542 | 376253ec | aliguori | monitor_printf(mon, "unknown command: '%s'\n", cmdname);
|
2543 | 9307c4c1 | bellard | return;
|
2544 | 9307c4c1 | bellard | found:
|
2545 | 9307c4c1 | bellard | |
2546 | 9307c4c1 | bellard | for(i = 0; i < MAX_ARGS; i++) |
2547 | 9307c4c1 | bellard | str_allocated[i] = NULL;
|
2548 | 3b46e624 | ths | |
2549 | 9307c4c1 | bellard | /* parse the parameters */
|
2550 | 9307c4c1 | bellard | typestr = cmd->args_type; |
2551 | 9307c4c1 | bellard | nb_args = 0;
|
2552 | 9dc39cba | bellard | for(;;) {
|
2553 | 9307c4c1 | bellard | c = *typestr; |
2554 | 9307c4c1 | bellard | if (c == '\0') |
2555 | 9dc39cba | bellard | break;
|
2556 | 9307c4c1 | bellard | typestr++; |
2557 | 9307c4c1 | bellard | switch(c) {
|
2558 | 9307c4c1 | bellard | case 'F': |
2559 | 81d0912d | bellard | case 'B': |
2560 | 9307c4c1 | bellard | case 's': |
2561 | 9307c4c1 | bellard | { |
2562 | 9307c4c1 | bellard | int ret;
|
2563 | 9307c4c1 | bellard | char *str;
|
2564 | 3b46e624 | ths | |
2565 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2566 | 9307c4c1 | bellard | p++; |
2567 | 9307c4c1 | bellard | if (*typestr == '?') { |
2568 | 9307c4c1 | bellard | typestr++; |
2569 | 9307c4c1 | bellard | if (*p == '\0') { |
2570 | 9307c4c1 | bellard | /* no optional string: NULL argument */
|
2571 | 9307c4c1 | bellard | str = NULL;
|
2572 | 9307c4c1 | bellard | goto add_str;
|
2573 | 9307c4c1 | bellard | } |
2574 | 9307c4c1 | bellard | } |
2575 | 9307c4c1 | bellard | ret = get_str(buf, sizeof(buf), &p);
|
2576 | 9307c4c1 | bellard | if (ret < 0) { |
2577 | 81d0912d | bellard | switch(c) {
|
2578 | 81d0912d | bellard | case 'F': |
2579 | 376253ec | aliguori | monitor_printf(mon, "%s: filename expected\n",
|
2580 | 376253ec | aliguori | cmdname); |
2581 | 81d0912d | bellard | break;
|
2582 | 81d0912d | bellard | case 'B': |
2583 | 376253ec | aliguori | monitor_printf(mon, "%s: block device name expected\n",
|
2584 | 376253ec | aliguori | cmdname); |
2585 | 81d0912d | bellard | break;
|
2586 | 81d0912d | bellard | default:
|
2587 | 376253ec | aliguori | monitor_printf(mon, "%s: string expected\n", cmdname);
|
2588 | 81d0912d | bellard | break;
|
2589 | 81d0912d | bellard | } |
2590 | 9307c4c1 | bellard | goto fail;
|
2591 | 9307c4c1 | bellard | } |
2592 | 9307c4c1 | bellard | str = qemu_malloc(strlen(buf) + 1);
|
2593 | 363a37d5 | blueswir1 | pstrcpy(str, sizeof(buf), buf);
|
2594 | 9307c4c1 | bellard | str_allocated[nb_args] = str; |
2595 | 9307c4c1 | bellard | add_str:
|
2596 | 9307c4c1 | bellard | if (nb_args >= MAX_ARGS) {
|
2597 | 9307c4c1 | bellard | error_args:
|
2598 | 376253ec | aliguori | monitor_printf(mon, "%s: too many arguments\n", cmdname);
|
2599 | 9307c4c1 | bellard | goto fail;
|
2600 | 9307c4c1 | bellard | } |
2601 | 9307c4c1 | bellard | args[nb_args++] = str; |
2602 | 9307c4c1 | bellard | } |
2603 | 9dc39cba | bellard | break;
|
2604 | 9307c4c1 | bellard | case '/': |
2605 | 9307c4c1 | bellard | { |
2606 | 9307c4c1 | bellard | int count, format, size;
|
2607 | 3b46e624 | ths | |
2608 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2609 | 9307c4c1 | bellard | p++; |
2610 | 9307c4c1 | bellard | if (*p == '/') { |
2611 | 9307c4c1 | bellard | /* format found */
|
2612 | 9307c4c1 | bellard | p++; |
2613 | 9307c4c1 | bellard | count = 1;
|
2614 | cd390083 | blueswir1 | if (qemu_isdigit(*p)) {
|
2615 | 9307c4c1 | bellard | count = 0;
|
2616 | cd390083 | blueswir1 | while (qemu_isdigit(*p)) {
|
2617 | 9307c4c1 | bellard | count = count * 10 + (*p - '0'); |
2618 | 9307c4c1 | bellard | p++; |
2619 | 9307c4c1 | bellard | } |
2620 | 9307c4c1 | bellard | } |
2621 | 9307c4c1 | bellard | size = -1;
|
2622 | 9307c4c1 | bellard | format = -1;
|
2623 | 9307c4c1 | bellard | for(;;) {
|
2624 | 9307c4c1 | bellard | switch(*p) {
|
2625 | 9307c4c1 | bellard | case 'o': |
2626 | 9307c4c1 | bellard | case 'd': |
2627 | 9307c4c1 | bellard | case 'u': |
2628 | 9307c4c1 | bellard | case 'x': |
2629 | 9307c4c1 | bellard | case 'i': |
2630 | 9307c4c1 | bellard | case 'c': |
2631 | 9307c4c1 | bellard | format = *p++; |
2632 | 9307c4c1 | bellard | break;
|
2633 | 9307c4c1 | bellard | case 'b': |
2634 | 9307c4c1 | bellard | size = 1;
|
2635 | 9307c4c1 | bellard | p++; |
2636 | 9307c4c1 | bellard | break;
|
2637 | 9307c4c1 | bellard | case 'h': |
2638 | 9307c4c1 | bellard | size = 2;
|
2639 | 9307c4c1 | bellard | p++; |
2640 | 9307c4c1 | bellard | break;
|
2641 | 9307c4c1 | bellard | case 'w': |
2642 | 9307c4c1 | bellard | size = 4;
|
2643 | 9307c4c1 | bellard | p++; |
2644 | 9307c4c1 | bellard | break;
|
2645 | 9307c4c1 | bellard | case 'g': |
2646 | 9307c4c1 | bellard | case 'L': |
2647 | 9307c4c1 | bellard | size = 8;
|
2648 | 9307c4c1 | bellard | p++; |
2649 | 9307c4c1 | bellard | break;
|
2650 | 9307c4c1 | bellard | default:
|
2651 | 9307c4c1 | bellard | goto next;
|
2652 | 9307c4c1 | bellard | } |
2653 | 9307c4c1 | bellard | } |
2654 | 9307c4c1 | bellard | next:
|
2655 | cd390083 | blueswir1 | if (*p != '\0' && !qemu_isspace(*p)) { |
2656 | 376253ec | aliguori | monitor_printf(mon, "invalid char in format: '%c'\n",
|
2657 | 376253ec | aliguori | *p); |
2658 | 9307c4c1 | bellard | goto fail;
|
2659 | 9307c4c1 | bellard | } |
2660 | 9307c4c1 | bellard | if (format < 0) |
2661 | 9307c4c1 | bellard | format = default_fmt_format; |
2662 | 4c27ba27 | bellard | if (format != 'i') { |
2663 | 4c27ba27 | bellard | /* for 'i', not specifying a size gives -1 as size */
|
2664 | 4c27ba27 | bellard | if (size < 0) |
2665 | 4c27ba27 | bellard | size = default_fmt_size; |
2666 | e90f009b | aurel32 | default_fmt_size = size; |
2667 | 4c27ba27 | bellard | } |
2668 | 9307c4c1 | bellard | default_fmt_format = format; |
2669 | 9307c4c1 | bellard | } else {
|
2670 | 9307c4c1 | bellard | count = 1;
|
2671 | 9307c4c1 | bellard | format = default_fmt_format; |
2672 | 4c27ba27 | bellard | if (format != 'i') { |
2673 | 4c27ba27 | bellard | size = default_fmt_size; |
2674 | 4c27ba27 | bellard | } else {
|
2675 | 4c27ba27 | bellard | size = -1;
|
2676 | 4c27ba27 | bellard | } |
2677 | 9307c4c1 | bellard | } |
2678 | 9307c4c1 | bellard | if (nb_args + 3 > MAX_ARGS) |
2679 | 9307c4c1 | bellard | goto error_args;
|
2680 | 1c5bf3bf | j_mayer | args[nb_args++] = (void*)(long)count; |
2681 | 1c5bf3bf | j_mayer | args[nb_args++] = (void*)(long)format; |
2682 | 1c5bf3bf | j_mayer | args[nb_args++] = (void*)(long)size; |
2683 | 9307c4c1 | bellard | } |
2684 | 9dc39cba | bellard | break;
|
2685 | 9307c4c1 | bellard | case 'i': |
2686 | 92a31b1f | bellard | case 'l': |
2687 | 9307c4c1 | bellard | { |
2688 | c2efc95d | blueswir1 | int64_t val; |
2689 | 7743e588 | blueswir1 | |
2690 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2691 | 9307c4c1 | bellard | p++; |
2692 | 3440557b | bellard | if (*typestr == '?' || *typestr == '.') { |
2693 | 3440557b | bellard | if (*typestr == '?') { |
2694 | 3440557b | bellard | if (*p == '\0') |
2695 | 3440557b | bellard | has_arg = 0;
|
2696 | 3440557b | bellard | else
|
2697 | 3440557b | bellard | has_arg = 1;
|
2698 | 3440557b | bellard | } else {
|
2699 | 3440557b | bellard | if (*p == '.') { |
2700 | 3440557b | bellard | p++; |
2701 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2702 | 3440557b | bellard | p++; |
2703 | 3440557b | bellard | has_arg = 1;
|
2704 | 3440557b | bellard | } else {
|
2705 | 3440557b | bellard | has_arg = 0;
|
2706 | 3440557b | bellard | } |
2707 | 3440557b | bellard | } |
2708 | 13224a87 | bellard | typestr++; |
2709 | 9307c4c1 | bellard | if (nb_args >= MAX_ARGS)
|
2710 | 9307c4c1 | bellard | goto error_args;
|
2711 | 1c5bf3bf | j_mayer | args[nb_args++] = (void *)(long)has_arg; |
2712 | 9307c4c1 | bellard | if (!has_arg) {
|
2713 | 9307c4c1 | bellard | if (nb_args >= MAX_ARGS)
|
2714 | 9307c4c1 | bellard | goto error_args;
|
2715 | 9307c4c1 | bellard | val = -1;
|
2716 | 9307c4c1 | bellard | goto add_num;
|
2717 | 9307c4c1 | bellard | } |
2718 | 9307c4c1 | bellard | } |
2719 | 376253ec | aliguori | if (get_expr(mon, &val, &p))
|
2720 | 9307c4c1 | bellard | goto fail;
|
2721 | 9307c4c1 | bellard | add_num:
|
2722 | 92a31b1f | bellard | if (c == 'i') { |
2723 | 92a31b1f | bellard | if (nb_args >= MAX_ARGS)
|
2724 | 92a31b1f | bellard | goto error_args;
|
2725 | 1c5bf3bf | j_mayer | args[nb_args++] = (void *)(long)val; |
2726 | 92a31b1f | bellard | } else {
|
2727 | 92a31b1f | bellard | if ((nb_args + 1) >= MAX_ARGS) |
2728 | 92a31b1f | bellard | goto error_args;
|
2729 | 7743e588 | blueswir1 | #if TARGET_PHYS_ADDR_BITS > 32 |
2730 | 1c5bf3bf | j_mayer | args[nb_args++] = (void *)(long)((val >> 32) & 0xffffffff); |
2731 | 92a31b1f | bellard | #else
|
2732 | 92a31b1f | bellard | args[nb_args++] = (void *)0; |
2733 | 92a31b1f | bellard | #endif
|
2734 | 1c5bf3bf | j_mayer | args[nb_args++] = (void *)(long)(val & 0xffffffff); |
2735 | 92a31b1f | bellard | } |
2736 | 9307c4c1 | bellard | } |
2737 | 9307c4c1 | bellard | break;
|
2738 | 9307c4c1 | bellard | case '-': |
2739 | 9307c4c1 | bellard | { |
2740 | 9307c4c1 | bellard | int has_option;
|
2741 | 9307c4c1 | bellard | /* option */
|
2742 | 3b46e624 | ths | |
2743 | 9307c4c1 | bellard | c = *typestr++; |
2744 | 9307c4c1 | bellard | if (c == '\0') |
2745 | 9307c4c1 | bellard | goto bad_type;
|
2746 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2747 | 9307c4c1 | bellard | p++; |
2748 | 9307c4c1 | bellard | has_option = 0;
|
2749 | 9307c4c1 | bellard | if (*p == '-') { |
2750 | 9307c4c1 | bellard | p++; |
2751 | 9307c4c1 | bellard | if (*p != c) {
|
2752 | 376253ec | aliguori | monitor_printf(mon, "%s: unsupported option -%c\n",
|
2753 | 376253ec | aliguori | cmdname, *p); |
2754 | 9307c4c1 | bellard | goto fail;
|
2755 | 9307c4c1 | bellard | } |
2756 | 9307c4c1 | bellard | p++; |
2757 | 9307c4c1 | bellard | has_option = 1;
|
2758 | 9307c4c1 | bellard | } |
2759 | 9307c4c1 | bellard | if (nb_args >= MAX_ARGS)
|
2760 | 9307c4c1 | bellard | goto error_args;
|
2761 | 1c5bf3bf | j_mayer | args[nb_args++] = (void *)(long)has_option; |
2762 | 9307c4c1 | bellard | } |
2763 | 9307c4c1 | bellard | break;
|
2764 | 9307c4c1 | bellard | default:
|
2765 | 9307c4c1 | bellard | bad_type:
|
2766 | 376253ec | aliguori | monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);
|
2767 | 9307c4c1 | bellard | goto fail;
|
2768 | 9307c4c1 | bellard | } |
2769 | 9dc39cba | bellard | } |
2770 | 9307c4c1 | bellard | /* check that all arguments were parsed */
|
2771 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2772 | 9307c4c1 | bellard | p++; |
2773 | 9307c4c1 | bellard | if (*p != '\0') { |
2774 | 376253ec | aliguori | monitor_printf(mon, "%s: extraneous characters at the end of line\n",
|
2775 | 376253ec | aliguori | cmdname); |
2776 | 9307c4c1 | bellard | goto fail;
|
2777 | 9dc39cba | bellard | } |
2778 | 9307c4c1 | bellard | |
2779 | 9307c4c1 | bellard | switch(nb_args) {
|
2780 | 9307c4c1 | bellard | case 0: |
2781 | a5f1b965 | blueswir1 | handler_0 = cmd->handler; |
2782 | 376253ec | aliguori | handler_0(mon); |
2783 | 9307c4c1 | bellard | break;
|
2784 | 9307c4c1 | bellard | case 1: |
2785 | a5f1b965 | blueswir1 | handler_1 = cmd->handler; |
2786 | 376253ec | aliguori | handler_1(mon, args[0]);
|
2787 | 9307c4c1 | bellard | break;
|
2788 | 9307c4c1 | bellard | case 2: |
2789 | a5f1b965 | blueswir1 | handler_2 = cmd->handler; |
2790 | 376253ec | aliguori | handler_2(mon, args[0], args[1]); |
2791 | 9307c4c1 | bellard | break;
|
2792 | 9307c4c1 | bellard | case 3: |
2793 | a5f1b965 | blueswir1 | handler_3 = cmd->handler; |
2794 | 376253ec | aliguori | handler_3(mon, args[0], args[1], args[2]); |
2795 | 9307c4c1 | bellard | break;
|
2796 | 9307c4c1 | bellard | case 4: |
2797 | a5f1b965 | blueswir1 | handler_4 = cmd->handler; |
2798 | 376253ec | aliguori | handler_4(mon, args[0], args[1], args[2], args[3]); |
2799 | 9307c4c1 | bellard | break;
|
2800 | 9307c4c1 | bellard | case 5: |
2801 | a5f1b965 | blueswir1 | handler_5 = cmd->handler; |
2802 | 376253ec | aliguori | handler_5(mon, args[0], args[1], args[2], args[3], args[4]); |
2803 | 9307c4c1 | bellard | break;
|
2804 | 3440557b | bellard | case 6: |
2805 | a5f1b965 | blueswir1 | handler_6 = cmd->handler; |
2806 | 376253ec | aliguori | handler_6(mon, args[0], args[1], args[2], args[3], args[4], args[5]); |
2807 | 3440557b | bellard | break;
|
2808 | ec36b695 | bellard | case 7: |
2809 | a5f1b965 | blueswir1 | handler_7 = cmd->handler; |
2810 | 376253ec | aliguori | handler_7(mon, args[0], args[1], args[2], args[3], args[4], args[5], |
2811 | 376253ec | aliguori | args[6]);
|
2812 | ec36b695 | bellard | break;
|
2813 | 9307c4c1 | bellard | default:
|
2814 | 376253ec | aliguori | monitor_printf(mon, "unsupported number of arguments: %d\n", nb_args);
|
2815 | 9307c4c1 | bellard | goto fail;
|
2816 | 9dc39cba | bellard | } |
2817 | 9307c4c1 | bellard | fail:
|
2818 | 9307c4c1 | bellard | for(i = 0; i < MAX_ARGS; i++) |
2819 | 9307c4c1 | bellard | qemu_free(str_allocated[i]); |
2820 | 9dc39cba | bellard | return;
|
2821 | 9dc39cba | bellard | } |
2822 | 9dc39cba | bellard | |
2823 | 81d0912d | bellard | static void cmd_completion(const char *name, const char *list) |
2824 | 81d0912d | bellard | { |
2825 | 81d0912d | bellard | const char *p, *pstart; |
2826 | 81d0912d | bellard | char cmd[128]; |
2827 | 81d0912d | bellard | int len;
|
2828 | 81d0912d | bellard | |
2829 | 81d0912d | bellard | p = list; |
2830 | 81d0912d | bellard | for(;;) {
|
2831 | 81d0912d | bellard | pstart = p; |
2832 | 81d0912d | bellard | p = strchr(p, '|');
|
2833 | 81d0912d | bellard | if (!p)
|
2834 | 81d0912d | bellard | p = pstart + strlen(pstart); |
2835 | 81d0912d | bellard | len = p - pstart; |
2836 | 81d0912d | bellard | if (len > sizeof(cmd) - 2) |
2837 | 81d0912d | bellard | len = sizeof(cmd) - 2; |
2838 | 81d0912d | bellard | memcpy(cmd, pstart, len); |
2839 | 81d0912d | bellard | cmd[len] = '\0';
|
2840 | 81d0912d | bellard | if (name[0] == '\0' || !strncmp(name, cmd, strlen(name))) { |
2841 | 731b0364 | aliguori | readline_add_completion(cur_mon->rs, cmd); |
2842 | 81d0912d | bellard | } |
2843 | 81d0912d | bellard | if (*p == '\0') |
2844 | 81d0912d | bellard | break;
|
2845 | 81d0912d | bellard | p++; |
2846 | 81d0912d | bellard | } |
2847 | 81d0912d | bellard | } |
2848 | 81d0912d | bellard | |
2849 | 81d0912d | bellard | static void file_completion(const char *input) |
2850 | 81d0912d | bellard | { |
2851 | 81d0912d | bellard | DIR *ffs; |
2852 | 81d0912d | bellard | struct dirent *d;
|
2853 | 81d0912d | bellard | char path[1024]; |
2854 | 81d0912d | bellard | char file[1024], file_prefix[1024]; |
2855 | 81d0912d | bellard | int input_path_len;
|
2856 | 81d0912d | bellard | const char *p; |
2857 | 81d0912d | bellard | |
2858 | 5fafdf24 | ths | p = strrchr(input, '/');
|
2859 | 81d0912d | bellard | if (!p) {
|
2860 | 81d0912d | bellard | input_path_len = 0;
|
2861 | 81d0912d | bellard | pstrcpy(file_prefix, sizeof(file_prefix), input);
|
2862 | 363a37d5 | blueswir1 | pstrcpy(path, sizeof(path), "."); |
2863 | 81d0912d | bellard | } else {
|
2864 | 81d0912d | bellard | input_path_len = p - input + 1;
|
2865 | 81d0912d | bellard | memcpy(path, input, input_path_len); |
2866 | 81d0912d | bellard | if (input_path_len > sizeof(path) - 1) |
2867 | 81d0912d | bellard | input_path_len = sizeof(path) - 1; |
2868 | 81d0912d | bellard | path[input_path_len] = '\0';
|
2869 | 81d0912d | bellard | pstrcpy(file_prefix, sizeof(file_prefix), p + 1); |
2870 | 81d0912d | bellard | } |
2871 | 81d0912d | bellard | #ifdef DEBUG_COMPLETION
|
2872 | 376253ec | aliguori | monitor_printf(cur_mon, "input='%s' path='%s' prefix='%s'\n",
|
2873 | 376253ec | aliguori | input, path, file_prefix); |
2874 | 81d0912d | bellard | #endif
|
2875 | 81d0912d | bellard | ffs = opendir(path); |
2876 | 81d0912d | bellard | if (!ffs)
|
2877 | 81d0912d | bellard | return;
|
2878 | 81d0912d | bellard | for(;;) {
|
2879 | 81d0912d | bellard | struct stat sb;
|
2880 | 81d0912d | bellard | d = readdir(ffs); |
2881 | 81d0912d | bellard | if (!d)
|
2882 | 81d0912d | bellard | break;
|
2883 | 81d0912d | bellard | if (strstart(d->d_name, file_prefix, NULL)) { |
2884 | 81d0912d | bellard | memcpy(file, input, input_path_len); |
2885 | 363a37d5 | blueswir1 | if (input_path_len < sizeof(file)) |
2886 | 363a37d5 | blueswir1 | pstrcpy(file + input_path_len, sizeof(file) - input_path_len,
|
2887 | 363a37d5 | blueswir1 | d->d_name); |
2888 | 81d0912d | bellard | /* stat the file to find out if it's a directory.
|
2889 | 81d0912d | bellard | * In that case add a slash to speed up typing long paths
|
2890 | 81d0912d | bellard | */
|
2891 | 81d0912d | bellard | stat(file, &sb); |
2892 | 81d0912d | bellard | if(S_ISDIR(sb.st_mode))
|
2893 | 363a37d5 | blueswir1 | pstrcat(file, sizeof(file), "/"); |
2894 | 731b0364 | aliguori | readline_add_completion(cur_mon->rs, file); |
2895 | 81d0912d | bellard | } |
2896 | 81d0912d | bellard | } |
2897 | 81d0912d | bellard | closedir(ffs); |
2898 | 81d0912d | bellard | } |
2899 | 81d0912d | bellard | |
2900 | 51de9760 | aliguori | static void block_completion_it(void *opaque, BlockDriverState *bs) |
2901 | 81d0912d | bellard | { |
2902 | 51de9760 | aliguori | const char *name = bdrv_get_device_name(bs); |
2903 | 81d0912d | bellard | const char *input = opaque; |
2904 | 81d0912d | bellard | |
2905 | 81d0912d | bellard | if (input[0] == '\0' || |
2906 | 81d0912d | bellard | !strncmp(name, (char *)input, strlen(input))) {
|
2907 | 731b0364 | aliguori | readline_add_completion(cur_mon->rs, name); |
2908 | 81d0912d | bellard | } |
2909 | 81d0912d | bellard | } |
2910 | 81d0912d | bellard | |
2911 | 81d0912d | bellard | /* NOTE: this parser is an approximate form of the real command parser */
|
2912 | 81d0912d | bellard | static void parse_cmdline(const char *cmdline, |
2913 | 81d0912d | bellard | int *pnb_args, char **args) |
2914 | 81d0912d | bellard | { |
2915 | 81d0912d | bellard | const char *p; |
2916 | 81d0912d | bellard | int nb_args, ret;
|
2917 | 81d0912d | bellard | char buf[1024]; |
2918 | 81d0912d | bellard | |
2919 | 81d0912d | bellard | p = cmdline; |
2920 | 81d0912d | bellard | nb_args = 0;
|
2921 | 81d0912d | bellard | for(;;) {
|
2922 | cd390083 | blueswir1 | while (qemu_isspace(*p))
|
2923 | 81d0912d | bellard | p++; |
2924 | 81d0912d | bellard | if (*p == '\0') |
2925 | 81d0912d | bellard | break;
|
2926 | 81d0912d | bellard | if (nb_args >= MAX_ARGS)
|
2927 | 81d0912d | bellard | break;
|
2928 | 81d0912d | bellard | ret = get_str(buf, sizeof(buf), &p);
|
2929 | 81d0912d | bellard | args[nb_args] = qemu_strdup(buf); |
2930 | 81d0912d | bellard | nb_args++; |
2931 | 81d0912d | bellard | if (ret < 0) |
2932 | 81d0912d | bellard | break;
|
2933 | 81d0912d | bellard | } |
2934 | 81d0912d | bellard | *pnb_args = nb_args; |
2935 | 81d0912d | bellard | } |
2936 | 81d0912d | bellard | |
2937 | 4c36ba32 | aliguori | static void monitor_find_completion(const char *cmdline) |
2938 | 81d0912d | bellard | { |
2939 | 81d0912d | bellard | const char *cmdname; |
2940 | 81d0912d | bellard | char *args[MAX_ARGS];
|
2941 | 81d0912d | bellard | int nb_args, i, len;
|
2942 | 81d0912d | bellard | const char *ptype, *str; |
2943 | 376253ec | aliguori | const mon_cmd_t *cmd;
|
2944 | 64866c3d | bellard | const KeyDef *key;
|
2945 | 81d0912d | bellard | |
2946 | 81d0912d | bellard | parse_cmdline(cmdline, &nb_args, args); |
2947 | 81d0912d | bellard | #ifdef DEBUG_COMPLETION
|
2948 | 81d0912d | bellard | for(i = 0; i < nb_args; i++) { |
2949 | 376253ec | aliguori | monitor_printf(cur_mon, "arg%d = '%s'\n", i, (char *)args[i]); |
2950 | 81d0912d | bellard | } |
2951 | 81d0912d | bellard | #endif
|
2952 | 81d0912d | bellard | |
2953 | 81d0912d | bellard | /* if the line ends with a space, it means we want to complete the
|
2954 | 81d0912d | bellard | next arg */
|
2955 | 81d0912d | bellard | len = strlen(cmdline); |
2956 | cd390083 | blueswir1 | if (len > 0 && qemu_isspace(cmdline[len - 1])) { |
2957 | 81d0912d | bellard | if (nb_args >= MAX_ARGS)
|
2958 | 81d0912d | bellard | return;
|
2959 | 81d0912d | bellard | args[nb_args++] = qemu_strdup("");
|
2960 | 81d0912d | bellard | } |
2961 | 81d0912d | bellard | if (nb_args <= 1) { |
2962 | 81d0912d | bellard | /* command completion */
|
2963 | 81d0912d | bellard | if (nb_args == 0) |
2964 | 81d0912d | bellard | cmdname = "";
|
2965 | 81d0912d | bellard | else
|
2966 | 81d0912d | bellard | cmdname = args[0];
|
2967 | 731b0364 | aliguori | readline_set_completion_index(cur_mon->rs, strlen(cmdname)); |
2968 | 376253ec | aliguori | for(cmd = mon_cmds; cmd->name != NULL; cmd++) { |
2969 | 81d0912d | bellard | cmd_completion(cmdname, cmd->name); |
2970 | 81d0912d | bellard | } |
2971 | 81d0912d | bellard | } else {
|
2972 | 81d0912d | bellard | /* find the command */
|
2973 | 376253ec | aliguori | for(cmd = mon_cmds; cmd->name != NULL; cmd++) { |
2974 | 81d0912d | bellard | if (compare_cmd(args[0], cmd->name)) |
2975 | 81d0912d | bellard | goto found;
|
2976 | 81d0912d | bellard | } |
2977 | 81d0912d | bellard | return;
|
2978 | 81d0912d | bellard | found:
|
2979 | 81d0912d | bellard | ptype = cmd->args_type; |
2980 | 81d0912d | bellard | for(i = 0; i < nb_args - 2; i++) { |
2981 | 81d0912d | bellard | if (*ptype != '\0') { |
2982 | 81d0912d | bellard | ptype++; |
2983 | 81d0912d | bellard | while (*ptype == '?') |
2984 | 81d0912d | bellard | ptype++; |
2985 | 81d0912d | bellard | } |
2986 | 81d0912d | bellard | } |
2987 | 81d0912d | bellard | str = args[nb_args - 1];
|
2988 | 81d0912d | bellard | switch(*ptype) {
|
2989 | 81d0912d | bellard | case 'F': |
2990 | 81d0912d | bellard | /* file completion */
|
2991 | 731b0364 | aliguori | readline_set_completion_index(cur_mon->rs, strlen(str)); |
2992 | 81d0912d | bellard | file_completion(str); |
2993 | 81d0912d | bellard | break;
|
2994 | 81d0912d | bellard | case 'B': |
2995 | 81d0912d | bellard | /* block device name completion */
|
2996 | 731b0364 | aliguori | readline_set_completion_index(cur_mon->rs, strlen(str)); |
2997 | 81d0912d | bellard | bdrv_iterate(block_completion_it, (void *)str);
|
2998 | 81d0912d | bellard | break;
|
2999 | 7fe48483 | bellard | case 's': |
3000 | 7fe48483 | bellard | /* XXX: more generic ? */
|
3001 | 7fe48483 | bellard | if (!strcmp(cmd->name, "info")) { |
3002 | 731b0364 | aliguori | readline_set_completion_index(cur_mon->rs, strlen(str)); |
3003 | 7fe48483 | bellard | for(cmd = info_cmds; cmd->name != NULL; cmd++) { |
3004 | 7fe48483 | bellard | cmd_completion(str, cmd->name); |
3005 | 7fe48483 | bellard | } |
3006 | 64866c3d | bellard | } else if (!strcmp(cmd->name, "sendkey")) { |
3007 | e600d1ef | blueswir1 | char *sep = strrchr(str, '-'); |
3008 | e600d1ef | blueswir1 | if (sep)
|
3009 | e600d1ef | blueswir1 | str = sep + 1;
|
3010 | 731b0364 | aliguori | readline_set_completion_index(cur_mon->rs, strlen(str)); |
3011 | 64866c3d | bellard | for(key = key_defs; key->name != NULL; key++) { |
3012 | 64866c3d | bellard | cmd_completion(str, key->name); |
3013 | 64866c3d | bellard | } |
3014 | 7fe48483 | bellard | } |
3015 | 7fe48483 | bellard | break;
|
3016 | 81d0912d | bellard | default:
|
3017 | 81d0912d | bellard | break;
|
3018 | 81d0912d | bellard | } |
3019 | 81d0912d | bellard | } |
3020 | 81d0912d | bellard | for(i = 0; i < nb_args; i++) |
3021 | 81d0912d | bellard | qemu_free(args[i]); |
3022 | 81d0912d | bellard | } |
3023 | 81d0912d | bellard | |
3024 | 731b0364 | aliguori | static int monitor_can_read(void *opaque) |
3025 | 9dc39cba | bellard | { |
3026 | 731b0364 | aliguori | Monitor *mon = opaque; |
3027 | 731b0364 | aliguori | |
3028 | 731b0364 | aliguori | return (mon->suspend_cnt == 0) ? 128 : 0; |
3029 | 9dc39cba | bellard | } |
3030 | 9dc39cba | bellard | |
3031 | 731b0364 | aliguori | static void monitor_read(void *opaque, const uint8_t *buf, int size) |
3032 | 9dc39cba | bellard | { |
3033 | 731b0364 | aliguori | Monitor *old_mon = cur_mon; |
3034 | 7e2515e8 | bellard | int i;
|
3035 | 376253ec | aliguori | |
3036 | 731b0364 | aliguori | cur_mon = opaque; |
3037 | 731b0364 | aliguori | |
3038 | cde76ee1 | aliguori | if (cur_mon->rs) {
|
3039 | cde76ee1 | aliguori | for (i = 0; i < size; i++) |
3040 | cde76ee1 | aliguori | readline_handle_byte(cur_mon->rs, buf[i]); |
3041 | cde76ee1 | aliguori | } else {
|
3042 | cde76ee1 | aliguori | if (size == 0 || buf[size - 1] != 0) |
3043 | cde76ee1 | aliguori | monitor_printf(cur_mon, "corrupted command\n");
|
3044 | cde76ee1 | aliguori | else
|
3045 | cde76ee1 | aliguori | monitor_handle_command(cur_mon, (char *)buf);
|
3046 | cde76ee1 | aliguori | } |
3047 | 9dc39cba | bellard | |
3048 | 731b0364 | aliguori | cur_mon = old_mon; |
3049 | 731b0364 | aliguori | } |
3050 | d8f44609 | aliguori | |
3051 | 376253ec | aliguori | static void monitor_command_cb(Monitor *mon, const char *cmdline, void *opaque) |
3052 | aa455485 | bellard | { |
3053 | 731b0364 | aliguori | monitor_suspend(mon); |
3054 | 376253ec | aliguori | monitor_handle_command(mon, cmdline); |
3055 | 731b0364 | aliguori | monitor_resume(mon); |
3056 | d8f44609 | aliguori | } |
3057 | d8f44609 | aliguori | |
3058 | cde76ee1 | aliguori | int monitor_suspend(Monitor *mon)
|
3059 | d8f44609 | aliguori | { |
3060 | cde76ee1 | aliguori | if (!mon->rs)
|
3061 | cde76ee1 | aliguori | return -ENOTTY;
|
3062 | 731b0364 | aliguori | mon->suspend_cnt++; |
3063 | cde76ee1 | aliguori | return 0; |
3064 | d8f44609 | aliguori | } |
3065 | d8f44609 | aliguori | |
3066 | 376253ec | aliguori | void monitor_resume(Monitor *mon)
|
3067 | d8f44609 | aliguori | { |
3068 | cde76ee1 | aliguori | if (!mon->rs)
|
3069 | cde76ee1 | aliguori | return;
|
3070 | 731b0364 | aliguori | if (--mon->suspend_cnt == 0) |
3071 | 731b0364 | aliguori | readline_show_prompt(mon->rs); |
3072 | aa455485 | bellard | } |
3073 | aa455485 | bellard | |
3074 | 731b0364 | aliguori | static void monitor_event(void *opaque, int event) |
3075 | 86e94dea | ths | { |
3076 | 376253ec | aliguori | Monitor *mon = opaque; |
3077 | 376253ec | aliguori | |
3078 | 2724b180 | aliguori | switch (event) {
|
3079 | 2724b180 | aliguori | case CHR_EVENT_MUX_IN:
|
3080 | 2724b180 | aliguori | readline_restart(mon->rs); |
3081 | 2724b180 | aliguori | monitor_resume(mon); |
3082 | 2724b180 | aliguori | monitor_flush(mon); |
3083 | 2724b180 | aliguori | break;
|
3084 | 2724b180 | aliguori | |
3085 | 2724b180 | aliguori | case CHR_EVENT_MUX_OUT:
|
3086 | 2724b180 | aliguori | if (mon->suspend_cnt == 0) |
3087 | 2724b180 | aliguori | monitor_printf(mon, "\n");
|
3088 | 2724b180 | aliguori | monitor_flush(mon); |
3089 | 2724b180 | aliguori | monitor_suspend(mon); |
3090 | 2724b180 | aliguori | break;
|
3091 | 86e94dea | ths | |
3092 | 2724b180 | aliguori | case CHR_EVENT_RESET:
|
3093 | 2724b180 | aliguori | monitor_printf(mon, "QEMU %s monitor - type 'help' for more "
|
3094 | 2724b180 | aliguori | "information\n", QEMU_VERSION);
|
3095 | 2724b180 | aliguori | if (mon->chr->focus == 0) |
3096 | 2724b180 | aliguori | readline_show_prompt(mon->rs); |
3097 | 2724b180 | aliguori | break;
|
3098 | 2724b180 | aliguori | } |
3099 | 86e94dea | ths | } |
3100 | 86e94dea | ths | |
3101 | 76655d6d | aliguori | |
3102 | 76655d6d | aliguori | /*
|
3103 | 76655d6d | aliguori | * Local variables:
|
3104 | 76655d6d | aliguori | * c-indent-level: 4
|
3105 | 76655d6d | aliguori | * c-basic-offset: 4
|
3106 | 76655d6d | aliguori | * tab-width: 8
|
3107 | 76655d6d | aliguori | * End:
|
3108 | 76655d6d | aliguori | */
|
3109 | 76655d6d | aliguori | |
3110 | 731b0364 | aliguori | void monitor_init(CharDriverState *chr, int flags) |
3111 | aa455485 | bellard | { |
3112 | 731b0364 | aliguori | static int is_first_init = 1; |
3113 | 87127161 | aliguori | Monitor *mon; |
3114 | 20d8a3ed | ths | |
3115 | 20d8a3ed | ths | if (is_first_init) {
|
3116 | c8256f9d | balrog | key_timer = qemu_new_timer(vm_clock, release_keys, NULL);
|
3117 | 20d8a3ed | ths | is_first_init = 0;
|
3118 | 20d8a3ed | ths | } |
3119 | 87127161 | aliguori | |
3120 | 87127161 | aliguori | mon = qemu_mallocz(sizeof(*mon));
|
3121 | 20d8a3ed | ths | |
3122 | 87127161 | aliguori | mon->chr = chr; |
3123 | 731b0364 | aliguori | mon->flags = flags; |
3124 | 2724b180 | aliguori | if (mon->chr->focus != 0) |
3125 | 2724b180 | aliguori | mon->suspend_cnt = 1; /* mux'ed monitors start suspended */ |
3126 | cde76ee1 | aliguori | if (flags & MONITOR_USE_READLINE) {
|
3127 | cde76ee1 | aliguori | mon->rs = readline_init(mon, monitor_find_completion); |
3128 | cde76ee1 | aliguori | monitor_read_command(mon, 0);
|
3129 | cde76ee1 | aliguori | } |
3130 | 87127161 | aliguori | |
3131 | 731b0364 | aliguori | qemu_chr_add_handlers(chr, monitor_can_read, monitor_read, monitor_event, |
3132 | 731b0364 | aliguori | mon); |
3133 | 87127161 | aliguori | |
3134 | 87127161 | aliguori | LIST_INSERT_HEAD(&mon_list, mon, entry); |
3135 | 731b0364 | aliguori | if (!cur_mon || (flags & MONITOR_IS_DEFAULT))
|
3136 | 87127161 | aliguori | cur_mon = mon; |
3137 | aa455485 | bellard | } |
3138 | aa455485 | bellard | |
3139 | 376253ec | aliguori | static void bdrv_password_cb(Monitor *mon, const char *password, void *opaque) |
3140 | 81d0912d | bellard | { |
3141 | bb5fc20f | aliguori | BlockDriverState *bs = opaque; |
3142 | bb5fc20f | aliguori | int ret = 0; |
3143 | 81d0912d | bellard | |
3144 | bb5fc20f | aliguori | if (bdrv_set_key(bs, password) != 0) { |
3145 | 376253ec | aliguori | monitor_printf(mon, "invalid password\n");
|
3146 | bb5fc20f | aliguori | ret = -EPERM; |
3147 | 9dc39cba | bellard | } |
3148 | 731b0364 | aliguori | if (mon->password_completion_cb)
|
3149 | 731b0364 | aliguori | mon->password_completion_cb(mon->password_opaque, ret); |
3150 | bb5fc20f | aliguori | |
3151 | 731b0364 | aliguori | monitor_read_command(mon, 1);
|
3152 | 9dc39cba | bellard | } |
3153 | c0f4ce77 | aliguori | |
3154 | 376253ec | aliguori | void monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
|
3155 | bb5fc20f | aliguori | BlockDriverCompletionFunc *completion_cb, |
3156 | bb5fc20f | aliguori | void *opaque)
|
3157 | c0f4ce77 | aliguori | { |
3158 | cde76ee1 | aliguori | int err;
|
3159 | cde76ee1 | aliguori | |
3160 | bb5fc20f | aliguori | if (!bdrv_key_required(bs)) {
|
3161 | bb5fc20f | aliguori | if (completion_cb)
|
3162 | bb5fc20f | aliguori | completion_cb(opaque, 0);
|
3163 | bb5fc20f | aliguori | return;
|
3164 | bb5fc20f | aliguori | } |
3165 | c0f4ce77 | aliguori | |
3166 | 376253ec | aliguori | monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
|
3167 | 376253ec | aliguori | bdrv_get_encrypted_filename(bs)); |
3168 | bb5fc20f | aliguori | |
3169 | 731b0364 | aliguori | mon->password_completion_cb = completion_cb; |
3170 | 731b0364 | aliguori | mon->password_opaque = opaque; |
3171 | bb5fc20f | aliguori | |
3172 | cde76ee1 | aliguori | err = monitor_read_password(mon, bdrv_password_cb, bs); |
3173 | cde76ee1 | aliguori | |
3174 | cde76ee1 | aliguori | if (err && completion_cb)
|
3175 | cde76ee1 | aliguori | completion_cb(opaque, err); |
3176 | c0f4ce77 | aliguori | } |