From 745cab5aadff425a6d20725238b5de7701d59577 Mon Sep 17 00:00:00 2001 From: Jeff Brasen Date: Wed, 27 Nov 2024 16:12:16 -0800 Subject: DynamicTablesPkg: Fix BDF format for PCI initiators The BDF format for PCI initiators in the SRAT table is incorrect. The format is not a UINT16 but specific bytes. PCI Bus Number (Bits 7:0 of Byte 2) PCI Device Number (Bits 7:3 of Byte 3) PCI Function Number (Bits 2:0 of Byte 3) REF: https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#device-handle-pci Signed-off-by: Jeff Brasen --- .../Library/Acpi/Common/AcpiSratLib/SratGenerator.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.c index 20e1a4bfd3..fd83a92dda 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.c @@ -80,9 +80,9 @@ GET_OBJECT_LIST ( /** Return the PCI Device information in BDF format - PCI Bus Number - Max 256 busses (Bits 15:8 of BDF) - PCI Device Number - Max 32 devices (Bits 7:3 of BDF) - PCI Function Number - Max 8 functions (Bits 2:0 of BDF) + PCI Bus Number - Max 256 busses (Bits 7:0 of byte 0 of BDF) + PCI Device Number - Max 32 devices (Bits 7:3 of byte 1 of BDF) + PCI Function Number - Max 8 functions (Bits 2:0 of byte 1 BDF) @param [in] DeviceHandlePci Pointer to the PCI Device Handle. @@ -94,12 +94,12 @@ GetBdf ( IN CONST CM_ARCH_COMMON_DEVICE_HANDLE_PCI *DeviceHandlePci ) { - UINT16 Bdf; + UINT8 Bdf[2]; - Bdf = (UINT16)DeviceHandlePci->BusNumber << 8; - Bdf |= (DeviceHandlePci->DeviceNumber & 0x1F) << 3; - Bdf |= DeviceHandlePci->FunctionNumber & 0x7; - return Bdf; + Bdf[0] = DeviceHandlePci->BusNumber; + Bdf[1] = (DeviceHandlePci->DeviceNumber & 0x1F) << 3; + Bdf[1] |= DeviceHandlePci->FunctionNumber & 0x7; + return *(UINT16 *)Bdf; } /** Add the Memory Affinity Structures in the SRAT Table. -- cgit