@@ -80,6 +80,8 @@ if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
testdir=x86
elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
testdir=arm
+elif [ "$arch" = "ppc64" ]; then
+ testdir=powerpc
else
testdir=$arch
fi
new file mode 100644
@@ -0,0 +1 @@
+asm-offsets.[hs]
new file mode 100644
@@ -0,0 +1,20 @@
+/*
+ * Each architecture must implement puts() and exit().
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+void io_init(void)
+{
+}
+
+void puts(const char *s __unused)
+{
+}
+
+void exit(int code __unused)
+{
+}
new file mode 100644
new file mode 100644
new file mode 100644
new file mode 100644
@@ -0,0 +1 @@
+asm-offsets.[hs]
new file mode 100644
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <kbuild.h>
+
+int main(void)
+{
+ return 0;
+}
new file mode 100644
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
new file mode 100644
@@ -0,0 +1,5 @@
+#ifndef _ASMPPC64_IO_H_
+#define _ASMPPC64_IO_H_
+#define __cpu_is_be() (1)
+#include <asm-generic/io.h>
+#endif
new file mode 100644
@@ -0,0 +1 @@
+#include <asm-generic/page.h>
new file mode 100644
@@ -0,0 +1,11 @@
+#ifndef _ASMPPC64_SPINLOCK_H_
+#define _ASMPPC64_SPINLOCK_H_
+
+struct spinlock {
+ int v;
+};
+
+extern void spin_lock(struct spinlock *lock);
+extern void spin_unlock(struct spinlock *lock);
+
+#endif /* _ASMPPC64_SPINLOCK_H_ */
new file mode 100644
new file mode 100644
@@ -0,0 +1,11 @@
+#include <asm/spinlock.h>
+
+void spin_lock(struct spinlock *lock)
+{
+ lock->v = 1;
+}
+
+void spin_unlock(struct spinlock *lock)
+{
+ lock->v = 0;
+}
new file mode 100644
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
new file mode 100644
@@ -0,0 +1,73 @@
+#
+# arm common makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+
+ifeq ($(LOADADDR),)
+ # qemu mach-virt default load address
+ LOADADDR = 0x40000000
+endif
+
+tests-common = \
+ $(TEST_DIR)/selftest.flat \
+ $(TEST_DIR)/spinlock-test.flat
+
+all: test_cases
+
+##################################################################
+phys_base = $(LOADADDR)
+
+CFLAGS += -std=gnu99
+CFLAGS += -ffreestanding
+CFLAGS += -Wextra
+CFLAGS += -O2
+CFLAGS += -I lib -I lib/libfdt
+
+asm-offsets = lib/$(ARCH)/asm-offsets.h
+include scripts/asm-offsets.mak
+
+cflatobjs += lib/util.o
+cflatobjs += lib/alloc.o
+cflatobjs += lib/devicetree.o
+cflatobjs += lib/virtio.o
+cflatobjs += lib/virtio-mmio.o
+cflatobjs += lib/chr-testdev.o
+cflatobjs += lib/arm/io.o
+cflatobjs += lib/arm/setup.o
+cflatobjs += lib/arm/mmu.o
+cflatobjs += lib/arm/bitops.o
+cflatobjs += lib/arm/psci.o
+cflatobjs += lib/arm/smp.o
+
+libeabi = lib/arm/libeabi.a
+eabiobjs = lib/arm/eabi_compat.o
+
+libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
+start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
+
+FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
+%.elf: LDFLAGS = $(CFLAGS) -nostdlib
+%.elf: %.o $(FLATLIBS) arm/flat.lds
+ $(CC) $(LDFLAGS) -o $@ \
+ -Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
+ $(filter %.o, $^) $(FLATLIBS)
+
+%.flat: %.elf
+ $(OBJCOPY) -O binary $^ $@
+
+$(libeabi): $(eabiobjs)
+ $(AR) rcs $@ $^
+
+arm_clean: libfdt_clean asm_offsets_clean
+ $(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
+ $(TEST_DIR)/.*.d lib/arm/.*.d
+
+##################################################################
+
+generated_files = $(asm-offsets)
+
+test_cases: $(generated_files) $(tests-common) $(tests)
+
+$(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
+$(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
new file mode 100644
@@ -0,0 +1,20 @@
+#
+# arm64 makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+bits = 64
+ldarch = elf64-littleaarch64
+kernel_offset = 0x80000
+
+cstart.o = $(TEST_DIR)/cstart64.o
+cflatobjs += lib/arm64/processor.o
+cflatobjs += lib/arm64/spinlock.o
+
+# arm64 specific tests
+tests =
+
+include $(TEST_DIR)/Makefile.common
+
+arch_clean: arm_clean
+ $(RM) lib/arm64/.*.d
new file mode 100644
@@ -0,0 +1,19 @@
+/*
+ * Entry point and assembler functions for ppc64 tests.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+.section .init
+
+.globl start
+start:
+ b halt
+
+.text
+
+.globl halt
+halt:
+1: b 1b
new file mode 100644
@@ -0,0 +1,27 @@
+
+SECTIONS
+{
+ .text : { *(.init) *(.text) *(.text.*) }
+ . = ALIGN(64K);
+ etext = .;
+ .data : {
+ *(.data)
+ }
+ . = ALIGN(16);
+ .rodata : { *(.rodata) }
+ . = ALIGN(16);
+ .bss : { *(.bss) }
+ . = ALIGN(64K);
+ edata = .;
+ . += 64K;
+ . = ALIGN(64K);
+ /*
+ * stack depth is 16K for arm and PAGE_SIZE for arm64, see THREAD_SIZE
+ * sp must be 16 byte aligned for arm64, and 8 byte aligned for arm
+ * sp must always be strictly less than the true stacktop
+ */
+ stackptr = . - 16;
+ stacktop = .;
+}
+
+ENTRY(start)
new file mode 100644
@@ -0,0 +1,7 @@
+#include <libcflat.h>
+
+int main(void)
+{
+ printf("hello world\n");
+ return 0;
+}
Use the arm/arm64 framework as a template to start a skeleton for powerpc/ppc64. Copy the arm makefiles and linker script verbatim. We'll modify them for powerpc with the next patch, making it clear what needs to be changed. Signed-off-by: Andrew Jones <drjones@redhat.com> --- configure | 2 ++ lib/powerpc/.gitignore | 1 + lib/powerpc/io.c | 20 +++++++++++++ lib/powerpc/mmu.c | 0 lib/powerpc/setup.c | 0 lib/powerpc/smp.c | 0 lib/ppc64/.gitignore | 1 + lib/ppc64/asm-offsets.c | 12 ++++++++ lib/ppc64/asm/asm-offsets.h | 1 + lib/ppc64/asm/io.h | 5 ++++ lib/ppc64/asm/page.h | 1 + lib/ppc64/asm/spinlock.h | 11 +++++++ lib/ppc64/processor.c | 0 lib/ppc64/spinlock.c | 11 +++++++ powerpc/Makefile | 1 + powerpc/Makefile.common | 73 +++++++++++++++++++++++++++++++++++++++++++++ powerpc/Makefile.ppc64 | 20 +++++++++++++ powerpc/cstart64.S | 19 ++++++++++++ powerpc/flat.lds | 27 +++++++++++++++++ powerpc/selftest.c | 7 +++++ 20 files changed, 212 insertions(+) create mode 100644 lib/powerpc/.gitignore create mode 100644 lib/powerpc/io.c create mode 100644 lib/powerpc/mmu.c create mode 100644 lib/powerpc/setup.c create mode 100644 lib/powerpc/smp.c create mode 100644 lib/ppc64/.gitignore create mode 100644 lib/ppc64/asm-offsets.c create mode 100644 lib/ppc64/asm/asm-offsets.h create mode 100644 lib/ppc64/asm/io.h create mode 100644 lib/ppc64/asm/page.h create mode 100644 lib/ppc64/asm/spinlock.h create mode 100644 lib/ppc64/processor.c create mode 100644 lib/ppc64/spinlock.c create mode 100644 powerpc/Makefile create mode 100644 powerpc/Makefile.common create mode 100644 powerpc/Makefile.ppc64 create mode 100644 powerpc/cstart64.S create mode 100644 powerpc/flat.lds create mode 100644 powerpc/selftest.c