* [U-Boot] [PATCH v3] x86: zImage: Pass working device tree data to the kernel
@ 2018-03-27 1:06 Ivan Gorinov
2018-03-27 1:58 ` Bin Meng
2018-03-30 8:10 ` Bin Meng
0 siblings, 2 replies; 4+ messages in thread
From: Ivan Gorinov @ 2018-03-27 1:06 UTC (permalink / raw)
To: u-boot
On x86 platforms, U-Boot does not pass Device Tree data to the kernel.
This prevents the kernel from using FDT loaded by U-Boot.
Read the working FDT address from the "fdtaddr" environment variable
and add a copy of the FDT data to the kernel setup_data list.
Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
---
arch/x86/include/asm/bootparam.h | 7 +++++--
arch/x86/lib/zimage.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 90768a9..6aba614 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -10,8 +10,11 @@
#include <asm/video/edid.h>
/* setup data types */
-#define SETUP_NONE 0
-#define SETUP_E820_EXT 1
+enum {
+ SETUP_NONE = 0,
+ SETUP_E820_EXT,
+ SETUP_DTB,
+};
/* extensible setup data list node */
struct setup_data {
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 2a82bc8..1ff77e9 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -14,6 +14,7 @@
*/
#include <common.h>
+#include <malloc.h>
#include <asm/acpi_table.h>
#include <asm/io.h>
#include <asm/ptrace.h>
@@ -95,6 +96,38 @@ static int get_boot_protocol(struct setup_header *hdr)
}
}
+static int setup_device_tree(struct setup_header *hdr, const void *fdt_blob)
+{
+ int bootproto = get_boot_protocol(hdr);
+ struct setup_data *sd;
+ int size;
+
+ if (bootproto < 0x0209)
+ return -ENOTSUPP;
+
+ 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)
{
@@ -261,6 +294,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
hdr->acpi_rsdp_addr = acpi_get_rsdp_addr();
#endif
+ setup_device_tree(hdr, (const void *)env_get_hex("fdtaddr", 0));
setup_video(&setup_base->screen_info);
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v3] x86: zImage: Pass working device tree data to the kernel
2018-03-27 1:06 [U-Boot] [PATCH v3] x86: zImage: Pass working device tree data to the kernel Ivan Gorinov
@ 2018-03-27 1:58 ` Bin Meng
2018-03-30 7:33 ` Bin Meng
2018-03-30 8:10 ` Bin Meng
1 sibling, 1 reply; 4+ messages in thread
From: Bin Meng @ 2018-03-27 1:58 UTC (permalink / raw)
To: u-boot
On Tue, Mar 27, 2018 at 9:06 AM, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
> On x86 platforms, U-Boot does not pass Device Tree data to the kernel.
> This prevents the kernel from using FDT loaded by U-Boot.
>
> Read the working FDT address from the "fdtaddr" environment variable
> and add a copy of the FDT data to the kernel setup_data list.
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
> arch/x86/include/asm/bootparam.h | 7 +++++--
> arch/x86/lib/zimage.c | 34 ++++++++++++++++++++++++++++++++++
> 2 files changed, 39 insertions(+), 2 deletions(-)
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v3] x86: zImage: Pass working device tree data to the kernel
2018-03-27 1:58 ` Bin Meng
@ 2018-03-30 7:33 ` Bin Meng
0 siblings, 0 replies; 4+ messages in thread
From: Bin Meng @ 2018-03-30 7:33 UTC (permalink / raw)
To: u-boot
On Tue, Mar 27, 2018 at 9:58 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Tue, Mar 27, 2018 at 9:06 AM, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
>> On x86 platforms, U-Boot does not pass Device Tree data to the kernel.
>> This prevents the kernel from using FDT loaded by U-Boot.
>>
>> Read the working FDT address from the "fdtaddr" environment variable
>> and add a copy of the FDT data to the kernel setup_data list.
>>
>> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
>> ---
>> arch/x86/include/asm/bootparam.h | 7 +++++--
>> arch/x86/lib/zimage.c | 34 ++++++++++++++++++++++++++++++++++
>> 2 files changed, 39 insertions(+), 2 deletions(-)
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
applied to u-boot-x86, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v3] x86: zImage: Pass working device tree data to the kernel
2018-03-27 1:06 [U-Boot] [PATCH v3] x86: zImage: Pass working device tree data to the kernel Ivan Gorinov
2018-03-27 1:58 ` Bin Meng
@ 2018-03-30 8:10 ` Bin Meng
1 sibling, 0 replies; 4+ messages in thread
From: Bin Meng @ 2018-03-30 8:10 UTC (permalink / raw)
To: u-boot
On Tue, Mar 27, 2018 at 9:06 AM, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
> On x86 platforms, U-Boot does not pass Device Tree data to the kernel.
> This prevents the kernel from using FDT loaded by U-Boot.
>
> Read the working FDT address from the "fdtaddr" environment variable
> and add a copy of the FDT data to the kernel setup_data list.
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
> arch/x86/include/asm/bootparam.h | 7 +++++--
> arch/x86/lib/zimage.c | 34 ++++++++++++++++++++++++++++++++++
> 2 files changed, 39 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
> index 90768a9..6aba614 100644
> --- a/arch/x86/include/asm/bootparam.h
> +++ b/arch/x86/include/asm/bootparam.h
> @@ -10,8 +10,11 @@
> #include <asm/video/edid.h>
>
> /* setup data types */
> -#define SETUP_NONE 0
> -#define SETUP_E820_EXT 1
> +enum {
> + SETUP_NONE = 0,
> + SETUP_E820_EXT,
> + SETUP_DTB,
> +};
>
> /* extensible setup data list node */
> struct setup_data {
> diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
> index 2a82bc8..1ff77e9 100644
> --- a/arch/x86/lib/zimage.c
> +++ b/arch/x86/lib/zimage.c
> @@ -14,6 +14,7 @@
> */
>
> #include <common.h>
> +#include <malloc.h>
> #include <asm/acpi_table.h>
> #include <asm/io.h>
> #include <asm/ptrace.h>
Sorry to mention that I added "#include <linux/libfdt.h>" here to fix
build error seen on several x86 boards during a buildman testing.
Changed applied to u-boot-x86.
> @@ -95,6 +96,38 @@ static int get_boot_protocol(struct setup_header *hdr)
> }
> }
>
Regards,
Bin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-30 8:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-27 1:06 [U-Boot] [PATCH v3] x86: zImage: Pass working device tree data to the kernel Ivan Gorinov
2018-03-27 1:58 ` Bin Meng
2018-03-30 7:33 ` Bin Meng
2018-03-30 8:10 ` Bin Meng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.