diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/build/debug/Hostboot/CallFunc.pm | 9 | ||||
-rwxr-xr-x | src/build/debug/Hostboot/HwpfAttrOverride.pm | 476 | ||||
-rwxr-xr-x | src/build/debug/Hostboot/_DebugFrameworkVMM.pm | 17 | ||||
-rw-r--r-- | src/build/mkrules/dist_targets.mk | 2 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiAttributeOverride.H | 207 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiAttributeService.H | 103 | ||||
-rwxr-xr-x | src/include/usr/hwpf/plat/fapiPlatAttributeService.H | 288 | ||||
-rw-r--r-- | src/include/usr/hwpf/plat/fapiPlatReasonCodes.H | 4 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiAttributeOverride.C | 331 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/makefile | 3 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/chip_attributes.xml | 16 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/fapiTestHwpAttr.C | 303 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C | 56 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatAttributeService.C | 197 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatTask.C | 63 | ||||
-rw-r--r-- | src/usr/hwpf/plat/makefile | 4 | ||||
-rw-r--r-- | src/usr/initservice/extinitsvc/extinitsvctasks.H | 2 |
17 files changed, 2004 insertions, 77 deletions
diff --git a/src/build/debug/Hostboot/CallFunc.pm b/src/build/debug/Hostboot/CallFunc.pm index e53393131..403be45e9 100755 --- a/src/build/debug/Hostboot/CallFunc.pm +++ b/src/build/debug/Hostboot/CallFunc.pm @@ -168,7 +168,7 @@ sub execFunc my $i = 0; while((0 != ::read16($address + CALLFUNC_DEBUG_READY_OFFSET)) && (0 == ::read8($address + CALLFUNC_DEBUG_COMPLETE_OFFSET)) && - ($i < 50)) + ($i < 100)) { ::executeInstrCycles(100000); $i = $i + 1; @@ -185,8 +185,11 @@ sub execFunc return 1; } - # Display return value. - ::userDisplay ::read64($address + CALLFUNC_DEBUG_RETVAL_OFFSET)."\n"; + if( $debug ) + { + # Display return value. + ::userDisplay ::read64($address + CALLFUNC_DEBUG_RETVAL_OFFSET)."\n"; + } } sub helpInfo diff --git a/src/build/debug/Hostboot/HwpfAttrOverride.pm b/src/build/debug/Hostboot/HwpfAttrOverride.pm new file mode 100755 index 000000000..5b3f312c6 --- /dev/null +++ b/src/build/debug/Hostboot/HwpfAttrOverride.pm @@ -0,0 +1,476 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/build/debug/Hostboot/HwpfAttrOverride.pm $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 2012 +# +# p1 +# +# Object Code Only (OCO) source materials +# Licensed Internal Code Source Materials +# IBM HostBoot Licensed Internal Code +# +# The source code for this program is not published or other- +# wise divested of its trade secrets, irrespective of what has +# been deposited with the U.S. Copyright Office. +# +# Origin: 30 +# +# IBM_PROLOG_END_TAG + +# +# This perl module will be used in a standalone Hostboot environment +# (Simics or VBU) to process a FAPI Attribute Override Text File and +# send the overrides to Hostboot +# +# Author: Mike Jones +# + +use strict; +package Hostboot::HwpfAttrOverride; +use Hostboot::_DebugFrameworkVMM; +use Hostboot::CallFunc; +use Exporter; +our @EXPORT_OK = ('main'); + +#------------------------------------------------------------------------------ +# Constants +#------------------------------------------------------------------------------ + +# From fapiTarget.H +use constant TARGET_TYPE_SYSTEM => 0x00000001; +use constant TARGET_TYPE_DIMM => 0x00000002; +use constant TARGET_TYPE_PROC_CHIP => 0x00000004; +use constant TARGET_TYPE_MEMBUF_CHIP => 0x00000008; +use constant TARGET_TYPE_EX_CHIPLET => 0x00000010; +use constant TARGET_TYPE_MBA_CHIPLET => 0x00000020; +use constant TARGET_TYPE_MCS_CHIPLET => 0x00000040; +use constant TARGET_TYPE_XBUS_ENDPOINT => 0x00000080; +use constant TARGET_TYPE_ABUS_ENDPOINT => 0x00000100; + +# From fapiAttributeOverride.H +use constant ATTR_POS_NA => 0xffff; +use constant ATTR_UNIT_POS_NA => 0xff; +use constant ATTR_ARRAYD_NA => 0xff; +use constant ATTR_OVERRIDE_CONST => 1; +use constant ATTR_OVERRIDE_NON_CONST => 2; +use constant ATTR_OVERRIDE_CLEAR_ALL => 3; + +# From fapiPlatAttrOverrideDirect.C +my $overrideSymbol = 'fapi::g_attrOverride'; + +# Expected filenames +my $attributeIdFileName = 'fapiAttributeIds.H'; +my $overrideFileName = 'hwpfAttributeOverrides.txt'; + +sub main +{ + my ($packName,$args) = @_; + my $debug = 0; + if (defined $args->{"debug"}) + { + $debug = 1; + } + + #-------------------------------------------------------------------------- + # Check if the Attribute ID and Attribute Overrides files exist + #-------------------------------------------------------------------------- + my $attributeIdFile = ::getImgPath(); + $attributeIdFile = $attributeIdFile."$attributeIdFileName"; + unless (-e $attributeIdFile) + { + die "Cannot find file $attributeIdFile"; + } + + my $overrideFile = ::getImgPath(); + $overrideFile = $overrideFile."$overrideFileName"; + unless (-e $overrideFile) + { + die "Cannot find file $overrideFile"; + } + + #-------------------------------------------------------------------------- + # Process the Attribute ID file. Record the values of the Attribute IDs and + # the Attribute Enumeration Values in hashes + #-------------------------------------------------------------------------- + my %attributeIdVals; + my %attributeEnumVals; + + open(IDFILE, "< $attributeIdFile") or die "Cannot open file $attributeIdFile"; + while (my $line = <IDFILE>) + { + chomp($line); + + if ($line =~ /^\s+(ATTR_\S+) = 0x(\S+),/) + { + # Found an attribute ID + $attributeIdVals{$1} = hex $2 + } + # Note that enumerated values can end with 'ULL' + elsif ($line =~ /\s+(ENUM_ATTR_\S+) = 0x([a-fA-F0-9]+)/) + { + # Found a hex attribute value enumeration + $attributeEnumVals{$1} = hex $2; + } + elsif ($line =~ /\s+(ENUM_ATTR_\S+) = ([0-9]+)/) + { + # Found a decimal attribute value enumeration + $attributeEnumVals{$1} = $2; + } + } + close(IDFILE); + + # Debug output + if ($debug) + { + foreach my $key (keys %attributeIdVals) + { + ::userDisplay "AttrIdVal: $key => $attributeIdVals{$key}\n"; + } + foreach my $key (keys %attributeEnumVals) + { + ::userDisplay "AttrEnumVal: $key => $attributeEnumVals{$key}\n"; + } + } + + #-------------------------------------------------------------------------- + # Process the Attribute Overrides file. Record the information for each + # override in arrays + #-------------------------------------------------------------------------- + my @attrIdString; + my @overrideVal; + my @attrId; + my @targetType; + my @pos; + my @unitPos; + my @overrideType; + my @arrayD1; + my @arrayD2; + my @arrayD3; + my @arrayD4; + + # Setup the initial override to be an instruction to "clear all overrides" + $attrIdString[0] = "CLEAR_ALL_OVERRIDES"; + $overrideVal[0] = 0; + $attrId[0] = 0; + $targetType[0] = 0; + $pos[0] = 0; + $unitPos[0] = 0; + $overrideType[0] = ATTR_OVERRIDE_CLEAR_ALL; + $arrayD1[0] = 0; + $arrayD2[0] = 0; + $arrayD3[0] = 0; + $arrayD4[0] = 0; + + my $numOverrides = 1; + my $curTargetType = TARGET_TYPE_SYSTEM; + my $curPos = ATTR_POS_NA; + my $curUnitPos = ATTR_UNIT_POS_NA; + + open(OVFILE, "< $overrideFile") or die "Cannot open file $overrideFile"; + + while (my $line = <OVFILE>) + { + chomp($line); + + if ($line =~ /^target = /) + { + # Found a target + my $p8pres = 0; + + # Figure out the target type + if ($line =~ /p8.ex/) + { + $p8pres = 1; + $curTargetType = TARGET_TYPE_EX_CHIPLET; + } + elsif ($line =~ /centaur.mba/) + { + $curTargetType = TARGET_TYPE_MBA_CHIPLET; + } + elsif ($line =~ /p8.mcs/) + { + $p8pres = 1; + $curTargetType = TARGET_TYPE_MCS_CHIPLET; + } + elsif ($line =~ /p8.xbus/) + { + $p8pres = 1; + $curTargetType = TARGET_TYPE_XBUS_ENDPOINT; + } + elsif ($line =~ /p8.abus/) + { + $p8pres = 1; + $curTargetType = TARGET_TYPE_ABUS_ENDPOINT; + } + elsif ($line =~ /centaur/) + { + $curTargetType = TARGET_TYPE_MEMBUF_CHIP; + } + elsif ($line =~ /p8/) + { + $p8pres = 1; + $curTargetType = TARGET_TYPE_PROC_CHIP; + } + elsif ($line =~ /dimm/) + { + $curTargetType = TARGET_TYPE_DIMM; + } + else + { + $curTargetType = TARGET_TYPE_SYSTEM; + } + + # Figure out the position + if ($p8pres == 1) + { + # Do not confuse 'p8' for position 8 + if ($line =~ /p8\S*:p(\d+)/) + { + $curPos = $1; + } + else + { + $curPos = ATTR_POS_NA; + } + } + else + { + if ($line =~ /:p(\d+)/) + { + $curPos = $1; + } + else + { + $curPos = ATTR_POS_NA; + } + } + + # Figure out the unit position + if ($line =~ /:c(\d+)/) + { + $curUnitPos = $1; + } + else + { + $curUnitPos = ATTR_UNIT_POS_NA; + } + } + elsif ($line =~ /^(ATTR_\w+)/) + { + # Found an override + $attrIdString[$numOverrides] = $1; + $targetType[$numOverrides] = $curTargetType; + $pos[$numOverrides] = $curPos; + $unitPos[$numOverrides] = $curUnitPos; + + # Figure out the attribute ID + if (exists $attributeIdVals{$1}) + { + $attrId[$numOverrides] = $attributeIdVals{$1}; + } + else + { + ::userDisplay "Cannot find ID $1 in $attributeIdFile\n"; + die; + } + + # Figure out the attribute array dimensions + if ($line =~ /^ATTR_\w+\[(\d)\]\[(\d)\]\[(\d)\]\[(\d)\] /) + { + # 4D array override + $arrayD1[$numOverrides] = $1; + $arrayD2[$numOverrides] = $2; + $arrayD3[$numOverrides] = $3; + $arrayD4[$numOverrides] = $4; + } + elsif ($line =~ /^ATTR_\w+\[(\d)\]\[(\d)\]\[(\d)\] /) + { + # 3D array override + $arrayD1[$numOverrides] = $1; + $arrayD2[$numOverrides] = $2; + $arrayD3[$numOverrides] = $3; + $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + } + elsif ($line =~ /^ATTR_\w+\[(\d)\]\[(\d)\] /) + { + # 2D array override + $arrayD1[$numOverrides] = $1; + $arrayD2[$numOverrides] = $2; + $arrayD3[$numOverrides] = ATTR_ARRAYD_NA; + $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + } + elsif ($line =~ /^ATTR_\w+\[(\d)\] /) + { + # 1D array override + $arrayD1[$numOverrides] = $1; + $arrayD2[$numOverrides] = ATTR_ARRAYD_NA; + $arrayD3[$numOverrides] = ATTR_ARRAYD_NA; + $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + } + else + { + # Non-array attribute + $arrayD1[$numOverrides] = ATTR_ARRAYD_NA; + $arrayD2[$numOverrides] = ATTR_ARRAYD_NA; + $arrayD3[$numOverrides] = ATTR_ARRAYD_NA; + $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + } + + # Figure out the override value + if ($line =~ /^ATTR_\S+\s+\S+\s+([A-Za-z]+\S*)/) + { + # enumerator + my $enum = "ENUM_"."$attrIdString[$numOverrides]"."_$1"; + if (exists $attributeEnumVals{$enum}) + { + $overrideVal[$numOverrides] = $attributeEnumVals{$enum}; + } + else + { + ::userDisplay "Cannot find enum $enum in $attributeIdFile\n"; + die; + } + } + elsif ($line =~ /^ATTR_\S+\s+\S+\s+0x([0-9A-Za-z]+)/) + { + # Hex value + $overrideVal[$numOverrides] = hex $1; + } + elsif ($line =~ /^ATTR_\S+\s+\S+\s+(\d+)/) + { + # Decimal Value + $overrideVal[$numOverrides] = $1; + } + else + { + ::userDisplay "Cannot find override value for $attrIdString[$numOverrides]\n"; + die; + } + + # Figure out the override type + if ($line =~ /CONST\s*/) + { + $overrideType[$numOverrides] = ATTR_OVERRIDE_CONST; + } + else + { + $overrideType[$numOverrides] = ATTR_OVERRIDE_NON_CONST; + } + + # Debug output + if ($debug) + { + ::userDisplay "OVERRIDE. Val: $overrideVal[$numOverrides]. "; + ::userDisplay "ID: $attrId[$numOverrides]. "; + ::userDisplay "TargType: $targetType[$numOverrides]. "; + ::userDisplay "Pos: $pos[$numOverrides].$unitPos[$numOverrides].\n"; + ::userDisplay " OType: $overrideType[$numOverrides]. "; + ::userDisplay "Dims: $arrayD1[$numOverrides]."; + ::userDisplay "$arrayD2[$numOverrides]."; + ::userDisplay "$arrayD3[$numOverrides]."; + ::userDisplay "$arrayD4[$numOverrides]\n"; + } + + $numOverrides++; + } + } + close(OVFILE); + + #-------------------------------------------------------------------------- + # Get the address of the Hostboot Attribute Override variable + #-------------------------------------------------------------------------- + my $overrideSymAddr = (::findSymbolAddress("$overrideSymbol"))[0]; + + if (not defined $overrideSymAddr) + { + ::userDisplay "Cannot find Hostboot symbol $overrideSymbol\n"; + die; + } + + my $overrideAddr = + Hostboot::_DebugFrameworkVMM::getPhysicalAddr($overrideSymAddr, $debug, 0); + + if ($overrideAddr eq Hostboot::_DebugFrameworkVMM::NotFound) + { + ::userDisplay "Cannot translate $overrideSymbol to a physical address\n"; + die; + } + + # From fapiAttributeOverride.H + # struct AttributeOverride + # { + # uint64_t iv_overrideVal; // Large enough to hold the biggest attribute size + # uint32_t iv_attrId; // fapi::AttributeId enum value + # uint32_t iv_targetType; // fapi::TargetType enum value + # uint16_t iv_pos; // For chips/dimms the position + # // For chiplets the parent chip position + # uint8_t iv_unitPos; // For chiplets the position + # uint8_t iv_overrideType; // fapi::AttributeOverrideType enum value + # uint8_t iv_arrayD1; // Applies to element D1 in 1D or more array atts + # uint8_t iv_arrayD2; // Applies to element D2 in 2D or more array atts + # uint8_t iv_arrayD3; // Applies to element D3 in 3D or more array atts + # uint8_t iv_arrayD4; // Applies to element D4 in 4D array atts + # }; + + #-------------------------------------------------------------------------- + # Send the overrides to Hostboot + #-------------------------------------------------------------------------- + for (my $i = 0; $i < $numOverrides; $i++) + { + # Write override to Hostboot + my $addr = $overrideAddr; + ::write64($addr, $overrideVal[$i]); + $addr += 8; + ::write32($addr, $attrId[$i]); + $addr += 4; + ::write32($addr, $targetType[$i]); + $addr += 4; + ::write16($addr, $pos[$i]); + $addr += 2; + ::write8($addr, $unitPos[$i]); + $addr++; + ::write8($addr, $overrideType[$i]); + $addr++; + ::write8($addr, $arrayD1[$i]); + $addr++; + ::write8($addr, $arrayD2[$i]); + $addr++; + ::write8($addr, $arrayD3[$i]); + $addr++; + ::write8($addr, $arrayD4[$i]); + + # Tell Hostboot to process the override + my $callFuncForce = 0; + my @callFuncParms; + Hostboot::CallFunc::execFunc("fapi::platAttrOverrideDirect()", + $debug, $callFuncForce, \@callFuncParms); + + if ($debug) + { + ::userDisplay "$attrIdString[$i] sent\n"; + } + } + + # The first override is actually an instruction to clear all overrides + my $actualNum = $numOverrides - 1; + ::userDisplay "All $actualNum override(s) successfully sent to Hostboot\n"; +} + +sub helpInfo +{ + my %info = ( + name => "HwpfAttrOverride", + intro => ["Applies HWPF Attribute Overrides to Hostboot"], + options => { + "debug" => ["More debug output."], + }, + notes => ["Looks for two files in the image directory", + "$attributeIdFileName: Contains attribute id/enum values", + "$overrideFileName: Contains the attribute overrides"] + ); +} diff --git a/src/build/debug/Hostboot/_DebugFrameworkVMM.pm b/src/build/debug/Hostboot/_DebugFrameworkVMM.pm index f8fb15488..a4e5bef03 100755 --- a/src/build/debug/Hostboot/_DebugFrameworkVMM.pm +++ b/src/build/debug/Hostboot/_DebugFrameworkVMM.pm @@ -614,14 +614,17 @@ sub getPhysicalAddr ::userDisplay (" \nVirtualToPhy: ERROR.. VA Address is out of range.\n"); } - if (($phyAddr eq Hostboot::_DebugFrameworkVMM::NotFound) || - ($phyAddr eq Hostboot::_DebugFrameworkVMM::NotPresent)) - { - ::userDisplay ("\n The Physical Address = $phyAddr\n"); - } - else + if ($debug) { - ::userDisplay (sprintf "\n The Physical Address = %X\n\n" , $phyAddr); + if (($phyAddr eq Hostboot::_DebugFrameworkVMM::NotFound) || + ($phyAddr eq Hostboot::_DebugFrameworkVMM::NotPresent)) + { + ::userDisplay ("\n The Physical Address = $phyAddr\n"); + } + else + { + ::userDisplay (sprintf "\n The Physical Address = %X\n\n" , $phyAddr); + } } return $phyAddr; diff --git a/src/build/mkrules/dist_targets.mk b/src/build/mkrules/dist_targets.mk index e5089c4a1..ea57bbb1e 100644 --- a/src/build/mkrules/dist_targets.mk +++ b/src/build/mkrules/dist_targets.mk @@ -58,6 +58,7 @@ COPY_FILES = \ img/isteplist.csv:tools,vpo \ img/dimmspd.dat:vpo \ img/procmvpd.dat:vpo \ + obj/genfiles/fapiAttributeIds.H:vpo \ src/build/hwpf/prcd_compile.tcl:tools \ src/usr/hwpf/hwp/initfiles/sample.initfile:tools \ $(foreach file, $(call ROOTPATH_WILDCARD,releaseNotes.html), $(file):fsp)\ @@ -148,6 +149,7 @@ simics.tar_CONTENTS = \ src/build/simics/hb-pnor-mvpd-preload.pl \ img/dimmspd.dat \ img/procmvpd.dat \ + obj/genfiles/fapiAttributeIds.H \ # # Contents for the fsp.tar. diff --git a/src/include/usr/hwpf/fapi/fapiAttributeOverride.H b/src/include/usr/hwpf/fapi/fapiAttributeOverride.H new file mode 100644 index 000000000..2a125a5ec --- /dev/null +++ b/src/include/usr/hwpf/fapi/fapiAttributeOverride.H @@ -0,0 +1,207 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/include/usr/hwpf/fapi/fapiAttributeOverride.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ +/** + * @file fapiAttributeOverride.H + * + * @brief Defines the AttributeOverrides and AttributeOverride classes. A + * platform can choose to use an AttributeOverrides object to store + * Attribute Overrides. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 06/07/2012 Created + */ + +#ifndef FAPIATTROVERRIDE_H_ +#define FAPIATTROVERRIDE_H_ + +#include <stdint.h> +#include <list> +#include <fapiAttributeIds.H> +#include <fapiTarget.H> + +namespace fapi +{ + +/** + * @enum AttributeOverrideType + * + * Enumeration of the possible attribute override types + */ +enum AttributeOverrideType +{ + ATTR_OVERRIDE_CONST = 1, // Not cleared by a FAPI_ATTR_SET + ATTR_OVERRIDE_NON_CONST = 2, // Cleared by a FAPI_ATTR_SET + ATTR_OVERRIDE_CLEAR_ALL = 3, // Clear all overrides +}; + +// Constants for various fields in AttributeOverrides +const uint16_t ATTR_POS_NA = 0xffff; // iv_pos not applicable +const uint8_t ATTR_UNIT_POS_NA = 0xff; // iv_unitPos not applicable +const uint8_t ATTR_ARRAYD_NA = 0xff; // iv_arayX not applicable + +/** + * @struct AttributeOverride + * + * This structure defines a single attribute override. In the case of an array + * attribute, it is an override for a single element + */ +struct AttributeOverride +{ + uint64_t iv_overrideVal; // Large enough to hold the biggest attribute size + uint32_t iv_attrId; // fapi::AttributeId enum value + uint32_t iv_targetType; // fapi::TargetType enum value + uint16_t iv_pos; // For chips/dimms the position + // For chiplets the parent chip position + uint8_t iv_unitPos; // For chiplets the position + uint8_t iv_overrideType; // fapi::AttributeOverrideType enum value + uint8_t iv_arrayD1; // Applies to element D1 in 1D or more array atts + uint8_t iv_arrayD2; // Applies to element D2 in 2D or more array atts + uint8_t iv_arrayD3; // Applies to element D3 in 3D or more array atts + uint8_t iv_arrayD4; // Applies to element D4 in 4D array atts +}; + +/** + * @class AttributeOverrides + * + * This class can be used to set and query attribute overrides + */ +class AttributeOverrides +{ +public: + /** + * @brief Default constructor + */ + AttributeOverrides(); + + /** + * @brief Destructor + */ + ~AttributeOverrides(); + + /** + * @brief Clear all overrides + */ + void clearOverrides(); + + /** + * @brief Clear any non-const override for a specified ID and Target + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + */ + void clearNonConstOverride(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget); + + /** + * @brief Set an override + * + * Note that no checking is done for duplicate overrides (an override on an + * attribute that already has an override) for performance. If a duplicate + * override is done then getOverride will return the first one. + * + * @param[in] i_override Reference to override structure, this is copied + */ + void setOverride(const AttributeOverride & i_override); + + /** + * @brief Get an override + * + * Note that for array attributes, this must be called repeatedly, to query + * an override for each element of the array + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[out] o_overrideVal Reference that is filled in with the override + * @param[in] i_arrayD1 Array dimension 1 if applicable + * @param[in] i_arrayD2 Array dimension 2 if applicable + * @param[in] i_arrayD3 Array dimension 3 if applicable + * @param[in] i_arrayD4 Array dimension 4 if applicable + * + * return true if override exists and was returned. + */ + bool getOverride(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + uint64_t & o_overrideVal, + const uint8_t i_arrayD1 = ATTR_ARRAYD_NA, + const uint8_t i_arrayD2 = ATTR_ARRAYD_NA, + const uint8_t i_arrayD3 = ATTR_ARRAYD_NA, + const uint8_t i_arrayD4 = ATTR_ARRAYD_NA); + + /** + * @brief Returns if any overrides exist + * + * This is only expected to be called by unit test + * + * return true if any overrides exist + */ + bool overridesExist(); + +private: + // Copy constructor and assignment operator disabled + AttributeOverrides(const AttributeOverrides & i_right); + AttributeOverrides & operator=(const AttributeOverrides & i_right); + + /** + * @brief Returns if the specified override is for the specified + * attribute ID and Target + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[in] i_candidate Reference to AttributeOverride + * + * @return true if the AttributeOverride matches + */ + static bool overrideMatch(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + const AttributeOverride & i_candidate); + + /** + * @brief Locks the AttributeOverrides object + * + * Implemented by the platform + */ + static void platLock(); + + /** + * @brief Unlocks the AttributeOverrides object + * + * Implemented by the platform + */ + static void platUnlock(); + + // The attribute overrides + bool iv_overridesExist; + std::list<AttributeOverride *> iv_overrides; + typedef std::list<AttributeOverride *>::iterator OverridesItr_t; + typedef std::list<AttributeOverride *>::const_iterator OverridesCItr_t; + +}; + +} + +#endif // FAPIATTROVERRIDE_H_ diff --git a/src/include/usr/hwpf/fapi/fapiAttributeService.H b/src/include/usr/hwpf/fapi/fapiAttributeService.H index 35f370c6d..1744d11a6 100644 --- a/src/include/usr/hwpf/fapi/fapiAttributeService.H +++ b/src/include/usr/hwpf/fapi/fapiAttributeService.H @@ -1,25 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/hwpf/fapi/fapiAttributeService.H $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// p1 -// -// Object Code Only (OCO) source materials -// Licensed Internal Code Source Materials -// IBM HostBoot Licensed Internal Code -// -// The source code for this program is not published or other- -// wise divested of its trade secrets, irrespective of what has -// been deposited with the U.S. Copyright Office. -// -// Origin: 30 -// -// IBM_PROLOG_END +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/include/usr/hwpf/fapi/fapiAttributeService.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2011-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ /** * @file fapiAttributeService.H * @@ -40,6 +41,7 @@ * camvanng 10/20/2011 Changed i_pTarget to "const" * ptr * mjjones 04/10/2012 Support for privileged atts + * mjjones 06/07/2012 Add attr override support */ #ifndef FAPIATTRIBUTESERVICE_H_ @@ -65,33 +67,58 @@ * l_rc = FAPI_ATTR_GET(<ID>, l_pTarget, l_pVal); * l_rc = FAPI_ATTR_SET(<ID>, l_pTarget, l_pVal); * - * The first part of these macros is a call to fapiCheckIdType that will cause a - * compile failure if the ID or VAL parameters are incorrect. + * A priveleged attribute is one that a HWP should not generally access, + * examples include ATTR_NAME and ATTR_EC, where usage can lead to a non + * data-driven design. A privileged attribute can be accessed with + * FAPI_ATTR_GET_PRIVILEGED and FAPI_ATTR_SET_PRIVILEGED + * + * The non-PRIVILEGED macros first call a template function (compiler will + * optimize out) that will cause a compile failure if the attribute is + * privileged, they then call a PRIVILEGED macro to get/set the attribute * - * For the non-PRIVILEGED macros, the second part is a call to - * fapiFailIfPrivileged that will cause a compile failure if the attribute is - * privileged (in general, HWPs should not access privileged attributes. - * Examples include ATTR_NAME and ATTR_EC, where usage can lead to a non - * data-driven design). + * The PRIVILEGED macros call a template function (compiler will optimize out) + * that will cause a compile failure if the ID is not valid or VAL is not the + * correct type. + * The GET macro calls the FAPI_PLAT_GET_ATTR_OVERRIDE PLAT macro to find if + * there is an attribute override value to return (platforms can set this to + * false if they do not support attribute override or if they handle it in + * the standard <ID>_GETMACRO path), if this returns false then the + * <ID>_GETMACRO PLAT macro is called to get the attribute, platforms must + * define a _GETMACRO for each attribute. * - * The final part of these macros calls a macro named <ID>_GET/SETMACRO. This - * macro is defined by PLAT and must do the work of getting/setting the - * attribute. + * The SET macro calls the <ID>_SETMACRO PLAT macro to set the attribute, + * platforms must define a _SETMACRO for each attribute. It then calls the + * FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE to clear any non-const attribute + * overrides (platforms can set this to NULL if they do not support + * attribute override or if they handle it in the standard <ID>_SETMACRO + * path). + * + * Note that a const attribute override is one that is always returned on a + * FAPI_ATTR_GET even if a subsequent FAPI_ATTR_SET is done. A non-const + * attribute override is one that is cleared when a FAPI_ATTR_SET is done */ #define FAPI_ATTR_GET(ID, PTARGET, VAL) \ - (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \ - fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \ - ID##_GETMACRO(ID, PTARGET, VAL)) + (fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \ + fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \ + FAPI_PLAT_GET_ATTR_OVERRIDE(fapi::ID, PTARGET, VAL) ? \ + fapi::FAPI_RC_SUCCESS \ + : ID##_GETMACRO(ID, PTARGET, VAL)) + #define FAPI_ATTR_SET(ID, PTARGET, VAL) \ - (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \ - fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \ + (fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \ + fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \ + FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE(fapi::ID, PTARGET), \ ID##_SETMACRO(ID, PTARGET, VAL)) #define FAPI_ATTR_GET_PRIVILEGED(ID, PTARGET, VAL) \ (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \ - ID##_GETMACRO(ID, PTARGET, VAL)) + FAPI_PLAT_GET_ATTR_OVERRIDE(fapi::ID, PTARGET, VAL) ? \ + fapi::FAPI_RC_SUCCESS \ + : ID##_GETMACRO(ID, PTARGET, VAL)) + #define FAPI_ATTR_SET_PRIVILEGED(ID, PTARGET, VAL) \ (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \ + FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE(fapi::ID, PTARGET), \ ID##_SETMACRO(ID, PTARGET, VAL)) namespace fapi diff --git a/src/include/usr/hwpf/plat/fapiPlatAttributeService.H b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H index 834f2facf..a60abcb38 100755 --- a/src/include/usr/hwpf/plat/fapiPlatAttributeService.H +++ b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H @@ -52,8 +52,10 @@ #include <fapiplatattrmacros.H> #include <hwpf/fapi/fapiReturnCode.H> #include <hwpf/fapi/fapiTarget.H> +#include <hwpf/fapi/fapiAttributeOverride.H> #include <spd/spdenums.H> #include <dimmConsts.H> +#include <util/singleton.H> //****************************************************************************** // Interface @@ -163,10 +165,290 @@ fapi::ReturnCode fapiPlatGetTargetName(const fapi::Target * i_pTarget, fapi::ReturnCode fapiPlatGetFunctional(const fapi::Target * i_pTarget, uint8_t & o_functional); +/** + * @brief This function is called by the FAPI_ATTR_GET macro when getting + * ATTR_POS. It should not be called directly + * + * This is needed because the HWPF attribute is a uint32_t and the Hostboot + * attribute is a uint16_t so a direct map will not work + * + * @param[in] i_pFapiTarget Target pointer + * @param[out] o_pos Output Posititon + * @return ReturnCode. Zero on success, else platform specified error + */ +fapi::ReturnCode fapiPlatGetTargetPos(const fapi::Target * i_pFapiTarget, + uint32_t & o_pos); + +/** + * @brief This wrapper function is called by the getAttrOverride function + * templates (which are called by FAPI_PLAT_GET_ATTR_OVERRIDE) to get an + * attribute override value + * + * This wrapper just invokes getAttrOverride on the AttributeOverrides singleton + * in the local (plat) module, it is needed because Singletons cannot be + * accessed outside of a module (this results in a duplicate singleton) + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[out] o_overrideVal Reference to value filled in with the override + * @param[in] i_arrayD1 Array dimension 1 if applicable + * @param[in] i_arrayD2 Array dimension 2 if applicable + * @param[in] i_arrayD3 Array dimension 3 if applicable + * @param[in] i_arrayD4 Array dimension 4 if applicable + * @return bool True if override value was returned + */ +bool getOverrideWrap(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + uint64_t & o_overrideVal, + const uint8_t i_arrayD1 = ATTR_ARRAYD_NA, + const uint8_t i_arrayD2 = ATTR_ARRAYD_NA, + const uint8_t i_arrayD3 = ATTR_ARRAYD_NA, + const uint8_t i_arrayD4 = ATTR_ARRAYD_NA); + +/** + * @brief This wrapper function is called by + * FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE to clear a non-const attribute + * override. + * + * This wrapper just invokes clearNonConstOverride on the AttributeOverrides + * singleton in the local (plat) module, it is needed because Singletons cannot + * be accessed outside of a module (this results in a duplicate singleton) + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + */ +void clearNonConstOverrideWrap(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget); + +/** + * @brief This wrapper function is called by HWP unit test to set an attribute + * override. It is not called by production code (outside of unit test, + * attribute overrides are set by the FSP or by a debug tool) + * + * This wrapper just invokes setOverride on the AttributeOverrides singleton in + * the local (plat) module, it is needed because Singletons cannot be accessed + * outside of a module (this results in a duplicate singleton) + * + * @param[in] i_override Reference to override + */ +void setOverrideWrap(const AttributeOverride & i_override); + +/** + * @brief This wrapper function is called by HWP unit test to clear all + * attribute overrides. It is not called by production code (outside of + * unit test, attribute overrides are cleared by the FSP or by a debug + * tool) + * + * This wrapper just invokes clearOverrides on the AttributeOverrides singleton + * in the local (plat) module, it is needed because Singletons cannot be + * accessed outside of a module (this results in a duplicate singleton) + */ +void clearOverridesWrap(); + +/** + * @brief This wrapper function is called by HWP unit test to test if any + * attribute overrides exist. It is not called by production code. + * + * This wrapper just invokes overridesExist on the AttributeOverrides singleton + * in the local (plat) module, it is needed because Singletons cannot be + * accessed outside of a module (this results in a duplicate singleton) + */ +bool overridesExistWrap(); + +/** + * @brief This function template is called by the FAPI_PLAT_GET_ATTR_OVERRIDE + * macro to get any override for a 1D array attribute + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[out] o_1dArray Reference to 1D array where override will be copied to + * @return bool True if override was returned + */ +template <typename T, uint8_t SZ1> +bool getOverrideT(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + T(&o_1dArray)[SZ1]) +{ + uint64_t l_overrideVal = 0; + + for (uint8_t d1 = 0; d1 < SZ1; d1++) + { + if (!(getOverrideWrap(i_attrId, i_pTarget, l_overrideVal, d1))) + { + // For array attributes, all elements must be overridden + return false; + } + else + { + // Standard conversion converts uint64_t to attribute type + o_1dArray[d1] = l_overrideVal; + } + } + + return true; +} + +/** + * @brief This function template is called by the FAPI_PLAT_GET_ATTR_OVERRIDE + * macro to get any override for a 2D array attribute + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[out] o_2dArray Reference to 2D array where override will be copied to + * @return bool True if override was returned + */ +template <typename T, uint8_t SZ1, uint8_t SZ2> +bool getOverrideT(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + T(&o_2dArray)[SZ1][SZ2]) +{ + uint64_t l_overrideVal = 0; + + for (uint8_t d1 = 0; d1 < SZ1; d1++) + { + for (uint8_t d2 = 0; d2 < SZ2; d2++) + { + if (!(getOverrideWrap(i_attrId, i_pTarget, l_overrideVal, d1, d2))) + { + // For array attributes, all elements must be overridden + return false; + } + else + { + // Standard conversion converts uint64_t to attribute type + o_2dArray[d1][d2] = l_overrideVal; + } + } + } + + return true; +} + +/** + * @brief This function template is called by the FAPI_PLAT_GET_ATTR_OVERRIDE + * macro to get any override for a 3D array attribute + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[out] o_3dArray Reference to 3D array where override will be copied to + * @return bool True if override was returned + */ +template <typename T, uint8_t SZ1, uint8_t SZ2, uint8_t SZ3> +bool getOverrideT(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + T(&o_3dArray)[SZ1][SZ2][SZ3]) +{ + uint64_t l_overrideVal = 0; + + for (uint8_t d1 = 0; d1 < SZ1; d1++) + { + for (uint8_t d2 = 0; d2 < SZ2; d2++) + { + for (uint8_t d3 = 0; d3 < SZ3; d3++) + { + if (!(getOverrideWrap(i_attrId, i_pTarget, l_overrideVal, d1, + d2, d3))) + { + // For array attributes, all elements must be overridden + return false; + } + else + { + // Standard conversion converts uint64_t to attribute type + o_3dArray[d1][d2][d3] = l_overrideVal; + } + } + } + } + + return true; +} + +/** + * @brief This function template is called by the FAPI_PLAT_GET_ATTR_OVERRIDE + * macro to get any override for a 4D array attribute + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[out] o_4dArray Reference to 4D array where override will be copied to + * @return bool True if override was returned + */ +template <typename T, uint8_t SZ1, uint8_t SZ2, uint8_t SZ3, uint8_t SZ4> +bool getOverrideT(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + T(&o_4dArray)[SZ1][SZ2][SZ3][SZ4]) +{ + uint64_t l_overrideVal = 0; + + for (uint8_t d1 = 0; d1 < SZ1; d1++) + { + for (uint8_t d2 = 0; d2 < SZ2; d2++) + { + for (uint8_t d3 = 0; d3 < SZ3; d3++) + { + for (uint8_t d4 = 0; d4 < SZ4; d4++) + { + if (!(getOverrideWrap(i_attrId, i_pTarget, l_overrideVal, + d1, d2, d3, d4))) + { + // For array attributes, all elements must be overridden + return false; + } + else + { + // Standard conversion converts uint64_t to attribute + // type + o_4dArray[d1][d2][d3][d4] = l_overrideVal; + } + } + } + } + } + + return true; } +/** + * @brief This function template is called by the FAPI_PLAT_GET_ATTR_OVERRIDE + * macro to get any override for a non-array attribute + * + * @param[in] i_attrId Attribute ID + * @param[in] i_pTarget Pointer to Target (NULL if system) + * @param[out] o_val Reference to variable where override will be copied to + * @return bool True if override was returned + */ +template <typename T> +bool getOverrideT(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + T & o_val) +{ + uint64_t l_overrideVal = 0; + + if (!(getOverrideWrap(i_attrId, i_pTarget, l_overrideVal))) + { + return false; + } + + o_val = static_cast<T>(l_overrideVal); + return true; } +} // namespace platAttrSvc + +} // namespace fapi + +/** + * @brief Macro that returns any attribute override + */ +#define FAPI_PLAT_GET_ATTR_OVERRIDE(ID, PTARGET, VAL) \ + fapi::platAttrSvc::getOverrideT(ID, PTARGET, VAL) + +/** + * @brief Macro that clears any non-const attribute override + */ +#define FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE(ID, PTARGET) \ + fapi::platAttrSvc::clearNonConstOverrideWrap(ID, PTARGET) + /** * @brief Macro which directly maps a FAPI request to get a platform * attribute to the equivalent host boot request @@ -315,4 +597,10 @@ fapi::ReturnCode fapiPlatGetFunctional(const fapi::Target * i_pTarget, #define ATTR_FUNCTIONAL_GETMACRO(ID, PTARGET, VAL) \ fapi::platAttrSvc::fapiPlatGetFunctional(PTARGET, VAL) +//------------------------------------------------------------------------------ +// MACRO to route ATTR_POS access to the correct Hostboot function +//------------------------------------------------------------------------------ +#define ATTR_POS_GETMACRO(ID, PTARGET, VAL) \ + fapi::platAttrSvc::fapiPlatGetTargetPos(PTARGET, VAL) + #endif // FAPIPLATATTRIBUTESERVICE_H_ diff --git a/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H b/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H index 883ed2783..d1c6b0b7a 100644 --- a/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H +++ b/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H @@ -53,6 +53,7 @@ namespace fapi MOD_EDI_EI_IO_RUN_TRAINING = 0x0D, MOD_THREAD_ACTIVATE = 0x0E, //@fixme RTC:42816 MOD_ATTR_GET_FUNCTIONAL = 0x0F, + MOD_ATTR_GET_HB_TARGET = 0x10, }; /** @@ -82,6 +83,9 @@ namespace fapi RC_NO_MASTER_CORE_TARGET = HWPF_COMP_ID | 0x1C, RC_THREAD_IN_WRONG_STATE = HWPF_COMP_ID | 0x1D, //@fixme RTC:42816 RC_THREAD_DID_NOT_START = HWPF_COMP_ID | 0x1E, //@fixme RTC:42816 + RC_NULL_FAPI_TARGET = HWPF_COMP_ID | 0x1F, + RC_UNEXPECTED_TARGET_TYPE = HWPF_COMP_ID | 0x20, + RC_ATTR_UNKNOWN_TARGET_NAME = HWPF_COMP_ID | 0x21, }; /** diff --git a/src/usr/hwpf/fapi/fapiAttributeOverride.C b/src/usr/hwpf/fapi/fapiAttributeOverride.C new file mode 100644 index 000000000..636bafc25 --- /dev/null +++ b/src/usr/hwpf/fapi/fapiAttributeOverride.C @@ -0,0 +1,331 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/fapi/fapiAttributeOverride.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ +/** + * @file fapiAttributeOverride.C + * + * @brief Implements the AttributeOverrides and AttributeOverride classes. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 06/07/2012 Created + */ + +#include <fapiAttributeOverride.H> +#include <fapiAttributeService.H> +#include <fapiPlatTrace.H> +#include <fapiReturnCode.H> +#include <fapiSystemConfig.H> + +namespace fapi +{ + +//****************************************************************************** +// Default Constructor +//****************************************************************************** +AttributeOverrides::AttributeOverrides() + : iv_overridesExist(false) +{ + FAPI_IMP("AttributeOverrides: Constructor"); +} + +//****************************************************************************** +// Destructor +//****************************************************************************** +AttributeOverrides::~AttributeOverrides() +{ + FAPI_IMP("AttributeOverrides: Destructor"); + for (OverridesItr_t l_itr = iv_overrides.begin(); l_itr + != iv_overrides.end(); ++l_itr) + { + delete (*l_itr); + } +} + +//****************************************************************************** +// clearOverrides +//****************************************************************************** +void AttributeOverrides::clearOverrides() +{ + FAPI_IMP("AttributeOverrides: Clearing all overrides"); + platLock(); + + iv_overridesExist = false; + + for (OverridesItr_t l_itr = iv_overrides.begin(); l_itr + != iv_overrides.end(); ++l_itr) + { + delete (*l_itr); + } + + iv_overrides.clear(); + + platUnlock(); +} + +//****************************************************************************** +// clearNonConstOverride +//****************************************************************************** +void AttributeOverrides::clearNonConstOverride( + const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget) +{ + // Do a quick check to see if any overrides exist. This is deliberately done + // without a lock for performance. Overrides should not be changed while + // HWPs are setting attributes, but even if they are there is no risk of + // corruption. + if (!iv_overridesExist) + { + return; + } + + platLock(); + + // Note that for an array attribute with an override, there will be multiple + // AttributeOverride objects, one for each element + OverridesItr_t l_itr = iv_overrides.begin(); + + while (l_itr != iv_overrides.end()) + { + if (((*l_itr)->iv_overrideType == ATTR_OVERRIDE_NON_CONST) && + overrideMatch(i_attrId, i_pTarget, *(*l_itr))) + { + delete (*l_itr); + l_itr = iv_overrides.erase(l_itr); + } + else + { + ++l_itr; + } + } + + if (iv_overrides.empty()) + { + iv_overridesExist = false; + } + + platUnlock(); +} + +//****************************************************************************** +// setOverride +//****************************************************************************** +void AttributeOverrides::setOverride(const AttributeOverride & i_override) +{ + if (i_override.iv_overrideType == ATTR_OVERRIDE_CLEAR_ALL) + { + clearOverrides(); + } + else + { + FAPI_IMP("Set Override. ID: 0x%x, Val: 0x%llx, Type: %d", + i_override.iv_attrId, i_override.iv_overrideVal, + i_override.iv_overrideType); + FAPI_INF("Set Override. Target Type: 0x%x, Pos: 0x%x, UPos: 0x%x", + i_override.iv_targetType, i_override.iv_pos, + i_override.iv_unitPos); + FAPI_INF("Set Override. Array Dims: %d.%d.%d.%d", + i_override.iv_arrayD1, i_override.iv_arrayD2, + i_override.iv_arrayD3, i_override.iv_arrayD4); + + AttributeOverride * l_pOverride = new AttributeOverride(); + *l_pOverride = i_override; + + platLock(); + iv_overridesExist = true; + iv_overrides.push_back(l_pOverride); + platUnlock(); + } +} + +//****************************************************************************** +// getOverride +//****************************************************************************** +bool AttributeOverrides::getOverride(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + uint64_t & o_overrideVal, + const uint8_t i_arrayD1, + const uint8_t i_arrayD2, + const uint8_t i_arrayD3, + const uint8_t i_arrayD4) +{ + // Do a quick check to see if any overrides exist. This is deliberately done + // without a lock for performance. Overrides should not be changed while + // HWPs are getting attributes, but even if they are there is no risk of + // corruption. + if (!iv_overridesExist) + { + return false; + } + + platLock(); + bool l_found = false; + + for (OverridesCItr_t l_itr = iv_overrides.begin(); l_itr + != iv_overrides.end(); ++l_itr) + { + if (overrideMatch(i_attrId, i_pTarget, *(*l_itr))) + { + // Check the array dimensions + if (((*l_itr)->iv_arrayD1 == i_arrayD1) && + ((*l_itr)->iv_arrayD2 == i_arrayD2) && + ((*l_itr)->iv_arrayD3 == i_arrayD3) && + ((*l_itr)->iv_arrayD4 == i_arrayD4)) + { + l_found = true; + o_overrideVal = (*l_itr)->iv_overrideVal; + FAPI_IMP("Returning HWPF Attribute Override, 0x%x = 0x%llx", + i_attrId, o_overrideVal); + break; + } + } + } + + platUnlock(); + return l_found; +} + +//****************************************************************************** +// overridesExist +//****************************************************************************** +bool AttributeOverrides::overridesExist() +{ + platLock(); + bool l_overridesExist = iv_overridesExist; + platUnlock(); + return l_overridesExist; +} + +//****************************************************************************** +// overrideMatch +//****************************************************************************** +bool AttributeOverrides::overrideMatch( + const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + const AttributeOverride & i_candidate) +{ + // Note that any errors querying a parent chip or a position attribute are + // dropped and the function returns false (attribute is not a match) + + // Check the Attribute ID + if (i_candidate.iv_attrId != static_cast<uint32_t>(i_attrId)) + { + return false; + } + + // Check the Target Type + if (i_pTarget == NULL) + { + if (i_candidate.iv_targetType != + static_cast<uint32_t>(TARGET_TYPE_SYSTEM)) + { + return false; + } + } + else if (i_candidate.iv_targetType != + static_cast<uint32_t>(i_pTarget->getType())) + { + return false; + } + + // Check the Target position if applicable and not the system Target + if ((i_candidate.iv_pos != ATTR_POS_NA) && + (i_pTarget != NULL) && + (i_pTarget->getType() != TARGET_TYPE_SYSTEM)) + { + ReturnCode l_rc; + uint32_t l_pos = 0xffffffff; + + if (i_pTarget->isChiplet()) + { + // Target is a chiplet, iv_pos is the parent chip position + Target l_chip; + + l_rc = fapiGetParentChip(*i_pTarget, l_chip); + + if (l_rc) + { + FAPI_ERR("Error (0x%x) from fapiGetParentChip", + static_cast<uint32_t>(l_rc)); + return false; + } + + l_rc = FAPI_ATTR_GET(ATTR_POS, &l_chip, l_pos); + + if (l_rc) + { + FAPI_ERR("Error (0x%x) getting parent chip position attr", + static_cast<uint32_t>(l_rc)); + return false; + } + } + else + { + // Target is not a chiplet, iv_pos is the Target position + l_rc = FAPI_ATTR_GET(ATTR_POS, i_pTarget, l_pos); + + if (l_rc) + { + FAPI_ERR("Error (0x%x) getting position attr", + static_cast<uint32_t>(l_rc)); + return false; + } + } + + if (i_candidate.iv_pos != l_pos) + { + return false; + } + } + + // Check the Unit Target position if applicable and a unit Target + if ((i_candidate.iv_unitPos != ATTR_UNIT_POS_NA) && + (i_pTarget != NULL) && + (i_pTarget->isChiplet())) + { + ReturnCode l_rc; + uint8_t l_unitPos = 0xff; + + l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS, i_pTarget, l_unitPos); + + if (l_rc) + { + FAPI_ERR("Error (0x%x) getting chiplet position attr", + static_cast<uint32_t>(l_rc)); + return false; + } + + if (i_candidate.iv_unitPos != l_unitPos) + { + return false; + } + } + + // Match + return true; +} + +} diff --git a/src/usr/hwpf/fapi/makefile b/src/usr/hwpf/fapi/makefile index 9df36f54c..5b3db9e72 100644 --- a/src/usr/hwpf/fapi/makefile +++ b/src/usr/hwpf/fapi/makefile @@ -35,7 +35,8 @@ OBJS = fapiReturnCode.o \ fapiHwAccess.o \ fapiErrorInfo.o \ fapiAttributeService.o \ - fapiChipEcFeature.o + fapiChipEcFeature.o \ + fapiAttributeOverride.o include ${ROOTPATH}/config.mk diff --git a/src/usr/hwpf/hwp/chip_attributes.xml b/src/usr/hwpf/hwp/chip_attributes.xml index 8a71d5bde..eb1ef23c3 100644 --- a/src/usr/hwpf/hwp/chip_attributes.xml +++ b/src/usr/hwpf/hwp/chip_attributes.xml @@ -1,11 +1,11 @@ <!-- IBM_PROLOG_BEGIN_TAG This is an automatically generated prolog. - $Source: src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml $ + $Source: src/usr/hwpf/hwp/chip_attributes.xml $ IBM CONFIDENTIAL - COPYRIGHT International Business Machines Corp. 2011 + COPYRIGHT International Business Machines Corp. 2011-2012 p1 @@ -19,7 +19,7 @@ Origin: 30 - IBM_PROLOG_END --> + IBM_PROLOG_END_TAG --> <!-- XML file specifying HWPF attributes. These are platInit attributes associated with chips. @@ -28,6 +28,16 @@ <attributes> <!-- ********************************************************************* --> <attribute> + <id>ATTR_POS</id> + <targetType>TARGET_TYPE_PROC_CHIP,TARGET_TYPE_MEMBUF_CHIP,TARGET_TYPE_DIMM</targetType> + <description> + Position of chip/dimm relative to drawer + </description> + <valueType>uint32</valueType> + <platInit/> + </attribute> + <!-- ********************************************************************* --> + <attribute> <id>ATTR_CHIP_ID</id> <targetType>TARGET_TYPE_PROC_CHIP,TARGET_TYPE_MEMBUF_CHIP</targetType> <description> diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C index 0d22b984b..021502f39 100755 --- a/src/usr/hwpf/hwp/fapiTestHwpAttr.C +++ b/src/usr/hwpf/hwp/fapiTestHwpAttr.C @@ -1,25 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/hwpf/hwp/fapiTestHwpAttr.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// p1 -// -// Object Code Only (OCO) source materials -// Licensed Internal Code Source Materials -// IBM HostBoot Licensed Internal Code -// -// The source code for this program is not published or other- -// wise divested of its trade secrets, irrespective of what has -// been deposited with the U.S. Copyright Office. -// -// Origin: 30 -// -// IBM_PROLOG_END +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/hwp/fapiTestHwpAttr.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2011-2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ /** * @file fapiTestHwpAttr.C * @@ -885,7 +886,6 @@ fapi::ReturnCode hwpTestAttributes() FAPI_INF("hwpTestAttributes: Deleting expected error 0x%x from fapiGetInitFileAttr", static_cast<uint32_t>(l_rc)); l_rc = fapi::FAPI_RC_SUCCESS; - break; } else { @@ -929,7 +929,264 @@ fapi::ReturnCode hwpTestAttributes() //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_array); //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_array); } + + //---------------------------------------------------------------------- + // Test non-const Attribute Override on ATTR_SCRATCH_UINT64_1 + //---------------------------------------------------------------------- + { + if (fapi::platAttrSvc::overridesExistWrap()) + { + FAPI_INF("hwpTestAttributes: OverrideUint64. Overrides exist, skipping test"); + } + else + { + // Set the attribute to a known value + uint64_t l_val = 4; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from SET"); + break; + } + + // Create an non-const override + fapi::AttributeOverride l_override; + l_override.iv_overrideVal = 9; + l_override.iv_attrId = + static_cast<uint32_t>(fapi::ATTR_SCRATCH_UINT64_1); + l_override.iv_targetType = + static_cast<uint32_t>(fapi::TARGET_TYPE_SYSTEM); + l_override.iv_pos = fapi::ATTR_POS_NA; + l_override.iv_unitPos = fapi::ATTR_UNIT_POS_NA; + l_override.iv_overrideType = fapi::ATTR_OVERRIDE_NON_CONST; + l_override.iv_arrayD1 = fapi::ATTR_ARRAYD_NA; + l_override.iv_arrayD2 = fapi::ATTR_ARRAYD_NA; + l_override.iv_arrayD3 = fapi::ATTR_ARRAYD_NA; + l_override.iv_arrayD4 = fapi::ATTR_ARRAYD_NA; + fapi::platAttrSvc::setOverrideWrap(l_override); + + // Check that the override value is returned + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from GET"); + break; + } + + if (l_val != 9) + { + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); + FAPI_ERR("hwpTestAttributes: OverrideUint64 GET returned %d", + static_cast<uint32_t>(l_val)); + break; + } + + // Set the attribute to a known value + l_val = 8; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from SET (2)"); + break; + } + + // Check that the override was cancelled (it is a non-const override) + l_val = 0; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from GET (2)"); + break; + } + + if (l_val != 8) + { + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); + FAPI_ERR("hwpTestAttributes: OverrideUint64 GET returned %d (2)", + static_cast<uint32_t>(l_val)); + break; + } + + // Clear all overrides + fapi::platAttrSvc::clearOverridesWrap(); + } + } + //---------------------------------------------------------------------- + // Test const Attribute Override on ATTR_SCRATCH_UINT8_1 + //---------------------------------------------------------------------- + { + if (fapi::platAttrSvc::overridesExistWrap()) + { + FAPI_INF("hwpTestAttributes: OverrideUint8. Overrides exist, skipping test"); + } + else + { + // Set the attribute to a known value + uint8_t l_val = 1; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from SET"); + break; + } + + // Create a const override + fapi::AttributeOverride l_override; + l_override.iv_overrideVal = 2; + l_override.iv_attrId = + static_cast<uint32_t>(fapi::ATTR_SCRATCH_UINT8_1); + l_override.iv_targetType = + static_cast<uint32_t>(fapi::TARGET_TYPE_SYSTEM); + l_override.iv_pos = fapi::ATTR_POS_NA; + l_override.iv_unitPos = fapi::ATTR_UNIT_POS_NA; + l_override.iv_overrideType = fapi::ATTR_OVERRIDE_CONST; + l_override.iv_arrayD1 = fapi::ATTR_ARRAYD_NA; + l_override.iv_arrayD2 = fapi::ATTR_ARRAYD_NA; + l_override.iv_arrayD3 = fapi::ATTR_ARRAYD_NA; + l_override.iv_arrayD4 = fapi::ATTR_ARRAYD_NA; + fapi::platAttrSvc::setOverrideWrap(l_override); + + // Check that the override value is returned + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from GET"); + break; + } + + if (l_val != 2) + { + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); + FAPI_ERR("hwpTestAttributes: OverrideUint8 GET returned %d", + l_val); + break; + } + + // Set the attribute to a known value + l_val = 3; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from SET (2)"); + break; + } + + // Check that the override value is still returned + l_val = 0; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from GET (2)"); + break; + } + + if (l_val != 2) + { + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); + FAPI_ERR("hwpTestAttributes: OverrideUint8 GET returned %d (2)", + l_val); + break; + } + + // Clear all overrides + fapi::platAttrSvc::clearOverridesWrap(); + + // Check that the real value is now returned + l_val = 0; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from GET (3)"); + break; + } + + if (l_val != 3) + { + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); + FAPI_ERR("hwpTestAttributes: OverrideUint8 GET returned %d (3)", + l_val); + break; + } + } + } + + + //---------------------------------------------------------------------- + // Test non-const Attribute Override on ATTR_SCRATCH_UINT64_ARRAY_2 + //---------------------------------------------------------------------- + { + if (fapi::platAttrSvc::overridesExistWrap()) + { + FAPI_INF("hwpTestAttributes: OverrideUint64array. Overrides exist, skipping test"); + } + else + { + // Create a non-const override + fapi::AttributeOverride l_override; + l_override.iv_attrId = + static_cast<uint32_t>(fapi::ATTR_SCRATCH_UINT64_ARRAY_2); + l_override.iv_targetType = + static_cast<uint32_t>(fapi::TARGET_TYPE_SYSTEM); + l_override.iv_pos = fapi::ATTR_POS_NA; + l_override.iv_unitPos = fapi::ATTR_UNIT_POS_NA; + l_override.iv_overrideType = fapi::ATTR_OVERRIDE_NON_CONST; + l_override.iv_arrayD3 = fapi::ATTR_ARRAYD_NA; + l_override.iv_arrayD4 = fapi::ATTR_ARRAYD_NA; + + l_override.iv_overrideVal = 20; + l_override.iv_arrayD1 = 0; + l_override.iv_arrayD2 = 0; + fapi::platAttrSvc::setOverrideWrap(l_override); + + l_override.iv_overrideVal = 21; + l_override.iv_arrayD1 = 0; + l_override.iv_arrayD2 = 1; + fapi::platAttrSvc::setOverrideWrap(l_override); + + l_override.iv_overrideVal = 22; + l_override.iv_arrayD1 = 1; + l_override.iv_arrayD2 = 0; + fapi::platAttrSvc::setOverrideWrap(l_override); + + l_override.iv_overrideVal = 0xfffffffe; + l_override.iv_arrayD1 = 1; + l_override.iv_arrayD2 = 1; + fapi::platAttrSvc::setOverrideWrap(l_override); + + // Check that the override value is returned + uint64_t l_val[2][2]; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_val); + + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: OverrideUint64array. Error from GET"); + break; + } + + if ((l_val[0][0] != 20) || (l_val[0][1] != 21) || + (l_val[1][0] != 22) || (l_val[1][1] != 0xfffffffe)) + { + FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); + FAPI_ERR("hwpTestAttributes: OverrideUint64array GET returned 0x%llx:0x%llx:0x%llx:0x%llx", + l_val[0][0], l_val[0][1], l_val[1][0], l_val[1][1]); + break; + } + + // Clear all overrides + fapi::platAttrSvc::clearOverridesWrap(); + } + } + } while (0); FAPI_INF("hwpTestAttributes: End HWP"); diff --git a/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C b/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C new file mode 100644 index 000000000..436a63477 --- /dev/null +++ b/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C @@ -0,0 +1,56 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ +/** + * @file fapiPlatAttrOverrideDirect.C + * + * @brief Defines a PLAT function that applies a HWPF Attribute Override + * written directly into Hostboot memory from the Simics/VBU console + */ + +//****************************************************************************** +// Includes +//****************************************************************************** +#include <util/singleton.H> +#include <hwpf/fapi/fapiAttributeOverride.H> + +namespace fapi +{ + +//****************************************************************************** +// Global Variables +//****************************************************************************** +AttributeOverride g_attrOverride; + +//****************************************************************************** +// platAttrOverrideDirect +// 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 platAttrOverrideDirect() +{ + // Apply the attribute override + Singleton<fapi::AttributeOverrides>::instance().setOverride(g_attrOverride); +} + +} diff --git a/src/usr/hwpf/plat/fapiPlatAttributeService.C b/src/usr/hwpf/plat/fapiPlatAttributeService.C index c08da58cd..75cff6ced 100644 --- a/src/usr/hwpf/plat/fapiPlatAttributeService.C +++ b/src/usr/hwpf/plat/fapiPlatAttributeService.C @@ -56,6 +56,90 @@ namespace platAttrSvc { //****************************************************************************** +// fapi::platAttrSvc::getHostbootTarget +//****************************************************************************** +fapi::ReturnCode getHostbootTarget( + const fapi::Target* i_pFapiTarget, + TARGETING::Target* & o_pTarget, + const TARGETING::TYPE i_expectedType = TARGETING::TYPE_NA) +{ + fapi::ReturnCode l_rc; + + // Check that the FAPI Target pointer is not NULL + if (i_pFapiTarget == NULL) + { + FAPI_ERR("getHostbootTarget. NULL FAPI Target passed"); + + /*@ + * @errortype + * @moduleid MOD_ATTR_GET_HB_TARGET + * @reasoncode RC_NULL_FAPI_TARGET + * @devdesc NULL FAPI Target passed to attribute access macro + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + fapi::MOD_ATTR_GET_HB_TARGET, + fapi::RC_NULL_FAPI_TARGET); + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); + } + else + { + // Extract the Hostboot Target pointer + o_pTarget = reinterpret_cast<TARGETING::Target*>(i_pFapiTarget->get()); + + // Check that the Hostboot Target pointer is not NULL + if (o_pTarget == NULL) + { + FAPI_ERR("getHostbootTarget. NULL Hostbot Target passed"); + + /*@ + * @errortype + * @moduleid MOD_ATTR_GET_HB_TARGET + * @reasoncode RC_EMBEDDED_NULL_TARGET_PTR + * @devdesc NULL HOSTBOOT Target passed to attribute access macro + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + fapi::MOD_ATTR_GET_HB_TARGET, + fapi::RC_EMBEDDED_NULL_TARGET_PTR); + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); + } + else + { + // Check that the Target Type is as expected + if (i_expectedType != TARGETING::TYPE_NA) + { + TARGETING::TYPE l_type = + o_pTarget->getAttr<TARGETING::ATTR_TYPE>(); + + if (l_type != i_expectedType) + { + FAPI_ERR("getHostbootTarget. Type: %d, expected %d", + l_type, i_expectedType); + + /*@ + * @errortype + * @moduleid MOD_ATTR_GET_HB_TARGET + * @reasoncode RC_UNEXPECTED_TARGET_TYPE + * @userdata1 Target Type + * @userdata2 Expected Target Type + * @devdesc Unexpected Target Type passed to attribute access macro + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + fapi::MOD_ATTR_GET_HB_TARGET, + fapi::RC_UNEXPECTED_TARGET_TYPE, + l_type, i_expectedType); + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); + } + } + } + } + + return l_rc; +} + +//****************************************************************************** // fapi::platAttrSvc::getSystemTarget //****************************************************************************** @@ -438,7 +522,120 @@ fapi::ReturnCode fapiPlatGetFunctional(const fapi::Target * i_pTarget, return l_rc; } +//****************************************************************************** +// fapi::platAttrSvc::fapiPlatGetTargetPos function +//****************************************************************************** +fapi::ReturnCode fapiPlatGetTargetPos(const fapi::Target * i_pFapiTarget, + uint32_t & o_pos) +{ + fapi::ReturnCode l_rc; + TARGETING::Target * l_pTarget = NULL; + + // Get the Hostboot Target + l_rc = getHostbootTarget(i_pFapiTarget, l_pTarget); + + if (l_rc) + { + FAPI_ERR("getTargetName: Error getting Hostboot Target"); + } + else + { + uint16_t l_pos = l_pTarget->getAttr<TARGETING::ATTR_POSITION>(); + o_pos = l_pos; + } + + return l_rc; +} + +//****************************************************************************** +// fapi::platAttrSvc::getOverrideWrap function +//****************************************************************************** +bool getOverrideWrap(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + uint64_t & o_overrideVal, + const uint8_t i_arrayD1, + const uint8_t i_arrayD2, + const uint8_t i_arrayD3, + const uint8_t i_arrayD4) +{ + return Singleton<fapi::AttributeOverrides>::instance().getOverride( + i_attrId, i_pTarget, o_overrideVal, i_arrayD1, i_arrayD2, i_arrayD3, + i_arrayD4); +} + +//****************************************************************************** +// fapi::platAttrSvc::clearNonConstOverrideWrap function +//****************************************************************************** +void clearNonConstOverrideWrap(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget) +{ + Singleton<fapi::AttributeOverrides>::instance().clearNonConstOverride( + i_attrId, i_pTarget); +} + +//****************************************************************************** +// fapi::platAttrSvc::setOverrideWrap function +//****************************************************************************** +void setOverrideWrap(const AttributeOverride & i_override) +{ + Singleton<fapi::AttributeOverrides>::instance().setOverride(i_override); +} + +//****************************************************************************** +// fapi::platAttrSvc::clearOverridesWrap function +//****************************************************************************** +void clearOverridesWrap() +{ + Singleton<fapi::AttributeOverrides>::instance().clearOverrides(); +} + +//****************************************************************************** +// fapi::platAttrSvc::overridesExistWrap function +//****************************************************************************** +bool overridesExistWrap() +{ + return Singleton<fapi::AttributeOverrides>::instance().overridesExist(); +} + +//****************************************************************************** +// fapi::platAttrSvc::AttributeOverridesLock class +// This is a simple container for a mutex +//****************************************************************************** +class AttributeOverridesLock +{ +public: + AttributeOverridesLock() + { + mutex_init(&iv_mutex); + } + + ~AttributeOverridesLock() + { + mutex_destroy(&iv_mutex); + } + mutex_t iv_mutex; +}; } // End platAttrSvc namespace +//****************************************************************************** +// fapi::AttributeOverrides::platLock function +// This is the Hostboot PLAT implementation of the FAPI function +//****************************************************************************** +void AttributeOverrides::platLock() +{ + mutex_lock(&(Singleton + <fapi::platAttrSvc::AttributeOverridesLock>::instance().iv_mutex)); +} + +//****************************************************************************** +// fapi::AttributeOverrides::platUnlock function +// This is the Hostboot PLAT implementation of the FAPI function +//****************************************************************************** +void AttributeOverrides::platUnlock() +{ + mutex_unlock(&(Singleton + <fapi::platAttrSvc::AttributeOverridesLock>::instance().iv_mutex)); +} + } // End fapi namespace diff --git a/src/usr/hwpf/plat/fapiPlatTask.C b/src/usr/hwpf/plat/fapiPlatTask.C new file mode 100644 index 000000000..dfab334a9 --- /dev/null +++ b/src/usr/hwpf/plat/fapiPlatTask.C @@ -0,0 +1,63 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/plat/fapiPlatTask.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ +/** + * @file fapiPlatTask.C + * + * @brief Performs the Hostboot fapi::plat startup task + */ + +//****************************************************************************** +// Includes +//****************************************************************************** +#include <sys/task.h> +#include <initservice/taskargs.H> +#include <hwpf/fapi/fapiAttributeOverride.H> +#include <fapiPlatTrace.H> + +namespace fapi +{ + +//****************************************************************************** +// Global Variables +//****************************************************************************** +// Defined in fapiPlatAttrOverrideDirect.C +extern AttributeOverride g_attrOverride; + +//****************************************************************************** +// platTaskEntry +// This function writes the g_attrOverride global variable first written by the +// Simics/VBU console and then read by fapiPlatAttrOverrideDirect.C to ensure +// it is paged and pinned in memory +//****************************************************************************** +void platTaskEntry(errlHndl_t &io_errl) +{ + FAPI_IMP("Starting platTaskEntry"); + g_attrOverride.iv_overrideVal = 0; + task_end(); +} + +// Macro that creates the _start function +TASK_ENTRY_MACRO(fapi::platTaskEntry); + +} // End fapi namespace diff --git a/src/usr/hwpf/plat/makefile b/src/usr/hwpf/plat/makefile index 5fd92402a..1056e9ecd 100644 --- a/src/usr/hwpf/plat/makefile +++ b/src/usr/hwpf/plat/makefile @@ -35,6 +35,8 @@ OBJS = fapiPlatHwAccess.o \ fapiPlatTarget.o \ fapiPlatUtil.o \ fapiPlatAttributeService.o \ - fapiMvpdAccess.o + fapiMvpdAccess.o \ + fapiPlatTask.o \ + fapiPlatAttrOverrideDirect.o include ${ROOTPATH}/config.mk diff --git a/src/usr/initservice/extinitsvc/extinitsvctasks.H b/src/usr/initservice/extinitsvc/extinitsvctasks.H index 4a0ae8c17..a15e5fd73 100644 --- a/src/usr/initservice/extinitsvc/extinitsvctasks.H +++ b/src/usr/initservice/extinitsvc/extinitsvctasks.H @@ -213,7 +213,7 @@ const TaskInfo g_exttaskinfolist[] = { "libplat.so" , // taskname NULL, // no pointer to fn { - INIT_TASK, // task type + START_TASK, // task type EXT_IMAGE, // Extended Module } }, |