All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-ppc-devel] [PATCH 0 of 6] Enhance PowerPC unit tests
@ 2008-01-15 22:43 ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

These patches create libcflat for PowerPC and allow testcases to communicate
with kvmctl via MMIO. They culminate in a C testcase that returns an error code
through kvmctl to the shell.

The x86 Makefiles looked hairy enough that I didn't want to mess with them, but
it should be fairly easy to convert x86 to use the new test/lib/ files.

16 files changed, 436 insertions(+), 130 deletions(-)
user/Makefile                     |   15 +++-----
user/config-powerpc.mak           |   65 +++++++++++++++++++++++++------------
user/config-x86-common.mak        |    6 ++-
user/iotable.c                    |   53 ++++++++++++++++++++++++++++++
user/iotable.h                    |   40 ++++++++++++++++++++++
user/main-ppc.c                   |   65 +++++++++++++++++++++++++++++++++----
user/main.c                       |   52 +----------------------------
user/test/lib/libcflat.h          |   37 +++++++++++++++++++++
user/test/lib/panic.c             |   13 +++++++
user/test/lib/powerpc/44x/map.c   |   51 +++++++++++++++++++++++++++++
user/test/lib/powerpc/44x/tlbwe.S |   50 ++++++++++++++--------------
user/test/lib/powerpc/io.c        |   35 +++++++++++++++++++
user/test/lib/printf.c            |   21 +----------
user/test/lib/string.c            |    2 -
user/test/powerpc/cstart.S        |   38 +++++++++++++++++++++
user/test/powerpc/exit.c          |   23 +++++++++++++

-------------------------------------------------------------------------
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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 0 of 6] Enhance PowerPC unit tests
@ 2008-01-15 22:43 ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

These patches create libcflat for PowerPC and allow testcases to communicate
with kvmctl via MMIO. They culminate in a C testcase that returns an error code
through kvmctl to the shell.

The x86 Makefiles looked hairy enough that I didn't want to mess with them, but
it should be fairly easy to convert x86 to use the new test/lib/ files.

16 files changed, 436 insertions(+), 130 deletions(-)
user/Makefile                     |   15 +++-----
user/config-powerpc.mak           |   65 +++++++++++++++++++++++++------------
user/config-x86-common.mak        |    6 ++-
user/iotable.c                    |   53 ++++++++++++++++++++++++++++++
user/iotable.h                    |   40 ++++++++++++++++++++++
user/main-ppc.c                   |   65 +++++++++++++++++++++++++++++++++----
user/main.c                       |   52 +----------------------------
user/test/lib/libcflat.h          |   37 +++++++++++++++++++++
user/test/lib/panic.c             |   13 +++++++
user/test/lib/powerpc/44x/map.c   |   51 +++++++++++++++++++++++++++++
user/test/lib/powerpc/44x/tlbwe.S |   50 ++++++++++++++--------------
user/test/lib/powerpc/io.c        |   35 +++++++++++++++++++
user/test/lib/printf.c            |   21 +----------
user/test/lib/string.c            |    2 -
user/test/powerpc/cstart.S        |   38 +++++++++++++++++++++
user/test/powerpc/exit.c          |   23 +++++++++++++

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [kvm-ppc-devel] [PATCH 1 of 6] Move IO handling code to a separate
  2008-01-15 22:43 ` Hollis Blanchard
@ 2008-01-15 22:43   ` Hollis Blanchard
  -1 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb@us.ibm.com>
# Date 1200436754 21600
# Node ID c6e8bf3f9f7c9705a0ad29f44fa148fe80a365ff
# Parent  f22e390c06b78ffbcec4738112309f66267e3582
This will allow other architectures to share it, since main.c is x86-only.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

---
5 files changed, 97 insertions(+), 52 deletions(-)
user/config-powerpc.mak    |    2 -
user/config-x86-common.mak |    2 -
user/iotable.c             |   53 ++++++++++++++++++++++++++++++++++++++++++++
user/iotable.h             |   40 +++++++++++++++++++++++++++++++++
user/main.c                |   52 +------------------------------------------


diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -20,7 +20,7 @@ tests := $(addprefix test/powerpc/, $(te
 
 all: kvmctl $(tests)
 
-kvmctl_objs = main-ppc.o ../libkvm/libkvm.a
+kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
 	rm -f $(tests)
diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
--- a/user/config-x86-common.mak
+++ b/user/config-x86-common.mak
@@ -2,7 +2,7 @@
 
 all: kvmctl test_cases
 
-kvmctl_objs= main.o ../libkvm/libkvm.a
+kvmctl_objs= main.o iotable.o ../libkvm/libkvm.a
 
 balloon_ctl: balloon_ctl.o
 
diff --git a/user/iotable.c b/user/iotable.c
new file mode 100644
--- /dev/null
+++ b/user/iotable.c
@@ -0,0 +1,53 @@
+/*
+ * Kernel-based Virtual Machine test driver
+ *
+ * This test driver provides a simple way of testing kvm, without a full
+ * device model.
+ *
+ * Copyright (C) 2006 Qumranet
+ *
+ * Authors:
+ *
+ *  Avi Kivity <avi@qumranet.com>
+ *  Yaniv Kamay <yaniv@qumranet.com>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <errno.h>
+
+#include "iotable.h"
+
+struct io_table_entry *io_table_lookup(struct io_table *io_table, uint64_t addr)
+{
+	int i;
+
+	for (i = 0; i < io_table->nr_entries; i++) {
+		if (io_table->entries[i].start <= addr &&
+		    addr < io_table->entries[i].end)
+			return &io_table->entries[i];
+	}
+
+	return NULL;
+}
+
+int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
+		      io_table_handler_t *handler, void *opaque)
+{
+	struct io_table_entry *entry;
+
+	if (io_table->nr_entries = MAX_IO_TABLE)
+		return -ENOSPC;
+
+	entry = &io_table->entries[io_table->nr_entries];
+	io_table->nr_entries++;
+
+	entry->start = start;
+	entry->end = start + size;
+	entry->handler = handler;
+	entry->opaque = opaque;
+
+	return 0;
+}
diff --git a/user/iotable.h b/user/iotable.h
new file mode 100644
--- /dev/null
+++ b/user/iotable.h
@@ -0,0 +1,40 @@
+/*
+ * Kernel-based Virtual Machine test driver
+ *
+ * This test driver provides a simple way of testing kvm, without a full
+ * device model.
+ *
+ * Copyright (C) 2006 Qumranet
+ *
+ * Authors:
+ *
+ *  Avi Kivity <avi@qumranet.com>
+ *  Yaniv Kamay <yaniv@qumranet.com>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#include <stdint.h>
+
+#define MAX_IO_TABLE	50
+
+typedef int (io_table_handler_t)(void *, int, int, uint64_t, uint64_t *);
+
+struct io_table_entry
+{
+	uint64_t start;
+	uint64_t end;
+	io_table_handler_t *handler;
+	void *opaque;
+};
+
+struct io_table
+{
+	int nr_entries;
+	struct io_table_entry entries[MAX_IO_TABLE];
+};
+
+struct io_table_entry *io_table_lookup(struct io_table *io_table,
+                                       uint64_t addr);
+int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
+                      io_table_handler_t *handler, void *opaque);
diff --git a/user/main.c b/user/main.c
--- a/user/main.c
+++ b/user/main.c
@@ -36,6 +36,8 @@
 #include <getopt.h>
 #include <stdbool.h>
 
+#include "iotable.h"
+
 static uint8_t ioram[IORAM_LEN];
 
 static int gettid(void)
@@ -53,24 +55,6 @@ kvm_context_t kvm;
 #define MAX_VCPUS 4
 
 #define IPI_SIGNAL (SIGRTMIN + 4)
-
-#define MAX_IO_TABLE	50
-
-typedef int (io_table_handler_t)(void *, int, int, uint64_t, uint64_t *);
-
-struct io_table_entry
-{
-	uint64_t start;
-	uint64_t end;
-	io_table_handler_t *handler;
-	void *opaque;
-};
-
-struct io_table
-{
-	int nr_entries;
-	struct io_table_entry entries[MAX_IO_TABLE];
-};
 
 static int ncpus = 1;
 static sem_t init_sem;
@@ -90,38 +74,6 @@ struct vcpu_info *vcpus;
 struct vcpu_info *vcpus;
 
 static uint32_t apic_sipi_addr;
-
-struct io_table_entry *io_table_lookup(struct io_table *io_table, uint64_t addr)
-{
-	int i;
-
-	for (i = 0; i < io_table->nr_entries; i++) {
-		if (io_table->entries[i].start <= addr &&
-		    addr < io_table->entries[i].end)
-			return &io_table->entries[i];
-	}
-
-	return NULL;
-}
-
-int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
-		      io_table_handler_t *handler, void *opaque)
-{
-	struct io_table_entry *entry;
-
-	if (io_table->nr_entries = MAX_IO_TABLE)
-		return -ENOSPC;
-
-	entry = &io_table->entries[io_table->nr_entries];
-	io_table->nr_entries++;
-
-	entry->start = start;
-	entry->end = start + size;
-	entry->handler = handler;
-	entry->opaque = opaque;
-
-	return 0;
-}
 
 static void apic_send_sipi(int vcpu)
 {

-------------------------------------------------------------------------
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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1 of 6] Move IO handling code to a separate file
@ 2008-01-15 22:43   ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1200436754 21600
# Node ID c6e8bf3f9f7c9705a0ad29f44fa148fe80a365ff
# Parent  f22e390c06b78ffbcec4738112309f66267e3582
This will allow other architectures to share it, since main.c is x86-only.

Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

---
5 files changed, 97 insertions(+), 52 deletions(-)
user/config-powerpc.mak    |    2 -
user/config-x86-common.mak |    2 -
user/iotable.c             |   53 ++++++++++++++++++++++++++++++++++++++++++++
user/iotable.h             |   40 +++++++++++++++++++++++++++++++++
user/main.c                |   52 +------------------------------------------


diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -20,7 +20,7 @@ tests := $(addprefix test/powerpc/, $(te
 
 all: kvmctl $(tests)
 
-kvmctl_objs = main-ppc.o ../libkvm/libkvm.a
+kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
 	rm -f $(tests)
diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
--- a/user/config-x86-common.mak
+++ b/user/config-x86-common.mak
@@ -2,7 +2,7 @@
 
 all: kvmctl test_cases
 
-kvmctl_objs= main.o ../libkvm/libkvm.a
+kvmctl_objs= main.o iotable.o ../libkvm/libkvm.a
 
 balloon_ctl: balloon_ctl.o
 
diff --git a/user/iotable.c b/user/iotable.c
new file mode 100644
--- /dev/null
+++ b/user/iotable.c
@@ -0,0 +1,53 @@
+/*
+ * Kernel-based Virtual Machine test driver
+ *
+ * This test driver provides a simple way of testing kvm, without a full
+ * device model.
+ *
+ * Copyright (C) 2006 Qumranet
+ *
+ * Authors:
+ *
+ *  Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *  Yaniv Kamay <yaniv-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <errno.h>
+
+#include "iotable.h"
+
+struct io_table_entry *io_table_lookup(struct io_table *io_table, uint64_t addr)
+{
+	int i;
+
+	for (i = 0; i < io_table->nr_entries; i++) {
+		if (io_table->entries[i].start <= addr &&
+		    addr < io_table->entries[i].end)
+			return &io_table->entries[i];
+	}
+
+	return NULL;
+}
+
+int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
+		      io_table_handler_t *handler, void *opaque)
+{
+	struct io_table_entry *entry;
+
+	if (io_table->nr_entries == MAX_IO_TABLE)
+		return -ENOSPC;
+
+	entry = &io_table->entries[io_table->nr_entries];
+	io_table->nr_entries++;
+
+	entry->start = start;
+	entry->end = start + size;
+	entry->handler = handler;
+	entry->opaque = opaque;
+
+	return 0;
+}
diff --git a/user/iotable.h b/user/iotable.h
new file mode 100644
--- /dev/null
+++ b/user/iotable.h
@@ -0,0 +1,40 @@
+/*
+ * Kernel-based Virtual Machine test driver
+ *
+ * This test driver provides a simple way of testing kvm, without a full
+ * device model.
+ *
+ * Copyright (C) 2006 Qumranet
+ *
+ * Authors:
+ *
+ *  Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *  Yaniv Kamay <yaniv-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
+#include <stdint.h>
+
+#define MAX_IO_TABLE	50
+
+typedef int (io_table_handler_t)(void *, int, int, uint64_t, uint64_t *);
+
+struct io_table_entry
+{
+	uint64_t start;
+	uint64_t end;
+	io_table_handler_t *handler;
+	void *opaque;
+};
+
+struct io_table
+{
+	int nr_entries;
+	struct io_table_entry entries[MAX_IO_TABLE];
+};
+
+struct io_table_entry *io_table_lookup(struct io_table *io_table,
+                                       uint64_t addr);
+int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
+                      io_table_handler_t *handler, void *opaque);
diff --git a/user/main.c b/user/main.c
--- a/user/main.c
+++ b/user/main.c
@@ -36,6 +36,8 @@
 #include <getopt.h>
 #include <stdbool.h>
 
+#include "iotable.h"
+
 static uint8_t ioram[IORAM_LEN];
 
 static int gettid(void)
@@ -53,24 +55,6 @@ kvm_context_t kvm;
 #define MAX_VCPUS 4
 
 #define IPI_SIGNAL (SIGRTMIN + 4)
-
-#define MAX_IO_TABLE	50
-
-typedef int (io_table_handler_t)(void *, int, int, uint64_t, uint64_t *);
-
-struct io_table_entry
-{
-	uint64_t start;
-	uint64_t end;
-	io_table_handler_t *handler;
-	void *opaque;
-};
-
-struct io_table
-{
-	int nr_entries;
-	struct io_table_entry entries[MAX_IO_TABLE];
-};
 
 static int ncpus = 1;
 static sem_t init_sem;
@@ -90,38 +74,6 @@ struct vcpu_info *vcpus;
 struct vcpu_info *vcpus;
 
 static uint32_t apic_sipi_addr;
-
-struct io_table_entry *io_table_lookup(struct io_table *io_table, uint64_t addr)
-{
-	int i;
-
-	for (i = 0; i < io_table->nr_entries; i++) {
-		if (io_table->entries[i].start <= addr &&
-		    addr < io_table->entries[i].end)
-			return &io_table->entries[i];
-	}
-
-	return NULL;
-}
-
-int io_table_register(struct io_table *io_table, uint64_t start, uint64_t size,
-		      io_table_handler_t *handler, void *opaque)
-{
-	struct io_table_entry *entry;
-
-	if (io_table->nr_entries == MAX_IO_TABLE)
-		return -ENOSPC;
-
-	entry = &io_table->entries[io_table->nr_entries];
-	io_table->nr_entries++;
-
-	entry->start = start;
-	entry->end = start + size;
-	entry->handler = handler;
-	entry->opaque = opaque;
-
-	return 0;
-}
 
 static void apic_send_sipi(int vcpu)
 {

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [kvm-ppc-devel] [PATCH 2 of 6] Register a debug MMIO handler,
  2008-01-15 22:43 ` Hollis Blanchard
@ 2008-01-15 22:43   ` Hollis Blanchard
  -1 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb@us.ibm.com>
# 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@us.ibm.com>

---
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, &regs);
+	*/
 
 	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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2 of 6] Register a debug MMIO handler, and implement putc() and exit() with it
@ 2008-01-15 22:43   ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# 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, &regs);
+	*/
 
 	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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [kvm-ppc-devel] [PATCH 3 of 6] Move FLATLIBS to
  2008-01-15 22:43 ` Hollis Blanchard
@ 2008-01-15 22:43   ` Hollis Blanchard
  -1 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb@us.ibm.com>
# Date 1200436754 21600
# Node ID 05365f8559d584fb1e935a9a64b5fa4f7e894d1f
# Parent  f058f7e0e9e2f47beb19114a4ee3c7c44ac03aa0
This allows other architectures to build test executables in other ways.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

---
2 files changed, 6 insertions(+), 7 deletions(-)
user/Makefile              |    9 ++-------
user/config-x86-common.mak |    4 ++++


diff --git a/user/Makefile b/user/Makefile
--- a/user/Makefile
+++ b/user/Makefile
@@ -7,6 +7,8 @@ DESTDIR : 
 #make sure env CFLAGS variable is not used
 CFLAGS +
+libgcc := $(shell gcc --print-libgcc-file-name)
 
 #include architecure specific make rules
 include config-$(ARCH).mak
@@ -29,17 +31,10 @@ CXXFLAGS = $(autodepend-flags)
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
 
-libgcc := $(shell gcc --print-libgcc-file-name)
-
-FLATLIBS = $(TEST_DIR)/libcflat.a $(libgcc)
-
 kvmctl: LDFLAGS += -pthread -lrt
 
 kvmctl: $(kvmctl_objs)
 	$(CC) $(LDFLAGS) $^ -o $@
-
-%.flat: %.o $(FLATLIBS)
-	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ $(FLATLIBS)
 
 %.o: %.S
 	$(CC) $(CFLAGS) -c -nostdlib -o $@ $^
diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
--- a/user/config-x86-common.mak
+++ b/user/config-x86-common.mak
@@ -5,6 +5,10 @@ kvmctl_objs= main.o iotable.o ../libkvm/
 kvmctl_objs= main.o iotable.o ../libkvm/libkvm.a
 
 balloon_ctl: balloon_ctl.o
+
+FLATLIBS = $(TEST_DIR)/libcflat.a $(libgcc)
+%.flat: %.o $(FLATLIBS)
+	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ $(FLATLIBS)
 
 tests-common = $(TEST_DIR)/bootstrap \
 			$(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \

-------------------------------------------------------------------------
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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3 of 6] Move FLATLIBS to config-x86-common.mak
@ 2008-01-15 22:43   ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1200436754 21600
# Node ID 05365f8559d584fb1e935a9a64b5fa4f7e894d1f
# Parent  f058f7e0e9e2f47beb19114a4ee3c7c44ac03aa0
This allows other architectures to build test executables in other ways.

Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

---
2 files changed, 6 insertions(+), 7 deletions(-)
user/Makefile              |    9 ++-------
user/config-x86-common.mak |    4 ++++


diff --git a/user/Makefile b/user/Makefile
--- a/user/Makefile
+++ b/user/Makefile
@@ -7,6 +7,8 @@ DESTDIR :=
 
 #make sure env CFLAGS variable is not used
 CFLAGS =
+
+libgcc := $(shell gcc --print-libgcc-file-name)
 
 #include architecure specific make rules
 include config-$(ARCH).mak
@@ -29,17 +31,10 @@ CXXFLAGS = $(autodepend-flags)
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
 
-libgcc := $(shell gcc --print-libgcc-file-name)
-
-FLATLIBS = $(TEST_DIR)/libcflat.a $(libgcc)
-
 kvmctl: LDFLAGS += -pthread -lrt
 
 kvmctl: $(kvmctl_objs)
 	$(CC) $(LDFLAGS) $^ -o $@
-
-%.flat: %.o $(FLATLIBS)
-	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ $(FLATLIBS)
 
 %.o: %.S
 	$(CC) $(CFLAGS) -c -nostdlib -o $@ $^
diff --git a/user/config-x86-common.mak b/user/config-x86-common.mak
--- a/user/config-x86-common.mak
+++ b/user/config-x86-common.mak
@@ -5,6 +5,10 @@ kvmctl_objs= main.o iotable.o ../libkvm/
 kvmctl_objs= main.o iotable.o ../libkvm/libkvm.a
 
 balloon_ctl: balloon_ctl.o
+
+FLATLIBS = $(TEST_DIR)/libcflat.a $(libgcc)
+%.flat: %.o $(FLATLIBS)
+	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ $(FLATLIBS)
 
 tests-common = $(TEST_DIR)/bootstrap \
 			$(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [kvm-ppc-devel] [PATCH 4 of 6] Use "$(CC)" instead of "gcc" to find
  2008-01-15 22:43 ` Hollis Blanchard
@ 2008-01-15 22:43   ` Hollis Blanchard
  -1 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb@us.ibm.com>
# Date 1200436754 21600
# Node ID 59aa1c2e71c23b6fe1fb072c81163807da817d5b
# Parent  05365f8559d584fb1e935a9a64b5fa4f7e894d1f
This allows for cross-compiling.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

---
1 file changed, 1 insertion(+), 1 deletion(-)
user/Makefile |    2 +-


diff --git a/user/Makefile b/user/Makefile
--- a/user/Makefile
+++ b/user/Makefile
@@ -8,7 +8,7 @@ DESTDIR : #make sure env CFLAGS variable is not used
 CFLAGS  
-libgcc := $(shell gcc --print-libgcc-file-name)
+libgcc := $(shell $(CC) --print-libgcc-file-name)
 
 #include architecure specific make rules
 include config-$(ARCH).mak

-------------------------------------------------------------------------
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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4 of 6] Use "$(CC)" instead of "gcc" to find libgcc
@ 2008-01-15 22:43   ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1200436754 21600
# Node ID 59aa1c2e71c23b6fe1fb072c81163807da817d5b
# Parent  05365f8559d584fb1e935a9a64b5fa4f7e894d1f
This allows for cross-compiling.

Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

---
1 file changed, 1 insertion(+), 1 deletion(-)
user/Makefile |    2 +-


diff --git a/user/Makefile b/user/Makefile
--- a/user/Makefile
+++ b/user/Makefile
@@ -8,7 +8,7 @@ DESTDIR :=
 #make sure env CFLAGS variable is not used
 CFLAGS =
 
-libgcc := $(shell gcc --print-libgcc-file-name)
+libgcc := $(shell $(CC) --print-libgcc-file-name)
 
 #include architecure specific make rules
 include config-$(ARCH).mak

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [kvm-ppc-devel] [PATCH 5 of 6] Create libcflat for PowerPC
  2008-01-15 22:43 ` Hollis Blanchard
@ 2008-01-15 22:43   ` Hollis Blanchard
  -1 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb@us.ibm.com>
# Date 1200436754 21600
# Node ID d4c0de7599e4a4ae107044aa4f4c95dc50f9ce6a
# Parent  59aa1c2e71c23b6fe1fb072c81163807da817d5b
This duplicates some test/x86/lib/ files into test/lib/ until someone ports x86
to use the common source. Architectures must provide their own exit() and
puts() implementations under test/lib/<arch>/.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

---
9 files changed, 182 insertions(+), 45 deletions(-)
user/Makefile                     |    4 ++
user/config-powerpc.mak           |   14 +++++++++-
user/test/lib/libcflat.h          |   37 ++++++++++++++++++++++++++
user/test/lib/panic.c             |   13 +++++++++
user/test/lib/powerpc/44x/map.c   |   51 +++++++++++++++++++++++++++++++++++++
user/test/lib/powerpc/44x/tlbwe.S |   50 ++++++++++++++++++------------------
user/test/lib/powerpc/io.c        |   35 +++++++++++++++++++++++++
user/test/lib/printf.c            |   21 +--------------
user/test/lib/string.c            |    2 -


diff --git a/user/Makefile b/user/Makefile
--- a/user/Makefile
+++ b/user/Makefile
@@ -9,6 +9,10 @@ CFLAGS  CFLAGS  
 libgcc := $(shell $(CC) --print-libgcc-file-name)
+cflatobjs := \
+	test/lib/panic.o \
+	test/lib/printf.o \
+	test/lib/string.o
 
 #include architecure specific make rules
 include config-$(ARCH).mak
diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -1,3 +1,10 @@ CFLAGS += -m32
+libcflat := test/lib/libcflat.a
+
+cflatobjs += \
+	test/lib/powerpc/io.o \
+	test/lib/powerpc/44x/map.o \
+	test/lib/powerpc/44x/tlbwe.o
+
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
@@ -20,7 +27,12 @@ tests := $(addprefix test/powerpc/, $(te
 
 all: kvmctl $(tests)
 
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding -I test/lib -I test/lib/powerpc/44x
+$(libcflat): $(cflatobjs)
+	ar rcs $@ $^
+
 kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
-	rm -f $(tests)
+	rm -f $(tests) $(cflatobjs)
diff --git a/user/test/lib/libcflat.h b/user/test/lib/libcflat.h
new file mode 100644
--- /dev/null
+++ b/user/test/lib/libcflat.h
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#ifndef __LIBCFLAT_H
+#define __LIBCFLAT_H
+
+#include <stdarg.h>
+
+extern int main(void);
+extern void exit(int code);
+extern void panic(char *fmt, ...);
+
+extern unsigned long strlen(const char *buf);
+extern char *strcat(char *dest, const char *src);
+
+extern int printf(const char *fmt, ...);
+extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
+
+extern void puts(const char *s);
+
+#endif
diff --git a/user/test/lib/panic.c b/user/test/lib/panic.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/panic.c
@@ -0,0 +1,13 @@
+#include "libcflat.h"
+
+void panic(char *fmt, ...)
+{
+	va_list va;
+	char buf[2000];
+
+	va_start(va, fmt);
+	vsnprintf(buf, sizeof(buf), fmt, va);
+	va_end(va);
+	puts(buf);
+	exit(-1);
+}
diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/map.c
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#include "libcflat.h"
+
+#define TLB_SIZE 64
+
+extern void tlbwe(unsigned int index,
+                  unsigned char tid,
+                  unsigned int word0,
+                  unsigned int word1,
+                  unsigned int word2);
+
+unsigned int next_free_index;
+
+#define PAGE_SHIFT 12
+#define PAGE_MASK (~((1<<PAGE_SHIFT)-1))
+
+#define V (1<<9)
+
+void map(unsigned long vaddr, unsigned long paddr)
+{
+	unsigned int w0, w1, w2;
+
+	/* We don't install exception handlers, so we can't handle TLB misses,
+	 * so we can't loop around and overwrite entry 0. */
+	if (next_free_index++ >= TLB_SIZE)
+		panic("TLB overflow");
+
+	w0 = (vaddr & PAGE_MASK) | V;
+	w1 = paddr & PAGE_MASK;
+	w2 = 0x3;
+
+	tlbwe(next_free_index, 0, w0, w1, w2);
+}
diff --git a/user/test/powerpc/44x/tlbwe.S b/user/test/lib/powerpc/44x/tlbwe.S
copy from user/test/powerpc/44x/tlbwe.S
copy to user/test/lib/powerpc/44x/tlbwe.S
--- a/user/test/lib/powerpc/44x/tlbwe.S
+++ b/user/test/lib/powerpc/44x/tlbwe.S
@@ -1,27 +1,29 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
 #define SPRN_MMUCR 0x3b2
 
-/* Create a mapping at 4MB */
-#define TLBWORD0 0x00400210
-#define TLBWORD1 0x00400000
-#define TLBWORD2 0x00000003
-
-.global _start
-_start:
-	li	r4, 0
+/* tlbwe(uint index, uint8_t tid, uint word0, uint word1, uint word2) */
+.global tlbwe
+tlbwe:
 	mtspr	SPRN_MMUCR, r4
-
-	li	r3, 23
-
-	lis	r4, TLBWORD0@h
-	ori	r4, r4, TLBWORD0@l
-	tlbwe	r4, r3, 0
-
-	lis	r4, TLBWORD1@h
-	ori	r4, r4, TLBWORD1@l
-	tlbwe	r4, r3, 1
-
-	lis	r4, TLBWORD2@h
-	ori	r4, r4, TLBWORD2@l
-	tlbwe	r4, r3, 2
-
-	b	.
+	tlbwe	r5, r3, 0
+	tlbwe	r6, r3, 1
+	tlbwe	r7, r3, 2
+	blr
diff --git a/user/test/lib/powerpc/io.c b/user/test/lib/powerpc/io.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/io.c
@@ -0,0 +1,35 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#include "libcflat.h"
+
+#define BASE 0xf0000000
+#define _putc ((volatile char *)(BASE))
+#define _exit ((volatile char *)(BASE+1))
+
+void puts(const char *s)
+{
+	while (*s != '\0')
+		*_putc = *s++;
+}
+
+void exit(int code)
+{
+	*_exit = code;
+}
diff --git a/user/test/x86/lib/printf.c b/user/test/lib/printf.c
copy from user/test/x86/lib/printf.c
copy to user/test/lib/printf.c
--- a/user/test/lib/printf.c
+++ b/user/test/lib/printf.c
@@ -1,11 +1,4 @@
-#include "printf.h"
-#include "smp.h"
-#include <stdarg.h>
-#include "string.h"
-
-static struct spinlock lock;
-
-void print(const char *s);
+#include "libcflat.h"
 
 typedef struct pstream {
     char *buffer;
@@ -92,7 +85,6 @@ void print_unsigned(pstream_t *ps, unsig
 
 int vsnprintf(char *buf, int size, const char *fmt, va_list va)
 {
-    int n;
     pstream_t s;
 
     s.buffer = buf;
@@ -173,13 +165,6 @@ int snprintf(char *buf, int size, const 
     return r;
 }
 
-void print_serial(const char *buf)
-{
-    unsigned long len = strlen(buf);
-
-    asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
-}
-
 int printf(const char *fmt, ...)
 {
     va_list va;
@@ -189,8 +174,6 @@ int printf(const char *fmt, ...)
     va_start(va, fmt);
     r = vsnprintf(buf, sizeof buf, fmt, va);
     va_end(va);
-    spin_lock(&lock);
-    print_serial(buf);
-    spin_unlock(&lock);
+    puts(buf);
     return r;
 }
diff --git a/user/test/x86/lib/string.c b/user/test/lib/string.c
copy from user/test/x86/lib/string.c
copy to user/test/lib/string.c
--- a/user/test/lib/string.c
+++ b/user/test/lib/string.c
@@ -1,4 +1,4 @@
-#include "string.h"
+#include "libcflat.h"
 
 unsigned long strlen(const char *buf)
 {

-------------------------------------------------------------------------
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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5 of 6] Create libcflat for PowerPC
@ 2008-01-15 22:43   ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1200436754 21600
# Node ID d4c0de7599e4a4ae107044aa4f4c95dc50f9ce6a
# Parent  59aa1c2e71c23b6fe1fb072c81163807da817d5b
This duplicates some test/x86/lib/ files into test/lib/ until someone ports x86
to use the common source. Architectures must provide their own exit() and
puts() implementations under test/lib/<arch>/.

Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

---
9 files changed, 182 insertions(+), 45 deletions(-)
user/Makefile                     |    4 ++
user/config-powerpc.mak           |   14 +++++++++-
user/test/lib/libcflat.h          |   37 ++++++++++++++++++++++++++
user/test/lib/panic.c             |   13 +++++++++
user/test/lib/powerpc/44x/map.c   |   51 +++++++++++++++++++++++++++++++++++++
user/test/lib/powerpc/44x/tlbwe.S |   50 ++++++++++++++++++------------------
user/test/lib/powerpc/io.c        |   35 +++++++++++++++++++++++++
user/test/lib/printf.c            |   21 +--------------
user/test/lib/string.c            |    2 -


diff --git a/user/Makefile b/user/Makefile
--- a/user/Makefile
+++ b/user/Makefile
@@ -9,6 +9,10 @@ CFLAGS =
 CFLAGS =
 
 libgcc := $(shell $(CC) --print-libgcc-file-name)
+cflatobjs := \
+	test/lib/panic.o \
+	test/lib/printf.o \
+	test/lib/string.o
 
 #include architecure specific make rules
 include config-$(ARCH).mak
diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -1,3 +1,10 @@ CFLAGS += -m32
+libcflat := test/lib/libcflat.a
+
+cflatobjs += \
+	test/lib/powerpc/io.o \
+	test/lib/powerpc/44x/map.o \
+	test/lib/powerpc/44x/tlbwe.o
+
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
@@ -20,7 +27,12 @@ tests := $(addprefix test/powerpc/, $(te
 
 all: kvmctl $(tests)
 
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding -I test/lib -I test/lib/powerpc/44x
+$(libcflat): $(cflatobjs)
+	ar rcs $@ $^
+
 kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
-	rm -f $(tests)
+	rm -f $(tests) $(cflatobjs)
diff --git a/user/test/lib/libcflat.h b/user/test/lib/libcflat.h
new file mode 100644
--- /dev/null
+++ b/user/test/lib/libcflat.h
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ */
+
+#ifndef __LIBCFLAT_H
+#define __LIBCFLAT_H
+
+#include <stdarg.h>
+
+extern int main(void);
+extern void exit(int code);
+extern void panic(char *fmt, ...);
+
+extern unsigned long strlen(const char *buf);
+extern char *strcat(char *dest, const char *src);
+
+extern int printf(const char *fmt, ...);
+extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
+
+extern void puts(const char *s);
+
+#endif
diff --git a/user/test/lib/panic.c b/user/test/lib/panic.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/panic.c
@@ -0,0 +1,13 @@
+#include "libcflat.h"
+
+void panic(char *fmt, ...)
+{
+	va_list va;
+	char buf[2000];
+
+	va_start(va, fmt);
+	vsnprintf(buf, sizeof(buf), fmt, va);
+	va_end(va);
+	puts(buf);
+	exit(-1);
+}
diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/map.c
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ */
+
+#include "libcflat.h"
+
+#define TLB_SIZE 64
+
+extern void tlbwe(unsigned int index,
+                  unsigned char tid,
+                  unsigned int word0,
+                  unsigned int word1,
+                  unsigned int word2);
+
+unsigned int next_free_index;
+
+#define PAGE_SHIFT 12
+#define PAGE_MASK (~((1<<PAGE_SHIFT)-1))
+
+#define V (1<<9)
+
+void map(unsigned long vaddr, unsigned long paddr)
+{
+	unsigned int w0, w1, w2;
+
+	/* We don't install exception handlers, so we can't handle TLB misses,
+	 * so we can't loop around and overwrite entry 0. */
+	if (next_free_index++ >= TLB_SIZE)
+		panic("TLB overflow");
+
+	w0 = (vaddr & PAGE_MASK) | V;
+	w1 = paddr & PAGE_MASK;
+	w2 = 0x3;
+
+	tlbwe(next_free_index, 0, w0, w1, w2);
+}
diff --git a/user/test/powerpc/44x/tlbwe.S b/user/test/lib/powerpc/44x/tlbwe.S
copy from user/test/powerpc/44x/tlbwe.S
copy to user/test/lib/powerpc/44x/tlbwe.S
--- a/user/test/lib/powerpc/44x/tlbwe.S
+++ b/user/test/lib/powerpc/44x/tlbwe.S
@@ -1,27 +1,29 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ */
+
 #define SPRN_MMUCR 0x3b2
 
-/* Create a mapping at 4MB */
-#define TLBWORD0 0x00400210
-#define TLBWORD1 0x00400000
-#define TLBWORD2 0x00000003
-
-.global _start
-_start:
-	li	r4, 0
+/* tlbwe(uint index, uint8_t tid, uint word0, uint word1, uint word2) */
+.global tlbwe
+tlbwe:
 	mtspr	SPRN_MMUCR, r4
-
-	li	r3, 23
-
-	lis	r4, TLBWORD0@h
-	ori	r4, r4, TLBWORD0@l
-	tlbwe	r4, r3, 0
-
-	lis	r4, TLBWORD1@h
-	ori	r4, r4, TLBWORD1@l
-	tlbwe	r4, r3, 1
-
-	lis	r4, TLBWORD2@h
-	ori	r4, r4, TLBWORD2@l
-	tlbwe	r4, r3, 2
-
-	b	.
+	tlbwe	r5, r3, 0
+	tlbwe	r6, r3, 1
+	tlbwe	r7, r3, 2
+	blr
diff --git a/user/test/lib/powerpc/io.c b/user/test/lib/powerpc/io.c
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/io.c
@@ -0,0 +1,35 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ */
+
+#include "libcflat.h"
+
+#define BASE 0xf0000000
+#define _putc ((volatile char *)(BASE))
+#define _exit ((volatile char *)(BASE+1))
+
+void puts(const char *s)
+{
+	while (*s != '\0')
+		*_putc = *s++;
+}
+
+void exit(int code)
+{
+	*_exit = code;
+}
diff --git a/user/test/x86/lib/printf.c b/user/test/lib/printf.c
copy from user/test/x86/lib/printf.c
copy to user/test/lib/printf.c
--- a/user/test/lib/printf.c
+++ b/user/test/lib/printf.c
@@ -1,11 +1,4 @@
-#include "printf.h"
-#include "smp.h"
-#include <stdarg.h>
-#include "string.h"
-
-static struct spinlock lock;
-
-void print(const char *s);
+#include "libcflat.h"
 
 typedef struct pstream {
     char *buffer;
@@ -92,7 +85,6 @@ void print_unsigned(pstream_t *ps, unsig
 
 int vsnprintf(char *buf, int size, const char *fmt, va_list va)
 {
-    int n;
     pstream_t s;
 
     s.buffer = buf;
@@ -173,13 +165,6 @@ int snprintf(char *buf, int size, const 
     return r;
 }
 
-void print_serial(const char *buf)
-{
-    unsigned long len = strlen(buf);
-
-    asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
-}
-
 int printf(const char *fmt, ...)
 {
     va_list va;
@@ -189,8 +174,6 @@ int printf(const char *fmt, ...)
     va_start(va, fmt);
     r = vsnprintf(buf, sizeof buf, fmt, va);
     va_end(va);
-    spin_lock(&lock);
-    print_serial(buf);
-    spin_unlock(&lock);
+    puts(buf);
     return r;
 }
diff --git a/user/test/x86/lib/string.c b/user/test/lib/string.c
copy from user/test/x86/lib/string.c
copy to user/test/lib/string.c
--- a/user/test/lib/string.c
+++ b/user/test/lib/string.c
@@ -1,4 +1,4 @@
-#include "string.h"
+#include "libcflat.h"
 
 unsigned long strlen(const char *buf)
 {

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [kvm-ppc-devel] [PATCH 6 of 6] Reorganize PowerPC makefiles and add
  2008-01-15 22:43 ` Hollis Blanchard
@ 2008-01-15 22:43   ` Hollis Blanchard
  -1 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb@us.ibm.com>
# Date 1200437012 21600
# Node ID 75481de4f07eab17035fb24f14417be2ee62ac10
# Parent  d4c0de7599e4a4ae107044aa4f4c95dc50f9ce6a

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

---
3 files changed, 92 insertions(+), 18 deletions(-)
user/config-powerpc.mak    |   49 +++++++++++++++++++++++++++-----------------
user/test/powerpc/cstart.S |   38 ++++++++++++++++++++++++++++++++++
user/test/powerpc/exit.c   |   23 ++++++++++++++++++++


diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -1,3 +1,4 @@ libcflat := test/lib/libcflat.a
+cstart := test/powerpc/cstart.o
 libcflat := test/lib/libcflat.a
 
 cflatobjs += \
@@ -5,27 +6,37 @@ cflatobjs += \
 	test/lib/powerpc/44x/map.o \
 	test/lib/powerpc/44x/tlbwe.o
 
+# these tests do not use libcflat
+simpletests := \
+	test/powerpc/spin.bin \
+	test/powerpc/io.bin \
+	test/powerpc/sprg.bin \
+	test/powerpc/44x/tlbsx.bin \
+	test/powerpc/44x/tlbwe_16KB.bin \
+	test/powerpc/44x/tlbwe_hole.bin \
+	test/powerpc/44x/tlbwe.bin
+
+# these tests use cstart.o, libcflat, and libgcc
+tests := \
+	test/powerpc/exit.bin
+
+all: kvmctl $(tests) $(simpletests)
+
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
+CFLAGS += -Wa,-mregnames
+
+$(simpletests): %.bin: %.o
+	$(CC) $(LDFLAGS) -nostdlib $^ -o $*.elf
+	$(OBJCOPY) -O binary $*.elf $@
+
+$(tests): %.bin: $(cstart) %.o $(libcflat)
+	$(CC) $(LDFLAGS) -nostdlib -Wl,-Ttext,0 $^ $(libgcc) -o $*.elf
+	$(OBJCOPY) -O binary $*.elf $@
+
 # for some reaons binutils hates tlbsx unless we say we're 405  :(
-CFLAGS += -Wa,-mregnames,-m405
-
-%.bin: %.o
-	$(OBJCOPY) -O binary $^ $@
-
-testobjs := \
-	io.bin \
-	spin.bin \
-	sprg.bin \
-	44x/tlbsx.bin \
-	44x/tlbwe_16KB.bin \
-	44x/tlbwe_hole.bin \
-	44x/tlbwe.bin
-
-tests := $(addprefix test/powerpc/, $(testobjs))
-
-all: kvmctl $(tests)
+test/powerpc/44x/tlbsx.bin: CFLAGS += -Wa,-m405
 
 $(libcflat): LDFLAGS += -nostdlib
 $(libcflat): CFLAGS += -ffreestanding -I test/lib -I test/lib/powerpc/44x
@@ -35,4 +46,6 @@ kvmctl_objs = main-ppc.o iotable.o ../li
 kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
-	rm -f $(tests) $(cflatobjs)
+	$(RM) $(simpletests) $(tests) $(cflatobjs) $(libcflat) $(cstart)
+	$(RM) $(patsubst %.bin, %.elf, $(simpletests) $(tests))
+	$(RM) $(patsubst %.bin, %.o, $(simpletests) $(tests))
diff --git a/user/test/powerpc/cstart.S b/user/test/powerpc/cstart.S
new file mode 100644
--- /dev/null
+++ b/user/test/powerpc/cstart.S
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation;
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#define OUTPUT_VADDR 0xf0000000
+#define OUTPUT_PADDR 0xf0000000
+
+.globl _start
+_start:
+	/* In the future we might need to assign a stack and zero BSS here. */
+
+	/* Map the debug page 1:1. */
+	lis	r3, OUTPUT_VADDR@h
+	ori	r3, r3, OUTPUT_VADDR@l
+	lis	r4, OUTPUT_PADDR@h
+	ori	r4, r4, OUTPUT_PADDR@l
+	bl	map
+
+	/* Call main() and pass return code to exit(). */
+	bl	main
+	bl	exit
+
+	b	.
diff --git a/user/test/powerpc/exit.c b/user/test/powerpc/exit.c
new file mode 100644
--- /dev/null
+++ b/user/test/powerpc/exit.c
@@ -0,0 +1,23 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation;
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+int main(void)
+{
+	return 1;
+}

-------------------------------------------------------------------------
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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 6 of 6] Reorganize PowerPC makefiles and add an "exit" test that uses libcflat
@ 2008-01-15 22:43   ` Hollis Blanchard
  0 siblings, 0 replies; 16+ messages in thread
From: Hollis Blanchard @ 2008-01-15 22:43 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

# HG changeset patch
# User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1200437012 21600
# Node ID 75481de4f07eab17035fb24f14417be2ee62ac10
# Parent  d4c0de7599e4a4ae107044aa4f4c95dc50f9ce6a

Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

---
3 files changed, 92 insertions(+), 18 deletions(-)
user/config-powerpc.mak    |   49 +++++++++++++++++++++++++++-----------------
user/test/powerpc/cstart.S |   38 ++++++++++++++++++++++++++++++++++
user/test/powerpc/exit.c   |   23 ++++++++++++++++++++


diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -1,3 +1,4 @@ libcflat := test/lib/libcflat.a
+cstart := test/powerpc/cstart.o
 libcflat := test/lib/libcflat.a
 
 cflatobjs += \
@@ -5,27 +6,37 @@ cflatobjs += \
 	test/lib/powerpc/44x/map.o \
 	test/lib/powerpc/44x/tlbwe.o
 
+# these tests do not use libcflat
+simpletests := \
+	test/powerpc/spin.bin \
+	test/powerpc/io.bin \
+	test/powerpc/sprg.bin \
+	test/powerpc/44x/tlbsx.bin \
+	test/powerpc/44x/tlbwe_16KB.bin \
+	test/powerpc/44x/tlbwe_hole.bin \
+	test/powerpc/44x/tlbwe.bin
+
+# these tests use cstart.o, libcflat, and libgcc
+tests := \
+	test/powerpc/exit.bin
+
+all: kvmctl $(tests) $(simpletests)
+
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
+CFLAGS += -Wa,-mregnames
+
+$(simpletests): %.bin: %.o
+	$(CC) $(LDFLAGS) -nostdlib $^ -o $*.elf
+	$(OBJCOPY) -O binary $*.elf $@
+
+$(tests): %.bin: $(cstart) %.o $(libcflat)
+	$(CC) $(LDFLAGS) -nostdlib -Wl,-Ttext,0 $^ $(libgcc) -o $*.elf
+	$(OBJCOPY) -O binary $*.elf $@
+
 # for some reaons binutils hates tlbsx unless we say we're 405  :(
-CFLAGS += -Wa,-mregnames,-m405
-
-%.bin: %.o
-	$(OBJCOPY) -O binary $^ $@
-
-testobjs := \
-	io.bin \
-	spin.bin \
-	sprg.bin \
-	44x/tlbsx.bin \
-	44x/tlbwe_16KB.bin \
-	44x/tlbwe_hole.bin \
-	44x/tlbwe.bin
-
-tests := $(addprefix test/powerpc/, $(testobjs))
-
-all: kvmctl $(tests)
+test/powerpc/44x/tlbsx.bin: CFLAGS += -Wa,-m405
 
 $(libcflat): LDFLAGS += -nostdlib
 $(libcflat): CFLAGS += -ffreestanding -I test/lib -I test/lib/powerpc/44x
@@ -35,4 +46,6 @@ kvmctl_objs = main-ppc.o iotable.o ../li
 kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
-	rm -f $(tests) $(cflatobjs)
+	$(RM) $(simpletests) $(tests) $(cflatobjs) $(libcflat) $(cstart)
+	$(RM) $(patsubst %.bin, %.elf, $(simpletests) $(tests))
+	$(RM) $(patsubst %.bin, %.o, $(simpletests) $(tests))
diff --git a/user/test/powerpc/cstart.S b/user/test/powerpc/cstart.S
new file mode 100644
--- /dev/null
+++ b/user/test/powerpc/cstart.S
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation;
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ */
+
+#define OUTPUT_VADDR 0xf0000000
+#define OUTPUT_PADDR 0xf0000000
+
+.globl _start
+_start:
+	/* In the future we might need to assign a stack and zero BSS here. */
+
+	/* Map the debug page 1:1. */
+	lis	r3, OUTPUT_VADDR@h
+	ori	r3, r3, OUTPUT_VADDR@l
+	lis	r4, OUTPUT_PADDR@h
+	ori	r4, r4, OUTPUT_PADDR@l
+	bl	map
+
+	/* Call main() and pass return code to exit(). */
+	bl	main
+	bl	exit
+
+	b	.
diff --git a/user/test/powerpc/exit.c b/user/test/powerpc/exit.c
new file mode 100644
--- /dev/null
+++ b/user/test/powerpc/exit.c
@@ -0,0 +1,23 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation;
+ *
+ * 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, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ */
+
+int main(void)
+{
+	return 1;
+}

-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-ppc-devel] [kvm-devel] [PATCH 1 of 6] Move IO handling
  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
  -1 siblings, 0 replies; 16+ messages in thread
From: Avi Kivity @ 2008-01-16  8:16 UTC (permalink / raw)
  To: Hollis Blanchard
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hollis Blanchard wrote:
> # HG changeset patch
> # User Hollis Blanchard <hollisb@us.ibm.com>
> # Date 1200436754 21600
> # Node ID c6e8bf3f9f7c9705a0ad29f44fa148fe80a365ff
> # Parent  f22e390c06b78ffbcec4738112309f66267e3582
> This will allow other architectures to share it, since main.c is x86-only.
>
>   

Applied patches 1-4.  Can we not avoid the duplication in 5?

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
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/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1 of 6] Move IO handling code to a separate file
@ 2008-01-16  8:16     ` Avi Kivity
  0 siblings, 0 replies; 16+ messages in thread
From: Avi Kivity @ 2008-01-16  8:16 UTC (permalink / raw)
  To: Hollis Blanchard
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hollis Blanchard wrote:
> # HG changeset patch
> # User Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> # Date 1200436754 21600
> # Node ID c6e8bf3f9f7c9705a0ad29f44fa148fe80a365ff
> # Parent  f22e390c06b78ffbcec4738112309f66267e3582
> This will allow other architectures to share it, since main.c is x86-only.
>
>   

Applied patches 1-4.  Can we not avoid the duplication in 5?

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-01-16  8:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-15 22:43 [kvm-ppc-devel] [PATCH 0 of 6] Enhance PowerPC unit tests Hollis Blanchard
2008-01-15 22:43 ` Hollis Blanchard
2008-01-15 22:43 ` [kvm-ppc-devel] [PATCH 1 of 6] Move IO handling code to a separate 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   ` [kvm-ppc-devel] [kvm-devel] [PATCH 1 of 6] Move IO handling Avi Kivity
2008-01-16  8:16     ` [PATCH 1 of 6] Move IO handling code to a separate file Avi Kivity
2008-01-15 22:43 ` [kvm-ppc-devel] [PATCH 2 of 6] Register a debug MMIO handler, Hollis Blanchard
2008-01-15 22:43   ` [PATCH 2 of 6] Register a debug MMIO handler, and implement putc() and exit() with it Hollis Blanchard
2008-01-15 22:43 ` [kvm-ppc-devel] [PATCH 3 of 6] Move FLATLIBS to Hollis Blanchard
2008-01-15 22:43   ` [PATCH 3 of 6] Move FLATLIBS to config-x86-common.mak Hollis Blanchard
2008-01-15 22:43 ` [kvm-ppc-devel] [PATCH 4 of 6] Use "$(CC)" instead of "gcc" to find 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 ` [kvm-ppc-devel] [PATCH 5 of 6] Create libcflat for PowerPC Hollis Blanchard
2008-01-15 22:43   ` Hollis Blanchard
2008-01-15 22:43 ` [kvm-ppc-devel] [PATCH 6 of 6] Reorganize PowerPC makefiles and add Hollis Blanchard
2008-01-15 22:43   ` [PATCH 6 of 6] Reorganize PowerPC makefiles and add an "exit" test that uses libcflat Hollis Blanchard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.