diff options
author | Mike Jones <mjjones@us.ibm.com> | 2011-09-13 11:44:54 -0500 |
---|---|---|
committer | MIKE J. JONES <mjjones@us.ibm.com> | 2011-09-14 08:26:05 -0500 |
commit | e59e01da049d2b864ff7cb1dd03b82e5a8a393b9 (patch) | |
tree | 138460bf6523c5b94a46f5100dac468f6026348f /src | |
parent | f00cbc2321649c74c078784a1fc47da3b10e1a54 (diff) | |
download | talos-hostboot-e59e01da049d2b864ff7cb1dd03b82e5a8a393b9.tar.gz talos-hostboot-e59e01da049d2b864ff7cb1dd03b82e5a8a393b9.zip |
HWPF: Add support for new System Config Query functions
Change-Id: I00220dc4a1ee4f630138d0ed87a943053a7a93d5
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/337
Tested-by: Jenkins Server
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Reviewed-by: Monte K. Copeland <copelanm@us.ibm.com>
Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiSystemConfig.H | 99 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiTarget.H | 29 | ||||
-rw-r--r-- | src/include/usr/hwpf/hwp/fapiTestHwpConfig.H | 59 | ||||
-rw-r--r-- | src/include/usr/hwpf/plat/fapiPlatHwpExecutor.H | 1 | ||||
-rw-r--r-- | src/include/usr/hwpf/plat/fapiPlatReasonCodes.H | 11 | ||||
-rw-r--r-- | src/include/usr/targeting/predicates/predicatectm.H | 50 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiTarget.C | 23 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiTestHwpConfig.C | 116 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/makefile | 3 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatSystemConfig.C | 266 | ||||
-rw-r--r-- | src/usr/hwpf/test/hwpftest.H | 35 |
11 files changed, 606 insertions, 86 deletions
diff --git a/src/include/usr/hwpf/fapi/fapiSystemConfig.H b/src/include/usr/hwpf/fapi/fapiSystemConfig.H index cf00fda90..5bb704661 100644 --- a/src/include/usr/hwpf/fapi/fapiSystemConfig.H +++ b/src/include/usr/hwpf/fapi/fapiSystemConfig.H @@ -27,6 +27,14 @@ * implement. It is an eCMD requirement that these be "C" functions. */ +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 09/12/2011 Updated with new functions. + * + */ + #ifndef FAPISYSTEMCONFIG_H_ #define FAPISYSTEMCONFIG_H_ @@ -38,57 +46,54 @@ extern "C" { -/** - * @brief Gets the functional chiplets that are children of the supplied target - * - * @param[in] i_target Parent target - * @param[in] i_targetType Type of chiplet required - * @param[out] o_chiplets Reference to vector that is filled in with the - * result chiplets - * - * @return ReturnCode. Zero on success, else error - */ -fapi::ReturnCode GetFunctionalChiplets(const fapi::Target& i_target, - const fapi::TargetType i_chipletType, - std::vector<fapi::Target> & o_chiplets); - -/** - * @brief Gets the existing chiplets that are children of the supplied target - * - * @param[in] i_target Parent target - * @param[in] i_targetType Type of chiplet required - * @param[out] o_chiplets Reference to vector that is filled in with the - * result chiplets - * - * @return ReturnCode. Zero on success, else error - */ -fapi::ReturnCode GetExistingChiplets(const fapi::Target& i_target, - const fapi::TargetType i_chipletType, - std::vector<fapi::Target> & o_chiplets); +/** + * @brief Gets the chiplets that are children of the input chip + * + * @param[in] i_chip Input chip + * @param[in] i_chipletType Type of chiplet required + * @param[out] o_chiplets Reference to vector that is cleared then filled in + * with the children chiplet Targets + * @param[in] i_state Only return targets of the specified state. Either + * present or functional (default) + * + * @return ReturnCode. Zero on success, else error + */ +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::TARGET_STATE_FUNCTIONAL); -/** - * @brief Gets the functional DIMMs that are children of the supplied target - * - * @param[in] i_target Parent target - * @param[out] o_dimms Reference to vector that is filled in with the result - * DIMMs +/** + * @brief Gets the DIMMs that are logically associated with the input target * - * @return ReturnCode. Zero on success, else error - */ -fapi::ReturnCode GetFunctionalDimms(const fapi::Target& i_target, - std::vector<fapi::Target> & o_dimms); + * The logical association is MCS-MBS-MBA-DIMM. The input target must be a MCS, + * MBS or MBA chiplet and the output will be the associated DIMMs + * + * @param[in] i_target Input target + * @param[out] o_dimms Reference to vector that is cleared then filled in with + * the associated DIMM Targets + * @param[in] i_state Only return targets of the specified state. Either + * present or functional (default) + * + * @return ReturnCode. Zero on success, else error + */ +fapi::ReturnCode fapiGetAssociatedDimms( + const fapi::Target& i_target, + std::vector<fapi::Target> & o_dimms, + const fapi::TargetState i_state = fapi::TARGET_STATE_FUNCTIONAL); -/** - * @brief Gets the existing DIMMs that are children of the supplied target +/** + * @brief Gets the parent chip of the input chiplet * - * @param[in] i_target Parent target - * @param[out] o_dimms Reference to vector that is filled in with the result - * DIMMs - * - * @return ReturnCode. Zero on success, else error - */ -fapi::ReturnCode GetExistingDimms(const fapi::Target& i_target, - std::vector<fapi::Target> & o_dimms); + * @param[in] i_chiplet Input chiplet + * @param[out] o_chip Reference to Target that is set to the parent chip + * + * @return ReturnCode. Zero on success, else error + */ +fapi::ReturnCode fapiGetParentChip( + const fapi::Target& i_chiplet, + fapi::Target & o_chip); } // extern "C" diff --git a/src/include/usr/hwpf/fapi/fapiTarget.H b/src/include/usr/hwpf/fapi/fapiTarget.H index 1ee28236d..7b87ffc16 100644 --- a/src/include/usr/hwpf/fapi/fapiTarget.H +++ b/src/include/usr/hwpf/fapi/fapiTarget.H @@ -35,6 +35,7 @@ * mjjones 06/29/2011 Removed incorrect MSB from 2 enums * mjjones 07/05/2011 Removed const from handle * mjjones 08/29/2011 Updated toString function + * mjjones 09/12/2011 Added isChip and isChiplet */ #ifndef FAPITARGET_H_ @@ -68,6 +69,20 @@ enum TargetType typedef uint32_t TargetTypes_t; /** + * @brief Enumeration of target state values (bitmask values) + */ +enum TargetState +{ + TARGET_STATE_PRESENT = 0x00000001, + TARGET_STATE_FUNCTIONAL = 0x00000002, +}; + +/** + * @brief Typedef used when passing multiple TargetState values + */ +typedef uint32_t TargetStates_t; + +/** * @brief ECMD constants */ const uint32_t MAX_ECMD_STRING_LEN = 64; @@ -176,6 +191,20 @@ public: void setType(const TargetType i_type); /** + * @brief Returns if the target is a chip + * + * @return boolean. true if chip else fase + */ + bool isChip() const; + + /** + * @brief Returns if the target is a chiplet + * + * @return boolean. true if chiplet else fase + */ + bool isChiplet() const; + + /** * @brief Convert a target to an ecmd-format target string * * This is used in order to trace the target in the common SCAN trace diff --git a/src/include/usr/hwpf/hwp/fapiTestHwpConfig.H b/src/include/usr/hwpf/hwp/fapiTestHwpConfig.H new file mode 100644 index 000000000..4faec30ef --- /dev/null +++ b/src/include/usr/hwpf/hwp/fapiTestHwpConfig.H @@ -0,0 +1,59 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/hwpf/hwp/fapiTestHwpConfig.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END +/** + * @file fapiTestHwpConfig.H + * + * @brief Defines a Hardware Procedure that exercises the FAPI System Config + * Query functions. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 09/12/2011 Created. + * + */ + +#ifndef FAPITESTHWCONFIG_H_ +#define FAPITESTHWCONFIG_H_ + +#include <fapi.H> + +// HWPs are defined as C functions because platforms may wish to package them +// in linux shared libraries which are DL-Opened +extern "C" +{ + +/** + * @brief A simple HWP that exercises the FAPI System Config Query functions. + * + * @param[in] i_chip Reference to target processor chip + * + * @return ReturnCode + */ +fapi::ReturnCode hwpTestConfig(const fapi::Target & i_chip); + +} // extern "C" + +#endif diff --git a/src/include/usr/hwpf/plat/fapiPlatHwpExecutor.H b/src/include/usr/hwpf/plat/fapiPlatHwpExecutor.H index 85a41e2e9..f751ffaf2 100644 --- a/src/include/usr/hwpf/plat/fapiPlatHwpExecutor.H +++ b/src/include/usr/hwpf/plat/fapiPlatHwpExecutor.H @@ -37,6 +37,7 @@ #include <fapiTestHwp.H> #include <fapiTestHwpError.H> #include <fapiTestHwpFfdc.H> +#include <fapiTestHwpConfig.H> /** * @brief HWP Executor macro diff --git a/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H b/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H index 124ec8171..03296c7dd 100644 --- a/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H +++ b/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H @@ -29,13 +29,18 @@ namespace fapi { enum hwpfModuleId { - MOD_RC_TO_ERRL = 0x01, + MOD_RC_TO_ERRL = 0x01, + MOD_FAPI_GET_CHILD_CHIPLETS = 0x02, + MOD_FAPI_GET_PARENT_CHIP = 0x03, }; enum hwpfReasonCode { - RC_HWP_ERROR = HWPF_COMP_ID | 0x01, - RC_FAPI_ERROR = HWPF_COMP_ID | 0x02, + RC_HWP_ERROR = HWPF_COMP_ID | 0x01, + RC_FAPI_ERROR = HWPF_COMP_ID | 0x02, + RC_INVALID_REQUEST = HWPF_COMP_ID | 0x03, + RC_UNSUPPORTED_REQUEST = HWPF_COMP_ID | 0x04, + RC_NO_SINGLE_PARENT = HWPF_COMP_ID | 0x05, }; }; diff --git a/src/include/usr/targeting/predicates/predicatectm.H b/src/include/usr/targeting/predicates/predicatectm.H index 79a374c50..c68987c7f 100644 --- a/src/include/usr/targeting/predicates/predicatectm.H +++ b/src/include/usr/targeting/predicates/predicatectm.H @@ -92,7 +92,28 @@ class PredicateCTM : public PredicateBase #define TARG_FUNC "~PredicateCTM()" #undef TARG_FUNC } - + + /** + * @brief Set the class + * + * @param[in] i_class Class of matching target + */ + void setClass(CLASS i_class); + + /** + * @brief Set the type + * + * @param[in] i_type Type of matching target + */ + void setType(TYPE i_type); + + /** + * @brief Set the model + * + * @param[in] i_model Model of matching target + */ + void setModel(MODEL i_model); + /** * @brief Returns whether target matches the specified class, type, * model @@ -132,6 +153,33 @@ inline PredicateCTM::PredicateCTM( #undef TARG_FUNC } +//****************************************************************************** +// PredicateCTM::setClass +//****************************************************************************** + +inline void PredicateCTM::setClass(CLASS i_class) +{ + iv_class = i_class; +} + +//****************************************************************************** +// PredicateCTM::setType +//****************************************************************************** + +inline void PredicateCTM::setType(TYPE i_type) +{ + iv_type = i_type; +} + +//****************************************************************************** +// PredicateCTM::setModel +//****************************************************************************** + +inline void PredicateCTM::setModel(MODEL i_model) +{ + iv_model = i_model; +} + #undef TARG_CLASS #undef TARG_NAMESPACE diff --git a/src/usr/hwpf/fapi/fapiTarget.C b/src/usr/hwpf/fapi/fapiTarget.C index 9d434b715..899cc4503 100644 --- a/src/usr/hwpf/fapi/fapiTarget.C +++ b/src/usr/hwpf/fapi/fapiTarget.C @@ -31,7 +31,8 @@ * Flag Defect/Feature User Date Description * ------ -------------- ---------- ----------- ---------------------------- * mjjones 04/13/2011 Created. Based on Hlava prototype - * mjjones 07/05/2011. Removed const from handle + * mjjones 07/05/2011 Removed const from handle + * mjjones 09/12/2011 Added isChip and isChiplet */ #include <fapiTarget.H> @@ -145,4 +146,24 @@ void Target::setType(const TargetType i_type) iv_type = i_type; } +//****************************************************************************** +// Is the target a chip? +//****************************************************************************** +bool Target::isChip() const +{ + return ((iv_type == TARGET_TYPE_PROC_CHIP) || + (iv_type == TARGET_TYPE_MEMBUF_CHIP)); +} + +//****************************************************************************** +// Is the target a chiplet? +//****************************************************************************** +bool Target::isChiplet() const +{ + return ((iv_type == TARGET_TYPE_EX_CHIPLET) || + (iv_type == TARGET_TYPE_MBA_CHIPLET) || + (iv_type == TARGET_TYPE_MBS_CHIPLET) || + (iv_type == TARGET_TYPE_MCS_CHIPLET)); +} + } diff --git a/src/usr/hwpf/hwp/fapiTestHwpConfig.C b/src/usr/hwpf/hwp/fapiTestHwpConfig.C new file mode 100644 index 000000000..ce47b82df --- /dev/null +++ b/src/usr/hwpf/hwp/fapiTestHwpConfig.C @@ -0,0 +1,116 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/hwpf/hwp/fapiTestHwpConfig.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2011 +// +// p1 +// +// Object Code Only (OCO) source materials +// Licensed Internal Code Source Materials +// IBM HostBoot Licensed Internal Code +// +// The source code for this program is not published or other- +// wise divested of its trade secrets, irrespective of what has +// been deposited with the U.S. Copyright Office. +// +// Origin: 30 +// +// IBM_PROLOG_END +/** + * @file fapiTestHwpConfig.C + * + * @brief Implements a Hardware Procedure that exercises the FAPI System Config + * Query functions. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 09/12/2011 Created. + * + */ + +#include <fapiTestHwpConfig.H> + +extern "C" +{ + +//****************************************************************************** +// hwpTestConfig +//****************************************************************************** +fapi::ReturnCode hwpTestConfig(const fapi::Target & i_chip) +{ + FAPI_INF("Performing HWP: hwpTestConfig"); + + // Print the ecmd string of the chip + char l_string[fapi::MAX_ECMD_STRING_LEN] = {0}; + i_chip.toString(l_string); + FAPI_INF("hwpInitialTest: Chip: %s", l_string); + + fapi::ReturnCode l_rc; + std::vector<fapi::Target> l_targets; + + // Call fapiGetChildChiplets to get the child MCS chiplets + l_rc = fapiGetChildChiplets(i_chip, fapi::TARGET_TYPE_MCS_CHIPLET, + l_targets); + + if (l_rc) + { + FAPI_ERR("hwpTestConfig: Error from fapiGetChildChiplets"); + } + else + { + FAPI_INF("hwpTestConfig: %d MCS chiplets", l_targets.size()); + + if (l_targets.size() == 0) + { + FAPI_ERR("hwpTestConfig: No MCS chiplets"); + l_rc = fapi::RC_TEST_ERROR_A; + } + else + { + // Save the first MCS target + fapi::Target l_mcs = l_targets[0]; + + // Call fapiGetAssociatedDimms to get the dimms for this MCS + l_rc = fapiGetAssociatedDimms(l_mcs, l_targets); + + if (l_rc) + { + FAPI_ERR("hwpTestConfig: Error from fapiGetAssociatedDimms"); + } + else + { + FAPI_INF("hwpTestConfig: %d dimms", l_targets.size()); + + // Call fapiGetParentChip to get the parent of the MCS + fapi::Target l_chip; + + l_rc = fapiGetParentChip(l_mcs, l_chip); + + if (l_rc) + { + FAPI_ERR("hwpTestConfig: Error from fapiGetParentChip"); + } + else + { + // Check that the parent chip is is same as the input chip + if (i_chip != l_chip) + { + FAPI_ERR("hwpTestConfig: Chip mismatch"); + l_rc = fapi::RC_TEST_ERROR_B; + } + } + } + } + } + + return l_rc; +} + +} // extern "C" diff --git a/src/usr/hwpf/hwp/makefile b/src/usr/hwpf/hwp/makefile index 1cd1d9851..4eb0da718 100644 --- a/src/usr/hwpf/hwp/makefile +++ b/src/usr/hwpf/hwp/makefile @@ -30,6 +30,7 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat OBJS = fapiTestHwp.o \ fapiTestHwpError.o \ - fapiTestHwpFfdc.o + fapiTestHwpFfdc.o \ + fapiTestHwpConfig.o include ${ROOTPATH}/config.mk diff --git a/src/usr/hwpf/plat/fapiPlatSystemConfig.C b/src/usr/hwpf/plat/fapiPlatSystemConfig.C index bbde5099e..31f10e05a 100644 --- a/src/usr/hwpf/plat/fapiPlatSystemConfig.C +++ b/src/usr/hwpf/plat/fapiPlatSystemConfig.C @@ -28,67 +28,271 @@ * Note that platform code must provide the implementation. */ -#include <fapiSystemConfig.H> #include <fapiPlatTrace.H> +#include <fapiSystemConfig.H> +#include <fapiPlatReasonCodes.H> +#include <errl/errlentry.H> +#include <targeting/targetservice.H> +#include <targeting/predicates/predicatectm.H> extern "C" { //****************************************************************************** -// GetFunctionalChiplets function +// fapiGetChildChiplets function //****************************************************************************** -fapi::ReturnCode GetFunctionalChiplets(const fapi::Target& i_target, - const fapi::TargetType i_chipletType, - std::vector<fapi::Target> & o_chiplets) +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 "GetFunctionalChiplets"); + // TODO. Need to support i_state - FAPI_DBG(EXIT_MRK "GetFunctionalChiplets"); + FAPI_INF(ENTER_MRK "fapiGetChildChiplets. Chiplet Type: 0x%x. State: 0x%x", + i_chipletType, i_state); - return fapi::FAPI_RC_PLAT_NOT_IMPLEMENTED; -} + fapi::ReturnCode l_rc; + o_chiplets.clear(); -//****************************************************************************** -// GetExistingChiplets function -//****************************************************************************** -fapi::ReturnCode GetExistingChiplets(const fapi::Target& i_target, - const fapi::TargetType i_chipletType, - std::vector<fapi::Target> & o_chiplets) -{ - FAPI_DBG(ENTER_MRK "GetExistingChiplets"); + // Create a Class/Type/Model predicate to look for units + TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_UNIT); + + // Check that the input target is a chip + if (!i_chip.isChip()) + { + FAPI_ERR("fapiGetChildChiplets. Input target type 0x%x is not a chip", + i_chip.getType()); - FAPI_DBG(EXIT_MRK "GetExistingChiplets"); + /*@ + * @errortype + * @moduleid MOD_FAPI_GET_CHILD_CHIPLETS + * @reasoncode RC_INVALID_REQUEST + * @userdata1 Type of input target + * @devdesc fapiGetChildChiplets request for non-chip + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi::MOD_FAPI_GET_CHILD_CHIPLETS, + fapi::RC_INVALID_REQUEST, + i_chip.getType()); - return fapi::FAPI_RC_PLAT_NOT_IMPLEMENTED; + // Attach the error log to the fapi::ReturnCode + l_rc = fapi::FAPI_RC_PLAT_ERR_SEE_DATA; + l_rc.setPlatData(reinterpret_cast<void *> (l_pError)); + } + else + { + // Update the predicate to look for the specified type + if (i_chipletType == fapi::TARGET_TYPE_EX_CHIPLET) + { + l_predicate.setType(TARGETING::TYPE_EX); + } + else if (i_chipletType == fapi::TARGET_TYPE_MBA_CHIPLET) + { + l_predicate.setType(TARGETING::TYPE_MBA); + } + else if (i_chipletType == fapi::TARGET_TYPE_MBS_CHIPLET) + { + l_predicate.setType(TARGETING::TYPE_MBS); + } + else if (i_chipletType == fapi::TARGET_TYPE_MCS_CHIPLET) + { + l_predicate.setType(TARGETING::TYPE_MCS); + } + else + { + FAPI_ERR("fapiGetChildChiplets. Chiplet type 0x%x not supported", + i_chipletType); + /*@ + * @errortype + * @moduleid MOD_FAPI_GET_CHILD_CHIPLETS + * @reasoncode RC_UNSUPPORTED_REQUEST + * @userdata1 Type of requested chiplet + * @devdesc fapiGetChildChiplets request for unsupported + * or invalid chiplet type + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi::MOD_FAPI_GET_CHILD_CHIPLETS, + fapi::RC_UNSUPPORTED_REQUEST, + i_chipletType); + + // Attach the error log to the fapi::ReturnCode + l_rc = fapi::FAPI_RC_PLAT_ERR_SEE_DATA; + l_rc.setPlatData(reinterpret_cast<void *> (l_pError)); + } + } + + if (!l_rc) + { + // Extract the HostBoot Target pointer for the input chip + TARGETING::Target * l_pChip = + reinterpret_cast<TARGETING::Target*>(i_chip.get()); + + // Create a vector of TARGETING::Target pointers + TARGETING::TargetHandleList l_chipletList; + + // Get children chiplets + TARGETING::targetService(). + getAssociated(l_chipletList, l_pChip, + TARGETING::TargetService::CHILD, + TARGETING::TargetService::IMMEDIATE, &l_predicate); + + // Return fapi::Targets to the caller + for (uint32_t i = 0; i < l_chipletList.size(); i++) + { + fapi::Target l_chiplet(i_chipletType, + reinterpret_cast<void *>(l_chipletList[i])); + o_chiplets.push_back(l_chiplet); + } + } + + FAPI_INF(EXIT_MRK "fapiGetChildChiplets. %d results", o_chiplets.size()); + return l_rc; } //****************************************************************************** -// GetFunctionalDimms function +// fapiGetAssociatedDimms function //****************************************************************************** -fapi::ReturnCode GetFunctionalDimms(const fapi::Target& i_target, - std::vector<fapi::Target> & o_dimms) +fapi::ReturnCode fapiGetAssociatedDimms( + const fapi::Target& i_target, + std::vector<fapi::Target> & o_dimms, + const fapi::TargetState i_state) { - FAPI_DBG(ENTER_MRK "GetFunctionalDimms"); + // TODO. Need to support i_state + + FAPI_INF(ENTER_MRK "fapiGetAssociatedDimms. State: 0x%x", i_state); - FAPI_DBG(EXIT_MRK "GetFunctionalDimms"); + fapi::ReturnCode l_rc; + o_dimms.clear(); - return fapi::FAPI_RC_PLAT_NOT_IMPLEMENTED; + // Create a Class/Type/Model predicate to look for dimm cards + TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_CARD, + TARGETING::TYPE_DIMM); + // Extract the HostBoot Target pointer for the input target + TARGETING::Target * l_pTarget = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + // Create a vector of TARGETING::Target pointers + TARGETING::TargetHandleList l_dimmList; + + // Get associated dimms + TARGETING::targetService(). + getAssociated(l_dimmList, l_pTarget, + TARGETING::TargetService::CHILD_BY_AFFINITY, + TARGETING::TargetService::ALL, &l_predicate); + + // Return fapi::Targets to the caller + for (uint32_t i = 0; i < l_dimmList.size(); i++) + { + fapi::Target l_dimm(fapi::TARGET_TYPE_DIMM, + reinterpret_cast<void *>(l_dimmList[i])); + o_dimms.push_back(l_dimm); + } + + FAPI_INF(EXIT_MRK "fapiGetAssociatedDimms. %d results", o_dimms.size()); + return l_rc; } //****************************************************************************** -// GetExistingDimms function +// fapiGetParentChip function //****************************************************************************** -fapi::ReturnCode GetExistingDimms(const fapi::Target& i_target, - std::vector<fapi::Target> & o_dimms) +fapi::ReturnCode fapiGetParentChip( + const fapi::Target& i_chiplet, + fapi::Target & o_chip) { - FAPI_DBG(ENTER_MRK "GetExistingDimms"); + FAPI_INF(ENTER_MRK "fapiGetParentChip"); + + fapi::ReturnCode l_rc; + + // Check that the input target is a chiplet + if (!i_chiplet.isChiplet()) + { + FAPI_ERR("fapiGetParentChip. Input target type 0x%x is not a chiplet", + i_chiplet.getType()); + + /*@ + * @errortype + * @moduleid MOD_FAPI_GET_PARENT_CHIP + * @reasoncode RC_INVALID_REQUEST + * @userdata1 Type of input target + * @devdesc fapiGetParentChip request for non-chiplet + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi::MOD_FAPI_GET_PARENT_CHIP, + fapi::RC_INVALID_REQUEST, + i_chiplet.getType()); - FAPI_DBG(EXIT_MRK "GetExistingDimms"); + // Attach the error log to the fapi::ReturnCode + l_rc = fapi::FAPI_RC_PLAT_ERR_SEE_DATA; + l_rc.setPlatData(reinterpret_cast<void *> (l_pError)); + } + else + { + // Create a Class/Type/Model predicate to look for chips + TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_CHIP); - return fapi::FAPI_RC_PLAT_NOT_IMPLEMENTED; + // Extract the HostBoot Target pointer for the input chiplet + TARGETING::Target * l_pChiplet = + reinterpret_cast<TARGETING::Target*>(i_chiplet.get()); + // Create a vector of TARGETING::Target pointers + TARGETING::TargetHandleList l_chipList; + + // Get parent + TARGETING::targetService(). + getAssociated(l_chipList, l_pChiplet, + TARGETING::TargetService::PARENT, + TARGETING::TargetService::IMMEDIATE, &l_predicate); + + if (l_chipList.size() != 1) + { + // One parent chip was not found + FAPI_ERR("fapiGetParentChip. Number of parents found is %d", + l_chipList.size()); + + /*@ + * @errortype + * @moduleid MOD_FAPI_GET_PARENT_CHIP + * @reasoncode RC_NO_SINGLE_PARENT + * @userdata1 Number of parents found + * @devdesc fapiGetParentChip request did not find one parent + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi::MOD_FAPI_GET_PARENT_CHIP, + fapi::RC_NO_SINGLE_PARENT, + l_chipList.size()); + + // Attach the error log to the fapi::ReturnCode + l_rc = fapi::FAPI_RC_PLAT_ERR_SEE_DATA; + l_rc.setPlatData(reinterpret_cast<void *> (l_pError)); + } + else + { + // Set the output chip type + if (l_chipList[0]->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 *>(l_chipList[0])); + } + } + + FAPI_INF(EXIT_MRK "fapiGetParentChip"); + return l_rc; } + } // extern "C" diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H index 3cf7095e4..eaf2fbc36 100644 --- a/src/usr/hwpf/test/hwpftest.H +++ b/src/usr/hwpf/test/hwpftest.H @@ -76,8 +76,8 @@ public: } /** - * @brief Test HWPF: call a test procedure that generates an error - */ + * @brief Test HWPF: call a test procedure that generates an error + */ void testHwpf2() { // Call a test hardware procedure @@ -103,6 +103,37 @@ public: TS_FAIL("testHwpf2: Unit Test failed. hwpTestError passed. Error logged"); } } + + /** + * @brief Test HWPF Config: call a test procedure that exercises the FAPI + * config query functions + */ + void testHwpf3() + { + errlHndl_t l_err = NULL; + + // Get the master processor chip + TARGETING::Target* l_pTarget = NULL; + TARGETING::targetService().masterProcChipTargetHandle(l_pTarget); + + // Create a FAPI Target and invoke the hwpTestConfig HWP. The HWP + // exercises the FAPI config query functions + fapi::Target l_fapiTarget(TARGET_TYPE_PROC_CHIP, + reinterpret_cast<void *> (l_pTarget)); + + FAPI_INVOKE_HWP(l_err, hwpTestConfig, l_fapiTarget); + + if (l_err) + { + TS_FAIL("testHwpf3: Unit Test failed. hwpTestConfig failed. Error logged"); + errlCommit(l_err); + } + else + { + TS_TRACE("testHwpf3: Unit Test failed. hwpTestConfig passed. Error logged"); + } + } + }; #endif |