aboutsummaryrefslogtreecommitdiffstats
path: root/roms/skiboot/test/sreset_world
diff options
context:
space:
mode:
Diffstat (limited to 'roms/skiboot/test/sreset_world')
-rw-r--r--roms/skiboot/test/sreset_world/Makefile.check48
-rwxr-xr-xroms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh76
-rwxr-xr-xroms/skiboot/test/sreset_world/run_mambo_sreset.sh76
-rw-r--r--roms/skiboot/test/sreset_world/run_sreset_world.tcl6
-rw-r--r--roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S99
5 files changed, 305 insertions, 0 deletions
diff --git a/roms/skiboot/test/sreset_world/Makefile.check b/roms/skiboot/test/sreset_world/Makefile.check
new file mode 100644
index 000000000..ec9fd2747
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/Makefile.check
@@ -0,0 +1,48 @@
+SRESET_WORLD_TEST := test/sreset_world/sreset_kernel/sreset_kernel
+SRESET_WORLD_STB_TEST := test/sreset_world/sreset_kernel/sreset_kernel.stb
+
+.PHONY: sreset_world-tests
+# We only do the SMT tests as we don't do OPAL re-entry
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-smt-mambo)
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-smt-p9-mambo)
+
+sreset_world-tests: $(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-mambo)
+sreset_world-tests: $(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo)
+
+boot-tests: sreset_world-tests
+check: sreset_world-tests
+
+cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
+ifeq ($(cc-name),clang)
+sreset_kernel_CFLAGS = --target=powerpc64-linux-gnu
+endif
+sreset_kernel_CFLAGS += -mbig-endian -m64
+
+$(SRESET_WORLD_TEST:%=%-check-smt-mambo): %-check-smt-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/sreset_world/run_mambo_sreset.sh , $@)
+
+$(SRESET_WORLD_TEST:%=%-check-smt-p9-mambo): %-check-smt-p9-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/sreset_world/run_mambo_p9_sreset.sh , $@)
+
+$(SRESET_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/sreset_world/run_mambo_sreset.sh , $@)
+
+$(SRESET_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/sreset_world/run_mambo_p9_sreset.sh , $@)
+
+test/sreset_world/sreset_kernel/sreset_kernel.o: test/sreset_world/sreset_kernel/sreset_kernel.S
+ $(call Q,CC, $(CC) $(sreset_kernel_CFLAGS) -c -o $@ $< ,$@)
+
+test/sreset_world/sreset_kernel/sreset_kernel: test/sreset_world/sreset_kernel/sreset_kernel.o
+ $(call Q,LD, $(LD) -EB -m elf64ppc -N -o $@ $^ , $@)
+
+test/sreset_world/sreset_kernel/sreset_kernel.stb: test/sreset_world/sreset_kernel/sreset_kernel libstb/create-container
+ $(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/,$@)
+
+
+clean: sreset_world-test-clean
+
+sreset_world-test-clean:
+ $(RM) test/sreset_world/sreset_kernel/sreset_kernel
+ $(RM) test/sreset_world/sreset_kernel/sreset_kernel.o
diff --git a/roms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh b/roms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh
new file mode 100755
index 000000000..1f6524000
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh
@@ -0,0 +1,76 @@
+#!/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 sreset_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel.stb
+ export SKIBOOT_CVC_CODE=$(pwd)/external/mambo/cvc.bin
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_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/sreset_world/run_sreset_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;}
+"Hello World!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for Hello SRESET\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n"; exit 1 }
+"Machine Check Stop" { exit 1;}
+"Hello SRESET!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for shutdown\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/sreset_world/run_mambo_sreset.sh b/roms/skiboot/test/sreset_world/run_mambo_sreset.sh
new file mode 100755
index 000000000..298a582f8
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/run_mambo_sreset.sh
@@ -0,0 +1,76 @@
+#!/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 sreset_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel.stb
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_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/sreset_world/run_sreset_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;}
+"Hello World!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for Hello SRESET\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n"; exit 1 }
+"Machine Check Stop" { exit 1;}
+"Hello SRESET!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for shutdown\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/sreset_world/run_sreset_world.tcl b/roms/skiboot/test/sreset_world/run_sreset_world.tcl
new file mode 100644
index 000000000..38da0d235
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/run_sreset_world.tcl
@@ -0,0 +1,6 @@
+source ../../external/mambo/skiboot.tcl
+source ../../external/mambo/mambo_utils.tcl
+
+mysim go
+mysim memory fwrite 0x30000000 0x500000 skiboot-sreset_world.dump
+exit
diff --git a/roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S b/roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S
new file mode 100644
index 000000000..08960d589
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+/*
+ * Test the SRESET OPAL call in Mambo by
+ * having a bit of fun printing 'Hello World' from the SRESET vector.
+ *
+ * Copyright 2013-2017 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 */
+ subi %r8, %r8, here - _start
+ /* Stash OPAL base and entry point somewhere SRESET can find it */
+ li %r6, 0xe0
+ std %r13, 0(%r6)
+ std %r14, 8(%r6)
+ std %r8, 16(%r6)
+ addi %r6, %r8, sreset_code_end - _start
+ addi %r7, %r8, sreset_code - _start
+ li %r10, 0x100
+c:
+ lwa %r9, 0(%r7)
+ stw %r9, 0(%r10)
+ addi %r7,%r7,4
+ addi %r10,%r10,4
+ cmpd %r7,%r6
+ bne c
+ sync
+ icbi 0,%r0
+ sync
+ isync
+
+ li %r0, 1 /* OPAL_CONSOLE_WRITE */
+ li %r3, 0 /* terminal 0 */
+ addi %r4, %r8, len - _start /* ptr to length of string */
+ addi %r5, %r8, str - _start /* ptr to string start */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ li %r0, 145 /* OPAL_SIGNAL_SYSTEM_RESET */
+ li %r3, -2 /* All *OTHER* CPUs */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ /* We shouldn't get here but if we do, just wait here */
+ b .
+
+sreset_code:
+ li %r6, 0xe0
+ ld %r13, 0(%r6)
+ ld %r14, 8(%r6)
+ ld %r8, 16(%r6) /* "here" */
+ li %r0, 1 /* OPAL_CONSOLE_WRITE */
+ li %r3, 0 /* terminal 0 */
+ li %r4, len2 - _start
+ li %r5, str2 - _start
+ add %r4, %r8, %r4
+ add %r5, %r8, %r5
+ 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 .
+
+sreset_code_end:
+
+len:
+ .long 0x00
+ .long (strend - str)
+str:
+ .string "Hello World!\n"
+strend:
+
+len2:
+ .long 0x00
+ .long (str2end - str2)
+str2:
+ .string "Hello SRESET!\n"
+str2end:
+