diff options
author | Tom Warren <twarren@nvidia.com> | 2011-08-30 10:10:21 -0700 |
---|---|---|
committer | Doug Anderson <dianders@chromium.org> | 2011-10-19 16:41:44 -0700 |
commit | cc06c984f08bd9ded99272f3bcb72f939b14ee56 (patch) | |
tree | 7caf0d458e5e8492225236c9f6b93a4d88202422 /disk | |
parent | 27a3cee0d07e2e4a53697379919d1d2ab93743b5 (diff) |
CHROMIUM: 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).
NOTE: this is based on an original change from nVidia (see Original-
lines below), but was modified to remove the unnecessary use of a
global variable.
BUG=chromium-os:21540
TEST=Can now run 'mmc rescan 1' and 'mmc part 1' on T30 board
(with WIP t30 patches applied).
TEST=No can still do mmc commands on Kaen.
Change-Id: I0e70bbde3a130b93bf3dd862e1330b41088dd0b0
Original-Change-Id: Idf877d17753b7f4da0180f342276ac28249e1980
Original-Reviewed-on: http://git-master/r/49880
Original-Tested-by: Tom Warren <twarren@nvidia.com>
Original-Reviewed-by: Tom Warren <twarren@nvidia.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/10271
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part_efi.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c index d435e68f988..2fef7e7b417 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -110,7 +110,7 @@ static int is_pte_valid(gpt_entry * pte); void print_part_efi(block_dev_desc_t * dev_desc) { gpt_header *gpt_head = memalign(CACHE_LINE_SIZE, sizeof(gpt_header)); - gpt_entry **pgpt_pte = NULL; + gpt_entry *gpt_pte = NULL; int i = 0; if (gpt_head == NULL) { @@ -124,31 +124,28 @@ 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, pgpt_pte) != 1) { + gpt_head, &gpt_pte) != 1) { printf("%s: *** ERROR: Invalid GPT ***\n", __func__); goto failure; } - 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 Start LBA End LBA\n"); 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("%s%d 0x%llX 0x%llX\n", GPT_ENTRY_NAME, (i + 1), - le64_to_int((*pgpt_pte)[i].starting_lba), - le64_to_int((*pgpt_pte)[i].ending_lba)); + le64_to_int(gpt_pte[i].starting_lba), + le64_to_int(gpt_pte[i].ending_lba)); } else { break; /* Stop at the first non valid PTE */ } } /* Remember to free pte */ - if (*pgpt_pte != NULL) { - debug("%s: Freeing pgpt_pte\n", __func__); - free(*pgpt_pte); - } + free(gpt_pte); failure: free(gpt_head); @@ -160,7 +157,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, disk_partition_t * info) { gpt_header *gpt_head = memalign(CACHE_LINE_SIZE, sizeof(gpt_header)); - gpt_entry **pgpt_pte = NULL; + gpt_entry *gpt_pte = NULL; int err = 0; if (gpt_head == NULL) { @@ -177,16 +174,16 @@ 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, pgpt_pte) != 1) { + gpt_head, &gpt_pte) != 1) { printf("%s: *** ERROR: Invalid GPT ***\n", __func__); err = -1; goto failure; } /* 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 */ - 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->blksz = GPT_BLOCK_SIZE; @@ -197,10 +194,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, info->start, info->size, info->name); /* Remember to free pte */ - if (*pgpt_pte != NULL) { - debug("%s: Freeing pgpt_pte\n", __func__); - free(*pgpt_pte); - } + free(gpt_pte); failure: free(gpt_head); @@ -369,9 +363,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), calc_crc32); - if (*pgpt_pte != NULL) { - free(*pgpt_pte); - } + free(*pgpt_pte); return 0; } |