summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/perv/p9_spr_name_map.C
diff options
context:
space:
mode:
Diffstat (limited to 'src/import/chips/p9/procedures/hwp/perv/p9_spr_name_map.C')
-rw-r--r--src/import/chips/p9/procedures/hwp/perv/p9_spr_name_map.C92
1 files changed, 62 insertions, 30 deletions
diff --git a/src/import/chips/p9/procedures/hwp/perv/p9_spr_name_map.C b/src/import/chips/p9/procedures/hwp/perv/p9_spr_name_map.C
index 5f66efa4c..5f9046693 100644
--- a/src/import/chips/p9/procedures/hwp/perv/p9_spr_name_map.C
+++ b/src/import/chips/p9/procedures/hwp/perv/p9_spr_name_map.C
@@ -36,26 +36,28 @@
//-----------------------------------------------------------------------------------
#include <p9_spr_name_map.H>
+std::map<std::string, SPRMapEntry> SPR_MAP;
+bool spr_map_initialized = false;
+
//-----------------------------------------------------------------------------------
// Function definitions
//-----------------------------------------------------------------------------------
-std::map<std::string, SPRMapEntry> spr_map;
-
-fapi2::ReturnCode p9_spr_name_map_init()
+bool p9_spr_name_map_init()
{
- FAPI_INF("Start SPR name map init");
-
- FAPI_ASSERT(spr_map.empty(),
- fapi2::P9_SPR_NAME_MAP_INIT_ERR(),
- "SPR name map is not empty when initialization");
+ if (spr_map_initialized)
+ {
+ return true;
+ }
+ if (!SPR_MAP.empty())
{
- LIST_SPR_REG(DO_SPR_MAP)
+ return false;
}
-fapi_try_exit:
- FAPI_INF("Exiting SPR name map init");
- return fapi2::current_err;
+ LIST_SPR_REG(DO_SPR_MAP)
+ spr_map_initialized = true;
+
+ return true;
}
//-----------------------------------------------------------------------------------
@@ -67,33 +69,63 @@ bool p9_spr_name_map_check_flag(unsigned char i_reg_flag, bool i_write)
}
//-----------------------------------------------------------------------------------
-fapi2::ReturnCode p9_spr_name_map(const std::string i_name, const bool i_write, uint32_t& o_number)
+bool p9_spr_name_map(const std::string i_name, const bool i_write, uint32_t& o_number)
{
- FAPI_INF("Start SPR name map");
bool l_check_flag = false;
- if(spr_map.find(i_name) != spr_map.end())
+ if(SPR_MAP.find(i_name) != SPR_MAP.end())
+ {
+ l_check_flag = p9_spr_name_map_check_flag(SPR_MAP[i_name].flag, i_write);
+
+ if(l_check_flag)
+ {
+ o_number = SPR_MAP[i_name].number;
+ }
+ }
+
+ return l_check_flag;
+}
+
+//-----------------------------------------------------------------------------------
+bool p9_get_share_type(const std::string i_name, Enum_ShareType& o_share_type)
+{
+ bool l_rc = false;
+
+ if(SPR_MAP.find(i_name) != SPR_MAP.end())
{
- l_check_flag = p9_spr_name_map_check_flag(spr_map[i_name].flag, i_write);
+ o_share_type = SPR_MAP[i_name].share_type;
+ l_rc = true;
+ }
- FAPI_ASSERT(l_check_flag,
- fapi2::P9_SPR_INVALID_RW_MODE_ACCESS_ERR()
- .set_REGNAME(i_name)
- .set_RWFLAG(spr_map[i_name].flag),
- "SPR RW mode check failed");
+ return l_rc;
+}
- o_number = spr_map[i_name].number;
+//-----------------------------------------------------------------------------------
+bool p9_get_bit_length(const std::string i_name, uint8_t& o_bit_length)
+{
+ bool l_rc = false;
+
+ if(SPR_MAP.find(i_name) != SPR_MAP.end())
+ {
+ o_bit_length = SPR_MAP[i_name].bit_length;
+ l_rc = true;
}
- else
+
+ return l_rc;
+}
+
+//-----------------------------------------------------------------------------------
+bool p9_get_spr_entry(const std::string i_name, SPRMapEntry& o_spr_entry)
+{
+ bool l_rc = false;
+
+ if(SPR_MAP.find(i_name) != SPR_MAP.end())
{
- FAPI_ASSERT(false,
- fapi2::P9_SPR_INVALID_NAME_ACCESS_ERR()
- .set_REGNAME(i_name),
- "SPR name is invalid");
+ o_spr_entry = SPR_MAP[i_name];
+ l_rc = true;
}
-fapi_try_exit:
- FAPI_INF("Exiting SPR name map");
- return fapi2::current_err;
+ return l_rc;
}
+
OpenPOWER on IntegriCloud