diff options
author | Elyes Haouas <ehaouas@noos.fr> | 2022-10-14 10:01:05 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-11-12 18:00:16 +0000 |
commit | 898176a24c5bdde896a47bf60966d1476b4f913f (patch) | |
tree | 6a1d3e53b0e395bb1e2e05d632d829beb78acca4 | |
parent | 7d67a19cfa42a5ef3ab9734ba9e445be59fc76e3 (diff) |
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>
-rw-r--r-- | src/soc/amd/morgana/agesa_acpi.c | 3 | ||||
-rw-r--r-- | src/vendorcode/google/chromeos/vpd_calibration.c | 2 | ||||
-rw-r--r-- | util/cbfstool/cbfs-payload-linux.c | 4 | ||||
-rw-r--r-- | util/cbfstool/elfheaders.c | 2 | ||||
-rw-r--r-- | util/cbfstool/ifwitool.c | 15 |
5 files changed, 14 insertions, 12 deletions
diff --git a/src/soc/amd/morgana/agesa_acpi.c b/src/soc/amd/morgana/agesa_acpi.c index 78c0e4cdf3..8838d9dc49 100644 --- a/src/soc/amd/morgana/agesa_acpi.c +++ b/src/soc/amd/morgana/agesa_acpi.c @@ -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; diff --git a/src/vendorcode/google/chromeos/vpd_calibration.c b/src/vendorcode/google/chromeos/vpd_calibration.c index 460d7dca3a..e5f5b579d1 100644 --- a/src/vendorcode/google/chromeos/vpd_calibration.c +++ b/src/vendorcode/google/chromeos/vpd_calibration.c @@ -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; diff --git a/util/cbfstool/cbfs-payload-linux.c b/util/cbfstool/cbfs-payload-linux.c index 9a29e68d9e..f9d0d111c7 100644 --- a/util/cbfstool/cbfs-payload-linux.c +++ b/util/cbfstool/cbfs-payload-linux.c @@ -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); diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c index 3a53735382..39faff209d 100644 --- a/util/cbfstool/elfheaders.c +++ b/util/cbfstool/elfheaders.c @@ -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"); diff --git a/util/cbfstool/ifwitool.c b/util/cbfstool/ifwitool.c index 8eda4c77b1..efcb594360 100644 --- a/util/cbfstool/ifwitool.c +++ b/util/cbfstool/ifwitool.c @@ -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); |