Apply register renaming for enhanced reading

This commit is contained in:
DataHoarder 2020-12-29 02:19:04 +01:00
parent 0823e1e78c
commit 2497c413ab
16 changed files with 151 additions and 36 deletions

View file

@ -37,6 +37,7 @@
enum class JumpKind{
Continue,
Absolute,
Speculative,
Branch,
Loop,
Return

View file

@ -193,6 +193,7 @@ void ImageFormat::decodeAnalyzeInstructionsAt(uint32_t offset) {
uint32_t maxUnchangedExecutions = 1000;
uint32_t maxTotalExecutions = 20000;
uint32_t speculativeJumps = 0;
while (!savedStates.empty()) {
AnalysisState state = savedStates.front();
@ -203,6 +204,10 @@ void ImageFormat::decodeAnalyzeInstructionsAt(uint32_t offset) {
do {
if(jumpsUsed.find(state.current) != jumpsUsed.end() && !jumpsUsed[state.current]){
speculativeJumps++;
}
jumpsUsed[state.current] = true;
if (state.current >= 0x100000 || (findInstructionByAddress(state.current) == nullptr &&
@ -229,6 +234,10 @@ void ImageFormat::decodeAnalyzeInstructionsAt(uint32_t offset) {
auto possibleBranches = instruction->execute(state);
if(jumpsUsed.find(state.current) != jumpsUsed.end() && !jumpsUsed[state.current]){
jumpsUsed.erase(state.current); //Clear to recognize a non-speculative jump
}
if ((instruction->getCommand() == Instruction::Instruction::CommandOp::JUMP ||
instruction->getCommand() == Instruction::Instruction::CommandOp::RETURN) &&
jumpsUsed.find(instruction->getEndAddress()) == jumpsUsed.end()) {
@ -270,7 +279,7 @@ void ImageFormat::decodeAnalyzeInstructionsAt(uint32_t offset) {
for (const auto &branch : possibleBranches) {
AnalysisState newState(state);
newState.current = branch.first & 0xfffffffc;
newState.current = branch.first;
for (const auto &entry : branch.second) {
newState.setRegister(entry.first, entry.second);
}
@ -295,6 +304,7 @@ void ImageFormat::decodeAnalyzeInstructionsAt(uint32_t offset) {
for (auto &visited : jumpsUsed) {
if (!visited.second && visited.first >= offset && visited.first <= 0x100000) {
baseState.current = visited.first;
baseState.addKnownJump(visited.first, 0, JumpKind::Speculative);
savedStates.push(baseState);
break;
}
@ -302,7 +312,7 @@ void ImageFormat::decodeAnalyzeInstructionsAt(uint32_t offset) {
}
std::cerr << "Next state, branched states left: " << std::dec << savedStates.size()
<< /*", executed states: " << std::dec << createdStates.size() <<*/ ", total instructions decoded: "
<< /*", executed states: " << std::dec << createdStates.size() <<*/ ", speculative jumps: " << std::dec << speculativeJumps << ", total instructions decoded: "
<< std::dec << instructions.size() << "\n";
}
}

View file

@ -30,9 +30,10 @@
#include "OutputContext.h"
#include "instructions/Write.h"
#include "instructions/Jump.h"
#include "Registers.h"
std::string OutputContext::getLabel(uint32_t location, bool force) const{
if(mappings.find(location) != mappings.end()){
if(mappings.find(location) != mappings.end() && (!force || !mappings.at(location).empty())){
return mappings.at(location);
}
if(force){
@ -92,12 +93,15 @@ void OutputContext::analyze() {
if(j.second != JumpKind::Return){
justReturn = false;
}
if(j.second != JumpKind::Absolute){
if(j.second != JumpKind::Absolute && j.second != JumpKind::Speculative){
justAbsolute = false;
}
if(j.second != JumpKind::Continue){
from << std::hex << std::setw(6) << std::setfill('0') << j.first << "(";
switch (j.second) {
case JumpKind::Speculative:
from << "Speculative";
break;
case JumpKind::Absolute:
from << "Absolute";
break;
@ -165,3 +169,26 @@ void OutputContext::analyze() {
}
}
void OutputContext::addMapping(uint32_t location, const std::string &name, bool force) {
if(mappings.find(location) == comments.end() || (force && !mappings[location].empty())) {
mappings[location] = name;
}
}
void OutputContext::addComment(uint32_t location, const std::string &comment) {
if(comments.find(location) != comments.end()){
comments[location] = comment + " --- " + comments[location];
}else{
comments[location] = comment;
}
}
std::string OutputContext::getAddressRegisterName(uint32_t addr, uint8_t offset) const {
if (offset || registers.find(addr) == registers.end()) {
return ::getAddressRegisterName(addr, offset);
} else {
return registers.at(addr);
}
}

View file

@ -41,6 +41,7 @@ private:
const ImageFormat& image;
std::unordered_map<uint32_t, std::string> mappings;
std::unordered_map<uint32_t, std::string> comments;
std::unordered_map<uint32_t, std::string> registers;
public:
@ -48,19 +49,18 @@ public:
}
void addMapping(uint32_t location, const std::string& name, bool force = false){
if(force || comments.find(location) == comments.end()) {
mappings[location] = name;
}
void addMapping(uint32_t location, const std::string& name, bool force = false);
void addComment(uint32_t location, const std::string& comment);
void addRegister(uint32_t addr, const std::string& name){
registers[addr] = name;
}
void addComment(uint32_t location, const std::string& comment){
std::string getAddressRegisterName(uint32_t addr, uint8_t offset) const ;
if(comments.find(location) != comments.end()){
comments[location] = comment + " --- " + comments[location];
}else{
comments[location] = comment;
}
std::string getAddressRegisterName(const Instruction::AddressWithOffset& address) const {
return getAddressRegisterName(address.address, address.offset);
}
std::string getLabel(uint32_t location, bool force = true) const;

View file

@ -80,10 +80,10 @@ std::string Instruction::Branch::toString() const {
std::vector<Instruction::OutputFormat> Instruction::Branch::toOutputFormat(const OutputContext &context) const {
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "BRANCH" << " " << getAddressRegisterName(address) << (equality ? " == " : " != ")).str()},
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "BRANCH" << " " << context.getAddressRegisterName(address) << (equality ? " == " : " != ")).str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " VALUE 0x" << std::hex << std::setw(8) << std::setfill('0') << value).str()},
OutputFormat{getAddress() + 8, dynamic_cast<std::stringstream&>(std::stringstream("") << " MASK 0x" << std::hex << std::setw(8) << std::setfill('0') << mask).str()},
OutputFormat{getAddress() + 12, dynamic_cast<std::stringstream&>(std::stringstream("") << " JUMP_ADDRESS " << context.getLabel(jumpAddress)).str()},
OutputFormat{getAddress() + 12, dynamic_cast<std::stringstream&>(std::stringstream("") << " JUMP_ADDRESS <" << context.getLabel(jumpAddress) << ">").str()},
};
}

View file

@ -29,6 +29,7 @@
#include "../Registers.h"
#include <iostream>
#include <iomanip>
#include "../OutputContext.h"
void Instruction::Calc::fromBytes(uint32_t offset, const std::vector<uint8_t> &bytes) {
_address = offset;
@ -122,9 +123,9 @@ std::vector<Instruction::OutputFormat> Instruction::Calc::toOutputFormat(const O
}
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(opname << " " << getAddressRegisterName(addressDestination, addressOffset) << " = ").str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " SOURCE " << getAddressRegisterName(addressSource, addressOffset)).str()},
OutputFormat{getAddress() + 8, dynamic_cast<std::stringstream&>(std::stringstream("") << " TARGET " << getAddressRegisterName(addressTarget, addressOffset)).str()},
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(opname << " " << context.getAddressRegisterName(addressDestination, addressOffset) << " = ").str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " SOURCE " << context.getAddressRegisterName(addressSource, addressOffset)).str()},
OutputFormat{getAddress() + 8, dynamic_cast<std::stringstream&>(std::stringstream("") << " TARGET " << context.getAddressRegisterName(addressTarget, addressOffset)).str()},
};
}

View file

@ -29,6 +29,7 @@
#include "../Registers.h"
#include <iostream>
#include <iomanip>
#include "../OutputContext.h"
void Instruction::CalcImm::fromBytes(uint32_t offset, const std::vector<uint8_t> &bytes) {
_address = offset;
@ -122,9 +123,9 @@ std::vector<Instruction::OutputFormat> Instruction::CalcImm::toOutputFormat(cons
}
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(opname << "_IMM " << getAddressRegisterName(addressDestination, addressOffset) << " = ").str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " SOURCE " << getAddressRegisterName(addressSource, addressOffset)).str()},
OutputFormat{getAddress() + 8, dynamic_cast<std::stringstream&>(std::stringstream("") << " TARGET 0x" << value).str()},
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(opname << "_IMM " << context.getAddressRegisterName(addressDestination, addressOffset) << " = ").str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " SOURCE " << context.getAddressRegisterName(addressSource, addressOffset)).str()},
OutputFormat{getAddress() + 8, dynamic_cast<std::stringstream&>(std::stringstream("") << " TARGET 0x" << std::hex << std::setw(8) << std::setfill('0') << value).str()},
};
}

View file

@ -29,6 +29,7 @@
#include "../Registers.h"
#include <iostream>
#include <iomanip>
#include "../OutputContext.h"
void Instruction::Copy::fromBytes(uint32_t offset, const std::vector<uint8_t> &bytes) {
_address = offset;
@ -63,8 +64,8 @@ std::string Instruction::Copy::toString() const {
std::vector<Instruction::OutputFormat> Instruction::Copy::toOutputFormat(const OutputContext &context) const {
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "COPY" << " " << std::dec << (uint32_t)count << ", " << getAddressRegisterName(addressAA)).str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " TO " << getAddressRegisterName(addressBB)).str()}
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "COPY" << " " << std::dec << (uint32_t)count << ", " << context.getAddressRegisterName(addressAA)).str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " TO " << context.getAddressRegisterName(addressBB)).str()}
};
}

View file

@ -53,7 +53,7 @@ std::string Instruction::Jump::toString() const {
std::vector<Instruction::OutputFormat> Instruction::Jump::toOutputFormat(const OutputContext &context) const {
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "JUMP" << " " << context.getLabel(jumpAddress)).str()}
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "JUMP" << " <" << context.getLabel(jumpAddress) << ">").str()}
};
}

View file

@ -149,13 +149,13 @@ std::vector<Instruction::OutputFormat> Instruction::Load::toOutputFormat(const O
uint32_t offset = 0;
std::vector<OutputFormat> f{
OutputFormat{getAddress() + offset++ * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << "LOAD" << " " << getAddressRegisterName(address, addressOffset) << ", INC " << std::dec << (uint32_t)increment).str()}
OutputFormat{getAddress() + offset++ * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << "LOAD" << " " << context.getAddressRegisterName(address, addressOffset) << ", INC " << std::dec << (uint32_t)increment).str()}
};
f.emplace_back(OutputFormat{getAddress() + offset++ * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " COUNT " << std::dec << data.size()).str()});
for (auto d : data) {
f.emplace_back(OutputFormat{getAddress() + offset * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " " << getAddressRegisterName(address + offset - 2, addressOffset) << " = 0x" << std::hex << std::setw(8) << std::setfill('0') << d).str()});
f.emplace_back(OutputFormat{getAddress() + offset * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " " << context.getAddressRegisterName(address + offset - 2, addressOffset) << " = 0x" << std::hex << std::setw(8) << std::setfill('0') << d).str()});
offset++;
}

View file

@ -55,7 +55,7 @@ std::string Instruction::Loop::toString() const {
std::vector<Instruction::OutputFormat> Instruction::Loop::toOutputFormat(const OutputContext &context) const {
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "LOOP" << " " << getRegisterName(static_cast<KnownRegisters>((uint32_t) KnownRegisters::BSM_COUNTER_0 + counter)) << ", " << context.getLabel(jumpAddress)).str()},
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "LOOP" << " " << context.getAddressRegisterName((uint32_t) KnownRegisters::BSM_COUNTER_0 + counter, 0) << ", <" << context.getLabel(jumpAddress) << ">").str()},
};
}

View file

@ -87,11 +87,11 @@ std::string Instruction::Poll::toString() const {
std::vector<Instruction::OutputFormat> Instruction::Poll::toOutputFormat(const OutputContext &context) const {
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "POLL" << " " << getAddressRegisterName(address) << (equality ? " == " : " != ")).str()},
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "POLL" << " " << context.getAddressRegisterName(address) << (equality ? " == " : " != ")).str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " VALUE 0x" << std::hex << std::setw(8) << std::setfill('0') << value).str()},
OutputFormat{getAddress() + 8, dynamic_cast<std::stringstream&>(std::stringstream("") << " MASK 0x" << std::hex << std::setw(8) << std::setfill('0') << mask).str()},
OutputFormat{getAddress() + 12, dynamic_cast<std::stringstream&>(std::stringstream("") << " RETRY MAX " << std::dec << maxRetry << " INTERVAL " << std::dec << retryInterval).str()},
OutputFormat{getAddress() + 16, dynamic_cast<std::stringstream&>(std::stringstream("") << " JUMP_ADDRESS " << context.getLabel(jumpAddress)).str()},
OutputFormat{getAddress() + 16, dynamic_cast<std::stringstream&>(std::stringstream("") << " JUMP_ADDRESS <" << context.getLabel(jumpAddress) << ">").str()},
};
}

View file

@ -29,6 +29,7 @@
#include "../Registers.h"
#include <iostream>
#include <iomanip>
#include "../OutputContext.h"
void Instruction::Return::fromBytes(uint32_t offset, const std::vector<uint8_t> &bytes) {
_address = offset;
@ -54,7 +55,7 @@ std::string Instruction::Return::toString() const {
std::vector<Instruction::OutputFormat> Instruction::Return::toOutputFormat(const OutputContext &context) const {
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "RETURN" << " [" << getAddressRegisterName(address) << "]").str()}
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "RETURN" << " [" << context.getAddressRegisterName(address) << "]").str()}
};
}

View file

@ -29,6 +29,7 @@
#include "../Registers.h"
#include <iostream>
#include <iomanip>
#include "../OutputContext.h"
void Instruction::Set::fromBytes(uint32_t offset, const std::vector<uint8_t> &bytes) {
_address = offset;
@ -65,7 +66,7 @@ std::string Instruction::Set::toString() const {
std::vector<Instruction::OutputFormat> Instruction::Set::toOutputFormat(const OutputContext &context) const {
return std::vector<OutputFormat>{
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "SET" << " " << getAddressRegisterName(address)).str()},
OutputFormat{getAddress(), dynamic_cast<std::stringstream&>(std::stringstream("") << "SET" << " " << context.getAddressRegisterName(address)).str()},
OutputFormat{getAddress() + 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " VALUE 0x" << std::hex << std::setw(8) << std::setfill('0') << value).str()},
OutputFormat{getAddress() + 8, dynamic_cast<std::stringstream&>(std::stringstream("") << " MASK 0x" << std::hex << std::setw(8) << std::setfill('0') << mask).str()}
};

View file

@ -69,11 +69,11 @@ std::vector<Instruction::OutputFormat> Instruction::Write::toOutputFormat(const
uint32_t offset = 0;
std::vector<OutputFormat> f{
OutputFormat{getAddress() + offset++ * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << "WRITE" << " " << getAddressRegisterName(address, addressOffset) << ", " << std::dec << (uint32_t ) data.size()).str()}
OutputFormat{getAddress() + offset++ * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << "WRITE" << " " << context.getAddressRegisterName(address, addressOffset) << ", " << std::dec << (uint32_t ) data.size()).str()}
};
for (auto d : data) {
f.emplace_back(OutputFormat{getAddress() + offset * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " " << getAddressRegisterName(address + offset - 1, addressOffset) << " = 0x" << std::hex << std::setw(8) << std::setfill('0') << d).str()});
f.emplace_back(OutputFormat{getAddress() + offset * 4, dynamic_cast<std::stringstream&>(std::stringstream("") << " " << context.getAddressRegisterName(address + offset - 1, addressOffset) << " = 0x" << std::hex << std::setw(8) << std::setfill('0') << d).str()});
offset++;
}

View file

@ -63,6 +63,24 @@ void decodeImage(const std::string &fileName) {
{0x1000, "load_bootCfg_pep_serialNumber"},
{0x1054, "load_bootCfg_customMac"},
{0x080600, "config_systimeClockSource"},
{0x080700, "config_startClocks"},
{0x080800, "config_pcie_pep_modes"},
{0x080900, "config_pcie_pep_enable"},
{0x083000, "config_?serdes?_pep"},
{0x085a0c, "config_pep0_offsets"},
{0x085a58, "config_pep1_offsets"},
{0x085aa4, "config_pep2_offsets"},
{0x085af0, "config_pep3_offsets"},
{0x085b3c, "config_pep4_offsets"},
{0x085b88, "config_pep5_offsets"},
{0x085bd4, "config_pep6_offsets"},
{0x085c20, "config_pep7_offsets"},
{0x085c6c, "config_pep8_offsets"},
{0x088000, "load_bootCfg_pep0_vpd"},
{0x0881c7, "load_bootCfg_pep1_vpd"},
{0x08838e, "load_bootCfg_pep2_vpd"},
@ -95,6 +113,7 @@ void decodeImage(const std::string &fileName) {
{0x0890f0, "load_bootCfg_spiTransferMode"},
{0x089100, "load_bootCfg_spiTransferSpeed"},
{0x089120, "load_bootCfg_skipPcieInitialization"},
{0x089130, "load_bootCfg_pep_numberOfLanes"},
{0x0891f0, "load_bootCfg_pep_mgmtPep"},
@ -124,11 +143,60 @@ void decodeImage(const std::string &fileName) {
{0x080068, ""},
{0x0870c4, ""},
//Unknown
{0x089110, "loc_089110_load_config_unknown_1"},
{0x089160, "loc_089160_load_config_unknown_9"},
{0x089190, "loc_089190_load_config_unknown_9"},
{0x0891c0, "loc_0891c0_load_config_unknown_9"},
{0x089220, "loc_089220_load_config_unknown_1"},
{0x089290, "loc_089290_load_config_unknown_9"},
{0x0892c0, "loc_0892c0_load_config_unknown_9"},
{0x089320, "loc_089320_load_config_unknown_9"},
{0x089350, "loc_089350_load_config_unknown_9"},
{0x0893b0, "loc_0893b0_load_config_unknown_1"}
};
std::unordered_map<uint32_t, std::string> comments{
{0x080260, "Setting BSM_ARGS means this will be called again when reset, BSM_SCRATCH[0x149] is set to ~ 084000"},
{0x084000, "XREF From BSM_ARGS"}
{0x084000, "XREF From BSM_ARGS"},
{0x080800, "Reset DEVICE_CFG to all 0"},
{0x080828, "set DEVICE_CFG.PCIeMode[0] to 1x8 (default 2x4)"},
{0x080850, "set DEVICE_CFG.PCIeMode[1] to 1x8 (default 2x4)"},
{0x080878, "set DEVICE_CFG.PCIeMode[2] to 1x8 (default 2x4)"},
{0x0808a0, "set DEVICE_CFG.PCIeMode[3] to 1x8 (default 2x4)"},
{0x08061c, "set DEVICE_CFG.SystimeClockSource to IEEE1588_REFCLK (default PCIE_REFCLK)"},
{0x080010, "set DEVICE_CFG.PCIeEnable[0..8] to enabled"},
{0x083958, "set SBUS_PCIE_COMMAND.Op to READ [0x21]"},
{0x083970, "set SBUS_PCIE_COMMAND.Op to WRITE [0x22]"},
};
std::unordered_map<uint32_t, std::string> registerRename{
{(uint32_t)KnownRegisters::MGMT_SCRATCH_0, "custom_RETURN_VALUE"},
{(uint32_t)KnownRegisters::MGMT_SCRATCH_1, "custom_RETURN_TO"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x141, "custom_PEP_CONFIG_serial0"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x142, "custom_PEP_CONFIG_serial1"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x143, "custom_PEP_CONFIG_mgmtPep"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x144, "custom_PEP_CONFIG_vendor_device"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x145, "custom_PEP_CONFIG_subVendor_subDevice"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x145, "custom_PEP_CONFIG_gen"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x13c, "custom_PEP_CONFIG_numberOfLanes"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x17f, "custom_PEP_CONFIG_ASPMEnable"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x139, "custom_PEP_ADDR_OFFSET"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x154, "custom_PEP_NUMBER"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x12e, "param_SBUS_PCIE_REQUEST_-_SBUS_PCIE_RESPONSE"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x12f, "param_SBUS_PCIE_COMMAND_doWrite"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x130, "param_SBUS_PCIE_COMMAND.DeviceAddress"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x131, "param_SBUS_PCIE_COMMAND.Register"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x132, "custom_param_RETURN_TO_SUCCESS"},
{(uint32_t)KnownRegisters::BSM_SCRATCH_START + 0x133, "custom_param_RETURN_TO_FAILURE"},
};
for(auto& e : knownNames){
@ -139,6 +207,10 @@ void decodeImage(const std::string &fileName) {
ctx.addComment(c.first, c.second);
}
for(auto& r : registerRename){
ctx.addRegister(r.first, r.second);
}
ctx.analyze();
uint32_t prevAddress = 0;
@ -267,7 +339,7 @@ patchImage(const std::string &originalImage, const std::string &settingsFile, co
// (BSM_ARGS = BSM_SCRATCH[0x149])
// 0x9110 LOAD 1 = 0x1 ???? do pcie init? IF 0: JUMP 0x081b78: OTHERWISE BIG BLOCK INIT?
// 0x9120 LOAD 1 = 0x0 ???? IF 0: SOFT_RESET.EPLReset = 0, SOFT_RESET.SwitchReset = 0 (RESET) ELSE: JUMP 0x080464
// 0x9120 LOAD 1 = 0x0 api.platform.config.switch.0.bootCfg.skipPcieInitialization
//
// ==0x9130 LOAD 9 api.platform.config.switch.0.bootCfg.pep.0.numberOfLanes
// 0x9160 LOAD 9 0, 4, 0, 4 ... ???? BSM_SCRATCH[0x13d]