pdbg utils for finding all active chips
Change-Id: I444c1062d28c10ecd47426c60ffe0604cc5eaac5
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index cf78149..30efd74 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -20,7 +20,7 @@
// Forward references for externally defined functions.
-void initializeIsolator(const std::vector<libhei::Chip>& i_chips);
+void initializeIsolator(std::vector<libhei::Chip>& o_chips);
//------------------------------------------------------------------------------
@@ -69,67 +69,6 @@
//------------------------------------------------------------------------------
-// Returns the chip model/level of the given target.
-libhei::ChipType_t __getChipType(pdbg_target* i_trgt)
-{
- libhei::ChipType_t type;
-
- // START WORKAROUND
- // TODO: Will need to grab the model/level from the target attributes when
- // they are available. For now, use ATTR_TYPE to determine which
- // currently supported value to use supported.
- uint8_t attrType = util::pdbg::getTrgtType(i_trgt);
- switch (attrType)
- {
- case 0x05: // PROC
- type = 0x120DA049;
- break;
-
- case 0x4b: // OCMB_CHIP
- type = 0x160D2000;
- break;
-
- default:
- trace::err("Unsupported ATTR_TYPE value: 0x%02x", attrType);
- assert(0);
- }
- // END WORKAROUND
-
- return type;
-}
-
-//------------------------------------------------------------------------------
-
-// Gathers list of active chips to analyze.
-void __getActiveChips(std::vector<libhei::Chip>& o_chips)
-{
- // Iterate each processor.
- pdbg_target* procTrgt;
- pdbg_for_each_class_target("proc", procTrgt)
- {
- // Active processors only.
- if (PDBG_TARGET_ENABLED != pdbg_target_probe(procTrgt))
- continue;
-
- // Add the processor to the list.
- o_chips.emplace_back(procTrgt, __getChipType(procTrgt));
-
- // Iterate the connected OCMBs, if they exist.
- pdbg_target* ocmbTrgt;
- pdbg_for_each_target("ocmb", procTrgt, ocmbTrgt)
- {
- // Active OCMBs only.
- if (PDBG_TARGET_ENABLED != pdbg_target_probe(ocmbTrgt))
- continue;
-
- // Add the OCMB to the list.
- o_chips.emplace_back(ocmbTrgt, __getChipType(ocmbTrgt));
- }
- }
-}
-
-//------------------------------------------------------------------------------
-
// Takes a signature list that will be filtered and sorted. The first entry in
// the returned list will be the root cause. If the returned list is empty,
// analysis failed.
@@ -237,12 +176,9 @@
trace::inf(">>> enter analyzeHardware()");
- // Get the active chips to be analyzed.
- std::vector<libhei::Chip> chips;
- __getActiveChips(chips);
-
- // Initialize the isolator for all chips.
+ // Initialize the isolator and get all of the chips to be analyzed.
trace::inf("Initializing the isolator...");
+ std::vector<libhei::Chip> chips;
initializeIsolator(chips);
// Isolate attentions.
diff --git a/analyzer/hei_user_interface.cpp b/analyzer/hei_user_interface.cpp
index 0f4a441..2422b38 100644
--- a/analyzer/hei_user_interface.cpp
+++ b/analyzer/hei_user_interface.cpp
@@ -43,10 +43,7 @@
bool accessFailure = false;
// The processor PIB target is required for SCOM access.
- char path[16];
- sprintf(path, "/proc%d/pib", pdbg_target_index(i_procTrgt));
- pdbg_target* scomTrgt = pdbg_target_from_path(nullptr, path);
- assert(nullptr != scomTrgt);
+ pdbg_target* scomTrgt = util::pdbg::getPibTrgt(i_procTrgt);
switch (i_regType)
{
diff --git a/analyzer/initialize_isolator.cpp b/analyzer/initialize_isolator.cpp
index 941b500..e75f5b3 100644
--- a/analyzer/initialize_isolator.cpp
+++ b/analyzer/initialize_isolator.cpp
@@ -105,8 +105,11 @@
//------------------------------------------------------------------------------
-void initializeIsolator(const std::vector<libhei::Chip>& i_chips)
+void initializeIsolator(std::vector<libhei::Chip>& o_chips)
{
+ // Get all of the active chips to be analyzed.
+ util::pdbg::getActiveChips(o_chips);
+
// Find all of the existing chip data files.
std::map<libhei::ChipType_t, fs::path> files;
__getChipDataFiles(files);
@@ -114,25 +117,10 @@
// Keep track of models/levels that have already been initialized.
std::map<libhei::ChipType_t, unsigned int> initTypes;
- for (const auto& chip : i_chips)
+ for (const auto& chip : o_chips)
{
auto chipType = chip.getType();
- // Trace each chip for debug.
- trace::inf("Chip found: type=0x%0" PRIx32 " chip=%s", chipType,
- util::pdbg::getPath(chip));
-
- if (0 == chipType)
- {
- // This is a special case. It means the model/level attributes have
- // not been initialized in the devtree. This is possible on the
- // epoch IPL where an attention occurs before Hostboot is able to
- // update the devtree information on the BMC.
-
- // TODO: Consider logging a PEL. Just skip for now.
- continue;
- }
-
// Mark this chip type as initialized (or will be if it hasn't been).
auto ret = initTypes.emplace(chipType, 1);
if (!ret.second)