Merge bar4Allowed with mgmtPep functionality

This commit is contained in:
DataHoarder 2020-12-22 22:57:05 +01:00
parent 38f0b983b6
commit 15b4789015

View file

@ -112,7 +112,7 @@ void patchImage(const std::string& originalImage, const std::string& settingsFil
imageObject.imageSignature += " :: Patched by rrcSmall :: git.gammaspectra.live/FM10K/rrcSmall";
}
auto baseOffsets = std::vector<uint32_t>{imageObject.getHeader().baseAddress, (uint32_t) imageObject.getHeader().baseAddress + 0x40000};
auto baseOffsets = std::vector<uint32_t>{imageObject.getHeader().baseAddress, (uint32_t) imageObject.getHeader().baseAddress + 0x40000}; //Target first and second bank
{
auto entry = config.getEntry("api.platform.config.switch.0.bootCfg.mgmtPep");
@ -124,7 +124,15 @@ void patchImage(const std::string& originalImage, const std::string& settingsFil
auto& load = reinterpret_cast<std::unique_ptr<Instruction::Load>&>(instruction);
if(load->address == (uint32_t)getScratchRegister(0x02e) && load->data.size() == 9){
for(uint32_t pepOffset = 0; pepOffset < 9; ++pepOffset){
load->data[pepOffset] = pepOffset == value || value == -1;
std::stringstream key;
key << "api.platform.config.switch.0.bootCfg.pep." << std::dec << pepOffset << ".bar4Allowed";
auto testEntry = config.getEntry(key.str());
bool bar4allowed = true;
if(testEntry.type == Configuration::ConfigurationNode::Type::ValueBool && !testEntry.value.empty()) {
bar4allowed = testEntry.getBool();
}
load->data[pepOffset] = bar4allowed && (pepOffset == value || value == -1);
}
}
}