Remove <swab.h> and swabXX() functions

GCC generates correct code for __builtin_bswapXX() on all architectures,
including ArmV4. It seems that whatever bug caused this to not work back
in commit 879ea7fce8 ("endian: Replace explicit byte swapping with
compiler builtin") has been fixed now. We can eliminate the swabXX()
functions and simplify the code.

All instances that had been calling these functions directly should have
been using real endianness conversions anyway.

Change-Id: I19713fd009aa5c0e01c4a42e0cf012364d6bed60
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90438
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Frans Hendriks <fhendriks@eltan.com>
This commit is contained in:
Julius Werner 2025-12-09 11:34:18 -08:00 committed by Yu-Ping Wu
commit 8f34fdfab3
9 changed files with 17 additions and 76 deletions

View file

@ -3,6 +3,7 @@
#include <mboot.h>
#include <assert.h>
#include <build.h>
#include <endian.h>
#include <vb2_api.h>
#include <board_mboot.h>
@ -87,7 +88,7 @@ tpm_result_t tpm2_get_capability_pcrs(TPML_PCR_SELECTION *Pcrs)
printk(BIOS_DEBUG, "Pcrs->count = %d\n", Pcrs->count);
for (index = 0; index < Pcrs->count; index++) {
Pcrs->pcrSelections[index].hash =
swab16(TpmCap.data.assignedPCR.pcrSelections[index].hash);
be16toh(TpmCap.data.assignedPCR.pcrSelections[index].hash);
printk(BIOS_DEBUG, "Pcrs->pcrSelections[%d].hash = %#x\n", index,
Pcrs->pcrSelections[index].hash);
Pcrs->pcrSelections[index].sizeofSelect =

View file

@ -12,7 +12,6 @@
#include <boot/coreboot_tables.h>
#include <security/tpm/tss/tcg-2.0/tss_structures.h>
#include <security/tpm/tss.h>
#include <swab.h>
/* TPM2 interface */
#define EFI_TPM2_ACPI_TABLE_START_METHOD_TIS 6