summaryrefslogtreecommitdiffstats
path: root/src/sbefw/core/sbeutil.C
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbefw/core/sbeutil.C')
-rw-r--r--src/sbefw/core/sbeutil.C62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/sbefw/core/sbeutil.C b/src/sbefw/core/sbeutil.C
index bc53e7a4..c0b291e2 100644
--- a/src/sbefw/core/sbeutil.C
+++ b/src/sbefw/core/sbeutil.C
@@ -5,7 +5,8 @@
/* */
/* OpenPOWER sbe Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2016,2017 */
+/* Contributors Listed Below - COPYRIGHT 2016,2018 */
+/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
@@ -25,8 +26,17 @@
#include "fapi2.H"
#include "sbetrace.H"
#include "sbeglobals.H"
+
+#include "plat_hw_access.H"
+#include "assert.h"
+
// Nest frequency array
#include "p9_frequency_buckets.H"
+
+#define SBE_PERV_SB_CS_SCOM 0x00050008
+#define SBCS_VEC_1_CLEAR(sbcsreg) (sbcsreg & ~0x0004000000000000ull)
+#define SBCS_VEC_1_GET(sbcsreg) (sbcsreg & 0x0004000000000000ull)
+
namespace SBE
{
bool isSimics() __attribute__((alias("__isSimicsRunning")));
@@ -58,5 +68,55 @@ namespace SBE
pk_timebase_freq_set(SBE_GLOBAL->sbefreq);
#undef SBE_FUNC
}
+
+ bool isHreset(void)
+ {
+ #define SBE_FUNC "IS_HRESET"
+ using namespace fapi2;
+ bool isHreset = false;
+ uint64_t sbcsreg = 0;
+ ReturnCode rc = FAPI2_RC_SUCCESS;
+ plat_target_handle_t tgtHndl;
+ rc = getscom_abs_wrap (&tgtHndl,
+ SBE_PERV_SB_CS_SCOM,
+ &sbcsreg);
+ if (rc != FAPI2_RC_SUCCESS)
+ {
+ SBE_ERROR(SBE_FUNC" could not read sbcs register, halting.");
+ pk_halt();
+ }
+ isHreset = SBCS_VEC_1_GET(sbcsreg);
+ SBE_INFO(SBE_FUNC" [%d]", isHreset);
+ return (isHreset);
+ #undef SBE_FUNC
+ }
+
+ void clearHresetBit(void)
+ {
+ #define SBE_FUNC "CLEAR_HRESET_BIT"
+ using namespace fapi2;
+ // clear the hreset bit
+ uint64_t sbcsreg = 0;
+ plat_target_handle_t tgtHndl;
+ ReturnCode rc = getscom_abs_wrap (&tgtHndl,
+ SBE_PERV_SB_CS_SCOM,
+ &sbcsreg);
+ if (rc != FAPI2_RC_SUCCESS)
+ {
+ SBE_ERROR(SBE_FUNC" could not read sbcs register, halting.");
+ pk_halt();
+ }
+
+ sbcsreg = SBCS_VEC_1_CLEAR(sbcsreg);
+ rc = putscom_abs_wrap (&tgtHndl,
+ SBE_PERV_SB_CS_SCOM,
+ sbcsreg);
+ if (rc != FAPI2_RC_SUCCESS)
+ {
+ SBE_ERROR(SBE_FUNC" could not write sbcs register, halting.");
+ pk_halt();
+ }
+ #undef SBE_FUNC
+ }
}
OpenPOWER on IntegriCloud