typedef struct term_cmd_t {
const char *name;
const char *args_type;
- void (*handler)();
+ void *handler;
const char *params;
const char *help;
} term_cmd_t;
static void do_info(const char *item)
{
term_cmd_t *cmd;
+ void (*handler)(void);
if (!item)
goto help;
help_cmd("info");
return;
found:
- cmd->handler();
+ handler = cmd->handler;
+ handler();
}
static void do_info_version(void)
#elif defined(TARGET_SPARC)
term_printf(" pc=0x" TARGET_FMT_lx " npc=0x" TARGET_FMT_lx, env->pc, env->npc);
#elif defined(TARGET_MIPS)
- term_printf(" PC=0x" TARGET_FMT_lx, env->PC[env->current_tc]);
+ term_printf(" PC=0x" TARGET_FMT_lx, env->active_tc.PC);
#endif
if (env->halted)
term_printf(" (halted)");
eject_device(bs, force);
}
-static void do_change_block(const char *device, const char *filename)
+static void do_change_block(const char *device, const char *filename, const char *fmt)
{
BlockDriverState *bs;
+ BlockDriver *drv = NULL;
bs = bdrv_find(device);
if (!bs) {
term_printf("device not found\n");
return;
}
+ if (fmt) {
+ drv = bdrv_find_format(fmt);
+ if (!drv) {
+ term_printf("invalid format %s\n", fmt);
+ return;
+ }
+ }
if (eject_device(bs, 0) < 0)
return;
- bdrv_open(bs, filename, 0);
+ bdrv_open2(bs, filename, 0, drv);
qemu_key_check(bs, filename);
}
}
}
-static void do_change(const char *device, const char *target)
+static void do_change(const char *device, const char *target, const char *fmt)
{
if (strcmp(device, "vnc") == 0) {
do_change_vnc(target);
} else {
- do_change_block(device, target);
+ do_change_block(device, target, fmt);
}
}
env = mon_get_cpu();
if (!env)
break;
- cpu_memory_rw_debug(env, addr, buf, l, 0);
+ if (cpu_memory_rw_debug(env, addr, buf, l, 0) < 0) {
+ term_printf(" Cannot access memory\n");
+ break;
+ }
}
i = 0;
while (i < l) {
{ 0x38, "alt" },
{ 0xb8, "alt_r" },
+ { 0x64, "altgr" },
+ { 0xe4, "altgr_r" },
{ 0x1d, "ctrl" },
{ 0x9d, "ctrl_r" },
{ 0xd2, "insert" },
{ 0xd3, "delete" },
+#if defined(TARGET_SPARC) && !defined(TARGET_SPARC64)
+ { 0xf0, "stop" },
+ { 0xf1, "again" },
+ { 0xf2, "props" },
+ { 0xf3, "undo" },
+ { 0xf4, "front" },
+ { 0xf5, "copy" },
+ { 0xf6, "open" },
+ { 0xf7, "paste" },
+ { 0xf8, "find" },
+ { 0xf9, "cut" },
+ { 0xfa, "lf" },
+ { 0xfb, "help" },
+ { 0xfc, "meta_l" },
+ { 0xfd, "meta_r" },
+ { 0xfe, "compose" },
+#endif
{ 0, NULL },
};
kbd_put_keycode(keycode & 0x7f);
}
/* delayed key up events */
- qemu_mod_timer(key_timer,
- qemu_get_clock(vm_clock) + ticks_per_sec * hold_time);
+ qemu_mod_timer(key_timer, qemu_get_clock(vm_clock) +
+ muldiv64(ticks_per_sec, hold_time, 1000));
}
static int mouse_button_state;
suffix, addr, size * 2, val);
}
+/* boot_set handler */
+static QEMUBootSetHandler *qemu_boot_set_handler = NULL;
+static void *boot_opaque;
+
+void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
+{
+ qemu_boot_set_handler = func;
+ boot_opaque = opaque;
+}
+
static void do_boot_set(const char *bootdevice)
{
int res;
if (qemu_boot_set_handler) {
- res = qemu_boot_set_handler(bootdevice);
+ res = qemu_boot_set_handler(boot_opaque, bootdevice);
if (res == 0)
term_printf("boot device list now set to %s\n", bootdevice);
else
"", "quit the emulator" },
{ "eject", "-fB", do_eject,
"[-f] device", "eject a removable medium (use -f to force it)" },
- { "change", "BF", do_change,
- "device filename", "change a removable medium" },
+ { "change", "BFs?", do_change,
+ "device filename [format]", "change a removable medium, optional format" },
{ "screendump", "F", do_screen_dump,
"filename", "save screen into PPM image 'filename'" },
{ "logfile", "F", do_logfile,
char buf[1024];
void *str_allocated[MAX_ARGS];
void *args[MAX_ARGS];
+ void (*handler_0)(void);
+ void (*handler_1)(void *arg0);
+ void (*handler_2)(void *arg0, void *arg1);
+ void (*handler_3)(void *arg0, void *arg1, void *arg2);
+ void (*handler_4)(void *arg0, void *arg1, void *arg2, void *arg3);
+ void (*handler_5)(void *arg0, void *arg1, void *arg2, void *arg3,
+ void *arg4);
+ void (*handler_6)(void *arg0, void *arg1, void *arg2, void *arg3,
+ void *arg4, void *arg5);
+ void (*handler_7)(void *arg0, void *arg1, void *arg2, void *arg3,
+ void *arg4, void *arg5, void *arg6);
#ifdef DEBUG
term_printf("command='%s'\n", cmdline);
goto fail;
}
str = qemu_malloc(strlen(buf) + 1);
- strcpy(str, buf);
+ pstrcpy(str, sizeof(buf), buf);
str_allocated[nb_args] = str;
add_str:
if (nb_args >= MAX_ARGS) {
switch(nb_args) {
case 0:
- cmd->handler();
+ handler_0 = cmd->handler;
+ handler_0();
break;
case 1:
- cmd->handler(args[0]);
+ handler_1 = cmd->handler;
+ handler_1(args[0]);
break;
case 2:
- cmd->handler(args[0], args[1]);
+ handler_2 = cmd->handler;
+ handler_2(args[0], args[1]);
break;
case 3:
- cmd->handler(args[0], args[1], args[2]);
+ handler_3 = cmd->handler;
+ handler_3(args[0], args[1], args[2]);
break;
case 4:
- cmd->handler(args[0], args[1], args[2], args[3]);
+ handler_4 = cmd->handler;
+ handler_4(args[0], args[1], args[2], args[3]);
break;
case 5:
- cmd->handler(args[0], args[1], args[2], args[3], args[4]);
+ handler_5 = cmd->handler;
+ handler_5(args[0], args[1], args[2], args[3], args[4]);
break;
case 6:
- cmd->handler(args[0], args[1], args[2], args[3], args[4], args[5]);
+ handler_6 = cmd->handler;
+ handler_6(args[0], args[1], args[2], args[3], args[4], args[5]);
break;
case 7:
- cmd->handler(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+ handler_7 = cmd->handler;
+ handler_7(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
break;
default:
term_printf("unsupported number of arguments: %d\n", nb_args);
if (!p) {
input_path_len = 0;
pstrcpy(file_prefix, sizeof(file_prefix), input);
- strcpy(path, ".");
+ pstrcpy(path, sizeof(path), ".");
} else {
input_path_len = p - input + 1;
memcpy(path, input, input_path_len);
break;
if (strstart(d->d_name, file_prefix, NULL)) {
memcpy(file, input, input_path_len);
- strcpy(file + input_path_len, d->d_name);
+ if (input_path_len < sizeof(file))
+ pstrcpy(file + input_path_len, sizeof(file) - input_path_len,
+ d->d_name);
/* stat the file to find out if it's a directory.
* In that case add a slash to speed up typing long paths
*/
stat(file, &sb);
if(S_ISDIR(sb.st_mode))
- strcat(file, "/");
+ pstrcat(file, sizeof(file), "/");
add_completion(file);
}
}
char *buf, int buf_size)
{
int i;
+ int old_focus[MAX_MON];
if (is_password) {
- for (i = 0; i < MAX_MON; i++)
- if (monitor_hd[i] && monitor_hd[i]->focus == 0)
+ for (i = 0; i < MAX_MON; i++) {
+ old_focus[i] = 0;
+ if (monitor_hd[i]) {
+ old_focus[i] = monitor_hd[i]->focus;
+ monitor_hd[i]->focus = 0;
qemu_chr_send_event(monitor_hd[i], CHR_EVENT_FOCUS);
+ }
+ }
}
+
readline_start(prompt, is_password, monitor_readline_cb, NULL);
monitor_readline_buf = buf;
monitor_readline_buf_size = buf_size;
while (monitor_readline_started) {
main_loop_wait(10);
}
+ /* restore original focus */
+ if (is_password) {
+ for (i = 0; i < MAX_MON; i++)
+ if (old_focus[i])
+ monitor_hd[i]->focus = old_focus[i];
+ }
}