[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 002/111] linux-user: add qemu-wrapper
From: |
Bryce Lanham |
Subject: |
[Qemu-devel] [PATCH 002/111] linux-user: add qemu-wrapper |
Date: |
Wed, 17 Aug 2011 15:46:07 -0500 |
From: Laurent Vivier <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
Makefile.target | 8 +++-
configure | 9 ++++
linux-user/qemu-wrapper.c | 97 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 113 insertions(+), 1 deletions(-)
create mode 100644 linux-user/qemu-wrapper.c
diff --git a/Makefile.target b/Makefile.target
index 4aacc67..a486aa9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -25,6 +25,7 @@ include $(SRC_PATH)/Makefile.objs
ifdef CONFIG_USER_ONLY
# user emulator name
QEMU_PROG=qemu-$(TARGET_ARCH2)
+USER_TOOLS=$(TARGET_TOOLS)
else
# system emulator name
ifeq ($(TARGET_ARCH), i386)
@@ -32,9 +33,10 @@ QEMU_PROG=qemu$(EXESUF)
else
QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF)
endif
+USER_TOOLS=
endif
-PROGS=$(QEMU_PROG)
+PROGS=$(QEMU_PROG) $(USER_TOOLS)
STPFILES=
ifndef CONFIG_HAIKU
@@ -64,6 +66,10 @@ else
stap:
endif
+qemu-wrapper.o: $(SRC_PATH)/linux-user/qemu-wrapper.c
+qemu-wrapper$(EXESUF): qemu-wrapper.o
+
+
all: $(PROGS) stap
# Dummy command so that make thinks it has done something
diff --git a/configure b/configure
index 0c67a4a..e85d2ca 100755
--- a/configure
+++ b/configure
@@ -2636,6 +2636,14 @@ if test "$softmmu" = yes ; then
fi
fi
fi
+target_tools=
+if test "$linux_user" = yes ; then
+ for target in $target_list ; do
+ case $target in
+ *-linux-user) target_tools="qemu-wrapper\$(EXESUF) $target_tools" ;;
+ esac
+ done
+fi
# Mac OS X ships with a broken assembler
roms=
@@ -3079,6 +3087,7 @@ fi
echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
echo "TOOLS=$tools" >> $config_host_mak
+echo "TARGET_TOOLS=$target_tools" >> $config_host_mak
echo "ROMS=$roms" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak
echo "INSTALL=$install" >> $config_host_mak
diff --git a/linux-user/qemu-wrapper.c b/linux-user/qemu-wrapper.c
new file mode 100644
index 0000000..6926a6c
--- /dev/null
+++ b/linux-user/qemu-wrapper.c
@@ -0,0 +1,97 @@
+/*
+ * qemu-wrapper
+ *
+ * Copyright (c) 2011 Laurent Vivier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that 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/>.
+ */
+
+/*
+ * HOWTO
+ *
+ * for instance, for m68k target.
+ *
+ * copy qemu-wrapper and qemu-m68 into the m68k filesystem:
+ *
+ * cd m68k-linux-user
+ * sudo cp qemu-m68k qemu-wrapper /m68k/usr/bin/qemu-wrapper
+ *
+ * update binfmts:
+ *
+ * update-binfmts --install m68k /usr/bin/qemu-wrapper \
+ * --magic \
+ * \x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04 \
+ * --mask \
+ *
\xff\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff
+ *
+ * chroot the m68k filesystem:
+ *
+ * sudo QEMU_CPU=m68020 chroot /m68k
+ *
+ * ******** IMPORTANT NOTE ********
+ *
+ * qemu-m68k and qemu-wrapper must be linked staticaly:
+ *
+ * ./configure --target-list=m68k-linux-user --static
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "config-target.h"
+
+int main(int argc, char **argv, char **envp) {
+ char *wrapper[argc + 7];
+ int current = 0;
+ char *cpu, *debug, *port;
+
+ wrapper[current] = argv[0];
+ current++;
+
+ cpu = getenv("QEMU_CPU");
+ if (cpu) {
+ wrapper[current] = (char*)"-cpu";
+ current++;
+ wrapper[current] = cpu;
+ current++;
+ }
+
+ debug = getenv("QEMU_DEBUG");
+ if (debug) {
+ wrapper[current] = (char*)"-d";
+ current++;
+ wrapper[current] = debug;
+ current++;
+ }
+ unsetenv("QEMU_DEBUG");
+
+ port = getenv("QEMU_GDB");
+ if (port) {
+ wrapper[current] = (char*)"-g";
+ current++;
+ wrapper[current] = port;
+ current++;
+ }
+ unsetenv("QEMU_GDB");
+
+ memcpy(&wrapper[current], &argv[1], sizeof(*argv) * (argc - 1));
+ current += argc - 1;
+
+ wrapper[current] = NULL;
+
+ return execve("/usr/bin/qemu-" TARGET_ARCH, wrapper, envp);
+}
--
1.7.2.3
- [Qemu-devel] [RFC][PATCH 000/111] QEMU m68k core additions, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 001/111] linux-user: Signals processing is not thread-safe., Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 002/111] linux-user: add qemu-wrapper,
Bryce Lanham <=
- [Qemu-devel] [PATCH 003/111] linux-user: define default cpu model in configure instead of linux-user/main.c, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 004/111] linux-user: specify the cpu model during configure, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 006/111] linux-user: define new environment variables, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 007/111] linux-user: define a script to set binfmt using debian flavored tools, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 008/111] linux-user: define default cpu model in configure instead of linux-user/main.c, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 009/111] m68k: add tcg_gen_debug_insn_start(), Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 005/111] linux-user,m68k: display default cpu, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 010/111] m68k: define m680x0 CPUs and features, Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 011/111] m68k: add missing accessing modes for some instructions., Bryce Lanham, 2011/08/17
- [Qemu-devel] [PATCH 013/111] m68k: add Scc instruction with memory operand., Bryce Lanham, 2011/08/17