Skip to content

Commit

Permalink
elfloader: avoid redundant calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <axelheider@gmx.de>
  • Loading branch information
axel-h committed Aug 9, 2024
1 parent fd0a5ec commit cd9b3a6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions elfloader-tool/src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ int load_images(
return -1;
}

/* Reserve space for the kernel, keep next start address page aligned. */
next_phys_addr = ROUND_UP(kernel_phys_end, PAGE_BITS);

void const *dtb = NULL;

#ifdef CONFIG_ELFLOADER_INCLUDE_DTB
Expand Down Expand Up @@ -465,9 +468,7 @@ int load_images(
* Move the DTB out of the way, if it's present.
*/
if (dtb) {
/* keep it page aligned */
next_phys_addr = dtb_phys_start = ROUND_UP(kernel_phys_end, PAGE_BITS);

dtb_phys_start = next_phys_addr;
size_t dtb_size = fdt_size(dtb);
if (0 == dtb_size) {
printf("ERROR: Invalid device tree blob supplied\n");
Expand All @@ -491,8 +492,6 @@ int load_images(
printf(" paddr=[%p..%p]\n", dtb_phys_start, dtb_phys_end - 1);
*chosen_dtb = (void *)dtb_phys_start;
*chosen_dtb_size = dtb_size;
} else {
next_phys_addr = ROUND_UP(kernel_phys_end, PAGE_BITS);
}

/* Load the kernel */
Expand Down

0 comments on commit cd9b3a6

Please sign in to comment.