aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--test/hello_world/Makefile.check23
-rw-r--r--test/hello_world/hello_kernel/asm-utils.h23
-rw-r--r--test/hello_world/hello_kernel/hello_kernel.S50
-rw-r--r--test/hello_world/hello_kernel/hello_kernel.ld29
-rwxr-xr-xtest/hello_world/run_hello_world.sh45
6 files changed, 171 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index fb5ed3a..2304666 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,4 +36,5 @@ libc/test/run-time
libc/test/run-time-gcov
libflash/test/test-flash
libflash/test/test-flash-gcov
+test/hello_world/hello_kernel/hello_kernel
VERSION
diff --git a/test/hello_world/Makefile.check b/test/hello_world/Makefile.check
new file mode 100644
index 0000000..f9e0e95
--- /dev/null
+++ b/test/hello_world/Makefile.check
@@ -0,0 +1,23 @@
+HELLO_WORLD_TEST := test/hello_world/hello_kernel/hello_kernel
+
+check: $(HELLO_WORLD_TEST:%=%-check)
+
+$(HELLO_WORLD_TEST:%=%-check) : %-check: %
+ ./test/hello_world/run_hello_world.sh
+
+CFLAGS=-I.
+ASFLAGS=-I.
+
+test/hello_world/hello_kernel/hello_kernel.o: test/hello_world/hello_kernel/hello_kernel.S
+ $(call Q,CC, $(CC) -m64 -c -Itest/hello_world/hello_kernel/ -o $@ $^ ,$@)
+
+hello_kernel_LDFLAGS=-m64 -Wl,--build-id=none -T test/hello_world/hello_kernel/hello_kernel.ld -ffreestanding -nostdlib -Ttext=0x0 -lgcc
+
+test/hello_world/hello_kernel/hello_kernel: test/hello_world/hello_kernel/hello_kernel.o
+ $(call Q,LD, $(CC) $(hello_kernel_LDFLAGS) -o $@ $^ , $@)
+
+clean: hello_world-test-clean
+
+hello_world-test-clean:
+ $(RM) -f test/hello_world/hello_kernel/hello_kernel
+ $(RM) -f test/hello_world/hello_kernel/hello_kernel.o
diff --git a/test/hello_world/hello_kernel/asm-utils.h b/test/hello_world/hello_kernel/asm-utils.h
new file mode 100644
index 0000000..bddf771
--- /dev/null
+++ b/test/hello_world/hello_kernel/asm-utils.h
@@ -0,0 +1,23 @@
+/* Copyright 2013-2014 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOAD_IMM64(r, e) \
+ lis r,(e)@highest; \
+ ori r,r,(e)@higher; \
+ rldicr r,r, 32, 31; \
+ oris r,r, (e)@h; \
+ ori r,r, (e)@l;
+
diff --git a/test/hello_world/hello_kernel/hello_kernel.S b/test/hello_world/hello_kernel/hello_kernel.S
new file mode 100644
index 0000000..41946a5
--- /dev/null
+++ b/test/hello_world/hello_kernel/hello_kernel.S
@@ -0,0 +1,50 @@
+/* Copyright 2013-2014 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <asm-utils.h>
+
+/*
+ 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.
+
+*/
+
+
+ . = 0x0
+ .globl _start
+_start:
+ mr 2, 8
+ li 0, 1 /* OPAL_CONSOLE_WRITE */
+ li 3, 0 /* terminal 0 */
+ LOAD_IMM64(29, 0x20010000)
+ lis 4, len@ha
+ addi 4,4, len@l
+ add 4,4,29
+ lis 5, str@ha
+ addi 5,5, str@l
+ add 5,5,29
+ mtctr 9
+ bctrl
+ attn
+
+len:
+ .long 0x00
+ .long 0x0D
+str:
+ .string "Hello World!\n"
diff --git a/test/hello_world/hello_kernel/hello_kernel.ld b/test/hello_world/hello_kernel/hello_kernel.ld
new file mode 100644
index 0000000..d9bbc92
--- /dev/null
+++ b/test/hello_world/hello_kernel/hello_kernel.ld
@@ -0,0 +1,29 @@
+ENTRY(_start)
+SECTIONS
+{
+ .text :
+ {
+ _start = .;
+ *(.text)
+ }
+
+ . = ALIGN(4096);
+ .data :
+ {
+ *(.rodata*)
+ *(.data*)
+ *(.sdata*)
+ *(.got2)
+ }
+
+ . = ALIGN(4096);
+ .bss :
+ {
+ _edata = .;
+ __bss_start = .;
+ *(.sbss)
+ *(.bss)
+ *(COMMON)
+ _end = . ;
+ }
+}
diff --git a/test/hello_world/run_hello_world.sh b/test/hello_world/run_hello_world.sh
new file mode 100755
index 0000000..dcb79a8
--- /dev/null
+++ b/test/hello_world/run_hello_world.sh
@@ -0,0 +1,45 @@
+#!/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. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! -x `which 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
+
+# Currently getting some core dumps from mambo, so disable them!
+OLD_ULIMIT_C=`ulimit -c`
+ulimit -c 0
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 30
+spawn $MAMBO_PATH/$MAMBO_BINARY -n -f skiboot.tcl
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Hello World!"
+}
+
+close
+exit 0
+EOF
+)
+ulimit -c $OLD_ULIMIT_C
+echo
+exit 0;