Commit graph

1596 commits

Author SHA1 Message Date
JinKang
cc9a0425a2 ShellPkg/Shell: Preserve multi-instance device paths
EfiShellGetMapFromDevicePath() stops at any end-type node and
converts an end-instance node into an end-entire node. This truncates a
multi-instance device path and modifies the protocol data in place.

Walk until the end-entire node instead. This leaves intermediate
instances and the original device path unchanged.

Signed-off-by: JinKang <2371488344@qq.com>
2026-08-26 13:32:07 +02:00
Pierre Gondois
fa41c179db ShellPkg/EfiDecompress: Fix Codeql issues
Fix codeql reported issues by flattening MainCmdEfiDecompress(),
making it easier for the tool to evaluate potential risks.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
383e680c3c ShellPkg/Comp: Extract helper functions
Refactor the Comp command and extract 2 functions:
- OpenFileOperand()
- CompareFiles()

This allows to simplify the logic of MainCmdComp() and
fix some codeql reported potential errors.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
35a2f27546 ShellPkg/EfiDecompress: Check presence of decompression protocol
Check the return value of LocateProtocol() before
using the decompression protocol. This avoids a
potential NULL pointer derefence spotted by codeql.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
d9185d45c2 ShellPkg/Dmem: Refactor MainCmdDmem()
Refactor MainCmdDmem() to make it easier to understand.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
f260ae0375 ShellPkg/EfiCompress: Extract OpenFileHelper() and CompressFile()
Extract file opening and compression code into helpers.

Upon calling:
- gEfiShellProtocol->GetFileSize()
- gEfiShellProtocol->ReadFile()
the returned Status is now checked.

Upon calling AllocateZeroPool, the failed status is now set to
EFI_OUT_OF_RESOURCES.

Other than that, no functional change.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
c089090278 ShellPkg/Pci: Extract ParsePciBdf()
Extract BDF argument parsing into a helper.

No functional change.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
ba2f216986 ShellPkg/Pci: Extract PciEnumerateAll()
Extract the default PCI enumeration path into a helper.

