util::pdbg functions for path, position, and target type
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I4f4a5b1aa6ab13f60e61d77a866cfc24c7854677
diff --git a/util/pdbg.cpp b/util/pdbg.cpp
index 14768c0..53c8020 100644
--- a/util/pdbg.cpp
+++ b/util/pdbg.cpp
@@ -1,6 +1,3 @@
-
-#include <libpdbg.h>
-
#include <util/pdbg.hpp>
namespace util
@@ -11,9 +8,49 @@
//------------------------------------------------------------------------------
+pdbg_target* getTrgt(const libhei::Chip& i_chip)
+{
+ return (pdbg_target*)i_chip.getChip();
+}
+
+//------------------------------------------------------------------------------
+
+const char* getPath(pdbg_target* i_trgt)
+{
+ return pdbg_target_path(i_trgt);
+}
+
const char* getPath(const libhei::Chip& i_chip)
{
- return pdbg_target_path((pdbg_target*)i_chip.getChip());
+ return getPath(getTrgt(i_chip));
+}
+
+//------------------------------------------------------------------------------
+
+uint32_t getChipPos(pdbg_target* i_trgt)
+{
+ uint32_t attr = 0;
+ pdbg_target_get_attribute(i_trgt, "ATTR_FAPI_POS", 4, 1, &attr);
+ return attr;
+}
+
+uint32_t getChipPos(const libhei::Chip& i_chip)
+{
+ return getChipPos(getTrgt(i_chip));
+}
+
+//------------------------------------------------------------------------------
+
+uint8_t getTrgtType(pdbg_target* i_trgt)
+{
+ uint8_t attr = 0;
+ pdbg_target_get_attribute(i_trgt, "ATTR_TYPE", 1, 1, &attr);
+ return attr;
+}
+
+uint8_t getTrgtType(const libhei::Chip& i_chip)
+{
+ return getTrgtType(getTrgt(i_chip));
}
//------------------------------------------------------------------------------
diff --git a/util/pdbg.hpp b/util/pdbg.hpp
index 2ee1c61..58af138 100644
--- a/util/pdbg.hpp
+++ b/util/pdbg.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <libpdbg.h>
+
#include <hei_main.hpp>
namespace util
@@ -8,12 +10,27 @@
namespace pdbg
{
-/**
- * @param A chip.
- * @return A string representing the chip's devtree path.
- */
+/** @return The target associated with the given chip. */
+pdbg_target* getTrgt(const libhei::Chip& i_chip);
+
+/** @return A string representing the given target's devtree path. */
+const char* getPath(pdbg_target* i_trgt);
+
+/** @return A string representing the given chip's devtree path. */
const char* getPath(const libhei::Chip& i_chip);
+/** @return The absolute position of the given target. */
+uint32_t getChipPos(pdbg_target* i_trgt);
+
+/** @return The absolute position of the given chip. */
+uint32_t getChipPos(const libhei::Chip& i_chip);
+
+/** @return The target type of the given target. */
+uint8_t getTrgtType(pdbg_target* i_trgt);
+
+/** @return The target type of the given chip. */
+uint8_t getTrgtType(const libhei::Chip& i_chip);
+
} // namespace pdbg
} // namespace util