treewide: Replace ALIGN(x, a) by ALIGN_UP(x, a) for clarity

Change-Id: I2a255cdcbcd38406f008a26fc0ed68d532e7a721
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68267
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Elyes Haouas 2022-10-14 10:01:05 +02:00 committed by Felix Held
parent 7d67a19cfa
commit 898176a24c
5 changed files with 14 additions and 12 deletions

View File

@ -4,6 +4,7 @@
#include <acpi/acpi.h>
#include <amdblocks/acpi.h>
#include <commonlib/bsd/helpers.h>
#include <device/device.h>
#include <FspGuids.h>
#include <soc/acpi.h>
@ -18,7 +19,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

@ -126,7 +126,7 @@ static size_t fill_up_entries_cache(struct vpd_blob_cache_t *cache,
cache->key_size = key_length;
cache->value_size = decoded_size;
cache->blob_size =
ALIGN(sizeof(struct calibration_blob) +
ALIGN_UP(sizeof(struct calibration_blob) +
cache->key_size +
cache->value_size, 4);
cbmem_entry_size += cache->blob_size;

View File

@ -253,7 +253,7 @@ int parse_bzImage_to_payload(const struct buffer *input,
/* 16 MB should be way outside coreboot's playground,
* so if possible (relocatable kernel) use that to
* avoid a trampoline copy. */
kernel_base = ALIGN(16*1024*1024, params.kernel_alignment);
kernel_base = ALIGN_UP(16*1024*1024, params.kernel_alignment);
if (hdr->init_size == 0) {
ERROR("init_size 0 for relocatable kernel\n");
return -1;
@ -275,7 +275,7 @@ int parse_bzImage_to_payload(const struct buffer *input,
* close to the kernel, so give it some room.
*/
initrd_base = kernel_base + buffer_size(&bzp.kernel);
initrd_base = ALIGN(initrd_base, 64*1024*1024);
initrd_base = ALIGN_UP(initrd_base, 64*1024*1024);
params.initrd_start = initrd_base;
params.initrd_size = buffer_size(&bzp.initrd);

View File

@ -1174,7 +1174,7 @@ int elf_writer_serialize(struct elf_writer *ew, struct buffer *out)
metadata_size += (Elf64_Xword)ew->ehdr.e_phnum * ew->ehdr.e_phentsize;
shstroffset = metadata_size;
/* Align up section header string size and metadata size to 4KiB */
metadata_size = ALIGN(metadata_size + shstrlen, 4096);
metadata_size = ALIGN_UP(metadata_size + shstrlen, 4096);
if (buffer_create(out, metadata_size + program_size, "elfout")) {
ERROR("Could not create output buffer for ELF.\n");

View File

@ -1,6 +1,7 @@
/* ifwitool, CLI utility for IFWI manipulation */
/* SPDX-License-Identifier: GPL-2.0-only */
#include <commonlib/bsd/helpers.h>
#include <commonlib/endian.h>
#include <getopt.h>
#include <stdlib.h>
@ -909,7 +910,7 @@ static int ifwi_parse(void)
* part of the image.
* ASSUMPTION: IFWI image always ends on a 4K boundary.
*/
ifwi_image.input_ifwi_end_offset = ALIGN(end_offset, 4 * KiB);
ifwi_image.input_ifwi_end_offset = ALIGN_UP(end_offset, 4 * KiB);
DEBUG("Parsing done.\n");
return 0;
@ -979,7 +980,7 @@ static void bpdt_reset(void)
__bpdt_reset(&ifwi_image.bpdt, bpdt_count, bpdt_size);
/* Update S-BPDT if required. */
bpdt_size = ALIGN(BPDT_HEADER_SIZE + sbpdt_count * BPDT_ENTRY_SIZE,
bpdt_size = ALIGN_UP(BPDT_HEADER_SIZE + sbpdt_count * BPDT_ENTRY_SIZE,
4 * KiB);
__bpdt_reset(&ifwi_image.subpart_buf[S_BPDT_TYPE], sbpdt_count,
bpdt_size);
@ -1091,7 +1092,7 @@ static void bpdt_entries_init_pack_order(void)
}
/* Pad ff bytes if there is any empty space left in BPDT 4K. */
curr_end = ALIGN(curr_offset, 4 * KiB);
curr_end = ALIGN_UP(curr_offset, 4 * KiB);
pad_buffer(last_bpdt_buff,
buffer_size(last_bpdt_buff) + (curr_end - curr_offset));
curr_offset = curr_end;
@ -1107,9 +1108,9 @@ static void bpdt_entries_init_pack_order(void)
if (subparts[type].attr & LIES_WITHIN_BPDT_4K)
continue;
assert(curr_offset == ALIGN(curr_offset, 4 * KiB));
assert(curr_offset == ALIGN_UP(curr_offset, 4 * KiB));
curr->offset = curr_offset;
curr_end = ALIGN(curr->offset + curr->size, 4 * KiB);
curr_end = ALIGN_UP(curr->offset + curr->size, 4 * KiB);
curr->size = curr_end - curr->offset;
pad_buffer(&ifwi_image.subpart_buf[type], curr->size);
@ -1130,7 +1131,7 @@ static void bpdt_entries_init_pack_order(void)
curr = find_entry_by_type(S_BPDT_TYPE);
assert(curr);
assert(curr_offset == ALIGN(curr_offset, 4 * KiB));
assert(curr_offset == ALIGN_UP(curr_offset, 4 * KiB));
curr->size = curr_offset - curr->offset;
}
@ -1190,7 +1191,7 @@ static void ifwi_write(const char *image_name)
size_t ifwi_start, ifwi_end, file_end;
ifwi_start = ifwi_image.input_ifwi_start_offset;
ifwi_end = ifwi_start + ALIGN(s->offset + s->size, 4 * KiB);
ifwi_end = ifwi_start + ALIGN_UP(s->offset + s->size, 4 * KiB);
file_end = ifwi_end + (buffer_size(&ifwi_image.input_buff) -
ifwi_image.input_ifwi_end_offset);