From 4f1f5c2dda167d556c704d1821a321949a68a62c Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Mon, 15 Dec 2014 15:32:09 +1100 Subject: Add hello_world tiny payload to test with mambo (if available) Just calls OPAL_CONSOLE_WRITE with "Hello World!" and with mambo we can execute this tiny boot test in not much time at all. Good little sanity check. Signed-off-by: Stewart Smith --- test/hello_world/Makefile.check | 23 ++++++++++++ test/hello_world/hello_kernel/asm-utils.h | 23 ++++++++++++ test/hello_world/hello_kernel/hello_kernel.S | 50 +++++++++++++++++++++++++++ test/hello_world/hello_kernel/hello_kernel.ld | 29 ++++++++++++++++ test/hello_world/run_hello_world.sh | 45 ++++++++++++++++++++++++ 5 files changed, 170 insertions(+) create mode 100644 test/hello_world/Makefile.check create mode 100644 test/hello_world/hello_kernel/asm-utils.h create mode 100644 test/hello_world/hello_kernel/hello_kernel.S create mode 100644 test/hello_world/hello_kernel/hello_kernel.ld create mode 100755 test/hello_world/run_hello_world.sh (limited to 'test') 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 + +/* + 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 <