From owner-dev-commits-src-main@freebsd.org Wed Dec 30 12:57:34 2020 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A57364C2D15; Wed, 30 Dec 2020 12:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D5WXZ3vptz3MrT; Wed, 30 Dec 2020 12:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 793F21E888; Wed, 30 Dec 2020 12:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 0BUCvYdx009106; Wed, 30 Dec 2020 12:57:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 0BUCvYkE009105; Wed, 30 Dec 2020 12:57:34 GMT (envelope-from git) Date: Wed, 30 Dec 2020 12:57:34 GMT Message-Id: <202012301257.0BUCvYkE009105@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michal Meloun Subject: git: 28482babd08a - main - arm64: Use new arm_kernel_boothdr script for generating booti images. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mmel X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 28482babd08afdee79a6d42bd4f54d57f176dc8a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Commit messages for the main branch of the src repository." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Dec 2020 12:57:34 -0000 The branch main has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=28482babd08afdee79a6d42bd4f54d57f176dc8a commit 28482babd08afdee79a6d42bd4f54d57f176dc8a Author: Michal Meloun AuthorDate: 2020-12-25 18:48:33 +0000 Commit: Michal Meloun CommitDate: 2020-12-30 12:56:11 +0000 arm64: Use new arm_kernel_boothdr script for generating booti images. --- sys/arm64/arm64/locore.S | 31 ------------------------------- sys/conf/Makefile.arm64 | 36 ++++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 47 deletions(-) diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index 3e7ea7b44b70..c62a2a5bd626 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -43,22 +43,6 @@ .globl kernbase .set kernbase, KERNBASE - -/* U-Boot booti related constants. */ -#if defined(LINUX_BOOT_ABI) -#ifndef UBOOT_IMAGE_OFFSET -#define UBOOT_IMAGE_OFFSET 0 /* Image offset from start of */ -#endif /* 2 MiB page */ - -#ifndef UBOOT_IMAGE_SIZE /* Total size of image */ -#define UBOOT_IMAGE_SIZE _end - _start -#endif - -#ifndef UBOOT_IMAGE_FLAGS -#define UBOOT_IMAGE_FLAGS 0 /* LE kernel, unspecified */ -#endif /* page size */ -#endif /* defined(LINUX_BOOT_ABI) */ - /* * We assume: * MMU on with an identity map, or off @@ -68,21 +52,6 @@ */ ENTRY(_start) -#if defined(LINUX_BOOT_ABI) - /* U-boot image header */ - b 1f /* code 0 */ - .long 0 /* code 1 */ - .quad UBOOT_IMAGE_OFFSET /* Image offset in 2 MiB page, LE */ - .quad UBOOT_IMAGE_SIZE /* Image size, LE */ - .quad UBOOT_IMAGE_FLAGS /* Flags for kernel. LE */ - .quad 0 /* Reserved */ - .quad 0 /* Reserved */ - .quad 0 /* Reserved */ - .long 0x644d5241 /* Magic "ARM\x64", LE */ - .long 0 /* Reserved for PE COFF offset*/ -1: -#endif /* defined(LINUX_BOOT_ABI) */ - /* Drop to EL1 */ bl drop_to_el1 diff --git a/sys/conf/Makefile.arm64 b/sys/conf/Makefile.arm64 index 057f4feb3d38..1f5760021f3e 100644 --- a/sys/conf/Makefile.arm64 +++ b/sys/conf/Makefile.arm64 @@ -40,25 +40,11 @@ SYSTEM_LD= \ --strip-symbol='$$[adtx]*' \ ${.TARGET} -# Generate the .bin (no elf headers) kernel as an extra build output. -# We must relink to generate the .bin kernel, because without headers the -# location of everything changes. We also strip the ARM marker symbols. +# Generate the .bin (booti images) kernel as an extra build output. +# The targets and rules to generate these appear near the end of the file. KERNEL_EXTRA+= ${KERNEL_KO}.bin KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin -${KERNEL_KO}.bin: ${SYSTEM_DEP} vers.o - @echo "linking ${.TARGET}" - @${SYSTEM_LD_BASECMD} \ - --defsym='text_start=kernbase' \ - -o ${.TARGET} ${SYSTEM_OBJS} vers.o - ${SIZE} ${.TARGET} - @${OBJCOPY} \ - --wildcard \ - --strip-symbol='$$[adtx]*' \ - --output-target=binary \ - ${.TARGET} - @chmod 755 ${.TARGET} - .if !empty(DDB_ENABLED) CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer .endif @@ -79,3 +65,21 @@ CLEAN+= ${KERNEL_KO}.bin %RULES .include "$S/conf/kern.post.mk" + +# Create a kernel.bin file... +# Copy the kernel to u-boot's booti image format (the elf headers are +# stripped and a custom binary head blob is prepended), saving the +# output in a temp file. We also strip arm "marker" symbols which are +# used only by elf toolchains. Read the symbols from kernel.full and pass +# them to arm_kernel_boothdr.awk, which generates a binary header blob +# that goes on the front of the stripped kernel. Cat the header blob +# and the temp file together to make the kernel.bin file. +${KERNEL_KO}.bin: ${FULLKERNEL} + @${OBJCOPY} --wildcard --strip-symbol='$$[adtx]*' \ + --output-target=binary ${.ALLSRC} ${.TARGET}.temp + @{ readelf -s ${.ALLSRC} | \ + ${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v8booti && \ + cat ${.TARGET}.temp; \ + } > ${.TARGET} + @rm ${.TARGET}.temp + @echo "created ${.TARGET} from ${.ALLSRC}"