Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 147c0516 authored by Cédric Le Goater's avatar Cédric Le Goater Committed by Benjamin Herrenschmidt
Browse files

powerpc/boot: Add support for 64bit little endian wrapper



The code is only slightly modified : entry points now use the
FIXUP_ENDIAN trampoline to switch endian order. The 32bit wrapper
is kept for big endian kernels and 64bit is enforced for little
endian kernels with a PPC64_BOOT_WRAPPER config option.

The linker script is generated using the kernel preprocessor flags
to make use of the CONFIG_* definitions and the wrapper script is
modified to take into account the new elf64ppc format.

Finally, the zImage file is compiled as a position independent
executable (-pie) which makes it loadable at any address by the
firmware.

Signed-off-by: default avatarCédric Le Goater <clg@fr.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 2d9afb36
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -22,8 +22,14 @@ all: $(obj)/zImage
BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
		 -fno-strict-aliasing -Os -msoft-float -pipe \
		 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
		 -isystem $(shell $(CROSS32CC) -print-file-name=include) \
		 -mbig-endian
		 -isystem $(shell $(CROSS32CC) -print-file-name=include)
ifdef CONFIG_PPC64_BOOT_WRAPPER
BOOTCFLAGS	+= -m64
endif
ifdef CONFIG_CPU_BIG_ENDIAN
BOOTCFLAGS	+= -mbig-endian
endif

BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc

ifdef CONFIG_DEBUG_INFO
@@ -142,7 +148,11 @@ $(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: $(srctree)/scripts/dtc
$(obj)/empty.c:
	@touch $@

$(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds: $(obj)/%: $(srctree)/$(src)/%.S
$(obj)/zImage.lds: $(obj)/%: $(srctree)/$(src)/%.S
	$(CROSS32CC) $(cpp_flags) -E -Wp,-MD,$(depfile) -P -Upowerpc \
		-D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<

$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
	@cp $< $@

clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
+1 −0
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@ prom:
	rfid

1:	/* Return from OF */
	FIXUP_ENDIAN

	/* Restore registers and return. */
	rldicl  r1,r1,0,32
+12 −0
Original line number Diff line number Diff line
@@ -62,4 +62,16 @@
#define SPRN_TBRL	268
#define SPRN_TBRU	269

#define FIXUP_ENDIAN						   \
	tdi   0, 0, 0x48; /* Reverse endian of b . + 8		*/ \
	b     $+36;	  /* Skip trampoline if endian is good	*/ \
	.long 0x05009f42; /* bcl 20,31,$+4			*/ \
	.long 0xa602487d; /* mflr r10				*/ \
	.long 0x1c004a39; /* addi r10,r10,28			*/ \
	.long 0xa600607d; /* mfmsr r11				*/ \
	.long 0x01006b69; /* xori r11,r11,1			*/ \
	.long 0xa6035a7d; /* mtsrr0 r10				*/ \
	.long 0xa6037b7d; /* mtsrr1 r11				*/ \
	.long 0x2400004c  /* rfid				*/

#endif /* _PPC64_PPC_ASM_H */
+3 −0
Original line number Diff line number Diff line
#include "ppc_asm.h"

	.text

	.globl _zimage_start
_zimage_start:
	FIXUP_ENDIAN
	b _zimage_start_lib
+14 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ cacheit=
binary=
gzip=.gz
pie=
format=

# cross-compilation prefix
CROSS=
@@ -136,6 +137,14 @@ if [ -z "$kernel" ]; then
    kernel=vmlinux
fi

elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
case "$elfformat" in
    elf64-powerpcle)	format=elf64lppc	;;
    elf64-powerpc)	format=elf32ppc	;;
    elf32-powerpc)	format=elf32ppc	;;
esac


platformo=$object/"$platform".o
lds=$object/zImage.lds
ext=strip
@@ -154,6 +163,10 @@ of)
pseries)
    platformo="$object/pseries-head.o $object/of.o $object/epapr.o"
    link_address='0x4000000'
    if [ "$format" != "elf32ppc" ]; then
	link_address=
	pie=-pie
    fi
    make_space=n
    ;;
maple)
@@ -379,7 +392,7 @@ if [ "$platform" != "miboot" ]; then
    if [ -n "$link_address" ] ; then
        text_start="-Ttext $link_address"
    fi
    ${CROSS}ld -m elf32ppc -T $lds $text_start $pie -o "$ofile" \
    ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \
	$platformo $tmp $object/wrapper.a
    rm $tmp
fi
Loading