mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-28 05:54:50 -04:00
NE Alpha 41
This commit is contained in:
parent
c0f1a8eadf
commit
227be5480e
12 changed files with 8145 additions and 37 deletions
|
@ -2818,13 +2818,13 @@ USTATUS FfsParser::performSecondPass(const UModelIndex & index)
|
|||
|
||||
// Calculate address difference
|
||||
const UINT32 vtfSize = model->header(lastVtf).size() + model->body(lastVtf).size() + model->tail(lastVtf).size();
|
||||
const UINT32 diff = 0xFFFFFFFFUL - model->offset(lastVtf) - vtfSize + 1;
|
||||
addressDiff = 0xFFFFFFFFUL - model->offset(lastVtf) - vtfSize + 1;
|
||||
|
||||
// Find and parse FIT
|
||||
parseFit(index, diff);
|
||||
parseFit(index);
|
||||
|
||||
// Apply address information to index and all it's child items
|
||||
addMemoryAddressesRecursive(index, diff);
|
||||
addMemoryAddressesRecursive(index);
|
||||
|
||||
// Add fixed and compressed
|
||||
addFixedAndCompressedRecursive(index);
|
||||
|
@ -2849,7 +2849,7 @@ USTATUS FfsParser::addFixedAndCompressedRecursive(const UModelIndex & index) {
|
|||
return U_SUCCESS;
|
||||
}
|
||||
|
||||
USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
||||
USTATUS FfsParser::parseFit(const UModelIndex & index)
|
||||
{
|
||||
// Check sanity
|
||||
if (!index.isValid())
|
||||
|
@ -2858,7 +2858,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||
// Search for FIT
|
||||
UModelIndex fitIndex;
|
||||
UINT32 fitOffset;
|
||||
USTATUS result = findFitRecursive(index, diff, fitIndex, fitOffset);
|
||||
USTATUS result = findFitRecursive(index, fitIndex, fitOffset);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
|
@ -2922,8 +2922,8 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||
|
||||
case FIT_TYPE_MICROCODE: {
|
||||
//TODO: refactor into function with error reporting
|
||||
if (currentEntry->Address > diff && currentEntry->Address < 0xFFFFFFFFUL) {
|
||||
UINT32 offset = (UINT32)currentEntry->Address - diff;
|
||||
if (currentEntry->Address > addressDiff && currentEntry->Address < 0xFFFFFFFFUL) {
|
||||
UINT32 offset = (UINT32)currentEntry->Address - addressDiff;
|
||||
UModelIndex mcIndex = model->findByOffset(offset);
|
||||
UByteArray mcFile = model->header(mcIndex) + model->body(mcIndex) + model->tail(mcIndex);
|
||||
|
||||
|
@ -2962,8 +2962,8 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||
case FIT_TYPE_AC_KEY_MANIFEST:
|
||||
case FIT_TYPE_AC_BOOT_POLICY:
|
||||
default:
|
||||
if (currentEntry->Address > diff && currentEntry->Address < 0xFFFFFFFFUL) {
|
||||
UINT32 offset = (UINT32)currentEntry->Address - diff;
|
||||
if (currentEntry->Address > addressDiff && currentEntry->Address < 0xFFFFFFFFUL) {
|
||||
UINT32 offset = (UINT32)currentEntry->Address - addressDiff;
|
||||
itemIndex = model->findByOffset(offset);
|
||||
}
|
||||
|
||||
|
@ -2987,7 +2987,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||
return U_SUCCESS;
|
||||
}
|
||||
|
||||
USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff, UModelIndex & found, UINT32 & fitOffset)
|
||||
USTATUS FfsParser::findFitRecursive(const UModelIndex & index, UModelIndex & found, UINT32 & fitOffset)
|
||||
{
|
||||
// Sanity check
|
||||
if (!index.isValid())
|
||||
|
@ -2995,7 +2995,7 @@ USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff
|
|||
|
||||
// Process child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
findFitRecursive(index.child(i, 0), diff, found, fitOffset);
|
||||
findFitRecursive(index.child(i, 0), found, fitOffset);
|
||||
if (found.isValid())
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
@ -3007,7 +3007,7 @@ USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff
|
|||
offset >= 0;
|
||||
offset = model->body(index).indexOf(FIT_SIGNATURE, offset + 1)) {
|
||||
// FIT candidate found, calculate it's physical address
|
||||
UINT32 fitAddress = model->offset(index) + diff + model->header(index).size() + (UINT32)offset;
|
||||
UINT32 fitAddress = model->offset(index) + addressDiff + model->header(index).size() + (UINT32)offset;
|
||||
|
||||
// Check FIT address to be stored in the last VTF
|
||||
if (fitAddress == storedFitAddress) {
|
||||
|
@ -3023,7 +3023,7 @@ USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff
|
|||
return U_SUCCESS;
|
||||
}
|
||||
|
||||
USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index, const UINT32 diff)
|
||||
USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index)
|
||||
{
|
||||
// Sanity check
|
||||
if (!index.isValid())
|
||||
|
@ -3032,7 +3032,7 @@ USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index, const
|
|||
// Set address value for non-compressed data
|
||||
if (!model->compressed(index)) {
|
||||
// Check address sanity
|
||||
UINT64 address = (const UINT64)diff + model->offset(index);
|
||||
UINT64 address = (const UINT64)addressDiff + model->offset(index);
|
||||
if (address <= 0xFFFFFFFFUL) {
|
||||
// Update info
|
||||
UINT32 headerSize = model->header(index).size();
|
||||
|
@ -3098,7 +3098,7 @@ USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index, const
|
|||
|
||||
// Process child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
addMemoryAddressesRecursive(index.child(i, 0), diff);
|
||||
addMemoryAddressesRecursive(index.child(i, 0));
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
|
|
|
@ -26,10 +26,10 @@ class FfsParser
|
|||
{
|
||||
public:
|
||||
// Default constructor and destructor
|
||||
FfsParser(TreeModel* treeModel) : model(treeModel), nvramParser(treeModel), meParser(treeModel), capsuleOffsetFixup(0) {}
|
||||
FfsParser(TreeModel* treeModel) : model(treeModel), nvramParser(treeModel), meParser(treeModel), capsuleOffsetFixup(0), addressDiff(0x100000000ULL) {}
|
||||
~FfsParser() {}
|
||||
|
||||
// Returns messages
|
||||
// Obtain parser messages
|
||||
std::vector<std::pair<UString, UModelIndex> > getMessages() const {
|
||||
std::vector<std::pair<UString, UModelIndex> > meVector = meParser.getMessages();
|
||||
std::vector<std::pair<UString, UModelIndex> > nvramVector = nvramParser.getMessages();
|
||||
|
@ -39,15 +39,18 @@ public:
|
|||
return resultVector;
|
||||
}
|
||||
|
||||
// Clears messages
|
||||
// Clear messages
|
||||
void clearMessages() { messagesVector.clear(); }
|
||||
|
||||
// Firmware image parsing
|
||||
// Parse firmware image
|
||||
USTATUS parse(const UByteArray &buffer);
|
||||
|
||||
// Obtain parsed FIT table
|
||||
std::vector<std::pair<std::vector<UString>, UModelIndex> > getFitTable() const { return fitTable; }
|
||||
|
||||
// Obtain offset/address difference
|
||||
UINT64 getAddressDiff() { return addressDiff; }
|
||||
|
||||
private:
|
||||
TreeModel *model;
|
||||
std::vector<std::pair<UString, UModelIndex> > messagesVector;
|
||||
|
@ -60,6 +63,7 @@ private:
|
|||
|
||||
UModelIndex lastVtf;
|
||||
UINT32 capsuleOffsetFixup;
|
||||
UINT64 addressDiff;
|
||||
std::vector<std::pair<std::vector<UString>, UModelIndex> > fitTable;
|
||||
|
||||
// First pass
|
||||
|
@ -109,10 +113,10 @@ private:
|
|||
// Second pass
|
||||
USTATUS performSecondPass(const UModelIndex & index);
|
||||
USTATUS addOffsetsRecursive(const UModelIndex & index);
|
||||
USTATUS addMemoryAddressesRecursive(const UModelIndex & index, const UINT32 diff);
|
||||
USTATUS addMemoryAddressesRecursive(const UModelIndex & index);
|
||||
USTATUS addFixedAndCompressedRecursive(const UModelIndex & index);
|
||||
USTATUS parseFit(const UModelIndex & index, const UINT32 diff);
|
||||
USTATUS findFitRecursive(const UModelIndex & index, const UINT32 diff, UModelIndex & found, UINT32 & fitOffset);
|
||||
USTATUS parseFit(const UModelIndex & index);
|
||||
USTATUS findFitRecursive(const UModelIndex & index, UModelIndex & found, UINT32 & fitOffset);
|
||||
};
|
||||
|
||||
#endif // FFSPARSER_H
|
||||
|
|
|
@ -124,7 +124,6 @@ public:
|
|||
UModelIndex createIndex(int row, int column, void *data) const { return UModelIndex(row, column, data, this); }
|
||||
#endif
|
||||
|
||||
|
||||
~TreeModel() {
|
||||
delete rootItem;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue