From 049dc848c4b94b9eb003eb744ccfd519104bbefb Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Wed, 8 Jul 2026 01:01:40 +0000 Subject: [PATCH] MdeModulePkg: Fix incorrect EfiPciWidth* enum literals In arguments of EFI_PCI_IO_PROTOCOL member functions, replace the EfiPciWidth* enum literals from EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH with the matching EfiPciIoWidth* values from EFI_PCI_IO_PROTOCOL_WIDTH. This keeps the call sites aligned with the protocol they actually use. The old values were copied from EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL code, so they obscured the intent of the calls and relied on an explicit cast. This mimics commit 8ba64a9a9417 ("UefiPayloadPkg: Fix build failure with CLANGPDB"). Generated by coccinelle script. ``` smpl @initialize:python@ @@ def to_pci_io_width(name): return name.replace("EfiPciWidth", "EfiPciIoWidth", 1) @normalize@ typedef EFI_PCI_IO_PROTOCOL; typedef EDKII_PCI_DEVICE_PPI; type T =~ "^EFI_PCI_IO_PROTOCOL_WIDTH$"; EFI_PCI_IO_PROTOCOL *x; EDKII_PCI_DEVICE_PPI *y; identifier bad =~ "EfiPciWidth(Uint|FifoUint|FillUint)(8|16|32|64)"; identifier top_op =~ "^(PollMem|PollIo|CopyMem)$"; identifier space =~ "^(Mem|Io|Pci)$"; identifier rw =~ "^(Read|Write)$"; fresh identifier good = script:python(bad) { to_pci_io_width(bad) }; expression first; expression list rest; @@ ( x->top_op | y->PciIo.top_op | x->space.rw | y->PciIo.space.rw ) ( first, - (T)bad + good , rest ) ``` Verified with: - `build -p MdeModulePkg/MdeModulePkg.dsc -m MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -a IA32 -b DEBUG -t GCC` - `build -p MdeModulePkg/MdeModulePkg.dsc -m MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -a X64 -b DEBUG -t GCC` Signed-off-by: Mingjie Shen --- MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c index ba14ccbc30..c290884110 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c @@ -598,7 +598,7 @@ RomDecode ( Value32 = RomBar | 0x1; PciIo->Pci.Write ( PciIo, - (EFI_PCI_IO_PROTOCOL_WIDTH)EfiPciWidthUint32, + EfiPciIoWidthUint32, RomBarIndex, 1, &Value32 @@ -630,7 +630,7 @@ RomDecode ( Value32 = 0xFFFFFFFE; PciIo->Pci.Write ( PciIo, - (EFI_PCI_IO_PROTOCOL_WIDTH)EfiPciWidthUint32, + EfiPciIoWidthUint32, RomBarIndex, 1, &Value32