summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
Diffstat (limited to 'disk')
-rw-r--r--disk/part_efi.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c
index ee9d64703d..b778106449 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -280,8 +280,10 @@ void part_print_efi(struct blk_desc *dev_desc)
printf("\tguid:\t%s\n", uuid);
}
+#if !defined(CONFIG_DUAL_BOOTLOADER) || !defined(CONFIG_SPL_BUILD)
/* Remember to free pte */
free(gpt_pte);
+#endif
return;
}
@@ -316,7 +318,9 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
!is_pte_valid(&gpt_pte[part - 1])) {
debug("%s: *** ERROR: Invalid partition number %d ***\n",
__func__, part);
+#if !defined(CONFIG_DUAL_BOOTLOADER) || !defined(CONFIG_SPL_BUILD)
free(gpt_pte);
+#endif
return -1;
}
@@ -343,8 +347,14 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__,
info->start, info->size, info->name);
- /* Remember to free pte */
+#if !defined(CONFIG_DUAL_BOOTLOADER) || !defined(CONFIG_SPL_BUILD)
+ /* Heap memory is very limited in SPL, if the dual bootloader is
+ * enabled, just load pte to dram instead of oc-ram. In such case,
+ * this part of memory shouldn't be freed. But in common routine,
+ * don't forget to free the memory after use.
+ */
free(gpt_pte);
+#endif
return 0;
}
@@ -1039,10 +1049,17 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
}
if (validate_gpt_entries(pgpt_head, *pgpt_pte)) {
+
+#if !defined(CONFIG_DUAL_BOOTLOADER) || !defined(CONFIG_SPL_BUILD)
+ /* Heap memory is very limited in SPL, if the dual bootloader is
+ * enabled, just load pte to dram instead of oc-ram. In such case,
+ * this part of memory shouldn't be freed. But in common routine,
+ * don't forget to free the memory after use.
+ */
free(*pgpt_pte);
+#endif
return 0;
}
-
/* We're done, all's well */
return 1;
}
@@ -1076,10 +1093,19 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
(u32) le32_to_cpu(pgpt_head->sizeof_partition_entry),
(ulong)count);
- /* Allocate memory for PTE, remember to FREE */
+ /* Allocate memory for PTE.
+ * Heap memory is very limited in SPL, if the dual bootloader is
+ * enabled, just load pte to dram instead of oc-ram. In such case,
+ * this part of memory shouldn't be freed. But in common routine,
+ * don't forget to free the memory after use.
+ */
if (count != 0) {
+#if defined(CONFIG_DUAL_BOOTLOADER) && defined(CONFIG_SPL_BUILD)
+ pte = (gpt_entry *)CONFIG_SYS_SPL_PTE_RAM_BASE;
+#else
pte = memalign(ARCH_DMA_MINALIGN,
PAD_TO_BLOCKSIZE(count, dev_desc));
+#endif
}
if (count == 0 || pte == NULL) {
@@ -1087,13 +1113,14 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
__func__, (ulong)count);
return NULL;
}
-
/* Read GPT Entries from device */
blk = le64_to_cpu(pgpt_head->partition_entry_lba);
blk_cnt = BLOCK_CNT(count, dev_desc);
if (blk_dread(dev_desc, blk, (lbaint_t)blk_cnt, pte) != blk_cnt) {
printf("*** ERROR: Can't read GPT Entries ***\n");
+#if !defined(CONFIG_DUAL_BOOTLOADER) || !defined(CONFIG_SPL_BUILD)
free(pte);
+#endif
return NULL;
}
return pte;