Skip to content

Commit 497f677

Browse files
committed
elfloader: avoid redundant calculation
Signed-off-by: Axel Heider <axelheider@gmx.de>
1 parent b305af4 commit 497f677

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

elfloader-tool/src/common.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ int load_images(
432432
return -1;
433433
}
434434

435+
/* Reserve space for the kernel, keep next start address page aligned. */
436+
next_phys_addr = ROUND_UP(kernel_phys_end, PAGE_BITS);
437+
435438
void const *dtb = NULL;
436439

437440
#ifdef CONFIG_ELFLOADER_INCLUDE_DTB
@@ -467,9 +470,7 @@ int load_images(
467470
* Move the DTB out of the way, if it's present.
468471
*/
469472
if (dtb) {
470-
/* keep it page aligned */
471-
next_phys_addr = dtb_phys_start = ROUND_UP(kernel_phys_end, PAGE_BITS);
472-
473+
dtb_phys_start = next_phys_addr;
473474
size_t dtb_size = fdt_size(dtb);
474475
if (0 == dtb_size) {
475476
printf("ERROR: Invalid device tree blob supplied\n");
@@ -493,8 +494,6 @@ int load_images(
493494
printf(" paddr=[%p..%p]\n", dtb_phys_start, dtb_phys_end - 1);
494495
*chosen_dtb = (void *)dtb_phys_start;
495496
*chosen_dtb_size = dtb_size;
496-
} else {
497-
next_phys_addr = ROUND_UP(kernel_phys_end, PAGE_BITS);
498497
}
499498

500499
/* Load the kernel */

0 commit comments

Comments
 (0)