]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - disk/part_efi.c
disk: support devices with HW partitions
[karo-tx-uboot.git] / disk / part_efi.c
index a280ab5be5dc63e9e66286742fc409dfb2b959d6..c74b7b91705b8eb1b21385127d5fbbc8d45cbe28 100644 (file)
@@ -93,15 +93,23 @@ void print_part_efi(block_dev_desc_t * dev_desc)
        if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
                         gpt_head, &gpt_pte) != 1) {
                printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-               return;
+               if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+                                gpt_head, &gpt_pte) != 1) {
+                       printf("%s: *** ERROR: Invalid Backup GPT ***\n",
+                              __func__);
+                       return;
+               } else {
+                       printf("%s: ***        Using Backup GPT ***\n",
+                              __func__);
+               }
        }
 
        debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
 
        printf("Part\tStart LBA\tEnd LBA\t\tName\n");
        printf("\tAttributes\n");
-       printf("\tType UUID\n");
-       printf("\tPartition UUID\n");
+       printf("\tType GUID\n");
+       printf("\tPartition GUID\n");
 
        for (i = 0; i < le32_to_cpu(gpt_head->num_partition_entries); i++) {
                /* Stop at the first non valid PTE */
@@ -114,11 +122,11 @@ void print_part_efi(block_dev_desc_t * dev_desc)
                        print_efiname(&gpt_pte[i]));
                printf("\tattrs:\t0x%016llx\n", gpt_pte[i].attributes.raw);
                uuid_bin = (unsigned char *)gpt_pte[i].partition_type_guid.b;
-               uuid_bin_to_str(uuid_bin, uuid);
+               uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
                printf("\ttype:\t%s\n", uuid);
                uuid_bin = (unsigned char *)gpt_pte[i].unique_partition_guid.b;
-               uuid_bin_to_str(uuid_bin, uuid);
-               printf("\tuuid:\t%s\n", uuid);
+               uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
+               printf("\tguid:\t%s\n", uuid);
        }
 
        /* Remember to free pte */
@@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
        if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
                        gpt_head, &gpt_pte) != 1) {
                printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-               return -1;
+               if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+                                gpt_head, &gpt_pte) != 1) {
+                       printf("%s: *** ERROR: Invalid Backup GPT ***\n",
+                              __func__);
+                       return -1;
+               } else {
+                       printf("%s: ***        Using Backup GPT ***\n",
+                              __func__);
+               }
        }
 
        if (part > le32_to_cpu(gpt_head->num_partition_entries) ||
@@ -165,7 +181,8 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
        sprintf((char *)info->type, "U-Boot");
        info->bootable = is_bootable(&gpt_pte[part - 1]);
 #ifdef CONFIG_PARTITION_UUIDS
-       uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid);
+       uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
+                       UUID_STR_FORMAT_GUID);
 #endif
 
        debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s", __func__,
@@ -251,7 +268,7 @@ int write_gpt_table(block_dev_desc_t *dev_desc,
            != pte_blk_cnt)
                goto err;
 
-       /* recalculate the values for the Second GPT Header */
+       /* recalculate the values for the Backup GPT Header */
        val = le64_to_cpu(gpt_h->my_lba);
        gpt_h->my_lba = gpt_h->alternate_lba;
        gpt_h->alternate_lba = cpu_to_le64(val);
@@ -323,7 +340,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
                str_uuid = partitions[i].uuid;
                bin_uuid = gpt_e[i].unique_partition_guid.b;
 
-               if (uuid_str_to_bin(str_uuid, bin_uuid)) {
+               if (uuid_str_to_bin(str_uuid, bin_uuid, UUID_STR_FORMAT_STD)) {
                        printf("Partition no. %d: invalid guid: %s\n",
                                i, str_uuid);
                        return -1;
@@ -370,7 +387,7 @@ int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
        gpt_h->header_crc32 = 0;
        gpt_h->partition_entry_array_crc32 = 0;
 
-       if (uuid_str_to_bin(str_guid, gpt_h->disk_guid.b))
+       if (uuid_str_to_bin(str_guid, gpt_h->disk_guid.b, UUID_STR_FORMAT_GUID))
                return -1;
 
        return 0;