From patchwork Thu Mar 15 22:43:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Gorinov X-Patchwork-Id: 886494 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 402P3L10MLz9sVd for ; Fri, 16 Mar 2018 09:51:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6005EC21E26; Thu, 15 Mar 2018 22:51:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DE9D7C21D8E; Thu, 15 Mar 2018 22:51:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 75818C21C2F; Thu, 15 Mar 2018 22:51:27 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lists.denx.de (Postfix) with ESMTPS id ADCF7C21BE5 for ; Thu, 15 Mar 2018 22:51:26 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2018 15:51:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,313,1517904000"; d="scan'208";a="24444896" Received: from dph9ls1.fm.intel.com (HELO intel.com) ([10.80.209.182]) by fmsmga007.fm.intel.com with ESMTP; 15 Mar 2018 15:51:10 -0700 Date: Thu, 15 Mar 2018 15:43:26 -0700 From: Ivan Gorinov To: u-boot@lists.denx.de Message-ID: <20180315224326.GA62494@intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Cc: Andy Shevchenko Subject: [U-Boot] [PATCH] x86: zImage: pass device tree setup data to the kernel X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Make a copy of DTB data with setup_data header and insert new item into the the setup data linked list. Signed-off-by: Ivan Gorinov --- arch/x86/include/asm/bootparam.h | 1 + arch/x86/lib/zimage.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h index 90768a9..ea25cf7 100644 --- a/arch/x86/include/asm/bootparam.h +++ b/arch/x86/include/asm/bootparam.h @@ -12,6 +12,7 @@ /* setup data types */ #define SETUP_NONE 0 #define SETUP_E820_EXT 1 +#define SETUP_DTB 2 /* extensible setup data list node */ struct setup_data { diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 2a82bc8..41ad4c7 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -14,6 +14,8 @@ */ #include +#include +#include #include #include #include @@ -95,6 +97,35 @@ static int get_boot_protocol(struct setup_header *hdr) } } +static int setup_device_tree(struct setup_header *hdr) +{ + const void *fdt_blob = gd->fdt_blob; + struct setup_data *sd; + int size; + + if (!fdt_blob) + return 0; + + size = fdt_totalsize(fdt_blob); + if (size < 0) + return -EINVAL; + + size += sizeof(struct setup_data); + sd = (struct setup_data *)malloc(size); + if (!sd) { + printf("Not enough memory for DTB setup data\n"); + return -ENOMEM; + } + + sd->next = hdr->setup_data; + sd->type = SETUP_DTB; + sd->len = fdt_totalsize(fdt_blob); + memcpy(sd->data, fdt_blob, sd->len); + hdr->setup_data = (unsigned long)sd; + + return 0; +} + struct boot_params *load_zimage(char *image, unsigned long kernel_size, ulong *load_addressp) { @@ -262,6 +293,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, #endif setup_video(&setup_base->screen_info); + setup_device_tree(hdr); return 0; }