From: "J. Mayer" <l_indien@magic.fr>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Term prompt for qemu
Date: 18 Nov 2003 09:13:42 +0100 [thread overview]
Message-ID: <1069143222.13658.2288.camel@rapid> (raw)
In-Reply-To: <1069140566.13658.2177.camel@rapid>
vl.c.diff
Add term prompt for user commands during emulation.
Also add <CTRL><a>+<d> to turn on/off log. This is useful
to know if qemu is still translating code, long time after the
boot.
diff -urNbB -x CVS qemu-current/vl.c qemu/vl.c
--- qemu-current/vl.c Tue Nov 18 06:51:10 2003
+++ qemu/vl.c Tue Nov 18 02:19:33 2003
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
+#include <ctype.h>
#include <getopt.h>
#include <inttypes.h>
#include <unistd.h>
@@ -1422,23 +1483,124 @@
}
#define TERM_ESCAPE 0x01 /* ctrl-a is used for escape */
-static int term_got_escape;
+static int term_got_escape, term_command;
+static unsigned char term_cmd_buf[128];
+
+typedef struct term_cmd_t {
+ const unsigned char *name;
+ void (*handler)(unsigned char *params);
+} term_cmd_t;
+
+static void do_change_cdrom (unsigned char *params);
+static void do_change_fd0 (unsigned char *params);
+static void do_change_fd1 (unsigned char *params);
+
+static term_cmd_t term_cmds[] = {
+ { "changecd", &do_change_cdrom, },
+ { "changefd0", &do_change_fd0, },
+ { "changefd1", &do_change_fd1, },
+ { NULL, NULL, },
+};
void term_print_help(void)
{
printf("\n"
"C-a h print this help\n"
"C-a x exit emulatior\n"
+ "C-a d switch on/off debug log\n"
"C-a s save disk data back to file (if -snapshot)\n"
"C-a b send break (magic sysrq)\n"
+ "C-a c send qemu internal command\n"
"C-a C-a send C-a\n"
);
}
+static void do_change_cdrom (unsigned char *params)
+{
+ /* Dunno how to do it... */
+}
+
+static void do_change_fd (int fd, unsigned char *params)
+{
+ unsigned char *name_start, *name_end, *ros;
+ int ro;
+
+ for (name_start = params;
+ isspace(*name_start); name_start++)
+ continue;
+ if (*name_start == '\0')
+ return;
+ for (name_end = name_start;
+ !isspace(*name_end) && *name_end != '\0'; name_end++)
+ continue;
+ for (ros = name_end + 1; isspace(*ros); ros++)
+ continue;
+ if (ros[0] == 'r' && ros[1] == 'o')
+ ro = 1;
+ else
+ ro = 0;
+ *name_end = '\0';
+ printf("Change fd %d to %s (%s)\n", fd, name_start, params);
+ fdctrl_disk_change(fd, name_start, ro);
+}
+
+static void do_change_fd0 (unsigned char *params)
+{
+ do_change_fd(0, params);
+}
+
+static void do_change_fd1 (unsigned char *params)
+{
+ do_change_fd(1, params);
+}
+
+static void serial_treat_command ()
+{
+ unsigned char *cmd_start, *cmd_end;
+ int i;
+
+ for (cmd_start = term_cmd_buf; isspace(*cmd_start); cmd_start++)
+ continue;
+ for (cmd_end = cmd_start;
+ !isspace(*cmd_end) && *cmd_end != '\0'; cmd_end++)
+ continue;
+ for (i = 0; term_cmds[i].name != NULL; i++) {
+ if (strlen(term_cmds[i].name) == (cmd_end - cmd_start) &&
+ memcmp(term_cmds[i].name, cmd_start, cmd_end - cmd_start) == 0) {
+ (*term_cmds[i].handler)(cmd_end + 1);
+ return;
+ }
+ }
+ *cmd_end = '\0';
+ printf("Unknown term command: %s\n", cmd_start);
+}
+
+extern FILE *logfile;
+
/* called when a char is received */
void serial_received_byte(SerialState *s, int ch)
{
- if (term_got_escape) {
+ if (term_command) {
+ if (ch == '\n' || ch == '\r' || term_command == 127) {
+ printf("\n");
+ serial_treat_command();
+ term_command = 0;
+ } else {
+ if (ch == 0x7F || ch == 0x08) {
+ if (term_command > 0) {
+ term_cmd_buf[--term_command] = '\0';
+ printf("\r "
+ " ");
+ printf("\r> %s", term_cmd_buf);
+ }
+ } else if (ch > 0x1f) {
+ term_cmd_buf[term_command++ - 1] = ch;
+ term_cmd_buf[term_command - 1] = '\0';
+ printf("\r> %s", term_cmd_buf);
+ }
+ fflush(stdout);
+ }
+ } else if (term_got_escape) {
term_got_escape = 0;
switch(ch) {
case 'h':
@@ -1447,6 +1609,14 @@
case 'x':
exit(0);
break;
+ case 'd':
+ if (logfile == NULL) {
+ printf("Turn logging ON\n");
+ cpu_set_log(CPU_LOG_ALL);
+ } else {
+ printf("Turn logging OFF\n");
+ cpu_reset_log();
+ }
case 's':
{
int i;
@@ -1462,6 +1632,11 @@
s->lsr |= UART_LSR_BI | UART_LSR_DR;
serial_update_irq();
break;
+ case 'c':
+ printf("> ");
+ fflush(stdout);
+ term_command = 1;
+ break;
case TERM_ESCAPE:
goto send_char;
}
@@ -2178,12 +2373,14 @@
val |= 0x20;
kbd_queue(s, val, 0);
break;
+#ifdef TARGET_I386
case KBD_CCMD_ENABLE_A20:
cpu_x86_set_a20(env, 1);
break;
case KBD_CCMD_DISABLE_A20:
cpu_x86_set_a20(env, 0);
break;
+#endif
case KBD_CCMD_RESET:
reset_requested = 1;
cpu_x86_interrupt(global_env, CPU_INTERRUPT_EXIT);
@@ -2516,7 +2713,9 @@
kbd_queue(s, val, 1);
break;
case KBD_CCMD_WRITE_OUTPORT:
+#ifdef TARGET_I386
cpu_x86_set_a20(env, (val >> 1) & 1);
+#endif
if (!(val & 1)) {
reset_requested = 1;
cpu_x86_interrupt(global_env, CPU_INTERRUPT_EXIT);
@@ -2559,7 +2758,7 @@
/***********************************************************/
/* Bochs BIOS debug ports */
-
+#ifdef TARGET_I386
void bochs_bios_write(CPUX86State *env, uint32_t addr, uint32_t val)
{
switch(addr) {
@@ -2601,6 +2800,7 @@
register_ioport_write(0x500, 1, bochs_bios_write, 1);
register_ioport_write(0x503, 1, bochs_bios_write, 1);
}
+#endif
/***********************************************************/
/* dumb display */
next prev parent reply other threads:[~2003-11-18 9:11 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-17 9:51 [Qemu-devel] new knoppix SegFault Jens Arm
2003-11-18 7:15 ` [Qemu-devel] [PATCH] Fixes for qemu J. Mayer
2003-11-18 7:30 ` J. Mayer
2003-11-18 7:31 ` Chad Page
2003-11-18 7:32 ` J. Mayer
2003-11-18 7:33 ` J. Mayer
2003-11-18 7:34 ` J. Mayer
2003-11-18 8:24 ` J. Mayer
2003-11-18 7:22 ` [Qemu-devel] [ADD] floppy disk emulation J. Mayer
2003-11-18 7:37 ` J. Mayer
2003-11-18 7:38 ` J. Mayer
2003-11-18 7:39 ` J. Mayer
2003-11-18 7:39 ` J. Mayer
2003-11-18 8:24 ` J. Mayer
2003-11-18 7:28 ` [Qemu-devel] [ADD] PPC processor emulation J. Mayer
2003-11-18 7:43 ` J. Mayer
2003-11-18 7:43 ` J. Mayer
2003-11-18 7:44 ` J. Mayer
2003-11-18 7:45 ` J. Mayer
2003-11-18 7:45 ` J. Mayer
2003-11-18 7:46 ` J. Mayer
2003-11-18 7:46 ` J. Mayer
2003-11-18 7:48 ` J. Mayer
2003-11-18 7:48 ` J. Mayer
2003-11-18 7:49 ` J. Mayer
2003-11-18 7:50 ` J. Mayer
2003-11-18 7:50 ` J. Mayer
2003-11-18 7:51 ` J. Mayer
2003-11-18 7:53 ` J. Mayer
2003-11-18 7:54 ` J. Mayer
2003-11-18 7:55 ` J. Mayer
2003-11-18 7:56 ` J. Mayer
2003-11-18 7:56 ` J. Mayer
2003-11-18 7:57 ` J. Mayer
2003-11-18 7:58 ` J. Mayer
2003-11-18 7:59 ` J. Mayer
2003-11-18 7:59 ` J. Mayer
2003-11-18 8:00 ` J. Mayer
2003-11-18 8:02 ` [Qemu-devel] [ADD] tests for PPC target J. Mayer
2003-11-18 8:06 ` J. Mayer
2003-11-18 8:08 ` J. Mayer
2003-11-18 8:08 ` J. Mayer
2003-11-18 8:09 ` J. Mayer
2003-11-18 8:10 ` J. Mayer
2003-11-18 8:25 ` J. Mayer
2003-11-18 8:24 ` [Qemu-devel] [ADD] PPC processor emulation J. Mayer
2003-11-18 9:37 ` Gwenole Beauchesne
2003-11-18 10:37 ` J. Mayer
2003-11-18 11:39 ` Raymond W. Lucke IV
2003-11-18 12:13 ` J. Mayer
2003-11-18 20:24 ` Raymond W. Lucke IV
2003-11-18 20:44 ` Jocelyn Mayer
2003-11-18 21:48 ` Chad Page
2003-11-18 22:50 ` J. Mayer
2003-11-19 1:11 ` Benjamin Herrenschmidt
2003-11-19 15:35 ` Jocelyn Mayer
2003-11-18 12:24 ` Gwenole Beauchesne
2003-11-18 12:57 ` Johan Rydberg
2003-11-18 14:52 ` Gwenole Beauchesne
2003-11-18 14:59 ` Jocelyn Mayer
2003-11-18 7:29 ` [Qemu-devel] [PATCH] Term prompt for qemu J. Mayer
2003-11-18 8:11 ` J. Mayer
2003-11-18 8:11 ` J. Mayer
2003-11-18 8:13 ` J. Mayer [this message]
2003-11-18 8:25 ` J. Mayer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1069143222.13658.2288.camel@rapid \
--to=l_indien@magic.fr \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).