diff options
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part.c | 6 | ||||
-rw-r--r-- | disk/part_efi.c | 30 | ||||
-rw-r--r-- | disk/part_efi.h | 4 |
3 files changed, 32 insertions, 8 deletions
diff --git a/disk/part.c b/disk/part.c index c79585f3dda..af6e0a60d2c 100644 --- a/disk/part.c +++ b/disk/part.c @@ -386,8 +386,9 @@ static void print_part_header (const char *type, block_dev_desc_t * dev_desc) void print_part (block_dev_desc_t * dev_desc) { - - switch (dev_desc->part_type) { + /* Force EFI */ + dev_desc->part_type = PART_TYPE_EFI; + switch (dev_desc->part_type) { #ifdef CONFIG_MAC_PARTITION case PART_TYPE_MAC: PRINTF ("## Testing for valid MAC partition ##\n"); @@ -418,7 +419,6 @@ void print_part (block_dev_desc_t * dev_desc) print_part_amiga (dev_desc); return; #endif - #ifdef CONFIG_EFI_PARTITION case PART_TYPE_EFI: PRINTF ("## Testing for valid EFI partition ##\n"); diff --git a/disk/part_efi.c b/disk/part_efi.c index 2fef7e7b417..2d7a7b85d74 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); diff --git a/disk/part_efi.h b/disk/part_efi.h index 6bbb06bde90..adf4e55f3b7 100644 --- a/disk/part_efi.h +++ b/disk/part_efi.h @@ -39,7 +39,11 @@ #define GPT_BLOCK_SIZE 512 #define GPT_HEADER_SIGNATURE 0x5452415020494645ULL #define GPT_HEADER_REVISION_V1 0x00010000 +#ifndef GPT_PRIMARY_PARTITION_TABLE_LBA +/* might be defined in colibri_t20.h when the device uses the nvidia partitioning + * and the GPT doesn't start at its default sector */ #define GPT_PRIMARY_PARTITION_TABLE_LBA 1ULL +#endif #define GPT_ENTRY_NAME "gpt" #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ |