mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/9] state: fix compile warnings for dev_err expansion
@ 2017-07-10 10:33 Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 2/9] common: efi: do not use undefined kconfig option Steffen Trumtrar
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Fix the following warnings:

  CC      common/state/backend_format_dtb.o
In file included from include/common.h:33:0,
                 from common/state/backend_format_dtb.c:18:
common/state/backend_format_dtb.c: In function ‘state_backend_format_dtb_verify’:
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 4 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_format_dtb.c:52:3: note: in expansion of macro ‘dev_err’
   dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
   ^~~~~~~
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 5 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_format_dtb.c:52:3: note: in expansion of macro ‘dev_err’
   dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
   ^~~~~~~
  CC      common/state/backend_format_raw.o
In file included from include/common.h:33:0,
                 from common/state/backend_format_raw.c:18:
common/state/backend_format_raw.c: In function ‘backend_format_raw_verify’:
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 4 has type ‘ssize_t {aka long int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_format_raw.c:111:3: note: in expansion of macro ‘dev_err’
   dev_err(backend_raw->dev, "Error, buffer length (%d) is shorter than the minimum required header length\n",
   ^~~~~~~
  CC      common/state/backend_storage.o
In file included from common/state/backend_storage.c:24:0:
common/state/backend_storage.c: In function ‘state_storage_mtd_buckets_init’:
include/printk.h:52:52: warning: format ‘%zu’ expects argument of type ‘size_t’,
but argument 5 has type ‘uint32_t {aka unsigned int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_storage.c:250:3: note: in expansion of macro ‘dev_err’
   dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %zu\n",
   ^~~~~~~

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/state/backend_format_dtb.c | 2 +-
 common/state/backend_format_raw.c | 2 +-
 common/state/backend_storage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/state/backend_format_dtb.c b/common/state/backend_format_dtb.c
index e88cda499b64..4c9d2eefc780 100644
--- a/common/state/backend_format_dtb.c
+++ b/common/state/backend_format_dtb.c
@@ -49,7 +49,7 @@ static int state_backend_format_dtb_verify(struct state_backend_format *format,
 	size_t len = *lenp;
 
 	if (dtb_len > len) {
-		dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
+		dev_err(fdtb->dev, "Error, stored DTB length (%zd) longer than read buffer (%zd)\n",
 			dtb_len, len);
 		return -EINVAL;
 	}
diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index d76718cf8270..2ba97e08a0ae 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -108,7 +108,7 @@ static int backend_format_raw_verify(struct state_backend_format *format,
 	ssize_t complete_len;
 
 	if (len < format_raw_min_length) {
-		dev_err(backend_raw->dev, "Error, buffer length (%d) is shorter than the minimum required header length\n",
+		dev_err(backend_raw->dev, "Error, buffer length (%zd) is shorter than the minimum required header length\n",
 			len);
 		return -EINVAL;
 	}
diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index 8d24f7053d3d..91135e99a64f 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -247,7 +247,7 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage,
 		end = meminfo->size;
 
 	if (!IS_ALIGNED(storage->offset, meminfo->erasesize)) {
-		dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %zu\n",
+		dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %u\n",
 			storage->offset, meminfo->erasesize);
 		return -EINVAL;
 	}
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 2/9] common: efi: do not use undefined kconfig option
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 3/9] fs: efi: return with correct error code in efifs_stat Steffen Trumtrar
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/efi/efi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/common/efi/efi.c b/common/efi/efi.c
index 05c58250f4a7..f924385958e1 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -266,8 +266,7 @@ static int efi_console_init(void)
 
 	add_generic_device("efi-stdio", DEVICE_ID_SINGLE, NULL, 0 , 0, 0, NULL);
 
-	if (IS_ENABLED(CONFIG_ARCH_EFI_REGISTER_COM1))
-		add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
+	add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
 				&ns16550_plat);
 
 	return 0;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 3/9] fs: efi: return with correct error code in efifs_stat
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 2/9] common: efi: do not use undefined kconfig option Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 4/9] devfs-core: add function to find cdev by partuuid Steffen Trumtrar
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Instead of erroring out when a file is not present, just return ENOENT if the
file does not exist and let the fs-layer handle the situation correctly.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 fs/efi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/efi.c b/fs/efi.c
index 0c0f52e87c47..85ff914291ed 100644
--- a/fs/efi.c
+++ b/fs/efi.c
@@ -407,9 +407,7 @@ static int efifs_stat(struct device_d *dev, const char *filename, struct stat *s
 
 	efiret = priv->root_dir->open(priv->root_dir, &entry, efi_path, EFI_FILE_MODE_READ, 0ULL);
 	if (EFI_ERROR(efiret)) {
-		pr_err("%s: unable to Open %s: %s\n", __func__, filename,
-				efi_strerror(efiret));
-		ret = -efi_errno(efiret);
+		ret = -ENOENT;
 		goto out_free;
 	}
 
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 4/9] devfs-core: add function to find cdev by partuuid
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 2/9] common: efi: do not use undefined kconfig option Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 3/9] fs: efi: return with correct error code in efifs_stat Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 5/9] of: of_path: find device via partuuid Steffen Trumtrar
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 fs/devfs-core.c  | 14 ++++++++++++++
 include/driver.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 3368d3ed68bd..be56edd18d80 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -95,6 +95,20 @@ struct cdev *cdev_by_device_node(struct device_node *node)
 	return NULL;
 }
 
+struct cdev *cdev_by_partuuid(const char *partuuid)
+{
+	struct cdev *cdev;
+
+	if (!partuuid)
+		return NULL;
+
+	list_for_each_entry(cdev, &cdev_list, list) {
+		if (!strcmp(cdev->partuuid, partuuid))
+			return cdev;
+	}
+	return NULL;
+}
+
 /**
  * device_find_partition - find a partition belonging to a physical device
  *
diff --git a/include/driver.h b/include/driver.h
index 3d701f24398a..8617872053d8 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -472,6 +472,7 @@ struct cdev *cdev_by_name(const char *filename);
 struct cdev *lcdev_by_name(const char *filename);
 struct cdev *cdev_readlink(struct cdev *cdev);
 struct cdev *cdev_by_device_node(struct device_node *node);
+struct cdev *cdev_by_partuuid(const char *partuuid);
 struct cdev *cdev_open(const char *name, unsigned long flags);
 struct cdev *cdev_create_loop(const char *path, ulong flags);
 void cdev_remove_loop(struct cdev *cdev);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 5/9] of: of_path: find device via partuuid
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (2 preceding siblings ...)
  2017-07-10 10:33 ` [PATCH v2 4/9] devfs-core: add function to find cdev by partuuid Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 6/9] efi: efi: load state from devicetree Steffen Trumtrar
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

When a node is compatible to a fixed-partitions, support searching the
corresponding device via the partuuid, if it specified in the device tree.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Changes since v1:
  - add documentation

 Documentation/devicetree/bindings/mtd/partition.txt | 21 +++++++++++++++++++++
 drivers/of/of_path.c                                | 17 ++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/partition.txt

diff --git a/Documentation/devicetree/bindings/mtd/partition.txt b/Documentation/devicetree/bindings/mtd/partition.txt
new file mode 100644
index 000000000000..ab21ff25bb11
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partition.txt
@@ -0,0 +1,21 @@
+Representing flash partitions in devicetree
+
+In addition to the upstream binding, another property is added:
+
+Optional properties:
+- partuuid : The partition UUID for this partition.
+
+
+Examples:
+
+flash@0 {
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		state_part: state {
+			partuuid = "16367da7-c518-499f-9aad-e1f366692365";
+		};
+	};
+};
diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index 334eab841a01..e53041b0a16c 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -56,11 +56,26 @@ static int __of_find_path(struct device_node *node, const char *part, char **out
 
 	dev = of_find_device_by_node_path(node->full_name);
 	if (!dev) {
+		int ret;
+		const char *uuid;
 		struct device_node *devnode = node->parent;
 
-		if (of_device_is_compatible(devnode, "fixed-partitions"))
+		if (of_device_is_compatible(devnode, "fixed-partitions")) {
 			devnode = devnode->parent;
 
+			/* when partuuid is specified short-circuit the search for the cdev */
+			ret = of_property_read_string(node, "partuuid", &uuid);
+			if (!ret) {
+				cdev = cdev_by_partuuid(uuid);
+				if (!cdev)
+					return -ENODEV;
+
+				*outpath = basprintf("/dev/%s", cdev->name);
+
+				return 0;
+			}
+		}
+
 		dev = of_find_device_by_node_path(devnode->full_name);
 		if (!dev)
 			return -ENODEV;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 6/9] efi: efi: load state from devicetree
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (3 preceding siblings ...)
  2017-07-10 10:33 ` [PATCH v2 5/9] of: of_path: find device via partuuid Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  2017-07-10 13:49   ` Lucas Stach
  2017-07-10 10:33 ` [PATCH v2 7/9] blspec: skip all devicetree tests if entry doesn't specify one Steffen Trumtrar
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Changes since v1:
  - add documentation

 Documentation/boards/efi.rst |  4 ++++
 common/efi/efi.c             | 56 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/Documentation/boards/efi.rst b/Documentation/boards/efi.rst
index ecadb3ebba57..8f78a800ef74 100644
--- a/Documentation/boards/efi.rst
+++ b/Documentation/boards/efi.rst
@@ -42,6 +42,10 @@ architectures. Switching to USB boot in the BIOS should then be enough to
 start barebox via USB. Some BIOSes allow to specify a path to a binary to
 be executed, others have a "start UEFI shell" entry which executes
 EFI/Shellx64.efi on the :term:`ESP`. This can be a barebox binary aswell.
+To use the :ref:`state_framework`, the describing devicetree file ``state.dtb``
+has to be put into the ``EFI/barebox/`` directory.
+Supported backends for EFI are raw partitions that can be discovered via a
+partition UUID.
 
 Running EFI barebox on qemu
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/common/efi/efi.c b/common/efi/efi.c
index f924385958e1..cc3051dedae9 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -40,6 +40,8 @@
 #include <efi.h>
 #include <efi/efi.h>
 #include <efi/efi-device.h>
+#include <libfile.h>
+#include <state.h>
 
 efi_runtime_services_t *RT;
 efi_boot_services_t *BS;
@@ -384,6 +386,60 @@ static int efi_postcore_init(void)
 }
 postcore_initcall(efi_postcore_init);
 
+static int efi_late_init(void)
+{
+	char *state_desc;
+	int ret;
+
+	state_desc = xasprintf("/boot/EFI/barebox/state.dtb");
+
+	if (state_desc) {
+		void *fdt;
+		size_t size;
+		struct device_node *root = NULL;
+		struct device_node *np = NULL;
+		struct state *state;
+
+		fdt = read_file(state_desc, &size);
+		if (!fdt) {
+			pr_err("unable to read %s: %s\n", state_desc,
+			       strerror(errno));
+			return -errno;
+		}
+
+		if (file_detect_type(fdt, size) != filetype_oftree) {
+			pr_err("%s is not an oftree file.\n", state_desc);
+			free(fdt);
+			return -EINVAL;
+		}
+
+		root = of_unflatten_dtb(fdt);
+
+		free(fdt);
+
+		if (IS_ERR(root))
+			return PTR_ERR(root);
+
+		of_set_root_node(root);
+
+		np = of_find_node_by_alias(root, "state");
+
+		state = state_new_from_node(np, NULL, 0, 0, false);
+		if (IS_ERR(state))
+			return PTR_ERR(state);
+
+		ret = state_load(state);
+		if (ret)
+			pr_warn("Failed to load persistent state, continuing with defaults, %d\n",
+				ret);
+
+		return 0;
+	}
+
+	return 0;
+}
+late_initcall(efi_late_init);
+
 static int do_efiexit(int argc, char *argv[])
 {
 	return BS->exit(efi_parent_image, EFI_SUCCESS, 0, NULL);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 7/9] blspec: skip all devicetree tests if entry doesn't specify one
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (4 preceding siblings ...)
  2017-07-10 10:33 ` [PATCH v2 6/9] efi: efi: load state from devicetree Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 8/9] efi: efi: register barebox-update handler Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 9/9] efi_defconfig: enable STATE Steffen Trumtrar
  7 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

If the blspec entry does not specify a devicetree to test against,
it doesn't make any sense to check the compatible of the machine or
find the root node.

Instead of first testing the barebox devicetree check if the entry
specifies one.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/blspec.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index 8132d141ab5c..b258e6600bbe 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -361,6 +361,14 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	const char *compat;
 	char *filename;
 
+	/* If the entry doesn't specifiy a devicetree we are compatible */
+	devicetree = blspec_entry_var_get(entry, "devicetree");
+	if (!devicetree)
+		return true;
+
+	if (!strcmp(devicetree, "none"))
+		return true;
+
 	/* If we don't have a root node every entry is compatible */
 	barebox_root = of_get_root_node();
 	if (!barebox_root)
@@ -375,14 +383,6 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	else
 		abspath = "";
 
-	/* If the entry doesn't specifiy a devicetree we are compatible */
-	devicetree = blspec_entry_var_get(entry, "devicetree");
-	if (!devicetree)
-		return true;
-
-	if (!strcmp(devicetree, "none"))
-		return true;
-
 	filename = basprintf("%s/%s", abspath, devicetree);
 
 	fdt = read_file(filename, &size);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 8/9] efi: efi: register barebox-update handler
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (5 preceding siblings ...)
  2017-07-10 10:33 ` [PATCH v2 7/9] blspec: skip all devicetree tests if entry doesn't specify one Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  2017-07-10 10:33 ` [PATCH v2 9/9] efi_defconfig: enable STATE Steffen Trumtrar
  7 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/efi/efi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/common/efi/efi.c b/common/efi/efi.c
