From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753738AbbFDJmQ (ORCPT ); Thu, 4 Jun 2015 05:42:16 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:55188 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbbFDJmH (ORCPT ); Thu, 4 Jun 2015 05:42:07 -0400 From: Yang Yingliang To: , CC: , , Subject: [RFC PATCH] arm64: Image: Allow the appending of a device tree binary Date: Thu, 4 Jun 2015 17:35:04 +0800 Message-ID: <1433410504-11628-1-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.18.231] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch provides the ability to boot using a device tree that is appended to the raw binary Image (e.g. cat Image .dtb > Image_w_dtb). Both BE and LE conditions are tested. Got references from e2a6a3aa ("ARM: zImage: Allow the appending of a device tree binary"). Signed-off-by: Yang Yingliang --- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/kernel/head.S | 12 ++++++++++++ arch/arm64/kernel/vmlinux.lds.S | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7796af4..d402448 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -660,6 +660,17 @@ endmenu menu "Boot options" +config ARM64_APPENDED_DTB + bool "Use appended device tree blob to Image" + depends on OF + help + With this option, the boot code will look for a device tree binary + (DTB) appended to Image + (e.g. cat Image .dtb > Image_w_dtb). + + With this option, the size of Image will be extended to be 2MB aligned. + The 2MB memory followed by Image is used for FDT blob. + config CMDLINE string "Default kernel command string" default "" diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 19f915e..ac00c8a 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -274,6 +274,18 @@ ENDPROC(preserve_boot_args) * The dtb must be 8-byte aligned and live in the first 512M of memory. */ __vet_fdt: +#ifdef CONFIG_ARM64_APPENDED_DTB + ldr x21, =_edata + add x21, x21, x28 + ldr w0, [x21] +#ifndef __AARCH64EB__ + ldr w1, =0xedfe0dd0 // FDT magic word +#else + ldr w1, =0xd00dfeed +#endif + cmp w0, w1 + b.ne 1f // no FDT found +#endif tst x21, #0x7 b.ne 1f cmp x21, x24 diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index a2c2986..c71bac3 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -54,6 +54,18 @@ PECOFF_FILE_ALIGNMENT = 0x200; #define PECOFF_EDATA_PADDING #endif +/* + * Set FDT pointer 2MB aligned to ensure + * it don't cross a 2-megabyte boundary. + */ +FDT_FILE_ALIGNMENT = (1 << 21); +#ifdef CONFIG_ARM64_APPENDED_DTB +#define FDT_EDATA_PADDING \ + .fdt_edata_padding : { BYTE(0); . = ALIGN(FDT_FILE_ALIGNMENT); } +#else +#define FDT_EDATA_PADDING +#endif + #ifdef CONFIG_DEBUG_ALIGN_RODATA #define ALIGN_DEBUG_RO . = ALIGN(1<