payloads,src: Replace ALIGN(x, a) by ALIGN_UP(x, a) for clarity
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Change-Id: I80f3d2c90c58daa62651f6fd635c043b1ce38b84
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68255
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c
index 078f9609..ea971b6 100644
--- a/src/lib/bootmem.c
+++ b/src/lib/bootmem.c
@@ -228,7 +228,7 @@
}
/* 4KiB alignment. */
- size = ALIGN(size, 4096);
+ size = ALIGN_UP(size, 4096);
region = NULL;
memranges_each_entry(r, &bootmem) {
if (range_entry_base(r) >= max_addr)
diff --git a/src/lib/gcov-glue.c b/src/lib/gcov-glue.c
index 14f3e3e..6bdb870 100644
--- a/src/lib/gcov-glue.c
+++ b/src/lib/gcov-glue.c
@@ -37,7 +37,7 @@
} else {
previous_file = current_file;
current_file =
- (FILE *)(ALIGN(((unsigned long)previous_file->data
+ (FILE *)(ALIGN_UP(((unsigned long)previous_file->data
+ previous_file->len), 16));
}
@@ -50,7 +50,7 @@
current_file->filename = (char *)¤t_file[1];
strcpy(current_file->filename, path);
current_file->data =
- (char *)ALIGN(((unsigned long)current_file->filename
+ (char *)ALIGN_UP(((unsigned long)current_file->filename
+ strlen(path) + 1), 16);
current_file->offset = 0;
current_file->len = 0;
diff --git a/src/lib/malloc.c b/src/lib/malloc.c
index 57a72c2..8ad038a 100644
--- a/src/lib/malloc.c
+++ b/src/lib/malloc.c
@@ -26,7 +26,7 @@
MALLOCDBG("%s Enter, boundary %zu, size %zu, free_mem_ptr %p\n",
__func__, boundary, size, free_mem_ptr);
- free_mem_ptr = (void *)ALIGN((unsigned long)free_mem_ptr, boundary);
+ free_mem_ptr = (void *)ALIGN_UP((unsigned long)free_mem_ptr, boundary);
p = free_mem_ptr;
free_mem_ptr += size;
diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c
index bee71d8..1446440 100644
--- a/src/lib/rmodule.c
+++ b/src/lib/rmodule.c
@@ -222,7 +222,7 @@
* to place the rmodule so that the program falls on the aligned
* address with the header just before it. Therefore, we need at least
* a page to account for the size of the header. */
- size_t region_size = ALIGN(memlen + region_alignment, 4096);
+ size_t region_size = ALIGN_UP(memlen + region_alignment, 4096);
/* The program starts immediately after the header. However,
* it needs to be aligned to a 4KiB boundary. Therefore, adjust the
* program location so that the program lands on a page boundary. The
diff --git a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c b/src/mainboard/emulation/qemu-i440fx/fw_cfg.c
index 3206e4c..5c23988 100644
--- a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c
+++ b/src/mainboard/emulation/qemu-i440fx/fw_cfg.c
@@ -249,7 +249,7 @@
uint64_t addr8;
switch (s[i].command) {
case BIOS_LINKER_LOADER_COMMAND_ALLOCATE:
- current = ALIGN(current, s[i].alloc.align);
+ current = ALIGN_UP(current, s[i].alloc.align);
if (fw_cfg_check_file(&f, s[i].alloc.file))
goto err;
@@ -329,7 +329,7 @@
printk(BIOS_DEBUG, "QEMU: loaded ACPI tables from fw_cfg.\n");
free(s);
free(addrs);
- return ALIGN(current, 16);
+ return ALIGN_UP(current, 16);
err:
printk(BIOS_DEBUG, "QEMU: loading ACPI tables from fw_cfg failed.\n");
diff --git a/src/northbridge/amd/agesa/family14/northbridge.c b/src/northbridge/amd/agesa/family14/northbridge.c
index 7a46bd4..6237a7f 100644
--- a/src/northbridge/amd/agesa/family14/northbridge.c
+++ b/src/northbridge/amd/agesa/family14/northbridge.c
@@ -709,14 +709,14 @@
acpi_hest_t *hest;
/* HEST */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
hest = (acpi_hest_t *)current;
acpi_write_hest(hest, acpi_fill_hest);
acpi_add_table(rsdp, hest);
current += hest->header.length;
/* SRAT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
srat = (acpi_srat_t *)agesawrapper_getlateinitptr(PICK_SRAT);
if (srat != NULL) {
@@ -730,7 +730,7 @@
}
/* SLIT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
slit = (acpi_slit_t *)agesawrapper_getlateinitptr(PICK_SLIT);
if (slit != NULL) {
@@ -744,7 +744,7 @@
}
/* SSDT */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current);
alib = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_ALIB);
if (alib != NULL) {
@@ -758,7 +758,7 @@
/* The DSDT needs additional work for the AGESA SSDT Pstate table */
/* Keep the comment for a while. */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * AGESA SSDT Pstate at %lx\n", current);
ssdt = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_PSTATE);
if (ssdt != NULL) {
diff --git a/src/northbridge/amd/agesa/family15tn/northbridge.c b/src/northbridge/amd/agesa/family15tn/northbridge.c
index caacce9..9cacb79 100644
--- a/src/northbridge/amd/agesa/family15tn/northbridge.c
+++ b/src/northbridge/amd/agesa/family15tn/northbridge.c
@@ -473,13 +473,13 @@
acpi_hest_t *hest;
/* HEST */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
hest = (acpi_hest_t *)current;
acpi_write_hest(hest, acpi_fill_hest);
acpi_add_table(rsdp, hest);
current += hest->header.length;
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * IVRS at %lx\n", current);
ivrs = agesawrapper_getlateinitptr(PICK_IVRS);
if (ivrs != NULL) {
@@ -492,7 +492,7 @@
}
/* SRAT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
srat = (acpi_srat_t *)agesawrapper_getlateinitptr(PICK_SRAT);
if (srat != NULL) {
@@ -505,7 +505,7 @@
}
/* SLIT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
slit = (acpi_slit_t *)agesawrapper_getlateinitptr(PICK_SLIT);
if (slit != NULL) {
@@ -518,7 +518,7 @@
}
/* ALIB */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current);
alib = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_ALIB);
if (alib != NULL) {
@@ -533,7 +533,7 @@
/* this pstate ssdt may cause Blue Screen: Fixed: Keep this comment for a while. */
/* SSDT */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current);
ssdt = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_PSTATE);
if (ssdt != NULL) {
diff --git a/src/northbridge/amd/agesa/family16kb/northbridge.c b/src/northbridge/amd/agesa/family16kb/northbridge.c
index 9f20e71..9943e34 100644
--- a/src/northbridge/amd/agesa/family16kb/northbridge.c
+++ b/src/northbridge/amd/agesa/family16kb/northbridge.c
@@ -467,13 +467,13 @@
acpi_hest_t *hest;
/* HEST */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
hest = (acpi_hest_t *)current;
acpi_write_hest(hest, acpi_fill_hest);
acpi_add_table(rsdp, hest);
current += hest->header.length;
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * IVRS at %lx\n", current);
ivrs = agesawrapper_getlateinitptr(PICK_IVRS);
if (ivrs != NULL) {
@@ -486,7 +486,7 @@
}
/* SRAT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
srat = (acpi_srat_t *)agesawrapper_getlateinitptr(PICK_SRAT);
if (srat != NULL) {
@@ -499,7 +499,7 @@
}
/* SLIT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
slit = (acpi_slit_t *)agesawrapper_getlateinitptr(PICK_SLIT);
if (slit != NULL) {
@@ -512,7 +512,7 @@
}
/* ALIB */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current);
alib = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_ALIB);
if (alib != NULL) {
@@ -527,7 +527,7 @@
/* this pstate ssdt may cause Blue Screen: Fixed: Keep this comment for a while. */
/* SSDT */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current);
ssdt = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_PSTATE);
if (ssdt != NULL) {
diff --git a/src/northbridge/amd/pi/00730F01/northbridge.c b/src/northbridge/amd/pi/00730F01/northbridge.c
index 0245a74..dab0e72 100644
--- a/src/northbridge/amd/pi/00730F01/northbridge.c
+++ b/src/northbridge/amd/pi/00730F01/northbridge.c
@@ -584,13 +584,13 @@
acpi_ivrs_t *ivrs;
/* HEST */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
acpi_write_hest((void *)current, acpi_fill_hest);
acpi_add_table(rsdp, (void *)current);
current += ((acpi_header_t *)current)->length;
/* IVRS */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * IVRS at %lx\n", current);
ivrs = (acpi_ivrs_t *)current;
acpi_create_ivrs(ivrs, acpi_fill_ivrs);
@@ -598,7 +598,7 @@
acpi_add_table(rsdp, ivrs);
/* SRAT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
srat = (acpi_srat_t *)agesawrapper_getlateinitptr(PICK_SRAT);
if (srat != NULL) {
@@ -611,7 +611,7 @@
}
/* SLIT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
slit = (acpi_slit_t *)agesawrapper_getlateinitptr(PICK_SLIT);
if (slit != NULL) {
@@ -624,7 +624,7 @@
}
/* ALIB */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current);
alib = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_ALIB);
if (alib != NULL) {
@@ -639,7 +639,7 @@
/* this pstate ssdt may cause Blue Screen: Fixed: Keep this comment for a while. */
/* SSDT */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current);
ssdt = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_PSTATE);
if (ssdt != NULL) {
diff --git a/src/soc/amd/cezanne/agesa_acpi.c b/src/soc/amd/cezanne/agesa_acpi.c
index a397360..4adf959 100644
--- a/src/soc/amd/cezanne/agesa_acpi.c
+++ b/src/soc/amd/cezanne/agesa_acpi.c
@@ -16,7 +16,7 @@
current = add_agesa_fsp_acpi_table(AMD_FSP_ACPI_ALIB_HOB_GUID, "ALIB", rsdp, current);
/* IVRS */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
ivrs = (acpi_ivrs_t *)current;
acpi_create_ivrs(ivrs, acpi_fill_ivrs);
current += ivrs->header.length;
diff --git a/src/soc/amd/mendocino/agesa_acpi.c b/src/soc/amd/mendocino/agesa_acpi.c
index 9062c7a..e0ca9ac 100644
--- a/src/soc/amd/mendocino/agesa_acpi.c
+++ b/src/soc/amd/mendocino/agesa_acpi.c
@@ -18,7 +18,7 @@
current = add_agesa_fsp_acpi_table(AMD_FSP_ACPI_ALIB_HOB_GUID, "ALIB", rsdp, current);
/* IVRS */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
ivrs = (acpi_ivrs_t *)current;
acpi_create_ivrs(ivrs, acpi_fill_ivrs);
current += ivrs->header.length;
diff --git a/src/soc/amd/picasso/agesa_acpi.c b/src/soc/amd/picasso/agesa_acpi.c
index e4a9b14..35eedcb 100644
--- a/src/soc/amd/picasso/agesa_acpi.c
+++ b/src/soc/amd/picasso/agesa_acpi.c
@@ -547,7 +547,7 @@
struct acpi_crat_header *crat;
/* CRAT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
crat = (struct acpi_crat_header *)current;
acpi_create_crat(crat, acpi_fill_crat);
current += crat->header.length;
@@ -557,7 +557,7 @@
current = add_agesa_fsp_acpi_table(AMD_FSP_ACPI_ALIB_HOB_GUID, "ALIB", rsdp, current);
/* IVRS */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
ivrs = (acpi_ivrs_t *)current;
acpi_create_ivrs(ivrs, acpi_fill_ivrs);
current += ivrs->header.length;
diff --git a/src/soc/amd/stoneyridge/northbridge.c b/src/soc/amd/stoneyridge/northbridge.c
index 500940c..4549abb 100644
--- a/src/soc/amd/stoneyridge/northbridge.c
+++ b/src/soc/amd/stoneyridge/northbridge.c
@@ -235,13 +235,13 @@
acpi_hest_t *hest;
/* HEST */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
hest = (acpi_hest_t *)current;
acpi_write_hest(hest, acpi_fill_hest);
acpi_add_table(rsdp, (void *)current);
current += hest->header.length;
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * IVRS at %lx\n", current);
ivrs = agesawrapper_getlateinitptr(PICK_IVRS);
if (ivrs != NULL) {
@@ -254,7 +254,7 @@
}
/* SRAT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
srat = (acpi_srat_t *)agesawrapper_getlateinitptr(PICK_SRAT);
if (srat != NULL) {
@@ -267,7 +267,7 @@
}
/* SLIT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
slit = (acpi_slit_t *)agesawrapper_getlateinitptr(PICK_SLIT);
if (slit != NULL) {
@@ -280,7 +280,7 @@
}
/* ALIB */
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current);
alib = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_ALIB);
if (alib != NULL) {
@@ -293,7 +293,7 @@
" Skipping.\n");
}
- current = ALIGN(current, 16);
+ current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current);
ssdt = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_PSTATE);
if (ssdt != NULL) {
diff --git a/src/soc/intel/common/mma.c b/src/soc/intel/common/mma.c
index 04d766d..3314e8e 100644
--- a/src/soc/intel/common/mma.c
+++ b/src/soc/intel/common/mma.c
@@ -173,7 +173,7 @@
return;
}
- mma_data_size = ALIGN(mma_hob_size, 16) +
+ mma_data_size = ALIGN_UP(mma_hob_size, 16) +
sizeof(struct mma_data_container);
mma_data = cbmem_add(CBMEM_ID_MMA_DATA, mma_data_size);
diff --git a/src/soc/intel/denverton_ns/acpi.c b/src/soc/intel/denverton_ns/acpi.c
index 808affa..399bb64 100644
--- a/src/soc/intel/denverton_ns/acpi.c
+++ b/src/soc/intel/denverton_ns/acpi.c
@@ -152,7 +152,7 @@
acpi_header_t *ssdt2;
current = acpi_write_hpet(device, current, rsdp);
- current = (ALIGN(current, 16));
+ current = (ALIGN_UP(current, 16));
ssdt2 = (acpi_header_t *)current;
memset(ssdt2, 0, sizeof(acpi_header_t));
@@ -162,7 +162,7 @@
acpi_add_table(rsdp, ssdt2);
printk(BIOS_DEBUG, "ACPI: * SSDT2 @ %p Length %x\n", ssdt2,
ssdt2->length);
- current = (ALIGN(current, 16));
+ current = (ALIGN_UP(current, 16));
} else {
ssdt2 = NULL;
printk(BIOS_DEBUG, "ACPI: * SSDT2 not generated.\n");
diff --git a/src/soc/intel/quark/memmap.c b/src/soc/intel/quark/memmap.c
index 97a9fd8..46671b2 100644
--- a/src/soc/intel/quark/memmap.c
+++ b/src/soc/intel/quark/memmap.c
@@ -12,7 +12,7 @@
/* Locate the top of RAM */
top_of_low_usable_memory = (uintptr_t) cbmem_top();
- top_of_ram = ALIGN(top_of_low_usable_memory, 16 * MiB);
+ top_of_ram = ALIGN_UP(top_of_low_usable_memory, 16 * MiB);
/* Cache postcar and ramstage */
postcar_frame_add_mtrr(pcf, top_of_ram - (16 * MiB), 16 * MiB,
diff --git a/src/soc/intel/xeon_sp/nb_acpi.c b/src/soc/intel/xeon_sp/nb_acpi.c
index 64851f5..c31fd61 100644
--- a/src/soc/intel/xeon_sp/nb_acpi.c
+++ b/src/soc/intel/xeon_sp/nb_acpi.c
@@ -414,7 +414,7 @@
const config_t *const config = config_of(device);
/* SRAT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
srat = (acpi_srat_t *) current;
acpi_create_srat(srat, acpi_fill_srat);
@@ -422,7 +422,7 @@
acpi_add_table(rsdp, srat);
/* SLIT */
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
slit = (acpi_slit_t *) current;
acpi_create_slit(slit, acpi_fill_slit);
@@ -431,7 +431,7 @@
/* DMAR */
if (config->vtd_support) {
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
dmar = (acpi_dmar_t *)current;
enum dmar_flags flags = DMAR_INTR_REMAP;
diff --git a/src/soc/intel/xeon_sp/ras/hest.c b/src/soc/intel/xeon_sp/ras/hest.c
index 02a9ab1..9eb54d9 100644
--- a/src/soc/intel/xeon_sp/ras/hest.c
+++ b/src/soc/intel/xeon_sp/ras/hest.c
@@ -91,7 +91,7 @@
printk(BIOS_DEBUG, "elog_addr: %llx, size:%x\n", gnvs->hest_log_addr,
CONFIG_ERROR_LOG_BUFFER_SIZE);
- current = ALIGN(current, 8);
+ current = ALIGN_UP(current, 8);
hest = (acpi_hest_t *)current;
acpi_write_hest(hest, acpi_fill_hest);
acpi_add_table(rsdp, (void *)current);
diff --git a/src/soc/samsung/exynos5250/fb.c b/src/soc/samsung/exynos5250/fb.c
index 1fc926a..ab097e2 100644
--- a/src/soc/samsung/exynos5250/fb.c
+++ b/src/soc/samsung/exynos5250/fb.c
@@ -100,7 +100,7 @@
{
unsigned int val;
- fb_size = ALIGN(fb_size, 4096);
+ fb_size = ALIGN_UP(fb_size, 4096);
write32(&exynos_disp_ctrl->vidcon1, pd->ivclk | pd->fixvclk);
val = ENVID_ON | ENVID_F_ON | (pd->clkval_f << CLKVAL_F_OFFSET);