From: Jerone Young <jyoung5@us.ibm.com>
To: kvm@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org
Subject: [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes
Date: Wed, 25 Jun 2008 15:39:14 -0500 [thread overview]
Message-ID: <0818f751aba30d65eb39.1214426354@thinkpadL> (raw)
In-Reply-To: <patchbomb.1214426350@thinkpadL>
4 files changed, 124 insertions(+), 1 deletion(-)
user/config-powerpc.mak | 10 ++++++-
user/test/lib/powerpc/44x/map.c | 51 +++++++++++++++++++++++++++++++++++++
user/test/lib/powerpc/44x/tlbwe.S | 29 +++++++++++++++++++++
user/test/lib/powerpc/io.c | 35 +++++++++++++++++++++++++
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Jerone Young <jyoung5@.us.ibm.com>
diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -3,6 +3,14 @@
CFLAGS += -I $(KERNELDIR)/include
# for some reaons binutils hates tlbsx unless we say we're 405 :(
CFLAGS += -Wa,-mregnames,-m405
+
+cflatobjs += \
+ test/lib/powerpc/io.o \
+ test/lib/powerpc/44x/map.o \
+ test/lib/powerpc/44x/tlbwe.o
+
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding -I test/lib -I test/lib/powerpc/44x
%.bin: %.o
$(OBJCOPY) -O binary $^ $@
@@ -18,7 +26,7 @@
tests := $(addprefix test/powerpc/, $(testobjs))
-all: kvmtrace kvmctl $(tests)
+all: kvmtrace kvmctl $(libcflat) $(tests)
kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
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/lib/powerpc/44x/tlbwe.S b/user/test/lib/powerpc/44x/tlbwe.S
new file mode 100644
--- /dev/null
+++ b/user/test/lib/powerpc/44x/tlbwe.S
@@ -0,0 +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
+
+/* tlbwe(uint index, uint8_t tid, uint word0, uint word1, uint word2) */
+.global tlbwe
+tlbwe:
+ mtspr SPRN_MMUCR, r4
+ 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;
+}
next prev parent reply other threads:[~2008-06-25 20:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-25 20:39 [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Jerone Young
2008-06-25 20:39 ` [PATCH 1 of 4] Consilidate libcflat for x86 to single lib for all archs Jerone Young
2008-06-25 20:39 ` [PATCH 2 of 4] Add Makefile and test changes required for x86 to use libcflat Jerone Young
2008-06-25 20:39 ` [PATCH 3 of 4] Remove old x86 test libs, that are now appart of libcflat Jerone Young
2008-06-25 20:39 ` Jerone Young [this message]
2008-06-25 21:28 ` [PATCH 4 of 4] Add initial PowerPC libcflat files & make file changes Hollis Blanchard
2008-06-26 15:14 ` Jerone Young
2008-06-25 21:27 ` [PATCH 0 of 4] [kvm-userspace][test] consolidate test libs to libcflat Hollis Blanchard
2008-06-26 15:12 ` Jerone Young
2008-06-26 22:01 ` Hollis Blanchard
2008-06-29 9:10 ` Avi Kivity
2008-06-29 13:24 ` Avi Kivity
2008-07-01 7:33 ` Jerone Young
2008-07-05 9:28 ` Avi Kivity
2008-07-05 17:32 ` Jerone Young
2008-07-05 17:36 ` Avi Kivity
2008-07-05 17:59 ` Jerone Young
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=0818f751aba30d65eb39.1214426354@thinkpadL \
--to=jyoung5@us.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.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