summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/utils/stopreg/p9_stop_util.C
diff options
context:
space:
mode:
authorPrem Shanker Jha <premjha2@in.ibm.com>2015-11-12 03:36:55 -0600
committerStephen Cprek <smcprek@us.ibm.com>2016-02-19 17:08:23 -0600
commit548a746856d6095fd4585253893d78b74205f926 (patch)
treeac8bdce8358cc2aae8d6d329dc6df675d717b387 /src/import/chips/p9/procedures/utils/stopreg/p9_stop_util.C
parent5c52f2606c25ccaa3d500323914257cd988c52d9 (diff)
downloadtalos-hostboot-548a746856d6095fd4585253893d78b74205f926.tar.gz
talos-hostboot-548a746856d6095fd4585253893d78b74205f926.zip
PM: Updated Stop API based on modified HOMER layout.
This commit updates the STOP APIs to accomodate changes made in HOMER layout. CME region begins at an offset of 2MB wrt start of HOMER whereas STOP GPE regions begins at 1 MB wrt start of HOMER. There are some corrections for minor coding aesthetics issues. Change-Id: I2914635fa7223654b89a084e17e33065b1655762 RTC: 140797 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21985 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Diffstat (limited to 'src/import/chips/p9/procedures/utils/stopreg/p9_stop_util.C')
-rwxr-xr-xsrc/import/chips/p9/procedures/utils/stopreg/p9_stop_util.C169
1 files changed, 169 insertions, 0 deletions
diff --git a/src/import/chips/p9/procedures/utils/stopreg/p9_stop_util.C b/src/import/chips/p9/procedures/utils/stopreg/p9_stop_util.C
new file mode 100755
index 000000000..28dffb71d
--- /dev/null
+++ b/src/import/chips/p9/procedures/utils/stopreg/p9_stop_util.C
@@ -0,0 +1,169 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: chips/p9/procedures/utils/stopreg/p9_stop_util.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* EKB Project */
+/* */
+/* COPYRIGHT 2015 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+///
+/// @file p9_stop_util.C
+/// @brief implements some utilty functions for STOP API.
+///
+// *HWP HW Owner : Greg Still <stillgs@us.ibm.com>
+// *HWP FW Owner : Prem Shanker Jha <premjha2@in.ibm.com>
+// *HWP Team : PM
+// *HWP Level : 2
+// *HWP Consumed by : HB:HYP
+
+#include "p9_stop_api.H"
+#include "p9_stop_util.H"
+#include "p9_stop_data_struct.H"
+namespace stopImageSection
+{
+
+/**
+ * @brief Returns proc chip's fuse mode status.
+ * @param i_pImage points to start of chip's HOMER image.
+ * @param o_fuseMode true if system is in fuse mode, false otherwise.
+ * @return STOP_SAVE_SUCCESS if functions succeeds, error code otherwise.
+ */
+StopReturnCode_t isFusedMode( void* const i_pImage, bool& o_fuseMode )
+{
+ o_fuseMode = false;
+ StopReturnCode_t l_rc = STOP_SAVE_SUCCESS;
+
+ do
+ {
+ if( !i_pImage )
+ {
+ MY_ERR( "invalid pointer to HOMER image");
+ l_rc = STOP_SAVE_ARG_INVALID_IMG;
+ break;
+ }
+
+ HomerImgDesc_t* pHomer = (HomerImgDesc_t*)i_pImage;
+
+ if( HOMER_MAGIC_WORD != pHomer->homerMagicNumber )
+ {
+ MY_ERR("corrupt or invalid HOMER image location");
+ break;
+ }
+
+ if( (uint8_t) FUSE_MODE == pHomer->fuseModeStatus )
+ {
+ o_fuseMode = true;
+ break;
+ }
+
+ if( (uint8_t) REGULAR_MODE == pHomer->fuseModeStatus )
+ {
+ break;
+ }
+
+ MY_ERR("Unexpected value 0x%08x for fuse mode. Bad or corrupt "
+ "HOMER location", pHomer->fuseModeStatus );
+ l_rc = STOP_SAVE_FAIL;
+
+ }
+ while(0);
+
+ return l_rc;
+}
+
+//----------------------------------------------------------------------
+
+StopReturnCode_t getCoreAndThread( void* const i_pImage, const uint64_t i_pir,
+ uint32_t& o_coreId, uint32_t& o_threadId )
+{
+ StopReturnCode_t l_rc = STOP_SAVE_SUCCESS;
+
+ do
+ {
+ // for SPR restore using 'Virtual Thread' and 'Physical Core' number
+ // In Fuse Mode:
+ // bit b28 and b31 of PIR give physical core and b29 and b30 gives
+ // virtual thread id.
+ // In Non Fuse Mode
+ // bit 28 and b29 of PIR give both logical and physical core number
+ // whereas b30 and b31 gives logical and virtual thread id.
+ bool fuseMode = false;
+ uint8_t coreThreadInfo = (uint8_t)i_pir;
+ o_coreId = 0;
+ o_threadId = 0;
+ l_rc = isFusedMode( i_pImage, fuseMode );
+
+ if( l_rc )
+ {
+ MY_ERR(" Checking Fuse mode. Read failed 0x%08x", l_rc );
+ break;
+ }
+
+ if( fuseMode )
+ {
+ if( coreThreadInfo & FUSE_BIT1 )
+ {
+ o_threadId = 2;
+ }
+
+ if( coreThreadInfo & FUSE_BIT2 )
+ {
+ o_threadId += 1;
+ }
+
+ if( coreThreadInfo & FUSE_BIT0 )
+ {
+ o_coreId = 2;
+ }
+
+ if( coreThreadInfo & FUSE_BIT3 )
+ {
+ o_coreId += 1;
+ }
+ }
+ else
+ {
+ if( coreThreadInfo & FUSE_BIT0 )
+ {
+ o_coreId = 2;
+ }
+
+ if ( coreThreadInfo & FUSE_BIT1 )
+ {
+ o_coreId += 1;
+ }
+
+ if( coreThreadInfo & FUSE_BIT2 )
+ {
+ o_threadId = 2;
+ }
+
+ if( coreThreadInfo & FUSE_BIT3 )
+ {
+ o_threadId += 1;
+ }
+
+
+ }
+
+ //quad field is not affected by fuse mode
+ o_coreId += 4 * (( coreThreadInfo & 0x70 ) >> 4 );
+
+ }
+ while(0);
+
+ return l_rc;
+}
+
+}//namespace stopImageSection ends
OpenPOWER on IntegriCloud