Commit graph

6656 commits

Author SHA1 Message Date
Michael Kubacki
7a934d0bef MdeModulePkg: Replace include guards with #pragma once
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.

`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.

Compared to macro-based include guards, `#pragma once`:

- Eliminates the risk of macro name collisions or copy/paste errors
  where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
  (e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
  file entirely, rather than re-reading it to find the matching
  `#endif` ("multiple-include optimization").
  - Note that some compilers may already optimize traditional include
    guards, by recognzining the idiomatic pattern.

This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.

However, this is considered acceptable given:

1. edk2 already defines a subset of supported compilers in
   BaseTools/Conf/tools_def.template, all of which have supported
   `#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
   include guard naming and potential macro collisions.

Approximate compiler support dates:

- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
  (http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-23 21:01:28 +00:00
rdiaz
b7a715f7c0 MdeModulePkg: Add Unmap Callback
Add Unmap callback for when PEI and SEC need to invalidate the
Rx/Tx buffer HOB on a call to Unmap.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiaz
0e8dc1693d MdeModulePkg: Code/Comment cleanup
Cleaned various comments and debug messages as well as
headers to either fix typos or for readability.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiaz
3457388b7c MdeModulePkg: Use EFI_PAGES_TO_SIZE macro in ArmFfaSecRxTxMap
Replaced all instances of PcdGet64 (PcdFfaTxRxPageCount) *
EFI_PAGE_SIZE, with EFI_PAGES_TO_SIZE macro.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiaz
ea8447eec7 MdeModulePkg: Remove global usage from ArmFfaSecRxTxMap
Removed the global variables in ArmFfaSecRxTxMap. Rx/Tx
buffer HOB is now created within the Map function rather
than in the constructor of ArmFfaSecLib. This allows for
the use of the HOB to find the Rx/Tx buffer information.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiaz
7416ebda09 MdeModulePkg: Remove global usage in ArmFfaCommon
Removed global variables in ArmFfaCommon. Moved the globals to
locals in each phase's ArmFfaLib implementation. SEC and PEI
will query when necessary to avoid setting globals when memory
is unavailable.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiaz
16d9ba7275 MdeModulePkg: Add helper to check if FF-A is supported
Added ArmFfaLibIsFfaSupported to ArmFfaCommon to allow for
queries of FF-A support outside of ArmFfaCommonInit.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
Yang Gang
be6ff0f289 MdeModulePkg/HiiDatabaseDxe: Fix parser issue in GetNameElement()
This commit removes an wrong goto statement which may cause DXE_ASSERT!

`ConfigRequest` example: `&NameValueVar0&NameValueVar1&NameValueVar2`.

When `*Progress` is `&NameValueVar2`, code will run to `goto Done;`,
then return NULL.

Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2026-02-10 01:31:21 +00:00
Kun Qin
25462a6ab2 MdeModulePkg: MmVariablePei: Populate correct v3 header
When using MM communicate v3 to fetch variable, the header calculation
was incorrect, causing the variable driver on the secure environment to
have random behavior.

This change refactored the original routine by following the current
DXE instance (mostly).

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-02-03 21:56:48 +00:00
Yang Gang
f5f4e9b764 MdeModulePkg/SetupBrowserDxe: Check Form parameter in RuleIdToExpression()
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2026-02-02 04:35:29 +00:00
Yang Gang
5a414b5ef7 MdeModulePkg/SetupBrowserDxe: Fix code issue in ParseOpCodes()
`if (CurrentForm != NULL)` and
`if (InScopeDisable && (CurrentForm == NULL))`conflict.

`if (CurrentForm != NULL)` should be `if (CurrentExpression != NULL)`.

Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2026-02-02 04:35:29 +00:00
Sherry Fan
64ad6f20d8 MdeModulePkg: BdsDxe: Introduce infinite boot retries
This PR introduces a new feature to enable infinite boot retries based on a newly created PCD.
When true, the system will continuously loop over all boot options.

PCD default is FALSE to match existing functionality.

This change is tested on QEMU based virtual platforms and physical
platforms.

This change is useful for certain server cases. Infinite retries allows
a server to continuously attempt boot in case of network failure and
recovery, and for such attempts to be accurately recorded in the TCG
logs.

Co-authored-by: Kun Qin <kun.qin@microsoft.com>
Co-authored-by: Aaron Pop <aaron.pop@microsoft.com>
Co-authored-by: Michael Kubacki <michael.kubacki@microsoft.com>

Signed-off-by: Sherry Fan <sherryfan@microsoft.com>
2026-02-02 02:24:18 +00:00
Gerd Hoffmann
ff69be3519 MdeModulePkg/CapsuleOnDiskLoadPei: fix gcc 16 warning
MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c:176:11: error: variable ‘Index’ set but not used [-Werror=unused-but-set-variable=]
  176 |   UINTN   Index;
      |           ^~~~~

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2026-02-01 20:30:31 +00:00
Gerd Hoffmann
e01df52281 MdeModulePkg/VarCheckHiiLib: fix gcc 16 warning
MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c: In function ‘ParseFv’:
MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c:263:34: error: variable ‘FfsIndex’ set but not used [-Werror=unused-but-set-variable=]
  263 |   UINTN                          FfsIndex;
      |                                  ^~~~~~~~

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2026-02-01 20:30:31 +00:00
Gerd Hoffmann
8992abde26 MdeModulePkg/DisplayEngineDxe: fix gcc 16 warning
MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c: In function ‘CreateSharedPopUp’:
MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c:590:11: error: variable ‘Count’ set but not used [-Werror=unused-but-set-variable=]
  590 |   UINTN   Count;
      |           ^~~~~

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2026-02-01 20:30:31 +00:00
Gerd Hoffmann
21441cdf29 MdeModulePkg/SmbiosMeasurementDxe: fix gcc 16 warning
MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c: In function ‘GetSmbiosStringById’:
MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c:221:10: error: variable ‘Size’ set but not used [-Werror=unused-but-set-variable=]
  221 |   UINTN  Size;
      |          ^~~~

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2026-02-01 20:30:31 +00:00
Gerd Hoffmann
0f451f6e1f MdeModulePkg/CustomizedDisplayLib: fix gcc 16 warning
MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c: In function ‘CreateDialog’:
MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c:435:18: error: variable ‘Count’ set but not used [-Werror=unused-but-set-variable=]
  435 |   UINTN          Count;
      |                  ^~~~~

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2026-02-01 20:30:31 +00:00
Paul Grimes
1a261da766 MdeModulePkg/UsbMassStorageDxe: Add retry mechanism to UsbMassReadBlocks
Add a retry mechanism to UsbMassReadBlocks() to improve robustness
when reading from USB mass storage devices. Some USB devices may
experience transient failures during read operations that can be
recovered by resetting the device and retrying.

The implementation:
- Saves original buffer parameters (Buffer, Lba, BufferSize)
- Attempts the read operation up to 4 times (initial + 3 retries)
- Resets the device via UsbMassReset() before each retry
- Restores buffer parameters before each retry attempt

This change is compliant with USB Mass Storage Class Bulk-Only
Transport Spec Rev 1.0:
- Section 5.3.4: Defines Reset Recovery procedure
- Section 3.1: States device is ready for next CBW after reset

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jacek Kolakowski <jacek.kolakowski@intel.com>
Signed-off-by: Paul Grimes <Paul.Grimes@amd.com>
2026-01-30 07:02:52 +00:00
Alok Kulkarni
f6489621b8 MdeModulePkg: PciBusDxe: Degrade MEM64 to PMEM64 when bridge lacks MEM64
P2P bridge Memory Base/Limit registers (0x20-0x22) only support 32-bit
addresses. Previously, MEM64 resources behind such bridges were always
degraded to MEM32, forcing allocation below 4GB. This can lead to
resource constraints when using massive storage (such as MPF drives)
as MEM32 space is limited on most platforms.

Based on PCIe Base Specification 6.3+, assigning 64-bit resources
irrespective of the prefetchable/non-prefetchable BAR bit is allowed.

In DegradeResource(), if an upstream bridge supports PMEM64, MEM64
resources are now degraded to PMEM64 first. This enables 64-bit BAR
allocation for devices like NVMe controllers that declare non-
prefetchable 64-bit BARs.

We still fall back to MEM32 degradation if the bridge lacks PMEM64
support as well.

Ref: PCI-SIG ECN "Removing Prefetchable Terminology" (2024-04-05)
Ref: PCIe Base Specification 6.3+

Signed-off-by: Kun Qin <kuqin12@gmail.com>
2026-01-30 04:53:05 +00:00
Khalid Ali
300dada916 MdeModulePkg/Core: Make PPI services spec complaint
The documentation of InstallPpi() and NotifyPpi() in both the spec and
function comment indicate to return EFI_OUT_OF_RESOURCES if memory
allocation fails.

However, the implementation of those two services assert if memory
allocation fails. This is a mismatch between what the function expected to
return and what actually returns.

Fix this by returning EFI_OUT_OF_RESOURCES if memory allocation fails,
so the code matches the documentation and comply with the spec. It is
expected service consumers(callers of these functions) to handle
failures appriciately.

Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
2026-01-30 02:18:50 +00:00
Michael D Kinney
d419725b23 MdeModulePkg/Core/Dxe/Mem: Fix GetMemoryMap() Alignment Issues
Fix alignment issues in memory map entries returned by
GetMemoryMap() when RUNTIME_PAGE_ALLOCATION_GRANULARITY is
larger than DEFAULT_PAGE_ALLOCATION_GRANULARITY.

There are no issues in the Page/Pool Allocation/Free services.

Logic issues issues are addressed in the memory map returned
by GetMemoryMap() due to missing cases for memory map entries
of type EfiConventionalMemory that overlap special memory bins.
Add logic to handle all possible memory map splits required to
convert internal memory map entries into an EFI Memory Map with
EFI Memory Map entries the follow alignment requirements when
the EFI Memory Map entries cover memory bins.

The four cases that must be handled are:
* Memory map entry contained within a bin.    [Already covered]
  Convert memory map entry type
* Memory map entry overlaps beginning of bin. [Added]
  Split memory map entry at beginning of bin.
* Memory map entry overlaps end of bin.       [Added]
  Split memory map entry at end of bin.
* Memory map entry overlaps entire bin.       [Added]
  Split memory map entry at both ends of bin.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-01-28 16:20:18 +00:00
Michael D Kinney
6834d43991 MdeModulePkg/Core/Dxe/Mem: Align initial memory map entries
Fix alignment issues in memory map entries returned by
GetMemoryMap() when RUNTIME_PAGE_ALLOCATION_GRANULARITY is
larger than DEFAULT_PAGE_ALLOCATION_GRANULARITY.

Alignment issues are addressed in the initial memory map
layout when Memory Type Information is provided with memory
bins that use RUNTIME_PAGE_ALLOCATION_GRANULARITY.

There are no issues in the Page/Pool Allocation/Free services.

* CoreSetMemoryTypeInformationRange() make sure there is room
  for all bins when accounting for alignment requirements.
  Allocate space for bins with base and length following
  alignment requirements.

* CoreSetMemoryTypeInformationRange() round up NumberOfPages in
  Memory Type Information based on alignment requirements.
  This is required so GetMemoryMap() will generate memory
  map entries that always follow alignment requirements.

* CoreAddMemoryDescriptor() round up NumberOfPages in
  Memory Type Information based on alignment requirements.
  This is required so GetMemoryMap() will generate memory
  map entries that always follow alignment requirements.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-01-28 16:20:18 +00:00
Damien-Chen
a2aaab4553 MdeModulePkg/Core/PiSmmCore/Page.c: Correct gMemoryMap typo
Correct function comment, gMemoryMep should be gMemoryMap.

Signed-off-by: Damien Chen <inkfan130924783@gmail.com>
2026-01-28 14:03:18 +00:00
Qihang Gao
491262f431 MdeModulePkg/Library: Fix property typos
The word property is misspelled as propery, so fix it.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-01-26 08:44:12 +00:00
Dongyan Qian
6458470010 MdeModulePkg/LoadFileOnFv2: Fix typo in Buffer parameter description
The comment for the Buffer parameter incorrectly said
"then no the size" instead of "then the size".
This patch fixes the typo only; no functional changes.

Reported-by: Yao Zi <ziyao@disroot.org>
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-01-23 10:46:37 +00:00
Dongyan Qian
8c3e181b79 MdeModulePkg/PciBusDxe: Fix typo in Buffer parameter description
The comment for the Buffer parameter incorrectly said
"then no the size" instead of "then the size".
This patch fixes the typo only; no functional changes.

Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-01-23 10:46:37 +00:00
Michael D Kinney
27e4a5510a MdeModulePkg/Universal/RegularExpressionDxe: Fix VS2022 NOOPT IA32 __allmul
Add implementation of intrinsic __allmul that is generated with VS2022
NOOPT IA32 builds.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-01-21 10:07:01 +00:00
George Liao
564b8e1825 MdeModulePkg/AcpiTableDxe:Created EfiACPIReclaimMemory for ACPIHOB RSDP
The RSDP table come from ACPI HOB which may no store in the
EfiACPIReclaimMemory-type memory. Therefore need to reserve an
EfiACPIReclaimMemory-type memory for it.

Signed-off-by: George Liao <george.liao@intel.com>
2026-01-19 09:55:23 +00:00
Aaron Pop (from Dev Box)
4743d8d992 MdeModulePkg: StatusCodeHandler Stmm remove assert
In StandaloneMM mode, IsStatusCodeUsingSerialPort is expecting to
find gMmStatusCodeUseSerialHobGuid, and will assert if it is not found.

Change the logic so that if the Guided Hob is not found, to let
the function return FALSE and progress to proceed.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2026-01-15 06:39:45 +00:00
Arkadiusz Filipowski
b220ba807e MdeModulePkg: Fix overflow in PciAllocateBusNumber
When StartBusNumber is 0xFF NextNumber would overflow and wrap back to 0.
This will be bypass check NextNumber > MaxNumberInRange as a result
PCI enumeration will continue instead of breaking due to lack of resources.

Signed-off-by: Arkadiusz Filipowski <arkadiusz.filipowski@intel.com>
2026-01-14 05:22:38 +00:00
Joey Vagedes
0ab766c6b6 MdeModulePkg: Add unit tests for DxeReportStatusCodeLib
This commit adds a host based unit test for DxeReportStatusCodeLib
that ensures that the platform cannot invert the TPL on an initial
call to ReportStatusCode functionality.

Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
2026-01-14 04:00:20 +00:00
Joey Vagedes
3fe8cad23c MdeModulePkg: RuntimeDxeReportStatusCodeLib: Do not query protocol
This commit stops the library from querying the protocol database for
the status code protocol at the time of library function use. This logic
can result in a TPL inversion if the protocol has not yet been cached
and the caller is calling the library function when the TPL is higher
then TPL_NOTIFY.

Instead, the protocol is now located during the constructor of the
library. If the protocol is not found, then an on-protocol install event
is registered which will cache the protocol. A destructor is also added
to close the event in the scenario that the driver is unloaded before
the protocol is installed.

Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
2026-01-14 04:00:20 +00:00
Joey Vagedes
ce61d5f327 MdeModulePkg: DxeReportStatusCodeLib: Do not query protocol
This commit stops the library from querying the protocol database for
the status code protocol at the time of library function use. This logic
can result in a TPL inversion if the protocol has not yet been cached
and the caller is calling the library function when the TPL is higher
then TPL_NOTIFY.

Instead, the protocol is now located during the constructor of the
library. If the protocol is not found, then an on-protocol install event
is registered which will cache the protocol. A destructor is also added
to close the event in the scenario that the driver is unloaded before
the protocol is installed.

Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
2026-01-14 04:00:20 +00:00
Levi Yun
c16f1cc684 MdePkg,MdeModulePkg/ArmFfaLib: introduce ArmFfaGetPartitionInfo()
Introduce ArmFfaGetPartitionInfo(), which retrieves the first partition
associated with the service GUID. This allows us to remove duplicated
code previously used to obtain the partition ID.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
Continuous-integration-options: PatchCheck.ignore-multi-package
2026-01-08 12:07:46 +00:00
Levi Yun
898ae481d9 MdeModulePkg/ArmFfaLib: support ArmFfaLib wihtout Rx/Tx buffer
In the normal world, it is possible to communicate with
a secure partition using the ARM_FFA_PARTITION_INFO_GET_REGS ABI,
even when the Rx/Tx buffer ABI is not supported.

Therefore, treat the EFI_UNSUPPORTED error returned
during Rx/Tx buffer mapping as a valid result
when the ARM_FFA_PARTITION_INFO_GET_REGS ABI is supported.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-01-08 12:07:46 +00:00
Levi Yun
eea64c7fcd MdePkg, MdeModulePkg/ArmFfaLib: add funcs to get partition info via regs
Starting from FF-A v1.2 [0], the FFA_PARTITION_INFO_GET_REGS
interface was added to retrieve partition information
through registers.

This ABI is useful in environments where the Rx/Tx buffer
does not need to be mapped, or where buffer mapping
is not supported for retrieving partition information.

To support this, two new APIs are introduced:
ArmFfaLibPartitionInfoGetRegs() and ArmFfaLibPartitionCountGetRegs().

Link: https://developer.arm.com/documentation/den0077/latest [0]
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-01-08 12:07:46 +00:00
Qihang Gao
a3c1ea0d0c MdeModulePkg: Optimize the process while cleaning dynamic string
In the current code, the HiiPackageList will be created and destroyed
each time the form is closed, which is unneccessary. This patch makes a
function that produces the origin HiiPackageList. The function will only
be called when the driver is initialized and the HiiPackageList will be
directly updated in DriverHealthManagerCleanDynamicString function. This
approach can avoid the unneccessary creation and destruction of the
HiiPackageList.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-01-08 09:44:39 +00:00
Qihang Gao
4e92a6a9d4 MdeModulePkg: Fix issue that French package is unexpectedly cleaned
The DriverHealthManagerStrings.uni file defines both English and French
languages, resulting in the generation of two Unicode string packages: the
first for English and the second for French. When cleaning the dynamic
strings from the HII package list, the pointer which should point to
dynamic string package incorrectly points to the static French package,
causing it to be unexpectedly cleaned.

This patch fixes the pointer of EFI_HII_PACKAGE_END type PackageHeader.
This way, there is no need for concern regarding the number of language
packages available.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-01-08 09:44:39 +00:00
Piotr Wejman
66346d5ede MdeModulePkg: Fix FreePages not existent memory
Commit 2d69507a4d added an attribute check to
prevent freeing memory that is read-only, read-protected, or for which
attribute retrieval fails. In such cases the code returned EFI_SUCCESS and
leaked the memory.

This introduced a regression in the System Architecture Compliance Suite
(ACS) BS.FreePages – Not Existent Memory test.
Link: https://github.com/tianocore/edk2-test/blob/edk2-test-stable202509/uefi-sct/Doc/TestCaseSpec/03_Services_Boot_Services.md#freepages
Test number: 5.1.2.2.1

GetMemoryAttributes() returns EFI_UNSUPPORTED for memory regions outside
system memory. The previous change treated all errors as a reason to leak
memory, while only the EFI_NO_MAPPING error code should trigger that
behavior. As a result, freeing non-existent memory incorrectly returned
EFI_SUCCESS instead of EFI_NOT_FOUND.

To fix this, memory is now leaked only when:
- GetMemoryAttributes() returns EFI_NO_MAPPING (inconsistent attributes),
  or
- GetMemoryAttributes() succeeds and the pages are marked RO or RP.

All other errors fall through to CoreInternalFreePages(), restoring the
previous and correct behavior.

Signed-off-by: Piotr Wejman <piotr.wejman@arm.com>
2025-12-30 01:36:38 +00:00
Black.Li
7ca8b1b4c7 MdeModulePkg/UfsPassThruDxe:Fix Ufs DM Command issue
After Execute UFS SCSI Commands, the Trd->PRDTL is dirty. It will cause issue
when next UFS DM Command is executed.

According to UFSHCI Spec, for UFS DeviceManagement function Trd->PRDTL
must be set to Zero.

Signed-off-by: Black.Li <black.li@cixtech.com>
2025-12-24 06:41:24 +00:00
Michael D Kinney
17cb2f90b6 MdeModulePkg/BrotliCustomDecompressLib: Undefine _MSC_VER for GCC
Update GCC Family to undefined _MSC_VER to match settings used
by other compilers. This addresses clang compatibility issues
for host-based unit test builds.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-12-24 03:36:31 +00:00
Jeremy Compostella
9fa1a35e56 MdeModulePkg/Universal/DebugServicePei: Correct function and entry point
Correct a typographical error in the DebugServicePei module by renaming
the function and entry point from DebugSerivceInitialize to
DebugServiceInitialize in both the C source file and the INF
configuration file.

Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2025-12-23 23:34:09 +00:00
aaronpop
f9326a4fec MdeModulePkg: Fix regressions from 11687, 11689.
11687 introduced a null check and break on the orderedlist
carriage return input handler. The carriage return is a special
case that should result in exiting the menu, but the null check
that prevented null pointer access changed the logic to continue
in the input wait loop.

Removed the break while still preventing null variable access
and allow function to exit.

11689 introduced checks on the call to EfiBootManagerGetLoadOptions,
but this encounterd a problem with the way that a default
platform recovery option was created.
The default platform recovery option was attempting to go through
existing recovery options to get the next available recovery option
number. The introduced null check short circuited these additional
calls and resulted in the platform recovery option not being created.

Modified the logic to no longer attempt to access recovery options
when non exist, and still create the default platform recovery option.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2025-12-19 14:48:19 +08:00
Khalid Ali
786de8636a MdeModulePkg/PciBusDxe: Fix boot hang introduced by ff3c1ad
The changes introduced by ff3c1ad which made two calls to
ProcessOpRomImage() resulted a platform where single OpRom present, the
same image to be loaded and started.

Prevent loading and starting same image twice.

Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
2025-12-15 08:11:30 +00:00
Qihang Gao
ff3c1adf20 MdeModulePkg: Load the native Option ROM image if the native one exists
Issue:https://github.com/tianocore/edk2/issues/11800

If there are multiple Option ROM images existed, current code will load
the first image that the emulator supports. Usually, x86 ROM image is
the first one and non-x86 ROM image is behind x86 ROM image. When the
emulator is introduced, x86 ROM image instead of native image is loaded
on non-x86 platforms.
This patch introduces a mechanism to prioritize the loading of native
images. Firstly, search the native image. If the native one is found,
just finish the process since the goal is reached. Otherwise, search
the foriegn images that the platform may support.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
Signed-off-by: Chao Li <lichao@loongson.cn>
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Chen Zhang <zhangchen@loongson.cn>
Cc: Dongyan Qian <qiandongyan@loongson.cn>
2025-12-10 09:53:49 +00:00
Aaron Pop
faa0ebc839 MdeModulePkg: Fix regressions from 11686, 11687, 11688, 11689.
11686, 11687, 11688, 11689 included some inverted conditionals
during the refactor. While the system booted, some behavior
was incorrect based on the inverted conditionals.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2025-12-06 09:54:37 +00:00
Ard Biesheuvel
bd4bb10d80 MdeModulePkg: Remove ambiguous negation of narrower type
Replace UINTN casts with EFI_PHYSICAL_ADDRESS in places where the result
is negated, as otherwise, the top bits may remain 0 unexpectedly.

VS2022 started warning about this, and thus breaking the IA32 CI build.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-12-03 11:50:28 +01:00
Aaron Pop
ede299f241 MdeModulePkg: Fix recently introduced uninitialized variable usage.
Address the build regressions, introduced in #11724, #11688, #11686 #11685.
These build regressions are for uninitialized variables before use.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2025-12-02 11:22:46 +01:00
Aaron Pop
1aedb79e9b MdeModulePkg: SpiNorFlash update FillWriteBuffer headers.
The function headers for FillWriteBuffer have become out of
date with the implementation. Update the function headers
to more clearly define the interface for recent changes.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2025-11-24 10:07:21 +01:00
Sathya Ravichandran
88d3a78171 MdeModulePkg/PCD: Replace VariableLock with VariablePolicy
Since VariableLock compromises security in the SMM environment,
it is deprecated. Used VariablePolicy instead for stronger and
more flexible UEFI variable protection.

Ref: [acd66e4]

Cc: Sachin Ganesh <sachinganesh@ami.com>
Signed-off-by: Sathya Ravichandran <sathyar@ami.com>
2025-11-24 06:23:55 +00:00