From 935a423f26d390e5003ed15781d4bfbf76ce0501 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Tue, 11 Feb 2025 15:24:20 +0100 Subject: [PATCH] device/pci_rom: Use correct endian conversion The Option ROM contains lots of 16bit values that are being used, thus use the 16bit endianness conversion function over the 32bit variant to avoid confusion. TEST: Still works on amd/birman+. Change-Id: I571be97a930ad018e1d1316117cefe5bd1c68f9b Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/86383 Reviewed-by: Felix Held Reviewed-by: Andy Ebrahiem Tested-by: build bot (Jenkins) --- src/device/pci_rom.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c index d60720eb49..7e19646d52 100644 --- a/src/device/pci_rom.c +++ b/src/device/pci_rom.c @@ -93,16 +93,16 @@ struct rom_header *pci_rom_probe(const struct device *dev) printk(BIOS_SPEW, "PCI expansion ROM, signature 0x%04x, INIT size 0x%04x, data ptr 0x%04x\n", - le32_to_cpu(rom_header->signature), - rom_header->size * 512, le32_to_cpu(rom_header->data)); + le16_to_cpu(rom_header->signature), + rom_header->size * 512, le16_to_cpu(rom_header->data)); - if (le32_to_cpu(rom_header->signature) != PCI_ROM_HDR) { + if (le16_to_cpu(rom_header->signature) != PCI_ROM_HDR) { printk(BIOS_ERR, "Incorrect expansion ROM header signature %04x\n", - le32_to_cpu(rom_header->signature)); + le16_to_cpu(rom_header->signature)); return NULL; } - rom_data = (((void *)rom_header) + le32_to_cpu(rom_header->data)); + rom_data = (((void *)rom_header) + le16_to_cpu(rom_header->data)); printk(BIOS_SPEW, "PCI ROM image, vendor ID %04x, device ID %04x,\n", rom_data->vendor, rom_data->device); @@ -144,9 +144,9 @@ struct rom_header *pci_rom_load(struct device *dev, + image_size); rom_data = (struct pci_data *)((void *)rom_header - + le32_to_cpu(rom_header->data)); + + le16_to_cpu(rom_header->data)); - image_size = le32_to_cpu(rom_data->ilen) * 512; + image_size = le16_to_cpu(rom_data->ilen) * 512; } while ((rom_data->type != 0) && (rom_data->indicator != 0)); // make sure we got x86 version if (rom_data->type != 0)