index cc3051dedae9..2c3ad33976c4 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -42,6 +42,7 @@
 #include <efi/efi-device.h>
 #include <libfile.h>
 #include <state.h>
+#include <bbu.h>
 
 efi_runtime_services_t *RT;
 efi_boot_services_t *BS;
@@ -382,6 +383,9 @@ static int efi_postcore_init(void)
 		free(uuid16);
 	}
 
+	bbu_register_std_file_update("fat", 0,	"/boot/EFI/BOOT/BOOTx64.EFI",
+				     filetype_exe);
+
 	return 0;
 }
 postcore_initcall(efi_postcore_init);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 9/9] efi_defconfig: enable STATE
  2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (6 preceding siblings ...)
  2017-07-10 10:33 ` [PATCH v2 8/9] efi: efi: register barebox-update handler Steffen Trumtrar
@ 2017-07-10 10:33 ` Steffen Trumtrar
  7 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-10 10:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 arch/x86/configs/efi_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/configs/efi_defconfig b/arch/x86/configs/efi_defconfig
index 0d9a44a4d23e..3e83fd92d9ea 100644
--- a/arch/x86/configs/efi_defconfig
+++ b/arch/x86/configs/efi_defconfig
@@ -15,12 +15,12 @@ CONFIG_CONSOLE_ACTIVATE_ALL=y
 CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_POLLER=y
+CONFIG_STATE=y
 CONFIG_DEBUG_INFO=y
 CONFIG_DEBUG_LL=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
 CONFIG_CMD_MEMINFO=y
-# CONFIG_CMD_LINUX16 is not set
 CONFIG_CMD_GO=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_RESET=y
