diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c index a454c9e0ae..debefb248c 100644 --- a/src/device/pci_rom.c +++ b/src/device/pci_rom.c @@ -245,10 +245,19 @@ pci_rom_acpi_fill_vfct(const struct device *device, acpi_vfct_t *vfct_struct, header->PCIFunction = PCI_FUNC(device->path.pci.devfn); header->PCIDevice = PCI_SLOT(device->path.pci.devfn); header->ImageLength = rom->size * 512; - memcpy((void *)&header->VbiosContent, rom, header->ImageLength); + memcpy((void *)header->VbiosContent, rom, header->ImageLength); vfct_struct->VBIOSImageOffset = (size_t)header - (size_t)vfct_struct; + /* Calculate and set checksum for VBIOS data if FSP GOP driver used, + Since GOP driver modifies ATOMBIOS tables at end of VBIOS */ + if (CONFIG(RUN_FSP_GOP)) { + /* Clear existing checksum before recalculating */ + header->VbiosContent[VFCT_VBIOS_CHECKSUM_OFFSET] = 0; + header->VbiosContent[VFCT_VBIOS_CHECKSUM_OFFSET] = + acpi_checksum(header->VbiosContent, header->ImageLength); + } + current += header->ImageLength; return current; } diff --git a/src/include/acpi/acpi.h b/src/include/acpi/acpi.h index 3a7c99c5a0..16fe912b39 100644 --- a/src/include/acpi/acpi.h +++ b/src/include/acpi/acpi.h @@ -466,6 +466,8 @@ typedef struct acpi_lpi_desc_ncst { uint64_t counter_frequency; /* Frequency in cycles per second - 0 means TSC freq */ } __packed acpi_lpi_desc_ncst_t; +#define VFCT_VBIOS_CHECKSUM_OFFSET 0x21 + /* VFCT image header */ typedef struct acpi_vfct_image_hdr { u32 PCIBus; @@ -477,7 +479,7 @@ typedef struct acpi_vfct_image_hdr { u16 SSID; u32 Revision; u32 ImageLength; - u8 VbiosContent; // dummy - copy VBIOS here + u8 VbiosContent[]; // dummy - copy VBIOS here } __packed acpi_vfct_image_hdr_t; /* VFCT (VBIOS Fetch Table) */