aboutsummaryrefslogtreecommitdiffstats
path: root/roms/skiboot/test/hello_world
diff options
context:
space:
mode:
Diffstat (limited to 'roms/skiboot/test/hello_world')
-rw-r--r--roms/skiboot/test/hello_world/Makefile.check69
-rw-r--r--roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S48
-rw-r--r--roms/skiboot/test/hello_world/run_hello_world.tcl5
-rwxr-xr-xroms/skiboot/test/hello_world/run_mambo_hello_world.sh64
-rwxr-xr-xroms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh64
-rwxr-xr-xroms/skiboot/test/hello_world/run_qemu_hello_world.sh65
6 files changed, 315 insertions, 0 deletions
diff --git a/roms/skiboot/test/hello_world/Makefile.check b/roms/skiboot/test/hello_world/Makefile.check
new file mode 100644
index 000000000..0390cf662
--- /dev/null
+++ b/roms/skiboot/test/hello_world/Makefile.check
@@ -0,0 +1,69 @@
+HELLO_WORLD_TEST := test/hello_world/hello_kernel/hello_kernel
+HELLO_WORLD_STB_TEST := test/hello_world/hello_kernel/hello_kernel.stb
+
+.PHONY: hello_world-tests
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-smt-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-smt-p9-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-p9-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-qemu)
+
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-mambo)
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo)
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-mambo)
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-p9-mambo)
+
+boot-tests: hello_world-tests
+check: hello_world-tests
+
+cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
+ifeq ($(cc-name),clang)
+hello_kernel_CFLAGS = --target=powerpc64-linux-gnu
+endif
+hello_kernel_CFLAGS += -mbig-endian -m64
+
+$(HELLO_WORLD_TEST:%=%-check-smt-mambo): %-check-smt-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/hello_world/run_mambo_hello_world.sh , $@)
+
+$(HELLO_WORLD_TEST:%=%-check-smt-p9-mambo): %-check-smt-p9-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/hello_world/run_mambo_p9_hello_world.sh , $@)
+
+$(HELLO_WORLD_TEST:%=%-check-mambo): %-check-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/hello_world/run_mambo_hello_world.sh, $@)
+
+$(HELLO_WORLD_TEST:%=%-check-p9-mambo): %-check-p9-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/hello_world/run_mambo_p9_hello_world.sh, $@)
+
+# and now, with secure and trusted boot:
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-mambo): %-check-stb-smt-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 THREADS=2 ./test/hello_world/run_mambo_hello_world.sh , $@)
+
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo): %-check-stb-smt-p9-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 THREADS=2 ./test/hello_world/run_mambo_p9_hello_world.sh , $@)
+
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-mambo): %-check-stb-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 ./test/hello_world/run_mambo_hello_world.sh, $@)
+
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-p9-mambo): %-check-stb-p9-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 ./test/hello_world/run_mambo_p9_hello_world.sh, $@)
+
+# qemu
+
+$(HELLO_WORLD_TEST:%=%-check-qemu): %-check-qemu: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/hello_world/run_qemu_hello_world.sh, $@)
+
+test/hello_world/hello_kernel/hello_kernel.o: test/hello_world/hello_kernel/hello_kernel.S
+ $(call Q,CC, $(CC) $(hello_kernel_CFLAGS) -c -o $@ $< ,$@)
+
+test/hello_world/hello_kernel/hello_kernel: test/hello_world/hello_kernel/hello_kernel.o
+ $(call Q,LD, $(LD) -EB -m elf64ppc -N -o $@ $^ , $@)
+
+test/hello_world/hello_kernel/hello_kernel.stb: test/hello_world/hello_kernel/hello_kernel libstb/create-container
+ $(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/,$@)
+
+clean: hello_world-test-clean
+
+hello_world-test-clean:
+ $(RM) test/hello_world/hello_kernel/hello_kernel
+ $(RM) test/hello_world/hello_kernel/hello_kernel.o
diff --git a/roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S b/roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S
new file mode 100644
index 000000000..4f774c179
--- /dev/null
+++ b/roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+/*
+ * hello_kernel.S!
+ *
+ * Because skiboot has its own stack, we don't even need that!
+ * All we need to do is make an OPAL call to write to the console.
+ *
+ * Copyright 2014-2016 IBM Corp.
+ */
+
+ . = 0x0
+ .globl _start
+_start:
+/*
+ * Save some values passed in from skiboot into registers that are
+ * non-volatile over OPAL calls.
+ * r8 is the OPAL base
+ * r9 is the OPAL entry point point
+ */
+ mr %r13, %r8
+ mr %r14, %r9
+
+ bl here
+here: mflr %r8 /* work out where we are running */
+
+ li %r0, 1 /* OPAL_CONSOLE_WRITE */
+ li %r3, 0 /* terminal 0 */
+ addi %r4, %r8, len - here /* ptr to length of string */
+ addi %r5, %r8, str - here /* ptr to string start */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ li %r0, 5 /* OPAL_CEC_POWER_DOWN */
+ li %r3, 0 /* normal shutdown */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ /* We shouldn't get here but if we do, just wait here */
+ b .
+
+len:
+ .long 0x00
+ .long (strend - str)
+str:
+ .string "Hello World!\n"
+strend:
diff --git a/roms/skiboot/test/hello_world/run_hello_world.tcl b/roms/skiboot/test/hello_world/run_hello_world.tcl
new file mode 100644
index 000000000..bbd916c39
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_hello_world.tcl
@@ -0,0 +1,5 @@
+source ../../external/mambo/skiboot.tcl
+
+mysim go
+mysim memory fwrite 0x30000000 0x500000 skiboot-hello_world.dump
+exit
diff --git a/roms/skiboot/test/hello_world/run_mambo_hello_world.sh b/roms/skiboot/test/hello_world/run_mambo_hello_world.sh
new file mode 100755
index 000000000..a9f5b8ad9
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_mambo_hello_world.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+
+if [ -z "$MAMBO_PATH" ]; then
+ MAMBO_PATH=/opt/ibm/systemsim-p8/
+fi
+
+if [ -z "$MAMBO_BINARY" ]; then
+ MAMBO_BINARY="/run/pegasus/power8"
+fi
+
+if [ ! -x "$MAMBO_PATH/$MAMBO_BINARY" ]; then
+ echo "Could not find executable MAMBO_BINARY ($MAMBO_PATH/$MAMBO_BINARY). Skipping hello_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel.stb
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
+fi
+
+# Currently getting some core dumps from mambo, so disable them!
+ulimit -c 0
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 30
+spawn $MAMBO_PATH/$MAMBO_BINARY -n -f ../../test/hello_world/run_hello_world.tcl
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Machine Check Stop" { exit 1;}
+"Execution stopped: Sim Support exit requested stop"
+}
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/roms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh b/roms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh
new file mode 100755
index 000000000..e9eee8c39
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+if [ -z "$P9MAMBO_PATH" ]; then
+ P9MAMBO_PATH=/opt/ibm/systemsim-p9/
+fi
+
+if [ -z "$P9MAMBO_BINARY" ]; then
+ P9MAMBO_BINARY="/run/p9/power9"
+fi
+
+if [ ! -x "$P9MAMBO_PATH/$P9MAMBO_BINARY" ]; then
+ echo "Could not find executable P9MAMBO_BINARY ($P9MAMBO_PATH/$P9MAMBO_BINARY). Skipping hello_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel.stb
+ export SKIBOOT_CVC_CODE=$(pwd)/external/mambo/cvc.bin
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
+fi
+
+# Currently getting some core dumps from mambo, so disable them!
+ulimit -c 0
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 30
+spawn $P9MAMBO_PATH/$P9MAMBO_BINARY -n -f ../../test/hello_world/run_hello_world.tcl
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Machine Check Stop" { exit 1;}
+"Execution stopped: Sim Support exit requested stop"
+}
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/roms/skiboot/test/hello_world/run_qemu_hello_world.sh b/roms/skiboot/test/hello_world/run_qemu_hello_world.sh
new file mode 100755
index 000000000..9ca35d382
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_qemu_hello_world.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+QEMU_ARGS="-M powernv -nodefaults -device ipmi-bmc-sim,id=bmc0 -serial none"
+QEMU_ARGS+=" -device isa-serial,chardev=s1 -chardev stdio,id=s1,signal=off"
+
+if [ -z "$QEMU_BIN" ]; then
+ QEMU_BIN="qemu-system-ppc64"
+fi
+
+if [ ! $(command -v $QEMU_BIN) ]; then
+ echo "Could not find executable QEMU_BIN ($QEMU_BIN). Skipping hello_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+
+export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+(
+cat <<EOF | expect
+set timeout 30
+spawn $QEMU_BIN -bios skiboot.lid $QEMU_ARGS -kernel $SKIBOOT_ZIMAGE -nographic
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Could not load OPAL firmware" { send_user "\nSkiboot is too large for this Qemu, skipping\n"; exit 4; }
+"Machine Check Stop" { exit 1;}
+"Hello World!"
+}
+close
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r -eq 4 ]; then
+ echo "Qemu is too old and can't load a skiboot.lid this big"
+ rm $T
+ exit 0
+fi
+
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+
+exit 0;