[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 6/6] backdoor: add a simple example
From: |
Lluís |
Subject: |
[Qemu-devel] [PATCH v1 6/6] backdoor: add a simple example |
Date: |
Wed, 03 Nov 2010 20:49:35 +0100 |
User-agent: |
StGit/0.15 |
Provides a guest application that exercices the instruction-based backdoor
communication, as well as a backdoor callback implementation that prints the
guest requests.
Signed-off-by: Lluís Vilanova <address@hidden>
---
.gitignore | 1 +
backdoor/examples/print/README | 13 ++++++++++++
backdoor/examples/print/guest/Makefile | 7 ++++++
backdoor/examples/print/guest/test.c | 33 +++++++++++++++++++++++++++++
backdoor/examples/print/host/Makefile | 13 ++++++++++++
backdoor/examples/print/host/printcb.c | 36 ++++++++++++++++++++++++++++++++
6 files changed, 103 insertions(+), 0 deletions(-)
create mode 100644 backdoor/examples/print/README
create mode 100644 backdoor/examples/print/guest/Makefile
create mode 100644 backdoor/examples/print/guest/test.c
create mode 100644 backdoor/examples/print/host/Makefile
create mode 100644 backdoor/examples/print/host/printcb.c
diff --git a/.gitignore b/.gitignore
index a43e4d1..e4a351d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,3 +58,4 @@ pc-bios/optionrom/multiboot.bin
pc-bios/optionrom/multiboot.raw
.stgit-*
cscope.*
+backdoor/examples/print/guest/test
diff --git a/backdoor/examples/print/README b/backdoor/examples/print/README
new file mode 100644
index 0000000..0675f16
--- /dev/null
+++ b/backdoor/examples/print/README
@@ -0,0 +1,13 @@
+This example simply defines instruction-based backdoors to print their
+arguments, along with a guest example code that makes use of backdoor
+instructions.
+
+To compile the host (quemu) run:
+ /path/to/qemu/configure
--with-backdoor=/path/to/qemu/backdoor/examples/print/host/
+ make
+
+To compile the guest program run:
+ make -C /path/to/qemu/backdoor/examples/print/guest/
+
+Now you can run it with:
+ /path/to/qemu/i386-linux-user/qemu-i386
/path/to/qemu/backdoor/examples/print/guest/test
diff --git a/backdoor/examples/print/guest/Makefile
b/backdoor/examples/print/guest/Makefile
new file mode 100644
index 0000000..ea266f2
--- /dev/null
+++ b/backdoor/examples/print/guest/Makefile
@@ -0,0 +1,7 @@
+CFLAGS += -I../../../../
+PROGS = test
+
+all: $(PROGS)
+
+clean:
+ rm -f $(PROGS)
diff --git a/backdoor/examples/print/guest/test.c
b/backdoor/examples/print/guest/test.c
new file mode 100644
index 0000000..aeae948
--- /dev/null
+++ b/backdoor/examples/print/guest/test.c
@@ -0,0 +1,33 @@
+/*
+ * Sample guest program exercising instruction-based backdoor communication.
+ *
+ * Copyright (c) 2010 Lluís Vilanova <address@hidden>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+
+#include "backdoor/guest.h"
+
+int main ()
+{
+ int i = 23;
+ printf("i8 1\n");
+ BACKDOOR_i8(0x01);
+ printf("i8_v32 1 32\n");
+ BACKDOOR_i8_v32(0x01, 32);
+ printf("i8_v32 2 i (%d)\n", i);
+ BACKDOOR_i8_v32(0x02, i);
+}
diff --git a/backdoor/examples/print/host/Makefile
b/backdoor/examples/print/host/Makefile
new file mode 100644
index 0000000..bfd6311
--- /dev/null
+++ b/backdoor/examples/print/host/Makefile
@@ -0,0 +1,13 @@
+# Makefile for user-provided backdoor code
+
+include $(SRC_PATH)/config-host.mak
+include $(SRC_PATH)/rules.mak
+include $(SRC_PATH)/Makefile.objs
+
+objs = printcb.o
+
+libbackdoor.a: $(objs)
+ $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR
$(TARGET_DIR)$@")
+
+clean:
+ rm -f libbackdoor.a $(objs)
diff --git a/backdoor/examples/print/host/printcb.c
b/backdoor/examples/print/host/printcb.c
new file mode 100644
index 0000000..60499c9
--- /dev/null
+++ b/backdoor/examples/print/host/printcb.c
@@ -0,0 +1,36 @@
+/*
+ * Sample user-defined callbacks for backdoor communication.
+ *
+ * Copyright (c) 2010 Lluís Vilanova <address@hidden>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+
+#include "cpu.h"
+#include "helper.h"
+
+
+void
+helper_backdoor_i8 (uint32_t imm)
+{
+ printf("backdoor_i8: %u\n", imm);
+}
+
+void
+helper_backdoor_i8_v32 (uint32_t imm, uint32_t value)
+{
+ printf("backdoor_i8_v32: %u %d\n", imm, value);
+}
- [Qemu-devel] [RFC][PATCH v1 0/6] backdoor: instruction-based guest-to-QEMU backdoor communication channel, Lluís, 2010/11/03
- [Qemu-devel] [PATCH v1 1/6] [arm m68k] move helpers.h to helper.h, Lluís, 2010/11/03
- [Qemu-devel] [PATCH v1 2/6] backdoor: handle config-time activation, Lluís, 2010/11/03
- [Qemu-devel] [PATCH v1 3/6] backdoor: declare host-side backdoor helpers, Lluís, 2010/11/03
- [Qemu-devel] [PATCH v1 4/6] backdoor: declare guest-side interface macros, Lluís, 2010/11/03
- [Qemu-devel] [PATCH v1 5/6] backdoor: [i386] provide and implement intruction-based backdoor interface, Lluís, 2010/11/03
- [Qemu-devel] [PATCH v1 6/6] backdoor: add a simple example,
Lluís <=