summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshish <ashish.more@in.ibm.com>2016-08-24 07:23:04 -0400
committerJoshua Hunsberger <jahunsbe@us.ibm.com>2017-10-23 16:19:18 -0500
commit4b6952f2a221963b839fad34f38ea7b76e0d0ee4 (patch)
tree2008e30d9c755ee7e04aaa957e57b3333601676e
parentc12f977d41ac971bb455870e98f0f9cf774901b2 (diff)
downloadtalos-hcode-4b6952f2a221963b839fad34f38ea7b76e0d0ee4.tar.gz
talos-hcode-4b6952f2a221963b839fad34f38ea7b76e0d0ee4.zip
PPE command line control
Change-Id: I467470a2a8832dc1ada7568cd3773ee53d61cbe9 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/28719 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Brian T. Vanderpool <vanderp@us.ibm.com> Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
-rw-r--r--import/chips/p9/procedures/hwp/lib/p9_ppe_commands.C348
-rw-r--r--import/chips/p9/procedures/hwp/lib/p9_ppe_commands.H86
-rw-r--r--import/chips/p9/procedures/hwp/lib/p9_ppe_commands.mk28
-rw-r--r--import/chips/p9/procedures/hwp/lib/p9_ppe_utils.C483
-rw-r--r--import/chips/p9/procedures/hwp/lib/p9_ppe_utils.H150
5 files changed, 1095 insertions, 0 deletions
diff --git a/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.C b/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.C
new file mode 100644
index 00000000..74bfd038
--- /dev/null
+++ b/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.C
@@ -0,0 +1,348 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: import/chips/p9/procedures/hwp/lib/p9_ppe_commands.C $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file p9_ppe_commands.C
+/// @brief Get PPE's internal state
+///
+/// *HWP HW Owner : Ashish More <ashish.more.@in.ibm.com>
+/// *HWP HW Backup Owner : Brian Vanderpool <vanderp@us.ibm.com>
+/// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+/// *HWP Team : PM
+/// *HWP Level : 2
+/// *HWP Consumed by : SBE, Cronus
+///
+/// @verbatim
+///
+/// Procedure Summary:
+/// - Dump out PPE's internal state
+///
+/// @endverbatim
+
+//-----------------------------------------------------------------------------
+// Includes
+//-----------------------------------------------------------------------------
+#include <fapi2.H>
+#include <p9_ppe_utils.C>
+#include <p9_ppe_commands.H>
+#include <p9_hcd_common.H>
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Perform PPE internal reg "read" operation
+ * @param[in] i_target Chip Target
+ * @param[in] i_base_address Base SCOM address of the PPE
+ * @param[in] i_mode PPE Dump Mode
+ * @param[out] v_ppe_minor_sprs_value Returned data
+ * @param[out] v_ppe_major_sprs_value Returned data
+ * @param[out] v_ppe_xirs_value Returned data
+ * @param[out] v_ppe_gprs_value Returned data
+ * @param[out] v_ppe_special_sprs_value Returned data
+ * @return fapi2::ReturnCode
+ */
+fapi2::ReturnCode
+ppe_check_status_data(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address,
+ std::vector<PPERegValue_t>& v_ppe_xirs_value,
+ bool& l_ppe_halt_state)
+{
+
+
+ PPERegValue_t l_regVal;
+ char outstr[32];
+ fapi2::buffer<uint64_t> l_data64;
+ fapi2::buffer<uint32_t> l_data32;
+
+ FAPI_INF("Base Address : 0x%08llX", i_base_address);
+ FAPI_INF("------ XIRs ------");
+ // XSR and IAR
+ FAPI_TRY(getScom(i_target, i_base_address + PPE_XIDBGPRO, l_data64), "Error in GETSCOM");
+ l_data64.extractToRight(l_data32, 0, 32);
+ sprintf(outstr, "XSR");
+ FAPI_INF("%-9s = 0x%08llX", outstr, l_data32);
+ l_regVal.reg.number = 1;
+ l_regVal.reg.name = "XSR";
+ l_regVal.value = l_data32;
+ v_ppe_xirs_value.push_back(l_regVal);
+
+ l_data64.extractToRight(l_data32, 32, 32);
+ sprintf(outstr, "IAR");
+ FAPI_INF("%-9s = 0x%08llX", outstr, l_data32);
+ l_regVal.reg.number = 2;
+ l_regVal.reg.name = "IAR";
+ l_regVal.value = l_data32;
+ v_ppe_xirs_value.push_back(l_regVal);
+
+ // IR and EDR
+ FAPI_TRY(getScom(i_target, i_base_address + PPE_XIRAMEDR, l_data64), "Error in GETSCOM");
+ l_data64.extractToRight(l_data32, 0, 32);
+ sprintf(outstr, "IR");
+ FAPI_INF("%-9s = 0x%08llX", outstr, l_data32);
+ l_regVal.reg.number = 3;
+ l_regVal.reg.name = "IR";
+ l_regVal.value = l_data32;
+ v_ppe_xirs_value.push_back(l_regVal);
+
+
+ l_data64.extractToRight(l_data32, 32, 32);
+ sprintf(outstr, "EDR");
+ FAPI_INF("%-9s = 0x%08llX", outstr, l_data32);
+ l_regVal.reg.number = 4;
+ l_regVal.reg.name = "EDR";
+ l_regVal.value = l_data32;
+ v_ppe_xirs_value.push_back(l_regVal);
+
+
+ // Save SPRG0
+ FAPI_TRY(getScom(i_target, i_base_address + PPE_XIRAMDBG, l_data64), "Error in GETSCOM");
+ l_data64.extractToRight(l_data32, 32, 32);
+ sprintf(outstr, "SPRG0");
+ FAPI_INF("%-9s = 0x%08llX", outstr, l_data32);
+ l_regVal.reg.number = 5;
+ l_regVal.reg.name = "SPRG0";
+ l_regVal.value = l_data32;
+ v_ppe_xirs_value.push_back(l_regVal);
+
+
+ //Initially Check for halt
+ FAPI_TRY(getScom(i_target, i_base_address + PPE_XIRAMDBG, l_data64), "Error in GETSCOM");
+
+ if (l_data64.getBit(0, 1))
+ {
+ l_ppe_halt_state = true;
+
+ }
+ else
+ {
+ l_ppe_halt_state = false;
+ }
+
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+
+// Hardware procedure
+fapi2::ReturnCode
+p9_ppe_commands(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address,
+ const PPE_Cmnds i_cmnds,
+ std::vector<PPERegValue_t>& v_ppe_xirs_value,
+ bool& v_ppe_halt_state
+ )
+{
+ fapi2::buffer<uint32_t> l_gpr31_save;
+ fapi2::buffer<uint64_t> l_sprg0_save;
+ fapi2::buffer<uint64_t> l_data64;
+ uint32_t l1_data32;
+ uint32_t l2_data32;
+ char outstr[32];
+
+ if(i_cmnds.cmnd_check_status)
+ {
+ //Call the function to collect the data.
+ ppe_check_status_data(i_target,
+ i_base_address,
+ v_ppe_xirs_value,
+ v_ppe_halt_state
+ );
+ }
+
+ if(i_cmnds.cmnd_force_halt)
+ {
+ FAPI_TRY(ppe_force_halt(i_target, i_base_address));
+ }
+
+ if(i_cmnds.cmnd_halt)
+ {
+ FAPI_TRY(ppe_halt(i_target, i_base_address));
+ }
+
+
+ if(i_cmnds.cmnd_resume)
+ {
+ FAPI_DBG("Resume PPE");
+ FAPI_TRY(ppe_resume(i_target, i_base_address));
+ }
+
+
+ if(i_cmnds.cmnd_resume_brkpt || i_cmnds.cmnd_resume_with_ram ||
+ i_cmnds.cmnd_set_instr_addr_brkpt || i_cmnds.cmnd_set_load_addr_brkpt ||
+ i_cmnds.cmnd_set_store_addr_brkpt || i_cmnds.cmnd_set_store_load_addr_brkpt || i_cmnds.cmnd_set_trap ||
+ i_cmnds.cmnd_reset_trap)
+ {
+ // Save SPRG0
+ FAPI_DBG("Save SPRG0");
+ FAPI_TRY(getScom(i_target, i_base_address + PPE_XIRAMDBG, l_data64), "Error in GETSCOM");
+ l_data64.extractToRight(l_sprg0_save, 32, 32);
+ FAPI_DBG("Saved SPRG0 value : 0x%08llX", l_sprg0_save );
+
+ FAPI_DBG("Save GPR31");
+ l_data64.flush<0>().insertFromRight(ppe_getMtsprInstruction(R31, SPRG0), 0, 32);
+ FAPI_DBG("getMtsprInstruction(%d, SPRG0): 0x%16llX", R31, l_data64 );
+
+ FAPI_TRY(ppe_RAMRead(i_target, i_base_address, l_data64, l_gpr31_save));
+ FAPI_DBG("Saved GPR31 value : 0x%08llX", l_gpr31_save );
+
+ if(i_cmnds.cmnd_resume_brkpt )
+ {
+ FAPI_DBG("Resume Breakpoint");
+ //Modify DBCR
+ //clear DBCR[8] IACE and DBCR[12:13] DACE
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ANDIS_CONST, 0x0F73, R31));
+ //then resume
+ FAPI_TRY(ppe_resume(i_target, i_base_address));
+ }
+
+ if(i_cmnds.cmnd_resume_with_ram )
+ {
+ //Get IAR
+ FAPI_DBG("Resume With Ram");
+ FAPI_TRY(fapi2::getScom(i_target, i_base_address + PPE_XIDBGPRO, l_data64), "Error in GETSCOM");
+ l_data64.extractToRight(l1_data32, 32, 32);
+ sprintf(outstr, "IAR before ramming instruction");
+ FAPI_INF("%-9s = 0x%08llX", outstr, l1_data32);
+
+ FAPI_INF("Ram the instruction 0x%08llX ", i_cmnds.ram_instr);
+ FAPI_TRY(ppe_RAM(i_target, i_base_address, i_cmnds.ram_instr));
+
+ //Get IAR again
+ FAPI_TRY(fapi2::getScom(i_target, i_base_address + PPE_XIDBGPRO, l_data64), "Error in GETSCOM");
+ l_data64.extractToRight(l2_data32, 32, 32);
+ sprintf(outstr, "IAR after ramming the instruction");
+ FAPI_INF("%-9s = 0x%08llX", outstr, l2_data32);
+
+ //If IAR is same after Ramming, increment IAR + 4
+ if(l1_data32 == l2_data32)
+ {
+ FAPI_DBG("IAR matches, increment IAR + 4");
+ l1_data32 = l1_data32 + 4 ;
+ FAPI_INF("new iar = 0x%08llX", l1_data32);
+ l_data64.flush<0>().insertFromRight(l1_data32, 32, 32);
+ FAPI_INF("New IAR = 0x%08llX", l_data64);
+ FAPI_TRY(putScom(i_target, i_base_address + PPE_XIDBGPRO, l_data64),
+ "Error in PUTSCOM in XIDBGPRO to change IAR + 4 ");
+ }
+
+ //Then resume
+ FAPI_TRY(ppe_resume(i_target, i_base_address));
+
+ }
+
+ if(i_cmnds.cmnd_set_instr_addr_brkpt | i_cmnds.cmnd_set_load_addr_brkpt |
+ i_cmnds.cmnd_set_store_addr_brkpt | i_cmnds.cmnd_set_store_load_addr_brkpt)
+ {
+ FAPI_INF("Update DACR with address 0x%X", i_cmnds.brkpt_address);
+ //Update address in DACR(Common)
+ FAPI_TRY(ppe_update_dacr(i_target, i_base_address, i_cmnds.brkpt_address, R31));
+
+ //Now set DBCR
+ if(i_cmnds.cmnd_set_instr_addr_brkpt)
+ {
+ FAPI_DBG("Set INSTR Addr Brkpt");
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ORIS_CONST, 0x0080, R31));
+
+ }
+
+ if(i_cmnds.cmnd_set_store_addr_brkpt)
+ {
+ FAPI_DBG("Set Store Addr Brkpt");
+ //Disable IACE bit 8
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ANDIS_CONST, 0x0F73, R31));
+ //Enable DACE i.e. bit 12:13 = 01
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ORIS_CONST, 0x0004, R31));
+
+ }
+
+ if(i_cmnds.cmnd_set_load_addr_brkpt)
+ {
+ FAPI_DBG("Set Load Addr Brkpt");
+ //Disable IACE bit 8
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ANDIS_CONST, 0x0F73, R31));
+ //Enable DACE i.e. bit 12:13 = 10
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ORIS_CONST, 0x0008, R31));
+
+ }
+
+ if(i_cmnds.cmnd_set_store_load_addr_brkpt)
+ {
+ FAPI_DBG("Set Store Load Addr Brkpt");
+ //Disable IACE bit 8
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ANDIS_CONST, 0x0F73, R31));
+ //Enable DACE i.e. bit 12:13 = 11
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ORIS_CONST, 0x000C, R31));
+
+ }
+
+ }
+
+ if(i_cmnds.cmnd_set_trap) //set bit DBCR[trap] 7th bit
+ {
+ FAPI_DBG("Set DBCR[TRAP]");
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ORIS_CONST, 0x0100, R31));
+ }
+
+ if(i_cmnds.cmnd_reset_trap) //reset bit DBCR[trap] 7th bit
+ {
+ FAPI_DBG("Reset DBCR[TRAP]");
+ FAPI_TRY(ppe_update_dbcr(i_target, i_base_address, ANDIS_CONST, 0x0EFF, R31));
+ }
+
+ FAPI_DBG("Restore GPR31");
+ l_gpr31_save.extractToRight(l_data64, 0, 32); // Put 32b save value into 64b buffer
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMDBG, l_data64));
+ l_data64.flush<0>().insertFromRight(ppe_getMfsprInstruction(R31, SPRG0), 0, 32);
+ FAPI_DBG("getMfsprInstruction(%d, SPRG0): 0x%16llX", 0, l_data64 );
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMEDR, l_data64));
+
+ //Restore GPR31 and SPRG0
+ FAPI_DBG("Restore SPRG0");
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+ FAPI_TRY(putScom(i_target, i_base_address + PPE_XIRAMDBG , l_sprg0_save), "Error in GETSCOM");
+
+ }
+
+ if(i_cmnds.cmnd_single_step)
+ {
+ FAPI_DBG("Single step PPE");
+ FAPI_TRY(ppe_single_step(i_target, i_base_address));
+
+ }
+
+ if(i_cmnds.cmnd_ram)
+ {
+ FAPI_DBG("RAM PPE");
+ FAPI_TRY(ppe_RAM(i_target, i_base_address, i_cmnds.ram_instr));
+
+ }
+
+
+
+
+
+fapi_try_exit:
+ return fapi2::current_err;
+} // Procedure
diff --git a/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.H b/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.H
new file mode 100644
index 00000000..f1d9d91c
--- /dev/null
+++ b/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.H
@@ -0,0 +1,86 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: import/chips/p9/procedures/hwp/lib/p9_ppe_commands.H $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+///
+/// @file p9_ppe_commands.H
+/// @brief PPE commands utility
+///
+/// *HWP HW Owner : Ashish More <ashish.more.@in.ibm.com>
+/// *HWP HW Backup Owner : Brian Vanderpool <vanderp@us.ibm.com>
+/// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+/// *HWP Team : PM
+/// *HWP Level : 2
+/// *HWP Consumed by : CMEs, GPEs, SBE, Cronus
+
+#ifndef __P9_PPE_COMMANDS_H__
+#define __P9_PPE_COMMANDS_H__
+
+typedef struct
+{
+ bool cmnd_halt ;
+ bool cmnd_force_halt;
+ bool cmnd_check_status;
+ bool cmnd_resume;
+ bool cmnd_resume_brkpt;
+ bool cmnd_resume_with_ram;
+ bool cmnd_set_instr_addr_brkpt;
+ bool cmnd_set_load_addr_brkpt;
+ bool cmnd_set_store_addr_brkpt;
+ bool cmnd_set_store_load_addr_brkpt;
+ bool cmnd_set_trap;
+ bool cmnd_reset_trap;
+ bool cmnd_single_step;
+ bool cmnd_ram;
+ uint64_t brkpt_address;
+ uint64_t ram_instr;
+
+} PPE_Cmnds;
+
+
+
+/// @typedef p9_ppe_commands_FP_t
+/// function pointer typedef definition for HWP call support
+typedef fapi2::ReturnCode (*p9_ppe_commands_FP_t) (
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>&,
+ const uint64_t, const PPE_Cmnds,
+ std::vector<PPERegValue_t>& v_ppe_xirs_value, bool& v_ppe_halt_state
+);
+
+extern "C"
+{
+
+/// @brief PPE Commands
+/// @param [in] i_target TARGET_TYPE_PROC_CHIP
+/// @param [in] i_base_address Base offset to be used for all accesses
+/// @return FAPI2_RC_SUCCESS
+ fapi2::ReturnCode
+ p9_ppe_commands(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address, const PPE_Cmnds i_cmnds,
+ std::vector<PPERegValue_t>& v_ppe_xirs_value, bool& v_ppe_halt_state
+ );
+
+} // extern C
+
+#endif // __P9_PPE_COMMANDS_H__
diff --git a/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.mk b/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.mk
new file mode 100644
index 00000000..e63ae20e
--- /dev/null
+++ b/import/chips/p9/procedures/hwp/lib/p9_ppe_commands.mk
@@ -0,0 +1,28 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: import/chips/p9/procedures/hwp/lib/p9_ppe_commands.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+PROCEDURE=p9_ppe_commands
+$(call ADD_MODULE_SRCDIR,$(PROCEDURE),$(ROOTPATH)/chips/p9/procedures/hwp/lib)
+OBJS+=p9_ppe_commands.o
+$(call BUILD_PROCEDURE)
diff --git a/import/chips/p9/procedures/hwp/lib/p9_ppe_utils.C b/import/chips/p9/procedures/hwp/lib/p9_ppe_utils.C
new file mode 100644
index 00000000..4229a6cf
--- /dev/null
+++ b/import/chips/p9/procedures/hwp/lib/p9_ppe_utils.C
@@ -0,0 +1,483 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: import/chips/p9/procedures/hwp/lib/p9_ppe_utils.C $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file p9_ppe_utils.C
+/// @brief PPE commonly used functions
+///
+/// *HWP HW Owner : Ashish More <ashish.more.@in.ibm.com>
+/// *HWP HW Backup Owner : Brian Vanderpool <vanderp@us.ibm.com>
+/// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+/// *HWP Team : PM
+/// *HWP Level : 2
+/// *HWP Consumed by : SBE, Cronus
+///
+/// @verbatim
+///
+/// @endverbatim
+
+//-----------------------------------------------------------------------------
+// Includes
+//-----------------------------------------------------------------------------
+#include <fapi2.H>
+#include <p9_ppe_utils.H>
+#include <p9_hcd_common.H>
+
+/**
+ * @brief enumerates opcodes for few instructions.
+ */
+enum
+{
+ OPCODE_31 = 31,
+ MTSPR_CONST1 = 467,
+ MTSPR_BASE_OPCODE = (OPCODE_31 << (31 - 5)) | (MTSPR_CONST1 << (31 - 30)),
+ MFSPR_CONST1 = 339,
+ MFSPR_BASE_OPCODE = (OPCODE_31 << (31 - 5)) | (MFSPR_CONST1 << (31 - 30)),
+ MFMSRD_CONST1 = 83,
+ MFCR_CONST1 = 19,
+ ANDIS_CONST = 29,
+ ORIS_CONST = 25,
+};
+
+// Vector defining the special acceess egisters
+std::vector<PPEReg_t> v_ppe_special_regs =
+{
+ { MSR, "MSR" },
+ { CR, "CR" },
+};
+
+// Vector defining the major SPRs
+// Note: SPRG0 is not include as it is saved and restored as the means for
+// accessing the other SPRS
+std::vector<PPEReg_t> v_ppe_major_sprs =
+{
+ { CTR, "CTR" },
+ { LR, "LR" },
+ { ISR, "ISR" },
+ { SRR0, "SRR0" },
+ { SRR1, "SRR1" },
+ { TCR, "TCR" },
+ { TSR, "TSR" },
+};
+
+// Vector defining the minor SPRs
+std::vector<PPEReg_t> v_ppe_minor_sprs =
+{
+ { DACR, "DACR" },
+ { DBCR, "DBCR" },
+ { DEC, "DEC" },
+ { IVPR, "IVPR" },
+ { PIR, "PIR" },
+ { PVR, "PVR" },
+ { XER, "XER" },
+};
+
+// Vector defining the GPRs
+std::vector<PPEReg_t> v_ppe_gprs =
+{
+ { R0, "R0" },
+ { R1, "R1" },
+ { R2, "R2" },
+ { R3, "R3" },
+ { R4, "R4" },
+ { R5, "R5" },
+ { R6, "R6" },
+ { R7, "R7" },
+ { R8, "R8" },
+ { R9, "R9" },
+ { R10, "R10" },
+ { R13, "R13" },
+ { R28, "R28" },
+ { R29, "R29" },
+ { R30, "R30" },
+ { R31, "R31" },
+};
+
+
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief generates a PPE instruction for some formats
+ * @param[in] i_Op Opcode
+ * @param[in] i_Rts Source or Target Register
+ * @param[in] i_RA Address Register
+ * @param[in] i_d Instruction Data Field
+ * @return returns 32 bit instruction representing the PPE instruction.
+ */
+
+uint32_t ppe_getInstruction( const uint16_t i_Op, const uint16_t i_Rts, const uint16_t i_Ra, const uint16_t i_d)
+{
+ uint32_t instOpcode = 0;
+
+ instOpcode = (i_Op & 0x3F) << (31 - 5);
+ instOpcode |= (i_Rts & 0x1F) << (31 - 10);
+ instOpcode |= (i_Ra & 0x1F) << (31 - 15);
+ instOpcode |= (i_d & 0xFFFF) << (31 - 31);
+
+ return instOpcode;
+}
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief generates instruction for mtspr
+ * @param[in] i_Rs source register number
+ * @param[in] i_Spr represents spr where data is to be moved.
+ * @return returns 32 bit instruction representing mtspr instruction.
+ */
+uint32_t ppe_getMtsprInstruction( const uint16_t i_Rs, const uint16_t i_Spr )
+{
+ uint32_t mtsprInstOpcode = 0;
+ uint32_t temp = (( i_Spr & 0x03FF ) << 11);
+ mtsprInstOpcode = ( temp & 0x0000F800 ) << 5;
+ mtsprInstOpcode |= ( temp & 0x001F0000 ) >> 5;
+ mtsprInstOpcode |= MTSPR_BASE_OPCODE;
+ mtsprInstOpcode |= ( i_Rs & 0x001F ) << 21;
+
+ return mtsprInstOpcode;
+}
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief generates instruction for mfspr
+ * @param[in] i_Rt target register number
+ * @param[in] i_Spr represents spr where data is to sourced
+ * @return returns 32 bit instruction representing mfspr instruction.
+ */
+uint32_t ppe_getMfsprInstruction( const uint16_t i_Rt, const uint16_t i_Spr )
+{
+ uint32_t mtsprInstOpcode = 0;
+ uint32_t temp = (( i_Spr & 0x03FF ) << 11);
+ mtsprInstOpcode = ( temp & 0x0000F800 ) << 5;
+ mtsprInstOpcode |= ( temp & 0x001F0000 ) >> 5;
+ mtsprInstOpcode |= MFSPR_BASE_OPCODE;
+ mtsprInstOpcode |= ( i_Rt & 0x001F ) << 21;
+
+ return mtsprInstOpcode;
+}
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief generates instruction for mfmsr instruction.
+ * @param[in] i_Rt target register number
+ * @return returns 32 bit instruction representing mfmsr instruction.
+ * @note moves contents of register MSR to i_Rt register.
+ */
+uint32_t ppe_getMfmsrInstruction( const uint16_t i_Rt )
+{
+ uint32_t mfmsrdInstOpcode = 0;
+ mfmsrdInstOpcode = 0;
+ mfmsrdInstOpcode = OPCODE_31 << 26;
+ mfmsrdInstOpcode |= i_Rt << 21 | ( MFMSRD_CONST1 << 1 );
+
+ return mfmsrdInstOpcode;
+}
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief generates instruction for mfcr instruction.
+ * @param[in] i_Rt target register number
+ * @return returns 32 bit instruction representing mfcr instruction.
+ * @note moves contents of register CR to i_Rt register.
+ */
+uint32_t ppe_getMfcrInstruction( const uint16_t i_Rt )
+{
+ uint32_t mfcrdInstOpcode = 0;
+ mfcrdInstOpcode = 0;
+ mfcrdInstOpcode = OPCODE_31 << 26;
+ mfcrdInstOpcode |= i_Rt << 21 | ( MFCR_CONST1 << 1 );
+
+ return mfcrdInstOpcode;
+}
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief poll for Halt state
+ * @param[in] i_Rt target register number
+ * @return fapi2::ReturnCode
+ * @note moves contents of register MSR to i_Rt register.
+ */
+fapi2::ReturnCode ppe_pollHaltState(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address)
+{
+ fapi2::buffer<uint64_t> l_data64;
+
+ // Halt state entry should be very fast on PPEs (eg nanoseconds)
+ // Try only using the SCOM access time to delay.
+ static const uint32_t HALT_TRIES = 10;
+
+ uint32_t l_timeout_count = HALT_TRIES;
+
+ do
+ {
+ FAPI_TRY(getScom(i_target, i_base_address + PPE_XIRAMDBG, l_data64), "Error in GETSCOM");
+ }
+ while (! l_data64.getBit<0>() &&
+ --l_timeout_count != 0);
+
+
+ FAPI_ASSERT(l_data64.getBit<0>(), fapi2::P9_PPE_STATE_HALT_TIMEOUT_ERR(),
+ "PPE Halt Timeout");
+
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief halt the engine
+ * @param[in] i_target target register number
+ * @return fapi2::ReturnCode
+ * @note programs XCR with halt bit to halt the engine.
+ */
+fapi2::ReturnCode ppe_halt(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address)
+{
+ fapi2::buffer<uint64_t> l_data64;
+
+ FAPI_INF(" Send HALT command via XCR...");
+ l_data64.flush<0>().insertFromRight(p9hcd::HALT, 1, 3);
+
+ FAPI_TRY(putScom(i_target, i_base_address + PPE_XIXCR, l_data64), "Error in PUTSCOM in XCR to generate Halt condition");
+
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief force halt the engine
+ * @param[in] i_target target register number
+ * @return fapi2::ReturnCode
+ * @note programs XCR with force halt to force halt the engine.
+ */
+fapi2::ReturnCode ppe_force_halt(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address)
+{
+ fapi2::buffer<uint64_t> l_data64;
+
+ FAPI_INF(" Send FORCE HALT command via XCR...");
+ l_data64.flush<0>().insertFromRight(p9hcd::FORCE_HALT, 1, 3);
+
+ FAPI_TRY(putScom(i_target, i_base_address + PPE_XIXCR, l_data64),
+ "Error in PUTSCOM in XCR to generate Force Halt condition");
+
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief single step the engine
+ * @param[in] i_target target register number
+ * @return fapi2::ReturnCode
+ * @note programs XCR with single step tosingle step the engine.
+ */
+fapi2::ReturnCode ppe_single_step(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address)
+{
+ fapi2::buffer<uint64_t> l_data64;
+
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+ FAPI_INF(" Send Single step command via XCR...");
+ l_data64.flush<0>().insertFromRight(p9hcd::SINGLE_STEP, 1, 3);
+
+ FAPI_TRY(putScom(i_target, i_base_address + PPE_XIXCR, l_data64),
+ "Error in PUTSCOM in XCR to generate Single Step condition");
+
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief resume the halted engine
+ * @param[in] i_target target register number
+ * @return fapi2::ReturnCode
+ * @note programs XCR with resume bit to resume the engine.
+ */
+fapi2::ReturnCode ppe_resume(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address)
+{
+ fapi2::buffer<uint64_t> l_data64;
+
+ static const uint32_t RESUME_TRIES = 10;
+ uint32_t l_timeout_count = RESUME_TRIES;
+ //Before reume always clear debug status (Michael's comment)
+ FAPI_INF(" Clear debug status via XCR...");
+ l_data64.flush<0>();
+ FAPI_TRY(putScom(i_target, i_base_address + PPE_XIXCR, l_data64), "Error in PUTSCOM in XCR to resume condition");
+
+ FAPI_INF(" Send RESUME command via XCR...");
+ l_data64.flush<0>().insertFromRight(p9hcd::RESUME, 1, 3);
+
+ FAPI_TRY(putScom(i_target, i_base_address + PPE_XIXCR, l_data64), "Error in PUTSCOM in XCR to resume condition");
+
+ do
+ {
+ FAPI_TRY(getScom(i_target, i_base_address + PPE_XIRAMEDR, l_data64));
+ FAPI_DBG(" Poll content: XSR: 0x%16llX", l_data64);
+ }
+ while((l_data64.getBit<p9hcd::HALTED_STATE>() != 0) && (--l_timeout_count != 0));
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief update dbcr
+ * @param[in] i_target target register number
+ * @return fapi2::ReturnCode
+ * @note programs mtdbcr
+ */
+fapi2::ReturnCode ppe_update_dbcr(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address,
+ const uint64_t l_inst_op,
+ const uint16_t l_immed_16,
+ const uint16_t i_Rs)
+{
+ fapi2::buffer<uint64_t> l_data64;
+ //Modify DBCR using read modify write
+ //Move DBCR to Rs
+ l_data64.flush<0>().insertFromRight(ppe_getMfsprInstruction(i_Rs, DBCR), 0, 32);
+ FAPI_DBG("getMfsprInstruction(%d, DBCR): 0x%16llX", i_Rs, l_data64 );
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMEDR, l_data64));
+ //Modify Rs
+ l_data64.flush<0>().insertFromRight(ppe_getInstruction(l_inst_op, i_Rs, i_Rs, l_immed_16), 0, 32);
+ FAPI_DBG("getInstruction(Immed %X: 0x%16llX", l_immed_16, l_data64 );
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMEDR, l_data64));
+ //MOVE new Rs into DBCR
+ l_data64.flush<0>().insertFromRight(ppe_getMtsprInstruction(i_Rs, DBCR), 0, 32);
+ FAPI_DBG("getMtsprInstruction(%d, DBCR): 0x%16llX", i_Rs, l_data64 );
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMEDR, l_data64));
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+
+/**
+ * @brief update dacr
+ * @param[in] i_target target register number
+ * @return fapi2::ReturnCode
+ * @note programs mtdacr
+ */
+fapi2::ReturnCode ppe_update_dacr(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address,
+ const uint64_t l_address,
+ const uint16_t i_Rs)
+{
+ fapi2::buffer<uint32_t> temp_inst32;
+ fapi2::buffer<uint64_t> temp_data64;
+
+ temp_data64.flush<0>().insertFromRight(ppe_getMfsprInstruction(i_Rs, SPRG0), 0, 32);
+ FAPI_DBG("getMfsprInstruction(%d, SPRG0): 0x%16llX", i_Rs, temp_data64 );
+ temp_data64.insertFromRight(l_address, 32, 32);
+ FAPI_DBG("Final Instr + SPRG0: 0x%16llX", temp_data64 );
+ //write sprg0 with address and ram mfsprg0 to i_Rs
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMGA, temp_data64 ));
+
+ //then mtdacr from i_Rs
+ temp_data64.flush<0>().insertFromRight(ppe_getMtsprInstruction(i_Rs, DACR), 0, 32);
+ FAPI_DBG("getMtsprInstruction(%d, DBCR): 0x%16llX", i_Rs, temp_data64 );
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMEDR, temp_data64));
+fapi_try_exit:
+ return fapi2::current_err;
+}
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Perform RAM "read" operation
+ * @param[in] i_target Chip Target
+ * @param[in] i_base_address Base SCOM address of the PPE
+ * @param[in] i_instruction RAM instruction to move a register
+ * @param[out] o_data Returned data
+ * @return fapi2::ReturnCode
+ */
+fapi2::ReturnCode ppe_RAMRead(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address,
+ const fapi2::buffer<uint64_t> i_instruction,
+ fapi2::buffer<uint32_t>& o_data)
+{
+ fapi2::buffer<uint64_t> l_data64;
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMEDR, i_instruction));
+ FAPI_DBG(" RAMREAD i_instruction: 0X%16llX", i_instruction);
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+ FAPI_TRY(fapi2::getScom(i_target, i_base_address + PPE_XIRAMDBG, l_data64), "Error in GETSCOM");
+ l_data64.extractToRight(o_data, 32, 32);
+ FAPI_DBG(" RAMREAD o_data: 0X%16llX", o_data);
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Perform RAM "read" operation
+ * @param[in] i_target Chip Target
+ * @param[in] i_base_address Base SCOM address of the PPE
+ * @param[in] i_instruction RAM instruction to move a register
+ * @param[out] o_data Returned data
+ * @return fapi2::ReturnCode
+ */
+fapi2::ReturnCode ppe_RAM(
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ const uint64_t i_base_address,
+ const uint64_t i_instruction
+)
+{
+ fapi2::buffer<uint64_t> l_data64;
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+
+
+ l_data64.flush<0>().insertFromRight(i_instruction, 0, 32);
+ FAPI_TRY(fapi2::putScom(i_target, i_base_address + PPE_XIRAMEDR, l_data64));
+ FAPI_DBG(" RAMREAD i_instruction: 0X%16llX", i_instruction);
+ FAPI_TRY(ppe_pollHaltState(i_target, i_base_address));
+
+fapi_try_exit:
+ return fapi2::current_err;
+}
diff --git a/import/chips/p9/procedures/hwp/lib/p9_ppe_utils.H b/import/chips/p9/procedures/hwp/lib/p9_ppe_utils.H
new file mode 100644
index 00000000..cbc0eaec
--- /dev/null
+++ b/import/chips/p9/procedures/hwp/lib/p9_ppe_utils.H
@@ -0,0 +1,150 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: import/chips/p9/procedures/hwp/lib/p9_ppe_utils.H $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+///
+/// @file p9_ppe_utils.H
+/// @brief PPE commonly used functions
+///
+/// *HWP HW Owner : Ashish More <ashish.more.@in.ibm.com>
+/// *HWP HW Backup Owner : Brian Vanderpool <vanderp@us.ibm.com>
+/// *HWP FW Owner : Sangeetha T S <sangeet2@in.ibm.com>
+/// *HWP Team : PM
+/// *HWP Level : 2
+/// *HWP Consumed by : CMEs, GPEs, SBE, Cronus
+
+#ifndef __P9_PPE_UTILS_H__
+#define __P9_PPE_UTILS_H__
+typedef struct
+{
+ uint16_t number;
+ std::string name;
+} PPEReg_t;
+
+typedef struct
+{
+ PPEReg_t reg;
+ uint32_t value;
+} PPERegValue_t;
+
+typedef struct
+{
+ PPEReg_t reg;
+ uint64_t value;
+} SCOMRegValue_t;
+
+/**
+ * @brief Offsets from base address for XIRs.
+ */
+const static uint64_t PPE_XIXCR = 0x0;
+const static uint64_t PPE_XIRAMRA = 0x1;
+const static uint64_t PPE_XIRAMGA = 0x2;
+const static uint64_t PPE_XIRAMDBG = 0x3;
+const static uint64_t PPE_XIRAMEDR = 0x4;
+const static uint64_t PPE_XIDBGPRO = 0x5;
+
+enum PPE_DUMP_MODE
+{
+ XIRS = 0x0,
+ SNAPSHOT = 0x1,
+ HALT = 0x2,
+ FORCE_HALT = 0x3
+};
+enum VERBOSE_MODE
+{
+ NOVERBOSE = 0x0,
+ VERBOSE = 0x1,
+ VERBOSEP = 0x2,
+};
+
+enum INT_VEC_OFFSET
+{
+ MCHK_VEC = 0x000 , // 0,
+ SRST_VEC = 0x040 , // 64,
+ DSI_VEC = 0x060 , // 96,
+ ISI_VEC = 0x080 , // 128,
+ EXT_VEC = 0x0A0 , // 160,
+ ALIG_VEC = 0x0C0 , // 192,
+ PRG_VEC = 0x0E0 , // 224,
+ DEC_VEC = 0x100 , // 256,
+ FIT_VEC = 0x120 , // 288,
+ WDT_VEC = 0x140 , // 320,
+} ;
+enum PPE_XIRS
+{
+ XIR_XSR,
+ XIR_IAR,
+ XIR_IR,
+ XIR_EDR,
+ XIR_SPRG0,
+};
+
+enum PPE_SPECIAL_ACCESS
+{
+ MSR,
+ CR,
+};
+enum PPE_SPRS
+{
+ CTR = 9,
+ DACR = 316,
+ DBCR = 308,
+ DEC = 22,
+ IVPR = 63,
+ ISR = 62,
+ LR = 8,
+ PIR = 286,
+ PVR = 287,
+ SPRG0 = 272,
+ SRR0 = 26,
+ SRR1 = 27,
+ TCR = 340,
+ TSR = 336,
+ XER = 1, //336,
+};
+
+
+// Note: EDR is available via XIR
+enum PPE_GPRS
+{
+ R0 = 0,
+ R1 = 1,
+ R2 = 2,
+ R3 = 3,
+ R4 = 4,
+ R5 = 5,
+ R6 = 6,
+ R7 = 7,
+ R8 = 8,
+ R9 = 9,
+ R10 = 10,
+ R13 = 13,
+ R28 = 28,
+ R29 = 29,
+ R30 = 30,
+ R31 = 31,
+};
+
+
+#endif // __P9_PPE_UTILS_H__
OpenPOWER on IntegriCloud