Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elfloader: avoid redundant calculation #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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