x86: zImage: pass device tree setup data to the kernel
PATCH v2 1/1 x86: zImage: pass device tree setup data to the kernel
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.
--- arch/x86/include/asm/bootparam.h | 1 + arch/x86/lib/zimage.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
arch/x86/include/asm/bootparam.h +1 -0
@@ -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 {
arch/x86/lib/zimage.c +32 -0
@@ -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 ; }
Signature · 1 line
2.7.4
PATCH v2 1/1 x86: zImage: pass device tree setup data to the kernel
Quoted 6 lines · Ivan Gorinov
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_dataheader and insert new item into the the setup data linked list.
So, now is the question, what to do with x86 hardware that has DTS in U- Boot, but uses ACPI tables, generated by U-Boot.
Would it work properly?
I would try to test it on Intel Edison (I hope you may do this yourself as well), though I don't know when, have not much time to work with Edison right now.
Quoted 80 lines
Signed-off-by Ivan Gorinov <[email protected]>--- arch/x86/include/asm/bootparam.h | 1 + arch/x86/lib/zimage.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)arch/x86/include/asm/bootparam.h +1
-0@@ -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 {arch/x86/lib/zimage.c +31
-0@@ -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,arch/x86/lib/zimage.c +1
-0ulong *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 ;}
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
PATCH v2 1/1 x86: zImage: pass device tree setup data to the kernel
Quoted 12 lines · Andy Shevchenko
Quoted 6 lines · Ivan Gorinov
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_dataheader and insert new item into the the setup data linked list.So, now is the question, what to do with x86 hardware that has DTS in U-
Boot, but uses ACPI tables, generated by U-Boot.
Quoted 6 lines
Would it work properly?
I would try to test it on Intel Edison (I hope you may do this yourself
as well), though I don't know when, have not much time to work with Edison right now.
Perhaps for now you may use CONFIG_ACPI_GENERATE (or how it's called?).
Quoted 5 lines
arch/x86/lib/zimage.c line 19
Quoted 5 lines
#include <
common.h>arch/x86/lib/zimage.c +2
-0+#include <malloc.h> +#include <asm/global_data.h> #include <asm/acpi_table.h>
Not in order.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
PATCH v2 1/1 x86: zImage: pass device tree setup data to the kernel
In reply to Andy ShevchenkoQuoted 10 lines · Andy Shevchenko
On x86 platforms, U-Boot does not provide Device Tree data to the
Quoted 5 lines
kernel.
This prevents the kernel from using the same hardware description.Make a copy of DTB data with
setup_dataheader and insert new item into the the setup data linked list.So, now is the question, what to do with x86 hardware that has DTS in U- Boot, but uses ACPI tables, generated by U-Boot.
Would it work properly?
It will work because CONFIG_OF is disabled in most x86 kernel configurations.
Quoted 3 lines
I would try to test it on Intel Edison (I hope you may do this yourself as well), though I don't know when, have not much time to work with Edison right now.
I am going to try that on a Minnowboard.
PATCH v2 1/1 x86: zImage: pass device tree setup data to the kernel
Quoted 8 lines · Ivan Gorinov
Quoted 7 lines · Andy Shevchenko
On x86 platforms, U-Boot does not provide Device Tree data to the
Quoted 5 lines
kernel.
This prevents the kernel from using the same hardware description.Make a copy of DTB data with
setup_dataheader and insert new item into the the setup data linked list.
Quoted 8 lines
Quoted 5 lines
So, now is the question, what to do with x86 hardware that has DTS in U-
Boot, but uses ACPI tables, generated by U-Boot.Would it work properly?
It will work because
CONFIG_OFis disabled in most x86 kernel configurations.
No one prevents to put CONFIG_OF=y into kernel configuration.
Quoted 6 lines
Quoted 4 lines
I would try to test it on Intel Edison (I hope you may do this yourself
as well), though I don't know when, have not much time to work with Edison right now.I am going to try that on a Minnowboard.
Yes, please.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
PATCH v2 1/1 x86: zImage: pass device tree setup data to the kernel
In reply to Ivan GorinovQuoted 4 lines · Ivan Gorinov
On x86 platforms, U-Boot does not provide Device Tree data to the kernel. This prevents the kernel from using the same hardware description.
Quoted 9 lines
Make a copy of DTB data with
setup_dataheader and insert new item into the the setup data linked list.Signed-off-by Ivan Gorinov <[email protected]>--- arch/x86/include/asm/bootparam.h | 1 + arch/x86/lib/zimage.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
See below
arch/x86/include/asm/bootparam.h line 15
Quoted 9 lines
arch/x86/include/asm/bootparam.h +1
-0@@ -12,6 +12,7 @@/* setup data types */ #define SETUP_NONE 0#define SETUP_E820_EXT 1 +#define SETUP_DTB 2
Make that an enum?
Quoted 63 lines
arch/x86/include/asm/bootparam.h +0
-0/* extensible setup data list node */ struct setup_data {arch/x86/lib/zimage.c +32
-1@@ -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