Skip to content

Commit

Permalink
[Cherry-Pick] Switch to use edk2-pytool-library UefiVariableSupportLib (
Browse files Browse the repository at this point in the history
microsoft#500)

There are multiple copies of VariableSupportLib floating across repos,
mostly only supporting Windows.

Functionality has been consolidated into edk2-pytool-library version
0.21.7. Support for Linux has been added.

Switch MfciPolicy.py, DecodeUefiLog.py and UefiVarAudit.py to use
consolidated version from edk2-pytool-library.

Removed local copies of VariableSupportLib.py

- [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, ...
- [ ] 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, ...

N/A
  • Loading branch information
apop5 committed Aug 27, 2024
1 parent 83f065e commit 18147d9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 404 deletions.
9 changes: 4 additions & 5 deletions AdvLoggerPkg/Application/DecodeUefiLog/DecodeUefiLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import copy

from win32com.shell import shell

from UefiVariablesSupportLib import UefiVariable
from edk2toollib.os.uefivariablesupport import UefiVariable


class AdvLogParser ():
Expand Down Expand Up @@ -1003,7 +1002,7 @@ def ReadLogFromUefiInterface():

while rc == 0:
VariableName = 'V'+str(Index)
(rc, var, errorstring) = UefiVar.GetUefiVar(VariableName, 'a021bf2b-34ed-4a98-859c-420ef94f3e94')
(rc, var) = UefiVar.GetUefiVar(VariableName, 'a021bf2b-34ed-4a98-859c-420ef94f3e94')
if (rc == 0):
Index += 1
InFile.write(var)
Expand Down Expand Up @@ -1060,7 +1059,7 @@ def main():
CountOfLines = len(lines)
print(f"{CountOfLines} lines written to {options.OutFilePath}")

except Exception as ex:
except Exception:
print("Error processing log output.")
traceback.print_exc()

Expand All @@ -1072,7 +1071,7 @@ def main():
RawFile.close()
print("RawFile complete")

except Exception as ex:
except Exception:
print("Error processing raw file output.")
traceback.print_exc()

Expand Down
114 changes: 0 additions & 114 deletions AdvLoggerPkg/Application/DecodeUefiLog/UefiVariablesSupportLib.py

This file was deleted.

20 changes: 10 additions & 10 deletions MfciPkg/Application/MfciPolicy/MfciPolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import argparse
import ctypes
from UefiVariableSupport.UefiVariablesSupportLib import UefiVariable
from edk2toollib.os.uefivariablesupport import UefiVariable

MFCI_VENDOR_GUID = "EBA1A9D2-BF4D-4736-B680-B36AFB4DD65B"
CURRENT_POLICY_BLOB = "CurrentMfciPolicyBlob"
Expand Down Expand Up @@ -77,7 +77,7 @@ def get_system_info():
UefiVar = UefiVariable()

for Variable in MFCI_POLICY_INFO_VARIABLES:
(errorcode, data, errorstring) = UefiVar.GetUefiVar(Variable, MFCI_VENDOR_GUID)
(errorcode, data) = UefiVar.GetUefiVar(Variable, MFCI_VENDOR_GUID)
if errorcode != 0:
logging.critical(f"Failed to get policy variable {Variable}")
else:
Expand All @@ -91,7 +91,7 @@ def get_system_info():
def get_current_mfci_policy():
UefiVar = UefiVariable()

(errorcode, data, errorstring) = UefiVar.GetUefiVar(CURRENT_MFCI_POLICY, MFCI_VENDOR_GUID)
(errorcode, data) = UefiVar.GetUefiVar(CURRENT_MFCI_POLICY, MFCI_VENDOR_GUID)
if errorcode == 0:
result = hex(int.from_bytes(data, byteorder="little", signed=False))
logging.info(f" Current MFCI Policy is {result}")
Expand All @@ -104,17 +104,17 @@ def get_current_mfci_policy():
def delete_current_mfci_policy():
UefiVar = UefiVariable()

(errorcode, data, errorstring) = UefiVar.SetUefiVar(CURRENT_POLICY_BLOB, MFCI_VENDOR_GUID, None, 3)
(errorcode, data) = UefiVar.SetUefiVar(CURRENT_POLICY_BLOB, MFCI_VENDOR_GUID, None, 3)
if errorcode == 0:
logging.info(f"Failed to Delete {CURRENT_POLICY_BLOB}\n {errorcode}{errorstring}")
logging.info(f"Failed to Delete {CURRENT_POLICY_BLOB}\n {errorcode}")
print(f"Failed to delete {CURRENT_POLICY_BLOB}")
else:
logging.info(f"{CURRENT_POLICY_BLOB} was deleted")
print(f"{CURRENT_POLICY_BLOB} was deleted")

(errorcode, data, errorstring) = UefiVar.SetUefiVar(NEXT_MFCI_POLICY_BLOB, MFCI_VENDOR_GUID, None, 3)
(errorcode, data) = UefiVar.SetUefiVar(NEXT_MFCI_POLICY_BLOB, MFCI_VENDOR_GUID, None, 3)
if errorcode == 0:
logging.info(f"Failed to Delete {NEXT_MFCI_POLICY_BLOB}\n {errorcode}{errorstring}")
logging.info(f"Failed to Delete {NEXT_MFCI_POLICY_BLOB}\n {errorcode}")
print(f"Failed to delete {NEXT_MFCI_POLICY_BLOB}")
else:
logging.info(f"{NEXT_MFCI_POLICY_BLOB} was deleted")
Expand All @@ -128,9 +128,9 @@ def set_next_mfci_policy(policy):
var = file.read()
UefiVar = UefiVariable()

(errorcode, data, errorstring) = UefiVar.SetUefiVar(NEXT_MFCI_POLICY_BLOB, MFCI_VENDOR_GUID, var, 3)
(errorcode, data) = UefiVar.SetUefiVar(NEXT_MFCI_POLICY_BLOB, MFCI_VENDOR_GUID, var, 3)
if errorcode == 0:
logging.info("Next Policy failed: {errorstring}")
logging.info("Next Policy failed: {errorcode}")
else:
logging.info("Next Policy was set")
print(f"{NEXT_MFCI_POLICY_BLOB} was set")
Expand All @@ -139,7 +139,7 @@ def set_next_mfci_policy(policy):
def get_next_mfci_policy():
UefiVar = UefiVariable()

(errorcode, data, errorstring) = UefiVar.GetUefiVar(NEXT_MFCI_POLICY_BLOB, MFCI_VENDOR_GUID)
(errorcode, data) = UefiVar.GetUefiVar(NEXT_MFCI_POLICY_BLOB, MFCI_VENDOR_GUID)
if errorcode != 0:
logging.info("No Next Mfci Policy Set")
print(f"No variable {NEXT_MFCI_POLICY_BLOB} found")
Expand Down

This file was deleted.

Loading

0 comments on commit 18147d9

Please sign in to comment.