grub2/0031-fdtbus-Add-ability-to-send-receive-messages-on-paren.patch
Peter Jones 88d855728e Fix arm kernel command line allocation
Resolves: rhbz#1484609
Get rid of the temporary extra efi packages hack.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-24 14:13:44 -04:00

135 lines
4.3 KiB
Diff

From c4313c812dc14e82a774b580b5e34d40e7f3fae6 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Tue, 9 May 2017 08:40:29 +0200
Subject: [PATCH 031/194] fdtbus: Add ability to send/receive messages on
parent busses.
---
grub-core/bus/fdt.c | 35 +++++++++++++++++------------------
include/grub/fdtbus.h | 18 +++++++++++++++++-
2 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/grub-core/bus/fdt.c b/grub-core/bus/fdt.c
index 34d535457..135da497b 100644
--- a/grub-core/bus/fdt.c
+++ b/grub-core/bus/fdt.c
@@ -25,30 +25,22 @@ static grub_size_t root_address_cells, root_size_cells;
/* Pointer to this symbol signals invalid mapping. */
char grub_fdtbus_invalid_mapping[1];
-struct grub_fdtbus_dev
-{
- struct grub_fdtbus_dev *next;
- struct grub_fdtbus_dev *parent;
- int node;
- struct grub_fdtbus_driver *driver;
-};
-
struct grub_fdtbus_dev *devs;
struct grub_fdtbus_driver *drivers;
-static int
-is_compatible (struct grub_fdtbus_driver *driver,
- int node)
+int
+grub_fdtbus_is_compatible (const char *compat_string,
+ const struct grub_fdtbus_dev *dev)
{
grub_size_t compatible_size;
- const char *compatible = grub_fdt_get_prop (dtb, node, "compatible",
+ const char *compatible = grub_fdt_get_prop (dtb, dev->node, "compatible",
&compatible_size);
if (!compatible)
return 0;
const char *compatible_end = compatible + compatible_size;
while (compatible < compatible_end)
{
- if (grub_strcmp (driver->compatible, compatible) == 0)
+ if (grub_strcmp (compat_string, compatible) == 0)
return 1;
compatible += grub_strlen (compatible) + 1;
}
@@ -75,10 +67,12 @@ fdtbus_scan (struct grub_fdtbus_dev *parent)
dev->parent = parent;
devs = dev;
FOR_LIST_ELEMENTS(driver, drivers)
- if (!dev->driver && is_compatible (driver, node))
+ if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev))
{
- if (driver->attach(dev) == GRUB_ERR_NONE)
+ grub_dprintf ("fdtbus", "Attaching %s\n", driver->compatible);
+ if (driver->attach (dev) == GRUB_ERR_NONE)
{
+ grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible);
dev->driver = driver;
break;
}
@@ -92,13 +86,18 @@ void
grub_fdtbus_register (struct grub_fdtbus_driver *driver)
{
struct grub_fdtbus_dev *dev;
+ grub_dprintf ("fdtbus", "Registering %s\n", driver->compatible);
grub_list_push (GRUB_AS_LIST_P (&drivers),
GRUB_AS_LIST (driver));
for (dev = devs; dev; dev = dev->next)
- if (!dev->driver && is_compatible (driver, dev->node))
+ if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev))
{
- if (driver->attach(dev) == GRUB_ERR_NONE)
- dev->driver = driver;
+ grub_dprintf ("fdtbus", "Attaching %s (%p)\n", driver->compatible, dev);
+ if (driver->attach (dev) == GRUB_ERR_NONE)
+ {
+ grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible);
+ dev->driver = driver;
+ }
grub_print_error ();
}
}
diff --git a/include/grub/fdtbus.h b/include/grub/fdtbus.h
index 985837e55..f519c40ec 100644
--- a/include/grub/fdtbus.h
+++ b/include/grub/fdtbus.h
@@ -22,7 +22,13 @@
#include <grub/fdt.h>
#include <grub/err.h>
-struct grub_fdtbus_dev;
+struct grub_fdtbus_dev
+{
+ struct grub_fdtbus_dev *next;
+ struct grub_fdtbus_dev *parent;
+ int node;
+ struct grub_fdtbus_driver *driver;
+};
struct grub_fdtbus_driver
{
@@ -33,6 +39,12 @@ struct grub_fdtbus_driver
grub_err_t (*attach) (const struct grub_fdtbus_dev *dev);
void (*detach) (const struct grub_fdtbus_dev *dev);
+
+ /* Message bus operations. */
+ grub_err_t (*send) (const struct grub_fdtbus_dev *dev, const void *data, grub_size_t sz);
+ grub_err_t (*receive) (const struct grub_fdtbus_dev *dev, void *data, grub_size_t sz);
+ grub_err_t (*start) (const struct grub_fdtbus_dev *dev);
+ void (*stop) (const struct grub_fdtbus_dev *dev);
};
extern char EXPORT_VAR(grub_fdtbus_invalid_mapping)[1];
@@ -63,6 +75,10 @@ EXPORT_FUNC(grub_fdtbus_register) (struct grub_fdtbus_driver *driver);
void
EXPORT_FUNC(grub_fdtbus_unregister) (struct grub_fdtbus_driver *driver);
+int
+EXPORT_FUNC(grub_fdtbus_is_compatible) (const char *compat_string,
+ const struct grub_fdtbus_dev *dev);
+
/* Must be called before any register(). */
/* dtb is assumed to be unfreeable and must remain
valid for lifetime of GRUB.
--
2.13.5