Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/23867
Change subject: util/cbfstool: Move x86 Linux trampoline ......................................................................
util/cbfstool: Move x86 Linux trampoline
Move linux trampoline code to support more than one architecture.
* Move the x86 trampoline to payloads/external/linux * Add make rules to compile it only if the toolchain is present * Add architecture independent Makefile for all trampolines * Rename the trampoline to linux_trampoline_x86
Change-Id: I1d8630554e9fd845840de88142e5115c0bf92842 --- M Makefile.inc A payloads/external/linux/Makefile A payloads/external/linux/Makefile.inc R payloads/external/linux/bzimage_loader.h R payloads/external/linux/linux_trampoline.h R payloads/external/linux/linux_trampoline_x86.S A payloads/external/linux/linux_trampoline_x86.c R payloads/external/linux/trampoline/x86/linux_trampoline.c M util/cbfstool/Makefile M util/cbfstool/Makefile.inc M util/cbfstool/cbfs-payload-linux.c 11 files changed, 86 insertions(+), 18 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/67/23867/1
diff --git a/Makefile.inc b/Makefile.inc index be658ef..d117d59 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -93,7 +93,7 @@ subdirs-y += $(wildcard src/arch/*) subdirs-y += src/mainboard/$(MAINBOARDDIR) subdirs-y += src/security -subdirs-y += payloads payloads/external +subdirs-y += payloads payloads/external payloads/external/linux
subdirs-y += site-local subdirs-y += util/checklist util/testing diff --git a/payloads/external/linux/Makefile b/payloads/external/linux/Makefile new file mode 100644 index 0000000..0f5f2fd --- /dev/null +++ b/payloads/external/linux/Makefile @@ -0,0 +1,18 @@ +.PHONY: clean +clean: + $(RM) */linux_trampoline.c + +%.bin: %.elf + echo " OBJCOPY $@" + $(OBJCOPY) -Obinary -j .data $< $@ + rm $< + +%.elf: %.S + echo " CC $@" + $(CC) $(CFLAGS) -o $@ $< -ffreestanding -nostdlib -nostdinc -Wl,--defsym=_start=0 + +%.c: %.bin + echo " XXD $@" + echo "/* This file is automatically generated. Do not manually change */" > $@ + xxd -c 16 -i $< >> $@ + rm $< diff --git a/payloads/external/linux/Makefile.inc b/payloads/external/linux/Makefile.inc new file mode 100644 index 0000000..c0a2b0c --- /dev/null +++ b/payloads/external/linux/Makefile.inc @@ -0,0 +1,37 @@ +################################################################################ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2009-2010 coresystems GmbH +## Copyright (C) 2015 Google Inc. +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; version 2 of the License. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## + +###################################################################### +# set up payload config and version files for later inclusion + +linuxdir:=$(top)/payloads/external/linux + +ifneq ($(GCC_CC_x86_32),) +$(linuxdir)/linux_trampoline_x86.c: $(linuxdir)/linux_trampoline_x86.S $(top)/src/arch/x86/include/* + $(MAKE) -C $(linuxdir) linux_trampoline_x86.c \ + HOSTCC="$(HOSTCC)" \ + CC="$(GCC_CC_x86_32)" \ + OBJCOPY="$(OBJCOPY_x86_32)" \ + CFLAGS="$(CFLAGS_x86_32) -I$(top)/src/arch/x86/include" +else ifneq ($(GCC_CC_x86_64),) +$(linuxdir)/linux_trampoline_x86.c: $(linuxdir)/linux_trampoline_x86.S $(top)/src/arch/x86/include/* + $(MAKE) -C $(linuxdir) linux_trampoline_x86.c \ + HOSTCC="$(HOSTCC)" \ + CC="$(GCC_CC_x86_64)" \ + OBJCOPY="$(OBJCOPY_x86_64)" \ + CFLAGS="$(CLFAGS_x86_64) -m32 -I$(top)/src/arch/x86/include" +endif diff --git a/util/cbfstool/linux.h b/payloads/external/linux/bzimage_loader.h similarity index 97% rename from util/cbfstool/linux.h rename to payloads/external/linux/bzimage_loader.h index 249c7d7..a01d3d7 100644 --- a/util/cbfstool/linux.h +++ b/payloads/external/linux/bzimage_loader.h @@ -188,3 +188,7 @@ u8 command_line[COMMAND_LINE_SIZE]; /* 0x800 */ u8 reserved17[1792]; /* 0x900 - 0x1000 */ }; + +/* trampoline */ +extern unsigned char linux_trampoline_x86_bin[]; +extern unsigned int linux_trampoline_x86_bin_len; diff --git a/util/cbfstool/linux_trampoline.h b/payloads/external/linux/linux_trampoline.h similarity index 100% rename from util/cbfstool/linux_trampoline.h rename to payloads/external/linux/linux_trampoline.h diff --git a/util/cbfstool/linux_trampoline.S b/payloads/external/linux/linux_trampoline_x86.S similarity index 100% rename from util/cbfstool/linux_trampoline.S rename to payloads/external/linux/linux_trampoline_x86.S diff --git a/payloads/external/linux/linux_trampoline_x86.c b/payloads/external/linux/linux_trampoline_x86.c new file mode 100644 index 0000000..a60d747 --- /dev/null +++ b/payloads/external/linux/linux_trampoline_x86.c @@ -0,0 +1,16 @@ +/* This file is automatically generated. Do not manually change */ +unsigned char linux_trampoline_x86_bin[] = { + 0xfc, 0x31, 0xd2, 0xb9, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x01, 0x00, 0x01, 0xcb, 0x8b, + 0x01, 0x3d, 0x4c, 0x42, 0x49, 0x4f, 0x74, 0x07, 0x83, 0xc1, 0x10, 0x39, 0xcb, 0x75, 0xe9, 0x39, + 0xcb, 0x0f, 0x84, 0x87, 0x00, 0x00, 0x00, 0x8b, 0x59, 0x04, 0x01, 0xcb, 0x8b, 0x49, 0x14, 0x83, + 0x3b, 0x11, 0x75, 0x05, 0x8b, 0x4b, 0x08, 0xeb, 0xcf, 0x83, 0x3b, 0x01, 0x75, 0x33, 0x8b, 0x43, + 0x04, 0x83, 0xe8, 0x08, 0xc1, 0xe8, 0x02, 0x3d, 0xa0, 0x00, 0x00, 0x00, 0x7e, 0x05, 0xb8, 0xa0, + 0x00, 0x00, 0x00, 0x89, 0xc6, 0xbf, 0x05, 0x00, 0x00, 0x00, 0xf7, 0xf7, 0xa3, 0xe8, 0x01, 0x09, + 0x00, 0x89, 0xf0, 0x91, 0x8d, 0x73, 0x08, 0xbf, 0xd0, 0x02, 0x09, 0x00, 0xf3, 0xa5, 0x91, 0xeb, + 0x05, 0x83, 0x3b, 0x12, 0x75, 0x00, 0x03, 0x5b, 0x04, 0x49, 0x75, 0xb3, 0xb8, 0x00, 0x00, 0x04, + 0x00, 0x0f, 0x01, 0x00, 0x8b, 0x58, 0x02, 0xc7, 0x43, 0x10, 0xff, 0xff, 0x00, 0x00, 0xc7, 0x43, + 0x14, 0x00, 0x9b, 0xcf, 0x00, 0xc7, 0x43, 0x18, 0xff, 0xff, 0x00, 0x00, 0xc7, 0x43, 0x1c, 0x00, + 0x93, 0xcf, 0x00, 0xbe, 0x00, 0x00, 0x09, 0x00, 0xff, 0x25, 0x14, 0x02, 0x09, 0x00, 0xf4, 0xeb, + 0xfd +}; +unsigned int linux_trampoline_x86_bin_len = 177; diff --git a/util/cbfstool/linux_trampoline.c b/payloads/external/linux/trampoline/x86/linux_trampoline.c similarity index 100% rename from util/cbfstool/linux_trampoline.c rename to payloads/external/linux/trampoline/x86/linux_trampoline.c diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile index caa8c7d..76efcad 100644 --- a/util/cbfstool/Makefile +++ b/util/cbfstool/Makefile @@ -30,15 +30,6 @@ $(RM) $(objutil)/cbfstool/ifwitool $(ifwiobj) $(RM) $(objutil)/cbfstool/cbfs-compression-tool $(cbfscompobj)
-linux_trampoline.c: linux_trampoline.S - rm -f linux_trampoline.c - $(CC) -m32 -o linux_trampoline linux_trampoline.S -ffreestanding -nostdlib -nostdinc -Wl,--defsym=_start=0 - $(OBJCOPY) -Obinary -j .data linux_trampoline trampoline - echo "/* This file is automatically generated. Do not manually change */" > trampoline.c - xxd -c 16 -i trampoline >> trampoline.c - mv trampoline.c linux_trampoline.c - rm linux_trampoline trampoline - .SILENT:
include Makefile.inc diff --git a/util/cbfstool/Makefile.inc b/util/cbfstool/Makefile.inc index 8e4d8b6..0575e1d 100644 --- a/util/cbfstool/Makefile.inc +++ b/util/cbfstool/Makefile.inc @@ -38,8 +38,9 @@ cbfsobj += kv_pair.o cbfsobj += valstr.o # linux as payload -cbfsobj += linux_trampoline.o +cbfsobj += linux_trampoline_x86.o cbfsobj += cbfs-payload-linux.o + # compression algorithms cbfsobj += $(compressionobj)
@@ -83,6 +84,7 @@ TOOLCPPFLAGS += -DNEED_VB2_SHA_LIBRARY TOOLCPPFLAGS += -I$(VBOOT_SOURCE)/firmware/include TOOLCPPFLAGS += -I$(VBOOT_SOURCE)/firmware/2lib/include +TOOLCPPFLAGS += -I$(top)/payloads/external/linux # UEFI header file support. It's not pretty, but that's what we currently # have right now. TOOLCPPFLAGS += -I$(top)/src @@ -101,6 +103,10 @@ TOOLCFLAGS+=-std=c99 endif
+$(objutil)/cbfstool/linux_trampoline_%.o: $(top)/payloads/external/linux/linux_trampoline_%.c + printf " HOSTCC $(subst $(objutil)/,,$(@))\n" + $(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $< + $(objutil)/cbfstool/%.o: $(objutil)/cbfstool/%.c printf " HOSTCC $(subst $(objutil)/,,$(@))\n" $(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $< diff --git a/util/cbfstool/cbfs-payload-linux.c b/util/cbfstool/cbfs-payload-linux.c index 6b4bf27..9646384 100644 --- a/util/cbfstool/cbfs-payload-linux.c +++ b/util/cbfstool/cbfs-payload-linux.c @@ -19,11 +19,7 @@
#include "common.h" #include "cbfs.h" -#include "linux.h" - -/* trampoline */ -extern unsigned char trampoline[]; -extern unsigned int trampoline_len; +#include "bzimage_loader.h"
/* * Current max number of segments include: @@ -97,8 +93,8 @@
static int bzp_add_trampoline(struct bzpayload *bzp) { - bzp_add_segment(bzp, &bzp->trampoline, trampoline, - trampoline_len); + bzp_add_segment(bzp, &bzp->trampoline, linux_trampoline_x86_bin, + linux_trampoline_x86_bin_len); return 0; }