mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-20 22:21:41 +00:00
disk: part_efi: fix **pgpt_pte == NULL
Code was setting **pgpt_pte == NULL, which meant that the pointer to the gpt_pte would be stored at RAM address 00000000. This 'worked' on T20 (SDRAM starts @ 0x00000000), but hung gpt/EFI access on T30 (SDRAM starts @ 0x80000000). Signed-off-by: Tom Warren <twarren@nvidia.com> Signed-off-by: Doug Anderson <dianders@chromium.org>
This commit is contained in:
parent
df70b1c2e2
commit
deb5ca8027
1 changed files with 15 additions and 23 deletions
|
@ -121,7 +121,7 @@ static char *print_efiname(gpt_entry *pte)
|
||||||
void print_part_efi(block_dev_desc_t * dev_desc)
|
void print_part_efi(block_dev_desc_t * dev_desc)
|
||||||
{
|
{
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(gpt_header, gpt_head, 1);
|
ALLOC_CACHE_ALIGN_BUFFER(gpt_header, gpt_head, 1);
|
||||||
gpt_entry **pgpt_pte = NULL;
|
gpt_entry *gpt_pte = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!dev_desc) {
|
if (!dev_desc) {
|
||||||
|
@ -130,31 +130,28 @@ void print_part_efi(block_dev_desc_t * dev_desc)
|
||||||
}
|
}
|
||||||
/* This function validates AND fills in the GPT header and PTE */
|
/* This function validates AND fills in the GPT header and PTE */
|
||||||
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
|
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
|
||||||
gpt_head, pgpt_pte) != 1) {
|
&(gpt_head), &gpt_pte) != 1) {
|
||||||
printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
|
printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("%s: gpt-entry at 0x%08X\n", __func__, (unsigned int)*pgpt_pte);
|
debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
|
||||||
|
|
||||||
printf("Part\tName\t\t\tStart LBA\tEnd LBA\n");
|
printf("Part\tName\t\t\tStart LBA\tEnd LBA\n");
|
||||||
for (i = 0; i < le32_to_int(gpt_head->num_partition_entries); i++) {
|
for (i = 0; i < le32_to_int(gpt_head->num_partition_entries); i++) {
|
||||||
|
|
||||||
if (is_pte_valid(&(*pgpt_pte)[i])) {
|
if (is_pte_valid(&gpt_pte[i])) {
|
||||||
printf("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1),
|
printf("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1),
|
||||||
print_efiname(&(*pgpt_pte)[i]),
|
print_efiname(&gpt_pte[i]),
|
||||||
le64_to_int((*pgpt_pte)[i].starting_lba),
|
le64_to_int(gpt_pte[i].starting_lba),
|
||||||
le64_to_int((*pgpt_pte)[i].ending_lba));
|
le64_to_int(gpt_pte[i].ending_lba));
|
||||||
} else {
|
} else {
|
||||||
break; /* Stop at the first non valid PTE */
|
break; /* Stop at the first non valid PTE */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remember to free pte */
|
/* Remember to free pte */
|
||||||
if (*pgpt_pte != NULL) {
|
free(gpt_pte);
|
||||||
debug("%s: Freeing pgpt_pte\n", __func__);
|
|
||||||
free(*pgpt_pte);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +159,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
|
||||||
disk_partition_t * info)
|
disk_partition_t * info)
|
||||||
{
|
{
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(gpt_header, gpt_head, 1);
|
ALLOC_CACHE_ALIGN_BUFFER(gpt_header, gpt_head, 1);
|
||||||
gpt_entry **pgpt_pte = NULL;
|
gpt_entry *gpt_pte = NULL;
|
||||||
|
|
||||||
/* "part" argument must be at least 1 */
|
/* "part" argument must be at least 1 */
|
||||||
if (!dev_desc || !info || part < 1) {
|
if (!dev_desc || !info || part < 1) {
|
||||||
|
@ -172,30 +169,27 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
|
||||||
|
|
||||||
/* This function validates AND fills in the GPT header and PTE */
|
/* This function validates AND fills in the GPT header and PTE */
|
||||||
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
|
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
|
||||||
gpt_head, pgpt_pte) != 1) {
|
&(gpt_head), &gpt_pte) != 1) {
|
||||||
printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
|
printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The ulong casting limits the maximum disk size to 2 TB */
|
/* The ulong casting limits the maximum disk size to 2 TB */
|
||||||
info->start = (ulong) le64_to_int((*pgpt_pte)[part - 1].starting_lba);
|
info->start = (ulong) le64_to_int(gpt_pte[part - 1].starting_lba);
|
||||||
/* The ending LBA is inclusive, to calculate size, add 1 to it */
|
/* The ending LBA is inclusive, to calculate size, add 1 to it */
|
||||||
info->size = ((ulong)le64_to_int((*pgpt_pte)[part - 1].ending_lba) + 1)
|
info->size = ((ulong)le64_to_int(gpt_pte[part - 1].ending_lba) + 1)
|
||||||
- info->start;
|
- info->start;
|
||||||
info->blksz = GPT_BLOCK_SIZE;
|
info->blksz = GPT_BLOCK_SIZE;
|
||||||
|
|
||||||
sprintf((char *)info->name, "%s",
|
sprintf((char *)info->name, "%s",
|
||||||
print_efiname(&(*pgpt_pte)[part - 1]));
|
print_efiname(&gpt_pte[part - 1]));
|
||||||
sprintf((char *)info->type, "U-Boot");
|
sprintf((char *)info->type, "U-Boot");
|
||||||
|
|
||||||
debug("%s: start 0x%lX, size 0x%lX, name %s", __func__,
|
debug("%s: start 0x%lX, size 0x%lX, name %s", __func__,
|
||||||
info->start, info->size, info->name);
|
info->start, info->size, info->name);
|
||||||
|
|
||||||
/* Remember to free pte */
|
/* Remember to free pte */
|
||||||
if (*pgpt_pte != NULL) {
|
free(gpt_pte);
|
||||||
debug("%s: Freeing pgpt_pte\n", __func__);
|
|
||||||
free(*pgpt_pte);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,9 +343,7 @@ static int is_gpt_valid(block_dev_desc_t * dev_desc, unsigned long long lba,
|
||||||
le32_to_int(pgpt_head->partition_entry_array_crc32),
|
le32_to_int(pgpt_head->partition_entry_array_crc32),
|
||||||
calc_crc32);
|
calc_crc32);
|
||||||
|
|
||||||
if (*pgpt_pte != NULL) {
|
free(*pgpt_pte);
|
||||||
free(*pgpt_pte);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue