From: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH 2 of 6] Register a debug MMIO handler, and implement putc() and exit() with it
Date: Tue, 15 Jan 2008 16:43:40 -0600 [thread overview]
Message-ID: <f058f7e0e9e2f47beb19.1200437020@basalt> (raw)
In-Reply-To: <patchbomb.1200437018@basalt>
# HG changeset patch
# User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1200436754 21600
# Node ID f058f7e0e9e2f47beb19114a4ee3c7c44ac03aa0
# Parent c6e8bf3f9f7c9705a0ad29f44fa148fe80a365ff
The return code from exit() will propagate all the way out to shell, which will
enable some automated testing.
Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
1 file changed, 58 insertions(+), 7 deletions(-)
user/main-ppc.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++------
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -37,6 +37,8 @@
#include <stdbool.h>
#include <inttypes.h>
+#include "iotable.h"
+
static int gettid(void)
{
return syscall(__NR_gettid);
@@ -45,6 +47,8 @@ kvm_context_t kvm;
kvm_context_t kvm;
#define IPI_SIGNAL (SIGRTMIN + 4)
+
+struct io_table mmio_table;
static int ncpus = 1;
static sem_t init_sem;
@@ -92,18 +96,63 @@ static int test_pre_kvm_run(void *opaque
return 0;
}
+static int mmio_handler(void *opaque, int len, int is_write, uint64_t offset,
+ uint64_t *data)
+{
+ int r = 0;
+
+ switch (offset) {
+ case 0: /* putc */
+ putc(*(char *)data, stdout);
+ fflush(stdout);
+ break;
+ case 1: /* exit */
+ r = *(char *)data;
+ break;
+ default:
+ printf("%s: offset %"PRIx64" len %d data %"PRIx64"\n",
+ __func__, offset, len, *(uint64_t *)data);
+ r = -EINVAL;
+ }
+
+ return r;
+}
+
static int test_mem_read(void *opaque, uint64_t addr, uint8_t *data, int len)
{
+ struct io_table_entry *iodev;
+
+#if 0
printf("%s: addr %"PRIx64" len %d\n", __func__, addr, len);
- memset(data, 0, len);
- return 0;
+#endif
+
+ iodev = io_table_lookup(&mmio_table, addr);
+ if (!iodev) {
+ printf("couldn't find device\n");
+ return -ENODEV;
+ }
+
+ return iodev->handler(iodev->opaque, len, 0, addr - iodev->start,
+ (uint64_t *)data);
}
static int test_mem_write(void *opaque, uint64_t addr, uint8_t *data, int len)
{
+ struct io_table_entry *iodev;
+
+#if 0
printf("%s: addr %"PRIx64" len %d data %"PRIx64"\n",
__func__, addr, len, *(uint64_t *)data);
- return 0;
+#endif
+
+ iodev = io_table_lookup(&mmio_table, addr);
+ if (!iodev) {
+ printf("couldn't find device\n");
+ return -ENODEV;
+ }
+
+ return iodev->handler(iodev->opaque, len, 1, addr - iodev->start,
+ (uint64_t *)data);
}
static int test_dcr_read(uint32_t dcrn, uint32_t *data)
@@ -173,11 +222,13 @@ void sync_caches(void *mem, unsigned lon
static void init_vcpu(int n, unsigned long entry)
{
+ /* XXX must set initial TLB state and stack
struct kvm_regs regs = {
.pc = entry,
};
kvm_set_regs(kvm, 0, ®s);
+ */
sigemptyset(&ipi_sigmask);
sigaddset(&ipi_sigmask, IPI_SIGNAL);
@@ -324,7 +375,7 @@ int main(int argc, char **argv)
for (i = 0; i < ncpus; ++i)
sem_wait(&init_sem);
- kvm_run(kvm, 0);
-
- return 0;
-}
+ io_table_register(&mmio_table, 0xf0000000, 64, mmio_handler, NULL);
+
+ return kvm_run(kvm, 0);
+}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2008-01-15 22:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-15 22:43 [PATCH 0 of 6] Enhance PowerPC unit tests Hollis Blanchard
2008-01-15 22:43 ` [PATCH 1 of 6] Move IO handling code to a separate file Hollis Blanchard
2008-01-16 8:16 ` Avi Kivity
2008-01-15 22:43 ` Hollis Blanchard [this message]
2008-01-15 22:43 ` [PATCH 3 of 6] Move FLATLIBS to config-x86-common.mak Hollis Blanchard
2008-01-15 22:43 ` [PATCH 4 of 6] Use "$(CC)" instead of "gcc" to find libgcc Hollis Blanchard
2008-01-15 22:43 ` [PATCH 5 of 6] Create libcflat for PowerPC Hollis Blanchard
2008-01-15 22:43 ` [PATCH 6 of 6] Reorganize PowerPC makefiles and add an "exit" test that uses libcflat Hollis Blanchard
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=f058f7e0e9e2f47beb19.1200437020@basalt \
--to=hollisb-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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