summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2
diff options
context:
space:
mode:
authorcrgeddes <crgeddes@us.ibm.com>2015-12-10 15:55:51 -0600
committerWILLIAM G. HOFFA <wghoffa@us.ibm.com>2016-02-26 08:49:33 -0600
commit581462957e6df9ea663914fabf65f9f77b4e4bfa (patch)
tree26602a2bccd1a3bfdc95d8c935ae74cecd155aed /src/usr/fapi2
parenta9e3b39d8520ff5c0356e85d4ce27ebf8f9a5fef (diff)
downloadtalos-hostboot-581462957e6df9ea663914fabf65f9f77b4e4bfa.tar.gz
talos-hostboot-581462957e6df9ea663914fabf65f9f77b4e4bfa.zip
Basic Hostboot platform support for FAPI2
Allows clean compile and link of FAPI2 procedures and a subset of the platform functional support RTC:123290 Change-Id: I9faa3bea86d1b43bca0a7eaca3869b45cc0b0d54 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/23046 Tested-by: Jenkins Server Reviewed-by: Martin Gloff <mgloff@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: Richard J. Knight <rjknight@us.ibm.com> Reviewed-by: WILLIAM G. HOFFA <wghoffa@us.ibm.com>
Diffstat (limited to 'src/usr/fapi2')
-rw-r--r--src/usr/fapi2/attribute_service.C386
-rwxr-xr-xsrc/usr/fapi2/fapi2.mk89
-rwxr-xr-xsrc/usr/fapi2/makefile51
-rwxr-xr-xsrc/usr/fapi2/platCreateHwpErrParser.pl272
-rw-r--r--src/usr/fapi2/plat_attr_override_sync.C610
-rw-r--r--src/usr/fapi2/plat_attribute_service.C40
-rw-r--r--src/usr/fapi2/plat_hwp_invoker.C53
-rw-r--r--src/usr/fapi2/plat_utils.C978
-rw-r--r--src/usr/fapi2/test/fapi2HwpTest.C277
-rw-r--r--src/usr/fapi2/test/fapi2Test.H68
-rw-r--r--src/usr/fapi2/test/fapi2TestUtils.C314
-rw-r--r--src/usr/fapi2/test/fapi2TestUtils.H66
-rw-r--r--src/usr/fapi2/test/makefile47
-rw-r--r--src/usr/fapi2/test/p9_sample_procedure.C386
-rw-r--r--src/usr/fapi2/test/p9_sample_procedure.H117
15 files changed, 3754 insertions, 0 deletions
diff --git a/src/usr/fapi2/attribute_service.C b/src/usr/fapi2/attribute_service.C
new file mode 100644
index 000000000..be9bee453
--- /dev/null
+++ b/src/usr/fapi2/attribute_service.C
@@ -0,0 +1,386 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/attribute_service.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file attribute_service.C
+///
+/// @brief Implements the platform functions that access attributes for FAPI2
+///
+
+//******************************************************************************
+// Includes
+//******************************************************************************
+
+// 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 <stdint.h>
+#include <return_code.H>
+#include <fapi2platattrmacros.H>
+#include <fapi2_attribute_service.H>
+#include <attribute_service.H>
+#include <attribute_plat_check.H>
+#include <attribute_ids.H>
+#include <targeting/common/attributes.H>
+#include <attributeenums.H>
+#include <target.H>
+#include <target_types.H>
+#include <hwpf_fapi2_reasoncodes.H>
+
+#include <devicefw/driverif.H>
+#include <plat_attr_override_sync.H>
+#include <vpd/spdenums.H>
+
+#include <errl/errlmanager.H>
+
+#include <targeting/common/targetservice.H>
+#include <targeting/common/predicates/predicatectm.H>
+#include <targeting/common/utilFilter.H>
+
+//******************************************************************************
+// Implementation
+//******************************************************************************
+
+namespace fapi2
+{
+namespace platAttrSvc
+{
+
+///
+/// @brief Gets the TARGETING object for the input FAPI target
+/// See doxygen in attribute_service.H
+///
+errlHndl_t getTargetingTarget(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
+ TARGETING::Target* & o_pTarget,
+ const TARGETING::TYPE i_expectedType)
+{
+ errlHndl_t l_errl = NULL;
+ do
+ {
+ if (i_pFapiTarget.get() == NULL)
+ {
+ // Fapi Target object isnt point to a real target
+ FAPI_ERR("getTargetingTarget. NULL Fapi Target");
+
+ /*@
+ * @errortype
+ * @moduleid fapi2::MOD_FAPI2_GET_TARGETING_TARGET
+ * @reasoncode RC_NULL_FAPI_TARGET
+ * @userdata1[0:31] Fapi2 Expected Type
+ * @userdata1[32:63] <unused>
+ * @userdata2[0:7] Is Chip
+ * @userdata2[8:15] Is Chiplet
+ * @userdata2[16:63] <unused>
+ * @devdesc Unable to resolve FapiTarget from input
+ * @custdesc Firmware Error
+ */
+ l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ MOD_FAPI2_GET_TARGETING_TARGET,
+ RC_NULL_FAPI_TARGET,
+ i_expectedType,
+ TWO_UINT8_TO_UINT16(
+ i_pFapiTarget.isChip(),
+ i_pFapiTarget.isChiplet()));
+
+ l_errl->collectTrace(FAPI_TRACE_NAME);
+ l_errl->collectTrace(FAPI_IMP_TRACE_NAME);
+
+ break;
+ }
+
+ o_pTarget = reinterpret_cast<TARGETING::Target*>(i_pFapiTarget.get());
+ 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 fapi2::MOD_FAPI2_GET_TARGETING_TARGET
+ * @reasoncode RC_MISMATCHED_FAPI_TARG_TARGET
+ * @userdata1[0:31] Actual Type
+ * @userdata1[32:63] Expected Type
+ * @userdata2[0:31] Initial FAPI2 Type
+ * @userdata2[32:47] Is Chip
+ * @userdata2[48:63] Is Chiplet
+ * @devdesc When coverting from FAPI2::target to
+ * Targeting::target the resulting
+ Targeting::target's was incorrect
+ * @custdesc Firmware Error
+ */
+ l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ MOD_FAPI2_GET_TARGETING_TARGET,
+ RC_MISMATCHED_FAPI_TARG_TARGET,
+ TWO_UINT32_TO_UINT64(l_type,
+ i_expectedType),
+ TWO_UINT32_TO_UINT64(
+ i_pFapiTarget.getType(),
+ TWO_UINT16_TO_UINT32(
+ i_pFapiTarget.isChip(),
+ i_pFapiTarget.isChiplet())));
+
+ l_errl->collectTrace(FAPI_TRACE_NAME);
+ l_errl->collectTrace(FAPI_IMP_TRACE_NAME);
+ break;
+ }
+ }
+ } while(0);
+
+ return l_errl;
+}
+
+bool getTargetingAttrHelper(TARGETING::Target * l_pTargTarget,
+ const TARGETING::ATTRIBUTE_ID i_targAttrId,
+ const uint32_t i_attrSize, void * o_pAttr)
+{
+ return l_pTargTarget->_tryGetAttr(i_targAttrId, i_attrSize, o_pAttr);
+}
+
+///
+/// @brief Gets a Targeting attribute, this is called by the macro that maps a
+/// FAPI Attribute get to a TARGETING attribute and should not be called
+/// directly.
+/// See doxygen in H file.
+///
+ReturnCode getTargetingAttr(
+ const Target< TARGET_TYPE_ALL, plat_target_handle_t >& i_pFapiTarget,
+ const TARGETING::ATTRIBUTE_ID i_targAttrId,
+ const uint32_t i_attrSize,
+ void * o_pAttr)
+{
+ errlHndl_t l_errl = NULL;
+ ReturnCode l_rc;
+ TARGETING::Target * l_pTargTarget = NULL;
+ l_errl = getTargetingTarget(i_pFapiTarget, l_pTargTarget);
+
+ if (l_errl)
+ {
+ FAPI_ERR("getTargetingAttr: Error from getTargetingTarget");
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ }
+ 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 = getTargetingAttrHelper(l_pTargTarget,
+ i_targAttrId,
+ i_attrSize, o_pAttr);
+
+ if (!l_success)
+ {
+ FAPI_ERR("getTargetingAttr: Error from _tryGetAttr");
+ }
+ }
+ return l_rc;
+}
+
+bool setTargetingAttrHelper(TARGETING::Target * l_pTargTarget,
+ const TARGETING::ATTRIBUTE_ID i_targAttrId,
+ const uint32_t i_attrSize,
+ void * o_pAttr)
+{
+ return l_pTargTarget->_trySetAttr(i_targAttrId, i_attrSize, o_pAttr);
+}
+
+///
+/// @brief Sets a Targeting attribute, this is called by the macro that maps a
+/// FAPI Attribute set to a FAPI2 TARGETING attribute and should not be
+/// called directly
+/// See doxygen in H file
+///
+ReturnCode setTargetingAttr(
+ const Target<TARGET_TYPE_ALL, plat_target_handle_t >& i_pFapiTarget,
+ const TARGETING::ATTRIBUTE_ID i_targAttrId,
+ const uint32_t i_attrSize,
+ void * i_pAttr)
+{
+ ReturnCode l_rc;
+ errlHndl_t l_errl = NULL;
+ TARGETING::Target * l_pTargTarget = NULL;
+ l_errl = getTargetingTarget(i_pFapiTarget, l_pTargTarget);
+
+ if (l_errl)
+ {
+ FAPI_ERR("setTargetingAttr: Error from getTargetingTarget");
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ }
+ 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 readable, but
+ // that is already checked by the Targeting compiler
+ bool l_success = setTargetingAttrHelper(l_pTargTarget,
+ i_targAttrId,
+ i_attrSize,
+ i_pAttr);
+
+ if (!l_success)
+ {
+ FAPI_ERR("setTargetingAttr: Error from _trySetAttr");
+ }
+ }
+ return l_rc;
+}
+
+//******************************************************************************
+// platGetTargetName function
+//******************************************************************************
+ReturnCode platGetTargetName(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
+ uint8_t & o_name)
+{
+ ReturnCode l_rc;
+ errlHndl_t l_errl = NULL;
+ TARGETING::Target * l_pHbTarget = NULL;
+ o_name = ENUM_ATTR_NAME_NONE;
+
+ do
+ {
+ l_errl = getTargetingTarget(i_pFapiTarget, l_pHbTarget);
+
+ if (l_errl)
+ {
+ FAPI_ERR("platGetTargetName: Error from getTargetingTarget");
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ break;
+ }
+
+ TARGETING::MODEL l_model =
+ l_pHbTarget->getAttr<TARGETING::ATTR_MODEL>();
+
+ if (l_model == TARGETING::MODEL_NIMBUS)
+ {
+ o_name = ENUM_ATTR_NAME_NIMBUS;
+ }
+ else if (l_model == TARGETING::MODEL_CUMULUS)
+ {
+ o_name = ENUM_ATTR_NAME_CUMULUS;
+ }
+ else if (l_model == TARGETING::MODEL_CENTAUR)
+ {
+ o_name = ENUM_ATTR_NAME_CENTAUR;
+ }
+ else
+ {
+ FAPI_ERR("platGetTargetName. Unknown name 0x%x", l_model);
+
+ /*@
+ * @errortype
+ * @moduleid fapi2::MOD_FAPI2_GET_TARGETING_TARGET
+ * @reasoncode RC_UNKNOWN_MODEL
+ * @userdata1[0:31] FAPI2 Type
+ * @userdata1[32:63] HB Target HUID
+ * @userdata2[0:31] HB Type
+ * @userdata2[32:63] HB Model
+ * @devdesc HB target found with unknown model attribute
+ * @custdesc Firmware Error
+ */
+ l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ MOD_FAPI2_GET_TARGETING_TARGET,
+ RC_UNKNOWN_MODEL,
+ TWO_UINT32_TO_UINT64(
+ i_pFapiTarget.getType(),
+ TARGETING::get_huid(l_pHbTarget)
+ ),
+ TWO_UINT32_TO_UINT64(
+ l_pHbTarget->
+ getAttr<TARGETING::ATTR_TYPE>(),
+ l_model));
+
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ break;
+ }
+ } while (0);
+
+ return l_rc;
+}
+
+//******************************************************************************
+// platGetFunctional function
+//******************************************************************************
+ReturnCode platGetFunctional(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
+ uint8_t & o_functional)
+{
+ errlHndl_t l_errl = NULL;
+ ReturnCode l_rc;
+ TARGETING::Target * l_pHbTarget = NULL;
+ o_functional = 0;
+
+ l_errl = getTargetingTarget(i_pFapiTarget, l_pHbTarget);
+
+ if (l_errl)
+ {
+ FAPI_ERR("platGetFunctional: Error from getTargetingTarget");
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ }
+ else
+ {
+ TARGETING::PredicateIsFunctional l_functional;
+ if (l_functional(l_pHbTarget))
+ {
+ o_functional = 1;
+ }
+ }
+
+ return l_rc;
+}
+
+//******************************************************************************
+// fapi::platAttrSvc::platGetTargetPos function
+//******************************************************************************
+ReturnCode platGetTargetPos(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
+ uint32_t & o_pos)
+{
+ errlHndl_t l_errl = NULL;
+ ReturnCode l_rc;
+ TARGETING::Target * l_pTarget = NULL;
+
+ // Get the Targeting Target
+ l_errl = getTargetingTarget(i_pFapiTarget, l_pTarget);
+
+ if (l_errl)
+ {
+ FAPI_ERR("getTargetName: Error from getTargetingTarget");
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ }
+ else
+ {
+ uint16_t l_pos = l_pTarget->getAttr<TARGETING::ATTR_POSITION>();
+ o_pos = l_pos;
+ }
+
+ return l_rc;
+}
+
+} // End platAttrSvc namespace
+
+} // End fapi2 namespace
diff --git a/src/usr/fapi2/fapi2.mk b/src/usr/fapi2/fapi2.mk
new file mode 100755
index 000000000..4fe67e6b0
--- /dev/null
+++ b/src/usr/fapi2/fapi2.mk
@@ -0,0 +1,89 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/fapi2/fapi2.mk $
+#
+# OpenPOWER HostBoot Project
+#
+# Contributors Listed Below - COPYRIGHT 2015,2016
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+#
+# @file src/usr/fapi2/fapi2.mk
+#
+# @brief Makefile for fapi2 module
+#
+
+EXTRAINCDIR += ${ROOTPATH}/src/import/hwpf/fapi2/include/
+EXTRAINCDIR += ${ROOTPATH}/src/include/usr/fapi2/
+
+#Hostboot objects
+OBJS += plat_utils.o
+OBJS += attribute_service.o
+OBJS += plat_attribute_service.o
+OBJS += plat_attr_override_sync.o
+OBJS += plat_hwp_invoker.o
+
+
+#EKB Objects (mirrored in src/import)
+OBJS += error_info.o
+OBJS += ffdc.o
+
+#Generated Objects
+OBJS += fapi2_attribute_service.o
+OBJS += fapi2_chip_ec_feature.o
+
+#------------------------------------------------------------------------------
+# Set fapi2 build environment
+#------------------------------------------------------------------------------
+
+# Chip directory
+CHIPS += p9
+
+FAPI2_ERROR_XML += $(wildcard \
+ $(ROOTPATH)/src/import/chips/p9/procedures/xml/error_info/*.xml)
+FAPI2_ERROR_XML += $(wildcard \
+ $(ROOTPATH)/src/import/hwpf/fapi2/xml/error_info/*.xml)
+
+# Attribute XML files.
+FAPI2_ATTR_XML += $(wildcard \
+ $(ROOTPATH)/src/import/hwpf/fapi2/xml/attribute_info/*.xml)
+FAPI2_ATTR_XML += $(wildcard \
+ $(ROOTPATH)/src/import/chips/p9/procedures/xml/attribute_info/*.xml)
+
+# Chip SCOM address header files.
+FAPI2_PLAT_INCLUDE += $(addsuffix /common/include, \
+ $(addprefix $(ROOTPATH)/src/import/chips/$CHIPS))
+
+#------------------------------------------------------------------------------
+# The PLAT HWP RC and FFDC parser file generated from Error XML files
+#------------------------------------------------------------------------------
+PLAT_HWP_ERR_PARSER = platHwpErrParser.H
+GENDIR_PLUGINS = $(ROOTPATH)/obj/genfiles/plugins
+GENPLUGINTARGET = $(addprefix $(GENDIR_PLUGINS)/, $(1))
+GENFILES_PLUGINS = ${PLAT_HWP_ERR_PARSER}
+$(call GENPLUGINTARGET, ${PLAT_HWP_ERR_PARSER}) : \
+ $(ROOTPATH)/src/usr/fapi2/platCreateHwpErrParser.pl ${FAPI2_ERROR_XML}
+ $< $(dir $@) ${FAPI2_ERROR_XML}
+
+
+# Add targets from 'BUILD_GENERATED' into the Hostboot 'GEN_PASS'.
+GEN_PASS_BODY += $(GEN_TARGETS)
+CLEAN_TARGETS += $(GEN_TARGETS)
+
+VPATH += ${ROOTPATH}/src/import/hwpf/fapi2/src/
+VPATH += ${GENPATH}
diff --git a/src/usr/fapi2/makefile b/src/usr/fapi2/makefile
new file mode 100755
index 000000000..26dcfca2b
--- /dev/null
+++ b/src/usr/fapi2/makefile
@@ -0,0 +1,51 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/fapi2/makefile $
+#
+# OpenPOWER HostBoot Project
+#
+# Contributors Listed Below - COPYRIGHT 2015,2016
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+#
+# @file src/usr/fapi2/makefile
+#
+# @brief Makefile rule for fapi2 module
+#
+
+ROOTPATH = ../../..
+GENPATH?=$(ROOTPATH)/obj/genfiles
+
+MODULE = fapi2
+SUBDIRS += test.d
+
+include ${ROOTPATH}/src/build/mkrules/verbose.rules.mk
+define __CLEAN_TARGET
+CLEAN_TARGETS += $(1)
+endef
+
+include fapi2.mk
+
+include ${ROOTPATH}/src/import/tools/build/common.dir/script.rules.mk
+include ${ROOTPATH}/src/import/hwpf/fapi2/tools/parseErrorInfo.mk
+include ${ROOTPATH}/src/import/hwpf/fapi2/tools/parseAttributeInfo.mk
+include ${ROOTPATH}/src/import/hwpf/fapi2/tools/createIfAttrService.mk
+
+include ${ROOTPATH}/config.mk
+
+vpath %.C ${GENDIR} \ No newline at end of file
diff --git a/src/usr/fapi2/platCreateHwpErrParser.pl b/src/usr/fapi2/platCreateHwpErrParser.pl
new file mode 100755
index 000000000..4c2fc8ec8
--- /dev/null
+++ b/src/usr/fapi2/platCreateHwpErrParser.pl
@@ -0,0 +1,272 @@
+#!/usr/bin/perl
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/fapi2/platCreateHwpErrParser.pl $
+#
+# OpenPOWER HostBoot Project
+#
+# Contributors Listed Below - COPYRIGHT 2015,2016
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+#
+# 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: Thi Tran
+#
+
+use strict;
+
+#------------------------------------------------------------------------------
+# Print Command Line Help
+#------------------------------------------------------------------------------
+my $numArgs = $#ARGV + 1;
+if ($numArgs < 2)
+{
+ print ("Usage: platCreateHwpErrParser.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 .= "platHwpErrParser.H";
+open(TGFILE, ">", $rcFile);
+
+#------------------------------------------------------------------------------
+# Print start of file information
+#------------------------------------------------------------------------------
+print TGFILE "// platHwpErrParser.H\n";
+print TGFILE "// This file is generated by perl script platCreateHwpErrParser.pl\n\n";
+print TGFILE "#ifndef PLATHWPERRPARSER_H_\n";
+print TGFILE "#define PLATHWPERRPARSER_H_\n\n";
+print TGFILE "#ifdef PARSER\n\n";
+print TGFILE "namespace fapi2\n";
+print TGFILE "{\n\n";
+print TGFILE "void parseHwpRc(ErrlUsrParser & i_parser,\n";
+print TGFILE " void * i_pBuffer,\n";
+print TGFILE " const uint32_t i_buflen)\n";
+print TGFILE "{\n";
+print TGFILE " uint64_t l_rc_64 = ntohll(*(static_cast<uint64_t *>(i_pBuffer)));\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 parseHwpFfdc(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 parseHwpFfdc 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/fapi2/plat_attr_override_sync.C b/src/usr/fapi2/plat_attr_override_sync.C
new file mode 100644
index 000000000..315fd7ca4
--- /dev/null
+++ b/src/usr/fapi2/plat_attr_override_sync.C
@@ -0,0 +1,610 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/plat_attr_override_sync.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+/**
+ * @file 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 <plat_attr_override_sync.H>
+#include <fapiPlatTrace.H>
+#include <hwpf_fapi2_reasoncodes.H>
+#include <targeting/common/utilFilter.H>
+#include <targeting/common/attributeTank.H>
+
+namespace fapi2
+{
+
+//******************************************************************************
+// 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 fapi2::TARGET_TYPE_DIMM:
+ l_targetType = TARGETING::TYPE_DIMM;
+ break;
+ case fapi2::TARGET_TYPE_PROC_CHIP:
+ l_targetType = TARGETING::TYPE_PROC;
+ break;
+ case fapi2::TARGET_TYPE_MEMBUF_CHIP:
+ l_targetType = TARGETING::TYPE_MEMBUF;
+ break;
+ case fapi2::TARGET_TYPE_EX_CHIPLET:
+ l_targetType = TARGETING::TYPE_EX;
+ break;
+ case fapi2::TARGET_TYPE_MBA_CHIPLET:
+ l_targetType = TARGETING::TYPE_MBA;
+ break;
+ case fapi2::TARGET_TYPE_MCS_CHIPLET:
+ l_targetType = TARGETING::TYPE_MCS;
+ break;
+ case fapi2::TARGET_TYPE_XBUS_ENDPOINT:
+ l_targetType = TARGETING::TYPE_XBUS;
+ break;
+ case fapi2::TARGET_TYPE_ABUS_ENDPOINT:
+ l_targetType = TARGETING::TYPE_ABUS;
+ break;
+ case fapi2::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);
+ }
+ 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 AttributeId i_attrId,
+ const Target<TARGET_TYPE_ALL>* 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 AttributeId i_attrId,
+ const Target<TARGET_TYPE_ALL>& i_pTarget,
+ void * o_pVal)
+{
+
+ return Singleton<AttrOverrideSync>::instance().getAttrOverride(i_attrId,
+ &i_pTarget, o_pVal);
+}
+
+//******************************************************************************
+void AttrOverrideSync::setAttrActions(const AttributeId i_attrId,
+ const Target<TARGET_TYPE_ALL>* 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 AttributeId i_attrId,
+ const Target<TARGET_TYPE_ALL>& 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 Target<TARGET_TYPE_ALL>* i_pTarget)
+{
+ uint32_t l_targetType = fapi2::TARGET_TYPE_SYSTEM;
+
+ if (i_pTarget != NULL)
+ {
+ l_targetType = i_pTarget->getType();
+ }
+
+ return l_targetType;
+}
+
+} // End fapi namespace
diff --git a/src/usr/fapi2/plat_attribute_service.C b/src/usr/fapi2/plat_attribute_service.C
new file mode 100644
index 000000000..9e3c0d823
--- /dev/null
+++ b/src/usr/fapi2/plat_attribute_service.C
@@ -0,0 +1,40 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/plat_attribute_service.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file plat_attribute_service.C
+///
+/// @brief Implements the specialized platform functions that access
+/// attributes for FAPI2
+///
+
+namespace fapi2
+{
+
+namespace platAttrSvc
+{
+
+} // End platAttrSvc namespace
+
+} // End fapi2 namespace
diff --git a/src/usr/fapi2/plat_hwp_invoker.C b/src/usr/fapi2/plat_hwp_invoker.C
new file mode 100644
index 000000000..3d4fa89cb
--- /dev/null
+++ b/src/usr/fapi2/plat_hwp_invoker.C
@@ -0,0 +1,53 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/plat_hwp_invoker.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file plat_hwp_invoker.C
+///
+/// @brief Implements the platform functions that access attributes for FAPI2
+///
+
+
+#include <plat_hwp_invoker.H>
+#include <return_code.H>
+
+//******************************************************************************
+// Implementation
+//******************************************************************************
+
+namespace fapi2
+{
+
+ //@todo RTC:124673
+ /**
+ * @brief Converts a fapi::ReturnCode to a HostBoot PLAT error log
+ */
+ errlHndl_t fapiRcToErrl(ReturnCode & io_rc,
+ ERRORLOG::errlSeverity_t i_sev)
+ {
+ errlHndl_t errl = NULL;
+ return errl;
+ }
+}
+//end fapi2 \ No newline at end of file
diff --git a/src/usr/fapi2/plat_utils.C b/src/usr/fapi2/plat_utils.C
new file mode 100644
index 000000000..aa146e45b
--- /dev/null
+++ b/src/usr/fapi2/plat_utils.C
@@ -0,0 +1,978 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/plat_utils.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file plat_utils.C
+///
+/// @brief Implements the plat_utils.H utility functions.
+///
+/// Note that platform code must provide the implementation.
+///
+
+#include <sys/time.h>
+#include <utils.H>
+#include <plat_trace.H>
+#include <return_code.H>
+#include <error_info.H>
+#include <assert.h>
+#include <plat_utils.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <hwpf_fapi2_reasoncodes.H>
+
+//******************************************************************************
+// 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);
+namespace fapi2
+{
+
+// Define global current_err
+//thread_local ReturnCode current_err;
+ReturnCode current_err;
+///
+/// @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 fapi2::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("fapi2::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 fapi2::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 fapi2::HwCallouts::HwCallout i_fapiPart)
+{
+ // Use the HwCallout enum value as an index
+ HWAS::partTypeEnum l_part = HWAS::NO_PART_TYPE;
+
+ // 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;
+ case HwCallouts::TOD_CLOCK:
+ l_part = HWAS::TOD_CLOCK;
+ break;
+ case HwCallouts::MEM_REF_CLOCK:
+ l_part = HWAS::MEM_REF_CLOCK;
+ break;
+ case HwCallouts::PROC_REF_CLOCK:
+ l_part = HWAS::PROC_REF_CLOCK;
+ break;
+ case HwCallouts::PCI_REF_CLOCK:
+ l_part = HWAS::PCI_REF_CLOCK;
+ break;
+
+ }
+
+ 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 fapi2::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;
+
+ //@TODO RTC:124673 - need to verify the order still matches
+ 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("fapi2::xlateProcedureCallout: Unknown proc 0x%x, assuming CODE",
+ i_fapiProc);
+ }
+
+ return l_proc;
+}
+
+///
+/// * @brief Translates a FAPI2 target type to a Targeting target type
+///
+/// * @param[i] i_targetType FAPI2 target type
+/// * @param[o] o_class Targeting class
+/// * @param[o] o_type Targeting type
+///
+void xlateTargetType(const fapi2::TargetType i_targetType,
+ TARGETING::CLASS & o_class,
+ TARGETING::TYPE & o_type)
+{
+ switch (i_targetType)
+ {
+ case fapi2::TARGET_TYPE_SYSTEM:
+ o_class = TARGETING::CLASS_SYS;
+ o_type = TARGETING::TYPE_SYS;
+ break;
+ case fapi2::TARGET_TYPE_DIMM:
+ o_class = TARGETING::CLASS_LOGICAL_CARD;
+ o_type = TARGETING::TYPE_DIMM;
+ break;
+ case fapi2::TARGET_TYPE_PROC_CHIP:
+ o_class = TARGETING::CLASS_CHIP;
+ o_type = TARGETING::TYPE_PROC;
+ break;
+ case fapi2::TARGET_TYPE_MEMBUF_CHIP:
+ o_class = TARGETING::CLASS_CHIP;
+ o_type = TARGETING::TYPE_MEMBUF;
+ break;
+ case fapi2::TARGET_TYPE_EX:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_EX;
+ break;
+ case fapi2::TARGET_TYPE_MBA:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_MBA;
+ break;
+ case fapi2::TARGET_TYPE_MCS:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_MCS;
+ break;
+ case fapi2::TARGET_TYPE_XBUS:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_XBUS;
+ break;
+ case fapi2::TARGET_TYPE_L4:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_L4;
+ break;
+ case fapi2::TARGET_TYPE_CORE:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_CORE;
+ break;
+ case fapi2::TARGET_TYPE_EQ:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_EQ;
+ break;
+ case fapi2::TARGET_TYPE_MCA:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_MCA;
+ break;
+ case fapi2::TARGET_TYPE_MCBIST:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_MCBIST;
+ break;
+ case fapi2::TARGET_TYPE_MI:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_MI;
+ break;
+ case fapi2::TARGET_TYPE_CAPP:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_CAPP;
+ break;
+ case fapi2::TARGET_TYPE_DMI:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_DMI;
+ break;
+ case fapi2::TARGET_TYPE_OBUS:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_OBUS;
+ break;
+ case fapi2::TARGET_TYPE_NV:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_NVBUS;
+ break;
+ case fapi2::TARGET_TYPE_SBE:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_SBE;
+ break;
+ case fapi2::TARGET_TYPE_PPE:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_PPE;
+ break;
+ case fapi2::TARGET_TYPE_PERV:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_PERV;
+ break;
+ case fapi2::TARGET_TYPE_PEC:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_PEC;
+ break;
+ case fapi2::TARGET_TYPE_PHB:
+ o_class = TARGETING::CLASS_UNIT;
+ o_type = TARGETING::TYPE_PHB;
+ break;
+ default:
+ o_class = TARGETING::CLASS_NA;
+ o_type = TARGETING::TYPE_NA;
+ }
+}
+
+///
+/// @brief Is this target type pair a physical parent <-> child?
+/// @return Return true if the types have physically parent <-> child
+/// relationship; false otherwise.
+///
+bool isPhysParentChild(const TargetType i_parentType,
+ const TargetType i_childType)
+{
+ bool l_result = false;
+ if (i_parentType == TARGET_TYPE_PROC_CHIP)
+ {
+ if ( (i_childType & (TARGET_TYPE_EX |
+ TARGET_TYPE_MCS |
+ TARGET_TYPE_XBUS |
+ TARGET_TYPE_ABUS |
+ TARGET_TYPE_CORE |
+ TARGET_TYPE_EQ |
+ TARGET_TYPE_MCA |
+ TARGET_TYPE_MCBIST |
+ TARGET_TYPE_MI |
+ TARGET_TYPE_CAPP |
+ TARGET_TYPE_DMI |
+ TARGET_TYPE_OBUS |
+ TARGET_TYPE_NV |
+ TARGET_TYPE_SBE |
+ TARGET_TYPE_PPE |
+ TARGET_TYPE_PERV |
+ TARGET_TYPE_PEC)) != 0 )
+ {
+ l_result = true;
+ }
+ }
+ else if (i_parentType == TARGET_TYPE_MEMBUF_CHIP)
+ {
+ if ( (i_childType & (TARGET_TYPE_MBA | TARGET_TYPE_L4)) != 0 )
+ {
+ l_result = true;
+ }
+ }
+ return l_result;
+}
+
+///
+/// @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 (auto itr = i_errInfo.iv_ffdcs.begin();
+ itr != i_errInfo.iv_ffdcs.end(); ++itr)
+ {
+ const void * l_pFfdc = (*itr)->getData(l_size);
+ uint32_t l_ffdcId = (*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_FAPI2_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 (auto itr = i_errInfo.iv_hwCallouts.begin();
+ itr != i_errInfo.iv_hwCallouts.end(); ++itr)
+ {
+ HWAS::callOutPriority l_priority =
+ xlateCalloutPriority((*itr)->iv_calloutPriority);
+
+ HwCallouts::HwCallout l_hw = ((*itr)->iv_hw);
+
+ TARGETING::Target * l_pRefTarget =
+ reinterpret_cast<TARGETING::Target*>((*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((*itr)->iv_hw);
+
+ FAPI_ERR("processEIHwCallouts: Adding clock-callout"
+ " (clock:%d, pri:%d)",
+ l_clock, l_priority);
+
+ // 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((*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 (auto itr = i_errInfo.iv_procedureCallouts.begin();
+ itr != i_errInfo.iv_procedureCallouts.end(); ++itr)
+ {
+ HWAS::epubProcedureID l_procedure =
+ xlateProcedureCallout((*itr)->iv_procedure);
+
+ HWAS::callOutPriority l_priority =
+ xlateCalloutPriority((*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 (auto itr = i_errInfo.iv_busCallouts.begin();
+ itr != i_errInfo.iv_busCallouts.end(); ++itr)
+ {
+ TARGETING::Target * l_pTarget1 =
+ reinterpret_cast<TARGETING::Target*>((*itr)->iv_target1.get());
+
+ TARGETING::Target * l_pTarget2 =
+ reinterpret_cast<TARGETING::Target*>((*itr)->iv_target2.get());
+
+ HWAS::callOutPriority l_priority =
+ xlateCalloutPriority((*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 (auto itr = i_errInfo.iv_CDGs.begin();
+ itr != i_errInfo.iv_CDGs.end(); ++itr)
+ {
+ TARGETING::Target * l_pTarget =
+ reinterpret_cast<TARGETING::Target*>((*itr)->iv_target.get());
+
+ HWAS::callOutPriority l_priority =
+ xlateCalloutPriority((*itr)->iv_calloutPriority);
+
+ HWAS::DeconfigEnum l_deconfig = HWAS::NO_DECONFIG;
+ if ((*itr)->iv_deconfigure)
+ {
+ l_deconfig = HWAS::DELAYED_DECONFIG;
+ }
+
+ HWAS::GARD_ErrorType l_gard = HWAS::GARD_NULL;
+ if ((*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 FAPI2 Parent Target
+/// @param[i] i_childType FAPI2 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 fapi2::Target<fapi2::TARGET_TYPE_ALL>& i_parentTarget,
+ const fapi2::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 == fapi2::TARGET_TYPE_DIMM)
+ {
+ l_childIsDimm = true;
+ }
+ else
+ {
+ l_childIsChip = fapi2::Target<TARGET_TYPE_ALL>::isChip(i_childType);
+ if (!l_childIsChip)
+ {
+ l_childIsChiplet = fapi2::Target<TARGET_TYPE_ALL>::
+ 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 ( 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 (auto itr = i_errInfo.iv_childrenCDGs.begin();
+ itr != i_errInfo.iv_childrenCDGs.end(); ++itr)
+ {
+ HWAS::callOutPriority l_priority =
+ xlateCalloutPriority((*itr)->iv_calloutPriority);
+
+ HWAS::DeconfigEnum l_deconfig = HWAS::NO_DECONFIG;
+ if ((*itr)->iv_deconfigure)
+ {
+ l_deconfig = HWAS::DELAYED_DECONFIG;
+ }
+
+ HWAS::GARD_ErrorType l_gard = HWAS::GARD_NULL;
+ if ((*itr)->iv_gard)
+ {
+ l_gard = HWAS::GARD_Unrecoverable;
+ }
+
+ // Get a list of children to callout
+ TARGETING::TargetHandleList l_children;
+ getChildTargetsForCDG((*itr)->iv_parent,
+ (*itr)->iv_childType,
+ (*itr)->iv_childPort,
+ (*itr)->iv_childNumber,
+ l_children);
+
+ // Callout/Deconfigure/GARD each child as appropriate
+ for (TARGETING::TargetHandleList::const_iterator
+ itr = l_children.begin();
+ itr != l_children.end(); ++itr)
+ {
+ FAPI_DBG("processEIChildrenCDGs: Calling out target"
+ " (huid:%.8x, pri:%d, deconf:%d, gard:%d)",
+ TARGETING::get_huid(*itr), l_priority, l_deconfig,
+ l_gard);
+ io_pError->addHwCallout(*itr, l_priority, l_deconfig, l_gard);
+ }
+ }
+}
+
+///
+/// @brief Converts a fapi2::ReturnCode to a HostBoot PLAT error log
+/// See doxygen in plat_utils.H
+///
+errlHndl_t rcToErrl(ReturnCode & io_rc,
+ ERRORLOG::errlSeverity_t i_sev)
+{
+ errlHndl_t l_pError = NULL;
+
+ FAPI_DBG("Entering rcToErrl");
+
+ if (io_rc)
+ {
+ uint64_t l_rcValue = 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("rcToErrl: PLAT error: 0x%08x", l_rcValue);
+ //@TODO RTC:143127
+ //l_pError = reinterpret_cast<errlHndl_t> (io_rc.releaseData());
+ }
+ else if (l_creator == ReturnCode::CREATOR_HWP)
+ {
+ // HWP Error. Create an error log
+ FAPI_ERR("rcToErrl: HWP error: 0x%08x", l_rcValue);
+
+ /*@
+ * @errortype
+ * @moduleid MOD_FAPI2_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(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ MOD_FAPI2_RC_TO_ERRL,
+ RC_HWP_GENERATED_ERROR,
+ 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_FAPI2_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("rcToErrl: No Error Information");
+ }
+ }
+ else
+ {
+ // FAPI error. Create an error log
+ FAPI_ERR("rcToErrl: FAPI error: 0x%08x", l_rcValue);
+
+ // The errlog reason code is the HWPF compID and the rcValue LSB
+ 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_FAPI2_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);
+ }
+ }
+
+ // 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 );
+ }
+
+ FAPI_DBG("Exiting rcToErrl");
+ return l_pError;
+}
+
+///
+/// @brief Log an error.
+///
+void logError(
+ fapi2::ReturnCode & io_rc,
+ fapi2::errlSeverity_t i_sev,
+ bool i_unitTestError )
+{
+ FAPI_DBG("Entering logError");
+
+ // ENUM CONVERSION FAPI to PLATFORM
+ errlHndl_t l_pError = NULL;
+
+ FAPI_INF("logError");
+
+ // Convert a FAPI severity to a ERRORLOG severity
+ ERRORLOG::errlSeverity_t l_sev = ERRORLOG::ERRL_SEV_UNRECOVERABLE;
+ switch (i_sev)
+ {
+ case fapi2::FAPI2_ERRL_SEV_RECOVERED:
+ l_sev = ERRORLOG::ERRL_SEV_RECOVERED;
+ break;
+ case fapi2::FAPI2_ERRL_SEV_PREDICTIVE:
+ l_sev = ERRORLOG::ERRL_SEV_PREDICTIVE;
+ break;
+ case fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE:
+ // l_sev set above
+ break;
+ default:
+ FAPI_ERR("severity (i_sev) of %d is unknown",i_sev);
+ break;
+ }
+
+ // Convert the return code to an error log.
+ // This will set the return code to FAPI2_RC_SUCCESS and clear any
+ // PLAT Data, HWP FFDC data, and Error Target associated with it.
+ l_pError = rcToErrl(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);
+ }
+
+ return;
+}
+
+ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles)
+{
+ nanosleep( 0, i_nanoSeconds );
+ return FAPI2_RC_SUCCESS;
+}
+
+///
+/// @brief Assert a condition, and halt
+///
+/// @param[in] a boolean representing the assertion
+///
+void Assert(bool i_expression)
+{
+ assert(i_expression);
+}
+
+bool platIsScanTraceEnabled()
+{
+ // SCAN trace can be dynamically turned on/off, always return true here
+ return 1;
+}
+
+} //end namespace
diff --git a/src/usr/fapi2/test/fapi2HwpTest.C b/src/usr/fapi2/test/fapi2HwpTest.C
new file mode 100644
index 000000000..c90431ecb
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2HwpTest.C
@@ -0,0 +1,277 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2HwpTest.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <fapi2.H>
+#include <hwpf_fapi2_reasoncodes.H>
+#include <fapi2TestUtils.H>
+
+namespace fapi2
+{
+
+
+//******************************************************************************
+// fapi2HwpTest
+//******************************************************************************
+errlHndl_t fapi2HwpTest()
+{
+ int numTests = 0;
+ int numFails = 0;
+ errlHndl_t l_errl = NULL;
+
+ do
+ {
+ // Create a vector of TARGETING::Target pointers
+ TARGETING::TargetHandleList l_chipList;
+
+ // Get a list of all of the proc chips
+ TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, false);
+
+ TARGETING::Target * l_nimbusProc = NULL;
+
+ //Take the first NIMBUS proc and use it
+ for(uint32_t i = 0; i < l_chipList.size(); i++)
+ {
+ if(TARGETING::MODEL_NIMBUS ==
+ l_chipList[i]->getAttr<TARGETING::ATTR_MODEL>())
+ {
+ l_nimbusProc = l_chipList[i];
+ break;
+ }
+ }
+ numTests++;
+ if(l_nimbusProc == NULL)
+ {
+ // Send an errorlog because we cannot find any NIMBUS procs.
+ FAPI_ERR("FAPI2_GETPARENT:: could not find Nimbus proc, skipping tests");
+ numFails++;
+ /*@
+ * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid fapi2::MOD_FAPI2_PLAT_HWP_TEST
+ * @reasoncode fapi2::RC_NO_PROCS_FOUND
+ * @userdata1 Model Type we looked for
+ * @userdata2 Unused
+ * @devdesc Could not find NIMBUS procs in system model
+ */
+ l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_PLAT_HWP_TEST,
+ fapi2::RC_NO_PROCS_FOUND,
+ TARGETING::MODEL_NIMBUS,
+ NULL,
+ true/*SW Error*/);
+ errlCommit(l_errl,HWPF_COMP_ID);
+ break;
+ }
+
+ TARGETING::Target* targeting_targets[NUM_TARGETS];
+ generateTargets(l_nimbusProc, targeting_targets);
+
+ for( uint64_t x = 0; x < NUM_TARGETS; x++ )
+ {
+ if(targeting_targets[x] == NULL)
+ {
+ FAPI_ERR("Unable to find target for item %d in targeting_targets", x);
+
+ /*@
+ * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid fapi2::MOD_FAPI2_PLAT_HWP_TEST
+ * @reasoncode fapi2::RC_NO_PATH_TO_TARGET_FOUND
+ * @userdata1 Index of target in array of objects
+ * @userdata2 Unused
+ * @devdesc Could not find a path to the target of that type
+ */
+ l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_PLAT_HWP_TEST,
+ fapi2::RC_NO_PATH_TO_TARGET_FOUND,
+ x,
+ NULL,
+ true/*SW Error*/);
+ errlCommit(l_errl,HWPF_COMP_ID);
+ }
+ }
+
+ fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(l_nimbusProc);
+ fapi2::Target<fapi2::TARGET_TYPE_EQ> fapi2_eqTarget(targeting_targets[MY_EQ]);
+ fapi2::Target<fapi2::TARGET_TYPE_EX> fapi2_exTarget(targeting_targets[MY_EX]);
+ fapi2::Target<fapi2::TARGET_TYPE_CORE> fapi2_coreTarget(
+ targeting_targets[MY_CORE]);
+ fapi2::Target<fapi2::TARGET_TYPE_MCS> fapi2_mcsTarget(targeting_targets[MY_MCS]);
+ fapi2::Target<fapi2::TARGET_TYPE_MCA> fapi2_mcaTarget(targeting_targets[MY_MCA]);
+ fapi2::Target<fapi2::TARGET_TYPE_MCBIST> fapi2_mcbistTarget(
+ targeting_targets[MY_MCBIST]);
+ fapi2::Target<fapi2::TARGET_TYPE_PEC> fapi2_pecTarget(targeting_targets[MY_PEC]);
+ fapi2::Target<fapi2::TARGET_TYPE_PHB> fapi2_phbTarget(targeting_targets[MY_PHB]);
+ fapi2::Target<fapi2::TARGET_TYPE_XBUS> fapi2_xbusTarget(
+ targeting_targets[MY_XBUS]);
+ fapi2::Target<fapi2::TARGET_TYPE_OBUS> fapi2_obusTarget(
+ targeting_targets[MY_OBUS]);
+ fapi2::Target<fapi2::TARGET_TYPE_NV> fapi2_nvbusTarget(
+ targeting_targets[MY_NVBUS]);
+ fapi2::Target<fapi2::TARGET_TYPE_PPE> fapi2_ppeTarget(targeting_targets[MY_PPE]);
+ fapi2::Target<fapi2::TARGET_TYPE_PERV> fapi2_pervTarget(
+ targeting_targets[MY_PERV]);
+ fapi2::Target<fapi2::TARGET_TYPE_SBE> fapi2_sbeTarget(targeting_targets[MY_SBE]);
+ fapi2::Target<fapi2::TARGET_TYPE_CAPP> fapi2_cappTarget(
+ targeting_targets[MY_CAPP]);
+
+
+ int scratchWriteValue = 5;
+
+ //Get/Set Attr for all of the targets
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_proc, fapi2_procTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_proc !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_eq, fapi2_eqTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_eq !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_ex, fapi2_exTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_ex !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_core, fapi2_coreTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_core !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mcs, fapi2_mcsTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_mcs !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mca, fapi2_mcaTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_mca !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mcbist, fapi2_mcbistTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_mcbist !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_pec, fapi2_pecTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_pec !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_phb, fapi2_phbTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_phb !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_xbus, fapi2_xbusTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_xbus !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_obus, fapi2_obusTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_obus !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_nv, fapi2_nvbusTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_nv !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_ppe, fapi2_ppeTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_ppe !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_perv, fapi2_pervTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_perv !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_sbe, fapi2_sbeTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_sbe !!");
+ }
+ numTests++;
+ FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_capp, fapi2_cappTarget, scratchWriteValue);
+ if(l_errl != NULL)
+ {
+ l_errl = NULL;
+ numFails++;
+ TS_FAIL("Error occured in p9_sample_procedure_capp !!");
+ }
+ }while(0);
+ FAPI_INF("test_sampleHWPs:: Test Complete. %d/%d fails", numFails,numTests);
+ return l_errl;
+}
+
+} \ No newline at end of file
diff --git a/src/usr/fapi2/test/fapi2Test.H b/src/usr/fapi2/test/fapi2Test.H
new file mode 100644
index 000000000..76a86a183
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2Test.H
@@ -0,0 +1,68 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2Test.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#ifndef __FAPI2TEST_H__
+#define __FAPI2TEST_H__
+
+/**
+ * @file fapi2Test.H
+ *
+ * @brief Test case for SCOM code
+*/
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <targeting/common/targetservice.H>
+#include <fapi2.H>
+#include <p9_sample_procedure.H>
+#include <hwp_executor.H>
+#include <plat_hwp_invoker.H>
+#include <pnor/pnorif.H>
+#include <targeting/common/utilFilter.H>
+#include <fapi2TestUtils.H>
+#include <hwpf_fapi2_reasoncodes.H>
+
+#include "fapi2HwpTest.C"
+
+using namespace fapi2;
+
+class fapi2Test: public CxxTest::TestSuite
+{
+public:
+
+/**
+* @brief Test some basic HWPs that hit all targets
+* that runs through the FAPI2 macros
+*
+*/
+void test_fapi2HwpTest(void)
+{
+ FAPI_INF(">>test_fapi2HwpTest starting...");
+ fapi2HwpTest();
+ FAPI_INF(">>test_fapi2HwpTest exiting...");
+}
+};
+
+#endif \ No newline at end of file
diff --git a/src/usr/fapi2/test/fapi2TestUtils.C b/src/usr/fapi2/test/fapi2TestUtils.C
new file mode 100644
index 000000000..896a94ba8
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2TestUtils.C
@@ -0,0 +1,314 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2TestUtils.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file fapi2TestUtils.C
+///
+/// @brief FAPI2 utility functions
+///
+/// Note that platform code must provide the implementation.
+///
+
+#include <fapi2.H>
+#include "fapi2TestUtils.H"
+
+
+//This is subject to change, try to keep updated
+#define NUM_EQS 6
+#define NUM_EXS 12
+#define NUM_CORES 24
+#define NUM_L2S 12
+#define NUM_L3S 12
+#define NUM_MCS 4
+#define NUM_MCAS 8
+#define NUM_MCBISTS 2
+#define NUM_PECS 3
+#define NUM_PHBS 6
+#define NUM_XBUS 1
+#define NUM_OBUS 2
+#define NUM_NVBUS 2
+#define NUM_PPES 21
+#define NUM_PERVS 55
+#define NUM_CAPPS 2
+#define NUM_SBES 1
+
+namespace fapi2
+{
+
+void generateTargets(TARGETING::Target* i_pMasterProcChip,
+ TARGETING::Target* o_targetList[])
+{
+ for( uint64_t x = 0; x < NUM_TARGETS; x++ )
+ {
+ o_targetList[x] = NULL;
+ }
+
+ // Set up entity path for NIMBUS proc
+ TARGETING::EntityPath l_epath;
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+
+ //Setup EQs, COREs, and EXs
+ for(int i = 0; i < NUM_EQS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_EQ,i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_EQ] =
+ TARGETING::targetService().toTarget(l_epath);
+ for(int j = 0; j < NUM_EXS; j++)
+ {
+ l_epath.addLast(TARGETING::TYPE_EX,i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_EX] =
+ TARGETING::targetService().toTarget(l_epath);
+ for(int k = 0; k < NUM_CORES; k++)
+ {
+ l_epath.addLast(TARGETING::TYPE_CORE,k);
+ if(TARGETING::targetService().toTarget(l_epath)!=NULL)
+ {
+ o_targetList[MY_CORE] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup MCSs and MCAs
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_MCS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_MCS, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_MCS] =
+ TARGETING::targetService().toTarget(l_epath);
+ for(int j = 0; j < NUM_MCAS; j++)
+ {
+ l_epath.addLast(TARGETING::TYPE_MCA,j);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_MCA] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup MCBISTs
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_MCBISTS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_MCBIST, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_MCBIST] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup PECs and PHBs
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_PECS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_PEC, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_PEC] =
+ TARGETING::targetService().toTarget(l_epath);
+ for(int j = 0; j < NUM_PHBS; j++)
+ {
+ l_epath.addLast(TARGETING::TYPE_PHB,j);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_PHB] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup XBUS
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_XBUS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_XBUS, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_XBUS] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup OBUSs
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_OBUS; i+=3)
+ {
+ l_epath.addLast(TARGETING::TYPE_OBUS, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_OBUS] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup NVBUS
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_NVBUS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_NVBUS, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_NVBUS] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup PPEs
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_PPES; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_PPE, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_PPE] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup CAPPs
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_CAPPS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_CAPP, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_CAPP] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup SBE
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_SBES; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_SBE, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_SBE] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+
+ //Setup PERVs
+ i_pMasterProcChip->tryGetAttr<TARGETING::ATTR_PHYS_PATH>(l_epath);
+ for(int i = 0; i < NUM_PERVS; i++)
+ {
+ l_epath.addLast(TARGETING::TYPE_PERV, i);
+ if(TARGETING::targetService().toTarget(l_epath) != NULL)
+ {
+ o_targetList[MY_PERV] =
+ TARGETING::targetService().toTarget(l_epath);
+ break;
+ }
+ else
+ {
+ l_epath.removeLast();
+ }
+ }
+}
+
+} // End namespace fapi2
diff --git a/src/usr/fapi2/test/fapi2TestUtils.H b/src/usr/fapi2/test/fapi2TestUtils.H
new file mode 100644
index 000000000..15ddb0b6a
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2TestUtils.H
@@ -0,0 +1,66 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2TestUtils.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file fapi2TestUtils.H
+///
+/// @brief FAPI2 utility functions
+///
+/// Note that platform code must provide the implementation.
+///
+
+#ifndef FAPI2TESTUTILS_H_
+#define FAPI2TESTUTILS_H_
+
+#include <fapi2.H>
+
+namespace fapi2
+{
+// Setup some targets to use
+enum{
+ MY_EQ,
+ MY_EX,
+ MY_CORE,
+ MY_MCS,
+ MY_MCA,
+ MY_MCBIST,
+ MY_PEC,
+ MY_PHB,
+ MY_XBUS,
+ MY_OBUS,
+ MY_NVBUS,
+ MY_PPE,
+ MY_PERV,
+ MY_CAPP,
+ MY_SBE,
+ NUM_TARGETS
+};
+
+
+void generateTargets(TARGETING::Target* i_pMasterProcChip,
+ TARGETING::Target* o_targetList[]);
+
+} // End namespace fapi2
+
+#endif
diff --git a/src/usr/fapi2/test/makefile b/src/usr/fapi2/test/makefile
new file mode 100644
index 000000000..ffebf05e3
--- /dev/null
+++ b/src/usr/fapi2/test/makefile
@@ -0,0 +1,47 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/fapi2/test/makefile $
+#
+# OpenPOWER HostBoot Project
+#
+# Contributors Listed Below - COPYRIGHT 2015,2016
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+# @file src/usr/fapi2/test/makefile
+#
+# @brief Makefile for fapi2 test case directory
+#
+ROOTPATH = ../../../..
+MODULE = testfapi2
+
+EXTRAINCDIR += ${ROOTPATH}/src/import/hwpf/fapi2/include/
+EXTRAINCDIR += ${ROOTPATH}/src/include/usr/fapi2/
+EXTRAINCDIR += ${ROOTPATH}/src/usr/fapi2/test/
+EXTRAINCDIR += ${ROOTPATH}/src/import/chips/p9/utils/
+
+
+# Procedures
+OBJS += p9_sample_procedure.o
+OBJS += fapi2TestUtils.o
+
+TESTS += fapi2Test.H
+
+include ${ROOTPATH}/config.mk
+
+vpath %.C ${GENDIR}
+
diff --git a/src/usr/fapi2/test/p9_sample_procedure.C b/src/usr/fapi2/test/p9_sample_procedure.C
new file mode 100644
index 000000000..1d4cf32e9
--- /dev/null
+++ b/src/usr/fapi2/test/p9_sample_procedure.C
@@ -0,0 +1,386 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/p9_sample_procedure.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <cxxtest/TestSuite.H>
+#include <p9_sample_procedure.H>
+#include <fapi2.H>
+#include <plat_attribute_service.H>
+
+
+//------------------------------------------------------------------------------
+/// @file p9_sample_procedure.C
+///
+/// @brief These procedures test FAPI_ATTR_GET, FAPI_ATTR_SET,
+/// and FAPI_TRY and FAPI_ERR. This is primarily here to
+/// to make sure these compile okay.
+//------------------------------------------------------------------------------
+
+
+fapi2::ReturnCode p9_sample_procedure_proc(
+ fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on PROC Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1,
+ i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on PROC Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1,
+ i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d",
+ l_attr_scratch,
+ expectedValue);
+
+
+ fapi_try_exit:
+
+ FAPI_ERR("Exiting ...");
+
+ return fapi2::current_err;
+
+}
+
+
+fapi2::ReturnCode p9_sample_procedure_ex(
+ fapi2::Target<fapi2::TARGET_TYPE_EX>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on EX Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on EX Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_eq(
+ fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on EQ Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on EQ Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_core(
+ fapi2::Target<fapi2::TARGET_TYPE_CORE>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on CORE Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on CORE Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+
+
+fapi2::ReturnCode p9_sample_procedure_mcs(
+ fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on MCS Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on MCS Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_mca(
+ fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on MCA Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on MCA Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_mcbist(
+ fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on MCBIST Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on MCBIST Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_xbus(
+ fapi2::Target<fapi2::TARGET_TYPE_XBUS>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on XBUS Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on XBUS Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_capp(
+ fapi2::Target<fapi2::TARGET_TYPE_CAPP>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on CAPP Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on CAPP Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_obus(
+ fapi2::Target<fapi2::TARGET_TYPE_OBUS>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on OBUS Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on OBUS Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_nv(
+ fapi2::Target<fapi2::TARGET_TYPE_NV>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on NV Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on NV Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_sbe(
+ fapi2::Target<fapi2::TARGET_TYPE_SBE>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on SBE Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on SBE Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_ppe(
+ fapi2::Target<fapi2::TARGET_TYPE_PPE>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on PPE Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on PPE Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_perv(
+ fapi2::Target<fapi2::TARGET_TYPE_PERV>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on PERV Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on PERV Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_phb(
+ fapi2::Target<fapi2::TARGET_TYPE_PHB>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on PHB Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on PHB Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
+fapi2::ReturnCode p9_sample_procedure_pec(
+ fapi2::Target<fapi2::TARGET_TYPE_PEC>& i_target,
+ uint8_t expectedValue)
+{
+ uint8_t l_attr_scratch = 0;
+ FAPI_ERR("Entering ...");
+ FAPI_ERR("Set Scratch Attr on PEC Target");
+ FAPI_TRY(FAPI_ATTR_SET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ expectedValue));
+
+ FAPI_ERR("Get Scratch Attr on PEC Target");
+ FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SCRATCH_UINT8_1, i_target,
+ l_attr_scratch));
+ FAPI_ERR("Read scratch value : %d , expected it to be %d", l_attr_scratch, expectedValue);
+
+fapi_try_exit:
+ FAPI_ERR("Exiting ...");
+ return fapi2::current_err;
+
+}
+
diff --git a/src/usr/fapi2/test/p9_sample_procedure.H b/src/usr/fapi2/test/p9_sample_procedure.H
new file mode 100644
index 000000000..e931e7624
--- /dev/null
+++ b/src/usr/fapi2/test/p9_sample_procedure.H
@@ -0,0 +1,117 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/p9_sample_procedure.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+//------------------------------------------------------------------------------
+/// @file p9_sample_procedure.H
+///
+/// @brief This procedure is a sample p9 procedure for compilation testing
+//------------------------------------------------------------------------------
+
+#ifndef _P9_SAMPLE_PROCEDURE_H_
+#define _P9_SAMPLE_PROCEDURE_H_
+
+
+#include <fapi2.H>
+#include <error_scope.H>
+
+typedef fapi2::ReturnCode (*p9_sample_procedure_FP_t)(const
+ fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>&);
+
+/// @brief This sample function has some CFAM/SCOM access for compilation
+/// testing
+///
+/// @param[in] i_target Reference to TARGET_TYPE_PROC_CHIP target
+/// @return FAPI2_RC_SUCCESS if success, else error code.
+extern "C"
+{
+
+fapi2::ReturnCode p9_sample_procedure_proc(
+ fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
+ uint8_t expectedValue);
+
+
+fapi2::ReturnCode p9_sample_procedure_ex(
+ fapi2::Target<fapi2::TARGET_TYPE_EX>& i_target,
+ uint8_t expectedValue);
+
+
+fapi2::ReturnCode p9_sample_procedure_eq(
+ fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_core(
+ fapi2::Target<fapi2::TARGET_TYPE_CORE>& i_target,
+ uint8_t expectedValue);
+
+
+fapi2::ReturnCode p9_sample_procedure_mcs(
+ fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_mca(
+ fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_mcbist(
+ fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_xbus(
+ fapi2::Target<fapi2::TARGET_TYPE_XBUS>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_capp(
+ fapi2::Target<fapi2::TARGET_TYPE_CAPP>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_obus(
+ fapi2::Target<fapi2::TARGET_TYPE_OBUS>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_nv(
+ fapi2::Target<fapi2::TARGET_TYPE_NV>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_sbe(
+ fapi2::Target<fapi2::TARGET_TYPE_SBE>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_ppe(
+ fapi2::Target<fapi2::TARGET_TYPE_PPE>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_perv(
+ fapi2::Target<fapi2::TARGET_TYPE_PERV>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_phb(
+ fapi2::Target<fapi2::TARGET_TYPE_PHB>& i_target,
+ uint8_t expectedValue);
+
+fapi2::ReturnCode p9_sample_procedure_pec(
+ fapi2::Target<fapi2::TARGET_TYPE_PEC>& i_target,
+ uint8_t expectedValue);
+}
+
+#endif // _P9_SAMPLE_PROCEDURE_H_
OpenPOWER on IntegriCloud