From: Hollis Blanchard <[EMAIL PROTECTED]>

- Create a 44x-specific makefile.
- Reorganize PowerPC makefiles to separate "simple" tests from those which
  link with libcflat.
- Create a minimal libcflat testcase (which just exits).

Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 config-powerpc-44x.mak       |   14 +++++++++++
 config-powerpc.mak           |   46 ++++++++++++++++++++++++++------------
 test/lib/powerpc/44x/map.c   |   51 +++++++++++++++++++++++++++++++++++++++++++
 test/lib/powerpc/44x/tlbwe.S |   29 ++++++++++++++++++++++++
 test/lib/powerpc/io.c        |   35 +++++++++++++++++++++++++++++
 test/powerpc/cstart.S        |   38 ++++++++++++++++++++++++++++++++
 test/powerpc/exit.c          |   23 +++++++++++++++++++
 7 files changed, 221 insertions(+), 15 deletions(-)

[diff]

diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak
new file mode 100644
--- /dev/null
+++ b/user/config-powerpc-44x.mak
@@ -0,0 +1,14 @@
+
+
+# for some reason binutils hates tlbsx unless we say we're 405  :(
+CFLAGS += -Wa,-m405 -I test/lib/powerpc/44x
+
+cflatobjs += \
+       test/lib/powerpc/44x/map.o \
+       test/lib/powerpc/44x/tlbwe.o
+
+simpletests += \
+       test/powerpc/44x/tlbsx.bin \
+       test/powerpc/44x/tlbwe_16KB.bin \
+       test/powerpc/44x/tlbwe_hole.bin \
+       test/powerpc/44x/tlbwe.bin
diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak
--- a/user/config-powerpc.mak
+++ b/user/config-powerpc.mak
@@ -1,26 +1,42 @@
+platform := 44x
+
 CFLAGS += -m32
 CFLAGS += -D__powerpc__
 CFLAGS += -I $(KERNELDIR)/include
-# for some reaons binutils hates tlbsx unless we say we're 405  :(
-CFLAGS += -Wa,-mregnames,-m405
+CFLAGS += -Wa,-mregnames -I test/lib
 
-%.bin: %.o
-       $(OBJCOPY) -O binary $^ $@
+cstart := test/powerpc/cstart.o
 
-testobjs := \
-       io.bin \
-       spin.bin \
-       sprg.bin \
-       44x/tlbsx.bin \
-       44x/tlbwe_16KB.bin \
-       44x/tlbwe_hole.bin \
-       44x/tlbwe.bin
+cflatobjs += \
+       test/lib/powerpc/io.o
 
-tests := $(addprefix test/powerpc/, $(testobjs))
+$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): CFLAGS += -ffreestanding
 
-all: kvmtrace kvmctl $(tests)
+# these tests do not use libcflat
+simpletests := \
+       test/powerpc/spin.bin \
+       test/powerpc/io.bin \
+       test/powerpc/sprg.bin
+
+# theses tests use cstart.o, libcflat, and libgcc
+tests := \
+       test/powerpc/exit.bin
+
+include config-powerpc-$(platform).mak
+
+
+all: kvmtrace kvmctl $(libcflat) $(simpletests) $(tests)
+
+$(simpletests): %.bin: %.o
+       $(CC) -nostdlib $^ -Wl,-T,flat.lds -o $@
+
+$(tests): %.bin: $(cstart) %.o $(libcflat)
+       $(CC) -nostdlib $^ $(libgcc) -Wl,-T,flat.lds -o $@
 
 kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a
 
 arch_clean:
-       rm -f $(tests)
+       $(RM) $(simpletests) $(tests) $(cstart)
+       $(RM) $(patsubst %.bin, %.elf, $(simpletests) $(tests))
+       $(RM) $(patsubst %.bin, %.o, $(simpletests) $(tests))
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 <[EMAIL PROTECTED]>
+ */
+
+#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 <[EMAIL PROTECTED]>
+ */
+
+#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 <[EMAIL PROTECTED]>
+ */
+
+#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/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 <[EMAIL PROTECTED]>
+ */
+
+#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, [EMAIL PROTECTED]
+       ori     r3, r3, [EMAIL PROTECTED]
+       lis     r4, [EMAIL PROTECTED]
+       ori     r4, r4, [EMAIL PROTECTED]
+       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 <[EMAIL PROTECTED]>
+ */
+
+int main(void)
+{
+       return 1;
+}
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to