diff options
Diffstat (limited to 'src/usr/hwpf/plat')
| -rw-r--r-- | src/usr/hwpf/plat/HBconfig | 4 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C | 631 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatAttributeService.C | 2142 | ||||
| -rwxr-xr-x | src/usr/hwpf/plat/fapiPlatCreateHwpErrParser.pl | 272 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatHwAccess.C | 736 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatHwpInvoker.C | 784 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatMBvpdAccess.C | 358 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatMvpdAccess.C | 1694 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C | 51 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatSystemConfig.C | 579 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatTarget.C | 279 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatTask.C | 83 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/fapiPlatUtil.C | 340 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/makefile | 33 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/plat.mk | 44 | ||||
| -rw-r--r-- | src/usr/hwpf/plat/runtime/makefile | 35 |
16 files changed, 0 insertions, 8065 deletions
diff --git a/src/usr/hwpf/plat/HBconfig b/src/usr/hwpf/plat/HBconfig deleted file mode 100644 index 2d9d4ba6c..000000000 --- a/src/usr/hwpf/plat/HBconfig +++ /dev/null @@ -1,4 +0,0 @@ -config VPD_GETMACRO_USE_EFF_ATTR - default y if !HAVE_MBVPD - help - Use EFF attribute in VPD GETMACRO diff --git a/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C b/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C deleted file mode 100644 index 66bbbda1f..000000000 --- a/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C +++ /dev/null @@ -1,631 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2015 */ -/* [+] 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 fapiPlatAttrOverrideSync.C - * - * @brief Implements the functions for Attribute Override and Sync - * - */ - -//****************************************************************************** -// Includes -//****************************************************************************** -#include <limits.h> -#include <sys/msg.h> -#include <string.h> -#include <vector> -#include <sys/msg.h> -#include <errl/errlentry.H> -#include <errl/errlmanager.H> -#include <mbox/mboxif.H> -#include <hwpf/plat/fapiPlatAttrOverrideSync.H> -#include <hwpf/plat/fapiPlatTrace.H> -#include <isteps/hwpf_reasoncodes.H> -#include <targeting/common/utilFilter.H> -#include <targeting/common/attributeTank.H> - -namespace fapi -{ - -//****************************************************************************** -// Global Variables -//****************************************************************************** - -#ifndef __HOSTBOOT_RUNTIME -// Set by a debug tool to directly apply an Attribute Override -TARGETING::AttributeTank::AttributeHeader g_attrOverrideHeader; -uint8_t g_attrOverride[AttrOverrideSync::MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES]; -uint8_t g_attrOverrideFapiTank = 0; -#endif - -//****************************************************************************** -// Apply a HWPF Attribute Override written directly into Hostboot memory from -// the Simics/VBU console. This function is called by a Simics/VBU debug tool -//****************************************************************************** -void directOverride() -{ -#ifndef __HOSTBOOT_RUNTIME - // Apply the attribute override - if (g_attrOverrideFapiTank) - { - FAPI_IMP("directOverride: Applying override to FAPI tank " - "Id: 0x%08x, TargType: 0x%08x, Pos: 0x%04x, UPos: 0x%02x", - g_attrOverrideHeader.iv_attrId, g_attrOverrideHeader.iv_targetType, - g_attrOverrideHeader.iv_pos, g_attrOverrideHeader.iv_unitPos); - FAPI_IMP("directOverride: Applying override to FAPI tank " - "Node: 0x%02x, Flags: 0x%02x, Size: 0x%08x", - g_attrOverrideHeader.iv_node, g_attrOverrideHeader.iv_flags, - g_attrOverrideHeader.iv_valSize); - - theAttrOverrideSync().iv_overrideTank.setAttribute( - g_attrOverrideHeader.iv_attrId, - g_attrOverrideHeader.iv_targetType, - g_attrOverrideHeader.iv_pos, - g_attrOverrideHeader.iv_unitPos, - g_attrOverrideHeader.iv_node, - g_attrOverrideHeader.iv_flags, - g_attrOverrideHeader.iv_valSize, - &g_attrOverride); - } - else - { - // Convert the FAPI targeting type to TARGETING - TARGETING::TYPE l_targetType = TARGETING::TYPE_SYS; - - switch (g_attrOverrideHeader.iv_targetType) - { - case fapi::TARGET_TYPE_DIMM: - l_targetType = TARGETING::TYPE_DIMM; - break; - case fapi::TARGET_TYPE_PROC_CHIP: - l_targetType = TARGETING::TYPE_PROC; - break; - case fapi::TARGET_TYPE_MEMBUF_CHIP: - l_targetType = TARGETING::TYPE_MEMBUF; - break; - case fapi::TARGET_TYPE_EX_CHIPLET: - l_targetType = TARGETING::TYPE_EX; - break; - case fapi::TARGET_TYPE_MBA_CHIPLET: - l_targetType = TARGETING::TYPE_MBA; - break; - case fapi::TARGET_TYPE_MCS_CHIPLET: - l_targetType = TARGETING::TYPE_MCS; - break; - case fapi::TARGET_TYPE_XBUS_ENDPOINT: - l_targetType = TARGETING::TYPE_XBUS; - break; - case fapi::TARGET_TYPE_ABUS_ENDPOINT: - l_targetType = TARGETING::TYPE_ABUS; - break; - case fapi::TARGET_TYPE_L4: - l_targetType = TARGETING::TYPE_L4; - break; - } - - FAPI_IMP("directOverride: Applying override to TARG tank " - "Id: 0x%08x, TargType: 0x%08x, Pos: 0x%04x, UPos: 0x%02x", - g_attrOverrideHeader.iv_attrId, l_targetType, - g_attrOverrideHeader.iv_pos, g_attrOverrideHeader.iv_unitPos); - FAPI_IMP("directOverride: Applying override to TARG tank " - "Node: 0x%02x, Flags: 0x%02x, Size: 0x%08x", - g_attrOverrideHeader.iv_node, g_attrOverrideHeader.iv_flags, - g_attrOverrideHeader.iv_valSize); - - TARGETING::Target::theTargOverrideAttrTank().setAttribute( - g_attrOverrideHeader.iv_attrId, - l_targetType, - g_attrOverrideHeader.iv_pos, - g_attrOverrideHeader.iv_unitPos, - g_attrOverrideHeader.iv_node, - g_attrOverrideHeader.iv_flags, - g_attrOverrideHeader.iv_valSize, - &g_attrOverride); - } -#endif -} - -//****************************************************************************** -AttrOverrideSync & theAttrOverrideSync() -{ - return Singleton<AttrOverrideSync>::instance(); -} - -//****************************************************************************** -AttrOverrideSync::AttrOverrideSync() {} - -//****************************************************************************** -AttrOverrideSync::~AttrOverrideSync() {} - -//****************************************************************************** -void AttrOverrideSync::monitorForFspMessages() -{ -#ifndef __HOSTBOOT_RUNTIME - FAPI_IMP("monitorForFspMessages starting"); - - // Register a message queue with the mailbox - msg_q_t l_pMsgQ = msg_q_create(); - errlHndl_t l_pErr = MBOX::msgq_register(MBOX::HB_HWPF_ATTR_MSGQ, l_pMsgQ); - - if (l_pErr) - { - // In the unlikely event that registering fails, the code will commit an - // error and then wait forever for a message to appear on the queue - FAPI_ERR("monitorForFspMessages: Error registering msgq with mailbox"); - errlCommit(l_pErr, HWPF_COMP_ID); - } - - while (1) - { - msg_t * l_pMsg = msg_wait(l_pMsgQ); - - if (l_pMsg->type == MSG_SET_OVERRIDES) - { - // FSP is setting attribute override(s). - uint64_t l_tank = l_pMsg->data[0]; - TARGETING::AttributeTank::AttributeSerializedChunk l_chunk; - l_chunk.iv_size = l_pMsg->data[1]; - l_chunk.iv_pAttributes = static_cast<uint8_t *>(l_pMsg->extra_data); - - if (l_chunk.iv_pAttributes == NULL) - { - FAPI_ERR("monitorForFspMessages: tank %d, size %d, NULL data pointer", - l_tank, l_chunk.iv_size); - /*@ - * @errortype - * @moduleid fapi::MOD_ATTR_OVERRIDE - * @reasoncode fapi::RC_NULL_POINTER - * @userdata1 Attribute Tank (FAPI/TARG) - * @userdata2 Size of attribute overrides - * @devdesc Override message received from HWSV - * contains NULL data pointer - */ - const bool hbSwError = false; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_ATTR_OVERRIDE, - fapi::RC_NULL_POINTER, - l_tank, l_chunk.iv_size, hbSwError); - l_pError->addProcedureCallout(HWAS::EPUB_PRC_SP_CODE, - HWAS::SRCI_PRIORITY_HIGH); - errlCommit(l_pError, HWPF_COMP_ID); - } - else if (l_tank == TARGETING::AttributeTank::TANK_LAYER_FAPI) - { - FAPI_INF( - "monitorForFspMessages: MSG_SET_OVERRIDES FAPI (size %lld)", - l_pMsg->data[1]); - iv_overrideTank.deserializeAttributes(l_chunk); - } - else - { - FAPI_INF( - "monitorForFspMessages: MSG_SET_OVERRIDES TARG (size %lld)", - l_pMsg->data[1]); - TARGETING::Target::theTargOverrideAttrTank(). - deserializeAttributes(l_chunk); - } - - // Free the memory - free(l_pMsg->extra_data); - l_pMsg->extra_data = NULL; - l_pMsg->data[0] = 0; - l_pMsg->data[1] = 0; - - if (msg_is_async(l_pMsg)) - { - msg_free(l_pMsg); - } - else - { - // Send the message back as a response - msg_respond(l_pMsgQ, l_pMsg); - } - } - else if (l_pMsg->type == MSG_CLEAR_ALL_OVERRIDES) - { - // FSP is clearing all attribute overrides. - FAPI_INF("monitorForFspMessages: MSG_CLEAR_ALL_OVERRIDES"); - iv_overrideTank.clearAllAttributes(); - TARGETING::Target::theTargOverrideAttrTank().clearAllAttributes(); - - if (msg_is_async(l_pMsg)) - { - msg_free(l_pMsg); - } - else - { - // Send the message back as a response - msg_respond(l_pMsgQ, l_pMsg); - } - } - else - { - FAPI_ERR("monitorForFspMessages: Unrecognized message 0x%x", - l_pMsg->type); - free(l_pMsg->extra_data); - l_pMsg->extra_data = NULL; - msg_free(l_pMsg); - } - } -#endif -} - -//****************************************************************************** -errlHndl_t AttrOverrideSync::sendAttrsToFsp( - const MAILBOX_MSG_TYPE i_msgType, - const TARGETING::AttributeTank::TankLayer i_tankLayer, - std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> & - io_attributes) -{ - errlHndl_t l_pErr = NULL; - -#ifndef __HOSTBOOT_RUNTIME - std::vector<TARGETING::AttributeTank::AttributeSerializedChunk>::iterator - l_itr; - - // Send Attributes through the mailbox chunk by chunk. - for (l_itr = io_attributes.begin(); l_itr != io_attributes.end(); ++l_itr) - { - msg_t * l_pMsg = msg_allocate(); - l_pMsg->type = i_msgType; - l_pMsg->data[0] = i_tankLayer; - l_pMsg->data[1] = (*l_itr).iv_size; - l_pMsg->extra_data = (*l_itr).iv_pAttributes; - - // Send the message and wait for a response, the response message is not - // read, it just ensures that the code waits until the FSP is done - // Note: A possible performance boost could be to send only the last - // message synchronously to avoid the small delay between each - // message - l_pErr = MBOX::sendrecv(MBOX::FSP_HWPF_ATTR_MSGQ, l_pMsg); - - if (l_pErr) - { - FAPI_ERR("sendAttrsToFsp: Error sending to FSP"); - msg_free(l_pMsg); - l_pMsg = NULL; - break; - } - - // Mailbox freed the chunk data - (*l_itr).iv_pAttributes = NULL; - msg_free(l_pMsg); - l_pMsg = NULL; - } - - // Free any memory (only in error case will there be memory to free) and - // clear the vector of Attribute Chunks - for (l_itr = io_attributes.begin(); l_itr != io_attributes.end(); ++l_itr) - { - free((*l_itr).iv_pAttributes); - (*l_itr).iv_pAttributes = NULL; - } - io_attributes.clear(); -#endif - - return l_pErr; -} - -//****************************************************************************** -void AttrOverrideSync::sendAttrOverridesAndSyncsToFsp() -{ -#ifndef __HOSTBOOT_RUNTIME - const uint32_t MAILBOX_CHUNK_SIZE = 4096; - - if (MBOX::mailbox_enabled()) - { - errlHndl_t l_pErr = NULL; - - // Non-const overrides may have been cleared by being written to. - // Therefore, clear the FSP Attribute Overrides for this node and - // send the current set of overrides to the FSP for this node - - // Clear all current FSP Attribute Overrides for this node - msg_t * l_pMsg = msg_allocate(); - l_pMsg->type = MSG_CLEAR_ALL_OVERRIDES; - l_pMsg->data[0] = 0; - l_pMsg->data[1] = 0; - l_pMsg->extra_data = NULL; - - // Send the message - l_pErr = MBOX::send(MBOX::FSP_HWPF_ATTR_MSGQ, l_pMsg); - - if (l_pErr) - { - FAPI_ERR( - "sendAttrOverridesAndSyncsToFsp: Error clearing overrides"); - errlCommit(l_pErr, HWPF_COMP_ID); - msg_free(l_pMsg); - l_pMsg = NULL; - } - else - { - l_pMsg = NULL; - - // Send Hostboot Attribute Overrides to the FSP - for (uint32_t i = TARGETING::AttributeTank::TANK_LAYER_FAPI; - i <= TARGETING::AttributeTank::TANK_LAYER_TARG; i++) - { - std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> - l_attributes; - - // Note that NODE_FILTER_NOT_ALL_NODES retrieves all overrides - // that are not for all nodes - i.e. overrides for this node. - // The FSP already has all overrides for all nodes. - if (i == TARGETING::AttributeTank::TANK_LAYER_FAPI) - { - iv_overrideTank.serializeAttributes( - TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, - MAILBOX_CHUNK_SIZE, l_attributes, - TARGETING::AttributeTank::NODE_FILTER_NOT_ALL_NODES); - } - else - { - TARGETING::Target::theTargOverrideAttrTank(). - serializeAttributes( - TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, - MAILBOX_CHUNK_SIZE, l_attributes, - TARGETING::AttributeTank:: - NODE_FILTER_NOT_ALL_NODES); - } - - if (l_attributes.size()) - { - l_pErr = sendAttrsToFsp(MSG_SET_OVERRIDES, - static_cast<TARGETING::AttributeTank::TankLayer>(i), - l_attributes); - - if (l_pErr) - { - FAPI_ERR( - "sendAttrOverridesAndSyncsToFsp: Error sending overrides (%d)", - i); - errlCommit(l_pErr, HWPF_COMP_ID); - break; - } - } - } - - // Send Hostboot Attributes to Sync to the FSP - for (uint32_t i = TARGETING::AttributeTank::TANK_LAYER_FAPI; - i <= TARGETING::AttributeTank::TANK_LAYER_TARG; i++) - { - std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> - l_attributes; - - if (i == TARGETING::AttributeTank::TANK_LAYER_FAPI) - { - iv_syncTank.serializeAttributes( - TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, - MAILBOX_CHUNK_SIZE, l_attributes); - } - else - { - TARGETING::Target::theTargSyncAttrTank(). - serializeAttributes( - TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, - MAILBOX_CHUNK_SIZE, l_attributes); - } - - if (l_attributes.size()) - { - l_pErr = sendAttrsToFsp(MSG_SET_SYNC_ATTS, - static_cast<TARGETING::AttributeTank::TankLayer>(i), - l_attributes); - - if (l_pErr) - { - FAPI_ERR( - "sendAttrOverridesAndSyncsToFsp: Error sending syncs (%d)", - i); - errlCommit(l_pErr, HWPF_COMP_ID); - break; - } - else - { - // Clear Sync tank - if (i == TARGETING::AttributeTank::TANK_LAYER_FAPI) - { - iv_syncTank.clearAllAttributes(); - } - else - { - TARGETING::Target::theTargSyncAttrTank(). - clearAllAttributes(); - } - } - } - } - } - } -#endif -} - -//****************************************************************************** -void AttrOverrideSync::getAttrOverridesFromFsp() -{ -#ifndef __HOSTBOOT_RUNTIME - FAPI_IMP("Requesting Attribute Overrides from the FSP"); - - errlHndl_t l_pErr = NULL; - - msg_t * l_pMsg = msg_allocate(); - l_pMsg->type = MSG_GET_OVERRIDES; - l_pMsg->data[0] = 0; - l_pMsg->data[1] = 0; - l_pMsg->extra_data = NULL; - - // Send the message and wait for a response, the response message is not - // read, it just ensures that the code waits until the FSP is done sending - // attribute overrides - l_pErr = MBOX::sendrecv(MBOX::FSP_HWPF_ATTR_MSGQ, l_pMsg); - - if (l_pErr) - { - FAPI_ERR("getAttrOverridesFromFsp: Error sending to FSP"); - errlCommit(l_pErr, HWPF_COMP_ID); - } - - msg_free(l_pMsg); - l_pMsg = NULL; -#endif -} - -//****************************************************************************** -bool AttrOverrideSync::getAttrOverride(const fapi::AttributeId i_attrId, - const fapi::Target * const i_pTarget, - void * o_pVal) const -{ - // Very fast check to see if there are any overrides at all - if (!(iv_overrideTank.attributesExist())) - { - return false; - } - - // Check to see if there are any overrides for this attr ID - if (!(iv_overrideTank.attributeExists(i_attrId))) - { - return false; - } - - // Do the work of figuring out the target's type/position/node and find out - // if there is an override for this target - uint32_t l_targetType = getTargetType(i_pTarget); - - // Get the Target pointer - TARGETING::Target * l_pTarget = - reinterpret_cast<TARGETING::Target*>(i_pTarget->get()); - uint16_t l_pos = 0; - uint8_t l_unitPos = 0; - uint8_t l_node = 0; - l_pTarget->getAttrTankTargetPosData(l_pos, l_unitPos, l_node); - - FAPI_INF("getAttrOverride: Checking for override for ID: 0x%08x, " - "TargType: 0x%08x, Pos/Upos/Node: 0x%08x", - i_attrId, l_targetType, - (static_cast<uint32_t>(l_pos) << 16) + - (static_cast<uint32_t>(l_unitPos) << 8) + l_node); - - bool l_override = iv_overrideTank.getAttribute(i_attrId, l_targetType, - l_pos, l_unitPos, l_node, o_pVal); - - if (l_override) - { - FAPI_INF("getAttrOverride: Returning Override for ID: 0x%08x", - i_attrId); - } - - return l_override; -} - -//****************************************************************************** -bool AttrOverrideSync::getAttrOverrideFunc(const fapi::AttributeId i_attrId, - const fapi::Target * const i_pTarget, - void * o_pVal) -{ - return Singleton<AttrOverrideSync>::instance().getAttrOverride(i_attrId, - i_pTarget, o_pVal); -} - - -//****************************************************************************** -void AttrOverrideSync::setAttrActions(const fapi::AttributeId i_attrId, - const fapi::Target * const i_pTarget, - const uint32_t i_size, - const void * i_pVal) -{ - // Figure out if effort should be expended figuring out the target's type/ - // position in order to clear any non-const attribute overrides and/or to - // store the attribute for syncing to Cronus - - bool l_clearAnyNonConstOverride = false; - - // Very fast check to see if there are any overrides at all for this Attr ID - if (iv_overrideTank.attributesExist()) - { - // Fast check to see if there are any overrides for this attr ID - if (iv_overrideTank.attributeExists(i_attrId)) - { - l_clearAnyNonConstOverride = true; - } - } - - bool l_syncAttribute = TARGETING::AttributeTank::syncEnabled(); - - if (l_clearAnyNonConstOverride || l_syncAttribute) - { - uint32_t l_targetType = getTargetType(i_pTarget); - - // Get the Target pointer - TARGETING::Target * l_pTarget = - reinterpret_cast<TARGETING::Target*>(i_pTarget->get()); - uint16_t l_pos = 0; - uint8_t l_unitPos = 0; - uint8_t l_node = 0; - l_pTarget->getAttrTankTargetPosData(l_pos, l_unitPos, l_node); - - if (l_clearAnyNonConstOverride) - { - // Clear any non const override for this attribute because the - // attribute is being written - iv_overrideTank.clearNonConstAttribute(i_attrId, l_targetType, - l_pos, l_unitPos, l_node); - } - - if (l_syncAttribute) - { - // Write the attribute to the SyncAttributeTank to sync to Cronus - iv_syncTank.setAttribute(i_attrId, l_targetType, l_pos, l_unitPos, - l_node, 0, i_size, i_pVal); - } - } -} - -//****************************************************************************** -void AttrOverrideSync::setAttrActionsFunc(const fapi::AttributeId i_attrId, - const fapi::Target * const i_pTarget, - const uint32_t i_size, - const void * i_pVal) -{ - Singleton<AttrOverrideSync>::instance().setAttrActions(i_attrId, i_pTarget, - i_size, i_pVal); -} - - -//****************************************************************************** -uint32_t AttrOverrideSync::getTargetType(const fapi::Target * const i_pTarget) -{ - uint32_t l_targetType = fapi::TARGET_TYPE_SYSTEM; - - if (i_pTarget != NULL) - { - l_targetType = i_pTarget->getType(); - } - - return l_targetType; -} - -} // End fapi namespace diff --git a/src/usr/hwpf/plat/fapiPlatAttributeService.C b/src/usr/hwpf/plat/fapiPlatAttributeService.C deleted file mode 100644 index 1d693e896..000000000 --- a/src/usr/hwpf/plat/fapiPlatAttributeService.C +++ /dev/null @@ -1,2142 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatAttributeService.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ -/* [+] 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 fapiPlatAttributeService.C - * - * @brief Implements the functions that access attributes - * - */ - -//****************************************************************************** -// Includes -//****************************************************************************** - -#include <hwpf/fapi/fapiTarget.H> -#include <hwpf/fapi/fapiHwpExecutor.H> -#include <targeting/common/targetservice.H> -#include <targeting/common/predicates/predicatectm.H> -#include <targeting/common/utilFilter.H> -#include <errl/errlentry.H> -#include <hwpf/plat/fapiPlatAttributeService.H> -#include <isteps/hwpf_reasoncodes.H> -#include <vpd/spdenums.H> -#include <devicefw/driverif.H> -#include <hwpf/hwp/mvpd_accessors/getMvpdExL2SingleMemberEnable.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdSlopeInterceptData.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdSpareDramData.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdVersion.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdSPDXRecordVersion.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdVoltageSettingData.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdDram2NModeEnabled.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdSensorMap.H> -#include <hwpf/hwp/mvpd_accessors/getMBvpdAttr.H> -#include <hwpf/hwp/mvpd_accessors/accessMBvpdL4BankDelete.H> -#include <hwpf/hwp/chip_accessors/getTdpRdpCurrentFactor.H> -#include <hwpf/hwp/chip_accessors/getPciOscswitchConfig.H> -#include <hwpf/hwp/chip_accessors/getOscswitchCtlAttr.H> -#include <fapiPllRingAttr.H> -#include <hwpf/hwp/pll_accessors/getPllRingAttr.H> -#include <hwpf/hwp/pll_accessors/getPllRingInfoAttr.H> -#include <hwpf/hwp/winkle_ring_accessors/getL3DeltaDataAttr.H> -#include <hwpf/hwp/tp_dbg_data_accessors/getTpDbgDataAttr.H> -#include <fapiAttributeIds.H> -#include <hwas/common/hwasCommon.H> -#include <proc_setup_bars_defs.H> - -// The following file checks at compile time that all HWPF attributes are -// handled by Hostboot. This is done to ensure that the HTML file listing -// supported HWPF attributes lists attributes handled by Hostboot -#include <fapiAttributePlatCheck.H> - - -//****************************************************************************** -// Implementation -//****************************************************************************** - -namespace fapi -{ - -namespace platAttrSvc -{ - -//****************************************************************************** -// fapi::platAttrSvc::getTargetingTarget -//****************************************************************************** -fapi::ReturnCode getTargetingTarget( - const fapi::Target* i_pFapiTarget, - TARGETING::Target* & o_pTarget, - const TARGETING::TYPE i_expectedType = TARGETING::TYPE_NA) -{ - fapi::ReturnCode l_rc; - - if (i_pFapiTarget == NULL) - { - TARGETING::targetService().getTopLevelTarget(o_pTarget); - } - else - { - o_pTarget = reinterpret_cast<TARGETING::Target*>(i_pFapiTarget->get()); - } - - if (o_pTarget == NULL) - { - // FAPI Target contained a NULL Targ handle or no top level target! - FAPI_ERR("getTargetingTarget. NULL Targ Target"); - - /*@ - * @errortype - * @moduleid MOD_ATTR_GET_TARGETING_TARGET - * @reasoncode RC_EMBEDDED_NULL_TARGET_PTR - * @devdesc NULL TARG Target passed to attribute access macro - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_ATTR_GET_TARGETING_TARGET, - RC_EMBEDDED_NULL_TARGET_PTR, - 0, 0, hbSwError); - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else if (i_expectedType != TARGETING::TYPE_NA) - { - TARGETING::TYPE l_type = o_pTarget->getAttr<TARGETING::ATTR_TYPE>(); - - if (l_type != i_expectedType) - { - FAPI_ERR("getTargetingTarget. Type: %d, expected %d", l_type, - i_expectedType); - - /*@ - * @errortype - * @moduleid MOD_ATTR_GET_TARGETING_TARGET - * @reasoncode RC_UNEXPECTED_TARGET_TYPE - * @userdata1 Target Type - * @userdata2 Expected Target Type - * @devdesc Unexpected Target Type passed to attribute access - * macro - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_ATTR_GET_TARGETING_TARGET, - RC_UNEXPECTED_TARGET_TYPE, - l_type, i_expectedType, hbSwError); - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - } - - return l_rc; -} - -//****************************************************************************** -// fapi::platAttrSvc::getTargetingAttr -//****************************************************************************** -fapi::ReturnCode getTargetingAttr(const fapi::Target * i_pFapiTarget, - const TARGETING::ATTRIBUTE_ID i_targAttrId, - const uint32_t i_attrSize, - void * o_pAttr) -{ - TARGETING::Target * l_pTargTarget = NULL; - - fapi::ReturnCode l_rc = getTargetingTarget(i_pFapiTarget, l_pTargTarget); - - if (l_rc) - { - FAPI_ERR("getTargetingAttr: Error from getTargetingTarget"); - } - else - { - // Note directly calling Target's private _tryGetAttr function for code - // size optimization, the public function is a template function that - // cannot be called with a variable attribute ID, the template function - // checks at compile time that the Targeting attribute is readable, but - // that is already checked by the Targeting compiler - bool l_success = l_pTargTarget->_tryGetAttr(i_targAttrId, i_attrSize, - o_pAttr); - - if (!l_success) - { - FAPI_ERR("getTargetingAttr: Error from _tryGetAttr"); - /*@ - * @errortype - * @moduleid MOD_PLAT_ATTR_SVC_GET_TARG_ATTR - * @reasoncode RC_FAILED_TO_ACCESS_ATTRIBUTE - * @userdata1 Platform attribute ID - * @userdata2 FAPI target type, or NULL if system target - * @devdesc Failed to get requested attribute. - * Possible causes: Invalid target, attribute not implemented, - * attribute not present on given target, target service - * not initialized - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_PLAT_ATTR_SVC_GET_TARG_ATTR, - RC_FAILED_TO_ACCESS_ATTRIBUTE, - i_targAttrId, - i_pFapiTarget ? i_pFapiTarget->getType(): NULL, - hbSwError); - l_rc.setPlatError(reinterpret_cast<void *>(l_pError)); - } - } - - return l_rc; -} - -//****************************************************************************** -// fapi::platAttrSvc::setTargetingAttr -//****************************************************************************** -fapi::ReturnCode setTargetingAttr(const fapi::Target * i_pFapiTarget, - const TARGETING::ATTRIBUTE_ID i_targAttrId, - const uint32_t i_attrSize, - void * i_pAttr) -{ - TARGETING::Target * l_pTargTarget = NULL; - - fapi::ReturnCode l_rc = getTargetingTarget(i_pFapiTarget, l_pTargTarget); - - if (l_rc) - { - FAPI_ERR("setTargetingAttr: Error from getTargetingTarget"); - } - else - { - // Note directly calling Target's private _trySetAttr function for code - // size optimization, the public function is a template function that - // cannot be called with a variable attribute ID, the template function - // checks at compile time that the Targeting attribute is writeable, but - // that is already checked by the Targeting compiler - bool l_success = l_pTargTarget->_trySetAttr(i_targAttrId, i_attrSize, - i_pAttr); - - if (!l_success) - { - FAPI_ERR("setTargetingAttr: Error from _trySetAttr"); - /*@ - * @errortype - * @moduleid MOD_PLAT_ATTR_SVC_SET_TARG_ATTR - * @reasoncode RC_FAILED_TO_ACCESS_ATTRIBUTE - * @userdata1 Platform attribute ID - * @userdata2 FAPI target type, or NULL if system target - * @devdesc Failed to Set requested attribute. - * Possible causes: Invalid target, attribute not implemented, - * attribute not present on given target, target service - * not initialized - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_PLAT_ATTR_SVC_SET_TARG_ATTR, - RC_FAILED_TO_ACCESS_ATTRIBUTE, - i_targAttrId, - i_pFapiTarget ? i_pFapiTarget->getType(): NULL, - hbSwError); - l_rc.setPlatError(reinterpret_cast<void *>(l_pError)); - } - } - - return l_rc; -} - -//****************************************************************************** -// fapiPlatGetSpdAttr function. -// Call SPD device driver to retrieve the SPD attribute -//****************************************************************************** -fapi::ReturnCode fapiPlatGetSpdAttr(const fapi::Target * i_pFapiTarget, - const uint16_t i_keyword, - void * o_data, const size_t i_len) -{ - FAPI_DBG(ENTER_MRK "fapiPlatGetSpdAttr"); - - fapi::ReturnCode l_rc; - TARGETING::Target* l_pTarget = NULL; - - l_rc = getTargetingTarget(i_pFapiTarget, l_pTarget, TARGETING::TYPE_DIMM); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetSpdAttr: Error from getTargetingTarget"); - } - else - { - errlHndl_t l_err = NULL; - size_t l_len = i_len; - l_err = deviceRead(l_pTarget, o_data, l_len, - DEVICE_SPD_ADDRESS(i_keyword)); - - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - FAPI_ERR("fapiPlatGetSpdAttr: Error from deviceRead, keyword 0x%04x, len %d", - i_keyword, i_len); - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - else - { - if ((i_len == sizeof(uint32_t)) && (l_len == sizeof(uint16_t))) - { - // This is a uint16_t attribute written to a uint32_t type. - // This is because FAPI attributes can only be uint8/32/64 - // Shift the data to be right aligned - *(static_cast<uint32_t *>(o_data)) >>= 16; - } - else if ((i_len == sizeof(uint32_t)) && (l_len == sizeof(uint8_t))) - { - // This is a uint8_t attribute written to a uint32_t type. - // Shift the data to the lower byte - *(static_cast<uint32_t *>(o_data)) >>= 24; - } - } - } - - FAPI_DBG(EXIT_MRK "fapiPlatGetSpdAttr"); - return l_rc; -} - -//****************************************************************************** -// fapiPlatGetModuleType function. -//****************************************************************************** -fapi::ReturnCode fapiPlatGetModuleType(const fapi::Target * i_pFapiTarget, - uint8_t & o_name) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pHbTarget = NULL; - o_name = ENUM_ATTR_NAME_NONE; - - l_rc = getTargetingTarget(i_pFapiTarget, l_pHbTarget , - TARGETING::TYPE_DIMM); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetTargetName: Error from getTargetingTarget"); - } - else - { - errlHndl_t l_err = NULL; - size_t l_len = sizeof(uint8_t); - uint8_t l_memType = 0; - l_err = deviceRead(l_pHbTarget , &l_memType, l_len, - DEVICE_SPD_ADDRESS(SPD::BASIC_MEMORY_TYPE)); - - - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - FAPI_ERR("fapiPlatGetModuleType: Error from deviceRead") - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - else - { - l_err = deviceRead(l_pHbTarget , &o_name, l_len, - DEVICE_SPD_ADDRESS(SPD::MODULE_TYPE)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - FAPI_ERR("fapiPlatGetModuleType: Error from deviceRead") - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - else - { - - if(((l_memType == fapi::ENUM_ATTR_SPD_DRAM_DEVICE_TYPE_DDR4) && - (o_name == SPD::JEDEC_VER4_LRDIMM_VAL))|| - ((l_memType == fapi::ENUM_ATTR_SPD_DRAM_DEVICE_TYPE_DDR3)&& - (o_name == SPD::JEDEC_VER3_LRDIMM_VAL))) - { - o_name = fapi::ENUM_ATTR_SPD_MODULE_TYPE_LRDIMM; - - } - } - } - } - - return l_rc; -} - - - - - -//****************************************************************************** -// fapiPlatSetSpdAttr function. -// Call SPD device driver to set the SPD attribute -//****************************************************************************** -fapi::ReturnCode fapiPlatSetSpdAttr(const fapi::Target * i_pFapiTarget, - const uint16_t i_keyword, - void * i_data, const size_t i_len) -{ - FAPI_DBG(ENTER_MRK "fapiPlatSetSpdAttr"); - - fapi::ReturnCode l_rc; - TARGETING::Target* l_pTarget = NULL; - - l_rc = getTargetingTarget(i_pFapiTarget, l_pTarget, TARGETING::TYPE_DIMM); - - if (l_rc) - { - FAPI_ERR("fapiPlatSetSpdAttr: Error from getTargetingTarget"); - } - else - { - errlHndl_t l_err = NULL; - size_t l_len = i_len; - l_err = deviceWrite(l_pTarget, i_data, l_len, - DEVICE_SPD_ADDRESS(i_keyword)); - - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - FAPI_ERR("fapiPlatSetSpdAttr: Error from deviceWrite, keyword 0x%04x, len %d", - i_keyword, i_len); - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - } - - FAPI_DBG(EXIT_MRK "fapiPlatSetSpdAttr"); - return l_rc; -} - -//****************************************************************************** -// fapiPlatGetDqMapping function. -//****************************************************************************** -fapi::ReturnCode fapiPlatGetDqMapping(const fapi::Target * i_pDimmFapiTarget, - uint8_t (&o_data)[DIMM_DQ_NUM_DQS]) -{ - fapi::ReturnCode l_rc; - - do - { - TARGETING::Target * l_pDimmTarget = NULL; - - l_rc = getTargetingTarget(i_pDimmFapiTarget, l_pDimmTarget, - TARGETING::TYPE_DIMM); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetDqMapping: Error from getTargetingTarget"); - break; - } - - if (l_pDimmTarget->getAttr<TARGETING::ATTR_MODEL>() == - TARGETING::MODEL_CDIMM) - { - // C-DIMM. There is no DQ mapping from Centaur DQ to DIMM Connector - // DQ because there is no DIMM Connector. Return a direct 1:1 map - // (0->0, 1->1, etc) - for (uint8_t i = 0; i < DIMM_DQ_NUM_DQS; i++) - { - o_data[i] = i; - } - } - else - { - // ISDIMM. Work back up from Dimm target to MBA to Mem Buf and - // gather dimm position to select ATTR_VPD_ISDIMMTOC4DQ data - - // Get DIMM's Port position off the MBA - uint8_t l_port=l_pDimmTarget->getAttr<TARGETING::ATTR_MBA_PORT>(); - - // Find MBA from DIMM - TARGETING::TargetHandleList l_mbaList; - getParentAffinityTargets (l_mbaList,l_pDimmTarget, - TARGETING::CLASS_UNIT, - TARGETING::TYPE_MBA, false); - - if (l_mbaList.size () != 1 ) - { - FAPI_ERR("fapiPlatGetDqMapping: expect 1 mba %d ", - l_mbaList.size()); - - /*@ - * @errortype - * @moduleid fapi::MOD_PLAT_ATTR_SVC_CEN_DQ_TO_DIMM_CONN_DQ - * @reasoncode fapi::RC_NO_SINGLE_MBA - * @userdata1 Number of MBAs - * @userdata2 DIMM HUID - * @devdesc fapiPlatGetVpdVersion could not find the - * expected 1 mba from the passed dimm target - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_PLAT_ATTR_SVC_CEN_DQ_TO_DIMM_CONN_DQ, - fapi::RC_NO_SINGLE_MBA, - l_mbaList.size(), - TARGETING::get_huid(l_pDimmTarget), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - break; - } - fapi::Target l_fapiMbaTarget(TARGET_TYPE_MBA_CHIPLET, - static_cast<void *>(l_mbaList[0])); - - // Get MBA position off the Mem Buf - uint8_t l_mbaPos = l_mbaList[0]-> - getAttr<TARGETING::ATTR_CHIP_UNIT>(); - - // find mem buff - fapi::Target l_fapiMbTarget; - l_rc = fapiGetParentChip(l_fapiMbaTarget, l_fapiMbTarget); - if (l_rc) - { - FAPI_ERR("fapiPlatGetDqMapping: Error getting MBA's parent "); - break; - } - - // Read wiring data - uint8_t l_wiringData[DIMM_TO_C4_PORTS][DIMM_TO_C4_DQ_ENTRIES]; - l_rc = FAPI_ATTR_GET(ATTR_VPD_ISDIMMTOC4DQ, - &l_fapiMbTarget,l_wiringData); - if (l_rc) - { - FAPI_ERR("fapiPlatGetDqMapping:" - " Error getting VPD_ISDIMMTOC4DQ data"); - break; - } - - // Map data - uint8_t l_index = l_mbaPos*2+l_port; - for (uint8_t i = 0; i < DIMM_DQ_NUM_DQS; i++) - { - o_data[i] = l_wiringData[l_index][i]; - } - } - } while (0); - - return l_rc; -} - -//****************************************************************************** -// fapiPlatGetTargetName function -//****************************************************************************** -fapi::ReturnCode fapiPlatGetTargetName(const fapi::Target * i_pFapiTarget, - uint8_t & o_name) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pHbTarget = NULL; - o_name = ENUM_ATTR_NAME_NONE; - - l_rc = getTargetingTarget(i_pFapiTarget, l_pHbTarget); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetTargetName: Error from getTargetingTarget"); - } - else - { - TARGETING::MODEL l_model = - l_pHbTarget->getAttr<TARGETING::ATTR_MODEL>(); - - if (l_model == TARGETING::MODEL_VENICE) - { - o_name = ENUM_ATTR_NAME_VENICE; - } - else if (l_model == TARGETING::MODEL_MURANO) - { - o_name = ENUM_ATTR_NAME_MURANO; - } - else if (l_model == TARGETING::MODEL_NAPLES) - { - o_name = ENUM_ATTR_NAME_NAPLES; - } - else if (l_model == TARGETING::MODEL_CENTAUR) - { - o_name = ENUM_ATTR_NAME_CENTAUR; - } - else - { - FAPI_ERR("fapiPlatGetTargetName. Unknown name 0x%x", l_model); - - /*@ - * @errortype - * @moduleid MOD_ATTR_GET_TARGET_NAME - * @reasoncode RC_ATTR_BAD_TARGET_PARAM - * @devdesc Failed to get the FAPI Target name due to - * unrecognized TARGETING Target model - * @userdata1 TARGETING Target model - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_ATTR_GET_TARGET_NAME, - RC_ATTR_BAD_TARGET_PARAM, - l_model, 0, hbSwError); - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - } - - return l_rc; -} - -//****************************************************************************** -// fapiPlatGetFunctional function -//****************************************************************************** -fapi::ReturnCode fapiPlatGetFunctional(const fapi::Target * i_pFapiTarget, - uint8_t & o_functional) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pHbTarget = NULL; - o_functional = 0; - - l_rc = getTargetingTarget(i_pFapiTarget, l_pHbTarget); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetFunctional: Error from getTargetingTarget"); - } - else - { - TARGETING::PredicateIsFunctional l_functional; - if (l_functional(l_pHbTarget)) - { - o_functional = 1; - } - } - - return l_rc; -} - -//****************************************************************************** -// fapi::platAttrSvc::fapiPlatGetTargetPos function -//****************************************************************************** -fapi::ReturnCode fapiPlatGetTargetPos(const fapi::Target * i_pFapiTarget, - uint32_t & o_pos) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pTarget = NULL; - - // Get the Targeting Target - l_rc = getTargetingTarget(i_pFapiTarget, l_pTarget); - - if (l_rc) - { - FAPI_ERR("getTargetName: Error from getTargetingTarget"); - } - else - { - uint16_t l_pos = l_pTarget->getAttr<TARGETING::ATTR_POSITION>(); - o_pos = l_pos; - } - - return l_rc; -} - -/** - * @enum - * Return values for ATTR_PROC_*_BAR_ENABLE -*/ -enum -{ - PROC_BARS_DISABLE = 0x0, - PROC_BARS_ENABLE = 0x1, -}; - -/** - * @brief Internal routine - * Do common checks and return an error if necessary for functions - * supporting proc/mss_setup_bars attributes - * Return useful parameters - * - * @param[in] - i_pFapiTarget incoming target - * @param[out] - o_procNum found processor number of i_pTarget - * @apram[out] - o_isEnabled ENABLE/DISABLE flag for BAR_ENABLE ATTRS - * @return - success or appropriate fapi returncode -*/ -fapi::ReturnCode barsPreCheck( const fapi::Target * i_pFapiTarget, - uint64_t &o_procNum, - uint8_t &o_isEnabled - ) -{ - fapi::ReturnCode l_rc; - TARGETING::Target* l_pTarget = NULL; - - l_rc = getTargetingTarget(i_pFapiTarget, l_pTarget); - - if (l_rc) - { - FAPI_ERR("barsPreCheck: Error from getTargetingTarget"); - } - else - { - // ATTR_POSITION should return the logical proc ID - o_procNum = - static_cast<uint64_t> - (l_pTarget->getAttr<TARGETING::ATTR_POSITION>() ); - - // if proc is functional then set the BAR_ENABLE ATTR to ENABLE - TARGETING::PredicateIsFunctional l_functional; - if (l_functional(l_pTarget)) - { - o_isEnabled = PROC_BARS_ENABLE; - } - else - { - o_isEnabled = PROC_BARS_DISABLE; - } - } - - return l_rc; -} - - -fapi::ReturnCode fapiPlatGetProcForeignNearBase ( - const fapi::Target * i_pTarget, - uint64_t (&o_foreignNearBase)[ 2 ] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - do - { - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcForeignNearBase: Error from barsPreCheck"); - break; - } - - // 2012-06-25 Per Dean return 0 here for now - o_foreignNearBase[0] = 0; - o_foreignNearBase[1] = 0; - - } while (0); - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcForeignNearSize ( - const fapi::Target * i_pTarget, - uint64_t (&o_foreignNearSize)[ 2 ] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - do - { - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcForeignNearSize: Error from barsPreCheck"); - break; - } - - // 2012-06-25 Per Dean return 0 here for now - o_foreignNearSize[0] = 0; - o_foreignNearSize[1] = 0; - - } while(0); - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcForeignFarBase ( - const fapi::Target * i_pTarget, - uint64_t (&o_foreignFarBase)[ 2 ] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - do - { - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcForeignFarBase: Error from barsPreCheck"); - break; - } - - // 2012-06-25 Per Dean return 0 here for now - o_foreignFarBase[0] = 0; - o_foreignFarBase[1] = 0; - - } while(0); - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcForeignFarSize ( - const fapi::Target * i_pTarget, - uint64_t (&o_foreignFarSize)[ 2 ] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - do - { - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcForeignFarSize: Error from barsPreCheck"); - break; - } - - // 2012-06-25 Per Dean return 0 here for now - o_foreignFarSize[0] = 0; - o_foreignFarSize[1] = 0; - - } while(0); - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcHaBase ( - const fapi::Target * i_pTarget, - uint64_t (&o_haBase)[ 8 ] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - do - { - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcHaBase: Error from barsPreCheck"); - break; - } - - // 2012-06-25 Per Dean return 0 here for now - o_haBase[0] = 0; - o_haBase[1] = 0; - o_haBase[2] = 0; - o_haBase[3] = 0; - o_haBase[4] = 0; - o_haBase[5] = 0; - o_haBase[6] = 0; - o_haBase[7] = 0; - - } while(0); - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcHaSize ( - const fapi::Target * i_pTarget, - uint64_t (&o_haSize)[ 8 ] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - do - { - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcHaSize: Error from barsPreCheck"); - break; - } - - // 2012-06-25 Per Dean return 0 here for now - o_haSize[0] = 0; - o_haSize[1] = 0; - o_haSize[2] = 0; - o_haSize[3] = 0; - o_haSize[4] = 0; - o_haSize[5] = 0; - o_haSize[6] = 0; - o_haSize[7] = 0; - - } while(0); - - return l_rc; -} - - -//------------------------------------------------------------------------------ -// Prototypes to support proc_setup_bars_mmio_attributes -// see proc_setup_bars_mmio_attributes for detailed descriptions -//------------------------------------------------------------------------------ - -fapi::ReturnCode fapiPlatGetProcPsiBridgeBarEnable ( - const fapi::Target * i_pTarget, - uint8_t &o_psiBridgeBarEnable ) -{ - fapi::ReturnCode l_rc; - o_psiBridgeBarEnable = PROC_BARS_DISABLE; - TARGETING::Target* l_pProcTarget = NULL; - - l_rc = getTargetingTarget(i_pTarget, l_pProcTarget); - - if (l_rc) - { - FAPI_ERR( - "fapiPlatGetProcPsiBridgeBarEnable: Error from getTargetingTarget"); - } - else - { - uint64_t bar = l_pProcTarget->getAttr<TARGETING::ATTR_PSI_BRIDGE_BASE_ADDR>(); - - // if bar is not zero - if ( bar ) - { - o_psiBridgeBarEnable = PROC_BARS_ENABLE; - } - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcFspBarEnable ( - const fapi::Target * i_pTarget, - uint8_t &o_fspBarEnable ) -{ - fapi::ReturnCode l_rc; - o_fspBarEnable = PROC_BARS_DISABLE; - TARGETING::Target* l_pProcTarget = NULL; - - l_rc = getTargetingTarget(i_pTarget, l_pProcTarget); - - if (l_rc) - { - FAPI_ERR( - "fapiPlatGetProcFspBarEnable: Error from getTargetingTarget"); - } - else - { - uint64_t bar = l_pProcTarget->getAttr<TARGETING::ATTR_FSP_BASE_ADDR>(); - - // if bar is not zero - if ( bar ) - { - o_fspBarEnable = PROC_BARS_ENABLE; - } - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcIntpBarEnable ( - const fapi::Target * i_pTarget, - uint8_t &o_intpBarEnable ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcIntpBarEnable: Error from barsPreCheck"); - } - else - { - o_intpBarEnable = l_isEnabled; - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcNxMmioBarEnable( - const fapi::Target * i_pTarget, - uint8_t &o_nxMmioBarEnable ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcNxMmioBarEnable: Error from barsPreCheck"); - } - else - { - o_nxMmioBarEnable = l_isEnabled; - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcNxMmioBarSize ( - const fapi::Target * i_pTarget, - uint64_t &o_nxMmioBarSize ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcNxMmioBarSize: Error from barsPreCheck"); - } - else - { - o_nxMmioBarSize = PROC_RNG_SIZE ; - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcPcieBarEnable ( - const fapi::Target * i_pTarget, - uint8_t (&o_pcieBarEnable) [4][3] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcPcieBarEnable: Error from barsPreCheck"); - } - else - { - // In PHYP mode, we need to leave the PCI BARs disabled - bool phyp_mode = false; - if( TARGETING::is_phyp_load() ) - { - phyp_mode = true; - } - - // BAR # 0 are the PCIE Mem 64 - // BAR # 1 are the PCIE Mem 32 - // BAR # 2 are the PHB REGS - for( uint8_t u=0; u< PROC_SETUP_BARS_PCIE_NUM_UNITS; u++ ) - { - if( phyp_mode ) - { - o_pcieBarEnable[u][0] = PROC_BARS_DISABLE ; - o_pcieBarEnable[u][1] = PROC_BARS_DISABLE ; - o_pcieBarEnable[u][2] = PROC_BARS_DISABLE ; - } - else - { - o_pcieBarEnable[u][0] = l_isEnabled ; - o_pcieBarEnable[u][1] = l_isEnabled ; - o_pcieBarEnable[u][2] = l_isEnabled ; - } - - FAPI_DBG( "fapiPlatGetProcPcieBarEnable: Unit %d : %p %p %p", - u, - o_pcieBarEnable[u][0], - o_pcieBarEnable[u][1], - o_pcieBarEnable[u][2] ); - } - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcPcieBarBaseAddr ( - const fapi::Target * i_pTarget, - uint64_t (&o_pcieBarBase) [4][3] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcPcieBarBaseAddr: Error from barsPreCheck"); - } - else - { - TARGETING::Target* l_pProcTarget = NULL; - - l_rc = getTargetingTarget(i_pTarget, l_pProcTarget); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetProcPcieBarBaseAddr: Error from getTargetingTarget"); - } - else - { - // Pull the data out of the Hostboot attribute - uint64_t l_pciMem32[4]; - uint64_t l_pciMem64[4]; - l_pProcTarget->tryGetAttr<TARGETING::ATTR_PCI_BASE_ADDRS_32>( - l_pciMem32); - l_pProcTarget->tryGetAttr<TARGETING::ATTR_PCI_BASE_ADDRS_64>( - l_pciMem64); - uint64_t l_phbRegs[4]; - l_pProcTarget->tryGetAttr<TARGETING::ATTR_PHB_BASE_ADDRS>( - l_phbRegs); - - // BAR # 0 are the PCIE mem 64, 64GB window - // BAR # 1 are the PCIE mem 32, 2GB window - // BAR # 2 are the PHB REGS - - //If we are in sapphire mode we need to shift the PCI - //Mem addresses down below the 48 bit limit for an NVIDA - //adapter. This is a workaround for GA1 so the adapter - //can be supported. Largest (theoretically dimm) is 1TB, - //so max mem is ~32TB for non brazos system. - - //Place mem64 @ 59TB-63TB (0x00003B0000000000) - //Place mem32 @ 63.875TB-64TB (0x00030FE000000000) - - //TODO RTC 100773 -- Fix this the correct way by - //having base addresses per payload type - - //We will change the base addr down 4 bits, but need to keep - //the proc/node offsets the same - for ( uint8_t u=0; u < PROC_SETUP_BARS_PCIE_NUM_UNITS; u++ ) - { - if(TARGETING::is_sapphire_load()) - { - o_pcieBarBase[u][0] = SAPPHIRE_PCIE_BAR0_BASE + - (l_pciMem64[u] & PCIE_BAR0_OFFSET_MASK); - o_pcieBarBase[u][1] = SAPPHIRE_PCIE_BAR1_BASE + - (l_pciMem32[u] & PCIE_BAR1_OFFSET_MASK); - } - else - { - o_pcieBarBase[u][0] = l_pciMem64[u]; - o_pcieBarBase[u][1] = l_pciMem32[u]; - } - - o_pcieBarBase[u][2] = l_phbRegs[u]; - - FAPI_DBG( "fapiPlatGetProcPcieBarBaseAddr: Chip %x Unit %d : %p %p %p", - TARGETING::get_huid(l_pProcTarget), - u, - o_pcieBarBase[u][0], - o_pcieBarBase[u][1], - o_pcieBarBase[u][2] ); - } - } - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetProcPcieBarSize ( - const fapi::Target * i_pTarget, - uint64_t (&o_pcieBarSize) [4][3] ) -{ - fapi::ReturnCode l_rc; - uint64_t l_procNum = 0; - uint8_t l_isEnabled = PROC_BARS_DISABLE; - - l_rc = barsPreCheck(i_pTarget, l_procNum, l_isEnabled); - if ( l_rc ) - { - FAPI_ERR("fapiPlatGetProcPcieBarSize: Error from barsPreCheck"); - } - else - { - // NOTE: supported BAR0/1 sizes are from 64KB-1PB - // NOTE: only supported BAR2 size is 4KB - for ( uint8_t u=0; u < PROC_SETUP_BARS_PCIE_NUM_UNITS; u++ ) - { - o_pcieBarSize[u][0] = PCIE_BAR0_SIZE ; - o_pcieBarSize[u][1] = PCIE_BAR1_SIZE ; - o_pcieBarSize[u][2] = PCIE_BAR2_SIZE; - - FAPI_DBG( "fapiPlatGetProcPcieBarSize: Unit %d : %p %p %p", - u, - o_pcieBarSize[u][0], - o_pcieBarSize[u][1], - o_pcieBarSize[u][2] ); - } - } - - return l_rc; -} - -fapi::ReturnCode fapiPlatGetMBvpdMemoryDataVersion( - const fapi::Target * i_pTarget, - uint32_t & o_val) -{ - // Call a VPD Accessor HWP to get the data - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdMemoryDataVersion, *i_pTarget, o_val); - return l_rc; -} -fapi::ReturnCode fapiPlatGetMBvpdSPDXRecordVersion( - const fapi::Target * i_pTarget, - uint32_t & o_val) -{ - // Call a VPD Accessor HWP to get the data - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdSPDXRecordVersion, *i_pTarget, o_val); - return l_rc; -} -fapi::ReturnCode fapiPlatGetMBvpdVoltageSettingData( - const fapi::Target * i_pTarget, - uint32_t & o_val) -{ - // Call a VPD Accessor HWP to get the data - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdVoltageSettingData, *i_pTarget, o_val); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetSingleMemberEnableAttr( - const fapi::Target * i_pTarget, - uint32_t & o_val) -{ - // Call a VPD Accessor HWP to get the data - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMvpdExL2SingleMemberEnable, *i_pTarget, o_val); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetAddrMirrorData ( - const fapi::Target * i_pTarget, - uint8_t (& o_val) [2][2] ) -{ - // Get the data using the HWP accessor - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdAddrMirrorData, *i_pTarget, o_val); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetAttrData ( - const fapi::Target * i_pTarget, - const fapi::AttributeId i_attr, - void * o_pVal, - const size_t i_valSize) -{ - // Call a VPD Accessor HWP to get the data - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdAttr, - *i_pTarget, i_attr, o_pVal, i_valSize); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetSlopeInterceptData ( - const fapi::Target * i_pTarget, - const fapi::MBvpdSlopeIntercept i_attr, - uint32_t & o_Val) -{ - // Call a VPD Accessor HWP to get the data - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdSlopeInterceptData, - *i_pTarget, i_attr, o_Val); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetVpdVersion ( - const fapi::Target * i_pFapiTarget, - uint32_t &o_val ) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pTarget = NULL; - TARGETING::TargetHandleList l_mbaList; - - do { - // Get the Targeting Target - l_rc = getTargetingTarget(i_pFapiTarget, l_pTarget); - if (l_rc) - { - FAPI_ERR("fapiPlatGetVpdVersion: Error from getTargetingTarget"); - break; - } - - // Find MBA target from DIMM target - getParentAffinityTargets (l_mbaList, l_pTarget, TARGETING::CLASS_UNIT, - TARGETING::TYPE_MBA, false); - - if (l_mbaList.size () != 1 ) - { - FAPI_ERR("fapiPlatGetVpdVersion: expect 1 mba %d ", - l_mbaList.size()); - - /*@ - * @errortype - * @moduleid fapi::MOD_PLAT_ATTR_SVC_GET_VPD_VERSION - * @reasoncode fapi::RC_NO_SINGLE_MBA - * @userdata1 Number of MBAs - * @userdata2 DIMM HUID - * @devdesc fapiPlatGetVpdVersion could not find the - * expected 1 mba from the passed dimm target - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_PLAT_ATTR_SVC_GET_VPD_VERSION, - fapi::RC_NO_SINGLE_MBA, - l_mbaList.size(), - TARGETING::get_huid(l_pTarget), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - break; - } - - // Get the Fapi Target - fapi::Target l_fapiTarget(TARGET_TYPE_MBA_CHIPLET, - static_cast<void *>(l_mbaList[0])); - - // Get the data using the HWP accessor - FAPI_EXEC_HWP(l_rc, getMBvpdVersion, l_fapiTarget, o_val); - if (l_rc) - { - FAPI_ERR("fapiPlatGetVpdVersion:" - " Error from getMBvpdVersion"); - break; - } - - } while (0); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetDram2NModeEnabled ( - const fapi::Target * i_pFapiTarget, - uint8_t &o_val ) -{ - // Get the data using the HWP accessor - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdDram2NModeEnabled, * i_pFapiTarget, o_val); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetSensorMap ( - const fapi::Target * i_pFapiTarget, - const fapi::MBvpdSensorMap i_attr, - uint8_t & o_val) -{ - // Get the data using the HWP accessor - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getMBvpdSensorMap, * i_pFapiTarget, i_attr, o_val); - return l_rc; -} - -fapi::ReturnCode fapiPlatL4BankDelete ( - const fapi::Target * i_pTarget, - uint32_t & io_val, - const fapi::MBvpdL4BankDeleteMode i_mode) -{ - // Call a VPD Accessor HWP to get or set the data - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, accessMBvpdL4BankDelete, - *i_pTarget, io_val, i_mode); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetEnableAttr ( fapi::AttributeId i_id, - const fapi::Target * i_pFapiTarget, uint8_t & o_enable ) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pTarget = NULL; - o_enable = 0; - - // Get the Targeting Target - l_rc = getTargetingTarget(i_pFapiTarget, l_pTarget); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetEnableAttr: Error from getTargetingTarget"); - } - else - { - TARGETING::TargetHandleList l_buses; - switch (i_id) - { - case fapi::ATTR_PROC_NX_ENABLE: - case fapi::ATTR_PROC_L3_ENABLE: - // The enable flag is based on the target's functional state - TARGETING::HwasState hwasState; - hwasState = l_pTarget->getAttr<TARGETING::ATTR_HWAS_STATE>(); - o_enable = hwasState.functional; - break; - case fapi::ATTR_PROC_PCIE_ENABLE: - // The enable flag is 1 if one of the pci target is functional - getChildChiplets( l_buses, l_pTarget, TARGETING::TYPE_PCI ); - o_enable = l_buses.size() ? 1 : 0; - break; - case fapi::ATTR_PROC_A_ENABLE: - // The enable flag reflects the state of the pervasive chiplet, - // NOT the bus logic, so always return true since we don't - // support partial good on the ABUS chiplet - o_enable = 1; - break; - case fapi::ATTR_PROC_X_ENABLE: - // Need to support having the X bus chiplet partial good - // Look at the saved away PG data - TARGETING::ATTR_CHIP_REGIONS_TO_ENABLE_type l_chipRegionData; - l_rc = FAPI_ATTR_GET(ATTR_CHIP_REGIONS_TO_ENABLE, i_pFapiTarget, - l_chipRegionData); - if (l_rc) { - FAPI_ERR("fapi_attr_get( ATTR_CHIP_REGIONS_TO_ENABLE ) failed. With rc = 0x%x", - (uint32_t) l_rc ); - break; - } - else if (l_chipRegionData[HWAS::VPD_CP00_PG_XBUS_INDEX] != 0) - { - o_enable = 0x1; - } - break; - default: - o_enable = 0; - break; - } - } - - return l_rc; -} - - -//------------------------------------------------------------------------------ -// Functions to support BAD_DQ_BITMAP_attribute -// See dimm_spd_attributes.xml for detailed descriptions -//------------------------------------------------------------------------------ - - -/** - * @brief This function is called by the FAPI_ATTR_GET macro when getting - * the Bad DQ Bitmap attribute - * It should not be called directly. - * - * @param[in] i_pTarget DIMM target pointer - * @param[out] o_data Bad DIMM DQ Bitmap - * @return ReturnCode. Zero on success, else platform specified error - */ -fapi::ReturnCode fapiPlatDimmGetBadDqBitmap ( - const fapi::Target * i_pTarget, - uint8_t (&o_data)[DIMM_DQ_MAX_DIMM_RANKS]\ - [DIMM_DQ_RANK_BITMAP_SIZE]) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pTarget = NULL; - TARGETING::TargetHandleList l_mbaList; - do - { - // Get the Targeting Target - l_rc = getTargetingTarget(i_pTarget, l_pTarget); - if (l_rc) - { - FAPI_ERR("fapiPlatDimmGetBadDqBitmap:Error from getTargetingTarget"); - break; - } - - // Find MBA target from DIMM target - getParentAffinityTargets(l_mbaList, l_pTarget, TARGETING::CLASS_UNIT, - TARGETING::TYPE_MBA, false); - - - if (l_mbaList.size() != 1 ) - { - FAPI_ERR("fapiPlatDimmGetBadDqBitmap: expect 1 mba %d ", - l_mbaList.size()); - - /*@ - * @errortype - * @moduleid fapi::MOD_PLAT_ATTR_SVC_GET_BADDQ_DATA - * @reasoncode fapi::RC_NO_SINGLE_MBA - * @userdata1 Number of MBAs - * @userdata2 DIMM HUID - * @devdesc fapiPlatDimmGetBadDqBitmap could not find the - * expected 1 mba from the passed dimm target - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_PLAT_ATTR_SVC_GET_BADDQ_DATA, - fapi::RC_NO_SINGLE_MBA, - l_mbaList.size(), - TARGETING::get_huid(l_pTarget), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - break; - } - - - // Create the Fapi Target - fapi::Target l_mbaTarget(TARGET_TYPE_MBA_CHIPLET, - static_cast<void *>(l_mbaList[0])); - - - FAPI_EXEC_HWP(l_rc, dimmBadDqBitmapAccessHwp, - l_mbaTarget, *i_pTarget, o_data, true); - - if (l_rc) - { - FAPI_ERR("fapiPlatDimmGetBadDqBitmap: " - "Error from dimmBadDqBitmapAccessHwp (get)"); - } - - }while(0); - return l_rc; -} - - -/** - * @brief This function is called by the FAPI_ATTR_SET macro when setting - * the Bad DQ Bitmap attribute - * It should not be called directly. - * - * @param[in] i_pTarget DIMM target pointer - * @param[in] i_data Bad DIMM DQ Bitmap - * @return ReturnCode. Zero on success, else platform specified error - */ -fapi::ReturnCode fapiPlatDimmSetBadDqBitmap ( - const fapi::Target * i_pTarget, - uint8_t (&i_data)[DIMM_DQ_MAX_DIMM_RANKS]\ - [DIMM_DQ_RANK_BITMAP_SIZE]) -{ - fapi::ReturnCode l_rc; - TARGETING::Target * l_pTarget = NULL; - TARGETING::TargetHandleList l_mbaList; - do - { - // Get the Targeting Target - l_rc = getTargetingTarget(i_pTarget, l_pTarget); - if (l_rc) - { - FAPI_ERR("fapiPlatDimmSetBadDqBitmap:Error from getTargetingTarget"); - break; - } - - // Find MBA target from DIMM target - getParentAffinityTargets(l_mbaList, l_pTarget, TARGETING::CLASS_UNIT, - TARGETING::TYPE_MBA, false); - - - if (l_mbaList.size() != 1 ) - { - FAPI_ERR("fapiPlatDimmSetBadDqBitmap: expect 1 mba %d ", - l_mbaList.size()); - - /*@ - * @errortype - * @moduleid fapi::MOD_PLAT_ATTR_SVC_SET_BADDQ_DATA - * @reasoncode fapi::RC_NO_SINGLE_MBA - * @userdata1 Number of MBAs - * @userdata2 DIMM HUID - * @devdesc fapiPlatDimmSetBadDqBitmap could not find the - * expected 1 mba from the passed dimm target - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_PLAT_ATTR_SVC_SET_BADDQ_DATA, - fapi::RC_NO_SINGLE_MBA, - l_mbaList.size(), - TARGETING::get_huid(l_pTarget), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - break; - } - - - // Create the Fapi Target - fapi::Target l_mbaTarget(TARGET_TYPE_MBA_CHIPLET, - static_cast<void *>(l_mbaList[0])); - - - FAPI_EXEC_HWP(l_rc, dimmBadDqBitmapAccessHwp, - l_mbaTarget, *i_pTarget, i_data, false); - - if (l_rc) - { - FAPI_ERR("fapiPlatdimmSetBadDqBitmap: " - "Error from dimmBadDqBitmapAccessHwp (set)"); - } - - }while(0); - return l_rc; -} - -//------------------------------------------------------------------------------ -// Function to support VPD_DIMM_SPARE attribute -// See dimm_spd_attributes.xml for detailed description -//------------------------------------------------------------------------------ - -/** - * @brief This function is called by the FAPI_ATTR_GET macro when getting - * the VPD DIMM Spare attribute - * It should not be called directly. - * - * @param[in] i_pTarget MBA target pointer - * @param[out] o_data Spare DRAM availability for MBA - * @return ReturnCode. Zero on success, else platform specified error - */ -fapi::ReturnCode fapiPlatDimmGetSpareDram ( - const fapi::Target * i_pTarget, - uint8_t (&o_data)[DIMM_DQ_MAX_MBA_PORTS] - [DIMM_DQ_MAX_MBAPORT_DIMMS] - [DIMM_DQ_MAX_DIMM_RANKS]) -{ - - fapi::ReturnCode l_rc; - do - { - FAPI_EXEC_HWP(l_rc, getMBvpdSpareDramData, *i_pTarget, o_data); - - if (l_rc) - { - FAPI_ERR("fapiPlatDimmGetSpareDram: " - "Error from getMBvpdSpareDramData"); - break; - } - - }while(0); - - return l_rc; -} - -//****************************************************************************** -// fapi::platAttrSvc::fapiPlatGetPllAttr function -//****************************************************************************** -fapi::ReturnCode fapiPlatGetPllAttr(const fapi::AttributeId i_targAttrId, - const fapi::Target * const i_pChipTarget, - uint8_t * o_data ) -{ - // Call a PLL Ring Attribute HWP to get the data - fapi::ReturnCode l_rc; - uint32_t l_ringLength = 0; - FAPI_EXEC_HWP(l_rc, getPllRingAttr, i_targAttrId, *i_pChipTarget, - l_ringLength, o_data); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetPllAttr(const fapi::AttributeId i_targAttrId, - const fapi::Target * const i_pChipTarget, - uint32_t (&o_pllRingLength)) -{ - // Call a PLL Ring Attribute HWP to get the data - fapi::ReturnCode l_rc; - uint8_t l_data[MAX_PLL_RING_SIZE_BYTES] = {}; - FAPI_EXEC_HWP(l_rc, getPllRingAttr, i_targAttrId, *i_pChipTarget, - o_pllRingLength, l_data); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetPllInfoAttr( - const fapi::Target * i_pProcChip, - const fapi::getPllRingInfo::Attr i_attr, - void * o_pVal, - const size_t i_len) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getPllRingInfoAttr, *i_pProcChip, i_attr, o_pVal, i_len); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetSpdAttrAccessor( - const fapi::Target * i_pDimm, - const fapi::getSpdAttr::Attr i_attr, - void * o_pVal, - const size_t i_len) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getSpdAttrAccessor, *i_pDimm, i_attr, o_pVal, i_len); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetL3DDAttr(const fapi::Target * i_pProcTarget, - uint32_t (&o_data)[DELTA_DATA_SIZE]) -{ - fapi::ReturnCode l_rc; - uint32_t l_ringLength=0; - FAPI_EXEC_HWP(l_rc, getL3DeltaDataAttr,*i_pProcTarget,o_data,l_ringLength); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetL3Length(const fapi::Target * i_pProcTarget, - uint32_t (&o_ringLength)) -{ - fapi::ReturnCode l_rc; - uint32_t l_data [DELTA_DATA_SIZE] = {}; - FAPI_EXEC_HWP(l_rc, getL3DeltaDataAttr,*i_pProcTarget,l_data,o_ringLength); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetPciOscswitchConfig - (const fapi::Target * i_pProcTarget, - uint8_t &o_val) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getPciOscswitchConfig, *i_pProcTarget, o_val); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetTdpRdpCurrentFactor - (const fapi::Target * i_pProcTarget, - uint32_t &o_val) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getTdpRdpCurrentFactor, *i_pProcTarget, o_val); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetSpdModspecComRefRawCard - (const fapi::Target * i_pDimmTarget, - uint8_t &o_val) -{ - fapi::ReturnCode l_rc; - uint8_t l_cardExt = 0; - uint8_t l_card = 0; - - do { - - // Get the Reference Raw Card Extension (0 or 1) - l_rc = fapiPlatGetSpdAttr(i_pDimmTarget, - SPD::MODSPEC_COM_REF_RAW_CARD_EXT, - &l_cardExt, sizeof(l_cardExt)); - if (l_rc) - { - break; //break with error - } - - // Get the References Raw Card (bits 4-0) - // When Reference Raw Card Extension = 0 - // Reference raw cards A through AL - // When Reference Raw Card Extension = 1 - // Reference raw cards AM through CB - l_rc = fapiPlatGetSpdAttr(i_pDimmTarget, SPD::MODSPEC_COM_REF_RAW_CARD, - &l_card, sizeof(l_card)); - if (l_rc) - { - break; //break with error - } - - // Raw Card = 0x1f(ZZ) means no JEDEC reference raw card design used. - // Have one ZZ in the return merged enumeration. - if (0x1f == l_card) - { - l_cardExt = 1; //Just one ZZ in the enumeration (0x3f) - } - - // Merge into a single enumeration - o_val = (l_cardExt <<5) | l_card; - - } while (0); - - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetOscswitchCtl - (const fapi::Target * i_pProcTarget, - const fapi::getOscswitchCtl::Attr i_attr, - void * o_pVal, - const size_t i_len) -{ - fapi::ReturnCode l_rc; - - FAPI_EXEC_HWP(l_rc,getOscswitchCtlAttr,*i_pProcTarget,i_attr,o_pVal,i_len); - - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetControlCapable(const fapi::Target * i_pTarget, - uint8_t & o_val) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc,getControlCapableData,*i_pTarget,o_val); - return l_rc; -} - -//----------------------------------------------------------------------------- -fapi::ReturnCode fapiPlatGetRCDCntlWord015(const fapi::Target * i_pFapiTarget, - uint64_t & o_val) -{ - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - o_val = 0; - size_t l_nibbleSize = 4; - const uint8_t l_keywordSize = 16; - const uint16_t l_keywords [l_keywordSize] = { SPD::RMM_RC0, - SPD::RMM_RC1, - SPD::RMM_RC2, - SPD::RMM_RC3, - SPD::RMM_RC4, - SPD::RMM_RC5, - SPD::RMM_RC6, - SPD::RMM_RC7, - SPD::RMM_RC8, - SPD::RMM_RC9, - SPD::RMM_RC10, - SPD::RMM_RC11, - SPD::RMM_RC12, - SPD::RMM_RC13, - SPD::RMM_RC14, - SPD::RMM_RC15 }; - do - { - uint8_t l_dimmType =0; - l_rc = FAPI_ATTR_GET(ATTR_SPD_MODULE_TYPE, i_pFapiTarget,l_dimmType); - if (l_rc) - { - FAPI_ERR("fapiPlatGetRCDCntlWord015: Error getting ATTR_SPD_MODULE_TYPE"); - break; - } - - - if (l_dimmType == ENUM_ATTR_SPD_MODULE_TYPE_RDIMM) - { - ATTR_SPD_DRAM_DEVICE_TYPE_Type l_spd_dramtype = - ENUM_ATTR_SPD_DRAM_DEVICE_TYPE_DDR3; - - l_rc = FAPI_ATTR_GET(ATTR_SPD_DRAM_DEVICE_TYPE, - i_pFapiTarget, - l_spd_dramtype); - if (l_rc) - { - FAPI_ERR("fapiPlatGetRCDCntlWord015: Error from get" - " ATTR_SPD_DRAM_DEVICE_TYPE"); - break; - } - - // Not defined for DDR4 - if (ENUM_ATTR_SPD_DRAM_DEVICE_TYPE_DDR4 == l_spd_dramtype) - { - o_val = 0; - break; - } - - TARGETING::Target* l_pTarget = NULL; - l_rc = getTargetingTarget(i_pFapiTarget, l_pTarget, TARGETING::TYPE_DIMM); - if (l_rc) - { - FAPI_ERR("fapiPlatGetRCDCntlWord015: Error from getTargetingTarget"); - break; - } - - uint8_t l_nibbleRead; - - for (int i = 0; i < l_keywordSize; i++) - { - l_nibbleRead = 0; - l_err = deviceRead(l_pTarget, &l_nibbleRead, l_nibbleSize, - DEVICE_SPD_ADDRESS(l_keywords[i])); - if (l_err) - { - FAPI_ERR("fapiPlatGetRCDCntlWord015:Error from deviceRead"); - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - o_val = (o_val << 4) | (l_nibbleRead & 0x0F); - } - } - else if ((l_dimmType == ENUM_ATTR_SPD_MODULE_TYPE_UDIMM) || - (l_dimmType == ENUM_ATTR_SPD_MODULE_TYPE_CDIMM)) - { - o_val = 0; - break; - } - else - { - /*@ - * @errortype - * @moduleid MOD_GET_RCD_CNTL_WORD - * @reasoncode RC_INVALID_DIMM_TYPE - * @userdata1 DIMM TYPE - * @devdesc Failed due to wrong DIMM type - */ - l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_GET_RCD_CNTL_WORD, - RC_INVALID_DIMM_TYPE, - l_dimmType, 0, true); - FAPI_ERR("fapiPlatGetRCDCntlWord015:Wrong dimm type"); - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - } while (0); - return l_rc; -} - -fapi::ReturnCode getIsDimmToC4DQ - (const fapi::Target * i_pTarget, - uint8_t (&o_val) [4][80]) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc,getDQAttrISDIMM,*i_pTarget,o_val); - return FAPI_RC_SUCCESS; -} - -fapi::ReturnCode getIsDimmToC4DQS - (const fapi::Target * i_pTarget, - uint8_t (&o_val) [4][20]) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc,getDQSAttrISDIMM,*i_pTarget,o_val); - return FAPI_RC_SUCCESS; -} - -/** - * @brief Get the Perv Vitle ring length. See doxygen in .H file - */ -fapi::ReturnCode fapiPlatGetPervVitlRingLengthAttr( - const fapi::Target * i_pProcTarget, - uint32_t (&o_ringLength)) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getPervVitlRingLengthAttr, - *i_pProcTarget, o_ringLength); - return l_rc; -} - -/** - * @brief Get the TP Vitle spy length. See doxygen in .H file - */ -fapi::ReturnCode fapiPlatGetTpVitlSpyLengthAttr( - const fapi::Target * i_pProcTarget, - uint32_t (&o_spyLength)) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getTpVitlSpyLengthAttr, *i_pProcTarget, o_spyLength); - return l_rc; -} - -/** - * @brief Get the TP Vitle spy offsets. See doxygen in .H file - */ -fapi::ReturnCode fapiPlatGetTpVitlSpyOffsetAttr( - const fapi::Target * i_pProcTarget, - uint32_t (&o_data)[SPY_OFFSET_SIZE]) -{ - fapi::ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, getTpVitlSpyOffsetAttr, *i_pProcTarget, o_data); - return l_rc; -} - -fapi::ReturnCode fapiPlatGetNodeMemAttrData ( - const fapi::Target * i_pTarget, - const TARGETING::ATTRIBUTE_ID i_attr, - uint32_t & o_val) -{ - - FAPI_DBG("fapiPlatGetNodeMemAttrData: START: i_attr=0x%X", i_attr); - - fapi::ReturnCode l_rc; - TARGETING::Target * l_pTgt = NULL; - - do { - - // Get non-FAPI Centaur Target - l_rc = getTargetingTarget(i_pTarget, l_pTgt, - TARGETING::TYPE_MEMBUF); - - if (l_rc) - { - FAPI_ERR("fapiPlatGetNodeMemAttrData: Error from getTargetingTarget"); - break; - } - - // Get NODE from MEMBUF target - TARGETING::TargetHandleList l_nodeList; - TARGETING::TargetService& tS = TARGETING::targetService(); - - TARGETING::PredicateCTM isaNode(TARGETING::CLASS_ENC, - TARGETING::TYPE_NODE); - tS.getAssociated( l_nodeList, - l_pTgt, - TARGETING::TargetService::PARENT, - TARGETING::TargetService::ALL, - &isaNode); - - // Node list should only have 1 tgt - if (l_nodeList.size() != 1 ) - { - FAPI_ERR("fapiPlatGetNodeMemAttrData: expect 1 node %d ", - l_nodeList.size()); - - /*@ - * @errortype - * @moduleid MOD_PLAT_ATTR_SVC_GET_MEM_ATTR_DATA - * @reasoncode RC_NO_SINGLE_NODE - * @userdata1 Number of Nodes - * @userdata2 MEMBUF Target HUID - * @devdesc fapiPlatGetNodeMemAttrData could not find the single - * node associated with this membuf target - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - MOD_PLAT_ATTR_SVC_GET_MEM_ATTR_DATA, - RC_NO_SINGLE_NODE, - l_nodeList.size(), - TARGETING::get_huid(l_pTgt), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - break; - } - - // Get the attribute from the node level - // NOTE: Using switch statement to explicitly track the attributes - // that need to do this lookup. - bool l_success = false; - - switch ( i_attr ) - { - case TARGETING::ATTR_MSS_CENT_VDD_SLOPE_ACTIVE: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_CENT_VDD_SLOPE_ACTIVE>(o_val); - break; - - case TARGETING::ATTR_MSS_CENT_VDD_SLOPE_INACTIVE: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_CENT_VDD_SLOPE_INACTIVE>(o_val); - break; - - case TARGETING::ATTR_MSS_CENT_VDD_INTERCEPT: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_CENT_VDD_INTERCEPT>(o_val); - break; - - case TARGETING::ATTR_MSS_CENT_VCS_SLOPE_ACTIVE: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_CENT_VCS_SLOPE_ACTIVE>(o_val); - break; - - case TARGETING::ATTR_MSS_CENT_VCS_SLOPE_INACTIVE: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_CENT_VCS_SLOPE_INACTIVE>(o_val); - break; - - case TARGETING::ATTR_MSS_CENT_VCS_INTERCEPT: - l_success = l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_CENT_VCS_INTERCEPT>(o_val); - break; - - case TARGETING::ATTR_MSS_VOLT_VPP_SLOPE_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_VOLT_VPP_SLOPE_EFF_CONFIG>(o_val); - break; - - case TARGETING::ATTR_MSS_VOLT_VPP_INTERCEPT_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_VOLT_VPP_INTERCEPT_EFF_CONFIG> - (o_val); - break; - - case TARGETING::ATTR_MSS_VOLT_DDR3_VDDR_SLOPE_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_VOLT_DDR3_VDDR_SLOPE_EFF_CONFIG> - (o_val); - break; - - case TARGETING::ATTR_MSS_VOLT_DDR3_VDDR_INTERCEPT_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_VOLT_DDR3_VDDR_INTERCEPT_EFF_CONFIG - >(o_val); - break; - - case TARGETING::ATTR_MRW_DDR3_VDDR_MAX_LIMIT_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MRW_DDR3_VDDR_MAX_LIMIT_EFF_CONFIG> - (o_val); - break; - - case TARGETING::ATTR_MSS_VOLT_DDR4_VDDR_SLOPE_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_VOLT_DDR4_VDDR_SLOPE_EFF_CONFIG> - (o_val); - break; - - case TARGETING::ATTR_MSS_VOLT_DDR4_VDDR_INTERCEPT_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MSS_VOLT_DDR4_VDDR_INTERCEPT_EFF_CONFIG - >(o_val); - break; - - case TARGETING::ATTR_MRW_DDR4_VDDR_MAX_LIMIT_EFF_CONFIG: - l_success = - l_nodeList[0]->tryGetAttr< - TARGETING::ATTR_MRW_DDR4_VDDR_MAX_LIMIT_EFF_CONFIG> - (o_val); - break; - - default: - // Use error creation below - l_success = false; - break; - } - - if (!l_success) - { - FAPI_ERR("fapiPlatGetNodeMemAttrData: Error from _tryGetAttr"); - - /*@ - * @errortype - * @moduleid MOD_PLAT_ATTR_SVC_GET_MEM_ATTR_DATA - * @reasoncode RC_FAILED_TO_ACCESS_ATTRIBUTE - * @userdata1[0:31] Platform attribute ID - * @userdata1[32:64] MEMBUF Target - * @userdata2 FAPI target type, or NULL if system target - * @devdesc Failed to get requested attribute. - * Possible causes: Invalid target, attribute not implemented, - * attribute not present on given target, target service - * not initialized - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_PLAT_ATTR_SVC_GET_MEM_ATTR_DATA, - RC_FAILED_TO_ACCESS_ATTRIBUTE, - TWO_UINT32_TO_UINT64( - i_attr, - TARGETING::get_huid(l_pTgt)), - i_pTarget ? i_pTarget->getType(): NULL, - hbSwError); - l_rc.setPlatError(reinterpret_cast<void *>(l_pError)); - } - - } while (0); - - FAPI_DBG("fapiPlatGetNodeMemAttrData: EXIT: i_attr=0x%X --> o_val = %d (0x%X)", - i_attr, o_val, o_val); - - return l_rc; - -} - -} // End platAttrSvc namespace - -} // End fapi namespace diff --git a/src/usr/hwpf/plat/fapiPlatCreateHwpErrParser.pl b/src/usr/hwpf/plat/fapiPlatCreateHwpErrParser.pl deleted file mode 100755 index 076bb65ad..000000000 --- a/src/usr/hwpf/plat/fapiPlatCreateHwpErrParser.pl +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/perl -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/hwpf/plat/fapiPlatCreateHwpErrParser.pl $ -# -# OpenPOWER HostBoot Project -# -# Contributors Listed Below - COPYRIGHT 2012,2015 -# [+] 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 - -# -# Purpose: This perl script will parse HWP Error XML files and create a -# file containing functions that parses the return code and FFDC -# data in HWP error logs. -# -# Author: Mike Jones -# - -use strict; - -#------------------------------------------------------------------------------ -# Print Command Line Help -#------------------------------------------------------------------------------ -my $numArgs = $#ARGV + 1; -if ($numArgs < 2) -{ - print ("Usage: fapiPlatCreateHwpErrParser.pl <output dir> <filename1> <filename2> ...\n"); - print (" This perl script will parse HWP Error XML files and create\n"); - print (" a file called fapiPlatHwpErrParser.H that contains functions to\n"); - print (" parse the return code and FFDC data in HWP error logs\n"); - exit(1); -} - -#------------------------------------------------------------------------------ -# Specify perl modules to use -#------------------------------------------------------------------------------ -use Digest::MD5 qw(md5_hex); -use XML::Simple; -my $xml = new XML::Simple (KeyAttr=>[]); - -# Uncomment to enable debug output -#use Data::Dumper; - -#------------------------------------------------------------------------------ -# Open output files for writing -#------------------------------------------------------------------------------ -my $rcFile = $ARGV[0]; -$rcFile .= "/"; -$rcFile .= "fapiPlatHwpErrParser.H"; -open(TGFILE, ">", $rcFile); - -#------------------------------------------------------------------------------ -# Print start of file information -#------------------------------------------------------------------------------ -print TGFILE "// fapiPlatHwpErrParser.H\n"; -print TGFILE "// This file is generated by perl script fapiPlatCreateHwpErrParser.pl\n\n"; -print TGFILE "#ifndef FAPIPLATHWPERRPARSER_H_\n"; -print TGFILE "#define FAPIPLATHWPERRPARSER_H_\n\n"; -print TGFILE "#ifdef PARSER\n\n"; -print TGFILE "namespace fapi\n"; -print TGFILE "{\n\n"; -print TGFILE "void fapiParseHwpRc(ErrlUsrParser & i_parser,\n"; -print TGFILE " void * i_pBuffer,\n"; -print TGFILE " const uint32_t i_buflen)\n"; -print TGFILE "{\n"; -print TGFILE " uint32_t l_rc = ntohl(*(static_cast<uint32_t *>(i_pBuffer)));\n\n"; -print TGFILE " switch(l_rc)\n"; -print TGFILE " {\n"; - -#------------------------------------------------------------------------------ -# For each XML file -#------------------------------------------------------------------------------ -foreach my $argnum (1 .. $#ARGV) -{ - #-------------------------------------------------------------------------- - # Read XML file - #-------------------------------------------------------------------------- - my $infile = $ARGV[$argnum]; - my $errors = $xml->XMLin($infile, ForceArray => ['hwpError']); - - # Uncomment to get debug output of all errors - #print "\nFile: ", $infile, "\n", Dumper($errors), "\n"; - - #-------------------------------------------------------------------------- - # For each Error - #-------------------------------------------------------------------------- - foreach my $err (@{$errors->{hwpError}}) - { - #---------------------------------------------------------------------- - # Get the description, remove newlines, leading and trailing spaces and - # multiple spaces - #---------------------------------------------------------------------- - my $desc = $err->{description}; - $desc =~ s/\n/ /g; - $desc =~ s/^ +//g; - $desc =~ s/ +$//g; - $desc =~ s/ +/ /g; - $desc =~ s/\"//g; - - #---------------------------------------------------------------------- - # Print the RC description - # Note that this uses the same code to calculate the error enum value - # as fapiParseErrorInfo.pl. This code must be kept in sync - #---------------------------------------------------------------------- - my $errHash128Bit = md5_hex($err->{rc}); - my $errHash24Bit = substr($errHash128Bit, 0, 6); - - print TGFILE " case 0x$errHash24Bit:\n"; - print TGFILE " i_parser.PrintString(\"HwpReturnCode\", \"$err->{rc}\");\n"; - print TGFILE " i_parser.PrintString(\"HWP Error description\", \"$desc\");\n"; - print TGFILE " break;\n"; - } -} - -#------------------------------------------------------------------------------ -# Print end of fapiParseHwpRc function -#------------------------------------------------------------------------------ -print TGFILE " default:\n"; -print TGFILE " i_parser.PrintNumber(\"Unrecognized Error ID\", \"0x%x\", l_rc);\n"; -print TGFILE " }\n"; -print TGFILE "}\n\n"; - -#------------------------------------------------------------------------------ -# Print start of fapiParseHwpFfdc function -#------------------------------------------------------------------------------ -print TGFILE "void fapiParseHwpFfdc(ErrlUsrParser & i_parser,\n"; -print TGFILE " void * i_pBuffer,\n"; -print TGFILE " const uint32_t i_buflen)\n"; -print TGFILE "{\n"; -print TGFILE " const uint32_t CFAM_DATA_LEN = 4;\n"; -print TGFILE " const uint32_t SCOM_DATA_LEN = 8;\n"; -print TGFILE " const uint32_t POS_LEN = 4;\n"; -print TGFILE " uint8_t * l_pBuffer = static_cast<uint8_t *>(i_pBuffer);\n"; -print TGFILE " uint32_t l_buflen = i_buflen;\n\n"; -print TGFILE " // The first uint32_t is the FFDC ID\n"; -print TGFILE " uint32_t * l_pFfdcId = static_cast<uint32_t *>(i_pBuffer);\n"; -print TGFILE " uint32_t l_ffdcId = ntohl(*l_pFfdcId);\n"; -print TGFILE " l_pBuffer += sizeof(l_ffdcId);\n"; -print TGFILE " l_buflen -= sizeof(l_ffdcId);\n"; -print TGFILE " switch(l_ffdcId)\n"; -print TGFILE " {\n"; - -#------------------------------------------------------------------------------ -# For each XML file -#------------------------------------------------------------------------------ -foreach my $argnum (1 .. $#ARGV) -{ - #-------------------------------------------------------------------------- - # Read XML file - #-------------------------------------------------------------------------- - my $infile = $ARGV[$argnum]; - my $errors = $xml->XMLin($infile, ForceArray => - ['hwpError', 'ffdc', 'registerFfdc', 'cfamRegister', 'scomRegister']); - - # Uncomment to get debug output of all errors - #print "\nFile: ", $infile, "\n", Dumper($errors), "\n"; - - #-------------------------------------------------------------------------- - # If it is an FFDC section resulting from a <hwpError><ffdc> element, print - # out the FFDC name and hexdump the data - #-------------------------------------------------------------------------- - foreach my $err (@{$errors->{hwpError}}) - { - foreach my $ffdc (@{$err->{ffdc}}) - { - #------------------------------------------------------------------ - # Figure out the FFDC ID stored in the data. This is calculated in - # the same way as fapiParseErrorInfo.pl. This code must be kept in - # sync - #------------------------------------------------------------------ - my $ffdcName = $err->{rc} . "_" . $ffdc; - my $ffdcHash128Bit = md5_hex($ffdcName); - my $ffdcHash32Bit = substr($ffdcHash128Bit, 0, 8); - - print TGFILE " case 0x$ffdcHash32Bit:\n"; - print TGFILE " i_parser.PrintString(\"HwpReturnCode\", \"$err->{rc}\");\n"; - print TGFILE " i_parser.PrintString(\"FFDC:\", \"$ffdc\");\n"; - print TGFILE " if (l_buflen) "; - print TGFILE "{i_parser.PrintHexDump(l_pBuffer, l_buflen);}\n"; - print TGFILE " break;\n"; - } - } - - #-------------------------------------------------------------------------- - # If it is an FFDC section resulting from a <registerFfdc> element, print - # out the ID and walk through the registers, printing each out - #-------------------------------------------------------------------------- - foreach my $registerFfdc (@{$errors->{registerFfdc}}) - { - #---------------------------------------------------------------------- - # Figure out the FFDC ID stored in the data. This is calculated in the - # same way as fapiParseErrorInfo.pl. This code must be kept in sync - #---------------------------------------------------------------------- - my $ffdcName = $registerFfdc->{id}; - my $ffdcHash128Bit = md5_hex($ffdcName); - my $ffdcHash32Bit = substr($ffdcHash128Bit, 0, 8); - print TGFILE " case 0x$ffdcHash32Bit:\n"; - print TGFILE " i_parser.PrintString(\"Register FFDC:\", \"$ffdcName\");\n"; - print TGFILE " while (l_buflen > 0)\n"; - print TGFILE " {\n"; - print TGFILE " if (l_buflen >= POS_LEN)\n"; - print TGFILE " {\n"; - print TGFILE " uint32_t * l_pBufferTemp = reinterpret_cast<uint32_t *>(l_pBuffer);\n"; - print TGFILE " i_parser.PrintNumber(\"Chip Position:\",\"%X\",ntohl(*l_pBufferTemp));\n"; - print TGFILE " l_pBufferTemp = NULL;\n"; - print TGFILE " l_pBuffer+= POS_LEN;\n"; - print TGFILE " l_buflen -= POS_LEN;\n"; - print TGFILE " }\n"; - foreach my $cfamRegister (@{$registerFfdc->{cfamRegister}}) - { - print TGFILE " if (l_buflen >= CFAM_DATA_LEN)\n"; - print TGFILE " {\n"; - print TGFILE " i_parser.PrintString(\"CFAM Register:\", \"$cfamRegister\");\n"; - print TGFILE " i_parser.PrintHexDump(l_pBuffer, CFAM_DATA_LEN);\n"; - print TGFILE " l_pBuffer+= CFAM_DATA_LEN;\n"; - print TGFILE " l_buflen -= CFAM_DATA_LEN;\n"; - print TGFILE " }\n"; - } - foreach my $scomRegister (@{$registerFfdc->{scomRegister}}) - { - - print TGFILE " if (l_buflen >= SCOM_DATA_LEN)\n"; - print TGFILE " {\n"; - print TGFILE " i_parser.PrintString(\"SCOM Register:\", \"$scomRegister\");\n"; - print TGFILE " i_parser.PrintHexDump(l_pBuffer, SCOM_DATA_LEN);\n"; - print TGFILE " l_pBuffer+= SCOM_DATA_LEN;\n"; - print TGFILE " l_buflen -= SCOM_DATA_LEN;\n"; - print TGFILE " }\n"; - } - print TGFILE " }\n"; - print TGFILE " break;\n"; - } -} - -#------------------------------------------------------------------------------ -# Print end of fapiParseHwpFfdc function -#------------------------------------------------------------------------------ -print TGFILE " default:\n"; -print TGFILE " i_parser.PrintNumber(\"Unrecognized FFDC\", \"0x%x\", l_ffdcId);\n"; -print TGFILE " if (l_buflen) "; -print TGFILE "{i_parser.PrintHexDump(l_pBuffer, l_buflen);}\n"; -print TGFILE " }\n\n"; -print TGFILE "}\n\n"; - -#------------------------------------------------------------------------------ -# Print end of file info -#------------------------------------------------------------------------------ -print TGFILE "}\n\n"; -print TGFILE "#endif\n"; -print TGFILE "#endif\n"; - -#------------------------------------------------------------------------------ -# Close output file -#------------------------------------------------------------------------------ -close(TGFILE); - diff --git a/src/usr/hwpf/plat/fapiPlatHwAccess.C b/src/usr/hwpf/plat/fapiPlatHwAccess.C deleted file mode 100644 index 28e313697..000000000 --- a/src/usr/hwpf/plat/fapiPlatHwAccess.C +++ /dev/null @@ -1,736 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatHwAccess.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ -/* [+] 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 fapiPlatHwAccess.C - * - * @brief Implements the fapiHwAccess.H functions. - * - * Note that platform code must provide the implementation. - */ - -#include <fapiHwAccess.H> -#include <fapiPlatTrace.H> -#include <fapiPlatHwAccess.H> -#include <isteps/hwpf_reasoncodes.H> -#include <errl/errlentry.H> -#include <devicefw/userif.H> -#include <ecmdDataBufferBase.H> -#include <targeting/common/predicates/predicates.H> -#include <targeting/common/targetservice.H> -#include <scan/scanif.H> - -extern "C" -{ - -// Function prototypes -uint64_t platGetDDScanMode(const uint32_t i_ringMode); - - -//****************************************************************************** -// platGetScom function, the platform implementation -//****************************************************************************** -fapi::ReturnCode platGetScom(const fapi::Target& i_target, - const uint64_t i_address, - ecmdDataBufferBase & o_data) -{ - FAPI_DBG(ENTER_MRK "platGetScom"); - - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - uint32_t l_ecmdRc = ECMD_DBUF_SUCCESS; - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - // Perform SCOM read - uint64_t l_data = 0; - size_t l_size = sizeof(uint64_t); - - l_err = deviceRead(l_target, - &l_data, - l_size, - DEVICE_SCOM_ADDRESS(i_address)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - else - { - // Set buffer to 64-bit long to store data - l_ecmdRc = o_data.setBitLength(64); - if (l_ecmdRc == ECMD_DBUF_SUCCESS) - { - l_ecmdRc = o_data.setDoubleWord(0, l_data); - } - - if (l_ecmdRc) - { - FAPI_ERR("platGetScom: ecmdDataBufferBase setBitLength() or setDoubleWord() returns error, ecmdRc 0x%.8X", - l_ecmdRc); - l_rc.setEcmdError(l_ecmdRc); - } - } - - FAPI_DBG(EXIT_MRK "platGetScom"); - return l_rc; -} - -//****************************************************************************** -// platPutScom function -//****************************************************************************** -fapi::ReturnCode platPutScom(const fapi::Target& i_target, - const uint64_t i_address, - ecmdDataBufferBase & i_data) -{ - FAPI_DBG(ENTER_MRK "platPutScom"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - // Perform SCOM write - uint64_t l_data = i_data.getDoubleWord(0); - size_t l_size = sizeof(uint64_t); - l_err = deviceWrite(l_target, - &l_data, - l_size, - DEVICE_SCOM_ADDRESS(i_address)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - - FAPI_DBG(EXIT_MRK "platPutScom"); - return l_rc; -} - -//****************************************************************************** -// platPutScomUnderMask function -//****************************************************************************** -fapi::ReturnCode platPutScomUnderMask(const fapi::Target& i_target, - const uint64_t i_address, - ecmdDataBufferBase & i_data, - ecmdDataBufferBase & i_mask) -{ - FAPI_DBG(ENTER_MRK "platPutScomUnderMask"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - do - { - // Get current value from HW - uint64_t l_data = 0; - size_t l_size = sizeof(uint64_t); - l_err = deviceRead(l_target, - &l_data, - l_size, - DEVICE_SCOM_ADDRESS(i_address)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Calculate new value to write to reg - uint64_t l_inData = i_data.getDoubleWord(0); // Data to write - uint64_t l_inMask = i_mask.getDoubleWord(0); // Write mask - uint64_t l_inMaskInverted = ~(l_inMask); // Write mask inverted - uint64_t l_newMask = (l_inData & l_inMask); // Retain set data bits - - // l_data = current data set bits - l_data &= l_inMaskInverted; - - // l_data = current data set bit + set mask bits - l_data |= l_newMask; - - // Write new value - l_err = deviceWrite(l_target, - &l_data, - l_size, - DEVICE_SCOM_ADDRESS(i_address)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - } - while(0); - - FAPI_DBG(EXIT_MRK "platPutScomUnderMask"); - return l_rc; -} - -/**************************************************************************** - * @brief Verify target of a cfam access - * We can't access the cfam engine of the master processor. - * Only allow access to the other processors. - * This function will return an error if the input target is - * the boot processor. - * - * @param[in] i_target The target where cfam access is called on. - * @param[in] i_address CFAM Address being accessed - * - * @return errlHndl_t if target is a processor, NULL otherwise. - ****************************************************************************/ -static errlHndl_t verifyCfamAccessTarget(const fapi::Target& i_target, - uint32_t i_address) -{ - errlHndl_t l_err = NULL; - - // Can't access cfam engine on the master processor - if (i_target.getType() == fapi::TARGET_TYPE_PROC_CHIP) - { - TARGETING::Target* l_pMasterProcChip = NULL; - TARGETING::targetService(). - masterProcChipTargetHandle( l_pMasterProcChip ); - - TARGETING::Target* l_pTarget = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - if( l_pMasterProcChip == l_pTarget ) - { - FAPI_ERR("verifyCfamAccessTarget: Attempt to access CFAM register %.8X on the master processor chip", - i_address); - - /*@ - * @errortype - * @moduleid fapi::MOD_VERIFY_CFAM_ACCESS_TARGET - * @reasoncode fapi::RC_CFAM_ACCESS_ON_PROC_ERR - * @userdata1 Target HUID - * @userdata2 CFAM address being accessed - * @devdesc Attempt to access CFAM register on - * the master processor chip - */ - const bool hbSwError = true; - l_err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_VERIFY_CFAM_ACCESS_TARGET, - fapi::RC_CFAM_ACCESS_ON_PROC_ERR, - TARGETING::get_huid(l_pMasterProcChip), - i_address, hbSwError); - } - } - - return l_err; -} - -/**************************************************************************** - * @brief Get chip target for cfam access - * HW procedures may pass in non-chip targets (such as MBA or - * MBS as a target), so we need to find the parent chip in order - * to pass it to the device driver. - * - * @param[in] i_target The target as passed in by the procedure. - * - * @return errlHndl_t if can't find parent, NULL otherwise. - ****************************************************************************/ -static errlHndl_t getCfamChipTarget(const TARGETING::Target* i_target, - TARGETING::Target*& o_chipTarget) -{ - errlHndl_t l_err = NULL; - - // Default to input target - o_chipTarget = const_cast<TARGETING::Target*>(i_target); - - // Check to see if this is a chiplet - if (i_target->getAttr<TARGETING::ATTR_CLASS>() == TARGETING::CLASS_UNIT) - { - // Look for its chip parent - TARGETING::PredicateCTM l_chipClass(TARGETING::CLASS_CHIP); - TARGETING::TargetHandleList l_list; - TARGETING::TargetService& l_targetService = TARGETING::targetService(); - (void) l_targetService.getAssociated( - l_list, - i_target, - TARGETING::TargetService::PARENT, - TARGETING::TargetService::ALL, - &l_chipClass); - - if ( l_list.size() == 1 ) - { - o_chipTarget = l_list[0]; - } - else - { - // Something is wrong here, can't have more than one parent chip - FAPI_ERR("getCfamChipTarget: Invalid number of parent chip for this target chiplet - # parent chips %d", l_list.size()); - /*@ - * @errortype - * @moduleid fapi::MOD_GET_CFAM_CHIP_TARGET - * @reasoncode fapi::RC_INVALID_NUM_PARENT_CHIP - * @userdata1 Number of parent chip found - * @userdata2 Chiplet HUID - * @devdesc Invalid num of parent chip found for input CFAM target chiplet - */ - const bool hbSwError = true; - l_err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_GET_CFAM_CHIP_TARGET, - fapi::RC_INVALID_NUM_PARENT_CHIP, - l_list.size(), - TARGETING::get_huid(i_target), - hbSwError); - } - } - return l_err; -} - -//****************************************************************************** -// platGetCfamRegister function -//****************************************************************************** -fapi::ReturnCode platGetCfamRegister(const fapi::Target& i_target, - const uint32_t i_address, - ecmdDataBufferBase & o_data) -{ - FAPI_DBG(ENTER_MRK "platGetCfamRegister"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - uint32_t l_ecmdRc = ECMD_DBUF_SUCCESS; - - do - { - // Can't access cfam engine on master processor - l_err = verifyCfamAccessTarget(i_target,i_address); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - // Get the chip target if l_target is not a chip - TARGETING::Target* l_myChipTarget = NULL; - l_err = getCfamChipTarget(l_target, l_myChipTarget); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Perform CFAM read via FSI - // Address needs to be multiply by 4 because register addresses are word - // offsets but the FSI addresses are byte offsets. - // However, we need to preserve the engine's offset of 0x0C00 and 0x1000. - uint64_t l_addr = ((i_address & 0x003F) << 2) | (i_address & 0xFF00); - uint32_t l_data = 0; - size_t l_size = sizeof(uint32_t); - l_err = deviceRead(l_myChipTarget, - &l_data, - l_size, - DEVICE_FSI_ADDRESS(l_addr)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Set buffer to 32-bit long to store data - l_ecmdRc = o_data.setBitLength(32); - if (l_ecmdRc == ECMD_DBUF_SUCCESS) - { - l_ecmdRc = o_data.setWord(0, l_data); - } - if (l_ecmdRc) - { - FAPI_ERR("platGetCfamRegister: ecmdDataBufferBase setBitLength()" - " or setWord() returns error, ecmdRc 0x%.8X", - l_ecmdRc); - l_rc.setEcmdError(l_ecmdRc); - } - - } while(0); - - FAPI_DBG(EXIT_MRK "platGetCfamRegister"); - return l_rc; -} - -//****************************************************************************** -// platPutCfamRegister function -//****************************************************************************** -fapi::ReturnCode platPutCfamRegister(const fapi::Target& i_target, - const uint32_t i_address, - ecmdDataBufferBase & i_data) -{ - FAPI_DBG(ENTER_MRK "platPutCfamRegister"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - - do - { - // Can't access cfam engine on master processor - l_err = verifyCfamAccessTarget(i_target,i_address); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - TARGETING::Target* l_myChipTarget = NULL; - // Get the chip target if l_target is not a chip - l_err = getCfamChipTarget(l_target, l_myChipTarget); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Perform CFAM write via FSI - // Address needs to be multiply by 4 because register addresses are word - // offsets but the FSI addresses are byte offsets - // However, we need to preserve the engine's offset of 0x0C00 and 0x1000. - uint64_t l_addr = ((i_address & 0x003F) << 2) | (i_address & 0xFF00); - uint32_t l_data = i_data.getWord(0); - size_t l_size = sizeof(uint32_t); - l_err = deviceWrite(l_myChipTarget, - &l_data, - l_size, - DEVICE_FSI_ADDRESS(l_addr)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - } while (0); - - FAPI_DBG(EXIT_MRK "platPutCfamRegister"); - return l_rc; -} - -/**************************************************************************** - * @brief Modifying input 32-bit data with the specified mode - * - * This method modify 32-bit input data (io_modifiedData) by applying the - * specified modify mode along with the input data (i_origData). - * - * @param[in] i_modifyMode Modification mode - * @param[in] i_origData 32-bit data to be used for modification - * @param[out] io_modifiedData 32-bit data to be modified - * - * @return void - * - ****************************************************************************/ -void platProcess32BitModifyMode(const fapi::ChipOpModifyMode i_modifyMode, - const uint32_t i_origDataBuf, - uint32_t& io_modifiedData) -{ - - // OR operation - if (fapi::CHIP_OP_MODIFY_MODE_OR == i_modifyMode) - { - io_modifiedData |= i_origDataBuf; - } - // AND operation - else if (fapi::CHIP_OP_MODIFY_MODE_AND == i_modifyMode) - { - io_modifiedData &= i_origDataBuf; - } - // Must be XOR operation - else - { - io_modifiedData ^= i_origDataBuf; - } - - return; -} - -//****************************************************************************** -// platModifyCfamRegister function -//****************************************************************************** -fapi::ReturnCode platModifyCfamRegister(const fapi::Target& i_target, - const uint32_t i_address, - ecmdDataBufferBase& i_data, - const fapi::ChipOpModifyMode i_modifyMode) -{ - FAPI_DBG(ENTER_MRK "platModifyCfamRegister"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - - do - { - // Can't access cfam engine on master processor - l_err = verifyCfamAccessTarget(i_target,i_address); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - // Get the chip target if l_target is not a chip - TARGETING::Target* l_myChipTarget = NULL; - l_err = getCfamChipTarget(l_target, l_myChipTarget); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Read current value - // Address needs to be multiply by 4 because register addresses are word - // offsets but the FSI addresses are byte offsets. - // However, we need to preserve the engine's offset of 0x0C00 and 0x1000. - uint64_t l_addr = ((i_address & 0x003F) << 2) | (i_address & 0xFF00); - uint32_t l_data = 0; - size_t l_size = sizeof(uint32_t); - l_err = deviceRead(l_myChipTarget, - &l_data, - l_size, - DEVICE_FSI_ADDRESS(l_addr)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - // Applying modification - platProcess32BitModifyMode(i_modifyMode, i_data.getWord(0), l_data); - - // Write back - l_err = deviceWrite(l_target, - &l_data, - l_size, - DEVICE_FSI_ADDRESS(l_addr)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - } while (0); - - FAPI_DBG(EXIT_MRK "platModifyCfamRegister"); - return l_rc; -} - -//****************************************************************************** -// platGetRing function, the platform implementation -//****************************************************************************** -fapi::ReturnCode platGetRing(const fapi::Target& i_target, - const scanRingId_t i_address, - ecmdDataBufferBase & o_data, - const uint32_t i_ringMode) -{ - FAPI_DBG(ENTER_MRK "platGetRing"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - // Output buffer must be set to ring's len by user - uint64_t l_ringLen = o_data.getBitLength(); - uint64_t l_flag = platGetDDScanMode(i_ringMode); - size_t l_size = o_data.getByteLength(); - l_err = deviceRead(l_target, - ecmdDataBufferBaseImplementationHelper::getDataPtr(&o_data), - l_size, - DEVICE_SCAN_ADDRESS(i_address, l_ringLen, l_flag)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - - FAPI_DBG(EXIT_MRK "platGetRing"); - return l_rc; -} - -//****************************************************************************** -// platPutRing function -//****************************************************************************** -fapi::ReturnCode platPutRing(const fapi::Target& i_target, - const scanRingId_t i_address, - ecmdDataBufferBase & i_data, - const uint32_t i_ringMode) -{ - - FAPI_DBG(ENTER_MRK "platPutRing"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - // Output buffer must be set to ring's len by user - uint64_t l_ringLen = i_data.getBitLength(); - uint64_t l_flag = platGetDDScanMode(i_ringMode); - size_t l_size = i_data.getByteLength(); - l_err = deviceWrite(l_target, - ecmdDataBufferBaseImplementationHelper::getDataPtr(&i_data), - l_size, - DEVICE_SCAN_ADDRESS(i_address, l_ringLen, l_flag)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - - FAPI_DBG(EXIT_MRK "platPutRing"); - return l_rc; -} - -//****************************************************************************** -// platModifyRing function -//****************************************************************************** -fapi::ReturnCode platModifyRing(const fapi::Target& i_target, - const scanRingId_t i_address, - ecmdDataBufferBase & i_data, - const fapi::ChipOpModifyMode i_modifyMode, - const uint32_t i_ringMode) -{ - FAPI_DBG(ENTER_MRK "platModifyRing"); - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - uint32_t l_ecmdRc = ECMD_DBUF_SUCCESS; - - do - { - // Extract the component pointer - TARGETING::Target* l_target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - // -------------------- - // Read current value - // -------------------- - uint64_t l_ringLen = i_data.getBitLength(); - ecmdDataBufferBase l_modifiedRingBuffer(l_ringLen); - uint64_t l_flag = platGetDDScanMode(i_ringMode); - size_t l_size = l_modifiedRingBuffer.getByteLength(); - l_err = deviceRead(l_target, - ecmdDataBufferBaseImplementationHelper::getDataPtr( - &l_modifiedRingBuffer), - l_size, - DEVICE_SCAN_ADDRESS(i_address, l_ringLen, l_flag)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - - // ---------------------- - // Applying modification - // ---------------------- - if (fapi::CHIP_OP_MODIFY_MODE_OR == i_modifyMode) - { - l_ecmdRc = l_modifiedRingBuffer.setOr(i_data, 0, l_ringLen); - } - else if (fapi::CHIP_OP_MODIFY_MODE_AND == i_modifyMode) - { - l_ecmdRc = l_modifiedRingBuffer.setAnd(i_data, 0, l_ringLen); - } - else - { - l_ecmdRc = l_modifiedRingBuffer.setXor(i_data, 0, l_ringLen); - } - - if (l_ecmdRc) - { - FAPI_ERR("platModifyRing: ecmdDataBufferBase operation returns error, ecmdRc 0x%.8X", - l_ecmdRc); - l_rc.setEcmdError(l_ecmdRc); - break; - } - - // --------------- - // Write back - // --------------- - l_err = deviceWrite(l_target, - ecmdDataBufferBaseImplementationHelper::getDataPtr( - &l_modifiedRingBuffer), - l_size, - DEVICE_SCAN_ADDRESS(i_address, l_ringLen, l_flag)); - if (l_err) - { - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - } - - } while (0); - - FAPI_DBG(EXIT_MRK "platModifyRing"); - return l_rc; -} - -//****************************************************************************** -// platPutRing function -//****************************************************************************** -uint64_t platGetDDScanMode(const uint32_t i_ringMode) -{ - fapi::ReturnCode l_rc; - uint32_t l_scanMode = 0; - - // Set Pulse - if (i_ringMode & fapi::RING_MODE_SET_PULSE) - { - l_scanMode |= SCAN::SET_PULSE; - } - - // Header Check - if (i_ringMode & fapi::RING_MODE_NO_HEADER_CHECK) - { - l_scanMode |= SCAN::NO_HEADER_CHECK; - } - - return l_scanMode; -} - - - -} // extern "C" diff --git a/src/usr/hwpf/plat/fapiPlatHwpInvoker.C b/src/usr/hwpf/plat/fapiPlatHwpInvoker.C deleted file mode 100644 index 09a2815df..000000000 --- a/src/usr/hwpf/plat/fapiPlatHwpInvoker.C +++ /dev/null @@ -1,784 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatHwpInvoker.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ -/* [+] 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 fapiPlatHwpInvoker.C - * - * @brief Implements the fapiRcToErrl function. - */ - -#include <fapiTarget.H> -#include <fapiReturnCode.H> -#include <fapiSystemConfig.H> -#include <fapiPlatTrace.H> -#include <fapiErrorInfo.H> -#include <isteps/hwpf_reasoncodes.H> -#include <errl/errlentry.H> -#include <targeting/common/utilFilter.H> - -namespace fapi -{ - -/** - * @brief Translates a FAPI callout priority to an HWAS callout priority - * - * @param[i] i_fapiPri FAPI callout priority - * - * @return HWAS callout priority - */ -HWAS::callOutPriority xlateCalloutPriority( - const fapi::CalloutPriorities::CalloutPriority i_fapiPri) -{ - // Use the CalloutPriority enum value as an index - HWAS::callOutPriority l_priority = HWAS::SRCI_PRIORITY_HIGH; - size_t l_index = i_fapiPri; - - const HWAS::callOutPriority HWAS_PRI[] = {HWAS::SRCI_PRIORITY_LOW, - HWAS::SRCI_PRIORITY_MED, - HWAS::SRCI_PRIORITY_HIGH}; - - if (l_index < (sizeof(HWAS_PRI)/sizeof(HWAS::callOutPriority))) - { - l_priority = HWAS_PRI[l_index]; - } - else - { - FAPI_ERR("fapi::xlateCalloutPriority: Unknown priority 0x%x, assuming HIGH", - i_fapiPri); - } - - return l_priority; -} - -/** - * @brief Translates a FAPI Clock HW callout to an HWAS clock callout - * - * @param[i] i_fapiClock FAPI Clock HW callout - * - * @return HWAS Clock HW callout - */ -HWAS::clockTypeEnum xlateClockHwCallout( - const fapi::HwCallouts::HwCallout i_fapiClock) -{ - // Use the HwCallout enum value as an index - HWAS::clockTypeEnum l_clock = HWAS::TODCLK_TYPE; - size_t l_index = i_fapiClock; - - const HWAS::clockTypeEnum HWAS_CLOCK[] = { - HWAS::TODCLK_TYPE, - HWAS::MEMCLK_TYPE, - HWAS::OSCREFCLK_TYPE, - HWAS::OSCPCICLK_TYPE}; - - if (l_index < (sizeof(HWAS_CLOCK)/sizeof(HWAS::clockTypeEnum))) - { - l_clock = HWAS_CLOCK[l_index]; - } - else - { - FAPI_ERR("fapi::xlateClockHwCallout: Unknown clock 0x%x, assuming TOD", - i_fapiClock); - } - - return l_clock; -} - -/** - * @brief Translates a FAPI Part HW callout to an HWAS part callout - * - * @param[i] i_fapiPart FAPI part HW callout - * - * @return HWAS part HW callout - */ -HWAS::partTypeEnum xlatePartHwCallout( - const fapi::HwCallouts::HwCallout i_fapiPart) -{ - // Use the HwCallout enum value as an index - HWAS::partTypeEnum l_part; - - // clock xlate function above assumes indexes match - // between 2 enums. seems better to do it explicitly - - switch (i_fapiPart) - { - case HwCallouts::FLASH_CONTROLLER_PART: - l_part = HWAS::FLASH_CONTROLLER_PART_TYPE; - break; - case HwCallouts::PNOR_PART: - l_part = HWAS::PNOR_PART_TYPE; - break; - case HwCallouts::SBE_SEEPROM_PART: - l_part = HWAS::SBE_SEEPROM_PART_TYPE; - break; - case HwCallouts::VPD_PART: - l_part = HWAS::VPD_PART_TYPE; - break; - case HwCallouts::LPC_SLAVE_PART: - l_part = HWAS::LPC_SLAVE_PART_TYPE; - break; - case HwCallouts::GPIO_EXPANDER_PART: - l_part = HWAS::GPIO_EXPANDER_PART_TYPE; - break; - case HwCallouts::SPIVID_SLAVE_PART: - l_part = HWAS::SPIVID_SLAVE_PART_TYPE; - break; - - default: - FAPI_ERR("fapi::xlatePartHwCallout: Unknown part", - i_fapiPart); - l_part = HWAS::NO_PART_TYPE; - } - - return l_part; -} -/** - * @brief Translates a FAPI procedure callout to an HWAS procedure callout - * - * @param[i] i_fapiProc FAPI procedure callout - * - * @return HWAS procedure callout - */ -HWAS::epubProcedureID xlateProcedureCallout( - const fapi::ProcedureCallouts::ProcedureCallout i_fapiProc) -{ - // Use the ProcedureCallout enum value as an index - HWAS::epubProcedureID l_proc = HWAS::EPUB_PRC_HB_CODE; - size_t l_index = i_fapiProc; - - const HWAS::epubProcedureID HWAS_PROC[] = { - HWAS::EPUB_PRC_HB_CODE, - HWAS::EPUB_PRC_LVL_SUPP, - HWAS::EPUB_PRC_MEMORY_PLUGGING_ERROR, - HWAS::EPUB_PRC_EIBUS_ERROR}; - - if (l_index < (sizeof(HWAS_PROC)/sizeof(HWAS::epubProcedureID))) - { - l_proc = HWAS_PROC[l_index]; - } - else - { - FAPI_ERR("fapi::xlateProcedureCallout: Unknown proc 0x%x, assuming CODE", - i_fapiProc); - } - - return l_proc; -} - -/** - * @brief Translates a FAPI target type to a Targeting target type - * - * @param[i] i_targetType FAPI target type - * @param[o] o_class Targeting class - * @param[o] o_type Targeting type - */ -void xlateTargetType(const fapi::TargetType i_targetType, - TARGETING::CLASS & o_class, - TARGETING::TYPE & o_type) -{ - switch (i_targetType) - { - case fapi::TARGET_TYPE_SYSTEM: - o_class = TARGETING::CLASS_SYS; - o_type = TARGETING::TYPE_SYS; - break; - case fapi::TARGET_TYPE_DIMM: - o_class = TARGETING::CLASS_LOGICAL_CARD; - o_type = TARGETING::TYPE_DIMM; - break; - case fapi::TARGET_TYPE_PROC_CHIP: - o_class = TARGETING::CLASS_CHIP; - o_type = TARGETING::TYPE_PROC; - break; - case fapi::TARGET_TYPE_MEMBUF_CHIP: - o_class = TARGETING::CLASS_CHIP; - o_type = TARGETING::TYPE_MEMBUF; - break; - case fapi::TARGET_TYPE_EX_CHIPLET: - o_class = TARGETING::CLASS_UNIT; - o_type = TARGETING::TYPE_EX; - break; - case fapi::TARGET_TYPE_MBA_CHIPLET: - o_class = TARGETING::CLASS_UNIT; - o_type = TARGETING::TYPE_MBA; - break; - case fapi::TARGET_TYPE_MCS_CHIPLET: - o_class = TARGETING::CLASS_UNIT; - o_type = TARGETING::TYPE_MCS; - break; - case fapi::TARGET_TYPE_XBUS_ENDPOINT: - o_class = TARGETING::CLASS_UNIT; - o_type = TARGETING::TYPE_XBUS; - break; - case fapi::TARGET_TYPE_ABUS_ENDPOINT: - o_class = TARGETING::CLASS_UNIT; - o_type = TARGETING::TYPE_ABUS; - break; - case fapi::TARGET_TYPE_L4: - o_class = TARGETING::CLASS_UNIT; - o_type = TARGETING::TYPE_L4; - break; - default: - o_class = TARGETING::CLASS_NA; - o_type = TARGETING::TYPE_NA; - } -} - -/** - * @brief Processes any FFDC in the ReturnCode Error Information and adds them - * to the error log - * - * @param[i] i_errInfo Reference to ReturnCode Error Information - * @param[io] io_pError Errorlog Handle - */ -void processEIFfdcs(const ErrorInfo & i_errInfo, - errlHndl_t io_pError) -{ - // Iterate through the FFDC sections, adding each to the error log - uint32_t l_size = 0; - - for (ErrorInfo::ErrorInfoFfdcCItr_t l_itr = i_errInfo.iv_ffdcs.begin(); - l_itr != i_errInfo.iv_ffdcs.end(); ++l_itr) - { - const void * l_pFfdc = (*l_itr)->getData(l_size); - uint32_t l_ffdcId = (*l_itr)->getFfdcId(); - - // Add the FFDC ID as the first word, then the FFDC data - FAPI_DBG("processEIFfdcs: Adding %d bytes of FFDC (id:0x%08x)", l_size, - l_ffdcId); - ERRORLOG::ErrlUD * l_pUD = io_pError->addFFDC( - HWPF_COMP_ID, &l_ffdcId, sizeof(l_ffdcId), 1, HWPF_UDT_HWP_FFDC); - - if (l_pUD) - { - io_pError->appendToFFDC(l_pUD, l_pFfdc, l_size); - } - } -} - -/** - * @brief Processes any HW callouts requests in the ReturnCode Error - * Information and adds them to the error log - * - * @param[i] i_errInfo Reference to ReturnCode Error Information - * @param[io] io_pError Errorlog Handle - */ -void processEIHwCallouts(const ErrorInfo & i_errInfo, - errlHndl_t io_pError) -{ - // Iterate through the HW callout requests, adding each to the error log - for (ErrorInfo::ErrorInfoHwCalloutCItr_t l_itr = - i_errInfo.iv_hwCallouts.begin(); - l_itr != i_errInfo.iv_hwCallouts.end(); ++l_itr) - { - HWAS::callOutPriority l_priority = - xlateCalloutPriority((*l_itr)->iv_calloutPriority); - - HwCallouts::HwCallout l_hw = ((*l_itr)->iv_hw); - - TARGETING::Target * l_pRefTarget = - reinterpret_cast<TARGETING::Target*>((*l_itr)->iv_refTarget.get()); - - if ( ((l_hw == HwCallouts::TOD_CLOCK) || - (l_hw == HwCallouts::MEM_REF_CLOCK) || - (l_hw == HwCallouts::PROC_REF_CLOCK) || - (l_hw == HwCallouts::PCI_REF_CLOCK)) && - l_pRefTarget != NULL) - { - HWAS::clockTypeEnum l_clock = - xlateClockHwCallout((*l_itr)->iv_hw); - - FAPI_ERR("processEIHwCallouts: Adding clock-callout" - " (clock:%d, pri:%d)", - l_clock, l_priority); - - //@fixme-RTC:127069-add native support to deconfig/gard clocks - // Force PCI clocks to be deconfigured and garded - if( l_hw == HwCallouts::PCI_REF_CLOCK ) - { - io_pError->addClockCallout(l_pRefTarget, - l_clock, - l_priority, - HWAS::DECONFIG, - HWAS::GARD_Predictive); - } - else - { - io_pError->addClockCallout(l_pRefTarget, l_clock, l_priority); - } - } - else if ( (l_hw == HwCallouts::FLASH_CONTROLLER_PART) || - (l_hw == HwCallouts::PNOR_PART) || - (l_hw == HwCallouts::SBE_SEEPROM_PART) || - (l_hw == HwCallouts::VPD_PART) || - (l_hw == HwCallouts::LPC_SLAVE_PART) || - (l_hw == HwCallouts::GPIO_EXPANDER_PART) || - (l_hw == HwCallouts::SPIVID_SLAVE_PART) ) - { - HWAS::partTypeEnum l_part = - xlatePartHwCallout((*l_itr)->iv_hw); - - FAPI_ERR("processEIHwCallouts: Adding part-callout" - " (part:%d, pri:%d)", - l_part, l_priority); - io_pError->addPartCallout(l_pRefTarget, l_part, l_priority); - } - else - { - FAPI_ERR("processEIHwCallouts: Unsupported HW callout (%d)", l_hw); - io_pError->addPartCallout(l_pRefTarget, HWAS::NO_PART_TYPE, - l_priority); - io_pError->addProcedureCallout( HWAS::EPUB_PRC_HB_CODE, l_priority); - } - } -} - -/** - * @brief Processes any Procedure callouts requests in the ReturnCode Error - * Information and adds them to the error log - * - * @param[i] i_errInfo Reference to ReturnCode Error Information - * @param[io] io_pError Errorlog Handle - */ -void processEIProcCallouts(const ErrorInfo & i_errInfo, - errlHndl_t io_pError) -{ - // Iterate through the procedure callout requests, adding each to the error - // log - for (ErrorInfo::ErrorInfoProcedureCalloutCItr_t l_itr = - i_errInfo.iv_procedureCallouts.begin(); - l_itr != i_errInfo.iv_procedureCallouts.end(); ++l_itr) - { - HWAS::epubProcedureID l_procedure = - xlateProcedureCallout((*l_itr)->iv_procedure); - - HWAS::callOutPriority l_priority = - xlateCalloutPriority((*l_itr)->iv_calloutPriority); - - FAPI_DBG("processEIProcCallouts: Adding proc-callout" - " (proc:0x%02x, pri:%d)", - l_procedure, l_priority); - io_pError->addProcedureCallout(l_procedure, l_priority); - } -} - -/** - * @brief Processes any Bus callouts requests in the ReturnCode Error - * Information and adds them to the error log - * - * @param[i] i_errInfo Reference to ReturnCode Error Information - * @param[io] io_pError Errorlog Handle - */ -void processEIBusCallouts(const ErrorInfo & i_errInfo, - errlHndl_t io_pError) -{ - // Iterate through the bus callout requests, adding each to the error log - for (ErrorInfo::ErrorInfoBusCalloutCItr_t l_itr = - i_errInfo.iv_busCallouts.begin(); - l_itr != i_errInfo.iv_busCallouts.end(); ++l_itr) - { - TARGETING::Target * l_pTarget1 = - reinterpret_cast<TARGETING::Target*>((*l_itr)->iv_target1.get()); - - TARGETING::Target * l_pTarget2 = - reinterpret_cast<TARGETING::Target*>((*l_itr)->iv_target2.get()); - - HWAS::callOutPriority l_priority = - xlateCalloutPriority((*l_itr)->iv_calloutPriority); - - bool l_busTypeValid = true; - HWAS::busTypeEnum l_busType = HWAS::FSI_BUS_TYPE; - TARGETING::TYPE l_type1 = l_pTarget1->getAttr<TARGETING::ATTR_TYPE>(); - TARGETING::TYPE l_type2 = l_pTarget2->getAttr<TARGETING::ATTR_TYPE>(); - - if ( ((l_type1 == TARGETING::TYPE_MCS) && - (l_type2 == TARGETING::TYPE_MEMBUF)) || - ((l_type1 == TARGETING::TYPE_MEMBUF) && - (l_type2 == TARGETING::TYPE_MCS)) ) - { - l_busType = HWAS::DMI_BUS_TYPE; - } - else if ((l_type1 == TARGETING::TYPE_ABUS) && - (l_type2 == TARGETING::TYPE_ABUS)) - { - l_busType = HWAS::A_BUS_TYPE; - } - else if ((l_type1 == TARGETING::TYPE_XBUS) && - (l_type2 == TARGETING::TYPE_XBUS)) - { - l_busType = HWAS::X_BUS_TYPE; - } - else - { - FAPI_ERR("processEIBusCallouts: Bus between target types not known (0x%08x:0x%08x)", - l_type1, l_type2); - l_busTypeValid = false; - } - - if (l_busTypeValid) - { - FAPI_DBG("processEIBusCallouts: Adding bus-callout" - " (bus:%d, pri:%d)", - l_busType, l_priority); - io_pError->addBusCallout(l_pTarget1, l_pTarget2, l_busType, - l_priority); - } - } -} - -/** - * @brief Processes any Callout/Deconfigure/GARD requests in the ReturnCode Error - * Information and adds them to the error log - * - * @param[i] i_errInfo Reference to ReturnCode Error Information - * @param[io] io_pError Errorlog Handle - */ -void processEICDGs(const ErrorInfo & i_errInfo, - errlHndl_t io_pError) -{ - // Iterate through the CGD requests, adding each to the error log - for (ErrorInfo::ErrorInfoCDGCItr_t l_itr = i_errInfo.iv_CDGs.begin(); - l_itr != i_errInfo.iv_CDGs.end(); ++l_itr) - { - TARGETING::Target * l_pTarget = - reinterpret_cast<TARGETING::Target*>((*l_itr)->iv_target.get()); - - HWAS::callOutPriority l_priority = - xlateCalloutPriority((*l_itr)->iv_calloutPriority); - - HWAS::DeconfigEnum l_deconfig = HWAS::NO_DECONFIG; - if ((*l_itr)->iv_deconfigure) - { - l_deconfig = HWAS::DELAYED_DECONFIG; - } - - HWAS::GARD_ErrorType l_gard = HWAS::GARD_NULL; - if ((*l_itr)->iv_gard) - { - l_gard = HWAS::GARD_Unrecoverable; - } - - FAPI_DBG("processEICDGs: Calling out target" - " (huid:%.8x, pri:%d, deconf:%d, gard:%d)", - TARGETING::get_huid(l_pTarget), l_priority, l_deconfig, - l_gard); - io_pError->addHwCallout(l_pTarget, l_priority, l_deconfig, l_gard); - } -} - -/** - * @brief Returns child targets to Callout/Deconfigure/GARD - * - * @param[i] i_parentTarget FAPI Parent Target - * @param[i] i_childType FAPI Child Type - * @param[i] i_childPort Child Port Number - * For DIMMs: MBA Port Number - * Else unused - * @param[i] i_childNum Child Number - * For DIMMs: DIMM Socket Number - * For Chips: Chip Position - * For Chiplets: Chiplet Position - */ -void getChildTargetsForCDG(const fapi::Target & i_parentTarget, - const fapi::TargetType i_childType, - const uint8_t i_childPort, - const uint8_t i_childNum, - TARGETING::TargetHandleList & o_childTargets) -{ - o_childTargets.clear(); - - do - { - // Get the parent TARGETING::Target - TARGETING::Target * l_pTargParent = - reinterpret_cast<TARGETING::Target *>(i_parentTarget.get()); - - if (l_pTargParent == NULL) - { - FAPI_ERR("getChildTargetsForCDG: NULL Target pointer"); - break; - } - - // Find if the child target type is a dimm, chip or chiplet - bool l_childIsDimm = false; - bool l_childIsChip = false; - bool l_childIsChiplet = false; - - if (i_childType == fapi::TARGET_TYPE_DIMM) - { - l_childIsDimm = true; - } - else - { - l_childIsChip = fapi::Target::isChip(i_childType); - - if (!l_childIsChip) - { - l_childIsChiplet = fapi::Target::isChiplet(i_childType); - } - } - - // Translate the FAPI child target type into TARGETING Class/Type - TARGETING::CLASS l_targChildClass = TARGETING::CLASS_NA; - TARGETING::TYPE l_targChildType = TARGETING::TYPE_NA; - xlateTargetType(i_childType, l_targChildClass, l_targChildType); - - if (l_targChildType == TARGETING::TYPE_NA) - { - FAPI_ERR("getChildTargetsForCDG: Could not xlate child type (0x%08x)", - i_childType); - break; - } - - // Get the child targets - TARGETING::TargetHandleList l_targChildList; - - if (fapi::Target::isPhysParentChild(i_parentTarget.getType(), - i_childType)) - { - // Child by containment - TARGETING::getChildChiplets(l_targChildList, l_pTargParent, - l_targChildType); - FAPI_ERR("getChildTargetsForCDG: Got %d candidate children by containment", - l_targChildList.size()); - } - else - { - // Assumption is child by affinity - TARGETING::getChildAffinityTargets(l_targChildList, l_pTargParent, - l_targChildClass, - l_targChildType); - FAPI_ERR("getChildTargetsForCDG: Got %d candidate children by affinity", - l_targChildList.size()); - } - - // Filter out child targets based on type and input port/number - for (TARGETING::TargetHandleList::const_iterator - l_itr = l_targChildList.begin(); - l_itr != l_targChildList.end(); ++l_itr) - { - if (l_childIsDimm) - { - // Match i_childPort and i_childNum - if ( ((i_childPort == ErrorInfoChildrenCDG::ALL_CHILD_PORTS) || - (i_childPort == - (*l_itr)->getAttr<TARGETING::ATTR_MBA_PORT>())) - && - ((i_childNum == ErrorInfoChildrenCDG::ALL_CHILD_NUMBERS) || - (i_childNum == - (*l_itr)->getAttr<TARGETING::ATTR_MBA_DIMM>())) ) - { - o_childTargets.push_back(*l_itr); - } - } - else if (l_childIsChip) - { - // Match i_childNum - if ((i_childNum == ErrorInfoChildrenCDG::ALL_CHILD_NUMBERS) || - (i_childNum == - (*l_itr)->getAttr<TARGETING::ATTR_POSITION>())) - { - o_childTargets.push_back(*l_itr); - } - } - else if (l_childIsChiplet) - { - // Match i_childNum - if ((i_childNum == ErrorInfoChildrenCDG::ALL_CHILD_NUMBERS) || - (i_childNum == - (*l_itr)->getAttr<TARGETING::ATTR_CHIP_UNIT>())) - { - o_childTargets.push_back(*l_itr); - } - } - else - { - // Do not match on anything - o_childTargets.push_back(*l_itr); - } - } - } while(0); -} - -/** - * @brief Processes any Children Callout/Deconfigure/GARD requests in the - * ReturnCode Error Information and adds them to the error log - * - * @param[i] i_errInfo Reference to ReturnCode Error Information - * @param[io] io_pError Errorlog Handle - */ -void processEIChildrenCDGs(const ErrorInfo & i_errInfo, - errlHndl_t io_pError) -{ - // Iterate through the Child CGD requests, adding each to the error log - for (ErrorInfo::ErrorInfoChildrenCDGCItr_t l_itr = - i_errInfo.iv_childrenCDGs.begin(); - l_itr != i_errInfo.iv_childrenCDGs.end(); ++l_itr) - { - HWAS::callOutPriority l_priority = - xlateCalloutPriority((*l_itr)->iv_calloutPriority); - - HWAS::DeconfigEnum l_deconfig = HWAS::NO_DECONFIG; - if ((*l_itr)->iv_deconfigure) - { - l_deconfig = HWAS::DELAYED_DECONFIG; - } - - HWAS::GARD_ErrorType l_gard = HWAS::GARD_NULL; - if ((*l_itr)->iv_gard) - { - l_gard = HWAS::GARD_Unrecoverable; - } - - // Get a list of children to callout - TARGETING::TargetHandleList l_children; - getChildTargetsForCDG((*l_itr)->iv_parent, - (*l_itr)->iv_childType, - (*l_itr)->iv_childPort, - (*l_itr)->iv_childNumber, - l_children); - - // Callout/Deconfigure/GARD each child as appropriate - for (TARGETING::TargetHandleList::const_iterator - l_itr = l_children.begin(); - l_itr != l_children.end(); ++l_itr) - { - FAPI_DBG("processEIChildrenCDGs: Calling out target" - " (huid:%.8x, pri:%d, deconf:%d, gard:%d)", - TARGETING::get_huid(*l_itr), l_priority, l_deconfig, - l_gard); - io_pError->addHwCallout(*l_itr, l_priority, l_deconfig, l_gard); - } - } -} - -//****************************************************************************** -// fapiRcToErrl function. Converts a fapi::ReturnCode to an error log -//****************************************************************************** -errlHndl_t fapiRcToErrl(ReturnCode & io_rc, - ERRORLOG::errlSeverity_t i_sev) -{ - errlHndl_t l_pError = NULL; - - if (io_rc) - { - // ReturnCode contains an error. Find out which component of the HWPF - // created the error - ReturnCode::returnCodeCreator l_creator = io_rc.getCreator(); - - if (l_creator == ReturnCode::CREATOR_PLAT) - { - // PLAT error. Release the errlHndl_t - FAPI_ERR("fapiRcToErrl: PLAT error: 0x%08x", - static_cast<uint32_t>(io_rc)); - l_pError = reinterpret_cast<errlHndl_t> (io_rc.releasePlatData()); - } - else if (l_creator == ReturnCode::CREATOR_HWP) - { - // HWP Error. Create an error log - uint32_t l_rcValue = static_cast<uint32_t>(io_rc); - FAPI_ERR("fapiRcToErrl: HWP error: 0x%08x", l_rcValue); - - /*@ - * @errortype - * @moduleid MOD_HWP_RC_TO_ERRL - * @reasoncode RC_HWP_GENERATED_ERROR - * @userdata1 RC value from HWP - * @userdata2 <unused> - * @devdesc HW Procedure generated error. See User Data. - * @custdesc Error initializing processor/memory subsystem - * during boot. See FRU list for repair actions - */ - l_pError = new ERRORLOG::ErrlEntry(i_sev, - MOD_HWP_RC_TO_ERRL, - RC_HWP_GENERATED_ERROR, - TO_UINT64(l_rcValue)); - - // Add the rcValue as FFDC. This will explain what the error was - l_pError->addFFDC(HWPF_COMP_ID, &l_rcValue, sizeof(l_rcValue), 1, - HWPF_UDT_HWP_RCVALUE); - - // Get the Error Information Pointer - const ErrorInfo * l_pErrorInfo = io_rc.getErrorInfo(); - - if (l_pErrorInfo) - { - // There is error information associated with the ReturnCode - processEIFfdcs(*l_pErrorInfo, l_pError); - processEIProcCallouts(*l_pErrorInfo, l_pError); - processEIBusCallouts(*l_pErrorInfo, l_pError); - processEICDGs(*l_pErrorInfo, l_pError); - processEIChildrenCDGs(*l_pErrorInfo, l_pError); - processEIHwCallouts(*l_pErrorInfo, l_pError); - } - else - { - FAPI_ERR("fapiRcToErrl: No Error Information"); - } - } - else - { - // FAPI error. Create an error log - FAPI_ERR("fapiRcToErrl: FAPI error: 0x%08x", - static_cast<uint32_t>(io_rc)); - - // The errlog reason code is the HWPF compID and the rcValue LSB - uint32_t l_rcValue = static_cast<uint32_t>(io_rc); - uint16_t l_reasonCode = l_rcValue; - l_reasonCode &= 0xff; - l_reasonCode |= HWPF_COMP_ID; - - // HostBoot errlog tags for FAPI errors are in hwpfReasonCodes.H - l_pError = new ERRORLOG::ErrlEntry(i_sev, - MOD_FAPI_RC_TO_ERRL, - l_reasonCode); - - // FAPI may have added Error Information. - // Get the Error Information Pointer - const ErrorInfo * l_pErrorInfo = io_rc.getErrorInfo(); - - if (l_pErrorInfo) - { - processEIFfdcs(*l_pErrorInfo, l_pError); - processEIProcCallouts(*l_pErrorInfo, l_pError); - processEIBusCallouts(*l_pErrorInfo, l_pError); - processEICDGs(*l_pErrorInfo, l_pError); - processEIChildrenCDGs(*l_pErrorInfo, l_pError); - processEIHwCallouts(*l_pErrorInfo, l_pError); - } - } - - // Set the ReturnCode to success, this will delete any ErrorInfo or PLAT - // DATA associated with the ReturnCode - io_rc = FAPI_RC_SUCCESS; - - // add the fapi traces to the elog - l_pError->collectTrace(FAPI_TRACE_NAME, 256 ); - l_pError->collectTrace(FAPI_IMP_TRACE_NAME, 384 ); - l_pError->collectTrace(FAPI_SCAN_TRACE_NAME, 256 ); - } - - return l_pError; -} - -} // End namespace diff --git a/src/usr/hwpf/plat/fapiPlatMBvpdAccess.C b/src/usr/hwpf/plat/fapiPlatMBvpdAccess.C deleted file mode 100644 index 184093b4b..000000000 --- a/src/usr/hwpf/plat/fapiPlatMBvpdAccess.C +++ /dev/null @@ -1,358 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatMBvpdAccess.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2013,2015 */ -/* [+] 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 fapiPlatMBvpdAccess.C - * - * @brief Implements the fapiMBvpdAccess.H functions - */ - -#include <stdint.h> -#include <errl/errlentry.H> - -// fapi support -#include <isteps/hwpf_reasoncodes.H> -#include <fapiMBvpdAccess.H> - -// MBVPD -#include <devicefw/userif.H> -#include <vpd/cvpdenums.H> - - -namespace fapi -{ - -//****************************************************************************** -// MBvpdRecordXlate -// Translates a FAPI MBVPD Record enumerator into a Hostboot MBVPD Record -// enumerator -//****************************************************************************** -fapi::ReturnCode MBvpdRecordXlate(const fapi::MBvpdRecord i_fapiRecord, - CVPD::cvpdRecord & o_hbRecord) -{ - // Create a lookup table for converting a FAPI MBVPD record enumerator to a - // Hostboot CVPD record enumerator. This is a simple array and relies on - // the FAPI record enumerators starting at zero and incrementing. - static const CVPD::cvpdRecord - mbvpdFapiRecordToHbRecord[] = - { - CVPD::VEIR, - CVPD::VER0, - CVPD::MER0, - CVPD::VSPD, - CVPD::VINI, - CVPD::OPFR, - CVPD::VNDR, - CVPD::SPDX, - }; - const uint8_t NUM_MBVPD_RECORDS = - sizeof(mbvpdFapiRecordToHbRecord)/sizeof(mbvpdFapiRecordToHbRecord[0]); - - fapi::ReturnCode l_rc; - - uint8_t l_index = static_cast<uint8_t>(i_fapiRecord); - - if (l_index >= NUM_MBVPD_RECORDS) - { - FAPI_ERR("MBvpdRecordXlate: Invalid MBVPD Record: 0x%x", i_fapiRecord); - /*@ - * @errortype - * @moduleid MOD_MBVPD_ACCESS - * @reasoncode RC_INVALID_RECORD - * @userdata1 Record enumerator - * @devdesc Attempt to read an MVPD field using an invalid record - */ - const bool hbSwError = true; - errlHndl_t l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - MOD_MBVPD_ACCESS, - RC_INVALID_RECORD, - i_fapiRecord, 0, hbSwError); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - } - else - { - o_hbRecord = mbvpdFapiRecordToHbRecord[l_index]; - } - - return l_rc; -} - -//****************************************************************************** -// MBvpdKeywordXlate -// Translates a FAPI MBVPD Keyword enumerator into a Hostboot CVPD Keyword -// enumerator -//****************************************************************************** -fapi::ReturnCode MBvpdKeywordXlate(const fapi::MBvpdKeyword i_fapiKeyword, - CVPD::cvpdKeyword & o_hbKeyword) -{ - // Create a lookup table for converting a FAPI MBVPD keyword enumerator to a - // Hostboot CVPD keyword enumerator. This is a simple array and relies on - // the FAPI record enumerators starting at zero and incrementing. - static const CVPD::cvpdKeyword - mbvpdFapiKeywordToHbKeyword[] = - { - CVPD::pdI, - CVPD::PF, - CVPD::MT, - CVPD::MR, - CVPD::pdA, - CVPD::EL, - CVPD::LM, - CVPD::MW, - CVPD::MV, - CVPD::AM, - CVPD::VZ, - CVPD::pdD, - CVPD::MX, - CVPD::DW, - CVPD::PN, - CVPD::SN, - CVPD::DR, - CVPD::CE, - CVPD::FN, - CVPD::CC, - CVPD::HE, - CVPD::CT, - CVPD::HW, - CVPD::VD, - CVPD::VN, - CVPD::VP, - CVPD::VS, - CVPD::M0, - CVPD::M1, - CVPD::M2, - CVPD::M3, - CVPD::M4, - CVPD::M5, - CVPD::M6, - CVPD::M7, - CVPD::M8, - CVPD::T1, - CVPD::T2, - CVPD::T4, - CVPD::T5, - CVPD::T6, - CVPD::T8, - CVPD::Q0, - CVPD::Q1, - CVPD::Q2, - CVPD::Q3, - CVPD::Q4, - CVPD::Q5, - CVPD::Q6, - CVPD::Q7, - CVPD::Q8, - CVPD::K0, - CVPD::K1, - CVPD::K2, - CVPD::K3, - CVPD::K4, - CVPD::K5, - CVPD::K6, - CVPD::K7, - CVPD::K8, - CVPD::MM, - CVPD::SS, - CVPD::ET, - CVPD::VM, - CVPD::pd1, - CVPD::pdZ, - CVPD::pd4, - CVPD::pd5, - CVPD::pd6, - CVPD::pd8, - CVPD::pdY, - }; - const uint8_t NUM_MBVPD_KEYWORDS = - sizeof(mbvpdFapiKeywordToHbKeyword)/sizeof(mbvpdFapiKeywordToHbKeyword[0]); - - fapi::ReturnCode l_rc; - - uint8_t l_index = static_cast<uint8_t>(i_fapiKeyword); - - if (l_index >= NUM_MBVPD_KEYWORDS) - { - FAPI_ERR("MbvpdKeywordXlate: Invalid MVPD Keyword: 0x%x", - i_fapiKeyword); - /*@ - * @errortype - * @moduleid MOD_MBVPD_ACCESS - * @reasoncode RC_INVALID_KEYWORD - * @userdata1 Keyword enumerator - * @devdesc Attempt to read an MVPD field using an invalid keyword - */ - const bool hbSwError = true; - errlHndl_t l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - MOD_MBVPD_ACCESS, - RC_INVALID_KEYWORD, - i_fapiKeyword, 0, hbSwError); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - } - else - { - o_hbKeyword = mbvpdFapiKeywordToHbKeyword[l_index]; - } - - return l_rc; -} - -} - -extern "C" -{ - -//****************************************************************************** -// fapiGetMBvpdField -//****************************************************************************** -fapi::ReturnCode fapiGetMBvpdField(const fapi::MBvpdRecord i_record, - const fapi::MBvpdKeyword i_keyword, - const fapi::Target &i_memBufTarget, - uint8_t * const i_pBuffer, - uint32_t &io_fieldSize) -{ - fapi::ReturnCode l_rc; - FAPI_DBG("fapiGetMBvpdField entry"); - - do - { - // Translate the FAPI record to a Hostboot record - CVPD::cvpdRecord l_hbRecord = CVPD::CVPD_INVALID_RECORD; - - l_rc = fapi::MBvpdRecordXlate(i_record, l_hbRecord); - - if (l_rc) - { - break; - } - - // Translate the FAPI keyword to a Hostboot keyword - CVPD::cvpdKeyword l_hbKeyword = CVPD::CVPD_INVALID_KEYWORD; - - l_rc = fapi::MBvpdKeywordXlate(i_keyword, l_hbKeyword); - - if (l_rc) - { - break; - } - - // Similarly to this function, deviceRead will return the size of the - // field if the pointer is NULL - size_t l_fieldLen = io_fieldSize; - - errlHndl_t l_errl = deviceRead( - reinterpret_cast< TARGETING::Target*>(i_memBufTarget.get()), - i_pBuffer, - l_fieldLen, - DEVICE_CVPD_ADDRESS(l_hbRecord, l_hbKeyword)); - - if (l_errl) - { - FAPI_ERR("fapGetMBvpdField: ERROR: deviceRead : errorlog PLID=0x%x", - l_errl->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - - break; - } - - // Success, update callers io_fieldSize for the case where the pointer - // is NULL and deviceRead returned the actual size - io_fieldSize = l_fieldLen; - FAPI_DBG("fapGetMBvpdField: returning field len=0x%x", io_fieldSize); - - } while(0); - - FAPI_DBG( "fapGetMBvpdField: exit" ); - - return l_rc; -} - -//****************************************************************************** -// fapSetMBvpdField -//****************************************************************************** -fapi::ReturnCode fapiSetMBvpdField(const fapi::MBvpdRecord i_record, - const fapi::MBvpdKeyword i_keyword, - const fapi::Target &i_memBufTarget, - const uint8_t * const i_pBuffer, - const uint32_t i_fieldSize) -{ - fapi::ReturnCode l_rc; - FAPI_DBG("fapiSetMBvpdField entry"); - - do - { - // Translate the FAPI record to a Hostboot record - CVPD::cvpdRecord l_hbRecord = CVPD::CVPD_INVALID_RECORD; - - l_rc = fapi::MBvpdRecordXlate(i_record, l_hbRecord); - - if (l_rc) - { - break; - } - - // Translate the FAPI keyword to a Hostboot keyword - CVPD::cvpdKeyword l_hbKeyword = CVPD::CVPD_INVALID_KEYWORD; - - l_rc = fapi::MBvpdKeywordXlate(i_keyword, l_hbKeyword); - - if (l_rc) - { - break; - } - - size_t l_fieldLen = i_fieldSize; - - errlHndl_t l_errl = deviceWrite( - reinterpret_cast< TARGETING::Target*>(i_memBufTarget.get()), - const_cast<uint8_t *>(i_pBuffer), - l_fieldLen, - DEVICE_CVPD_ADDRESS(l_hbRecord, l_hbKeyword)); - - if (l_errl) - { - FAPI_ERR("fapSetMBvpdField: ERROR:deviceWrite : errorlog PLID=0x%x", - l_errl->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - - break; - } - - } while(0); - - FAPI_DBG( "fapSetMBvpdField: exit" ); - - return l_rc; -} - -} // extern "C" diff --git a/src/usr/hwpf/plat/fapiPlatMvpdAccess.C b/src/usr/hwpf/plat/fapiPlatMvpdAccess.C deleted file mode 100644 index ce2b5b6fc..000000000 --- a/src/usr/hwpf/plat/fapiPlatMvpdAccess.C +++ /dev/null @@ -1,1694 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatMvpdAccess.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2015 */ -/* [+] 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 fapiPlatMvpdAccess.C - * - * @brief Implements the fapiMvpdAccess.H functions - */ - -#include <stdint.h> -#include <errl/errlentry.H> -#include <freqVoltageSvc.H> - -// fapi support -#include <fapiAttributeService.H> -#include <fapiMvpdAccess.H> -#include <fapiSystemConfig.H> -#include <isteps/hwpf_reasoncodes.H> - -// MVPD -#include <devicefw/userif.H> -#include <vpd/mvpdenums.H> - -const uint8_t NON_ECO_VOLTAGE_BUCKET_OFFFSET = 0x04; -const uint8_t ALTERNATE_BUCKET_OFFSET = 0x05; -const uint8_t BUCKET_ID_MASK = 0x0F; -const uint8_t DEFAULT_BUCKET = 1; -const uint8_t VERSION_01_BUCKET_SZ = 0x33; // 51 decimal -const uint8_t POUND_V_VERSION_01 = 0x01; - -// Decimal 50 - 2 bytes for each 25 attributes. -const uint8_t MAX_MVPD_VOLTAGE_BUCKET_ATTR_SZ = 0x32; -// Two byte shift -const uint8_t MVPD_TWO_BYTE_ATTR_VAL_SHIFT = 0x10; -// Invalid chip unit -const uint8_t MVPD_INVALID_CHIP_UNIT = 0xFF; - -namespace fapi -{ - -//****************************************************************************** -// MvpdRecordXlate -// Translates a FAPI MVPD Record enumerator into a Hostboot MVPD Record -// enumerator -//****************************************************************************** -fapi::ReturnCode MvpdRecordXlate(const fapi::MvpdRecord i_fapiRecord, - MVPD::mvpdRecord & o_hbRecord, - uint8_t & o_chipUnitNum) -{ - // Create a lookup table for converting a FAPI MVPD record enumerator to a - // Hostboot MVPD record enumerator. This is a simple array and relies on - // the FAPI record enumerators starting at zero and incrementing. - - //Structure to map fapi::MVPD_RECORD to chiplet chip num position - struct mvpdRecordToChip - { - MVPD::mvpdRecord rec; - // This is the chip unit position. 0xFF means record associated to all - // chiplets, any other number means record associated to the ex chiplet - // corresponding to that number. - uint8_t exChipNum; - }; - static const mvpdRecordToChip mvpdFapiRecordToHbRecord[] = - { - {MVPD::CRP0,0xFF}, - {MVPD::CP00,0xFF}, - {MVPD::VINI,0xFF}, - {MVPD::LRP0,0x00}, - {MVPD::LRP1,0x01}, - {MVPD::LRP2,0x02}, - {MVPD::LRP3,0x03}, - {MVPD::LRP4,0x04}, - {MVPD::LRP5,0x05}, - {MVPD::LRP6,0x06}, - {MVPD::LRP7,0x07}, - {MVPD::LRP8,0x08}, - {MVPD::LRP9,0x09}, - {MVPD::LRPA,0x0A}, - {MVPD::LRPB,0x0B}, - {MVPD::LRPC,0x0C}, - {MVPD::LRPD,0x0D}, - {MVPD::LRPE,0x0E}, - {MVPD::LWP0,0x00}, - {MVPD::LWP1,0x01}, - {MVPD::LWP2,0x02}, - {MVPD::LWP3,0x03}, - {MVPD::LWP4,0x04}, - {MVPD::LWP5,0x05}, - {MVPD::LWP6,0x06}, - {MVPD::LWP7,0x07}, - {MVPD::LWP8,0x08}, - {MVPD::LWP9,0x09}, - {MVPD::LWPA,0x0A}, - {MVPD::LWPB,0x0B}, - {MVPD::LWPC,0x0C}, - {MVPD::LWPD,0x0D}, - {MVPD::LWPE,0x0E}, - {MVPD::VWML,0xFF}, - {MVPD::MER0,0xFF}, - }; - const uint8_t NUM_MVPD_RECORDS = - sizeof(mvpdFapiRecordToHbRecord)/sizeof(mvpdFapiRecordToHbRecord[0]); - - fapi::ReturnCode l_rc; - - uint8_t l_index = static_cast<uint8_t>(i_fapiRecord); - - if (l_index >= NUM_MVPD_RECORDS) - { - FAPI_ERR("MvpdRecordXlate: Invalid MVPD Record: 0x%x", i_fapiRecord); - /*@ - * @errortype - * @moduleid MOD_MVPD_ACCESS - * @reasoncode RC_INVALID_RECORD - * @userdata1 Record enumerator - * @devdesc Attempt to read an MVPD field using an invalid record - */ - const bool hbSwError = true; - errlHndl_t l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_MVPD_ACCESS, - fapi::RC_INVALID_RECORD, - i_fapiRecord, 0, hbSwError); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - } - else - { - o_hbRecord = mvpdFapiRecordToHbRecord[l_index].rec; - o_chipUnitNum = mvpdFapiRecordToHbRecord[l_index].exChipNum; - } - - return l_rc; -} - -//****************************************************************************** -// MvpdKeywordXlate -// Translates a FAPI MVPD Keyword enumerator into a Hostboot MVPD Keyword -// enumerator -//****************************************************************************** -fapi::ReturnCode MvpdKeywordXlate(const fapi::MvpdKeyword i_fapiKeyword, - MVPD::mvpdKeyword & o_hbKeyword) -{ - // Create a lookup table for converting a FAPI MVPD keyword enumerator to a - // Hostboot MVPD keyword enumerator. This is a simple array and relies on - // the FAPI record enumerators starting at zero and incrementing. - static const MVPD::mvpdKeyword - mvpdFapiKeywordToHbKeyword[] = - { - MVPD::VD, - MVPD::ED, - MVPD::TE, - MVPD::DD, - MVPD::pdP, - MVPD::ST, - MVPD::DN, - MVPD::PG, - MVPD::PK, - MVPD::pdR, - MVPD::pdV, - MVPD::pdH, - MVPD::SB, - MVPD::DR, - MVPD::VZ, - MVPD::CC, - MVPD::CE, - MVPD::FN, - MVPD::PN, - MVPD::SN, - MVPD::PR, - MVPD::HE, - MVPD::CT, - MVPD::HW, - MVPD::pdM, - MVPD::IN, - MVPD::pd2, - MVPD::pd3, - MVPD::OC, - MVPD::FO, - MVPD::pdI, - MVPD::pdG, - MVPD::MK, - MVPD::PB, - MVPD::CH, - MVPD::IQ, - }; - const uint8_t NUM_MVPD_KEYWORDS = - sizeof(mvpdFapiKeywordToHbKeyword)/sizeof(mvpdFapiKeywordToHbKeyword[0]); - - fapi::ReturnCode l_rc; - - uint8_t l_index = static_cast<uint8_t>(i_fapiKeyword); - - if (l_index >= NUM_MVPD_KEYWORDS) - { - FAPI_ERR("MvpdKeywordXlate: Invalid MVPD Keyword: 0x%x", i_fapiKeyword); - /*@ - * @errortype - * @moduleid MOD_MVPD_ACCESS - * @reasoncode RC_INVALID_KEYWORD - * @userdata1 Keyword enumerator - * @devdesc Attempt to read an MVPD field using an invalid keyword - */ - const bool hbSwError = true; - errlHndl_t l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_MVPD_ACCESS, - fapi::RC_INVALID_KEYWORD, - i_fapiKeyword, 0, hbSwError); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - } - else - { - o_hbKeyword = mvpdFapiKeywordToHbKeyword[l_index]; - } - - return l_rc; -} - -//****************************************************************************** -// getVoltageBucketAttr -//****************************************************************************** -fapi::ReturnCode getVoltageBucketAttr(const fapi::Target & i_exchplet, - const fapi::voltageBucketData_t & i_data, - uint8_t * io_pData, - uint32_t & io_dataSz) -{ - fapi::ReturnCode l_rc; - do - { - if( io_dataSz < MAX_MVPD_VOLTAGE_BUCKET_ATTR_SZ) - { - FAPI_ERR("getVltgBucketAttr: Invalid buffer size:0x%08X," - "expected:0x%08X",io_dataSz, - MAX_MVPD_VOLTAGE_BUCKET_ATTR_SZ); - errlHndl_t l_err = NULL; - - /*@ - * @errortype - * @moduleid fapi::MOD_PLAT_MVPD_GET_VLTG_BUCKET_ATTR - * @reasoncode fapi::RC_INVALID_SIZE - * @userdata1 Invalid input length - * @userdata2 Expected length - * @devdesc Input buffer size is smaller than expected length. - */ - l_err = - new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_PLAT_MVPD_GET_VLTG_BUCKET_ATTR, - fapi::RC_INVALID_SIZE, - io_dataSz, - MAX_MVPD_VOLTAGE_BUCKET_ATTR_SZ); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - break; - } - - //NOTE: Below attributes are read and value written to the output - // buffer as the VPD voltage bucket data layout. See MVPD documentation - // for more details - uint32_t l_data = 0; - uint32_t l_idx = 0; - // Write bucket id. This is written directly as this is not an - // override attribute (cannot be changed). - io_pData[l_idx] = i_data.bucketId; - l_idx++; - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_NOM_FREQ_MHZ, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_NOM_FREQ_MHZ"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_NEST_NOM_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_NEST_NOM_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_NEST_NOM_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_NEST_NOM_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_CS_NOM_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_CS_NOM_VOLTAGE"); - break; - } - - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_CS_NOM_CURRENT, - &i_exchplet, - l_data); - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_CS_NOM_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_PS_FREQ_MHZ,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_PS_FREQ_MHZ"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_NEST_PS_VOLTAGE,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_NEST_PS_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_NEST_PS_CURRENT,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_NEST_PS_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_CS_PS_VOLTAGE,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_CS_PS_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_CS_PS_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_CS_PS_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_TURBO_FREQ_MHZ, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_TURBO_FREQ_MHZ"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_NEST_TURBO_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_NEST_TURBO_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_NEST_TURBO_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_NEST_TURBO_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_CS_TURBO_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_CS_TURBO_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_CS_TURBO_CURRENT, - &i_exchplet, l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_CS_TURBO_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_FVMIN_FREQ_MHZ, - &i_exchplet,l_data); - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_FVMIN_FREQ_MHZ"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_NEST_FVMIN_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_NEST_FVMIN_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_NEST_FVMIN_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_NEST_FVMIN_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_CS_FVMIN_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_CS_FVMIN_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_CS_FVMIN_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_CS_FVMIN_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_LAB_FREQ_MHZ, - &i_exchplet,l_data); - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_LAB_FREQ_MHZ"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_NEST_LAB_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_NEST_LAB_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_NEST_LAB_CURRENT, - &i_exchplet, l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_NEST_LAB_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_V_CS_LAB_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_V_CS_LAB_VOLTAGE"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - l_rc = FAPI_ATTR_GET(ATTR_OVERRIDE_MVPD_I_CS_LAB_CURRENT, - &i_exchplet, l_data); - - if( l_rc ) - { - FAPI_ERR("getVltgBucketAttr:Err in get " - "ATTR_OVERRIDE_MVPD_I_CS_LAB_CURRENT"); - break; - } - - // Read value and put 2 bytes to the output buffer. FAPI ATTR cannot - // be 2 bytes by design so had to make it 4 bytes and do shift to - // return 2 bytes which is actual size of the data in the VPD. - l_data = l_data << MVPD_TWO_BYTE_ATTR_VAL_SHIFT; - memcpy(&io_pData[l_idx],&l_data,sizeof(uint16_t)); - l_idx += sizeof(uint16_t); - - //Return actual buffer size in output param - io_dataSz = l_idx; - - }while(false); - - if(l_rc) - { - // On error return 0 size - io_dataSz = 0; - } - - return l_rc; -} - -//****************************************************************************** -// setVoltageBucketAttr -//****************************************************************************** -fapi::ReturnCode setVoltageBucketAttr(const fapi::Target & i_exchplet, - const fapi::voltageBucketData_t & i_data) -{ - fapi::ReturnCode l_rc; - do - { - // local variable is used as i_data fields are 2 bytes (matching VPD - // data length) and FAPI attributes are 4 bytes long. FAPI attributes - // cannot be 2 bytes by design. - uint32_t l_data = i_data.nomFreq; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_NOM_FREQ_MHZ, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_NOM_FREQ_MHZ"); - break; - } - - l_data = i_data.VnestNomVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_NEST_NOM_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_NEST_NOM_VOLTAGE"); - break; - } - - l_data = i_data.InestNomCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_NEST_NOM_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_NEST_NOM_CURRENT"); - break; - } - - l_data = i_data.VcsNomVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_CS_NOM_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_CS_NOM_VOLTAGE"); - break; - } - - l_data = i_data.IcsNomCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_CS_NOM_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_CS_NOM_CURRENT"); - break; - } - - l_data = i_data.PSFreq; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_PS_FREQ_MHZ,&i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_PS_FREQ_MHZ"); - break; - } - - l_data = i_data.VnestPSVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_NEST_PS_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_NEST_PS_VOLTAGE"); - break; - } - - l_data = i_data.InestPSCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_NEST_PS_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_NEST_PS_CURRENT"); - break; - } - - l_data = i_data.VcsPSVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_CS_PS_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_CS_PS_VOLTAGE"); - break; - } - - l_data = i_data.IcsPSCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_CS_PS_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_CS_PS_CURRENT"); - break; - } - - l_data = i_data.turboFreq; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_TURBO_FREQ_MHZ, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_TURBO_FREQ_MHZ"); - break; - } - - l_data = i_data.VnestTurboVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_NEST_TURBO_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_NEST_TURBO_VOLTAGE"); - break; - } - - l_data = i_data.InestTurboCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_NEST_TURBO_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_NEST_TURBO_CURRENT"); - break; - } - - l_data = i_data.VcsTurboVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_CS_TURBO_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_CS_TURBO_VOLTAGE"); - break; - } - - l_data = i_data.IcsTurboCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_CS_TURBO_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_CS_TURBO_CURRENT"); - break; - } - l_data = i_data.fvminFreq; - - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_FVMIN_FREQ_MHZ, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_FVMIN_FREQ_MHZ"); - break; - } - - l_data = i_data.VnestFvminVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_NEST_FVMIN_VOLTAGE, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_NEST_FVMIN_VOLTAGE"); - break; - } - - l_data = i_data.InestFvminCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_NEST_FVMIN_CURRENT, - &i_exchplet,l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_NEST_FVMIN_CURRENT"); - break; - } - l_data = i_data.VcsFvminVltg; - - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_CS_FVMIN_VOLTAGE,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_CS_FVMIN_VOLTAGE"); - break; - } - - l_data = i_data.IcsFvminCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_CS_FVMIN_CURRENT,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_CS_FVMIN_CURRENT"); - break; - } - - l_data = i_data.labFreq; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_LAB_FREQ_MHZ,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_LAB_FREQ_MHZ"); - break; - } - l_data = i_data.VnestLabVltg; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_NEST_LAB_VOLTAGE,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_NEST_LAB_VOLTAGE"); - break; - } - l_data = i_data.InestLabCurr; - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_NEST_LAB_CURRENT,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_NEST_LAB_CURRENT"); - break; - } - l_data = i_data.VcsLabVltg; - - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_V_CS_LAB_VOLTAGE,&i_exchplet, - l_data); - - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_V_CS_LAB_VOLTAGE"); - break; - } - l_data = i_data.IcsLabCurr; - - l_rc = FAPI_ATTR_SET(ATTR_OVERRIDE_MVPD_I_CS_LAB_CURRENT,&i_exchplet, - l_data); - if( l_rc ) - { - FAPI_ERR("setVltgBucketAttr:Err in set " - "ATTR_OVERRIDE_MVPD_I_CS_LAB_CURRENT"); - break; - } - - }while(false); - - return l_rc; -} - -/** - * @brief Parse and get #V version one bucket data - * - * @par Detailed Description: - * This function handles parsing of version one #V data and returns - * bucket data buffer. - * - * @param[in] i_prBucketId Bucket id to read data for - * @param[in] i_dataSz #V data buffer size - * @param[in] i_vDataPtr #V data buffer - * @param[out] o_data On success, structure with #V version one bucket - * data from VPD - * - * @return fapi::ReturnCode. FAPI_RC_SUCCESS, or failure value. - */ -fapi::ReturnCode fapiGetVerOneVoltageBucketData( - const TARGETING::Target * i_pChipTarget, - const uint8_t i_prBucketId, - const uint32_t i_dataSz, - const uint8_t *i_vDataPtr, - fapi::voltageBucketData_t & o_data) -{ - fapi::ReturnCode l_rc; - errlHndl_t l_err = NULL; - - do - { - memset (&o_data,0,sizeof (o_data)); - - // For version 0x01, valid bucket id is 1 through 5. - if( (i_prBucketId == 0 ) || - (i_prBucketId > 5) ) - { - FAPI_ERR("Found invalid bucket ID:0x%02X", i_prBucketId); - - /*@ - * @errortype - * @moduleid fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA - * @reasoncode fapi::RC_INVALID_PARAM - * @userdata1 Invalid bucket id - * @devdesc Invalid bucket id found for the voltage data. - */ - l_err = - new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA, - fapi::RC_INVALID_PARAM, - i_prBucketId); - - // Callout HW as VPD data is incorrect - l_err->addHwCallout(i_pChipTarget, HWAS::SRCI_PRIORITY_HIGH, - HWAS::DECONFIG, HWAS::GARD_NULL); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // Documented in Module VPD document: mvpd-p8-100212.pdf Version 1.0 - // skip (1 byte version + 3 byte PNP + - // ((bucketId-1(as bucketId starts at 1)) * bucket data size ) - uint32_t l_bucketOffset = 4 + ((i_prBucketId -1)* VERSION_01_BUCKET_SZ); - - if( i_dataSz < (l_bucketOffset + VERSION_01_BUCKET_SZ)) - { - FAPI_ERR("Not enough data to get bucket data " - "Returned data length:[0x%08X],expected len:[0x%08X]", - i_dataSz, l_bucketOffset + VERSION_01_BUCKET_SZ); - - /*@ - * @errortype - * @moduleid fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA - * @reasoncode fapi::RC_INVALID_SIZE - * @userdata1 Voltage data length - * @userdata2 Expected length - * @devdesc Not enough voltage data to read bucket data. - */ - l_err = - new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA, - fapi::RC_INVALID_SIZE, - i_dataSz, - (l_bucketOffset + VERSION_01_BUCKET_SZ)); - - // Callout HW as VPD data is incorrect - l_err->addHwCallout(i_pChipTarget, HWAS::SRCI_PRIORITY_HIGH, - HWAS::DECONFIG, HWAS::GARD_NULL); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // Got bucket data, now make sure input bucket id matches with the - // bucket id pointed to by the bucket data. Ignore default value - // since it means VPD is not initialized. - if( (i_prBucketId != i_vDataPtr[l_bucketOffset]) && - (i_prBucketId != DEFAULT_BUCKET) ) - { - FAPI_ERR("BucketId:[0x%02x] from PR data " - "does not match bucketId:[0x%02X] from the voltage " - "data for HUID:[0x%08X]", - i_prBucketId, i_vDataPtr[l_bucketOffset], - i_pChipTarget->getAttr<TARGETING::ATTR_HUID>()); - - /*@ - * @errortype - * @moduleid fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA - * @reasoncode fapi::RC_DATA_MISMATCH - * @userdata1[0:31] Voltage bucket id - * @userdata1[32:63] PR bucket id - * @userdata2 Voltage bucket id offset - * @devdesc Bucket id from PR keyword does not match - * bucket id in the voltage data - */ - l_err = - new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA, - fapi::RC_DATA_MISMATCH, - TWO_UINT32_TO_UINT64(i_vDataPtr[l_bucketOffset], i_prBucketId), - l_bucketOffset); - - // Callout HW as VPD data is incorrect - l_err->addHwCallout(i_pChipTarget, HWAS::SRCI_PRIORITY_HIGH, - HWAS::DECONFIG, HWAS::GARD_NULL); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // Make sure bucket data is large enough to process output structure - if (sizeof(o_data) < (VERSION_01_BUCKET_SZ)) - { - FAPI_ERR("Not enough bucket data to fill o_data," - "bucket length:[0x%08X],o_data size:[0x%08X]", - VERSION_01_BUCKET_SZ,sizeof(o_data)); - - /*@ - * @errortype - * @moduleid fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA - * @reasoncode fapi::RC_INVALID_DATA - * @userdata1 Bucket data length - * @userdata2 Output Data size - * @devdesc Not enough bucket data to fill output data. - */ - l_err = - new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_GET_VER_ONE_VOLTAGE_BUCKET_DATA, - fapi::RC_INVALID_DATA, - VERSION_01_BUCKET_SZ, - (sizeof(o_data))); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // TODO RTC 116552 Clean up logic to map data to a struct - uint8_t l_idx = l_bucketOffset; - //Bucket id - o_data.bucketId = i_vDataPtr[l_idx]; - l_idx += sizeof(o_data.bucketId); - //Nominal - o_data.nomFreq = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.nomFreq); - o_data.VnestNomVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VnestNomVltg); - o_data.InestNomCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.InestNomCurr); - o_data.VcsNomVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VcsNomVltg); - o_data.IcsNomCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.IcsNomCurr); - - //PowerSave - o_data.PSFreq = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.PSFreq); - o_data.VnestPSVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VnestPSVltg); - o_data.InestPSCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.InestPSCurr); - o_data.VcsPSVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VcsPSVltg); - o_data.IcsPSCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.IcsPSCurr); - //Turbo - o_data.turboFreq = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.turboFreq); - o_data.VnestTurboVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VnestTurboVltg); - o_data.InestTurboCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.InestTurboCurr); - o_data.VcsTurboVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VcsTurboVltg); - o_data.IcsTurboCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.IcsTurboCurr); - - // Fvmin - o_data.fvminFreq = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.fvminFreq); - o_data.VnestFvminVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VnestFvminVltg); - o_data.InestFvminCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.InestFvminCurr); - o_data.VcsFvminVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VcsFvminVltg); - o_data.IcsFvminCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.IcsFvminCurr); - - //Lab - o_data.labFreq = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.labFreq); - o_data.VnestLabVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VnestLabVltg); - o_data.InestLabCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.InestLabCurr); - o_data.VcsLabVltg = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.VcsLabVltg); - o_data.IcsLabCurr = *(reinterpret_cast<uint16_t*>( - const_cast<uint8_t*>(&i_vDataPtr[l_idx]))); - l_idx += sizeof(o_data.IcsLabCurr); - - } while(0); - - return l_rc; -} - -} - -extern "C" -{ - -//****************************************************************************** -// fapiGetMvpdField -//****************************************************************************** -fapi::ReturnCode fapiGetMvpdField(const fapi::MvpdRecord i_record, - const fapi::MvpdKeyword i_keyword, - const fapi::Target &i_procTarget, - uint8_t * const i_pBuffer, - uint32_t &io_fieldSize) -{ - uint8_t l_chipUnitNum = MVPD_INVALID_CHIP_UNIT; - errlHndl_t l_errl = NULL; - fapi::ReturnCode l_rc; - FAPI_DBG("fapiGetMvpdField entry"); - - do - { - // Translate the FAPI record to a Hostboot record - MVPD::mvpdRecord l_hbRecord = MVPD::MVPD_INVALID_RECORD; - - l_rc = fapi::MvpdRecordXlate(i_record, l_hbRecord, l_chipUnitNum); - - if (l_rc) - { - break; - } - - // Translate the FAPI keyword to a Hostboot keyword - MVPD::mvpdKeyword l_hbKeyword = MVPD::INVALID_MVPD_KEYWORD; - - l_rc = fapi::MvpdKeywordXlate(i_keyword, l_hbKeyword); - - if (l_rc) - { - break; - } - - // For #V keyword need to read the bucket id from the processor VPD - // and then read #V data to get the voltage bucket data. Use exsiting - // freq voltage service call to get the voltage bucket data - if(i_keyword == fapi::MVPD_KEYWORD_PDV) - { - fapi::voltageBucketData_t l_pVData; - - // Get #V bucket data - l_rc = fapiGetPoundVBucketData(i_procTarget, - (uint32_t) l_hbRecord, - l_pVData); - if (l_rc) - { - TARGETING::Target * l_pChipTarget = - reinterpret_cast<TARGETING::Target*>(i_procTarget.get()); - - FAPI_ERR("fapiGetMvpdField: Error getting #V bucket data " - "HUID: 0x%08X", - l_pChipTarget->getAttr<TARGETING::ATTR_HUID>()); - - break; - } - - // Get EX - CHPLET list and find the correct chiplet to read - // write attributes - std::vector<fapi::Target> l_exchiplets; - fapi::TargetState l_state = fapi::TARGET_STATE_PRESENT; - - l_rc = fapiGetChildChiplets( - i_procTarget,fapi::TARGET_TYPE_EX_CHIPLET, - l_exchiplets,l_state); - - if( l_rc) - { - FAPI_ERR("fapiGetMvpdField:Error getting exchiplet list"); - break; - } - - std::vector<fapi::Target>::iterator l_itr; - // Traverse through ex-chiplet and compare chip unit pos to find - // right ex chiplet - for(l_itr = l_exchiplets.begin();l_itr!=l_exchiplets.end();l_itr++) - { - uint8_t l_chipUnit = MVPD_INVALID_CHIP_UNIT; - // get chip unit - l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS,&(*(l_itr)),l_chipUnit); - - if( l_rc) - { - FAPI_ERR("fapiGetMvpdField:Err getting CHIP_UNIT_POS Attr"); - break; - } - - //Find correct chiplet - // If ex-chiplet chip unit pos does not match the one input - // record corresponds to then go to the next ex-chiplet - if( l_chipUnit != l_chipUnitNum) - { - continue; - } - // Matching ex-chiplet found. Write MVPD voltage bucket - // attributes associated to it. - l_rc = setVoltageBucketAttr(*l_itr,l_pVData); - - if( l_rc) - { - FAPI_ERR("fapiGetMvpdField:Error setting voltage bucket " - "attribute"); - break; - } - - // Read it back to get override value (if any) - l_rc = getVoltageBucketAttr(*l_itr,l_pVData,i_pBuffer, - io_fieldSize); - - if( l_rc) - { - FAPI_ERR("fapiGetMvpdField:Error reading voltage bucket " - "attribute"); - break; - } - // found correct core so we are done - break; - } //end for loop - - if( l_rc) - { - break; - } - - } - else // non-#V Module VPD data - { - // Similarly to this function, deviceRead will return the size of - // the field if the pointer is NULL - size_t l_fieldLen = io_fieldSize; - - l_errl = deviceRead( - reinterpret_cast< TARGETING::Target*>(i_procTarget.get()), - i_pBuffer, - l_fieldLen, - DEVICE_MVPD_ADDRESS(l_hbRecord, l_hbKeyword)); - - if (l_errl) - { - FAPI_ERR("fapiGetMvpdField: ERROR: deviceRead : errorlog PLID=0x%x", - l_errl->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - - break; - } - - // Success, update callers io_fieldSize for the case where the - // pointer is NULL and deviceRead returned the actual size - io_fieldSize = l_fieldLen; - - } - - FAPI_DBG("fapiGetMvpdField: returning field len=0x%x", io_fieldSize); - - } while(0); - - if( l_rc) - { - io_fieldSize = 0; - } - - FAPI_DBG( "fapiGetMvpdField: exit" ); - - return l_rc; -} - -//****************************************************************************** -// fapiSetMvpdField -//****************************************************************************** -fapi::ReturnCode fapiSetMvpdField(const fapi::MvpdRecord i_record, - const fapi::MvpdKeyword i_keyword, - const fapi::Target &i_procTarget, - const uint8_t * const i_pBuffer, - const uint32_t i_fieldSize) -{ - fapi::ReturnCode l_rc; - uint8_t l_chipUnitNum = MVPD_INVALID_CHIP_UNIT; - FAPI_DBG("fapiSetMvpdField entry"); - - do - { - // Translate the FAPI record to a Hostboot record - MVPD::mvpdRecord l_hbRecord = MVPD::MVPD_INVALID_RECORD; - - l_rc = fapi::MvpdRecordXlate(i_record, l_hbRecord, l_chipUnitNum); - - if (l_rc) - { - break; - } - - // Translate the FAPI keyword to a Hostboot keyword - MVPD::mvpdKeyword l_hbKeyword = MVPD::INVALID_MVPD_KEYWORD; - - l_rc = fapi::MvpdKeywordXlate(i_keyword, l_hbKeyword); - - if (l_rc) - { - break; - } - - size_t l_fieldLen = i_fieldSize; - - errlHndl_t l_errl = deviceWrite( - reinterpret_cast< TARGETING::Target*>(i_procTarget.get()), - const_cast<uint8_t *>(i_pBuffer), - l_fieldLen, - DEVICE_MVPD_ADDRESS(l_hbRecord, l_hbKeyword)); - - if (l_errl) - { - FAPI_ERR("fapiSetMvpdField: ERROR: deviceWrite : errorlog PLID=0x%x", - l_errl->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_errl)); - - break; - } - - } while(0); - - FAPI_DBG( "fapiSetMvpdField: exit" ); - - return l_rc; -} - -fapi::ReturnCode fapiGetPoundVBucketData( - const fapi::Target &i_procTarget, - const uint32_t i_record, - fapi::voltageBucketData_t & o_data) -{ - fapi::ReturnCode l_rc; - size_t l_vpdSize = 0; - uint8_t *l_prDataPtr = NULL; - uint8_t *l_vDataPtr = NULL; - errlHndl_t l_err = NULL; - - do - { - TARGETING::Target * l_pChipTarget = - reinterpret_cast<TARGETING::Target*>(i_procTarget.get()); - - // Read PR keyword size - l_err = deviceRead( l_pChipTarget, - NULL, - l_vpdSize, - DEVICE_MVPD_ADDRESS( MVPD::VINI, - MVPD::PR ) ); - if (l_err) - { - FAPI_ERR("Error getting PR keyword size for HUID: " - "0x%08X, errorlog PLID=0x%x", - l_pChipTarget->getAttr<TARGETING::ATTR_HUID>(), - l_err->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // Assert if deviceRead returned success but size is 0 - assert(l_vpdSize != 0); - - l_prDataPtr = new uint8_t [l_vpdSize]; - - // Read PR keyword data - l_err = deviceRead(l_pChipTarget, - l_prDataPtr, - l_vpdSize, - DEVICE_MVPD_ADDRESS( MVPD::VINI, - MVPD::PR ) ); - if (l_err) - { - FAPI_ERR("Error getting PR keyword data for HUID: " - "0x%08X, errorlog PLID=0x%x", - l_pChipTarget->getAttr<TARGETING::ATTR_HUID>(), - l_err->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // Get non-ECO mode bucket id - bits 4-7 - uint8_t l_bucketId = - (l_prDataPtr[NON_ECO_VOLTAGE_BUCKET_OFFFSET] & BUCKET_ID_MASK); - if( l_bucketId == 0) - { - FAPI_INF("bucketId is zero, using alternate offset"); - l_bucketId = l_prDataPtr[ALTERNATE_BUCKET_OFFSET]; - } - if( l_bucketId == 0) // VPD is not initialized / programmed correctly - { - FAPI_INF("bucketId is zero, invalid VPD, using default value 0x%x", - DEFAULT_BUCKET); - l_bucketId = DEFAULT_BUCKET; - } - - l_vpdSize = 0; - l_err = deviceRead( l_pChipTarget, - NULL, - l_vpdSize, - DEVICE_MVPD_ADDRESS( i_record, - MVPD::pdV ) ); - if (l_err) - { - FAPI_ERR("Error getting #V keyword size for HUID: " - "0x%08X, errorlog PLID=0x%x", - l_pChipTarget->getAttr<TARGETING::ATTR_HUID>(), - l_err->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // Assert if deviceRead returned success but size is 0 - assert(l_vpdSize != 0); - - l_vDataPtr = new uint8_t [l_vpdSize]; - - l_err = deviceRead( l_pChipTarget, - l_vDataPtr, - l_vpdSize, - DEVICE_MVPD_ADDRESS( i_record, - MVPD::pdV ) ); - if (l_err) - { - FAPI_ERR("Error getting #V keyword data for HUID: " - "0x%08X, errorlog PLID=0x%x", - l_pChipTarget->getAttr<TARGETING::ATTR_HUID>(), - l_err->plid()); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - uint8_t l_version = 0x0; - - l_version = l_vDataPtr[0]; - - if( l_version != POUND_V_VERSION_01) - { - FAPI_ERR("Found unsupported version:[0x%02X] of " - "the #V data", l_version); - - /*@ - * @errortype - * @moduleid fapi::MOD_GET_POUNDV_BUCKET_DATA - * @reasoncode fapi::RC_DATA_NOT_SUPPORTED - * @userdata1[0:31] Unsupported version - * @userdata1[32:63] Expected version - * @userdata2 #V KW data size - * @devdesc Unsupported #V keyword data version found. - */ - l_err = - new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_GET_POUNDV_BUCKET_DATA, - fapi::RC_DATA_NOT_SUPPORTED, - TWO_UINT32_TO_UINT64(l_version, POUND_V_VERSION_01), - l_vpdSize); - - // Callout HW as VPD data is incorrect - l_err->addHwCallout(l_pChipTarget, HWAS::SRCI_PRIORITY_HIGH, - HWAS::DECONFIG, HWAS::GARD_NULL); - - // Code (SW) callout in case this is downlevel VPD version - l_err->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE, - HWAS::SRCI_PRIORITY_MED); - - // Add the error log pointer as data to the ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_err)); - - break; - } - - // Parse #V Version one data to get bucket data - l_rc = fapiGetVerOneVoltageBucketData(l_pChipTarget, - l_bucketId, - l_vpdSize, - l_vDataPtr, - o_data); - if (l_rc) - { - FAPI_ERR("Error getting voltage bucket data for version 0x%x, " - "PR KW bucketId:[0x%02X], errorlog PLID=0x%x", - POUND_V_VERSION_01, l_bucketId, l_err->plid()); - - break; - } - - } while(0); - - if (l_prDataPtr != NULL) - { - delete [] l_prDataPtr; - } - if (l_vDataPtr != NULL) - { - delete [] l_vDataPtr; - } - - return l_rc; -} - -} // extern "C" diff --git a/src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C b/src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C deleted file mode 100644 index 5a2b261db..000000000 --- a/src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C +++ /dev/null @@ -1,51 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ -/* */ -/* 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 platReturnCodeDataRef.C - * - * @brief Implements the platform part of the ReturnCodeDataRef class. - * - * Note that platform code must provide the implementation. FAPI has provided - * an example for platforms that do not attach ReturnCodeData to a ReturnCode. - */ - -#include <fapiReturnCodeDataRef.H> -#include <fapiPlatTrace.H> -#include <errl/errlentry.H> - -namespace fapi -{ - -//****************************************************************************** -// deletePlatData function -//****************************************************************************** -void ReturnCodeDataRef::deletePlatData() -{ - FAPI_DBG("ReturnCodePlatDataRef::deleteData"); - - // HostBoot platform uses iv_pData to point at an error log. - delete (static_cast<errlHndl_t>(iv_pPlatData)); - iv_pPlatData = NULL; -} - -} diff --git a/src/usr/hwpf/plat/fapiPlatSystemConfig.C b/src/usr/hwpf/plat/fapiPlatSystemConfig.C deleted file mode 100644 index 55820824c..000000000 --- a/src/usr/hwpf/plat/fapiPlatSystemConfig.C +++ /dev/null @@ -1,579 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatSystemConfig.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ -/* [+] 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 fapiPlatSystemConfig.C - * - * @brief Implements the fapiSystemConfig.H functions. - * - * Note that platform code must provide the implementation. - */ - -#include <fapiPlatTrace.H> -#include <fapiSystemConfig.H> -#include <isteps/hwpf_reasoncodes.H> -#include <errl/errlentry.H> -#include <targeting/common/commontargeting.H> -#include <targeting/common/utilFilter.H> -#include <targeting/common/targetservice.H> -#include <targeting/common/predicates/predicatectm.H> - -extern "C" -{ -using namespace TARGETING; - -//****************************************************************************** -// fapiGetOtherSideOfMemChannel function -//****************************************************************************** -fapi::ReturnCode fapiGetOtherSideOfMemChannel( - const fapi::Target& i_target, - fapi::Target & o_target, - const fapi::TargetState i_state) -{ - fapi::ReturnCode l_rc; - TargetHandleList l_targetList; - - FAPI_DBG(ENTER_MRK "fapiGetOtherSideOfMemChannel. State: 0x%08x", - i_state); - - TargetHandle_t l_target = - reinterpret_cast<TargetHandle_t>(i_target.get()); - - if (l_target == NULL) - { - FAPI_ERR("fapiGetOtherSideOfMemChannel. Embedded NULL target pointer"); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL - * @reasoncode fapi::RC_EMBEDDED_NULL_TARGET_PTR - * @devdesc Target has embedded null target pointer - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL, - fapi::RC_EMBEDDED_NULL_TARGET_PTR, - 0, 0, hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else if (i_target.getType() == fapi::TARGET_TYPE_MCS_CHIPLET) - { - // find the Centaur that is associated with this MCS - getChildAffinityTargetsByState(l_targetList, l_target, - CLASS_CHIP, TYPE_MEMBUF, UTIL_FILTER_PRESENT); - - if(l_targetList.size() != 1) // one and only one expected - { - FAPI_ERR("fapiGetOtherSideOfMemChannel. expect 1 Centaur %d", - l_targetList.size()); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL - * @reasoncode fapi::RC_NO_SINGLE_MEMBUFF - * @userdata1 Number of Memory Buffers - * @userdata2 MCS HUID - * @devdesc fapiGetOtherSideOfMemChannel could not find exactly - * one target on the other side of the correct state - * @custdesc A problem occurrred during the IPL of the system. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL, - fapi::RC_NO_SINGLE_MEMBUFF, - l_targetList.size(), - TARGETING::get_huid(l_target), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - - } - else - { - o_target.setType(fapi::TARGET_TYPE_MEMBUF_CHIP); - o_target.set(reinterpret_cast<void *>(l_targetList[0])); - } - - } - else if (i_target.getType() == fapi::TARGET_TYPE_MEMBUF_CHIP) - { - // find the MCS that is associated with this Centaur - getParentAffinityTargets (l_targetList, l_target, - CLASS_UNIT, TYPE_MCS, false); - - if(l_targetList.size() != 1) // one and only one expected - { - FAPI_ERR("fapiGetOtherSideOfMemChannel. expect 1 MCS %d", - l_targetList.size()); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL - * @reasoncode fapi::RC_NO_SINGLE_MCS - * @userdata1 Number of MCSs - * @userdata2 Membuf HUID - * @devdesc fapiGetOtherSideOfMemChannel could not find exactly - * one target on the other side of the correct state - * @custdesc A problem occurrred during the IPL of the system. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL, - fapi::RC_NO_SINGLE_MCS, - l_targetList.size(), - TARGETING::get_huid(l_target), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - o_target.setType(fapi::TARGET_TYPE_MCS_CHIPLET); - o_target.set(reinterpret_cast<void *>(l_targetList[0])); - } - - } - else - { - FAPI_ERR("fapiGetOtherSideOfMemChannel. target 0x%08x not supported", - i_target.getType()); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL - * @reasoncode fapi::RC_UNSUPPORTED_REQUEST - * @userdata1 Requested type - * @userdata2 Unsupported Target HUID - * @devdesc fapiGetOtherSideOfMemChannel request for unsupported - * or invalid target type - * @custdesc A problem occurrred during the IPL of the system: Request - * for unsupported or invalid target type. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL, - fapi::RC_UNSUPPORTED_REQUEST, - i_target.getType(), - TARGETING::get_huid(l_target), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - - if (!l_rc) // OK so far, check that state is as requested - { - HwasState l_state = - l_targetList[0]->getAttr<ATTR_HWAS_STATE>(); - - if (((i_state == fapi::TARGET_STATE_PRESENT) && !l_state.present) || - ((i_state == fapi::TARGET_STATE_FUNCTIONAL) && !l_state.functional)) - { - FAPI_ERR("fapiGetOtherSideOfMemChannel. state mismatch"); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL - * @reasoncode fapi::RC_STATE_MISMATCH - * @userdata1 Requested state - * @userdata2 Other Target HUID - * @devdesc fapiGetOtherSideOfMemChannel target not present or - * functional as requested - * @custdesc A problem occurred during the IPL of the system: - * Requested target not present or not functional. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_OTHER_SIDE_OF_MEM_CHANNEL, - fapi::RC_STATE_MISMATCH, - i_state, - TARGETING::get_huid(l_targetList[0]), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - - } - - FAPI_DBG(EXIT_MRK "fapiGetOtherSideOfMemChannel. rc = 0x%x", - static_cast<uint32_t>(l_rc)); - - return l_rc; -} - -//****************************************************************************** -// fapiGetChildChiplets function -//****************************************************************************** -fapi::ReturnCode fapiGetChildChiplets( - const fapi::Target & i_chip, - const fapi::TargetType i_chipletType, - std::vector<fapi::Target> & o_chiplets, - const fapi::TargetState i_state) -{ - FAPI_DBG(ENTER_MRK "fapiGetChildChiplets. Chiplet Type:0x%08x State:0x%08x", - i_chipletType, i_state); - - fapi::ReturnCode l_rc; - o_chiplets.clear(); - - // Extract the HostBoot Target pointer for the input chip - TARGETING::Target * l_pChip = - reinterpret_cast<TARGETING::Target*>(i_chip.get()); - - // Check that the input target is a chip - if (!i_chip.isChip()) - { - FAPI_ERR("fapiGetChildChiplets. Input target type 0x%08x is not a chip", - i_chip.getType()); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_CHILD_CHIPLETS - * @reasoncode fapi::RC_INVALID_REQUEST - * @userdata1 Type of input target - * @userdata2 Input Target HUID - * @devdesc fapiGetChildChiplets request for non-chip - * @custdesc A problem occurred during the IPL of the system. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_CHILD_CHIPLETS, - fapi::RC_INVALID_REQUEST, - i_chip.getType(), - TARGETING::get_huid(l_pChip), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - TARGETING::TYPE l_type = TARGETING::TYPE_NA; - - if (i_chipletType == fapi::TARGET_TYPE_EX_CHIPLET) - { - l_type = TARGETING::TYPE_EX; - } - else if (i_chipletType == fapi::TARGET_TYPE_MBA_CHIPLET) - { - l_type = TARGETING::TYPE_MBA; - } - else if (i_chipletType == fapi::TARGET_TYPE_MCS_CHIPLET) - { - l_type = TARGETING::TYPE_MCS; - } - else if (i_chipletType == fapi::TARGET_TYPE_XBUS_ENDPOINT) - { - l_type = TARGETING::TYPE_XBUS; - } - else if (i_chipletType == fapi::TARGET_TYPE_ABUS_ENDPOINT) - { - l_type = TARGETING::TYPE_ABUS; - } - else if (i_chipletType == fapi::TARGET_TYPE_L4) - { - l_type = TARGETING::TYPE_L4; - } - else - { - FAPI_ERR("fapiGetChildChiplets. Chiplet type 0x%08x not supported", - i_chipletType); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_CHILD_CHIPLETS - * @reasoncode fapi::RC_UNSUPPORTED_REQUEST - * @userdata1 Type of requested chiplet - * @userdata2 Input Chip Target HUID - * @devdesc fapiGetChildChiplets request for unsupported - * or invalid chiplet type - * @custdesc A problem occurred during the IPL of the system: - * Request for an unsupported or invalid chiplet type. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_CHILD_CHIPLETS, - fapi::RC_UNSUPPORTED_REQUEST, - i_chipletType, - TARGETING::get_huid(l_pChip), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - if (!l_rc) - { - if (l_pChip == NULL) - { - FAPI_ERR("fapiGetChildChiplets. Embedded NULL target pointer"); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_CHILD_CHIPLETS - * @reasoncode fapi::RC_EMBEDDED_NULL_TARGET_PTR - * @devdesc Target has embedded null target pointer - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_CHILD_CHIPLETS, - fapi::RC_EMBEDDED_NULL_TARGET_PTR, - 0, 0, hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - TARGETING::TargetHandleList l_chipletList; - - TARGETING::getChildChiplets(l_chipletList, l_pChip, l_type, - false); - - // Return fapi::Targets to the caller - for (TARGETING::TargetHandleList::const_iterator - chipletIter = l_chipletList.begin(); - chipletIter != l_chipletList.end(); - ++chipletIter) - { - TARGETING::HwasState l_state = - (*chipletIter)->getAttr<TARGETING::ATTR_HWAS_STATE>(); - - // HWPs/FAPI considers partial good chiplets as present, but - // firmware considers them not-present. Return all chiplets - // in the model when caller requests PRESENT - if ((fapi::TARGET_STATE_FUNCTIONAL == i_state) && - !l_state.functional) - { - continue; - } - - fapi::Target l_chiplet(i_chipletType, - reinterpret_cast<void *>(*chipletIter)); - o_chiplets.push_back(l_chiplet); - } - } - } - } - - FAPI_DBG(EXIT_MRK "fapiGetChildChiplets. %d results", o_chiplets.size()); - return l_rc; -} - -//****************************************************************************** -// fapiGetAssociatedDimms function -//****************************************************************************** -fapi::ReturnCode fapiGetAssociatedDimms( - const fapi::Target& i_target, - std::vector<fapi::Target> & o_dimms, - const fapi::TargetState i_state) -{ - FAPI_DBG(ENTER_MRK "fapiGetAssociatedDimms. State: 0x%08x", i_state); - - fapi::ReturnCode l_rc; - o_dimms.clear(); - - // Extract the HostBoot Target pointer for the input target - TARGETING::Target * l_pTarget = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - if (l_pTarget == NULL) - { - FAPI_ERR("fapiGetAssociatedDimms. Embedded NULL target pointer"); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_ASSOCIATE_DIMMS - * @reasoncode fapi::RC_EMBEDDED_NULL_TARGET_PTR - * @devdesc Target has embedded null target pointer - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_ASSOCIATE_DIMMS, - fapi::RC_EMBEDDED_NULL_TARGET_PTR, - 0, 0, hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - // Get associated dimms - TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_LOGICAL_CARD, - TARGETING::TYPE_DIMM); - TARGETING::TargetHandleList l_dimmList; - - TARGETING::targetService(). - getAssociated(l_dimmList, l_pTarget, - TARGETING::TargetService::CHILD_BY_AFFINITY, - TARGETING::TargetService::ALL, &l_predicate); - - // Return fapi::Targets to the caller - for (TARGETING::TargetHandleList::const_iterator - dimmIter = l_dimmList.begin(); - dimmIter != l_dimmList.end(); - ++dimmIter) - { - TARGETING::HwasState l_state = - (*dimmIter)->getAttr<TARGETING::ATTR_HWAS_STATE>(); - - if ((fapi::TARGET_STATE_PRESENT == i_state) && !l_state.present) - { - continue; - } - if ((fapi::TARGET_STATE_FUNCTIONAL == i_state) && - !l_state.functional) - { - continue; - } - - fapi::Target l_dimm(fapi::TARGET_TYPE_DIMM, - reinterpret_cast<void *>(*dimmIter)); - o_dimms.push_back(l_dimm); - } - } - - FAPI_DBG(EXIT_MRK "fapiGetAssociatedDimms. %d results", o_dimms.size()); - return l_rc; -} - -//****************************************************************************** -// fapiGetParentChip function -//****************************************************************************** -fapi::ReturnCode fapiGetParentChip( - const fapi::Target& i_chiplet, - fapi::Target & o_chip) -{ - FAPI_DBG(ENTER_MRK "fapiGetParentChip"); - - fapi::ReturnCode l_rc; - - // Extract the HostBoot Target pointer for the input chiplet - TARGETING::Target * l_pChiplet = - reinterpret_cast<TARGETING::Target*>(i_chiplet.get()); - - // Check that the input target is a chiplet - if (!i_chiplet.isChiplet()) - { - FAPI_ERR("fapiGetParentChip. Input target type 0x%08x is not a chiplet", - i_chiplet.getType()); - - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_PARENT_CHIP - * @reasoncode fapi::RC_INVALID_REQUEST - * @userdata1 Type of input target - * @userdata2 Input Target HUID - * @devdesc fapiGetParentChip request for non-chiplet - * @custdesc A problem occurred during the IPL of the system. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_PARENT_CHIP, - fapi::RC_INVALID_REQUEST, - i_chiplet.getType(), - TARGETING::get_huid(l_pChiplet), - hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - if (l_pChiplet == NULL) - { - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_PARENT_CHIP - * @reasoncode fapi::RC_EMBEDDED_NULL_TARGET_PTR - * @devdesc Target has embedded null target pointer - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_PARENT_CHIP, - fapi::RC_EMBEDDED_NULL_TARGET_PTR, - 0, 0, hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - const TARGETING::Target * l_pChip = - TARGETING::getParentChip(l_pChiplet); - - if (l_pChip == NULL) - { - FAPI_ERR("fapiGetParentChip. Parent not found"); - /*@ - * @errortype - * @moduleid fapi::MOD_FAPI_GET_PARENT_CHIP - * @reasoncode fapi::RC_NO_SINGLE_PARENT - * @userdata1 Input Chiplet Target HUID - * @devdesc fapiGetParentChip did not find one parent - * @custdesc A problem occurred during the IPL of the system. - */ - const bool hbSwError = true; - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_PARENT_CHIP, - fapi::RC_NO_SINGLE_PARENT, - TARGETING::get_huid(l_pChiplet), - 0, hbSwError); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - // Set the output chip type - if (l_pChip->getAttr<TARGETING::ATTR_TYPE>() == - TARGETING::TYPE_PROC) - { - o_chip.setType(fapi::TARGET_TYPE_PROC_CHIP); - } - else - { - o_chip.setType(fapi::TARGET_TYPE_MEMBUF_CHIP); - } - - // Set the output chip (platform specific) handle - o_chip.set(reinterpret_cast<void *> - (const_cast<TARGETING::Target*>(l_pChip))); - } - } - } - - FAPI_DBG(EXIT_MRK "fapiGetParentChip"); - return l_rc; -} - - -} // extern "C" diff --git a/src/usr/hwpf/plat/fapiPlatTarget.C b/src/usr/hwpf/plat/fapiPlatTarget.C deleted file mode 100644 index 66299e1e0..000000000 --- a/src/usr/hwpf/plat/fapiPlatTarget.C +++ /dev/null @@ -1,279 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatTarget.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2014 */ -/* [+] 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 platTarget.C - * - * @brief Implements the platform part of the Target class. - * - * Note that platform code must provide the implementation. - * - * FAPI has provided a default implementation for platforms that use the - * handle pointer to point to a Component that is not created/deleted when a - * Target object is created/deleted (i.e. two Target objects that reference - * the same component have the same pointer). It could be possible for a - * platform specific ID structure to be created and pointed to each time a new - * Target is created, in that case, the pointed to object's type needs to be - * be known in order to do a deep compare/copy and a delete. - */ - -#include <fapiTarget.H> -#include <fapiPlatTrace.H> -#include <fapiUtil.H> -#include <targeting/common/attributes.H> -#include <string.h> - -namespace fapi -{ - -//****************************************************************************** -// Compare the handle -// -// If the pointers point to the same component then the handles are the same -//****************************************************************************** -bool Target::compareHandle(const Target & i_right) const -{ - return (iv_pHandle == i_right.iv_pHandle); -} - -//****************************************************************************** -// Copy the handle -// -// Note shallow copy of iv_pHandle. Both Targets point to the same component -//****************************************************************************** -void Target::copyHandle(const Target & i_right) -{ - iv_pHandle = i_right.iv_pHandle; -} - -//****************************************************************************** -// Delete the handle -//****************************************************************************** -void Target::deleteHandle() -{ - // Intentionally does nothing. The component must not be deleted -} - -//****************************************************************************** -// Get the ecmd-format string -//****************************************************************************** -const char * Target::toEcmdString() const -{ - if (iv_pEcmdString == NULL) - { - iv_pEcmdString = reinterpret_cast<char(*)>( - fapiMalloc(fapi::MAX_ECMD_STRING_LEN * sizeof(char))); - char (&l_ecmdString)[fapi::MAX_ECMD_STRING_LEN] = - *(reinterpret_cast<char(*)[fapi::MAX_ECMD_STRING_LEN]> - (iv_pEcmdString)); - toString(l_ecmdString); - } - - return iv_pEcmdString; -} - -//****************************************************************************** -// Get the ECMD String -//****************************************************************************** -void Target::toString(char (&o_ecmdString)[MAX_ECMD_STRING_LEN]) const -{ - // Extract the Targeting target pointer - TARGETING::Target* l_pTarget = - reinterpret_cast<TARGETING::Target*>(iv_pHandle); - - if (l_pTarget == NULL) - { - FAPI_ERR("toString: Called on NULL target"); - strcpy(o_ecmdString, "ecmd-no-target"); - } - else - { - // TODO. RTC 98421 - // This is a temporary function that constructs the ECMD String from the - // target's physical path attribute, eventually, the ECMD String will be - // its own attribute (sourced from the MRW) and this function will be - // changed to simply get the attribute - - // Try to get the physical path attribute - TARGETING::EntityPath l_path; - if (l_pTarget->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_path)) - { - uint32_t l_sizePath = l_path.size(); - - // This function returns the ecmd string for chips and chiplets. The - // output string is: - // Chiplet: <chip>.<unit> kX:nX:sX:pXX:cX - // Chip: <chip> kX:nX:sX:pXX - // There is officially a tab character between ">" and "k", this is - // replaced with the number of spaces seen in the Cronus trace - // If the k.. string is less than 19 chars, it is padded to 19 chars - // - // <chip> = chip type ("p8" = processor, "centaur" = memory buffer) - // <unit> = unit type ("ex", "mcs", "mba", "abus", "xbus") - // kX = cage number. Always zero - // nX = node number. Always zero (right now) - // sX = slot number. Always zero - // pXX = chip position - // cX = unit position - // - // Examples: - // "p8 k0:n0:s0:p01 " - // "p8.ex k0:n0:s0:p01:c0 " - // "p8.mcs k0:n0:s0:p01:c0 " - // "centaur k0:n0:s0:p01 " - const char * const ECMD_CHIP_PROC = "p8"; - const char * const ECMD_CHIP_PROC_SPC = " "; - const char * const ECMD_CHIP_MEMBUF = "centaur"; - const char * const ECMD_CHIP_MEMBUF_SPC = " "; - const char * const ECMD_CHIPLET_EX = "ex "; - const char * const ECMD_CHIPLET_MCS = "mcs "; - const char * const ECMD_CHIPLET_MBA = "mba "; - const char * const ECMD_CHIPLET_XBUS = "xbus "; - const char * const ECMD_CHIPLET_ABUS = "abus "; - const int K_STRING_LEN = 19; - - // Look for a chip in the path - const char * l_pChipType = NULL; - const char * l_pChipTypeSpc = NULL; - uint32_t l_chipPos = 0; - uint32_t l_node = 0; - - for (uint32_t i = 0; ((i < l_sizePath) && (l_pChipType == NULL)); - i++) - { - if(l_path[i].type == TARGETING::TYPE_NODE){ - l_node = l_path[i].instance; - } - if (l_path[i].type == TARGETING::TYPE_PROC) - { - l_pChipType = ECMD_CHIP_PROC; - l_pChipTypeSpc = ECMD_CHIP_PROC_SPC; - l_chipPos = l_path[i].instance; - } - else if (l_path[i].type == TARGETING::TYPE_MEMBUF) - { - l_pChipType = ECMD_CHIP_MEMBUF; - l_pChipTypeSpc = ECMD_CHIP_MEMBUF_SPC; - l_chipPos = l_path[i].instance; - } - } - - if (l_pChipType == NULL) - { - FAPI_ERR("toString: Physical Path does not contain known chip"); - strcpy(o_ecmdString, "ecmd-no-chip"); - } - else - { - // Look for the last chiplet in the path (some chiplets are - // children of other chiplets in PHYS_PATH e.g. MBS->MBA) - const char * l_pChipletType = NULL; - uint32_t l_chipletPos = 0; - - for (int32_t i = l_sizePath - 1; - ((i >= 0) && (l_pChipletType == NULL)); - i--) - { - if (l_path[i].type == TARGETING::TYPE_EX) - { - l_pChipletType = ECMD_CHIPLET_EX; - l_chipletPos = l_path[i].instance; - } - else if (l_path[i].type == TARGETING::TYPE_MCS) - { - l_pChipletType = ECMD_CHIPLET_MCS; - l_chipletPos = l_path[i].instance; - } - else if (l_path[i].type == TARGETING::TYPE_MBA) - { - l_pChipletType = ECMD_CHIPLET_MBA; - l_chipletPos = l_path[i].instance; - } - else if (l_path[i].type == TARGETING::TYPE_XBUS) - { - l_pChipletType = ECMD_CHIPLET_XBUS; - l_chipletPos = l_path[i].instance; - } - else if (l_path[i].type == TARGETING::TYPE_ABUS) - { - l_pChipletType = ECMD_CHIPLET_ABUS; - l_chipletPos = l_path[i].instance; - } - } - - // Construct the ecmd string - char * l_pStr = &o_ecmdString[0]; - - // Chip Type - strcpy(l_pStr, l_pChipType); - l_pStr += strlen(l_pChipType); - - if (l_pChipletType != NULL) - { - // Chiplet Type - *l_pStr = '.'; - l_pStr++; - - strcpy(l_pStr, l_pChipletType); - l_pStr += strlen(l_pChipletType); - } - else - { - strcpy(l_pStr, l_pChipTypeSpc); - l_pStr += strlen(l_pChipTypeSpc); - } - - int l_kstringlen = sprintf(l_pStr, "k0:n%d:s0:p%02d", - l_node, l_chipPos); - l_pStr += l_kstringlen; - - if (l_pChipletType != NULL) - { - // Chiplet Pos - int l_num = sprintf(l_pStr, ":c%d", l_chipletPos); - l_pStr += l_num; - l_kstringlen += l_num; - } - - // Pad the k-string to K_STRING_LEN characters - while (l_kstringlen < K_STRING_LEN) - { - *l_pStr = ' '; - l_pStr++; - l_kstringlen++; - } - - *l_pStr = '\0'; - } - } - else - { - FAPI_ERR("toString: Physical Path Attribute does not exist"); - strcpy(o_ecmdString, "ecmd-no-path"); - } - } -} - -} - diff --git a/src/usr/hwpf/plat/fapiPlatTask.C b/src/usr/hwpf/plat/fapiPlatTask.C deleted file mode 100644 index b4c06a7e0..000000000 --- a/src/usr/hwpf/plat/fapiPlatTask.C +++ /dev/null @@ -1,83 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatTask.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* COPYRIGHT International Business Machines Corp. 2012,2014 */ -/* */ -/* 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 fapiPlatTask.C - * - * @brief Performs the Hostboot fapi::plat startup task - */ - -//****************************************************************************** -// Includes -//****************************************************************************** -#include <initservice/taskargs.H> -#include <hwpf/plat/fapiPlatAttrOverrideSync.H> -#include <hwpf/plat/fapiPlatTrace.H> - -namespace fapi -{ - -//****************************************************************************** -// Global Variables -//****************************************************************************** -// Defined in fapiPlatAttrOverrideSync.C -extern TARGETING::AttributeTank::AttributeHeader g_attrOverrideHeader; -extern uint8_t g_attrOverride[AttrOverrideSync::MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES]; -extern uint8_t g_attrOverrideFapiTank; - -//****************************************************************************** -// This function monitors for FSP mailbox messages -//****************************************************************************** -void * platMonitorForFspMessages(void * i_pContext) -{ - FAPI_IMP("Starting platMonitorForFspMessages"); - fapi::theAttrOverrideSync().monitorForFspMessages(); - return NULL; // Execution should never reach here -} - -//****************************************************************************** -// This function is run when the extended initservice loads the plat module -// -// It writes the global variables associated with direct attribute override to -// ensure they are paged and pinned in memory. These variables are used by a -// debug tool to override attributes -// -// It starts a task that monitors for FSP mailbox messages on the -// HB_HWPF_ATTR_MSGQ message queue -//****************************************************************************** -void platTaskEntry(errlHndl_t &io_errl) -{ - FAPI_IMP("Starting platTaskEntry"); - - // Write the global variables associated with direct attribute override - g_attrOverrideHeader.iv_attrId = 0; - g_attrOverride[0] = 0; - g_attrOverrideFapiTank = 0; - - // Start task that monitors for FSP mailbox messages - task_create(fapi::platMonitorForFspMessages, NULL); -} - -} // End fapi namespace - -// Macro that creates the _start function -TASK_ENTRY_MACRO(fapi::platTaskEntry); diff --git a/src/usr/hwpf/plat/fapiPlatUtil.C b/src/usr/hwpf/plat/fapiPlatUtil.C deleted file mode 100644 index a61cd012a..000000000 --- a/src/usr/hwpf/plat/fapiPlatUtil.C +++ /dev/null @@ -1,340 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/plat/fapiPlatUtil.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ -/* [+] 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 fapiPlatUtil.C - * - * @brief Implements the fapiUtil.H utility functions. - * - * Note that platform code must provide the implementation. - */ - -#include <assert.h> -#include <fapi.H> -#include <trace/interface.H> -#include <sys/time.h> -#include <errl/errlmanager.H> -#include <fapiPlatHwpInvoker.H> -#include <vfs/vfs.H> -#include <initservice/initsvcbreakpoint.H> -#include <errl/errlentry.H> -#include <initservice/initserviceif.H> -#include <util/align.H> -#include <fapiPlatUtil.H> - -#ifdef __HOSTBOOT_RUNTIME -#include <runtime/interface.h> -#include <targeting/common/targetservice.H> -#include <runtime/rt_targeting.H> -#include <isteps/hwpf_reasoncodes.H> -#include "handleSpecialWakeup.H" -#endif - -//****************************************************************************** -// Trace descriptors -//****************************************************************************** -trace_desc_t* g_fapiTd; -trace_desc_t* g_fapiImpTd; -trace_desc_t* g_fapiScanTd; -trace_desc_t* g_fapiMfgTd; - -//****************************************************************************** -// Global TracInit objects. Construction will initialize the trace buffer -//****************************************************************************** -TRAC_INIT(&g_fapiTd, FAPI_TRACE_NAME, 2*KILOBYTE); -TRAC_INIT(&g_fapiImpTd, FAPI_IMP_TRACE_NAME, 2*KILOBYTE); -TRAC_INIT(&g_fapiScanTd, FAPI_SCAN_TRACE_NAME, 4*KILOBYTE); -TRAC_INIT(&g_fapiMfgTd, FAPI_MFG_TRACE_NAME, 4*KILOBYTE); - -extern "C" -{ - -//****************************************************************************** -// fapiAssert -//****************************************************************************** -void fapiAssert(bool i_expression) -{ - assert(i_expression); -} - -//****************************************************************************** -// fapiDelay -// -// At the present time, VBU runs hostboot without a Simics -// front end. If a HW procedure wants to delay, we just make the -// syscall nanosleep(). In the syscall, the kernel will continue to consume -// clock cycles as it looks for a runnable task. When the sleep time expires, -// the calling task will resume running. -// -// In the future there could be a Simics front end to hostboot VBU. Then -// a possible implementation will be to use the Simics magic instruction -// to trigger a Simics hap. The Simics hap handler can call the simdispatcher -// client/server API to tell the Awan to advance some number of cycles. -// -// Monte 4 Aug 2011 -//****************************************************************************** - -fapi::ReturnCode fapiDelay(uint64_t i_nanoSeconds, uint64_t i_simCycles) -{ - FAPI_DBG( INFO_MRK "delay %lld nanosec", i_nanoSeconds ); - nanosleep( 0, i_nanoSeconds ); - return fapi::FAPI_RC_SUCCESS; -} - -//****************************************************************************** -// fapiLogError -//****************************************************************************** -void fapiLogError(fapi::ReturnCode & io_rc, - fapi::fapiErrlSeverity_t i_sev, - bool i_unitTestError) -{ - // ENUM CONVERSION FAPI to PLATFORM - - errlHndl_t l_pError = NULL; - - FAPI_INF("fapiLogError: logging error"); - - // Convert a FAPI severity to a ERRORLOG severity - ERRORLOG::errlSeverity_t l_sev = ERRORLOG::ERRL_SEV_UNRECOVERABLE; - switch (i_sev) - { - case fapi::FAPI_ERRL_SEV_RECOVERED: - l_sev = ERRORLOG::ERRL_SEV_RECOVERED; - break; - case fapi::FAPI_ERRL_SEV_PREDICTIVE: - l_sev = ERRORLOG::ERRL_SEV_PREDICTIVE; - break; - case fapi::FAPI_ERRL_SEV_UNRECOVERABLE: - // l_sev set above - break; - default: - FAPI_ERR("severity (i_sev) of %d is unknown",i_sev); - } - - // Convert the return code to an error log. - // This will set the return code to FAPI_RC_SUCCESS and clear any PLAT Data, - // HWP FFDC data, and Error Target associated with it. - l_pError = fapiRcToErrl(io_rc, l_sev); - - // Commit the error log. This will delete the error log and set the handle - // to NULL. - if (i_unitTestError) - { - errlCommit(l_pError, CXXTEST_COMP_ID); - } - else - { - errlCommit(l_pError, HWPF_COMP_ID); - } -} - -//****************************************************************************** -// platIsScanTraceEnabled -//****************************************************************************** -bool platIsScanTraceEnabled() -{ - // SCAN trace can be dynamically turned on/off, always return true here - return 1; -} - -//****************************************************************************** -// platSetScanTrace -// Implementation to be added if needed -//****************************************************************************** -//void platSetScanTrace(bool i_enable) -//{ -// -//} - -//****************************************************************************** -// fapiLoadInitFile -//****************************************************************************** -fapi::ReturnCode fapiLoadInitFile(const fapi::Target & i_Target, - const char * i_file, const char *& o_addr, size_t & o_size) -{ -#ifndef __HOSTBOOT_RUNTIME - fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; - errlHndl_t l_pError = NULL; - o_size = 0; - o_addr = NULL; - - FAPI_INF("fapiLoadInitFile: %s", i_file); - - l_pError = VFS::module_load(i_file); - if(l_pError) - { - // Add the error log pointer as data to the ReturnCode - FAPI_ERR("fapiLoadInitFile: module_load failed"); - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - l_pError = VFS::module_address(i_file, o_addr, o_size); - if(l_pError) - { - // Add the error log pointer as data to the ReturnCode - FAPI_ERR("fapiLoadInitFile: module_address failed"); - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - FAPI_DBG("fapiLoadInitFile: data module addr = %p, size = %ld", - o_addr, o_size); - FAPI_DBG("fapiLoadInitFile: *addr = 0x%llX", - *(reinterpret_cast<const uint64_t*>(o_addr))); - } - } -#else - fapi::ReturnCode l_rc = fapi::FAPI_RC_PLAT_NOT_SUPPORTED_AT_RUNTIME; -#endif - - return l_rc; -} - -//****************************************************************************** -// fapiUnloadInitFile -//****************************************************************************** -fapi::ReturnCode fapiUnloadInitFile(const char * i_file, const char *& io_addr, - size_t & io_size) -{ -#ifndef __HOSTBOOT_RUNTIME - fapi::ReturnCode l_rc = fapi::FAPI_RC_SUCCESS; - errlHndl_t l_pError = NULL; - - FAPI_INF("fapiUnloadInitFile: %s", i_file); - - l_pError = VFS::module_unload(i_file); - if(l_pError) - { - // Add the error log pointer as data to the ReturnCode - FAPI_ERR("fapiUnloadInitFile: module_unload failed %s", i_file); - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - } - else - { - io_addr = NULL; - io_size = 0; - } -#else - fapi::ReturnCode l_rc = fapi::FAPI_RC_PLAT_NOT_SUPPORTED_AT_RUNTIME; -#endif - - return l_rc; -} - -//****************************************************************************** -// fapiBreakPoint -//****************************************************************************** -void fapiBreakPoint( uint32_t i_info) -{ -#ifndef __HOSTBOOT_RUNTIME - INITSERVICE::iStepBreakPoint( i_info ); -#endif -} - -//****************************************************************************** -// fapiSpecialWakeup -//****************************************************************************** -fapi::ReturnCode fapiSpecialWakeup(const fapi::Target & i_target, - const bool i_enable) -{ - fapi::ReturnCode fapi_rc = fapi::FAPI_RC_SUCCESS; - FAPI_INF("fapiSpecialWakeup"); -#ifdef __HOSTBOOT_RUNTIME - if(!INITSERVICE::spBaseServicesEnabled()) - { - TARGETING::Target* l_EXtarget = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - errlHndl_t err_SW = handleSpecialWakeup(l_EXtarget,i_enable); - if(err_SW) - { - fapi_rc.setPlatError(reinterpret_cast<void *>(err_SW)); - } - - } - else if(g_hostInterfaces && g_hostInterfaces->wakeup) - { - TARGETING::Target* target = - reinterpret_cast<TARGETING::Target*>(i_target.get()); - - RT_TARG::rtChipId_t core_id = 0; - errlHndl_t err = RT_TARG::getRtTarget(target, core_id); - if(err) - { - fapi_rc.setPlatError(reinterpret_cast<void *>(err)); - } - else - { - uint32_t mode = 0; //Force awake - if(!i_enable) - { - mode = 1; // clear force - } - int rc = g_hostInterfaces->wakeup(core_id, mode); - - if(rc) - { - FAPI_ERR("CPU core wakeup call to hypervisor returned rc = %d", - rc); - /*@ - * @errortype - * @moduleid fapi::MOD_PLAT_SPECIAL_WAKEUP - * @reasoncode fapi::RC_RT_WAKEUP_FAILED - * @userdata1 Hypervisor return code - * @userdata2 Chiplet HUID - * @devdesc Error code from hypervisor wakeup call - */ - const bool hbSwError = true; - err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_PLAT_SPECIAL_WAKEUP, - fapi::RC_RT_WAKEUP_FAILED, - rc, - TARGETING::get_huid(target), - hbSwError); - - fapi_rc.setPlatError(reinterpret_cast<void*>(err)); - } - } - } -#endif - // On Hostboot, processor cores cannot sleep so return success to the - // fapiSpecialWakeup enable/disable calls - return fapi_rc; -} - -} - -//****************************************************************************** -// fapiPlatMalloc -//****************************************************************************** -void* fapiPlatMalloc(size_t s) -{ - if (s > PAGE_SIZE) - { - s = PAGE_SIZE * ALIGN_POW2(ALIGN_PAGE(s) / PAGE_SIZE); - } - return malloc(s); -} diff --git a/src/usr/hwpf/plat/makefile b/src/usr/hwpf/plat/makefile deleted file mode 100644 index 912a359ea..000000000 --- a/src/usr/hwpf/plat/makefile +++ /dev/null @@ -1,33 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/hwpf/plat/makefile $ -# -# OpenPOWER HostBoot Project -# -# COPYRIGHT International Business Machines Corp. 2011,2014 -# -# 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 -ROOTPATH = ../../../.. -MODULE = plat - -# include common fapi OBJs between HB and HBRT -include plat.mk - -OBJS += fapiPlatTask.o - -SUBDIRS += runtime.d - -include ${ROOTPATH}/config.mk diff --git a/src/usr/hwpf/plat/plat.mk b/src/usr/hwpf/plat/plat.mk deleted file mode 100644 index 063796055..000000000 --- a/src/usr/hwpf/plat/plat.mk +++ /dev/null @@ -1,44 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/hwpf/plat/plat.mk $ -# -# OpenPOWER HostBoot Project -# -# Contributors Listed Below - COPYRIGHT 2014,2015 -# [+] 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 -# Common to both HB and HBRT -EXTRAINCDIR += ${ROOTPATH}/src/include/usr/ecmddatabuffer -EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat -EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi -EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp -EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/include -EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/pstates/pstates -EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/dram_initialization/proc_setup_bars - -OBJS += fapiPlatHwAccess.o -OBJS += fapiPlatHwpInvoker.o -OBJS += fapiPlatReturnCodeDataRef.o -OBJS += fapiPlatSystemConfig.o -OBJS += fapiPlatTarget.o -OBJS += fapiPlatUtil.o -OBJS += fapiPlatAttributeService.o -OBJS += fapiPlatMvpdAccess.o -OBJS += fapiPlatMBvpdAccess.o -OBJS += fapiPlatAttrOverrideSync.o - diff --git a/src/usr/hwpf/plat/runtime/makefile b/src/usr/hwpf/plat/runtime/makefile deleted file mode 100644 index 76e324d85..000000000 --- a/src/usr/hwpf/plat/runtime/makefile +++ /dev/null @@ -1,35 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/hwpf/plat/runtime/makefile $ -# -# OpenPOWER HostBoot Project -# -# Contributors Listed Below - COPYRIGHT 2013,2015 -# [+] 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 -HOSTBOOT_RUNTIME = 1 -ROOTPATH = ../../../../.. -MODULE = plat_rt -VPATH += ../ - -EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp/pll_accessors/ -EXTRAINCDIR += ${ROOTPATH}/src/usr/scom/runtime - -# include common fapi OBJs -include ../plat.mk - -include ${ROOTPATH}/config.mk |

