6668 Commits

Author SHA1 Message Date
Sherry Fan
7e5cc68f1e MdeModulePkg: fix mdlint issues
Fix markdownlint formatting issues in READMEs.

Signed-off-by: Sherry Fan <sherryfan@microsoft.com>
2026-03-04 22:02:33 +00:00
rdiaz
a39c3835aa MdeModulePkg: Add FFA_NS_RES_INFO_GET to ArmFfaCommon
Add FFA_NS_RES_INFO_GET implementation to ArmFfaCommon

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-03-04 01:22:07 +00:00
Damien-Chen
58c9ba24d4 MdeModulePkg/TerminalDxe: Fix Backspace key for VT-UTF8 terminal type
When QEMU is launched with -nographic, the Backspace key (DEL, 0x7f)
doesn't work in the UEFI Shell because the VT-UTF8 terminal type
interprets DEL as SCAN_DELETE instead of CHAR_BACKSPACE.

Modern terminal emulators (xterm, gnome-terminal, etc.) send DEL (0x7f)
for Backspace and are UTF-8 compatible. This patch updates
TerminalTypeVtUtf8 to interpret DEL as CHAR_BACKSPACE, consistent with
how TerminalTypeTtyTerm already handles it.

This approach preserves VT-UTF8 as the default terminal type (which
supports full Unicode), while fixing the Backspace functionality for
modern terminal environments.

Signed-off-by: Damien Chen <inkfan130924783@gmail.com>
2026-02-28 04:43:49 +00:00
Kun Qin
5b9430b72b MdeModulePkg: DxeMain: Check memory type overlap inside CoreGetMemoryMap
This change adds validation to CoreGetMemoryMap to ensure that special
memory bins are fully respected. Specifically, any memory map entry that
falls within a special bin must be entirely contained within that bin,
and its memory type must match the bin's designated type.

This check helps preventing unintended changes that could cause the
system memory map to cross bin boundaries unexpectedly.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-02-28 04:20:00 +00:00
Star Zeng
02d5363679 MdeModulePkg HobPrintLib: Also print EFI_HOB_TYPE_UNUSED type HOB
EFI_HOB_TYPE_UNUSED is not unknown HOB type, instead of printing
"Unknown Hob type, ...", this patch updates code to also print
EFI_HOB_TYPE_UNUSED type HOB.

Signed-off-by: Star Zeng <star.zeng@intel.com>
2026-02-28 03:56:45 +00:00
Ashraf Ali S
41b32312c4 MdeModulePkg: Fix PreferMode selection for same-width text modes
The current PreferMode selection logic requires both Columns AND Rows to
be strictly greater (>) than the current maximum, which fails when a
text mode has the same column count but more rows.

Example failure case (1920x1200 display):
- Mode 5: 240x56 - Selected as PreferMode
- Mode 6: 240x63 - Rejected because 240 is not > 240

This mismatch causes ConsplitterSetConsoleOutMode to later request
Mode 6, triggering an unnecessary text mode change and clearing the
screen during console init.

Root Cause:
GraphicsConsole used: if ((Col > Max) && (Row > Max))
This fails when only rows increase while columns stay the same.

Solution:
Change to: if ((Col >= Max) && (Row >= Max))
This aligns with ConSplitter mode selection logic and correctly selects
the mode with the highest column and row counts.

After fix (1920x1200 display):
- Mode 5: 240x56
- Mode 6: 240x63 - Correctly selected as PreferMode

This ensures GraphicsConsole and ConSplitter match on the preferred mode
preventing unnecessary screen clears during console initialization.

Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
2026-02-28 03:35:35 +00:00
Michael D Kinney
935518abbb MdeModulePkg/Include/Guid: Add back include guard
Add include guards back to include files that use the same
include guard macro in BaseTools/Source/C/Include/Common
and MdePkg or MdeModulePkg.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-02-27 07:15:11 +00:00
Khalid Ali
bd8667a7fd MdeModulePkg/Core: Move SMI depth tracker below SMI presence check
Fixes: #11764

Currently, mSmiManageCallingDepth is incremented always whether SMI
handler is present or not. However get decremented only when SMI handler
is found. This causes mSmiManageCallingDepth to grow infinitely as long
as SMI handler isn't present.

Increment mSmiManageCallingDepth only when SMI handler presence is
confirmed.

Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
2026-02-27 06:09:41 +00:00
Ray Ni
4d0946c082 MdeModulePkg/PeiDxeDebugLibReportStatusCode: Fix comma parsing
The DebugPrintMarker function in PeiDxeDebugLibReportStatusCode/DebugLib.c
does not recognize the comma (`,`) flag in printf-style format strings.
When a driver uses format strings with thousand separators like "%,ld" to
format large numbers (e.g., 1234567 as "1,234,567"), the DebugPrintMarker
parser fails to recognize the comma flag and causes incorrect argument
extraction when building the BASE_LIST for status code reporting, leading
to unexpected or corrupted debug output in status code reports.

The change is to add the missing comma flag check to align with
BasePrintLib's format parsing logic, ensuring consistent behavior across
all print library implementations.

Signed-off-by: Ray Ni <ray.ni@intel.com>
2026-02-27 03:30:57 +00:00
Ray Ni
a7c119589f MdeModulePkg/PeiDebugLibDebugPpi: Fix comma parsing in VaListToBaseList
The VaListToBaseList function in PeiDebugLibDebugPpi/DebugLib.c does not
recognize the comma (`,`) flag in printf-style format strings. When a
driver uses format strings with thousand separators like "%,ld" to format
large numbers (e.g., 1234567 as "1,234,567"), the VaListToBaseList parser
fails to recognize the comma flag and causes incorrect argument extraction
from the VA_LIST, leading to unexpected or corrupted debug output.

The change is to add a check for the comma character in the format string
parsing logic to align with BasePrintLib's format parsing logic,
ensuring consistent behavior across all print library implementations.

Signed-off-by: Ray Ni <ray.ni@intel.com>
2026-02-27 03:30:57 +00:00
Jacek Kolakowski
2e92a908e7 MdeModulePkg: Mark PcdMrIovSupport obsolete - deprecated in PCIe 6.0
MR-IOV was actually not used in MdeModulePkg and it has been
deprecated in PCIe 6.0 specification. Remove code references,
but keep PcdMrIovSupport with just a comment that it is deprecated.

Signed-off-by: Jacek Kolakowski <Jacek.Kolakowski@intel.com>
2026-02-25 05:03:02 +00:00
Jacek Kolakowski
24eddc65b3 MdeModulePkg: Add platform limit for size in Resizable BAR
Resizable BAR driver selects max available BAR size to configure for use.
It may happen that some PCIe device declare support for size that exceeds
processor address width. Platform needs a way to define the max size it
can accept. This change introduce PCD called PcdPcieResizableBarMaxSize.
It is dynamic PCD where platform can provide its limit for BAR size.
Such PCD can be also controlled with a configuration knob.

Signed-off-by: Jacek Kolakowski <Jacek.Kolakowski@intel.com>
2026-02-25 03:40:14 +00:00
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