@@ -61,6 +61,7 @@ CONFIG_CMD_OF_NODE=y
 CONFIG_CMD_OF_PROPERTY=y
 CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_STATE=y
 CONFIG_NET=y
 CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 6/9] efi: efi: load state from devicetree
  2017-07-10 10:33 ` [PATCH v2 6/9] efi: efi: load state from devicetree Steffen Trumtrar
@ 2017-07-10 13:49   ` Lucas Stach
  2017-07-11 15:00     ` Lucas Stach
  0 siblings, 1 reply; 11+ messages in thread
From: Lucas Stach @ 2017-07-10 13:49 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

Am Montag, den 10.07.2017, 12:33 +0200 schrieb Steffen Trumtrar:
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>

This commit breaks compilation of the efi_defconfig with:
barebox/common/efi/efi.c:427: undefined reference to `state_new_from_node'
barebox/common/efi/efi.c:431: undefined reference to `state_load'

You probably don't want to compile in this initcall when !CONFIG_STATE.

Regards,
Lucas

> ---
> Changes since v1:
>   - add documentation
> 
>  Documentation/boards/efi.rst |  4 ++++
>  common/efi/efi.c             | 56 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 60 insertions(+)
> 
> diff --git a/Documentation/boards/efi.rst b/Documentation/boards/efi.rst
> index ecadb3ebba57..8f78a800ef74 100644
> --- a/Documentation/boards/efi.rst
> +++ b/Documentation/boards/efi.rst
> @@ -42,6 +42,10 @@ architectures. Switching to USB boot in the BIOS should then be enough to
>  start barebox via USB. Some BIOSes allow to specify a path to a binary to
>  be executed, others have a "start UEFI shell" entry which executes
>  EFI/Shellx64.efi on the :term:`ESP`. This can be a barebox binary aswell.
> +To use the :ref:`state_framework`, the describing devicetree file ``state.dtb``
> +has to be put into the ``EFI/barebox/`` directory.
> +Supported backends for EFI are raw partitions that can be discovered via a
> +partition UUID.
>  
>  Running EFI barebox on qemu
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> diff --git a/common/efi/efi.c b/common/efi/efi.c
> index f924385958e1..cc3051dedae9 100644
> --- a/common/efi/efi.c
> +++ b/common/efi/efi.c
> @@ -40,6 +40,8 @@
>  #include <efi.h>
>  #include <efi/efi.h>
>  #include <efi/efi-device.h>
> +#include <libfile.h>
> +#include <state.h>
>  
>  efi_runtime_services_t *RT;
>  efi_boot_services_t *BS;
> @@ -384,6 +386,60 @@ static int efi_postcore_init(void)
>  }
>  postcore_initcall(efi_postcore_init);
>  
> +static int efi_late_init(void)
> +{
> +	char *state_desc;
> +	int ret;
> +
> +	state_desc = xasprintf("/boot/EFI/barebox/state.dtb");
> +
> +	if (state_desc) {
> +		void *fdt;
> +		size_t size;
> +		struct device_node *root = NULL;
> +		struct device_node *np = NULL;
> +		struct state *state;
> +
> +		fdt = read_file(state_desc, &size);
> +		if (!fdt) {
> +			pr_err("unable to read %s: %s\n", state_desc,
> +			       strerror(errno));
> +			return -errno;
> +		}
> +
> +		if (file_detect_type(fdt, size) != filetype_oftree) {
> +			pr_err("%s is not an oftree file.\n", state_desc);
> +			free(fdt);
> +			return -EINVAL;
> +		}
> +
> +		root = of_unflatten_dtb(fdt);
> +
> +		free(fdt);
> +
> +		if (IS_ERR(root))
> +			return PTR_ERR(root);
> +
> +		of_set_root_node(root);
> +
> +		np = of_find_node_by_alias(root, "state");
> +
> +		state = state_new_from_node(np, NULL, 0, 0, false);
> +		if (IS_ERR(state))
> +			return PTR_ERR(state);
> +
> +		ret = state_load(state);
> +		if (ret)
> +			pr_warn("Failed to load persistent state, continuing with defaults, %d\n",
> +				ret);
> +
> +		return 0;
> +	}
> +
> +	return 0;
> +}
> +late_initcall(efi_late_init);
> +
>  static int do_efiexit(int argc, char *argv[])
>  {
>  	return BS->exit(efi_parent_image, EFI_SUCCESS, 0, NULL);



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 6/9] efi: efi: load state from devicetree
  2017-07-10 13:49   ` Lucas Stach
@ 2017-07-11 15:00     ` Lucas Stach
  0 siblings, 0 replies; 11+ messages in thread
From: Lucas Stach @ 2017-07-11 15:00 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

Am Montag, den 10.07.2017, 15:49 +0200 schrieb Lucas Stach:
> Am Montag, den 10.07.2017, 12:33 +0200 schrieb Steffen Trumtrar:
> > Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> 
> This commit breaks compilation of the efi_defconfig with:
> barebox/common/efi/efi.c:427: undefined reference to `state_new_from_node'
> barebox/common/efi/efi.c:431: undefined reference to `state_load'
> 
> You probably don't want to compile in this initcall when !CONFIG_STATE.

I've added a fix for this while applying.

Regards,
Lucas


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-07-11 15:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 2/9] common: efi: do not use undefined kconfig option Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 3/9] fs: efi: return with correct error code in efifs_stat Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 4/9] devfs-core: add function to find cdev by partuuid Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 5/9] of: of_path: find device via partuuid Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 6/9] efi: efi: load state from devicetree Steffen Trumtrar
2017-07-10 13:49   ` Lucas Stach
2017-07-11 15:00     ` Lucas Stach
2017-07-10 10:33 ` [PATCH v2 7/9] blspec: skip all devicetree tests if entry doesn't specify one Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 8/9] efi: efi: register barebox-update handler Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 9/9] efi_defconfig: enable STATE Steffen Trumtrar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox