public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ivan Gorinov <ivan.gorinov@intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel
Date: Fri, 16 Mar 2018 10:38:36 -0700	[thread overview]
Message-ID: <20180316173836.GA1813@intel.com> (raw)

On x86 platforms, U-Boot does not provide Device Tree data to the kernel.
This prevents the kernel from using the same hardware description.

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 <ivan.gorinov@intel.com>
---
 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 <common.h>
+#include <malloc.h>
+#include <asm/global_data.h>
 #include <asm/acpi_table.h>
 #include <asm/io.h>
 #include <asm/ptrace.h>
@@ -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;
 }
-- 
2.7.4

             reply	other threads:[~2018-03-16 17:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 17:38 Ivan Gorinov [this message]
2018-03-16 17:52 ` [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel Andy Shevchenko
2018-03-16 17:55   ` Andy Shevchenko
2018-03-17  0:16   ` Ivan Gorinov
2018-03-19  9:19     ` Andy Shevchenko
2018-03-16 19:40 ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180316173836.GA1813@intel.com \
    --to=ivan.gorinov@intel.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox