X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=disk%2Fpart_efi.c;h=f1f3e5bceff74259a190391efaab502cd4486ea6;hb=da158ec5f2db86d88a631c05c540ba5ee1937a77;hp=60b1c1d7618ee3472750a10a9ac0c9bc94024983;hpb=b7e7831e5d5be047f421ddc1f308afc22764a893;p=platform%2Fkernel%2Fu-boot.git diff --git a/disk/part_efi.c b/disk/part_efi.c index 60b1c1d..f1f3e5b 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -22,18 +23,18 @@ #include #include #include +#include #include #include #include -DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_HAVE_BLOCK_DEVICE -/* - * GUID for basic data partions. - */ +/* GUID for basic data partitons */ +#if CONFIG_IS_ENABLED(EFI_PARTITION) static const efi_guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID; +#endif -#ifdef CONFIG_HAVE_BLOCK_DEVICE /** * efi_crc32() - EFI version of crc32 function * @buf: buffer to calculate crc32 of @@ -220,8 +221,7 @@ void part_print_efi(struct blk_desc *dev_desc) ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz); gpt_entry *gpt_pte = NULL; int i = 0; - char uuid[UUID_STR_LEN + 1]; - unsigned char *uuid_bin; + unsigned char *uuid; /* This function validates AND fills in the GPT header and PTE */ if (find_valid_gpt(dev_desc, gpt_head, &gpt_pte) != 1) @@ -235,25 +235,22 @@ void part_print_efi(struct blk_desc *dev_desc) printf("\tPartition GUID\n"); for (i = 0; i < le32_to_cpu(gpt_head->num_partition_entries); i++) { - /* Stop at the first non valid PTE */ + /* Skip invalid PTE */ if (!is_pte_valid(&gpt_pte[i])) - break; + continue; printf("%3d\t0x%08llx\t0x%08llx\t\"%s\"\n", (i + 1), le64_to_cpu(gpt_pte[i].starting_lba), le64_to_cpu(gpt_pte[i].ending_lba), 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_STR_FORMAT_GUID); - printf("\ttype:\t%s\n", uuid); -#ifdef CONFIG_PARTITION_TYPE_GUID - if (!uuid_guid_get_str(uuid_bin, uuid)) - printf("\ttype:\t%s\n", uuid); -#endif - uuid_bin = (unsigned char *)gpt_pte[i].unique_partition_guid.b; - uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID); - printf("\tguid:\t%s\n", uuid); + uuid = (unsigned char *)gpt_pte[i].partition_type_guid.b; + if (CONFIG_IS_ENABLED(PARTITION_TYPE_GUID)) + printf("\ttype:\t%pUl\n\t\t(%pUs)\n", uuid, uuid); + else + printf("\ttype:\t%pUl\n", uuid); + uuid = (unsigned char *)gpt_pte[i].unique_partition_guid.b; + printf("\tguid:\t%pUl\n", uuid); } /* Remember to free pte */ @@ -329,7 +326,7 @@ static int part_test_efi(struct blk_desc *dev_desc) * set_protective_mbr(): Set the EFI protective MBR * @param dev_desc - block device descriptor * - * @return - zero on success, otherwise error + * Return: - zero on success, otherwise error */ static int set_protective_mbr(struct blk_desc *dev_desc) { @@ -560,9 +557,8 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc) * from the start of the device) to be specified as a property * of the device tree '/config' node. */ - config_offset = fdtdec_get_config_int(gd->fdt_blob, - "u-boot,efi-partition-entries-offset", - -EINVAL); + config_offset = ofnode_conf_read_int( + "u-boot,efi-partition-entries-offset", -EINVAL); if (config_offset != -EINVAL) { offset_bytes = PAD_TO_BLOCKSIZE(config_offset, dev_desc); offset_blks = offset_bytes / dev_desc->blksz; @@ -690,6 +686,15 @@ int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head, /* Free pte before allocating again */ free(*gpt_pte); + /* + * Check that the alternate_lba entry points to the last LBA + */ + if (le64_to_cpu(gpt_head->alternate_lba) != (dev_desc->lba - 1)) { + printf("%s: *** ERROR: Misplaced Backup 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", @@ -866,6 +871,9 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf) return 1; } + /* Update the partition table entries*/ + part_init(dev_desc); + return 0; } #endif @@ -1112,4 +1120,4 @@ U_BOOT_PART_TYPE(a_efi) = { .print = part_print_ptr(part_print_efi), .test = part_test_efi, }; -#endif +#endif /* CONFIG_HAVE_BLOCK_DEVICE */