summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay73@gmail.com>2015-10-27 11:00:27 +0100
committerTom Rini <trini@konsulko.com>2015-11-12 15:58:58 -0500
commit7561b258a1bdda25daee78824a400d48921f4802 (patch)
tree9947bb71da958c871e8ab8cbe246088f6cb3e118 /disk
parentb38c108a9833ca2acb568530ebd269760f3925d9 (diff)
downloadu-boot-imx-7561b258a1bdda25daee78824a400d48921f4802.zip
u-boot-imx-7561b258a1bdda25daee78824a400d48921f4802.tar.gz
u-boot-imx-7561b258a1bdda25daee78824a400d48921f4802.tar.bz2
gpt: add optional parameter type in gpt command
code under flag CONFIG_PARTITION_TYPE_GUID add parameter "type" to select partition type guid example of use with gpt command : partitions = uuid_disk=${uuid_gpt_disk}; \ name=boot,size=0x6bc00,uuid=${uuid_gpt_boot}; \ name=root,size=0x7538ba00,uuid=${uuid_gpt_root}, \ type=0fc63daf-8483-4772-8e79-3d69d8477de4; gpt write mmc 0 $partitions Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
Diffstat (limited to 'disk')
-rw-r--r--disk/part.c9
-rw-r--r--disk/part_efi.c25
2 files changed, 34 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c
index e57a252..909712e 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -392,6 +392,9 @@ int get_partition_info(block_dev_desc_t *dev_desc, int part,
/* The common case is no UUID support */
info->uuid[0] = 0;
#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ info->type_guid[0] = 0;
+#endif
switch (dev_desc->part_type) {
#ifdef CONFIG_MAC_PARTITION
@@ -532,6 +535,9 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
#ifdef CONFIG_PARTITION_UUIDS
info->uuid[0] = 0;
#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ info->type_guid[0] = 0;
+#endif
return 0;
}
@@ -639,6 +645,9 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
#ifdef CONFIG_PARTITION_UUIDS
info->uuid[0] = 0;
#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ info->type_guid[0] = 0;
+#endif
ret = 0;
goto cleanup;
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 15627f2..c124143 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -283,6 +283,10 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
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);
@@ -419,6 +423,10 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
char *str_uuid;
unsigned char *bin_uuid;
#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ char *str_type_guid;
+ unsigned char *bin_type_guid;
+#endif
for (i = 0; i < parts; i++) {
/* partition starting lba */
@@ -445,9 +453,26 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
else
gpt_e[i].ending_lba = cpu_to_le64(offset - 1);
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ str_type_guid = partitions[i].type_guid;
+ bin_type_guid = gpt_e[i].partition_type_guid.b;
+ if (strlen(str_type_guid)) {
+ if (uuid_str_to_bin(str_type_guid, bin_type_guid,
+ UUID_STR_FORMAT_GUID)) {
+ printf("Partition no. %d: invalid type guid: %s\n",
+ i, str_type_guid);
+ return -1;
+ }
+ } else {
+ /* default partition type GUID */
+ memcpy(bin_type_guid,
+ &PARTITION_BASIC_DATA_GUID, 16);
+ }
+#else
/* partition type GUID */
memcpy(gpt_e[i].partition_type_guid.b,
&PARTITION_BASIC_DATA_GUID, 16);
+#endif
#ifdef CONFIG_PARTITION_UUIDS
str_uuid = partitions[i].uuid;