summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-03-22 14:39:01 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-23 12:16:25 +0100
commitd2e7b10d2cb3b97dcad6a45bd97a3857cbc3db66 (patch)
tree93d886dcf6e298e10c41918503c346ccd6238e20 /include
parent5ef1dfb28ad9b95f5366b4c8cc4bfc20cd789e94 (diff)
downloadbarebox-d2e7b10d2cb3b97dcad6a45bd97a3857cbc3db66.tar.gz
barebox-d2e7b10d2cb3b97dcad6a45bd97a3857cbc3db66.tar.xz
ARM: make ARM_USE_COMPRESSED_DTB available for other arches
Other PBL-enabled architecture can benefit from compressed dtbs as well. Move symbol and code to a comm place to be able to use it from RISC-V in a later commit. In order not to break out of tree boards at runtime, the old symbol name is maintained for ARM. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/compressed-dtb.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/compressed-dtb.h b/include/compressed-dtb.h
new file mode 100644
index 0000000000..1ba98a7e2b
--- /dev/null
+++ b/include/compressed-dtb.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef COMPRESSED_DTB_H_
+#define COMPRESSED_DTB_H_
+
+#include <linux/types.h>
+#include <asm/unaligned.h>
+
+struct barebox_boarddata_compressed_dtb {
+#define BAREBOX_BOARDDATA_COMPRESSED_DTB_MAGIC 0x7b66bcbd
+ u32 magic;
+ u32 datalen;
+ u32 datalen_uncompressed;
+};
+
+static inline bool blob_is_compressed_fdt(const void *blob)
+{
+ const struct barebox_boarddata_compressed_dtb *dtb = blob;
+
+ return dtb->magic == BAREBOX_BOARDDATA_COMPRESSED_DTB_MAGIC;
+}
+
+static inline bool fdt_blob_can_be_decompressed(const void *blob)
+{
+ return IS_ENABLED(CONFIG_USE_COMPRESSED_DTB) && blob
+ && blob_is_compressed_fdt(blob);
+}
+
+static inline bool blob_is_fdt(const void *blob)
+{
+ return get_unaligned_be32(blob) == FDT_MAGIC;
+}
+
+#endif