No functional change.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
42f1d004c0 ShellPkg/UefiShellDebug1: Lower indentation level in MainCmdXXX() (4/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Lower the indentation level in the newly created MainCmdXXX()
functions.

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- SerMode.c
- SetSize.c
- SetVar.c
- SmbiosView/SmbiosView.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
642954d295 ShellPkg/UefiShellDebug1: Lower indentation level in MainCmdXXX() (3/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Lower the indentation level in the newly created MainCmdXXX()
functions.

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- MemMap.c
- Mm.c
- Mode.c
- Pci.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
d395696428 ShellPkg/UefiShellDebug1: Lower indentation level in MainCmdXXX() (2/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Lower the indentation level in the newly created MainCmdXXX()
functions.

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Edit/Edit.c
- EfiCompress.c
- EfiDecompress.c
- LoadPciRom.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
cad93da7e5 ShellPkg/UefiShellDebug1: Lower indentation level in MainCmdXXX() (1/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Lower the indentation level in the newly created MainCmdXXX()
functions.

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Comp.c
- Cxl.c
- Dblk.c
- Dmem.c
- DmpStore.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
cebf8bc4ae ShellPkg/UefiShellDebug1: Extract MainCmdXXX() function (4/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package

For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- SerMode.c
- SetSize.c
- SetVar.c
- SmbiosView/SmbiosView.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
0b6156b43a ShellPkg/UefiShellDebug1: Extract MainCmdXXX() function (3/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package

For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- MemMap.c
- Mm.c
- Mode.c
- Pci.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
5bdbf4462b ShellPkg/UefiShellDebug1: Extract MainCmdXXX() function (2/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package

For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Edit/Edit.c
- EfiCompress.c
- EfiDecompress.c
- HexEdit/HexEdit.c
- LoadPciRom.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
6d0ef532c6 ShellPkg/UefiShellDebug1: Extract MainCmdXXX() function (1/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package

For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Comp.c
- Cxl.c
- Dblk.c
- Dmem.c
- DmpStore.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
cb7f7262d5 ShellPkg/Mm: Remove unnecessary goto
If ShellCommandLineParse() fails, there is no need to free:
- InputStr
- Package
Remove the goto statement.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
adad73339d ShellPkg/ShellDebug1: Rationalize Package init/free
Package is sometimes initialized to NULL and only
freed if not NULL. Remove these as:
- Package is initialized in ShellCommandLineParse().
- If ShellCommandLineFreeVarList() is reached,
  Package cannot be NULL.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
c827978910 ShellPkg/LoadPciRom: Fix memory leak
Package is never freed.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
6dea226953 ShellPkg/UefiShellDebug1: Return if ShellCommandLineParse() failed (4/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- SerMode.c
- SetSize.c
- SetVar.c
- SmbiosView/SmbiosView.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
da181122b1 ShellPkg/UefiShellDebug1: Return if ShellCommandLineParse() failed (3/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- MemMap.c
- Mm.c
- Mode.c
- Pci.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
d23559e847 ShellPkg/UefiShellDebug1: Return if ShellCommandLineParse() failed (2/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Edit/Edit.c
- EfiCompress.c
- EfiDecompress.c
- HexEdit/HexEdit.c
- LoadPciRom.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
7ee84dc437 ShellPkg/UefiShellDebug1: Return if ShellCommandLineParse() failed (1/4)
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.

Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().

To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Comp.c
- Cxl.c
- Dblk.c
- Dmem.c
- DmpStore.c

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
4e1e739338 ShellPkg/Ls: Remove double-free calls
Package is always freed in ShellCommandRunLs().
Remove calls to ShellCommandLineFreeVarList() in MainCmdLs().

This double-free was introduced in:
commit 531b0aa002 ("ShellPkg/UefiShellLevel2:
Extract MainCmdXXX() function")

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Pierre Gondois
a3da9cde61 ShellPkg/Edit: Remove unused code snippet
The commented out code snippet seems to try to create a new file
with the user input filename. FileBufferRead() seems to have replaced
this code snippet in a better wrapper:
- if the file exists, open it
- otherwise, create the file

Remove the commented-out code snippet.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-08-04 10:35:35 +03:00
Michael Kubacki
df9111c2d3 Global: Set MarkdownLintCheck plugin to AuditOnly
In preparation for the MarkdownLintCheck plugin being added to the
repo, this change defaults the plugin to `AuditOnly` mode in each
package. This allows package maintainers to enable the plugin as they
see fit.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-29 12:32:09 +00:00
Vincent Gatine
21b358b81d ShellPkg/Pci: Restore BAR informations
Restore informations lost in the pci shell command.

sbsa-ref Host Bridge:

```
 Cache Line Size(C): 00                 Latency Timer(D): 00
 Header Type(0E):    00, Single function, PCI device
 Class: Bridge Device - Host/PCI bridge -
+Base Address Registers(10):
+  (None)
+Expansion ROM Disabled(30)
+
+Cardbus CIS ptr(28):   00000000
+Sub VendorID(2C):          1AF4      Subsystem ID(2E):      1100
+Capabilities Ptr(34):        00
+Interrupt Line(3C):          FF      Interrupt Pin(3D):       00
+Min_Gnt(3E):                 00      Max_Lat(3F):             00
```
sbsa-ref Ethernet Controller:

```
 Cache Line Size(C): 00                 Latency Timer(D): 00
 Header Type(0E):    00, Single function, PCI device
 Class: Network Controller - Ethernet controller -
+Base Address Registers(10):
+     Start_Address  Type  Space    Prefetchable?     Size             Limit
+  --------------------------------------------------------------------------
+          81060000  Mem   32 bits  No             00020000          8107FFFF
+          81040000  Mem   32 bits  No             00020000          8105FFFF
+              0000  I/O                               0020              001F
+          81080000  Mem   32 bits  No             00004000          81083FFF
+  --------------------------------------------------------------------------
+Expansion ROM Disabled(30)
+
+Cardbus CIS ptr(28):   00000000
+Sub VendorID(2C):          8086      Subsystem ID(2E):      0000
+Capabilities Ptr(34):        C8
+Interrupt Line(3C):          FF      Interrupt Pin(3D):       01
+Min_Gnt(3E):                 00      Max_Lat(3F):             00

 Pci Express device capability structure:
 CapID( 0):          10            NextCap Ptr( 1):    A0
```

Signed-off-by: Vincent Gatine <vincent.gatine@sipearl.com>
2026-07-17 22:58:58 +00:00
Sami Mujawar
a70c872966 ShellPkg/AcpiView: Add parser for CCEL ACPI table
The ACPI 6.5 specification introduces the CCEL (CC Event Log) table
in section 5.2.34:
https://uefi.org/specs/ACPI/6.5/
05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table

Extend AcpiView with a parser to decode and display CCEL table
contents. This allows users to inspect CCEL tables from the UEFI
Shell.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-03 12:24:39 +00:00
Sami Mujawar
f47d5291b9 ShellPkg/Acpiview: Make reserved-field validation common
Move the reserved-field validators from MpamParser.c into AcpiParser.c
and expose them through AcpiParser.h so they can be reused by multiple
Acpiview parsers.

Update the AGDI, MPAM and WSMT parsers to use the common helpers for
byte-length and bit-length reserved fields.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-03 12:24:39 +00:00
Sami Mujawar
ec44a71ba7 ShellPkg/Acpiview: Increase the max supported parsers
The RegisterParser() function is failing with error code
EFI_OUT_OF_RESOURCES as we have run out of space for
registering the ACPI table parsers in mTableParserList[].

Therefore, increase the MAX_ACPI_TABLE_PARSERS to 128.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-03 12:24:39 +00:00
VarshitPandya
c362e91e56 ShellPkg: Add missing smbiosview Type 28 locations
Add the missing SMBIOS Type 28 Temperature Probe location decode values
to smbiosview.

The Type 28 Location field defines values 0x0C through 0x0F for Front
Panel Board, Back Panel Board, Power System Board, and Drive Back Plane,
but smbiosview only decoded values up to 0x0B.

Signed-off-by: VarshitPandya <varshit.pandya@arm.com>
2026-07-02 07:22:54 +00:00
VarshitPandya
7bc6629f40 ShellPkg: Fix smbiosview Type 26 location/status decode
The smbiosview Type 26 Voltage Probe decoder uses the low 5 bits of
LocationAndStatus as the probe location and the high 3 bits as the probe
status.

However, the Type 26 lookup tables were swapped: VPLocationTable contained
status strings and VPStatusTable contained location strings. This caused
valid records to be displayed as, for example:

  Voltage Probe - Location: OK
  Voltage Probe - Status: Processor

Swap the table contents so Type 26 output matches the SMBIOS
LocationAndStatus bit layout.

Signed-off-by: VarshitPandya <varshit.pandya@arm.com>
2026-07-02 07:22:54 +00:00
Qihang Gao
8dab052c57 ShellPkg: Add null pointer checks before dereference
In AllocateMemory(), several pointers are used without prior null
checks. This may lead to unexpected behavior or system crashes if any
of these pointers are NULL.

Add explicit null checks for these pointers to ensure safe access and
prevent potential null pointer dereferences.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-07-01 12:10:28 +00:00
VarshitPandya
4ad28a8588 ShellPkg: ShellPkg: Fix SMBIOS Type 28 probe labels
Use a Temperature Probe specific HII string when displaying the Type 28
Location field in smbiosview.

The Type 28 decoder was using the Voltage Probe location label, causing
temperature probe records to be displayed with the wrong field name.

Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
2026-06-29 17:19:33 +00:00
VarshitPandya
39d8052bc6 ShellPkg: Fix SMBIOS Type 26 probe decoding
Decode the Type 26 Voltage Probe Location and Status fields according
to the SMBIOS 3.9.0 specification, section 7.27, "Voltage Probe
(Type 26)".

Table 95, "Voltage Probe: Location and Status fields", defines bits
4:0 as the Location field and bits 7:5 as the Status field. smbiosview
was decoding these fields in the opposite order, causing the displayed
voltage probe location and status to be swapped.

Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
2026-06-29 17:19:33 +00:00
Qihang Gao
70741a15d9 ShellPkg: Fix the issue that the UEFI Shell layout is messed up
Fixes https://github.com/tianocore/edk2/issues/12689

When the UEFI Shell mapping table is empty (NULL), the console layout
becomes corrupted in DEBUG builds. This occurs because the cursor position
for the message map: No mapping found. is computed incorrectly under DEBUG
mode. The presence of DEBUG output from the Shell driver causes
gST->ConOut->Mode->CursorRow to no longer reflect the actual cursor position
on the serial port, leading to misplacement of subsequent output.

This patch replaces the existing print routine with ShellPrintHiiDefaultEx().
The new function automatically calculates the correct cursor position for the
"No mapping found" line, eliminating the dependency on the stale CursorRow
value. As a result, the layout remains consistent regardless of DEBUG message
activity.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-06-21 16:49:02 +00:00
Mingjie Shen
018240c278 ShellPkg: Replace manual alignment checks with helper macros
Replace manual alignment checks with IS_ALIGNED() and
ADDRESS_IS_ALIGNED().

Convert the following bitmask and modulo forms:

- ((E & ((PowOf2Expr) - ONE)) == ZERO)
- ((E & ((PowOf2Expr) - ONE)) != ZERO)
- ((E % (PowOf2Expr)) == ZERO)
- ((E % (PowOf2Expr)) != ZERO)

to the corresponding helper macro forms:

+ IS_ALIGNED (E, PowOf2Expr)
+ !IS_ALIGNED (E, PowOf2Expr)

PowOf2Expr is limited to known power-of-two expressions, including
SIZE_* and BASE_* macros, EFI_PAGE_SIZE, CPU_STACK_ALIGNMENT,
RUNTIME_PAGE_ALLOCATION_GRANULARITY, sizeof() of UEFI integer types
(e.g. BOOLEAN, CHAR16, UINT32, UINTN) and pointer types, and 1 << E1
expressions.

Address checks that cast the checked value to UINTN are written with
ADDRESS_IS_ALIGNED().

The change was generated with the Coccinelle semantic patch below.

```smpl
@power_of_2_expr@
expression PowOf2Expr;
expression E1;
typedef BOOLEAN, CHAR8, CHAR16, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, INTN, UINTN;
type ScalarType = { BOOLEAN, CHAR8, CHAR16, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, INTN, UINTN };
type AnyType;
type PointerType = AnyType *;
idexpression ScalarType ScalarValue;
idexpression PointerType PointerValue;
constant SizeBase =~ "^(SIZE|BASE)_(1|2|4|8|16|32|64|128|256|512)[KMGTPE]B$";
constant NamedPowerOf2 =~ "^(EFI_PAGE_SIZE|CPU_STACK_ALIGNMENT|RUNTIME_PAGE_ALLOCATION_GRANULARITY)$";
constant ONE = {1, 1U, 1u};
@@
(
(
  SizeBase
|
  NamedPowerOf2
|
  ONE << E1
|
  sizeof (ScalarType)
|
  sizeof (PointerType)
|
  sizeof (ScalarValue)
|
  sizeof (PointerValue)
)
&
PowOf2Expr
)

@aligned depends on power_of_2_expr disable is_zero,isnt_zero@
expression E;
expression power_of_2_expr.PowOf2Expr;
constant ONE = {1, 1U, 1u};
constant ZERO = {0, 0U, 0u};
@@
(
  ((E & (E - ONE)) == ZERO)
|
- ((E & ((PowOf2Expr) - ONE)) == ZERO)
+ IS_ALIGNED (E, PowOf2Expr)
|
  ((E & (E - ONE)) != ZERO)
|
- ((E & ((PowOf2Expr) - ONE)) != ZERO)
+ !IS_ALIGNED (E, PowOf2Expr)
|
- ((E % (PowOf2Expr)) == ZERO)
+ IS_ALIGNED (E, PowOf2Expr)
|
- ((E % (PowOf2Expr)) != ZERO)
+ !IS_ALIGNED (E, PowOf2Expr)
)

@address_is_aligned@
typedef UINTN;
expression *Address;
expression Alignment;
@@
- IS_ALIGNED ((UINTN) Address, Alignment)
+ ADDRESS_IS_ALIGNED (Address, Alignment)

@normalize_aligned disable paren expression@
expression E, SZ;
@@
(
- (IS_ALIGNED (E, SZ))
+ IS_ALIGNED (E, SZ)
|
- (!IS_ALIGNED (E, SZ))
+ !IS_ALIGNED (E, SZ)
)

@normalize_macro_args disable paren expression@
expression E, SZ;
@@
(
- IS_ALIGNED ((E), SZ)
+ IS_ALIGNED (E, SZ)
|
- IS_ALIGNED (E, (SZ))
+ IS_ALIGNED (E, SZ)
)
```

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2026-06-09 07:20:10 +00:00
Qihang Gao
28c09d6d56 ShellPkg: Remove improper Depex section in UEFI_APPLICATION
According to INF specification, UEFI_APPLICATION cannot have Depex
section. So remove it.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-06-09 05:51:07 +00:00
Simon Wang
2816ff0ab0 ShellPkg/Acpiview: Refactor EINJ table parser validation
ACPI defines Injection Header Size as the length of the EINJ
injection header, not necessarily the absolute offset of the
instruction entries. Update parser validation to use the correct
entry offset calculation and accept the layout used by Linux and
existing firmware tables.

Signed-off-by: Simon Wang <simowang@nvidia.com>
2026-06-03 06:16:13 +00:00
Oliver Smith-Denny
bf5ed9cc55 Global: Fix Spelling Errors in PCI/PCIe Definitions
Fix spelling errors in definitions in Pci22.h.
Update consumers in MdeModulePkg, OvmfPkg, ShellPkg,
and SourceLevelDebugPkg.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-05-08 02:15:34 +00:00
Pierre Gondois
f1f89f454c ShellPkg/UefiShellLevel3: Lower indentation level in MainCmdXXX()
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.

Lower the indentation level in the newly created MainCmdXXX()
functions.

Some ASSERT() are removed in Help.c as they check variables
which were initialized a few lines above.

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Pierre Gondois
8b5c970c55 ShellPkg/Help: Extract PrintMatchingHelp() function
Extract a PrintMatchingHelp() function in the Help command
to help splitting the logic MainCmdHelp() function.

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Pierre Gondois
27c785b0df ShellPkg/UefiShellLevel3: Extract ProcessFileList() function
Extract a ProcessFileList() in:
- Touch.c
- Type.c
to lower the indentation level and simplify the logic.

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Pierre Gondois
014d8fb941 ShellPkg/UefiShellLevel3: Extract MainCmdXXX() function
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.

Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Pierre Gondois
49ba46ec0a ShellPkg/UefiShellLevel3: Return if ShellCommandLineParse() failed
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.

Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Pierre Gondois
a219f8cfc5 ShellPkg/Help: Free package on all paths
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Pierre Gondois
899b8b8550 ShellPkg/Type: Factorize character display
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Pierre Gondois
680ee2e3e9 ShellPkg/Cls: Factorize color parsing
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-05-01 12:16:07 +00:00
Oleksandr Tymoshenko
68662fd712 ShellPkg: Add 'cxl' command
Add a 'cxl' command to list and query CXL devices.

Signed-off-by: Oleksandr Tymoshenko <ovt@google.com>
2026-05-01 08:48:04 +02:00
Pierre Gondois
c801f959bb ShellPkg/UefiShellLevel1: Lower indentation level in MainCmdXXX()
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.

Lower the indentation level in the newly created MainCmdXXX()
functions.
Remove the ShellStatus variable which is not necessary.

No functional change should be induced by this patch.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2026-04-30 12:14:33 +00:00