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>
This commit is contained in:
Elyes Haouas 2022-10-10 12:34:21 +02:00 committed by Felix Held
parent 5f69b867f0
commit d6b6b22616
20 changed files with 50 additions and 50 deletions

View File

@ -68,7 +68,7 @@ static struct cbfile *firstfile(void)
static struct cbfile *nextfile(struct cbfile *f)
{
f = (struct cbfile *)((u8 *)f + ALIGN(ntohl(f->len) + ntohl(f->offset),
f = (struct cbfile *)((u8 *)f + ALIGN_UP(ntohl(f->len) + ntohl(f->offset),
ntohl(header->align)));
return getfile(f);
}

View File

@ -228,7 +228,7 @@ void *bootmem_allocate_buffer(size_t size)
}
/* 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)

View File

@ -37,7 +37,7 @@ static FILE *fopen(const char *path, const char *mode)
} 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 @@ static FILE *fopen(const char *path, const char *mode)
current_file->filename = (char *)&current_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;

View File

@ -26,7 +26,7 @@ void *memalign(size_t boundary, size_t size)
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;

View File

@ -222,7 +222,7 @@ static void *rmodule_cbfs_allocator(void *rsl_arg, size_t unused,
* 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

View File

@ -249,7 +249,7 @@ unsigned long fw_cfg_acpi_tables(unsigned long start)
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 @@ unsigned long fw_cfg_acpi_tables(unsigned long start)
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");

View File

@ -709,14 +709,14 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
/* 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) {

View File

@ -473,13 +473,13 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
/* 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) {

View File

@ -467,13 +467,13 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
/* 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) {

View File

@ -584,13 +584,13 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
/* 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) {

View File

@ -16,7 +16,7 @@ uintptr_t agesa_write_acpi_tables(const struct device *device, uintptr_t current
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;

View File

@ -18,7 +18,7 @@ uintptr_t agesa_write_acpi_tables(const struct device *device, uintptr_t current
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;

View File

@ -547,7 +547,7 @@ uintptr_t agesa_write_acpi_tables(const struct device *device, uintptr_t current
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 @@ uintptr_t agesa_write_acpi_tables(const struct device *device, uintptr_t current
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;

View File

@ -235,13 +235,13 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
}
/* 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 @@ static unsigned long agesa_write_acpi_tables(const struct device *device,
" 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) {

View File

@ -173,7 +173,7 @@ static void save_mma_results_data(void *unused)
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);

View File

@ -152,7 +152,7 @@ unsigned long southcluster_write_acpi_tables(const struct device *device,
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 @@ unsigned long southcluster_write_acpi_tables(const struct device *device,
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");

View File

@ -12,7 +12,7 @@ void fill_postcar_frame(struct postcar_frame *pcf)
/* 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,

View File

@ -414,7 +414,7 @@ unsigned long northbridge_write_acpi_tables(const struct device *device,
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 @@ unsigned long northbridge_write_acpi_tables(const struct device *device,
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 @@ unsigned long northbridge_write_acpi_tables(const struct device *device,
/* 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;

View File

@ -91,7 +91,7 @@ unsigned long hest_create(unsigned long current, struct acpi_rsdp *rsdp)
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);

View File

@ -100,7 +100,7 @@ void fb_init(unsigned long int fb_size, void *lcdbase,
{
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);