aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.target1
-rw-r--r--android-commands.h19
-rw-r--r--android-console.c30
-rw-r--r--android-console.h26
-rw-r--r--include/monitor/monitor.h1
-rw-r--r--monitor.c28
-rw-r--r--vl.c2
7 files changed, 102 insertions, 5 deletions
diff --git a/Makefile.target b/Makefile.target
index 9986047545..ad66194f57 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -113,6 +113,7 @@ endif #CONFIG_BSD_USER
# System emulator target
ifdef CONFIG_SOFTMMU
obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o
+obj-y += android-console.o
obj-y += qtest.o
obj-y += hw/
obj-$(CONFIG_FDT) += device_tree.o
diff --git a/android-commands.h b/android-commands.h
new file mode 100644
index 0000000000..a8a9075897
--- /dev/null
+++ b/android-commands.h
@@ -0,0 +1,19 @@
+/* hand-written for now; consider .hx autogen */
+
+static mon_cmd_t android_cmds[] = {
+ {
+ .name = "help|h|?",
+ .args_type = "name:S?",
+ .params = "",
+ .help = "print a list of commands",
+ .mhandler.cmd = do_help_cmd,
+ },
+ {
+ .name = "kill",
+ .args_type = "",
+ .params = "",
+ .help = "kill the emulator instance",
+ .mhandler.cmd = android_console_kill,
+ },
+ { NULL, NULL, },
+};
diff --git a/android-console.c b/android-console.c
new file mode 100644
index 0000000000..9bc2ad4dd2
--- /dev/null
+++ b/android-console.c
@@ -0,0 +1,30 @@
+/* Android console command implementation.
+ *
+ * Copyright (c) 2014 Linaro Limited
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2 or later, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "android-console.h"
+#include "monitor/monitor.h"
+#include "qemu/sockets.h"
+#include "net/slirp.h"
+#include "slirp/libslirp.h"
+#include "qmp-commands.h"
+
+void android_console_kill(Monitor *mon, const QDict *qdict)
+{
+ monitor_printf(mon, "OK: killing emulator, bye bye\n");
+ monitor_suspend(mon);
+ qmp_quit(NULL);
+}
diff --git a/android-console.h b/android-console.h
new file mode 100644
index 0000000000..7aa183489c
--- /dev/null
+++ b/android-console.h
@@ -0,0 +1,26 @@
+/* Android console interface
+ *
+ * Copyright (c) 2014 Linaro Limited
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2 or later, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef ANDROID_CONSOLE_H
+#define ANDROID_CONSOLE_H
+
+#include "qemu-common.h"
+
+void android_console_kill(Monitor *mon, const QDict *qdict);
+
+#endif
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 1c1f56f36b..43ca2fded3 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -15,6 +15,7 @@ extern Monitor *default_mon;
#define MONITOR_USE_READLINE 0x02
#define MONITOR_USE_CONTROL 0x04
#define MONITOR_USE_PRETTY 0x08
+#define MONITOR_ANDROID_CONSOLE 0x10
/* flags for monitor commands */
#define MONITOR_CMD_ASYNC 0x0001
diff --git a/monitor.c b/monitor.c
index 593679a17a..c9f4a245c7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -68,6 +68,7 @@
#include "exec/memory.h"
#include "qmp-commands.h"
#include "hmp.h"
+#include "android-console.h"
#include "qemu/thread.h"
/* for pic/irq_info */
@@ -201,6 +202,8 @@ struct Monitor {
void *password_opaque;
mon_cmd_t *cmd_table;
QError *error;
+ const char *prompt;
+ const char *banner;
QLIST_HEAD(,mon_fd_t) fds;
QLIST_ENTRY(Monitor) entry;
};
@@ -214,6 +217,7 @@ static int mon_refcount;
static mon_cmd_t mon_cmds[];
static mon_cmd_t info_cmds[];
+static mon_cmd_t android_cmds[];
static const mon_cmd_t qmp_cmds[];
@@ -245,7 +249,7 @@ void monitor_read_command(Monitor *mon, int show_prompt)
if (!mon->rs)
return;
- readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL);
+ readline_start(mon->rs, mon->prompt, 0, monitor_command_cb, NULL);
if (show_prompt)
readline_show_prompt(mon->rs);
}
@@ -2973,6 +2977,8 @@ static const mon_cmd_t qmp_cmds[] = {
{ /* NULL */ },
};
+#include "android-commands.h"
+
/*******************************************************************/
static const char *pch;
@@ -3740,8 +3746,12 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
cmd = search_dispatch_table(table, cmdname);
if (!cmd) {
- monitor_printf(mon, "unknown command: '%.*s'\n",
- (int)(p - cmdline), cmdline);
+ if (mon->cmd_table == android_cmds) {
+ monitor_printf(mon, "KO: unknown command, try 'help'\n");
+ } else {
+ monitor_printf(mon, "unknown command: '%.*s'\n",
+ (int)(p - cmdline), cmdline);
+ }
return NULL;
}
@@ -5101,8 +5111,7 @@ static void monitor_event(void *opaque, int event)
break;
case CHR_EVENT_OPENED:
- monitor_printf(mon, "QEMU %s monitor - type 'help' for more "
- "information\n", QEMU_VERSION);
+ monitor_printf(mon, "%s\n", mon->banner);
if (!mon->mux_out) {
readline_show_prompt(mon->rs);
}
@@ -5175,6 +5184,15 @@ void monitor_init(CharDriverState *chr, int flags)
mon = g_malloc(sizeof(*mon));
monitor_data_init(mon);
+ mon->prompt = "(qemu) ";
+ mon->banner =
+ "QEMU " QEMU_VERSION " monitor - type 'help' for more information";
+
+ if (flags & MONITOR_ANDROID_CONSOLE) {
+ mon->cmd_table = android_cmds;
+ mon->prompt = "";
+ mon->banner = "Android Console: type 'help' for a list of commands";
+ }
mon->chr = chr;
mon->flags = flags;
diff --git a/vl.c b/vl.c
index 709d8cda8d..d8c1572f74 100644
--- a/vl.c
+++ b/vl.c
@@ -2454,6 +2454,8 @@ static int mon_init_func(QemuOpts *opts, void *opaque)
flags = MONITOR_USE_READLINE;
} else if (strcmp(mode, "control") == 0) {
flags = MONITOR_USE_CONTROL;
+ } else if (strcmp(mode, "android-console") == 0) {
+ flags = MONITOR_ANDROID_CONSOLE | MONITOR_USE_READLINE;
} else {
fprintf(stderr, "unknown monitor mode \"%s\"\n", mode);
exit(1);