Skip to content

Commit

Permalink
Add varpolicy dynamic shell command (#254)
Browse files Browse the repository at this point in the history
## Description

Adds a new module (dynamic shell command) to ShellPkg that lists
variable policy information for all UEFI variables on the system.

Some other UEFI variable related functionality is also included to
give a greater sense of platform UEFI variable state.

Like all dynamic shell commands, a platform only needs to include
`VariablePolicyDynamicCommand.inf` in their flash image to have
the command registered in their UEFI shell.

- [x] Impacts functionality?
  - **Functionality** - Does the change ultimately impact how firmware functions?
  - Examples: Add a new library, publish a new PPI, update an algorithm, ...
- [ ] Impacts security?
  - **Security** - Does the change have a direct security impact on an application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
  - **Breaking change** - Will anyone consuming this change experience a break
    in build or boot behavior?
  - Examples: Add a new library class, move a module to a different repo, call
    a function in a new library class in a pre-existing module, ...
- [x] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
  - **Documentation** - Does the change contain explicit documentation additions
    outside direct code modifications (and comments)?
  - Examples: Update readme file, add feature readme file, link to documentation
    on an a separate Web page, ...

## How This Was Tested

Verified:

1. ShellPkg builds the module
2. A platform (QemuQ35Pkg) can integrate and run the module
3. Command is registered and available in shell
4. Command help text shows and is correct
5. Command flag arguments parse as expected
6. `"varpolicy"` dumps platform variables
7. `"varpolicy -?"` shows help text
8. `"varpolicy -b"` pages output as expected
9. `"varpolicy -s"` shows accurate variable statistic information
10. `"varpolicy -p"` shows accurate UEFI variable policy information
11. `"varpolicy-v -b"` dumps all information including variable data hex dump
12. The command unloads correctly

## Integration Instructions

Include the following lines in platform DSC (in DXE components section):

```
  ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf {
    <PcdsFixedAtBuild>
      gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
  }
```

Include the following line in platform FDF:

```
INF  ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf
```

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki authored and kenlautner committed Oct 18, 2023
1 parent bffca97 commit 9a80c32
Show file tree
Hide file tree
Showing 5 changed files with 1,248 additions and 0 deletions.
Loading

0 comments on commit 9a80c32

Please sign in to comment.