@@ -209,6 +209,32 @@ static void part_print_gpt(gpt_header *gpt_head,
}
}
+static void part_get_disk_info(int part, unsigned int blksz,
+ gpt_entry *gpt_pte, disk_partition_t *info)
+{
+ /* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */
+ info->start = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].starting_lba);
+ /* The ending LBA is inclusive, to calculate size, add 1 to it */
+ info->size = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1
+ - info->start;
+ info->blksz = blksz;
+
+ sprintf((char *)info->name, "%s", print_efiname(&gpt_pte[part - 1]));
+ strcpy((char *)info->type, "U-Boot");
+ info->bootable = is_bootable(&gpt_pte[part - 1]);
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
+ UUID_STR_FORMAT_GUID);
+#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
+ info->type_guid, UUID_STR_FORMAT_GUID);
+#endif
+
+ debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__,
+ info->start, info->size, info->name);
+}
+
/*
* Public Functions (include/part.h)
*/
@@ -275,28 +301,7 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
return -1;
}
- /* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */
- info->start = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].starting_lba);
- /* The ending LBA is inclusive, to calculate size, add 1 to it */
- info->size = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1
- - info->start;
- info->blksz = dev_desc->blksz;
-
- sprintf((char *)info->name, "%s",
- print_efiname(&gpt_pte[part - 1]));
- strcpy((char *)info->type, "U-Boot");
- info->bootable = is_bootable(&gpt_pte[part - 1]);
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
- UUID_STR_FORMAT_GUID);
-#endif
-#ifdef CONFIG_PARTITION_TYPE_GUID
- uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
- info->type_guid, UUID_STR_FORMAT_GUID);
-#endif
-
- debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__,
- info->start, info->size, info->name);
+ part_get_disk_info(part, dev_desc->blksz, gpt_pte, info);
/* Remember to free pte */
free(gpt_pte);