]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bloblist: add API to check the register conventions
authorRaymond Mao <raymond.mao@linaro.org>
Sat, 3 Feb 2024 16:36:20 +0000 (08:36 -0800)
committerTom Rini <trini@konsulko.com>
Thu, 29 Feb 2024 14:24:21 +0000 (09:24 -0500)
Add bloblist_check_reg_conv() to check whether the bloblist is compliant
to the register conventions defined in Firmware Handoff specification.
This API can be used for all Arm platforms.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
common/bloblist.c
include/bloblist.h

index 2d373910b6d0c34c6b7322c05e22152cc5d7cb6b..980b1ddbcb4f697763fd7b1c70e956a13cc073e5 100644 (file)
@@ -542,3 +542,14 @@ int bloblist_maybe_init(void)
 
        return 0;
 }
+
+int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig)
+{
+       if (rzero || rsig != (BLOBLIST_MAGIC | BLOBLIST_REGCONV_VER) ||
+           rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) {
+               gd->bloblist = NULL;  /* Reset the gd bloblist pointer */
+               return -EIO;
+       }
+
+       return 0;
+}
index 84fc9438191c0df0afc7a236f7c074605e2f374b..f7e800f6812792e4ca44556056d53cc5c010599b 100644 (file)
@@ -78,6 +78,13 @@ enum {
        BLOBLIST_VERSION        = 1,
        BLOBLIST_MAGIC          = 0x4a0fb10b,
 
+       /*
+        * FIXME:
+        * Register convention version should be placed into a higher byte
+        * https://github.com/FirmwareHandoff/firmware_handoff/issues/32
+        */
+       BLOBLIST_REGCONV_VER    = 1 << 24,
+
        BLOBLIST_BLOB_ALIGN_LOG2 = 3,
        BLOBLIST_BLOB_ALIGN      = 1 << BLOBLIST_BLOB_ALIGN_LOG2,
 
@@ -461,4 +468,17 @@ static inline int bloblist_maybe_init(void)
 }
 #endif /* BLOBLIST */
 
+/**
+ * bloblist_check_reg_conv() - Check whether the bloblist is compliant to
+ *                            the register conventions according to the
+ *                            Firmware Handoff spec.
+ *
+ * @rfdt:  Register that holds the FDT base address.
+ * @rzero: Register that must be zero.
+ * @rsig:  Register that holds signature and register conventions version.
+ * Return: 0 if OK, -EIO if the bloblist is not compliant to the register
+ *        conventions.
+ */
+int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig);
+
 #endif /* __BLOBLIST_H */