diff options
Diffstat (limited to 'sbe/sbefw')
-rw-r--r-- | sbe/sbefw/sbeHostMsg.H | 24 | ||||
-rw-r--r-- | sbe/sbefw/sbeHostUtils.C | 51 | ||||
-rw-r--r-- | sbe/sbefw/sbeHostUtils.H | 12 | ||||
-rw-r--r-- | sbe/sbefw/sbe_host_intf.H | 42 | ||||
-rw-r--r-- | sbe/sbefw/sbe_sp_intf.H | 51 | ||||
-rw-r--r-- | sbe/sbefw/sbecmdparser.C | 44 | ||||
-rw-r--r-- | sbe/sbefw/sbecmdringaccess.C | 169 | ||||
-rw-r--r-- | sbe/sbefw/sbecmdringaccess.H | 55 | ||||
-rw-r--r-- | sbe/sbefw/sbefwfiles.mk | 2 |
9 files changed, 443 insertions, 7 deletions
diff --git a/sbe/sbefw/sbeHostMsg.H b/sbe/sbefw/sbeHostMsg.H index 12ab1502..edd040cf 100644 --- a/sbe/sbefw/sbeHostMsg.H +++ b/sbe/sbefw/sbeHostMsg.H @@ -1,3 +1,27 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/sbefw/sbeHostMsg.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] 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: ppe/sbe/sbefw/sbeHostMsg.H * diff --git a/sbe/sbefw/sbeHostUtils.C b/sbe/sbefw/sbeHostUtils.C index f143db6b..bdb0064e 100644 --- a/sbe/sbefw/sbeHostUtils.C +++ b/sbe/sbefw/sbeHostUtils.C @@ -36,7 +36,7 @@ #include "sbe_host_intf.H" #include "sbeerrorcodes.H" #include "assert.h" - +#include "fapi2.H" /////////////////////////////////////////////////////////////////// @@ -74,7 +74,9 @@ uint32_t sbeReadPsu2SbeMbxReg (uint32_t i_addr, break; } - SBE_DEBUG(SBE_FUNC"l_data=[0x%016X]", o_pData[l_count]); + SBE_DEBUG(SBE_FUNC"l_data=[0x%08X%08X]", + SBE::higher32BWord(o_pData[l_count]), + SBE::lower32BWord(o_pData[l_count])); ++l_count; ++i_addr; } @@ -149,7 +151,9 @@ uint32_t sbeWriteSbe2PsuMbxReg (uint32_t i_addr, { while (l_count < i_count) { - SBE_DEBUG(SBE_FUNC"l_data=[0x%016X]", *(i_pData+l_count)); + SBE_DEBUG(SBE_FUNC"l_data=[0x%08X%08X]", + SBE::higher32BWord(*(i_pData+l_count)), + SBE::lower32BWord(*(i_pData+l_count))); l_rc = putscom_abs ( i_addr, *(i_pData+l_count) ); if (l_rc) @@ -180,3 +184,44 @@ uint32_t sbeWriteSbe2PsuMbxReg (uint32_t i_addr, #undef SBE_FUNC } + +/* @brief - Send PSU Chip Op response + * + * @param[in] - i_sbe2PsuRespHdr - Response header + * @param[in] - i_fapiRc - fapi rc of the relevant hwp call + * @param[in/out] - io_rc - rc status of the PSU access utility + * + * @return - void + */ +void sbePSUSendResponse(sbeSbe2PsuRespHdr_t &i_sbe2PsuRespHdr, + uint32_t &i_fapiRc, + uint32_t &io_rc) +{ +#define SBE_FUNC "sbePSUSendResponse" + do + { + // Making sure the PSU access utility is functional + if(io_rc != SBE_SEC_OPERATION_SUCCESSFUL) + { + break; + } + // TODO via RTC:151555 Generate FFDC + if(i_fapiRc != fapi2::FAPI2_RC_SUCCESS) + { + i_sbe2PsuRespHdr.setStatus(SBE_PRI_GENERIC_EXECUTION_FAILURE, + SBE_SEC_GENERIC_FAILURE_IN_EXECUTION); + } + + // Send the response header + io_rc = sbeWriteSbe2PsuMbxReg(SBE_HOST_PSU_MBOX_REG4, + (uint64_t*)(&i_sbe2PsuRespHdr), + (sizeof(i_sbe2PsuRespHdr)/sizeof(uint64_t)), + true); + if(SBE_SEC_OPERATION_SUCCESSFUL != io_rc) + { + SBE_ERROR(SBE_FUNC" Failed to write to " + "SBE_HOST_PSU_MBOX_REG4"); + } + } while(0); +#undef SBE_FUNC +} diff --git a/sbe/sbefw/sbeHostUtils.H b/sbe/sbefw/sbeHostUtils.H index c172e4e9..0605d476 100644 --- a/sbe/sbefw/sbeHostUtils.H +++ b/sbe/sbefw/sbeHostUtils.H @@ -35,6 +35,7 @@ #include <stdint.h> #include "ppe42_scom.h" +#include "sbeHostMsg.H" /** * @brief SBE PSU Access register addresses @@ -230,4 +231,15 @@ uint32_t sbeWriteSbe2PsuMbxReg (uint32_t i_addr, const uint8_t i_count, bool i_setBit0ToIntrHB = false); +/* @brief - Send PSU Chip Op response + * + * @param[in] - i_sbe2PsuRespHdr - Response header + * @param[in] - i_fapiRc - fapi rc of the relevant hwp call + * @param[in/out] - io_rc - rc status of the PSU access utility + * + * @return - void + */ +void sbePSUSendResponse(sbeSbe2PsuRespHdr_t &i_sbe2PsuRespHdr, + uint32_t &i_fapiRc, + uint32_t &io_rc); #endif // __SBEFW_SBEHOSTUTILS_H diff --git a/sbe/sbefw/sbe_host_intf.H b/sbe/sbefw/sbe_host_intf.H index e31813e9..ac08ae42 100644 --- a/sbe/sbefw/sbe_host_intf.H +++ b/sbe/sbefw/sbe_host_intf.H @@ -1,3 +1,27 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/sbefw/sbe_host_intf.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] 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: ppe/sbe/sbefw/sbe_host_intf.H * @@ -24,8 +48,9 @@ static const uint16_t SBE_SBEFW_HOST_MINOR_VERSION = 0; */ enum sbePsuCommandClass { - SBE_PSU_CMD_CLASS_UNKNOWN = 0, - SBE_PSU_CMD_CLASS_CORE_STATE = 0xD1, + SBE_PSU_CMD_CLASS_UNKNOWN = 0, + SBE_PSU_CMD_CLASS_CORE_STATE = 0xD1, + SBE_PSU_CMD_CLASS_RING_ACCESS = 0xD3, }; /** @@ -33,8 +58,17 @@ enum sbePsuCommandClass */ enum sbePsuCoreStateControlCommands { - SBE_PSU_CMD_CONTROL_DEADMAN = 0x01, - SBE_PSU_CMD_UNKNOWN = 0xFF, + SBE_PSU_CMD_CONTROL_DEADMAN = 0x01, + SBE_PSU_CMD_UNKNOWN = 0xFF, +}; + +/** + * @brief enums for SBE-Host interface ring access messages + */ +enum sbePsuRingAccessMessages +{ + SBE_PSU_MSG_PUT_RING_FROM_IMAGE = 0x01, + SBE_PSU_MSG_UNKNOWN = 0xFF, }; /** diff --git a/sbe/sbefw/sbe_sp_intf.H b/sbe/sbefw/sbe_sp_intf.H index 531a72eb..1f02515f 100644 --- a/sbe/sbefw/sbe_sp_intf.H +++ b/sbe/sbefw/sbe_sp_intf.H @@ -1,3 +1,27 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/sbefw/sbe_sp_intf.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* [+] 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 sbe_sp_intf.H * @@ -348,6 +372,33 @@ enum sbeRegAccesRegType SBE_REG_ACCESS_FPR = 0x02, }; +/* + * @brief enums for target types used in ring access chip op +*/ +typedef enum +{ + TARGET_PERV = 0x0000, + TARGET_PROC_CHIP = 0x0001, + TARGET_CORE = 0x0002, + TARGET_EX = 0x0003, +} sbeRingTargetTypes_t; + +/* + * @brief enums for access modes used in ring access chip op + */ +typedef enum +{ + SBE_RING_MODE_NO_HEADER_CHECK = 0x0001, ///< Don't check header + SBE_RING_MODE_SET_PULSE_NO_OPCG_COND = 0x0002, ///< Set pulse with + /// no OPCG conditioning + SBE_RING_MODE_SET_PULSE_NSL = 0x0004, ///< Set pulse with NSL + /// pulse + SBE_RING_MODE_SET_PULSE_SL = 0x0008, ///< Set pulse with SL + /// pulse + SBE_RING_MODE_SET_PULSE_ALL = 0x0010, ///< Set pulse with pulse + /// to all hold types +} sbeRingAccessModes_t; + #ifdef __cplusplus } #endif diff --git a/sbe/sbefw/sbecmdparser.C b/sbe/sbefw/sbecmdparser.C index 9dc6c094..572574fe 100644 --- a/sbe/sbefw/sbecmdparser.C +++ b/sbe/sbefw/sbecmdparser.C @@ -1,3 +1,27 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/sbefw/sbecmdparser.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* [+] 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: ppe/sbe/sbefw/sbecmdparser.C * @@ -12,6 +36,7 @@ #include "sbecmdmemaccess.H" #include "sbecmdregaccess.H" #include "sbecmdcntrldmt.H" +#include "sbecmdringaccess.H" #include "sbecmdsram.H" #include "sbecmdcntlinst.H" #include "sbetrace.H" @@ -144,6 +169,19 @@ static sbeCmdStruct_t g_sbeCoreStateControlCmdArray [] = }, }; +////////////////////////////////////////////////////////////// +// @brief g_sbePutRingFromImageCmdArray +// +////////////////////////////////////////////////////////////// +static sbeCmdStruct_t g_sbePutRingFromImageCmdArray [] = +{ + {sbePutRingFromImagePSU, + SBE_PSU_MSG_PUT_RING_FROM_IMAGE, + SBE_FENCE_AT_CONTINUOUS_IPL, + }, +}; + + //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// uint8_t sbeGetCmdStructAttr (const uint8_t i_cmdClass, @@ -200,6 +238,12 @@ uint8_t sbeGetCmdStructAttr (const uint8_t i_cmdClass, *o_ppCmd = (sbeCmdStruct_t*)g_sbeCoreStateControlCmdArray; break; + case SBE_PSU_CMD_CLASS_RING_ACCESS: + l_numCmds = sizeof(g_sbePutRingFromImageCmdArray) / + sizeof(sbeCmdStruct_t); + *o_ppCmd = (sbeCmdStruct_t*)g_sbePutRingFromImageCmdArray; + break; + // This will grow with each class of chipOp in future default: break; diff --git a/sbe/sbefw/sbecmdringaccess.C b/sbe/sbefw/sbecmdringaccess.C new file mode 100644 index 00000000..79939139 --- /dev/null +++ b/sbe/sbefw/sbecmdringaccess.C @@ -0,0 +1,169 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/sbefw/sbecmdringaccess.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] 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: ppe/sbe/sbefw/sbecmdcntrldmt.C + * + * @brief This file contains Put Ring From Image Command handler + * + */ +#include "sbecmdringaccess.H" +#include "sbetrace.H" +#include "sbeHostMsg.H" +#include "sbeHostUtils.H" +#include "sbeutil.H" +#include "fapi2.H" + +using namespace fapi2; +/*@brief - Map sbe ring access modes to fapi ring access modes + * + * @param[in] - i_ringMode - sbe ring access mode + * + * @return - l_fapiRingMode - fapi ring mode + */ +uint16_t sbeToFapiRingMode(uint16_t i_ringMode) +{ + uint16_t l_fapiRingMode = RING_MODE_HEADER_CHECK; + + if(i_ringMode & SBE_RING_MODE_SET_PULSE_NO_OPCG_COND) + { + l_fapiRingMode |= RING_MODE_SET_PULSE_NO_OPCG_COND; + } + if(i_ringMode & SBE_RING_MODE_NO_HEADER_CHECK) + { + l_fapiRingMode |= RING_MODE_NO_HEADER_CHECK; + } + if(i_ringMode & SBE_RING_MODE_SET_PULSE_NSL) + { + l_fapiRingMode |= RING_MODE_SET_PULSE_NSL; + } + if(i_ringMode & SBE_RING_MODE_SET_PULSE_SL) + { + l_fapiRingMode |= RING_MODE_SET_PULSE_SL; + } + if(i_ringMode & SBE_RING_MODE_SET_PULSE_ALL) + { + l_fapiRingMode |= RING_MODE_SET_PULSE_ALL; + } + return l_fapiRingMode; +} + +/*@brief - create fapi target handle for the target type + * + * @param[in] - i_taretType - sbe ring target type + * @param[in] - i_chipletId - chiplet id + * @param[out] - o_tgtHndl - fapi target handle + * + * @return - true - on success + * false - on failure + */ +bool sbeGetFapiTargetHandle(uint16_t i_targetType, + uint16_t i_chipletId, + fapi2::plat_target_handle_t &o_tgtHndl) +{ + bool l_rc = true; + switch(i_targetType) + { + case TARGET_CORE: + o_tgtHndl = plat_getTargetHandleByChipletNumber + <fapi2::TARGET_TYPE_CORE>(i_chipletId); + break; + case TARGET_EX: + o_tgtHndl = plat_getTargetHandleByChipletNumber + <fapi2::TARGET_TYPE_EX>(i_chipletId); + break; + case TARGET_PERV: + o_tgtHndl = plat_getTargetHandleByChipletNumber + <fapi2::TARGET_TYPE_PERV>(i_chipletId); + break; + case TARGET_PROC_CHIP: + o_tgtHndl = plat_getChipTarget().get(); + break; + default: + l_rc = false; + break; + } + return l_rc; +} + +uint32_t sbePutRingFromImagePSU (uint8_t *i_pArg) +{ +#define SBE_FUNC " sbePutRingFromImagePSU " + SBE_ENTER(SBE_FUNC); + uint32_t l_rc = SBE_SEC_OPERATION_SUCCESSFUL; + uint32_t l_fapiRc = FAPI2_RC_SUCCESS; + sbePSUPutRingCMD_t l_cmd = {0}; + do + { + // Fetch Ring ID, Ring mode and pervasive chiplet id from the message + // and also send Ack to Host via SBE_SBE2PSU_DOORBELL_SET_BIT1 + l_rc = sbeReadPsu2SbeMbxReg(SBE_HOST_PSU_MBOX_REG1, + (sizeof(l_cmd)/sizeof(uint64_t)), + (uint64_t*)&l_cmd, + true); + if(SBE_SEC_OPERATION_SUCCESSFUL != l_rc) + { + SBE_ERROR(SBE_FUNC "Failed to extract SBE_HOST_PSU_MBOX_REG1 and " + "SBE_HOST_PSU_MBOX_REG2"); + break; + } + + // Construct a Target from Chiplet ID and Target Type + fapi2::plat_target_handle_t l_tgtHndl = {0}; + if(!sbeGetFapiTargetHandle(l_cmd.TargetType, l_cmd.ChipletID, + l_tgtHndl)) + { + SBE_ERROR(SBE_FUNC "Invalid target type [0x%04x]", + (uint16_t)l_cmd.TargetType); + g_sbeSbe2PsuRespHdr.setStatus(SBE_PRI_INVALID_DATA, + SBE_SEC_INVALID_TARGET_TYPE_PASSED); + break; + } + fapi2::Target<TARGET_TYPE_ALL> l_Tgt(l_tgtHndl); + + // Initialize with HEADER CHECK mode + uint16_t l_ringMode = sbeToFapiRingMode(l_cmd.RingMode); + + l_fapiRc = (uint32_t)putRing(l_Tgt, (RingID)l_cmd.RingID, + (RingMode)l_ringMode); + if(l_fapiRc != FAPI2_RC_SUCCESS) + { + SBE_ERROR(SBE_FUNC "putRing HWP failure - " + "MSG - Target Type [0x%04x] Ring ID [0x%04x]" + " Ring Mode [0x%04x] Chiplet ID [0x%04x]", + l_cmd.TargetType, + l_cmd.RingID, + l_cmd.RingMode, + l_cmd.ChipletID); + break; + } + }while(0); // End of do-while + + // Send the response + sbePSUSendResponse(g_sbeSbe2PsuRespHdr, l_fapiRc, l_rc); + + SBE_EXIT(SBE_FUNC); + return l_rc; +#undef SBE_FUNC +} diff --git a/sbe/sbefw/sbecmdringaccess.H b/sbe/sbefw/sbecmdringaccess.H new file mode 100644 index 00000000..ff835dc4 --- /dev/null +++ b/sbe/sbefw/sbecmdringaccess.H @@ -0,0 +1,55 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/sbefw/sbecmdringaccess.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] 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: ppe/sbe/sbefw/sbeputringfromimage.H + * + * @brief This file contains the Put Ring From Image Command handler + * + */ + +#ifndef __SBEFW_SBECMDRINGACCESS_H +#define __SBEFW_SBECMDRINGACCESS_H + +#include <stdint.h> + +typedef struct +{ + uint64_t TargetType:16; + uint64_t ChipletID:16; + uint64_t RingID:16; + uint64_t RingMode:16; +} sbePSUPutRingCMD_t; + +/** + * @brief Put Ring From Image Command (0xD301) + * + * @param[in] i_pArg Buffer to be passed to the function (not used as of now) + * + * @return RC from the PSU access utility + */ +uint32_t sbePutRingFromImagePSU(uint8_t *i_pArg); + +#endif // __SBEFW_SBECMDRINGACCESS_H + diff --git a/sbe/sbefw/sbefwfiles.mk b/sbe/sbefw/sbefwfiles.mk index b7fef999..a86c6179 100644 --- a/sbe/sbefw/sbefwfiles.mk +++ b/sbe/sbefw/sbefwfiles.mk @@ -40,6 +40,8 @@ SBEFW-CPP-SOURCES += sberegaccess.C SBEFW-CPP-SOURCES += sbecmdcntlinst.C SBEFW-CPP-SOURCES += sbecmdregaccess.C SBEFW-CPP-SOURCES += sbeFFDC.C +SBEFW-CPP-SOURCES += sbecmdringaccess.C + SBEFW-C-SOURCES = SBEFW-S-SOURCES = |