-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Driver to existing Binary of specified GUID #12
Open
YuweiChen1110
wants to merge
2
commits into
intel:main
Choose a base branch
from
YuweiChen1110:XmlCli_Submit0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Built-in imports | ||
from collections import namedtuple | ||
Check notice Code scanning / CodeQL Unused import Note
Import of 'namedtuple' is not used.
|
||
|
||
# custom imports | ||
import structure | ||
from logger import log | ||
|
||
|
||
__version__ = "0.0.1" | ||
__author__ = "Christine Chen & Yuting2 Yang" | ||
|
||
class TreeStructure: | ||
def __init__(self) -> None: | ||
self.ParentNode = None | ||
self.ChildNodeList = [] | ||
|
||
class TreeNode: | ||
def __init__(self, Key) -> None: | ||
self.Key = Key | ||
self.Type = None | ||
self.Data = b'' | ||
self.WholeTreeData = b'' | ||
self.Position = TreeStructure() | ||
|
||
def HasChild(self): | ||
if self.Position.ChildNodeList != []: | ||
return True | ||
else: | ||
return False | ||
|
||
def InsertChildNode(self, NewChild, order=None): | ||
if order is not None: | ||
self.Position.ChildNodeList.insert(order, NewChild) | ||
NewChild.Position.ParentNode = self | ||
else: | ||
self.Position.ChildNodeList.append(NewChild) | ||
NewChild.Position.ParentNode = self | ||
|
||
def RemoveChildNode(self, RemoveChild): | ||
self.Position.ChildNodeList.remove(RemoveChild) | ||
|
||
def FindNode(self, key, findlist) -> None: | ||
if self.Type == 'FFS' and self.Data.Name.guid==key.guid: | ||
findlist.append(self) | ||
for item in self.Position.ChildNodeList: | ||
item.FindNode(key, findlist) | ||
|
||
class FvNode: | ||
def __init__(self): | ||
self.Name = '' | ||
self.Header = None | ||
self.ExtHeader = None | ||
self.Data = b'' | ||
self.Info = None | ||
self.IsValid = None | ||
self.Free_Space = 0 | ||
|
||
def InitExtEntry(self, buffer, buffer_pointer): | ||
self.ExtEntryOffset = self.Header.ExtHeaderOffset + 20 | ||
buffer.seek(buffer_pointer+self.ExtEntryOffset) | ||
if self.ExtHeader.ExtHeaderSize != 20: | ||
self.ExtEntryExist = 1 | ||
self.ExtEntry = structure.EfiFirmwareVolumeExtEntry.read_from(buffer) | ||
self.ExtTypeExist = 1 | ||
if self.ExtEntry.ExtEntryType == 0x01: | ||
nums = (self.ExtEntry.ExtEntrySize - 8) // 16 | ||
self.ExtEntry = structure.Refine_FV_EXT_ENTRY_OEM_TYPE_Header(nums).read_from(buffer) | ||
elif self.ExtEntry.ExtEntryType == 0x02: | ||
nums = self.ExtEntry.ExtEntrySize - 20 | ||
self.ExtEntry = structure.Refine_FV_EXT_ENTRY_GUID_TYPE_Header(nums).read_from(buffer) | ||
elif self.ExtEntry.ExtEntryType == 0x03: | ||
self.ExtEntry = structure.EfiFirmwareVolumeExtEntryUsedSizeType.read_from(buffer) | ||
else: | ||
self.ExtTypeExist = 0 | ||
else: | ||
self.ExtEntryExist = 0 | ||
|
||
def ModCheckSum(self): | ||
# Fv Header Sums to 0. | ||
Header = structure.struct2stream(self.Header)[::-1] | ||
Size = self.Header.HeaderLength // 2 | ||
Sum = 0 | ||
for i in range(Size): | ||
Sum += int(Header[i*2: i*2 + 2].hex(), 16) | ||
if Sum & 0xffff: | ||
self.Header.Checksum = 0x10000 - (Sum - self.Header.Checksum) % 0x10000 | ||
|
||
def ModFvExt(self): | ||
# If used space changes and self.ExtEntry.UsedSize exists, self.ExtEntry.UsedSize need to be changed. | ||
if self.Header.ExtHeaderOffset and self.ExtEntryExist and self.ExtTypeExist and self.ExtEntry.Hdr.ExtEntryType == 0x03: | ||
self.ExtEntry.UsedSize = self.Header.FvLength - self.Free_Space | ||
|
||
def ModFvSize(self): | ||
# If Fv Size changed, self.Header.FvLength and self.Header.BlockMap[i].NumBlocks need to be changed. | ||
BlockMapNum = len(self.Header.BlockMap) | ||
for i in range(BlockMapNum): | ||
if self.Header.BlockMap[i].Length: | ||
self.Header.BlockMap[i].NumBlocks = self.Header.FvLength // self.Header.BlockMap[i].Length | ||
|
||
def ModExtHeaderData(self): | ||
if self.Header.ExtHeaderOffset: | ||
ExtHeaderData = structure.struct2stream(self.ExtHeader) | ||
ExtHeaderDataOffset = self.Header.ExtHeaderOffset - self.Header.HeaderLength | ||
self.Data = self.Data[:ExtHeaderDataOffset] + ExtHeaderData + self.Data[ExtHeaderDataOffset+20:] | ||
if self.Header.ExtHeaderOffset and self.ExtEntryExist: | ||
ExtHeaderEntryData = structure.struct2stream(self.ExtEntry) | ||
ExtHeaderEntryDataOffset = self.Header.ExtHeaderOffset + 20 - self.HeaderLength | ||
self.Data = self.Data[:ExtHeaderEntryDataOffset] + ExtHeaderEntryData + self.Data[ExtHeaderEntryDataOffset+len(ExtHeaderEntryData):] | ||
|
||
|
||
class FfsNode: | ||
def __init__(self): | ||
self.Name = '' | ||
self.Header = None | ||
self.Data = b'' | ||
self.PadData = b'' | ||
self.Info = None | ||
self.FfsType = None | ||
|
||
def ModCheckSum(self) -> None: | ||
HeaderData = structure.struct2stream(self.Header) | ||
HeaderSum = 0 | ||
for item in HeaderData: | ||
HeaderSum += item | ||
HeaderSum -= self.Header.State | ||
HeaderSum -= self.Header.IntegrityCheck.Checksum.File | ||
if HeaderSum & 0xff: | ||
Header = self.Header.IntegrityCheck.Checksum.Header + 0x100 - HeaderSum % 0x100 | ||
self.Header.IntegrityCheck.Checksum.Header = Header % 0x100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ | |
from collections import OrderedDict | ||
|
||
# Custom imports | ||
from .logger import log | ||
from .configurations import XMLCLI_CONFIG, ENCODING, XMLCLI_DIR, OUT_DIR, PY3, STATUS_CODE_RECORD_FILE | ||
from logger import log | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it work when installed as python site package module? |
||
from configurations import XMLCLI_CONFIG, ENCODING, XMLCLI_DIR, OUT_DIR, PY3, STATUS_CODE_RECORD_FILE | ||
|
||
try: | ||
from defusedxml import ElementTree as ET | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file breaks PEP-8 naming convention guideline