]> Git Repo - J-u-boot.git/blobdiff - common/avb_verify.c
avb2.0: add get_size_of_partition()
[J-u-boot.git] / common / avb_verify.c
index f9a00f8871c0c13c7b35a9ff6e6f0999cfddfa7e..82ddebcfc24ebe6954c71ced7ab798f3155108f7 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <avb_verify.h>
+#include <blk.h>
 #include <fastboot.h>
 #include <image.h>
 #include <malloc.h>
@@ -288,8 +289,8 @@ static unsigned long mmc_read_and_flush(struct mmc_part *part,
                tmp_buf = buffer;
        }
 
-       blks = part->mmc->block_dev.block_read(part->mmc_blk,
-                               start, sectors, tmp_buf);
+       blks = blk_dread(part->mmc_blk,
+                        start, sectors, tmp_buf);
        /* flush cache after read */
        flush_cache((ulong)tmp_buf, sectors * part->info.blksz);
 
@@ -327,8 +328,8 @@ static unsigned long mmc_write(struct mmc_part *part, lbaint_t start,
                tmp_buf = buffer;
        }
 
-       return part->mmc->block_dev.block_write(part->mmc_blk,
-                               start, sectors, tmp_buf);
+       return blk_dwrite(part->mmc_blk,
+                         start, sectors, tmp_buf);
 }
 
 static struct mmc_part *get_partition(AvbOps *ops, const char *partition)
@@ -698,6 +699,37 @@ static AvbIOResult get_unique_guid_for_partition(AvbOps *ops,
        return AVB_IO_RESULT_OK;
 }
 
+/**
+ * get_size_of_partition() - gets the size of a partition identified
+ * by a string name
+ *
+ * @ops: contains AVB ops handlers
+ * @partition: partition name (NUL-terminated UTF-8 string)
+ * @out_size_num_bytes: returns the value of a partition size
+ *
+ * @return:
+ *      AVB_IO_RESULT_OK, on success (GUID found)
+ *      AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE, out_size_num_bytes is NULL
+ *      AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION, if partition was not found
+ */
+static AvbIOResult get_size_of_partition(AvbOps *ops,
+                                        const char *partition,
+                                        u64 *out_size_num_bytes)
+{
+       struct mmc_part *part;
+
+       if (!out_size_num_bytes)
+               return AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE;
+
+       part = get_partition(ops, partition);
+       if (!part)
+               return AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION;
+
+       *out_size_num_bytes = part->info.blksz * part->info.size;
+
+       return AVB_IO_RESULT_OK;
+}
+
 /**
  * ============================================================================
  * AVB2.0 AvbOps alloc/initialisation/free
@@ -721,7 +753,7 @@ AvbOps *avb_ops_alloc(int boot_device)
        ops_data->ops.read_is_device_unlocked = read_is_device_unlocked;
        ops_data->ops.get_unique_guid_for_partition =
                get_unique_guid_for_partition;
-
+       ops_data->ops.get_size_of_partition = get_size_of_partition;
        ops_data->mmc_dev = boot_device;
 
        return &ops_data->ops;
This page took 0.024723 seconds and 4 git commands to generate.