summaryrefslogtreecommitdiff
path: root/disk/part_efi.c
diff options
context:
space:
mode:
Diffstat (limited to 'disk/part_efi.c')
-rw-r--r--disk/part_efi.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 2fef7e7b41..2d7a7b85d7 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -125,8 +125,17 @@ void print_part_efi(block_dev_desc_t * dev_desc)
/* This function validates AND fills in the GPT header and PTE */
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
gpt_head, &gpt_pte) != 1) {
- printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
- goto failure;
+ printf("%s: *** ERROR: Invalid Primary GPT ***\n", __func__);
+ /* Testing secondary GPT */
+ if(is_gpt_valid(dev_desc, dev_desc->lba - 1,
+ gpt_head, &gpt_pte) != 1) {
+ printf("%s: *** ERROR: Invalid Secondary GPT ***\n", __func__);
+ goto failure;
+ }
+ else
+ {
+ /* Fix primary GPT here */
+ }
}
debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -175,9 +184,18 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
/* This function validates AND fills in the GPT header and PTE */
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
gpt_head, &gpt_pte) != 1) {
- printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
- err = -1;
- goto failure;
+ printf("%s: *** ERROR: Invalid Primary GPT ***\n", __func__);
+ /* Testing secondary GPT */
+ if(is_gpt_valid(dev_desc, dev_desc->lba-1,
+ gpt_head, &gpt_pte) != 1) {
+ printf("%s: *** ERROR: Invalid Secondary GPT ***\n", __func__);
+ err = -1;
+ goto failure;
+ }
+ else
+ {
+ /* Fix primary GPT here */
+ }
}
/* The ulong casting limits the maximum disk size to 2 TB */
@@ -398,6 +416,8 @@ static gpt_entry *alloc_read_gpt_entries(block_dev_desc_t * dev_desc,
le32_to_int(pgpt_head->num_partition_entries),
le32_to_int(pgpt_head->sizeof_partition_entry), count);
+ /* Set count to be a multiple of 512 */
+ count = ((count+GPT_BLOCK_SIZE-1) / GPT_BLOCK_SIZE) * GPT_BLOCK_SIZE;
/* Allocate memory for PTE, remember to FREE */
if (count != 0) {
pte = memalign(CACHE_LINE_SIZE, count);