grub2/0372-Have-another-stab-at-fixing-fdt-build-issues.patch
Peter Jones 1f9267118f Fix some minor BLS issues
Rework the FDT module linking to make aarch64 build and boot right

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-17 16:50:04 -04:00

293 lines
9.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 17 Jul 2018 13:32:36 -0400
Subject: [PATCH] Have another stab at fixing fdt build issues.
This is an egregious hack until I can figure out how kinking this is supposed
to work.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/Makefile.core.def | 13 -------------
grub-core/bus/fdt.c | 6 ++++++
grub-core/lib/fdt.c | 29 ++++++++++++++++++++++++-----
grub-core/loader/arm/linux.c | 2 ++
grub-core/loader/arm64/linux.c | 4 ++++
grub-core/loader/arm64/xen_boot.c | 3 +++
grub-core/loader/efi/fdt.c | 5 +++++
include/grub/fdt.h | 16 ----------------
8 files changed, 44 insertions(+), 34 deletions(-)
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index f96b1933eea..3fc16fa9df1 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -166,7 +166,6 @@ kernel = {
arm_coreboot = kern/arm/coreboot/init.c;
arm_coreboot = kern/arm/coreboot/timer.c;
arm_coreboot = kern/arm/coreboot/coreboot.S;
- arm_coreboot = lib/fdt.c;
arm_coreboot = bus/fdt.c;
arm_coreboot = term/ps2.c;
arm_coreboot = term/arm/pl050.c;
@@ -1694,17 +1693,11 @@ module = {
enable = i386_pc;
};
-/*
module = {
name = xen_boot;
arm64 = loader/arm64/xen_boot.c;
-
- fdt = lib/fdt.c;
- fdt = loader/efi/fdt.c;
-
enable = arm64;
};
-*/
module = {
name = linux;
@@ -1721,23 +1714,17 @@ module = {
arm64 = loader/arm64/linux.c;
emu = loader/emu/linux.c;
- fdt = lib/fdt.c;
- fdt = loader/efi/fdt.c;
-
common = loader/linux.c;
common = lib/cmdline.c;
efi = loader/efi/linux.c;
};
-/*
module = {
name = fdt;
arm64 = loader/efi/fdt.c;
- common = lib/fdt.c;
enable = fdt;
};
-*/
module = {
name = xnu;
diff --git a/grub-core/bus/fdt.c b/grub-core/bus/fdt.c
index 135da497ba6..4d1914d2c28 100644
--- a/grub-core/bus/fdt.c
+++ b/grub-core/bus/fdt.c
@@ -19,6 +19,12 @@
#include <grub/fdtbus.h>
#include <grub/fdt.h>
#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+
+
+#include "../lib/fdt.c"
static const void *dtb;
static grub_size_t root_address_cells, root_size_cells;
diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c
index 0d371c5633e..16128fd6f32 100644
--- a/grub-core/lib/fdt.c
+++ b/grub-core/lib/fdt.c
@@ -16,12 +16,22 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <grub/fdt.h>
-#include <grub/misc.h>
-#include <grub/mm.h>
-#include <grub/dl.h>
+static int grub_fdt_create_empty_tree (void *fdt, unsigned int size);
+static int grub_fdt_check_header (const void *fdt, unsigned int size);
+static int grub_fdt_check_header_nosize (const void *fdt);
+static int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
+ const char *name);
+static int grub_fdt_first_node (const void *fdt, unsigned int parentoffset);
+static int grub_fdt_next_node (const void *fdt, unsigned int currentoffset);
+static int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset,
+ const char *name);
+static const char *
+grub_fdt_get_nodename (const void *fdt, unsigned int nodeoffset);
+static const void *grub_fdt_get_prop (const void *fdt, unsigned int nodeoffset, const char *name,
+ grub_uint32_t *len);
-GRUB_MOD_LICENSE ("GPLv3+");
+static int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
+ const void *val, grub_uint32_t len);
#define FDT_SUPPORTED_VERSION 17
@@ -263,6 +273,7 @@ static grub_uint32_t *find_prop (const void *fdt, unsigned int nodeoffset,
the size allocated for the FDT; if this function is called before the other
functions in this file and returns success, the other functions are
guaranteed not to access memory locations outside the allocated memory. */
+static inline __attribute__((__unused__))
int grub_fdt_check_header_nosize (const void *fdt)
{
if (((grub_addr_t) fdt & 0x3) || (grub_fdt_get_magic (fdt) != FDT_MAGIC)
@@ -281,6 +292,7 @@ int grub_fdt_check_header_nosize (const void *fdt)
return 0;
}
+static inline __attribute__((__unused__))
int grub_fdt_check_header (const void *fdt, unsigned int size)
{
if (size < sizeof (grub_fdt_header_t)
@@ -327,6 +339,7 @@ advance_token (const void *fdt, const grub_uint32_t *token, const grub_uint32_t
return 0;
}
+static inline __attribute__((__unused__))
int grub_fdt_next_node (const void *fdt, unsigned int currentoffset)
{
const grub_uint32_t *token = (const grub_uint32_t *) fdt + (currentoffset + grub_fdt_get_off_dt_struct (fdt)) / 4;
@@ -337,6 +350,7 @@ int grub_fdt_next_node (const void *fdt, unsigned int currentoffset)
- grub_fdt_get_off_dt_struct (fdt));
}
+static inline __attribute__((__unused__))
int grub_fdt_first_node (const void *fdt, unsigned int parentoffset)
{
const grub_uint32_t *token, *end;
@@ -358,6 +372,7 @@ int grub_fdt_first_node (const void *fdt, unsigned int parentoffset)
}
/* Find a direct sub-node of a given parent node. */
+static inline __attribute__((__unused__))
int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
const char *name)
{
@@ -385,6 +400,7 @@ int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
}
}
+static inline __attribute__((__unused__))
const char *
grub_fdt_get_nodename (const void *fdt, unsigned int nodeoffset)
{
@@ -407,6 +423,7 @@ int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset,
return add_subnode (fdt, parentoffset, name);
}
+static inline __attribute__((__unused__))
const void *
grub_fdt_get_prop (const void *fdt, unsigned int nodeoffset, const char *name,
grub_uint32_t *len)
@@ -425,6 +442,7 @@ grub_fdt_get_prop (const void *fdt, unsigned int nodeoffset, const char *name,
return prop + 3;
}
+static inline __attribute__((__unused__))
int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
const void *val, grub_uint32_t len)
{
@@ -501,6 +519,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
return 0;
}
+static inline __attribute__((__unused__))
int
grub_fdt_create_empty_tree (void *fdt, unsigned int size)
{
diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
index 9f43e41bb55..48016219e49 100644
--- a/grub-core/loader/arm/linux.c
+++ b/grub-core/loader/arm/linux.c
@@ -29,6 +29,8 @@
#include <grub/lib/cmdline.h>
#include <grub/linux.h>
+#include "../../lib/fdt.c"
+
GRUB_MOD_LICENSE ("GPLv3+");
static grub_dl_t my_mod;
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 84670a053b2..5438e8187d7 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -24,6 +24,8 @@
#include <grub/linux.h>
#include <grub/loader.h>
#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
#include <grub/types.h>
#include <grub/cpu/linux.h>
#include <grub/efi/efi.h>
@@ -34,6 +36,8 @@
#include <grub/i18n.h>
#include <grub/lib/cmdline.h>
+#include "../../lib/fdt.c"
+
GRUB_MOD_LICENSE ("GPLv3+");
static grub_dl_t my_mod;
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
index 258264c79e8..3c232c18c70 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -34,6 +34,9 @@
#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */
#include <grub/i18n.h>
#include <grub/lib/cmdline.h>
+#include <grub/dl.h>
+
+#include "../../lib/fdt.c"
GRUB_MOD_LICENSE ("GPLv3+");
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
index 55c09a19939..44555fd42f0 100644
--- a/grub-core/loader/efi/fdt.c
+++ b/grub-core/loader/efi/fdt.c
@@ -20,12 +20,17 @@
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
+#include <grub/misc.h>
#include <grub/command.h>
#include <grub/file.h>
#include <grub/efi/efi.h>
#include <grub/efi/fdtload.h>
#include <grub/efi/memory.h>
+#include "../../lib/fdt.c"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
static void *loaded_fdt;
static void *fdt;
diff --git a/include/grub/fdt.h b/include/grub/fdt.h
index 158b1bc4b3a..6b39cfe4861 100644
--- a/include/grub/fdt.h
+++ b/include/grub/fdt.h
@@ -101,22 +101,6 @@ struct grub_fdt_empty_tree {
#define grub_fdt_set_size_dt_struct(fdt, value) \
grub_fdt_set_header(fdt, size_dt_struct, value)
-int EXPORT_FUNC(grub_fdt_create_empty_tree) (void *fdt, unsigned int size);
-int EXPORT_FUNC(grub_fdt_check_header) (const void *fdt, unsigned int size);
-int EXPORT_FUNC(grub_fdt_check_header_nosize) (const void *fdt);
-int EXPORT_FUNC(grub_fdt_find_subnode) (const void *fdt, unsigned int parentoffset,
- const char *name);
-int EXPORT_FUNC(grub_fdt_first_node) (const void *fdt, unsigned int parentoffset);
-int EXPORT_FUNC(grub_fdt_next_node) (const void *fdt, unsigned int currentoffset);
-int EXPORT_FUNC(grub_fdt_add_subnode) (void *fdt, unsigned int parentoffset,
- const char *name);
-const char *
-EXPORT_FUNC(grub_fdt_get_nodename) (const void *fdt, unsigned int nodeoffset);
-const void *EXPORT_FUNC(grub_fdt_get_prop) (const void *fdt, unsigned int nodeoffset, const char *name,
- grub_uint32_t *len);
-
-int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const char *name,
- const void *val, grub_uint32_t len);
#define grub_fdt_set_prop32(fdt, nodeoffset, name, val) \
({ \
grub_uint32_t _val = grub_cpu_to_be32(val); \